From 8aec8807c9df260dc8c347d3d3d468a20465f33c Mon Sep 17 00:00:00 2001 From: Doug Brown Date: Sun, 28 May 2023 10:55:09 -0700 Subject: [PATCH] Fix line endings A whole bunch of files in this project had DOS line endings. This is due to how I started working on it on a Windows machine with little Git experience. Now it's inconsistent so I'm fixing it. --- .cproject | 582 +-- .project | 166 +- .settings/de.innot.avreclipse.core.prefs | 68 +- LICENSE.txt | 678 ++-- chip_id.h | 78 +- drivers/mcp23s17.c | 424 +- drivers/mcp23s17.h | 152 +- drivers/parallel_flash.c | 858 ++-- drivers/parallel_flash.h | 166 +- hal/at90usb646/Descriptors.c | 542 +-- hal/at90usb646/Descriptors.h | 178 +- .../LUFA/CodeTemplates/DriverStubs/Buttons.h | 176 +- .../CodeTemplates/DriverStubs/Dataflash.h | 436 +-- .../LUFA/CodeTemplates/DriverStubs/Joystick.h | 200 +- .../LUFA/CodeTemplates/DriverStubs/LEDs.h | 256 +- .../LUFA/CodeTemplates/LUFAConfig.h | 320 +- .../LUFA/CodeTemplates/makefile_template.avr8 | 1426 +++---- .../LUFA/CodeTemplates/makefile_template.uc3 | 972 ++--- .../CodeTemplates/makefile_template.xmega | 1410 +++---- .../LUFA/Common/ArchitectureSpecific.h | 296 +- hal/at90usb646/LUFA/Common/Architectures.h | 168 +- hal/at90usb646/LUFA/Common/Attributes.h | 300 +- hal/at90usb646/LUFA/Common/BoardTypes.h | 424 +- hal/at90usb646/LUFA/Common/Common.h | 750 ++-- hal/at90usb646/LUFA/Common/CompilerSpecific.h | 194 +- hal/at90usb646/LUFA/Common/Endianness.h | 978 ++--- hal/at90usb646/LUFA/Doxygen.conf | 3464 ++++++++--------- .../LUFA/DoxygenPages/AboutLUFA.txt | 40 +- .../LUFA/DoxygenPages/AlternativeStacks.txt | 138 +- .../BuildingLinkableLibraries.txt | 46 +- .../LUFA/DoxygenPages/ChangeLog.txt | 2734 ++++++------- .../LUFA/DoxygenPages/CompileTimeTokens.txt | 438 +-- .../LUFA/DoxygenPages/CompilingApps.txt | 60 +- .../LUFA/DoxygenPages/ConfiguringApps.txt | 178 +- .../LUFA/DoxygenPages/DevelopingWithLUFA.txt | 42 +- .../LUFA/DoxygenPages/DeviceSupport.txt | 780 ++-- .../LUFA/DoxygenPages/DirectorySummaries.txt | 508 +-- hal/at90usb646/LUFA/DoxygenPages/Donating.txt | 48 +- .../LUFA/DoxygenPages/FutureChanges.txt | 96 +- .../LUFA/DoxygenPages/GettingStarted.txt | 54 +- hal/at90usb646/LUFA/DoxygenPages/Groups.txt | 86 +- .../LUFA/DoxygenPages/LUFAPoweredProjects.txt | 312 +- .../LUFA/DoxygenPages/LUFAvsAtmelStack.txt | 104 +- .../LUFA/DoxygenPages/LibraryApps.txt | 256 +- .../LUFA/DoxygenPages/LibraryResources.txt | 66 +- .../LUFA/DoxygenPages/LicenseInfo.txt | 44 +- hal/at90usb646/LUFA/DoxygenPages/MainPage.txt | 96 +- .../DoxygenPages/MigrationInformation.txt | 1272 +++--- .../LUFA/DoxygenPages/ProgrammingApps.txt | 54 +- .../DoxygenPages/SoftwareBootloaderJump.txt | 142 +- .../LUFA/DoxygenPages/VIDAndPIDValues.txt | 848 ++-- .../LUFA/DoxygenPages/WhyUseLUFA.txt | 86 +- .../LUFA/DoxygenPages/WritingBoardDrivers.txt | 54 +- .../LUFA/Drivers/USB/Class/CDCClass.h | 160 +- .../Drivers/USB/Class/Common/CDCClassCommon.h | 772 ++-- .../Drivers/USB/Class/Device/CDCClassDevice.c | 730 ++-- .../Drivers/USB/Class/Device/CDCClassDevice.h | 714 ++-- .../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c | 106 +- .../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 528 +-- .../USB/Core/AVR8/EndpointStream_AVR8.c | 538 +-- .../USB/Core/AVR8/EndpointStream_AVR8.h | 1294 +++--- .../Drivers/USB/Core/AVR8/Endpoint_AVR8.c | 364 +- .../Drivers/USB/Core/AVR8/Endpoint_AVR8.h | 1746 ++++----- .../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 594 +-- .../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | 744 ++-- .../LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h | 318 +- .../Drivers/USB/Core/AVR8/PipeStream_AVR8.c | 430 +- .../Drivers/USB/Core/AVR8/PipeStream_AVR8.h | 882 ++--- .../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c | 362 +- .../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h | 1846 ++++----- .../Template/Template_Endpoint_Control_R.c | 168 +- .../Template/Template_Endpoint_Control_W.c | 186 +- .../Core/AVR8/Template/Template_Endpoint_RW.c | 178 +- .../USB/Core/AVR8/Template/Template_Pipe_RW.c | 176 +- .../USB/Core/AVR8/USBController_AVR8.c | 524 +-- .../USB/Core/AVR8/USBController_AVR8.h | 874 ++--- .../Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c | 550 +-- .../Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h | 738 ++-- .../LUFA/Drivers/USB/Core/ConfigDescriptor.c | 292 +- .../LUFA/Drivers/USB/Core/ConfigDescriptor.h | 570 +-- hal/at90usb646/LUFA/Drivers/USB/Core/Device.h | 318 +- .../LUFA/Drivers/USB/Core/DeviceStandardReq.c | 760 ++-- .../LUFA/Drivers/USB/Core/DeviceStandardReq.h | 318 +- .../LUFA/Drivers/USB/Core/Endpoint.h | 236 +- .../LUFA/Drivers/USB/Core/EndpointStream.h | 248 +- hal/at90usb646/LUFA/Drivers/USB/Core/Events.c | 78 +- hal/at90usb646/LUFA/Drivers/USB/Core/Events.h | 732 ++-- hal/at90usb646/LUFA/Drivers/USB/Core/Host.h | 278 +- .../LUFA/Drivers/USB/Core/HostStandardReq.c | 632 +-- .../LUFA/Drivers/USB/Core/HostStandardReq.h | 582 +-- hal/at90usb646/LUFA/Drivers/USB/Core/OTG.h | 160 +- hal/at90usb646/LUFA/Drivers/USB/Core/Pipe.h | 272 +- .../LUFA/Drivers/USB/Core/PipeStream.h | 200 +- .../LUFA/Drivers/USB/Core/StdDescriptors.h | 1478 +++---- .../LUFA/Drivers/USB/Core/StdRequestType.h | 516 +-- .../LUFA/Drivers/USB/Core/USBController.h | 266 +- .../LUFA/Drivers/USB/Core/USBInterrupt.h | 146 +- .../LUFA/Drivers/USB/Core/USBMode.h | 526 +-- .../LUFA/Drivers/USB/Core/USBTask.c | 182 +- .../LUFA/Drivers/USB/Core/USBTask.h | 408 +- hal/at90usb646/LUFA/Drivers/USB/USB.h | 828 ++-- hal/at90usb646/LUFA/License.txt | 36 +- hal/at90usb646/LUFA/Version.h | 104 +- hal/at90usb646/LUFA/makefile | 184 +- hal/at90usb646/board.c | 102 +- hal/at90usb646/board_hw.h | 80 +- hal/at90usb646/cdc_device_definition.c | 92 +- hal/at90usb646/cdc_device_definition.h | 60 +- hal/at90usb646/gpio.c | 232 +- hal/at90usb646/gpio_hw.h | 78 +- hal/at90usb646/hardware.h | 132 +- hal/at90usb646/parallel_bus.c | 1466 +++---- hal/at90usb646/spi.c | 398 +- hal/at90usb646/spi_private.h | 74 +- hal/at90usb646/usbcdc.c | 146 +- hal/at90usb646/usbcdc_hw.h | 166 +- hal/board.h | 76 +- hal/gpio.h | 144 +- hal/parallel_bus.h | 122 +- hal/spi.h | 150 +- hal/usbcdc.h | 84 +- led.h | 130 +- main.c | 142 +- programmer_protocol.h | 372 +- simm_programmer.c | 1326 +++---- simm_programmer.h | 62 +- tests/simm_electrical_test.c | 946 ++--- tests/simm_electrical_test.h | 64 +- util.h | 62 +- 129 files changed, 28411 insertions(+), 28411 deletions(-) diff --git a/.cproject b/.cproject index 48e4975..f01bbf6 100644 --- a/.cproject +++ b/.cproject @@ -1,291 +1,291 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project index 6f14074..d6845e1 100644 --- a/.project +++ b/.project @@ -1,83 +1,83 @@ - - - SIMMProgrammer - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/SIMMProgrammer/Release} - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - de.innot.avreclipse.core.avrnature - - + + + SIMMProgrammer + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/SIMMProgrammer/Release} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + de.innot.avreclipse.core.avrnature + + diff --git a/.settings/de.innot.avreclipse.core.prefs b/.settings/de.innot.avreclipse.core.prefs index b395909..87bd1a6 100644 --- a/.settings/de.innot.avreclipse.core.prefs +++ b/.settings/de.innot.avreclipse.core.prefs @@ -1,34 +1,34 @@ -#Sat Mar 03 13:46:14 PST 2012 -avrtarget/ClockFrequency=16000000 -avrtarget/ExtRAMSize=0 -avrtarget/ExtendedRAM=false -avrtarget/MCUType=at90usb646 -avrtarget/UseEEPROM=false -avrtarget/UseExtendedRAMforHeap=true -avrtarget/avrdude/BitBangDelay= -avrtarget/avrdude/Bitclock= -avrtarget/avrdude/EEPROMFile= -avrtarget/avrdude/EEPROMFromConfig=true -avrtarget/avrdude/FlashFile= -avrtarget/avrdude/FlashFromConfig=true -avrtarget/avrdude/Fuses/ByteValues=223\:208\:248 -avrtarget/avrdude/Fuses/FileName= -avrtarget/avrdude/Fuses/MCUid=at90usb646 -avrtarget/avrdude/Fuses/UseFile=false -avrtarget/avrdude/Fuses/Write=true -avrtarget/avrdude/Locks/ByteValues=-1 -avrtarget/avrdude/Locks/FileName= -avrtarget/avrdude/Locks/MCUid=at90usb646 -avrtarget/avrdude/Locks/UseFile=false -avrtarget/avrdude/Locks/Write=false -avrtarget/avrdude/NoChipErase=false -avrtarget/avrdude/NoSigCheck=false -avrtarget/avrdude/NoVerify=false -avrtarget/avrdude/NoWrite=false -avrtarget/avrdude/OtherOptions= -avrtarget/avrdude/ProgrammerID=programmerconfig.1 -avrtarget/avrdude/UseCounter=false -avrtarget/avrdude/WriteEEPROM=false -avrtarget/avrdude/WriteFlash=true -avrtarget/perConfig=false -eclipse.preferences.version=1 +#Sat Mar 03 13:46:14 PST 2012 +avrtarget/ClockFrequency=16000000 +avrtarget/ExtRAMSize=0 +avrtarget/ExtendedRAM=false +avrtarget/MCUType=at90usb646 +avrtarget/UseEEPROM=false +avrtarget/UseExtendedRAMforHeap=true +avrtarget/avrdude/BitBangDelay= +avrtarget/avrdude/Bitclock= +avrtarget/avrdude/EEPROMFile= +avrtarget/avrdude/EEPROMFromConfig=true +avrtarget/avrdude/FlashFile= +avrtarget/avrdude/FlashFromConfig=true +avrtarget/avrdude/Fuses/ByteValues=223\:208\:248 +avrtarget/avrdude/Fuses/FileName= +avrtarget/avrdude/Fuses/MCUid=at90usb646 +avrtarget/avrdude/Fuses/UseFile=false +avrtarget/avrdude/Fuses/Write=true +avrtarget/avrdude/Locks/ByteValues=-1 +avrtarget/avrdude/Locks/FileName= +avrtarget/avrdude/Locks/MCUid=at90usb646 +avrtarget/avrdude/Locks/UseFile=false +avrtarget/avrdude/Locks/Write=false +avrtarget/avrdude/NoChipErase=false +avrtarget/avrdude/NoSigCheck=false +avrtarget/avrdude/NoVerify=false +avrtarget/avrdude/NoWrite=false +avrtarget/avrdude/OtherOptions= +avrtarget/avrdude/ProgrammerID=programmerconfig.1 +avrtarget/avrdude/UseCounter=false +avrtarget/avrdude/WriteEEPROM=false +avrtarget/avrdude/WriteFlash=true +avrtarget/perConfig=false +eclipse.preferences.version=1 diff --git a/LICENSE.txt b/LICENSE.txt index 89e08fb..d159169 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,339 +1,339 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, 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. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, 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 or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -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 give any other recipients of the Program a copy of this License -along with the Program. - -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 Program or any portion -of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -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 Program, 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 Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) 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; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, 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 executable. However, as a -special exception, the source code 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. - -If distribution of executable or 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 counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program 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. - - 5. 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 Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program 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 to -this License. - - 7. 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 Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program 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 Program. - -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. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program 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. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 Program -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 Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, 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 - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), 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 Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. 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. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), 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 Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/chip_id.h b/chip_id.h index 9e06964..76e1a56 100644 --- a/chip_id.h +++ b/chip_id.h @@ -1,39 +1,39 @@ -/* - * chip_id.h - * - * Created on: Dec 10, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef CHIP_ID_H_ -#define CHIP_ID_H_ - -#define SST_GREENLIANT 0xBF - #define GLS29EE010 0x07 - #define GLS29SF020 0x24 - #define GLS29SF040 0x13 - #define SST39SF010A 0xB5 - #define SST39SF020A 0xB6 - #define SST39SF040 0xB7 - -#define AMD 0x01 - #define AM29F040B 0xA4 - -#endif /* CHIP_ID_H_ */ +/* + * chip_id.h + * + * Created on: Dec 10, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CHIP_ID_H_ +#define CHIP_ID_H_ + +#define SST_GREENLIANT 0xBF + #define GLS29EE010 0x07 + #define GLS29SF020 0x24 + #define GLS29SF040 0x13 + #define SST39SF010A 0xB5 + #define SST39SF020A 0xB6 + #define SST39SF040 0xB7 + +#define AMD 0x01 + #define AM29F040B 0xA4 + +#endif /* CHIP_ID_H_ */ diff --git a/drivers/mcp23s17.c b/drivers/mcp23s17.c index 52a6787..32eadbc 100644 --- a/drivers/mcp23s17.c +++ b/drivers/mcp23s17.c @@ -1,212 +1,212 @@ -/* - * mcp23s17.c - * - * Created on: Nov 25, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "mcp23s17.h" -#include "hardware.h" - -/// Maximum SPI clock rate = 10 MHz -#define MCP23S17_MAX_CLOCK 10000000UL - -static void MCP23S17_WriteBothRegs(MCP23S17 *mcp, uint8_t addrA, uint16_t value); -static uint16_t MCP23S17_ReadBothRegs(MCP23S17 *mcp, uint8_t addrA); - -/** Initializes an MCP23S17 object - * - * @param mcp The MCP23S17 object to initialize - * @param resetPin The GPIO pin hooked to the reset input - */ -void MCP23S17_Init(MCP23S17 *mcp, GPIOPin resetPin) -{ - SPI_InitDevice(&mcp->spi, MCP23S17_MAX_CLOCK, SPI_MODE_0); - - // Do a reset pulse if we need to. No need to save the reset pin - // after that. - if (!GPIO_IsNull(resetPin)) - { - GPIO_SetDirection(resetPin, true); - GPIO_SetOff(resetPin); - DelayUS(1); - GPIO_SetOn(resetPin); - DelayUS(1); - } -} - -/** Begins a set of transactions with the MCP23S17. - * - * @param mcp The MCP23S17 to talk with - * - * You have to call this before using any of the MCP23S17 functions other than - * init. This takes control of the SPI bus. If the MCP23S17 is the only device - * on the bus, you can just call this once in the program. Otherwise, you should - * release it as soon as you're done so other SPI devices can use the bus instead. - */ -void MCP23S17_Begin(MCP23S17 *mcp) -{ - SPI_RequestBus(&mcp->spi); -} - -/** Ends a set of transactions with the MCP23S17. - * - * @param mcp The MCP23S17 to release - * - * You should call this when you're done talking to the MCP23S17 to free up the - * SPI bus for other devices. - */ -void MCP23S17_End(MCP23S17 *mcp) -{ - SPI_ReleaseBus(&mcp->spi); -} - -/** Sets the data direction register in the MCP23S17 - * - * @param mcp The MCP23S17 - * @param ddr Bitmask representing direction of the 16 GPIO pins (1 = output, 0 = input) - */ -void MCP23S17_SetDDR(MCP23S17 *mcp, uint16_t ddr) -{ - // The MCP23S17's DDR is backwards from most other chips. I like dealing - // with it so it behaves like other MCUs, so I invert any DDR values in this - // driver. In other words, when you set or get the DDR through this driver, - // the 1s and 0s are backwards from what the MCP23S17's datasheet says, but - // they are consistent with most MCUs. I value the consistency more. - MCP23S17_WriteBothRegs(mcp, MCP23S17_IODIRA, ~ddr); -} - -/** Reads the data direction register in the MCP23S17 - * - * @param mcp The MCP23S17 - * @return Bitmask representing direction of the 16 GPIO pins (1 = output, 0 = input) - */ -uint16_t MCP23S17_DDR(MCP23S17 *mcp) -{ - // As I mentioned above, DDR bits are inverted from what the MCP23S17's - // datasheet says, but consistent with most MCUs - return ~MCP23S17_ReadBothRegs(mcp, MCP23S17_IODIRA); -} - -/** Sets the output values in the MCP23S17 - * - * @param mcp The MCP23S17 - * @param data Bitmask representing output state of the 16 GPIO pins (1 = high, 0 = low) - */ -void MCP23S17_SetOutputs(MCP23S17 *mcp, uint16_t data) -{ - MCP23S17_WriteBothRegs(mcp, MCP23S17_GPIOA, data); -} - -/** Gets the current output values in the MCP23S17 - * - * @param mcp The MCP23S17 - * @return Bitmask representing output state of the 16 GPIO pins (1 = high, 0 = low) - */ -uint16_t MCP23S17_Outputs(MCP23S17 *mcp) -{ - return MCP23S17_ReadBothRegs(mcp, MCP23S17_OLATA); -} - -/** Reads the current input values in the MCP23S17 - * - * @param mcp The MCP23S17 - * @return Bitmask representing input state of the 16 GPIO pins (1 = high, 0 = low) - */ -uint16_t MCP23S17_ReadInputs(MCP23S17 *mcp) -{ - return MCP23S17_ReadBothRegs(mcp, MCP23S17_GPIOA); -} - -/** Enables/disables pullups in the MCP23S17 - * - * @param mcp The MCP23S17 - * @param pullups Bitmask representing which input pins should have pullups enabled. - */ -void MCP23S17_SetPullups(MCP23S17 *mcp, uint16_t pullups) -{ - MCP23S17_WriteBothRegs(mcp, MCP23S17_GPPUA, pullups); -} - -/** Reads the current pullup state in the MCP23S17 - * - * @param mcp The MCP23S17 - * return Bitmask representing which input pins have pullups enabled. - */ -uint16_t MCP23S17_Pullups(MCP23S17 *mcp) -{ - return MCP23S17_ReadBothRegs(mcp, MCP23S17_GPPUA); -} - -/** Helper function that writes two consecutive registers in the MCP23S17 - * - * @param mcp The MCP23S17 - * @param addrA The address of the first ("A") register - * @param value The value to write to the A and B registers. High byte = A, low byte = B - */ -static void MCP23S17_WriteBothRegs(MCP23S17 *mcp, uint8_t addrA, uint16_t value) -{ - // addrA should contain the address of the "A" register. - // the chip should also be in "same bank" mode. - SPI_Assert(&mcp->spi); - - // Start off the communication by telling the MCP23S17 that we are writing to a register - SPI_RWByte(&mcp->spi, MCP23S17_CONTROL_WRITE(0)); - - // Tell it the first register we're writing to (the "A" register) - SPI_RWByte(&mcp->spi, addrA); - - // Write the first byte of the register - SPI_RWByte(&mcp->spi, (uint8_t)((value >> 8) & 0xFF)); - - // It should auto-increment to the "B" register, now write that - SPI_RWByte(&mcp->spi, (uint8_t)(value & 0xFF)); - - SPI_Deassert(&mcp->spi); -} - -/** Helper function that reads two consecutive registers in the MCP23S17 - * - * @param mcp The MCP23S17 - * @param addrA The address of the first ("A") register - * @return The value read back from the A and B registers. High byte = A, low byte = B - */ -static uint16_t MCP23S17_ReadBothRegs(MCP23S17 *mcp, uint8_t addrA) -{ - uint16_t returnVal; - - SPI_Assert(&mcp->spi); - - // Start off the communication by telling the MCP23S17 that we are reading from a register - SPI_RWByte(&mcp->spi, MCP23S17_CONTROL_READ(0)); - - // Tell it which register we're reading from (the "A" register) - SPI_RWByte(&mcp->spi, addrA); - - // Read the first byte of the register - returnVal = (((uint16_t)SPI_RWByte(&mcp->spi, 0)) << 8); - - // It should auto-increment to the "B" register, now read that - returnVal |= SPI_RWByte(&mcp->spi, 0); - - SPI_Deassert(&mcp->spi); - - return returnVal; -} +/* + * mcp23s17.c + * + * Created on: Nov 25, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "mcp23s17.h" +#include "hardware.h" + +/// Maximum SPI clock rate = 10 MHz +#define MCP23S17_MAX_CLOCK 10000000UL + +static void MCP23S17_WriteBothRegs(MCP23S17 *mcp, uint8_t addrA, uint16_t value); +static uint16_t MCP23S17_ReadBothRegs(MCP23S17 *mcp, uint8_t addrA); + +/** Initializes an MCP23S17 object + * + * @param mcp The MCP23S17 object to initialize + * @param resetPin The GPIO pin hooked to the reset input + */ +void MCP23S17_Init(MCP23S17 *mcp, GPIOPin resetPin) +{ + SPI_InitDevice(&mcp->spi, MCP23S17_MAX_CLOCK, SPI_MODE_0); + + // Do a reset pulse if we need to. No need to save the reset pin + // after that. + if (!GPIO_IsNull(resetPin)) + { + GPIO_SetDirection(resetPin, true); + GPIO_SetOff(resetPin); + DelayUS(1); + GPIO_SetOn(resetPin); + DelayUS(1); + } +} + +/** Begins a set of transactions with the MCP23S17. + * + * @param mcp The MCP23S17 to talk with + * + * You have to call this before using any of the MCP23S17 functions other than + * init. This takes control of the SPI bus. If the MCP23S17 is the only device + * on the bus, you can just call this once in the program. Otherwise, you should + * release it as soon as you're done so other SPI devices can use the bus instead. + */ +void MCP23S17_Begin(MCP23S17 *mcp) +{ + SPI_RequestBus(&mcp->spi); +} + +/** Ends a set of transactions with the MCP23S17. + * + * @param mcp The MCP23S17 to release + * + * You should call this when you're done talking to the MCP23S17 to free up the + * SPI bus for other devices. + */ +void MCP23S17_End(MCP23S17 *mcp) +{ + SPI_ReleaseBus(&mcp->spi); +} + +/** Sets the data direction register in the MCP23S17 + * + * @param mcp The MCP23S17 + * @param ddr Bitmask representing direction of the 16 GPIO pins (1 = output, 0 = input) + */ +void MCP23S17_SetDDR(MCP23S17 *mcp, uint16_t ddr) +{ + // The MCP23S17's DDR is backwards from most other chips. I like dealing + // with it so it behaves like other MCUs, so I invert any DDR values in this + // driver. In other words, when you set or get the DDR through this driver, + // the 1s and 0s are backwards from what the MCP23S17's datasheet says, but + // they are consistent with most MCUs. I value the consistency more. + MCP23S17_WriteBothRegs(mcp, MCP23S17_IODIRA, ~ddr); +} + +/** Reads the data direction register in the MCP23S17 + * + * @param mcp The MCP23S17 + * @return Bitmask representing direction of the 16 GPIO pins (1 = output, 0 = input) + */ +uint16_t MCP23S17_DDR(MCP23S17 *mcp) +{ + // As I mentioned above, DDR bits are inverted from what the MCP23S17's + // datasheet says, but consistent with most MCUs + return ~MCP23S17_ReadBothRegs(mcp, MCP23S17_IODIRA); +} + +/** Sets the output values in the MCP23S17 + * + * @param mcp The MCP23S17 + * @param data Bitmask representing output state of the 16 GPIO pins (1 = high, 0 = low) + */ +void MCP23S17_SetOutputs(MCP23S17 *mcp, uint16_t data) +{ + MCP23S17_WriteBothRegs(mcp, MCP23S17_GPIOA, data); +} + +/** Gets the current output values in the MCP23S17 + * + * @param mcp The MCP23S17 + * @return Bitmask representing output state of the 16 GPIO pins (1 = high, 0 = low) + */ +uint16_t MCP23S17_Outputs(MCP23S17 *mcp) +{ + return MCP23S17_ReadBothRegs(mcp, MCP23S17_OLATA); +} + +/** Reads the current input values in the MCP23S17 + * + * @param mcp The MCP23S17 + * @return Bitmask representing input state of the 16 GPIO pins (1 = high, 0 = low) + */ +uint16_t MCP23S17_ReadInputs(MCP23S17 *mcp) +{ + return MCP23S17_ReadBothRegs(mcp, MCP23S17_GPIOA); +} + +/** Enables/disables pullups in the MCP23S17 + * + * @param mcp The MCP23S17 + * @param pullups Bitmask representing which input pins should have pullups enabled. + */ +void MCP23S17_SetPullups(MCP23S17 *mcp, uint16_t pullups) +{ + MCP23S17_WriteBothRegs(mcp, MCP23S17_GPPUA, pullups); +} + +/** Reads the current pullup state in the MCP23S17 + * + * @param mcp The MCP23S17 + * return Bitmask representing which input pins have pullups enabled. + */ +uint16_t MCP23S17_Pullups(MCP23S17 *mcp) +{ + return MCP23S17_ReadBothRegs(mcp, MCP23S17_GPPUA); +} + +/** Helper function that writes two consecutive registers in the MCP23S17 + * + * @param mcp The MCP23S17 + * @param addrA The address of the first ("A") register + * @param value The value to write to the A and B registers. High byte = A, low byte = B + */ +static void MCP23S17_WriteBothRegs(MCP23S17 *mcp, uint8_t addrA, uint16_t value) +{ + // addrA should contain the address of the "A" register. + // the chip should also be in "same bank" mode. + SPI_Assert(&mcp->spi); + + // Start off the communication by telling the MCP23S17 that we are writing to a register + SPI_RWByte(&mcp->spi, MCP23S17_CONTROL_WRITE(0)); + + // Tell it the first register we're writing to (the "A" register) + SPI_RWByte(&mcp->spi, addrA); + + // Write the first byte of the register + SPI_RWByte(&mcp->spi, (uint8_t)((value >> 8) & 0xFF)); + + // It should auto-increment to the "B" register, now write that + SPI_RWByte(&mcp->spi, (uint8_t)(value & 0xFF)); + + SPI_Deassert(&mcp->spi); +} + +/** Helper function that reads two consecutive registers in the MCP23S17 + * + * @param mcp The MCP23S17 + * @param addrA The address of the first ("A") register + * @return The value read back from the A and B registers. High byte = A, low byte = B + */ +static uint16_t MCP23S17_ReadBothRegs(MCP23S17 *mcp, uint8_t addrA) +{ + uint16_t returnVal; + + SPI_Assert(&mcp->spi); + + // Start off the communication by telling the MCP23S17 that we are reading from a register + SPI_RWByte(&mcp->spi, MCP23S17_CONTROL_READ(0)); + + // Tell it which register we're reading from (the "A" register) + SPI_RWByte(&mcp->spi, addrA); + + // Read the first byte of the register + returnVal = (((uint16_t)SPI_RWByte(&mcp->spi, 0)) << 8); + + // It should auto-increment to the "B" register, now read that + returnVal |= SPI_RWByte(&mcp->spi, 0); + + SPI_Deassert(&mcp->spi); + + return returnVal; +} diff --git a/drivers/mcp23s17.h b/drivers/mcp23s17.h index 39fda22..74484f8 100644 --- a/drivers/mcp23s17.h +++ b/drivers/mcp23s17.h @@ -1,76 +1,76 @@ -/* - * mcp23s17.h - * - * Created on: Nov 25, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef DRIVERS_MCP23S17_H_ -#define DRIVERS_MCP23S17_H_ - -#include "../hal/spi.h" - -/// A few register defines. Ordinarily I wouldn't put these in the header file -/// because users of this module shouldn't care...but I have had to do some -/// optimizations with the AVR to bypass the hardware abstraction layer. -#define MCP23S17_CONTROL_WRITE(address) (0x40 | (address << 1)) -#define MCP23S17_CONTROL_READ(address) (0x40 | (address << 1) | 1) -#define MCP23S17_IODIRA 0x00 -#define MCP23S17_IODIRB 0x01 -#define MCP23S17_IPOLA 0x02 -#define MCP23S17_IPOLB 0x03 -#define MCP23S17_GPINTENA 0x04 -#define MCP23S17_GPINTENB 0x05 -#define MCP23S17_DEFVALA 0x06 -#define MCP23S17_DEFVALB 0x07 -#define MCP23S17_INTCONA 0x08 -#define MCP23S17_INTCONB 0x09 -#define MCP23S17_IOCON 0x0A -#define MCP23S17_IOCON_AGAIN 0x0B -#define MCP23S17_GPPUA 0x0C -#define MCP23S17_GPPUB 0x0D -#define MCP23S17_INTFA 0x0E -#define MCP23S17_INTFB 0x0F -#define MCP23S17_INTCAPA 0x10 -#define MCP23S17_INTCAPB 0x11 -#define MCP23S17_GPIOA 0x12 -#define MCP23S17_GPIOB 0x13 -#define MCP23S17_OLATA 0x14 -#define MCP23S17_OLATB 0x15 - -/// Struct representing a single MCP23S17 device -typedef struct MCP23S17 -{ - /// The SPI device representing this MCP23S17 - SPIDevice spi; -} MCP23S17; - -void MCP23S17_Init(MCP23S17 *mcp, GPIOPin resetPin); -void MCP23S17_Begin(MCP23S17 *mcp); -void MCP23S17_End(MCP23S17 *mcp); -void MCP23S17_SetDDR(MCP23S17 *mcp, uint16_t ddr); -uint16_t MCP23S17_DDR(MCP23S17 *mcp); -void MCP23S17_SetOutputs(MCP23S17 *mcp, uint16_t data); -uint16_t MCP23S17_Outputs(MCP23S17 *mcp); -uint16_t MCP23S17_ReadInputs(MCP23S17 *mcp); -void MCP23S17_SetPullups(MCP23S17 *mcp, uint16_t pullups); -uint16_t MCP23S17_Pullups(MCP23S17 *mcp); - -#endif /* DRIVERS_MCP23S17_H_ */ +/* + * mcp23s17.h + * + * Created on: Nov 25, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef DRIVERS_MCP23S17_H_ +#define DRIVERS_MCP23S17_H_ + +#include "../hal/spi.h" + +/// A few register defines. Ordinarily I wouldn't put these in the header file +/// because users of this module shouldn't care...but I have had to do some +/// optimizations with the AVR to bypass the hardware abstraction layer. +#define MCP23S17_CONTROL_WRITE(address) (0x40 | (address << 1)) +#define MCP23S17_CONTROL_READ(address) (0x40 | (address << 1) | 1) +#define MCP23S17_IODIRA 0x00 +#define MCP23S17_IODIRB 0x01 +#define MCP23S17_IPOLA 0x02 +#define MCP23S17_IPOLB 0x03 +#define MCP23S17_GPINTENA 0x04 +#define MCP23S17_GPINTENB 0x05 +#define MCP23S17_DEFVALA 0x06 +#define MCP23S17_DEFVALB 0x07 +#define MCP23S17_INTCONA 0x08 +#define MCP23S17_INTCONB 0x09 +#define MCP23S17_IOCON 0x0A +#define MCP23S17_IOCON_AGAIN 0x0B +#define MCP23S17_GPPUA 0x0C +#define MCP23S17_GPPUB 0x0D +#define MCP23S17_INTFA 0x0E +#define MCP23S17_INTFB 0x0F +#define MCP23S17_INTCAPA 0x10 +#define MCP23S17_INTCAPB 0x11 +#define MCP23S17_GPIOA 0x12 +#define MCP23S17_GPIOB 0x13 +#define MCP23S17_OLATA 0x14 +#define MCP23S17_OLATB 0x15 + +/// Struct representing a single MCP23S17 device +typedef struct MCP23S17 +{ + /// The SPI device representing this MCP23S17 + SPIDevice spi; +} MCP23S17; + +void MCP23S17_Init(MCP23S17 *mcp, GPIOPin resetPin); +void MCP23S17_Begin(MCP23S17 *mcp); +void MCP23S17_End(MCP23S17 *mcp); +void MCP23S17_SetDDR(MCP23S17 *mcp, uint16_t ddr); +uint16_t MCP23S17_DDR(MCP23S17 *mcp); +void MCP23S17_SetOutputs(MCP23S17 *mcp, uint16_t data); +uint16_t MCP23S17_Outputs(MCP23S17 *mcp); +uint16_t MCP23S17_ReadInputs(MCP23S17 *mcp); +void MCP23S17_SetPullups(MCP23S17 *mcp, uint16_t pullups); +uint16_t MCP23S17_Pullups(MCP23S17 *mcp); + +#endif /* DRIVERS_MCP23S17_H_ */ diff --git a/drivers/parallel_flash.c b/drivers/parallel_flash.c index cb57bff..8d66d1c 100644 --- a/drivers/parallel_flash.c +++ b/drivers/parallel_flash.c @@ -1,429 +1,429 @@ -/* - * parallel_flash.c - * - * Created on: Nov 25, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "parallel_flash.h" -#include "../util.h" - -/// Erasable sector size in SST39SF040 -#define SECTOR_SIZE_SST39SF040 (4*1024UL) -/// Erasable sector size in M29F160FB5AN6E2, 8-bit mode -#define SECTOR_SIZE_M29F160FB5AN6E2_8 (64*1024UL) - -static uint32_t ParallelFlash_MaskForChips(uint8_t chips); -static ALWAYS_INLINE void ParallelFlash_WaitForCompletion(void); -static ALWAYS_INLINE uint32_t ParallelFlash_UnlockAddress1(void); - -/// The type/arrangement of parallel flash chips we are talking to -static ParallelFlashChipType curChipType = ParallelFlash_SST39SF040_x4; - -/** Sets the type/arrangement of parallel flash chips we are talking to - * - * @param type The type/arrangement of flash chips - */ -void ParallelFlash_SetChipType(ParallelFlashChipType type) -{ - curChipType = type; -} - -/** Gets the type/arrangement of parallel flash chips we are talking to - * - * @return The current type/arrangement of flash chips - */ -ParallelFlashChipType ParallelFlash_ChipType(void) -{ - return curChipType; -} - -/** Reads data from the flash chip - * - * @param startAddress The address for reading - * @param buf The buffer to read to - * @param len The number of bytes to read - */ -void ParallelFlash_Read(uint32_t startAddress, uint32_t *buf, uint16_t len) -{ - // Just forward this request directly onto the parallel bus. Nothing - // special is required for reading a chunk of data. - ParallelBus_Read(startAddress, buf, len); -} - -/** Unlocks the flash chips using the special write sequence - * - * @param chipsMask The mask of which chips to unlock - */ -void ParallelFlash_UnlockChips(uint8_t chipsMask) -{ - // Use a mask so we don't unlock chips we don't want to talk with - uint32_t mask = ParallelFlash_MaskForChips(chipsMask); - uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); - - // First part of unlock sequence: - // Write 0x55555555 to the address bus and 0xAA to the data bus - // (Some datasheets may only say 0x555 or 0x5555, but they ignore - // the upper bits, so writing the alternating pattern to all address lines - // should make it compatible with larger chips). - ParallelBus_WriteCycle(unlockAddress, 0xAAAAAAAAUL & mask); - - // Second part of unlock sequence is the same thing, but reversed. - ParallelBus_WriteCycle(~unlockAddress, 0x55555555UL & mask); -} - -/** Reads the ID of the chips - * - * @param Pointer to variable for storing ID info about each chip - */ -void ParallelFlash_IdentifyChips(ParallelFlashChipID *chips) -{ - // Start by writing the unlock sequence to ALL chips - ParallelFlash_UnlockChips(ALL_CHIPS); - - // Write 0x90 to the first unlock address for the identify command... - ParallelBus_WriteCycle(ParallelFlash_UnlockAddress1(), 0x90909090UL); - - // Now we can read the vendor and product ID from addresses 0 and 1 - // (or 1 and 2 if we're using the M29F160FB5AN6E2 in 8-bit mode). - // Note: The Micron datasheet says it requires 12V to be applied to A9 - // in order for the identification command to work properly, but in - // practice the identification process works fine without it. - uint32_t vendorAddress = curChipType != ParallelFlash_M29F160FB5AN6E2_x4 ? - 0 : 1; - uint32_t manufacturers = ParallelBus_ReadCycle(vendorAddress); - uint32_t devices = ParallelBus_ReadCycle(vendorAddress + 1); - for (int8_t i = 0; i < PARALLEL_FLASH_NUM_CHIPS; i++) - { - uint8_t manufacturer = (uint8_t)(manufacturers >> (8 * i)); - uint8_t device = (uint8_t)(devices >> (8 * i)); - chips[PARALLEL_FLASH_NUM_CHIPS - i - 1].manufacturer = manufacturer; - chips[PARALLEL_FLASH_NUM_CHIPS - i - 1].device = device; - } - - // Exit software ID mode - ParallelBus_WriteCycle(0, 0xF0F0F0F0UL); -} - -/** Erases the specified chips - * - * @param chipsMask The mask of which chips to erase - */ -void ParallelFlash_EraseChips(uint8_t chipsMask) -{ - uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); - ParallelFlash_UnlockChips(chipsMask); - ParallelBus_WriteCycle(unlockAddress, 0x80808080UL); - ParallelFlash_UnlockChips(chipsMask); - ParallelBus_WriteCycle(unlockAddress, 0x10101010UL); - ParallelFlash_WaitForCompletion(); -} - -/** Erases only the range of sectors specified in the specified chips - * - * @param address The start address to erase (must be aligned to a sector boundary) - * @param length The number of bytes to erase (must be aligned to a sector boundary) - * @param chipsMask The mask of which chips to erase - * @return True on success, false on failure - */ -bool ParallelFlash_EraseSectors(uint32_t address, uint32_t length, uint8_t chipsMask) -{ - bool result = false; - - // Figure out our sector size - uint32_t sectorSize; - switch (curChipType) - { - case ParallelFlash_SST39SF040_x4: - default: - sectorSize = SECTOR_SIZE_SST39SF040; - break; - case ParallelFlash_M29F160FB5AN6E2_x4: - sectorSize = SECTOR_SIZE_M29F160FB5AN6E2_8; - break; - } - - // Make sure the area requested to be erased is on good boundaries - if ((address % sectorSize) || - (length % sectorSize)) - { - return false; - } - - // We're good to go. Let's do it. The process varies based on the chip type - if (curChipType == ParallelFlash_SST39SF040_x4) - { - // This chip sucks because you have to erase each sector with its own - // complete erase unlock command, which can take a while. At least - // individual erase operations are much faster on this chip... - while (length) - { - // Start the erase command - ParallelFlash_UnlockChips(chipsMask); - ParallelBus_WriteCycle(ParallelFlash_UnlockAddress1(), 0x80808080UL); - ParallelFlash_UnlockChips(chipsMask); - - // Now provide a sector address, but only one. Then the whole - // unlock sequence has to be done again after this sector is done. - ParallelBus_WriteCycle(address, 0x30303030UL); - - address += sectorSize; - length -= sectorSize; - - // Wait for completion of this individual erase operation before - // we can start a new erase operation. - ParallelFlash_WaitForCompletion(); - } - - result = true; - } - else if (curChipType == ParallelFlash_M29F160FB5AN6E2_x4) - { - // This chip is nicer because it can take all the sector addresses at - // once and then do the final erase operation in one fell swoop. - // Start the erase command - ParallelFlash_UnlockChips(chipsMask); - ParallelBus_WriteCycle(ParallelFlash_UnlockAddress1(), 0x80808080UL); - ParallelFlash_UnlockChips(chipsMask); - - // Now provide as many sector addresses as needed to erase. - // The first address is a bit of a special case because the boot sector - // actually has finer granularity for sector sizes. - if (address == 0) - { - ParallelBus_WriteCycle(0x00000000UL, 0x30303030UL); - ParallelBus_WriteCycle(0x00004000UL, 0x30303030UL); - ParallelBus_WriteCycle(0x00006000UL, 0x30303030UL); - ParallelBus_WriteCycle(0x00008000UL, 0x30303030UL); - address += sectorSize; - length -= sectorSize; - } - - // The remaining sectors can use a more generic algorithm - while (length) - { - ParallelBus_WriteCycle(address, 0x30303030UL); - address += sectorSize; - length -= sectorSize; - } - - // Wait for completion of the entire erase operation - ParallelFlash_WaitForCompletion(); - - result = true; - } - - return result; - -} - -/** Writes a buffer of data to all 4 chips simultaneously - * - * @param startAddress The starting address to write in flash - * @param buf The buffer to write - * @param len The length of data to write - * - * The API may look silly to have broken into different functions like this, but - * it's a performance optimization. It means we don't have to check during every - * byte write to see the chip unlock mask. It saves a bunch of time. - */ -void ParallelFlash_WriteAllChips(uint32_t startAddress, uint32_t const *buf, uint16_t len) -{ - uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); - - // Normal write process used by most parallel flashes - if (curChipType != ParallelFlash_M29F160FB5AN6E2_x4) - { - while (len--) - { - // Write this byte. - // Unlock...and don't use the unlock function because this one - // is more efficient knowing the mask is 0xFFFFFFFF - ParallelBus_WriteCycle(unlockAddress, 0xAAAAAAAAUL); - ParallelBus_WriteCycle(~unlockAddress, 0x55555555UL); - ParallelBus_WriteCycle(unlockAddress, 0xA0A0A0A0UL); - ParallelBus_WriteCycle(startAddress, *buf); - ParallelFlash_WaitForCompletion(); - - startAddress++; - buf++; - } - } - // Optimized write process available on the M29F160FB5AN6E2, requires - // fewer write cycles per byte if you know you're writing multiple bytes. - else - { - // Do an unlock bypass command so that we can write bytes faster. - // Writes will only require 2 write cycles instead of 4 - ParallelBus_WriteCycle(unlockAddress, 0xAAAAAAAAUL); - ParallelBus_WriteCycle(~unlockAddress, 0x55555555UL); - ParallelBus_WriteCycle(unlockAddress, 0x20202020UL); - - while (len--) - { - // Write this byte. - ParallelBus_WriteCycle(0, 0xA0A0A0A0UL); - ParallelBus_WriteCycle(startAddress, *buf); - ParallelFlash_WaitForCompletion(); - - startAddress++; - buf++; - } - - // When we're all done, do "unlock bypass reset" to exit from - // programming mode - ParallelBus_WriteCycle(0, 0x90909090UL); - ParallelBus_WriteCycle(0, 0x00000000UL); - } -} - -/** Writes a buffer of data to the specified chips simultaneously - * - * @param startAddress The starting address to write in flash - * @param buf The buffer to write - * @param len The length of data to write - * @param chipsMask The mask of which chips to write - */ -void ParallelFlash_WriteSomeChips(uint32_t startAddress, uint32_t const *buf, uint16_t len, uint8_t chipsMask) -{ - uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); - - // Normal write process used by most parallel flashes - if (curChipType != ParallelFlash_M29F160FB5AN6E2_x4) - { - while (len--) - { - // Write this byte. - ParallelFlash_UnlockChips(chipsMask); - ParallelBus_WriteCycle(unlockAddress, 0xA0A0A0A0UL); - ParallelBus_WriteCycle(startAddress, *buf); - ParallelFlash_WaitForCompletion(); - - startAddress++; - buf++; - } - } - // Optimized write process available on the M29F160FB5AN6E2, requires - // fewer write cycles per byte if you know you're writing multiple bytes. - else - { - // Do an unlock bypass command so that we can write bytes faster. - // Writes will only require 2 write cycles instead of 4 - ParallelFlash_UnlockChips(chipsMask); - ParallelBus_WriteCycle(unlockAddress, 0x20202020UL); - - while (len--) - { - // Write this byte. - ParallelBus_WriteCycle(0, 0xA0A0A0A0UL); - ParallelBus_WriteCycle(startAddress, *buf); - ParallelFlash_WaitForCompletion(); - - startAddress++; - buf++; - } - - // When we're all done, do "unlock bypass reset" to exit from - // programming mode - ParallelBus_WriteCycle(0, 0x90909090UL); - ParallelBus_WriteCycle(0, 0x00000000UL); - } -} - -/** Calculates a 32-bit mask to use with the unlock process when unlocking chips - * - * @param chipsMask The mask of which chips to write - * @return A 32-bit mask that can be used on the data bus to filter out the unlock sequence - * - * For clarity, chipsMask has 1 bit per chip. The return value has 1 byte per - * chip. The return value masks the unlock sequence so we only supply a valid - * unlock sequence to the chips that we want to unlock. - */ -static uint32_t ParallelFlash_MaskForChips(uint8_t chips) -{ - // Calculates a mask so we can filter out chips we don't care about. - - // Optimization because we typically don't mask the chips - if (chips == 0x0F) - { - return 0xFFFFFFFFUL; - } - - // This probably looks dumb not doing this as a loop...but AVR GCC is - // terrible. This approach results in more optimal generated instructions. - uint32_t mask = 0; - if (chips & (1 << 0)) - { - mask |= 0x000000FFUL; - } - if (chips & (1 << 1)) - { - mask |= 0x0000FF00UL; - } - if (chips & (1 << 2)) - { - mask |= 0x00FF0000UL; - } - if (chips & (1 << 3)) - { - mask |= 0xFF000000UL; - } - - return mask; -} - -/** Waits for an erase or write operation on the flash chip to complete. - * - * We know we're done when the value we read from the chip stops changing. There - * is a "toggle" status bit that will stop toggling when the op is complete. - */ -static ALWAYS_INLINE void ParallelFlash_WaitForCompletion(void) -{ - uint32_t readback = ParallelBus_ReadCycle(0); - uint32_t next = ParallelBus_ReadCycle(0); - while (next != readback) - { - readback = next; - next = ParallelBus_ReadCycle(0); - } -} - -/** Gets the first unlock address to use when unlocking writes on this chip - * - * @return The first unlock address. - * - * Note: The second unlock address is the bitwise NOT of this address. - */ -static ALWAYS_INLINE uint32_t ParallelFlash_UnlockAddress1(void) -{ - // Most chips use alternating bits, with A0 being a 1 bit - if (curChipType != ParallelFlash_M29F160FB5AN6E2_x4) - { - return 0x55555555UL; - } - // The M29F160FB5AN6E2 is weird because it's an 8-/16-bit chip. In 8-bit - // mode it has an "A-1" pin that we treat as A0, then the chip's A0 pin is - // really our A1, and so on. The unlock sequence still starts on the chip's - // physical pin A0, so effectively the unlock address is inverted. - else - { - return 0xAAAAAAAAUL; - } -} +/* + * parallel_flash.c + * + * Created on: Nov 25, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "parallel_flash.h" +#include "../util.h" + +/// Erasable sector size in SST39SF040 +#define SECTOR_SIZE_SST39SF040 (4*1024UL) +/// Erasable sector size in M29F160FB5AN6E2, 8-bit mode +#define SECTOR_SIZE_M29F160FB5AN6E2_8 (64*1024UL) + +static uint32_t ParallelFlash_MaskForChips(uint8_t chips); +static ALWAYS_INLINE void ParallelFlash_WaitForCompletion(void); +static ALWAYS_INLINE uint32_t ParallelFlash_UnlockAddress1(void); + +/// The type/arrangement of parallel flash chips we are talking to +static ParallelFlashChipType curChipType = ParallelFlash_SST39SF040_x4; + +/** Sets the type/arrangement of parallel flash chips we are talking to + * + * @param type The type/arrangement of flash chips + */ +void ParallelFlash_SetChipType(ParallelFlashChipType type) +{ + curChipType = type; +} + +/** Gets the type/arrangement of parallel flash chips we are talking to + * + * @return The current type/arrangement of flash chips + */ +ParallelFlashChipType ParallelFlash_ChipType(void) +{ + return curChipType; +} + +/** Reads data from the flash chip + * + * @param startAddress The address for reading + * @param buf The buffer to read to + * @param len The number of bytes to read + */ +void ParallelFlash_Read(uint32_t startAddress, uint32_t *buf, uint16_t len) +{ + // Just forward this request directly onto the parallel bus. Nothing + // special is required for reading a chunk of data. + ParallelBus_Read(startAddress, buf, len); +} + +/** Unlocks the flash chips using the special write sequence + * + * @param chipsMask The mask of which chips to unlock + */ +void ParallelFlash_UnlockChips(uint8_t chipsMask) +{ + // Use a mask so we don't unlock chips we don't want to talk with + uint32_t mask = ParallelFlash_MaskForChips(chipsMask); + uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); + + // First part of unlock sequence: + // Write 0x55555555 to the address bus and 0xAA to the data bus + // (Some datasheets may only say 0x555 or 0x5555, but they ignore + // the upper bits, so writing the alternating pattern to all address lines + // should make it compatible with larger chips). + ParallelBus_WriteCycle(unlockAddress, 0xAAAAAAAAUL & mask); + + // Second part of unlock sequence is the same thing, but reversed. + ParallelBus_WriteCycle(~unlockAddress, 0x55555555UL & mask); +} + +/** Reads the ID of the chips + * + * @param Pointer to variable for storing ID info about each chip + */ +void ParallelFlash_IdentifyChips(ParallelFlashChipID *chips) +{ + // Start by writing the unlock sequence to ALL chips + ParallelFlash_UnlockChips(ALL_CHIPS); + + // Write 0x90 to the first unlock address for the identify command... + ParallelBus_WriteCycle(ParallelFlash_UnlockAddress1(), 0x90909090UL); + + // Now we can read the vendor and product ID from addresses 0 and 1 + // (or 1 and 2 if we're using the M29F160FB5AN6E2 in 8-bit mode). + // Note: The Micron datasheet says it requires 12V to be applied to A9 + // in order for the identification command to work properly, but in + // practice the identification process works fine without it. + uint32_t vendorAddress = curChipType != ParallelFlash_M29F160FB5AN6E2_x4 ? + 0 : 1; + uint32_t manufacturers = ParallelBus_ReadCycle(vendorAddress); + uint32_t devices = ParallelBus_ReadCycle(vendorAddress + 1); + for (int8_t i = 0; i < PARALLEL_FLASH_NUM_CHIPS; i++) + { + uint8_t manufacturer = (uint8_t)(manufacturers >> (8 * i)); + uint8_t device = (uint8_t)(devices >> (8 * i)); + chips[PARALLEL_FLASH_NUM_CHIPS - i - 1].manufacturer = manufacturer; + chips[PARALLEL_FLASH_NUM_CHIPS - i - 1].device = device; + } + + // Exit software ID mode + ParallelBus_WriteCycle(0, 0xF0F0F0F0UL); +} + +/** Erases the specified chips + * + * @param chipsMask The mask of which chips to erase + */ +void ParallelFlash_EraseChips(uint8_t chipsMask) +{ + uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); + ParallelFlash_UnlockChips(chipsMask); + ParallelBus_WriteCycle(unlockAddress, 0x80808080UL); + ParallelFlash_UnlockChips(chipsMask); + ParallelBus_WriteCycle(unlockAddress, 0x10101010UL); + ParallelFlash_WaitForCompletion(); +} + +/** Erases only the range of sectors specified in the specified chips + * + * @param address The start address to erase (must be aligned to a sector boundary) + * @param length The number of bytes to erase (must be aligned to a sector boundary) + * @param chipsMask The mask of which chips to erase + * @return True on success, false on failure + */ +bool ParallelFlash_EraseSectors(uint32_t address, uint32_t length, uint8_t chipsMask) +{ + bool result = false; + + // Figure out our sector size + uint32_t sectorSize; + switch (curChipType) + { + case ParallelFlash_SST39SF040_x4: + default: + sectorSize = SECTOR_SIZE_SST39SF040; + break; + case ParallelFlash_M29F160FB5AN6E2_x4: + sectorSize = SECTOR_SIZE_M29F160FB5AN6E2_8; + break; + } + + // Make sure the area requested to be erased is on good boundaries + if ((address % sectorSize) || + (length % sectorSize)) + { + return false; + } + + // We're good to go. Let's do it. The process varies based on the chip type + if (curChipType == ParallelFlash_SST39SF040_x4) + { + // This chip sucks because you have to erase each sector with its own + // complete erase unlock command, which can take a while. At least + // individual erase operations are much faster on this chip... + while (length) + { + // Start the erase command + ParallelFlash_UnlockChips(chipsMask); + ParallelBus_WriteCycle(ParallelFlash_UnlockAddress1(), 0x80808080UL); + ParallelFlash_UnlockChips(chipsMask); + + // Now provide a sector address, but only one. Then the whole + // unlock sequence has to be done again after this sector is done. + ParallelBus_WriteCycle(address, 0x30303030UL); + + address += sectorSize; + length -= sectorSize; + + // Wait for completion of this individual erase operation before + // we can start a new erase operation. + ParallelFlash_WaitForCompletion(); + } + + result = true; + } + else if (curChipType == ParallelFlash_M29F160FB5AN6E2_x4) + { + // This chip is nicer because it can take all the sector addresses at + // once and then do the final erase operation in one fell swoop. + // Start the erase command + ParallelFlash_UnlockChips(chipsMask); + ParallelBus_WriteCycle(ParallelFlash_UnlockAddress1(), 0x80808080UL); + ParallelFlash_UnlockChips(chipsMask); + + // Now provide as many sector addresses as needed to erase. + // The first address is a bit of a special case because the boot sector + // actually has finer granularity for sector sizes. + if (address == 0) + { + ParallelBus_WriteCycle(0x00000000UL, 0x30303030UL); + ParallelBus_WriteCycle(0x00004000UL, 0x30303030UL); + ParallelBus_WriteCycle(0x00006000UL, 0x30303030UL); + ParallelBus_WriteCycle(0x00008000UL, 0x30303030UL); + address += sectorSize; + length -= sectorSize; + } + + // The remaining sectors can use a more generic algorithm + while (length) + { + ParallelBus_WriteCycle(address, 0x30303030UL); + address += sectorSize; + length -= sectorSize; + } + + // Wait for completion of the entire erase operation + ParallelFlash_WaitForCompletion(); + + result = true; + } + + return result; + +} + +/** Writes a buffer of data to all 4 chips simultaneously + * + * @param startAddress The starting address to write in flash + * @param buf The buffer to write + * @param len The length of data to write + * + * The API may look silly to have broken into different functions like this, but + * it's a performance optimization. It means we don't have to check during every + * byte write to see the chip unlock mask. It saves a bunch of time. + */ +void ParallelFlash_WriteAllChips(uint32_t startAddress, uint32_t const *buf, uint16_t len) +{ + uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); + + // Normal write process used by most parallel flashes + if (curChipType != ParallelFlash_M29F160FB5AN6E2_x4) + { + while (len--) + { + // Write this byte. + // Unlock...and don't use the unlock function because this one + // is more efficient knowing the mask is 0xFFFFFFFF + ParallelBus_WriteCycle(unlockAddress, 0xAAAAAAAAUL); + ParallelBus_WriteCycle(~unlockAddress, 0x55555555UL); + ParallelBus_WriteCycle(unlockAddress, 0xA0A0A0A0UL); + ParallelBus_WriteCycle(startAddress, *buf); + ParallelFlash_WaitForCompletion(); + + startAddress++; + buf++; + } + } + // Optimized write process available on the M29F160FB5AN6E2, requires + // fewer write cycles per byte if you know you're writing multiple bytes. + else + { + // Do an unlock bypass command so that we can write bytes faster. + // Writes will only require 2 write cycles instead of 4 + ParallelBus_WriteCycle(unlockAddress, 0xAAAAAAAAUL); + ParallelBus_WriteCycle(~unlockAddress, 0x55555555UL); + ParallelBus_WriteCycle(unlockAddress, 0x20202020UL); + + while (len--) + { + // Write this byte. + ParallelBus_WriteCycle(0, 0xA0A0A0A0UL); + ParallelBus_WriteCycle(startAddress, *buf); + ParallelFlash_WaitForCompletion(); + + startAddress++; + buf++; + } + + // When we're all done, do "unlock bypass reset" to exit from + // programming mode + ParallelBus_WriteCycle(0, 0x90909090UL); + ParallelBus_WriteCycle(0, 0x00000000UL); + } +} + +/** Writes a buffer of data to the specified chips simultaneously + * + * @param startAddress The starting address to write in flash + * @param buf The buffer to write + * @param len The length of data to write + * @param chipsMask The mask of which chips to write + */ +void ParallelFlash_WriteSomeChips(uint32_t startAddress, uint32_t const *buf, uint16_t len, uint8_t chipsMask) +{ + uint32_t unlockAddress = ParallelFlash_UnlockAddress1(); + + // Normal write process used by most parallel flashes + if (curChipType != ParallelFlash_M29F160FB5AN6E2_x4) + { + while (len--) + { + // Write this byte. + ParallelFlash_UnlockChips(chipsMask); + ParallelBus_WriteCycle(unlockAddress, 0xA0A0A0A0UL); + ParallelBus_WriteCycle(startAddress, *buf); + ParallelFlash_WaitForCompletion(); + + startAddress++; + buf++; + } + } + // Optimized write process available on the M29F160FB5AN6E2, requires + // fewer write cycles per byte if you know you're writing multiple bytes. + else + { + // Do an unlock bypass command so that we can write bytes faster. + // Writes will only require 2 write cycles instead of 4 + ParallelFlash_UnlockChips(chipsMask); + ParallelBus_WriteCycle(unlockAddress, 0x20202020UL); + + while (len--) + { + // Write this byte. + ParallelBus_WriteCycle(0, 0xA0A0A0A0UL); + ParallelBus_WriteCycle(startAddress, *buf); + ParallelFlash_WaitForCompletion(); + + startAddress++; + buf++; + } + + // When we're all done, do "unlock bypass reset" to exit from + // programming mode + ParallelBus_WriteCycle(0, 0x90909090UL); + ParallelBus_WriteCycle(0, 0x00000000UL); + } +} + +/** Calculates a 32-bit mask to use with the unlock process when unlocking chips + * + * @param chipsMask The mask of which chips to write + * @return A 32-bit mask that can be used on the data bus to filter out the unlock sequence + * + * For clarity, chipsMask has 1 bit per chip. The return value has 1 byte per + * chip. The return value masks the unlock sequence so we only supply a valid + * unlock sequence to the chips that we want to unlock. + */ +static uint32_t ParallelFlash_MaskForChips(uint8_t chips) +{ + // Calculates a mask so we can filter out chips we don't care about. + + // Optimization because we typically don't mask the chips + if (chips == 0x0F) + { + return 0xFFFFFFFFUL; + } + + // This probably looks dumb not doing this as a loop...but AVR GCC is + // terrible. This approach results in more optimal generated instructions. + uint32_t mask = 0; + if (chips & (1 << 0)) + { + mask |= 0x000000FFUL; + } + if (chips & (1 << 1)) + { + mask |= 0x0000FF00UL; + } + if (chips & (1 << 2)) + { + mask |= 0x00FF0000UL; + } + if (chips & (1 << 3)) + { + mask |= 0xFF000000UL; + } + + return mask; +} + +/** Waits for an erase or write operation on the flash chip to complete. + * + * We know we're done when the value we read from the chip stops changing. There + * is a "toggle" status bit that will stop toggling when the op is complete. + */ +static ALWAYS_INLINE void ParallelFlash_WaitForCompletion(void) +{ + uint32_t readback = ParallelBus_ReadCycle(0); + uint32_t next = ParallelBus_ReadCycle(0); + while (next != readback) + { + readback = next; + next = ParallelBus_ReadCycle(0); + } +} + +/** Gets the first unlock address to use when unlocking writes on this chip + * + * @return The first unlock address. + * + * Note: The second unlock address is the bitwise NOT of this address. + */ +static ALWAYS_INLINE uint32_t ParallelFlash_UnlockAddress1(void) +{ + // Most chips use alternating bits, with A0 being a 1 bit + if (curChipType != ParallelFlash_M29F160FB5AN6E2_x4) + { + return 0x55555555UL; + } + // The M29F160FB5AN6E2 is weird because it's an 8-/16-bit chip. In 8-bit + // mode it has an "A-1" pin that we treat as A0, then the chip's A0 pin is + // really our A1, and so on. The unlock sequence still starts on the chip's + // physical pin A0, so effectively the unlock address is inverted. + else + { + return 0xAAAAAAAAUL; + } +} diff --git a/drivers/parallel_flash.h b/drivers/parallel_flash.h index 2c08eef..309290b 100644 --- a/drivers/parallel_flash.h +++ b/drivers/parallel_flash.h @@ -1,83 +1,83 @@ -/* - * parallel_flash.h - * - * Created on: Nov 25, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef DRIVERS_PARALLEL_FLASH_H_ -#define DRIVERS_PARALLEL_FLASH_H_ - -#include "../hal/parallel_bus.h" - -/// The number of chips we are simultaneously addressing -#define PARALLEL_FLASH_NUM_CHIPS 4 - -/// Masks for functions that want a chip mask... -#define IC1 (1 << 3) -#define IC2 (1 << 2) -#define IC3 (1 << 1) -#define IC4 (1 << 0) -#define ALL_CHIPS (IC1 | IC2 | IC3 | IC4) - -/// Holds info about the chip (retrieved with JEDEC standards) -typedef struct ParallelFlashChipID -{ - /// The manufacturer ID - uint8_t manufacturer; - /// The device ID - uint8_t device; -} ParallelFlashChipID; - -/// Type/layout of chips currently being addressed -typedef enum ParallelFlashChipType -{ - /// Four SST39SF040 chips, 512 KB each, for a total of 2 MB - ParallelFlash_SST39SF040_x4, - /// Four M29F160FB5AN6E2 chips, 2 MB each, in 8-bit mode, for a total of 8 MB - ParallelFlash_M29F160FB5AN6E2_x4, -} ParallelFlashChipType; - -// Tells which type of flash chip we are communicating with -void ParallelFlash_SetChipType(ParallelFlashChipType type); -ParallelFlashChipType ParallelFlash_ChipType(void); - -// Reads a set of data from all 4 chips simultaneously -void ParallelFlash_Read(uint32_t startAddress, uint32_t *buf, uint16_t len); - -// Does an unlock sequence on the chips requested -void ParallelFlash_UnlockChips(uint8_t chipsMask); - -// Identifies all four chips -void ParallelFlash_IdentifyChips(ParallelFlashChipID *chips); - -// Erases the chips/sectors requested -void ParallelFlash_EraseChips(uint8_t chipsMask); -bool ParallelFlash_EraseSectors(uint32_t address, uint32_t length, uint8_t chipsMask); - -// Writes a buffer to all 4 chips simultaneously (each uint32_t contains an 8-bit portion for each chip). -// Optimized variant of this function if we know we're writing to all 4 chips simultaneously. -// Allows us to bypass a lot of operations involving "chipsMask". -void ParallelFlash_WriteAllChips(uint32_t startAddress, uint32_t const *buf, uint16_t len); - -// Writes a buffer to a mask of requested chips (each uint32_t contains an 8-bit portion for each chip). -void ParallelFlash_WriteSomeChips(uint32_t startAddress, uint32_t const *buf, uint16_t len, uint8_t chipsMask); - -#endif /* DRIVERS_PARALLEL_FLASH_H_ */ +/* + * parallel_flash.h + * + * Created on: Nov 25, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef DRIVERS_PARALLEL_FLASH_H_ +#define DRIVERS_PARALLEL_FLASH_H_ + +#include "../hal/parallel_bus.h" + +/// The number of chips we are simultaneously addressing +#define PARALLEL_FLASH_NUM_CHIPS 4 + +/// Masks for functions that want a chip mask... +#define IC1 (1 << 3) +#define IC2 (1 << 2) +#define IC3 (1 << 1) +#define IC4 (1 << 0) +#define ALL_CHIPS (IC1 | IC2 | IC3 | IC4) + +/// Holds info about the chip (retrieved with JEDEC standards) +typedef struct ParallelFlashChipID +{ + /// The manufacturer ID + uint8_t manufacturer; + /// The device ID + uint8_t device; +} ParallelFlashChipID; + +/// Type/layout of chips currently being addressed +typedef enum ParallelFlashChipType +{ + /// Four SST39SF040 chips, 512 KB each, for a total of 2 MB + ParallelFlash_SST39SF040_x4, + /// Four M29F160FB5AN6E2 chips, 2 MB each, in 8-bit mode, for a total of 8 MB + ParallelFlash_M29F160FB5AN6E2_x4, +} ParallelFlashChipType; + +// Tells which type of flash chip we are communicating with +void ParallelFlash_SetChipType(ParallelFlashChipType type); +ParallelFlashChipType ParallelFlash_ChipType(void); + +// Reads a set of data from all 4 chips simultaneously +void ParallelFlash_Read(uint32_t startAddress, uint32_t *buf, uint16_t len); + +// Does an unlock sequence on the chips requested +void ParallelFlash_UnlockChips(uint8_t chipsMask); + +// Identifies all four chips +void ParallelFlash_IdentifyChips(ParallelFlashChipID *chips); + +// Erases the chips/sectors requested +void ParallelFlash_EraseChips(uint8_t chipsMask); +bool ParallelFlash_EraseSectors(uint32_t address, uint32_t length, uint8_t chipsMask); + +// Writes a buffer to all 4 chips simultaneously (each uint32_t contains an 8-bit portion for each chip). +// Optimized variant of this function if we know we're writing to all 4 chips simultaneously. +// Allows us to bypass a lot of operations involving "chipsMask". +void ParallelFlash_WriteAllChips(uint32_t startAddress, uint32_t const *buf, uint16_t len); + +// Writes a buffer to a mask of requested chips (each uint32_t contains an 8-bit portion for each chip). +void ParallelFlash_WriteSomeChips(uint32_t startAddress, uint32_t const *buf, uint16_t len, uint8_t chipsMask); + +#endif /* DRIVERS_PARALLEL_FLASH_H_ */ diff --git a/hal/at90usb646/Descriptors.c b/hal/at90usb646/Descriptors.c index 712ab55..fdd607b 100644 --- a/hal/at90usb646/Descriptors.c +++ b/hal/at90usb646/Descriptors.c @@ -1,271 +1,271 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2011. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * USB Device Descriptors, for library use when in USB device mode. Descriptors are special - * computer-readable structures which the host requests upon device enumeration, to determine - * the device's capabilities and functions. - */ - -#include "Descriptors.h" - -/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as - * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. - * This allows the host to track a device across insertions on different ports, allowing them to retain allocated - * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices - * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value - * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and - * port location). - */ -#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) - #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. -#endif - -/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall - * device characteristics, including the supported USB version, control endpoint size and the - * number of device configurations. The descriptor is read out by the USB host when the enumeration - * process begins. - */ -const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = -{ - .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, - - .USBSpecification = VERSION_BCD(01.10), - .Class = CDC_CSCP_CDCClass, - .SubClass = CDC_CSCP_NoSpecificSubclass, - .Protocol = CDC_CSCP_NoSpecificProtocol, - - .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, - - .VendorID = 0x16D0, - .ProductID = 0x06AA, - .ReleaseNumber = VERSION_BCD(00.01), - - .ManufacturerStrIndex = 0x01, - .ProductStrIndex = 0x02, - .SerialNumStrIndex = USE_INTERNAL_SERIAL, - - .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS -}; - -/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage - * of the device in one of its supported configurations, including information about any device interfaces - * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting - * a configuration so that the host may correctly communicate with the USB device. - */ -const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = -{ - .Config = - { - .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, - - .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), - .TotalInterfaces = 2, - - .ConfigurationNumber = 1, - .ConfigurationStrIndex = NO_DESCRIPTOR, - - .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED), - - .MaxPowerConsumption = USB_CONFIG_POWER_MA(500) - }, - - .CDC_CCI_Interface = - { - .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - - .InterfaceNumber = 0, - .AlternateSetting = 0, - - .TotalEndpoints = 1, - - .Class = CDC_CSCP_CDCClass, - .SubClass = CDC_CSCP_ACMSubclass, - .Protocol = CDC_CSCP_ATCommandProtocol, - - .InterfaceStrIndex = NO_DESCRIPTOR - }, - - .CDC_Functional_Header = - { - .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, - .Subtype = CDC_DSUBTYPE_CSInterface_Header, - - .CDCSpecification = VERSION_BCD(01.10), - }, - - .CDC_Functional_ACM = - { - .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, - .Subtype = CDC_DSUBTYPE_CSInterface_ACM, - - .Capabilities = 0x06, - }, - - .CDC_Functional_Union = - { - .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, - .Subtype = CDC_DSUBTYPE_CSInterface_Union, - - .MasterInterfaceNumber = 0, - .SlaveInterfaceNumber = 1, - }, - - .CDC_NotificationEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), - .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = CDC_NOTIFICATION_EPSIZE, - .PollingIntervalMS = 0xFF - }, - - .CDC_DCI_Interface = - { - .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, - - .InterfaceNumber = 1, - .AlternateSetting = 0, - - .TotalEndpoints = 2, - - .Class = CDC_CSCP_CDCDataClass, - .SubClass = CDC_CSCP_NoDataSubclass, - .Protocol = CDC_CSCP_NoDataProtocol, - - .InterfaceStrIndex = NO_DESCRIPTOR - }, - - .CDC_DataOutEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), - .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = CDC_TXRX_EPSIZE, - .PollingIntervalMS = 0x01 - }, - - .CDC_DataInEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), - .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), - .EndpointSize = CDC_TXRX_EPSIZE, - .PollingIntervalMS = 0x01 - } -}; - -/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests - * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate - * via the language ID table available at USB.org what languages the device supports for its string descriptors. - */ -const USB_Descriptor_String_t PROGMEM LanguageString = -{ - .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, - - .UnicodeString = {LANGUAGE_ID_ENG} -}; - -/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable - * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device - * Descriptor. - */ -const USB_Descriptor_String_t PROGMEM ManufacturerString = -{ - .Header = {.Size = USB_STRING_LEN(10), .Type = DTYPE_String}, - - .UnicodeString = L"Doug Brown" -}; - -/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, - * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device - * Descriptor. - */ -const USB_Descriptor_String_t PROGMEM ProductString = -{ - .Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String}, - - .UnicodeString = L"Mac ROM SIMM Programmer" -}; - -/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" - * documentation) by the application code so that the address and size of a requested descriptor can be given - * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function - * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the - * USB host. - */ -uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint8_t wIndex, - const void ** const DescriptorAddress) -{ - const uint8_t DescriptorType = (wValue >> 8); - const uint8_t DescriptorNumber = (wValue & 0xFF); - - const void *Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - { - case DTYPE_Device: - Address = &DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = &ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_String: - switch (DescriptorNumber) - { - case 0x00: - Address = &LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - case 0x01: - Address = &ManufacturerString; - Size = pgm_read_byte(&ManufacturerString.Header.Size); - break; - case 0x02: - Address = &ProductString; - Size = pgm_read_byte(&ProductString.Header.Size); - break; - } - - break; - } - - *DescriptorAddress = Address; - return Size; -} - +/* + LUFA Library + Copyright (C) Dean Camera, 2011. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * USB Device Descriptors, for library use when in USB device mode. Descriptors are special + * computer-readable structures which the host requests upon device enumeration, to determine + * the device's capabilities and functions. + */ + +#include "Descriptors.h" + +/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as + * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. + * This allows the host to track a device across insertions on different ports, allowing them to retain allocated + * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices + * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value + * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and + * port location). + */ +#if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) + #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. +#endif + +/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall + * device characteristics, including the supported USB version, control endpoint size and the + * number of device configurations. The descriptor is read out by the USB host when the enumeration + * process begins. + */ +const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = +{ + .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, + + .USBSpecification = VERSION_BCD(01.10), + .Class = CDC_CSCP_CDCClass, + .SubClass = CDC_CSCP_NoSpecificSubclass, + .Protocol = CDC_CSCP_NoSpecificProtocol, + + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + + .VendorID = 0x16D0, + .ProductID = 0x06AA, + .ReleaseNumber = VERSION_BCD(00.01), + + .ManufacturerStrIndex = 0x01, + .ProductStrIndex = 0x02, + .SerialNumStrIndex = USE_INTERNAL_SERIAL, + + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS +}; + +/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage + * of the device in one of its supported configurations, including information about any device interfaces + * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting + * a configuration so that the host may correctly communicate with the USB device. + */ +const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = +{ + .Config = + { + .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, + + .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), + .TotalInterfaces = 2, + + .ConfigurationNumber = 1, + .ConfigurationStrIndex = NO_DESCRIPTOR, + + .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED), + + .MaxPowerConsumption = USB_CONFIG_POWER_MA(500) + }, + + .CDC_CCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 0, + .AlternateSetting = 0, + + .TotalEndpoints = 1, + + .Class = CDC_CSCP_CDCClass, + .SubClass = CDC_CSCP_ACMSubclass, + .Protocol = CDC_CSCP_ATCommandProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_Functional_Header = + { + .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, + .Subtype = CDC_DSUBTYPE_CSInterface_Header, + + .CDCSpecification = VERSION_BCD(01.10), + }, + + .CDC_Functional_ACM = + { + .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, + .Subtype = CDC_DSUBTYPE_CSInterface_ACM, + + .Capabilities = 0x06, + }, + + .CDC_Functional_Union = + { + .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, + .Subtype = CDC_DSUBTYPE_CSInterface_Union, + + .MasterInterfaceNumber = 0, + .SlaveInterfaceNumber = 1, + }, + + .CDC_NotificationEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_NOTIFICATION_EPSIZE, + .PollingIntervalMS = 0xFF + }, + + .CDC_DCI_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = 1, + .AlternateSetting = 0, + + .TotalEndpoints = 2, + + .Class = CDC_CSCP_CDCDataClass, + .SubClass = CDC_CSCP_NoDataSubclass, + .Protocol = CDC_CSCP_NoDataProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .CDC_DataOutEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x01 + }, + + .CDC_DataInEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), + .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CDC_TXRX_EPSIZE, + .PollingIntervalMS = 0x01 + } +}; + +/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests + * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate + * via the language ID table available at USB.org what languages the device supports for its string descriptors. + */ +const USB_Descriptor_String_t PROGMEM LanguageString = +{ + .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, + + .UnicodeString = {LANGUAGE_ID_ENG} +}; + +/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable + * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +const USB_Descriptor_String_t PROGMEM ManufacturerString = +{ + .Header = {.Size = USB_STRING_LEN(10), .Type = DTYPE_String}, + + .UnicodeString = L"Doug Brown" +}; + +/** Product descriptor string. This is a Unicode string containing the product's details in human readable form, + * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device + * Descriptor. + */ +const USB_Descriptor_String_t PROGMEM ProductString = +{ + .Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String}, + + .UnicodeString = L"Mac ROM SIMM Programmer" +}; + +/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" + * documentation) by the application code so that the address and size of a requested descriptor can be given + * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function + * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the + * USB host. + */ +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + const void ** const DescriptorAddress) +{ + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorNumber = (wValue & 0xFF); + + const void *Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + switch (DescriptorNumber) + { + case 0x00: + Address = &LanguageString; + Size = pgm_read_byte(&LanguageString.Header.Size); + break; + case 0x01: + Address = &ManufacturerString; + Size = pgm_read_byte(&ManufacturerString.Header.Size); + break; + case 0x02: + Address = &ProductString; + Size = pgm_read_byte(&ProductString.Header.Size); + break; + } + + break; + } + + *DescriptorAddress = Address; + return Size; +} + diff --git a/hal/at90usb646/Descriptors.h b/hal/at90usb646/Descriptors.h index da7553d..7d854db 100644 --- a/hal/at90usb646/Descriptors.h +++ b/hal/at90usb646/Descriptors.h @@ -1,89 +1,89 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2011. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * Header file for Descriptors.c. - */ - -#ifndef _DESCRIPTORS_H_ -#define _DESCRIPTORS_H_ - - /* Includes: */ - #include - - #include "LUFA/Drivers/USB/USB.h" - - /* Macros: */ - /** Endpoint number of the CDC device-to-host notification IN endpoint. */ - #define CDC_NOTIFICATION_EPNUM 2 - - /** Endpoint number of the CDC device-to-host data IN endpoint. */ - #define CDC_TX_EPNUM 3 - - /** Endpoint number of the CDC host-to-device data OUT endpoint. */ - #define CDC_RX_EPNUM 4 - - /** Size in bytes of the CDC device-to-host notification IN endpoint. */ - #define CDC_NOTIFICATION_EPSIZE 8 - - /** Size in bytes of the CDC data IN and OUT endpoints. */ - #define CDC_TXRX_EPSIZE 64 - - /* Type Defines: */ - /** Type define for the device configuration descriptor structure. This must be defined in the - * application code, as the configuration descriptor contains several sub-descriptors which - * vary between devices, and which describe the device's usage to the host. - */ - typedef struct - { - USB_Descriptor_Configuration_Header_t Config; - - // CDC Command Interface - USB_Descriptor_Interface_t CDC_CCI_Interface; - USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; - USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; - USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; - USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; - - // CDC Data Interface - USB_Descriptor_Interface_t CDC_DCI_Interface; - USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; - USB_Descriptor_Endpoint_t CDC_DataInEndpoint; - } USB_Descriptor_Configuration_t; - - /* Function Prototypes: */ - uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint8_t wIndex, - const void** const DescriptorAddress) - ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2011. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for Descriptors.c. + */ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + + /* Includes: */ + #include + + #include "LUFA/Drivers/USB/USB.h" + + /* Macros: */ + /** Endpoint number of the CDC device-to-host notification IN endpoint. */ + #define CDC_NOTIFICATION_EPNUM 2 + + /** Endpoint number of the CDC device-to-host data IN endpoint. */ + #define CDC_TX_EPNUM 3 + + /** Endpoint number of the CDC host-to-device data OUT endpoint. */ + #define CDC_RX_EPNUM 4 + + /** Size in bytes of the CDC device-to-host notification IN endpoint. */ + #define CDC_NOTIFICATION_EPSIZE 8 + + /** Size in bytes of the CDC data IN and OUT endpoints. */ + #define CDC_TXRX_EPSIZE 64 + + /* Type Defines: */ + /** Type define for the device configuration descriptor structure. This must be defined in the + * application code, as the configuration descriptor contains several sub-descriptors which + * vary between devices, and which describe the device's usage to the host. + */ + typedef struct + { + USB_Descriptor_Configuration_Header_t Config; + + // CDC Command Interface + USB_Descriptor_Interface_t CDC_CCI_Interface; + USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header; + USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM; + USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union; + USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; + + // CDC Data Interface + USB_Descriptor_Interface_t CDC_DCI_Interface; + USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; + USB_Descriptor_Endpoint_t CDC_DataInEndpoint; + } USB_Descriptor_Configuration_t; + + /* Function Prototypes: */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + const void** const DescriptorAddress) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + +#endif + diff --git a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Buttons.h b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Buttons.h index b944c95..e050d75 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Buttons.h +++ b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Buttons.h @@ -1,88 +1,88 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/* - This is a stub driver header file, for implementing custom board - layout hardware with compatible LUFA board specific drivers. If - the library is configured to use the BOARD_USER board mode, this - driver file should be completed and copied into the "/Board/" folder - inside the application's folder. - - This stub is for the board-specific component of the LUFA Buttons driver, - for the control of physical board-mounted GPIO pushbuttons. -*/ - -#ifndef __BUTTONS_USER_H__ -#define __BUTTONS_USER_H__ - - /* Includes: */ - // TODO: Add any required includes here - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_BUTTONS_H) - #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Button mask for the first button on the board. */ - #define BUTTONS_BUTTON1 // TODO: Add mask for first board button here - - /* Inline Functions: */ - #if !defined(__DOXYGEN__) - static inline void Buttons_Init(void) - { - // TODO: Initialize the appropriate port pins as an inputs here, with pull-ups - } - - static inline void Buttons_Disable(void) - { - // TODO: Clear the appropriate port pins as high impedance inputs here - } - - static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; - static inline uint8_t Buttons_GetStatus(void) - { - // TODO: Return current button status here, debounced if required - } - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + This is a stub driver header file, for implementing custom board + layout hardware with compatible LUFA board specific drivers. If + the library is configured to use the BOARD_USER board mode, this + driver file should be completed and copied into the "/Board/" folder + inside the application's folder. + + This stub is for the board-specific component of the LUFA Buttons driver, + for the control of physical board-mounted GPIO pushbuttons. +*/ + +#ifndef __BUTTONS_USER_H__ +#define __BUTTONS_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_BUTTONS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Button mask for the first button on the board. */ + #define BUTTONS_BUTTON1 // TODO: Add mask for first board button here + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + // TODO: Initialize the appropriate port pins as an inputs here, with pull-ups + } + + static inline void Buttons_Disable(void) + { + // TODO: Clear the appropriate port pins as high impedance inputs here + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + // TODO: Return current button status here, debounced if required + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Dataflash.h b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Dataflash.h index ef186e4..9fcc25f 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Dataflash.h +++ b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Dataflash.h @@ -1,218 +1,218 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/* - This is a stub driver header file, for implementing custom board - layout hardware with compatible LUFA board specific drivers. If - the library is configured to use the BOARD_USER board mode, this - driver file should be completed and copied into the "/Board/" folder - inside the application's folder. - - This stub is for the board-specific component of the LUFA Dataflash - driver. -*/ - -#ifndef __DATAFLASH_USER_H__ -#define __DATAFLASH_USER_H__ - - /* Includes: */ - // TODO: Add any required includes here - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_DATAFLASH_H) - #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. - #endif - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Macros: */ - #define DATAFLASH_CHIPCS_MASK // TODO: Replace this with a mask of all the /CS pins of all Dataflashes - #define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs - #define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Constant indicating the total number of dataflash ICs mounted on the selected board. */ - #define DATAFLASH_TOTALCHIPS 1 // TODO: Replace with the number of Dataflashes on the board, max 2 - - /** Mask for no dataflash chip selected. */ - #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK - - /** Mask for the first dataflash chip selected. */ - #define DATAFLASH_CHIP1 // TODO: Replace with mask to hold /CS of first Dataflash low, and all others high - - /** Mask for the second dataflash chip selected. */ - #define DATAFLASH_CHIP2 // TODO: Replace with mask to hold /CS of second Dataflash low, and all others high - - /** Internal main memory page size for the board's dataflash ICs. */ - #define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs - - /** Total number of pages inside each of the board's dataflash ICs. */ - #define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs - - /* Inline Functions: */ - /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. - * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. - */ - static inline void Dataflash_Init(void) - { - DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; - DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; - } - - /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. - * - * \param[in] Byte Byte of data to send to the dataflash - * - * \return Last response byte from the dataflash - */ - static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; - static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) - { - // TODO - } - - /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. - * - * \param[in] Byte Byte of data to send to the dataflash - */ - static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; - static inline void Dataflash_SendByte(const uint8_t Byte) - { - // TODO - } - - /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash. - * - * \return Last response byte from the dataflash - */ - static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline uint8_t Dataflash_ReceiveByte(void) - { - // TODO - } - - /** Determines the currently selected dataflash chip. - * - * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected - * or a DATAFLASH_CHIPn mask (where n is the chip number). - */ - static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline uint8_t Dataflash_GetSelectedChip(void) - { - return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); - } - - /** Selects the given dataflash chip. - * - * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is - * the chip number). - */ - static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; - static inline void Dataflash_SelectChip(const uint8_t ChipMask) - { - DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); - } - - /** Deselects the current dataflash chip, so that no dataflash is selected. */ - static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; - static inline void Dataflash_DeselectChip(void) - { - Dataflash_SelectChip(DATAFLASH_NO_CHIP); - } - - /** Selects a dataflash IC from the given page number, which should range from 0 to - * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one - * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside - * the total number of pages contained in the boards dataflash ICs, all dataflash ICs - * are deselected. - * - * \param[in] PageAddress Address of the page to manipulate, ranging from - * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). - */ - static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) - { - Dataflash_DeselectChip(); - - if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) - return; - - #if (DATAFLASH_TOTALCHIPS == 2) - if (PageAddress & 0x01) - Dataflash_SelectChip(DATAFLASH_CHIP2); - else - Dataflash_SelectChip(DATAFLASH_CHIP1); - #else - Dataflash_SelectChip(DATAFLASH_CHIP1); - #endif - } - - /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive - * a new command. - */ - static inline void Dataflash_ToggleSelectedChipCS(void) - { - uint8_t SelectedChipMask = Dataflash_GetSelectedChip(); - - Dataflash_DeselectChip(); - Dataflash_SelectChip(SelectedChipMask); - } - - /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main - * memory page program or main memory to buffer transfer. - */ - static inline void Dataflash_WaitWhileBusy(void) - { - Dataflash_ToggleSelectedChipCS(); - Dataflash_SendByte(DF_CMD_GETSTATUS); - while (!(Dataflash_ReceiveByte() & DF_STATUS_READY)); - Dataflash_ToggleSelectedChipCS(); - } - - /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with - * dataflash commands which require a complete 24-bit address. - * - * \param[in] PageAddress Page address within the selected dataflash IC - * \param[in] BufferByte Address within the dataflash's buffer - */ - static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte) - { - #if (DATAFLASH_TOTALCHIPS == 2) - PageAddress >>= 1; - #endif - - Dataflash_SendByte(PageAddress >> 5); - Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); - Dataflash_SendByte(BufferByte); - } - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + This is a stub driver header file, for implementing custom board + layout hardware with compatible LUFA board specific drivers. If + the library is configured to use the BOARD_USER board mode, this + driver file should be completed and copied into the "/Board/" folder + inside the application's folder. + + This stub is for the board-specific component of the LUFA Dataflash + driver. +*/ + +#ifndef __DATAFLASH_USER_H__ +#define __DATAFLASH_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_DATAFLASH_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define DATAFLASH_CHIPCS_MASK // TODO: Replace this with a mask of all the /CS pins of all Dataflashes + #define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs + #define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Constant indicating the total number of dataflash ICs mounted on the selected board. */ + #define DATAFLASH_TOTALCHIPS 1 // TODO: Replace with the number of Dataflashes on the board, max 2 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 // TODO: Replace with mask to hold /CS of first Dataflash low, and all others high + + /** Mask for the second dataflash chip selected. */ + #define DATAFLASH_CHIP2 // TODO: Replace with mask to hold /CS of second Dataflash low, and all others high + + /** Internal main memory page size for the board's dataflash ICs. */ + #define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs + + /** Total number of pages inside each of the board's dataflash ICs. */ + #define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs + + /* Inline Functions: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + // TODO + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + // TODO + } + + /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash. + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_ReceiveByte(void) + { + // TODO + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) + return; + + #if (DATAFLASH_TOTALCHIPS == 2) + if (PageAddress & 0x01) + Dataflash_SelectChip(DATAFLASH_CHIP2); + else + Dataflash_SelectChip(DATAFLASH_CHIP1); + #else + Dataflash_SelectChip(DATAFLASH_CHIP1); + #endif + } + + /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive + * a new command. + */ + static inline void Dataflash_ToggleSelectedChipCS(void) + { + uint8_t SelectedChipMask = Dataflash_GetSelectedChip(); + + Dataflash_DeselectChip(); + Dataflash_SelectChip(SelectedChipMask); + } + + /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main + * memory page program or main memory to buffer transfer. + */ + static inline void Dataflash_WaitWhileBusy(void) + { + Dataflash_ToggleSelectedChipCS(); + Dataflash_SendByte(DF_CMD_GETSTATUS); + while (!(Dataflash_ReceiveByte() & DF_STATUS_READY)); + Dataflash_ToggleSelectedChipCS(); + } + + /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with + * dataflash commands which require a complete 24-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte) + { + #if (DATAFLASH_TOTALCHIPS == 2) + PageAddress >>= 1; + #endif + + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + diff --git a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Joystick.h b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Joystick.h index 8131c1c..4843ce6 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Joystick.h +++ b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/Joystick.h @@ -1,100 +1,100 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/* - This is a stub driver header file, for implementing custom board - layout hardware with compatible LUFA board specific drivers. If - the library is configured to use the BOARD_USER board mode, this - driver file should be completed and copied into the "/Board/" folder - inside the application's folder. - - This stub is for the board-specific component of the LUFA Joystick - driver, for a digital four-way (plus button) joystick. -*/ - -#ifndef __JOYSTICK_USER_H__ -#define __JOYSTICK_USER_H__ - - /* Includes: */ - // TODO: Add any required includes here - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_JOYSTICK_H) - #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Mask for the joystick being pushed in the left direction. */ - #define JOY_LEFT // TODO: Add mask to indicate joystick left position here - - /** Mask for the joystick being pushed in the right direction. */ - #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here - - /** Mask for the joystick being pushed in the upward direction. */ - #define JOY_UP // TODO: Add mask to indicate joystick up position here - - /** Mask for the joystick being pushed in the downward direction. */ - #define JOY_DOWN // TODO: Add mask to indicate joystick down position here - - /** Mask for the joystick being pushed inward. */ - #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here - - /* Inline Functions: */ - #if !defined(__DOXYGEN__) - static inline void Joystick_Init(void) - { - // TODO: Initialize joystick port pins as inputs with pull-ups - } - - static inline void Joystick_Disable(void) - { - // TODO: Clear the joystick pins as high impedance inputs here - } - - static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; - static inline uint8_t Joystick_GetStatus(void) - { - // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros - } - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + This is a stub driver header file, for implementing custom board + layout hardware with compatible LUFA board specific drivers. If + the library is configured to use the BOARD_USER board mode, this + driver file should be completed and copied into the "/Board/" folder + inside the application's folder. + + This stub is for the board-specific component of the LUFA Joystick + driver, for a digital four-way (plus button) joystick. +*/ + +#ifndef __JOYSTICK_USER_H__ +#define __JOYSTICK_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_JOYSTICK_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT // TODO: Add mask to indicate joystick left position here + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP // TODO: Add mask to indicate joystick up position here + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN // TODO: Add mask to indicate joystick down position here + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + // TODO: Initialize joystick port pins as inputs with pull-ups + } + + static inline void Joystick_Disable(void) + { + // TODO: Clear the joystick pins as high impedance inputs here + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/LEDs.h b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/LEDs.h index 19043f7..1314e94 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/LEDs.h +++ b/hal/at90usb646/LUFA/CodeTemplates/DriverStubs/LEDs.h @@ -1,128 +1,128 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/* - This is a stub driver header file, for implementing custom board - layout hardware with compatible LUFA board specific drivers. If - the library is configured to use the BOARD_USER board mode, this - driver file should be completed and copied into the "/Board/" folder - inside the application's folder. - - This stub is for the board-specific component of the LUFA LEDs driver, - for the LEDs (up to four) mounted on most development boards. -*/ - -#ifndef __LEDS_USER_H__ -#define __LEDS_USER_H__ - - /* Includes: */ - // TODO: Add any required includes here - -/* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_LEDS_H) - #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** LED mask for the first LED on the board. */ - #define LEDS_LED1 // TODO: Add mask for first board LED here - - /** LED mask for the second LED on the board. */ - #define LEDS_LED2 // TODO: Add mask for second board LED here - - /** LED mask for the third LED on the board. */ - #define LEDS_LED3 // TODO: Add mask for third board LED here - - /** LED mask for the fourth LED on the board. */ - #define LEDS_LED4 // TODO: Add mask for fourth board LED here - - /** LED mask for all the LEDs on the board. */ - #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) - - /** LED mask for none of the board LEDs. */ - #define LEDS_NO_LEDS 0 - - /* Inline Functions: */ - #if !defined(__DOXYGEN__) - static inline void LEDs_Init(void) - { - // TODO: Add code to initialize LED port pins as outputs here - } - - static inline void LEDs_Disable(void) - { - // TODO: Clear the LED port pins as high impedance inputs here - } - - static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) - { - // TODO: Add code to turn on LEDs given in the LEDMask mask here, leave others as-is - } - - static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) - { - // TODO: Add code to turn off LEDs given in the LEDMask mask here, leave others as-is - } - - static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) - { - // TODO: Add code to turn on only LEDs given in the LEDMask mask here, all others off - } - - static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) - { - // TODO: Add code to set the Leds in the given LEDMask to the status given in ActiveMask here - } - - static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) - { - // TODO: Add code to toggle the Leds in the given LEDMask, ignoring all others - } - - static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; - static inline uint8_t LEDs_GetLEDs(void) - { - // TODO: Add code to return the current LEDs status' here which can be masked against LED_LED* macros - } - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + This is a stub driver header file, for implementing custom board + layout hardware with compatible LUFA board specific drivers. If + the library is configured to use the BOARD_USER board mode, this + driver file should be completed and copied into the "/Board/" folder + inside the application's folder. + + This stub is for the board-specific component of the LUFA LEDs driver, + for the LEDs (up to four) mounted on most development boards. +*/ + +#ifndef __LEDS_USER_H__ +#define __LEDS_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + +/* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_LEDS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 // TODO: Add mask for first board LED here + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 // TODO: Add mask for second board LED here + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 // TODO: Add mask for third board LED here + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 // TODO: Add mask for fourth board LED here + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + // TODO: Add code to initialize LED port pins as outputs here + } + + static inline void LEDs_Disable(void) + { + // TODO: Clear the LED port pins as high impedance inputs here + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + // TODO: Add code to turn on LEDs given in the LEDMask mask here, leave others as-is + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + // TODO: Add code to turn off LEDs given in the LEDMask mask here, leave others as-is + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + // TODO: Add code to turn on only LEDs given in the LEDMask mask here, all others off + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + // TODO: Add code to set the Leds in the given LEDMask to the status given in ActiveMask here + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + // TODO: Add code to toggle the Leds in the given LEDMask, ignoring all others + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + // TODO: Add code to return the current LEDs status' here which can be masked against LED_LED* macros + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/CodeTemplates/LUFAConfig.h b/hal/at90usb646/LUFA/CodeTemplates/LUFAConfig.h index 28da615..5672d0e 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/LUFAConfig.h +++ b/hal/at90usb646/LUFA/CodeTemplates/LUFAConfig.h @@ -1,160 +1,160 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/* - This is a header file which can be used to configure LUFA's - compile time options, as an alternative to the compile time - constants supplied through a makefile. To use this configuration - header, copy this into your project's root directory and supply - the \c USE_LUFA_CONFIG_HEADER token to the compiler so that it is - defined in all compiled source files. - - For information on what each token does, refer to the LUFA - manual section "Summary of Compile Tokens". -*/ - -#ifndef __LUFA_CONFIG_H__ -#define __LUFA_CONFIG_H__ - - #if (ARCH == ARCH_AVR8) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ -// #define ORDERED_EP_CONFIG -// #define USE_STATIC_OPTIONS {Insert Value Here} -// #define USB_DEVICE_ONLY -// #define USB_HOST_ONLY -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_LIMITED_CONTROLLER_CONNECT -// #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ -// #define USE_RAM_DESCRIPTORS -// #define USE_FLASH_DESCRIPTORS -// #define USE_EEPROM_DESCRIPTORS -// #define NO_INTERNAL_SERIAL -// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} -// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} -// #define FIXED_NUM_CONFIGURATION {Insert Value Here} -// #define CONTROL_ONLY_DEVICE -// #define INTERRUPT_CONTROL_ENDPOINT -// #define NO_DEVICE_REMOTE_WAKEUP -// #define NO_DEVICE_SELF_POWER - - /* USB Host Mode Driver Related Tokens: */ -// #define HOST_STATE_AS_GPIOR {Insert Value Here} -// #define USB_HOST_TIMEOUT_MS {Insert Value Here} -// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} -// #define NO_AUTO_VBUS_MANAGEMENT -// #define INVERTED_VBUS_ENABLE_LINE - - #elif (ARCH == ARCH_XMEGA) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ -// #define USE_STATIC_OPTIONS {Insert Value Here} -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_LIMITED_CONTROLLER_CONNECT -// #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ -// #define USE_RAM_DESCRIPTORS -// #define USE_FLASH_DESCRIPTORS -// #define USE_EEPROM_DESCRIPTORS -// #define NO_INTERNAL_SERIAL -// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} -// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} -// #define FIXED_NUM_CONFIGURATION {Insert Value Here} -// #define CONTROL_ONLY_DEVICE -// #define NO_DEVICE_REMOTE_WAKEUP -// #define NO_DEVICE_SELF_POWER - - #elif (ARCH == ARCH_UC3) - - /* Non-USB Related Configuration Tokens: */ -// #define DISABLE_TERMINAL_CODES - - /* USB Class Driver Related Tokens: */ -// #define HID_HOST_BOOT_PROTOCOL_ONLY -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} -// #define HID_USAGE_STACK_DEPTH {Insert Value Here} -// #define HID_MAX_COLLECTIONS {Insert Value Here} -// #define HID_MAX_REPORTITEMS {Insert Value Here} -// #define HID_MAX_REPORT_IDS {Insert Value Here} -// #define NO_CLASS_DRIVER_AUTOFLUSH - - /* General USB Driver Related Tokens: */ -// #define ORDERED_EP_CONFIG -// #define USE_STATIC_OPTIONS {Insert Value Here} -// #define USB_DEVICE_ONLY -// #define USB_HOST_ONLY -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} -// #define NO_SOF_EVENTS - - /* USB Device Mode Driver Related Tokens: */ -// #define NO_INTERNAL_SERIAL -// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} -// #define FIXED_NUM_CONFIGURATION {Insert Value Here} -// #define CONTROL_ONLY_DEVICE -// #define INTERRUPT_CONTROL_ENDPOINT -// #define NO_DEVICE_REMOTE_WAKEUP -// #define NO_DEVICE_SELF_POWER - - /* USB Host Mode Driver Related Tokens: */ -// #define USB_HOST_TIMEOUT_MS {Insert Value Here} -// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} -// #define NO_AUTO_VBUS_MANAGEMENT -// #define INVERTED_VBUS_ENABLE_LINE - - #endif -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + This is a header file which can be used to configure LUFA's + compile time options, as an alternative to the compile time + constants supplied through a makefile. To use this configuration + header, copy this into your project's root directory and supply + the \c USE_LUFA_CONFIG_HEADER token to the compiler so that it is + defined in all compiled source files. + + For information on what each token does, refer to the LUFA + manual section "Summary of Compile Tokens". +*/ + +#ifndef __LUFA_CONFIG_H__ +#define __LUFA_CONFIG_H__ + + #if (ARCH == ARCH_AVR8) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ +// #define ORDERED_EP_CONFIG +// #define USE_STATIC_OPTIONS {Insert Value Here} +// #define USB_DEVICE_ONLY +// #define USB_HOST_ONLY +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS +// #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL +// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} +// #define FIXED_NUM_CONFIGURATION {Insert Value Here} +// #define CONTROL_ONLY_DEVICE +// #define INTERRUPT_CONTROL_ENDPOINT +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + + /* USB Host Mode Driver Related Tokens: */ +// #define HOST_STATE_AS_GPIOR {Insert Value Here} +// #define USB_HOST_TIMEOUT_MS {Insert Value Here} +// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} +// #define NO_AUTO_VBUS_MANAGEMENT +// #define INVERTED_VBUS_ENABLE_LINE + + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ +// #define USE_STATIC_OPTIONS {Insert Value Here} +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS +// #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL +// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} +// #define FIXED_NUM_CONFIGURATION {Insert Value Here} +// #define CONTROL_ONLY_DEVICE +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + + #elif (ARCH == ARCH_UC3) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ +// #define ORDERED_EP_CONFIG +// #define USE_STATIC_OPTIONS {Insert Value Here} +// #define USB_DEVICE_ONLY +// #define USB_HOST_ONLY +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define NO_INTERNAL_SERIAL +// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} +// #define FIXED_NUM_CONFIGURATION {Insert Value Here} +// #define CONTROL_ONLY_DEVICE +// #define INTERRUPT_CONTROL_ENDPOINT +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + + /* USB Host Mode Driver Related Tokens: */ +// #define USB_HOST_TIMEOUT_MS {Insert Value Here} +// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} +// #define NO_AUTO_VBUS_MANAGEMENT +// #define INVERTED_VBUS_ENABLE_LINE + + #endif +#endif + diff --git a/hal/at90usb646/LUFA/CodeTemplates/makefile_template.avr8 b/hal/at90usb646/LUFA/CodeTemplates/makefile_template.avr8 index 3e3747a..7fd1939 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/makefile_template.avr8 +++ b/hal/at90usb646/LUFA/CodeTemplates/makefile_template.avr8 @@ -1,713 +1,713 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. -# >> Modified for use with the LUFA project. << -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# Dean Camera -# Opendous Inc. -# Denver Gingerich -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make dfu = Download the hex file to the device, using dfu-programmer (must -# have dfu-programmer installed). -# -# make flip = Download the hex file to the device, using Atmel FLIP (must -# have Atmel FLIP installed). -# -# make dfu-ee = Download the eeprom file to the device, using dfu-programmer -# (must have dfu-programmer installed). -# -# make flip-ee = Download the eeprom file to the device, using Atmel FLIP -# (must have Atmel FLIP installed). -# -# make doxygen = Generate DoxyGen documentation for the project (must have -# DoxyGen installed) -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ### - - -# Targeted chip architecture (see library "Architectures" documentation) -ARCH = AVR8 - - -# Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called -# "Board" inside the application directory. -BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ### - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This will be an integer division of F_CLOCK below, as it is sourced by -# F_CLOCK after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -F_CPU = ### INSERT PRESCALED SYSTEM CLOCK SPEED HERE, IN HZ ### - - -# Input clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency (before any prescaling is performed) in Hz. This value may -# differ from F_CPU if prescaling is used on the latter, and is required as the -# raw input clock is fed directly to the PLL sections of the AVR for high speed -# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' -# at the end, this will be done automatically to create a 32-bit value in your -# source code. -# -# If no clock division is performed on the input clock inside the AVR (via the -# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = ### INSERT CLOCK TO USB MODULE HERE, IN HZ ### - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = ### INSERT NAME OF MAIN FILENAME HERE, WITHOUT EXTENSION ### - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = . - - -# Path to the LUFA library -LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ### - - -# LUFA library compile-time options and predefined tokens (add '-D' before each token) -LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKENS HERE ### - - -# Create the LUFA source path variables by including the LUFA root makefile -include $(LUFA_PATH)/LUFA/makefile - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c \ - $(LUFA_SRC_USB) \ - $(LUFA_SRC_USBCLASS) - ### INSERT ADDITIONAL PROJECT SOURCE FILENAMES OR LUFA MODULE NAMES HERE ### - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = $(LUFA_PATH)/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL -CDEFS += -DF_USB=$(F_USB)UL -CDEFS += -DBOARD=BOARD_$(BOARD) -CDEFS += -DARCH=ARCH_$(ARCH) -CDEFS += $(LUFA_OPTS) - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) -ADEFS += -DF_USB=$(F_USB)UL -ADEFS += -DBOARD=BOARD_$(BOARD) -ADEFS += -DARCH=ARCH_$(ARCH) -ADEFS += $(LUFA_OPTS) - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -CPPDEFS += -DF_USB=$(F_USB)UL -CPPDEFS += -DBOARD=BOARD_$(BOARD) -CPPDEFS += -DARCH=ARCH_$(ARCH) -CPPDEFS += $(LUFA_OPTS) - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -ffunction-sections -CFLAGS += -fno-inline-small-functions -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -fno-strict-aliasing -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -ffunction-sections -CPPFLAGS += -fno-strict-aliasing -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax -LDFLAGS += -Wl,--gc-sections -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x - - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# -AVRDUDE_PROGRAMMER = jtagmkII - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = usb - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -build: elf hex eep lss sym -#build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=lib$(TARGET).a -lib: $(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf -MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) -FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) - - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - -flip: $(TARGET).hex - batchisp -hardware usb -device $(MCU) -operation erase f - batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program - batchisp -hardware usb -device $(MCU) -operation start reset 0 - -dfu: $(TARGET).hex - dfu-programmer $(MCU) erase - dfu-programmer $(MCU) flash $(TARGET).hex - dfu-programmer $(MCU) reset - -flip-ee: $(TARGET).hex $(TARGET).eep - $(COPY) $(TARGET).eep $(TARGET)eep.hex - batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase - batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program - batchisp -hardware usb -device $(MCU) -operation start reset 0 - $(REMOVE) $(TARGET)eep.hex - -dfu-ee: $(TARGET).hex $(TARGET).eep - dfu-programmer $(MCU) eeprom-flash $(TARGET).eep - dfu-programmer $(MCU) reset - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVEDIR) .dep - -doxygen: - @echo Generating Project Documentation \($(TARGET)\)... - @doxygen Doxygen.conf - @echo Documentation Generation Complete. - -clean_doxygen: - rm -rf Documentation - -checksource: - @for f in $(SRC) $(CPPSRC) $(ASRC); do \ - if [ -f $$f ]; then \ - echo "Found Source File: $$f" ; \ - else \ - echo "Source File Not Found: $$f" ; \ - fi; done - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff doxygen clean \ -clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ -debug gdb-config checksource +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + +# MCU name +MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ### + + +# Targeted chip architecture (see library "Architectures" documentation) +ARCH = AVR8 + + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ### + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_CLOCK below, as it is sourced by +# F_CLOCK after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = ### INSERT PRESCALED SYSTEM CLOCK SPEED HERE, IN HZ ### + + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = ### INSERT CLOCK TO USB MODULE HERE, IN HZ ### + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = ### INSERT NAME OF MAIN FILENAME HERE, WITHOUT EXTENSION ### + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ### + + +# LUFA library compile-time options and predefined tokens (add '-D' before each token) +LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKENS HERE ### + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) + ### INSERT ADDITIONAL PROJECT SOURCE FILENAMES OR LUFA MODULE NAMES HERE ### + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DF_USB=$(F_USB)UL +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DARCH=ARCH_$(ARCH) +CDEFS += $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_USB=$(F_USB)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +ADEFS += -DARCH=ARCH_$(ARCH) +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_USB=$(F_USB)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CPPDEFS += -DARCH=ARCH_$(ARCH) +CPPDEFS += $(LUFA_OPTS) + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -ffunction-sections +CPPFLAGS += -fno-strict-aliasing +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRALIBDIRS = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = jtagmkII + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +flip: $(TARGET).hex + batchisp -hardware usb -device $(MCU) -operation erase f + batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + +dfu: $(TARGET).hex + dfu-programmer $(MCU) erase + dfu-programmer $(MCU) flash $(TARGET).hex + dfu-programmer $(MCU) reset + +flip-ee: $(TARGET).hex $(TARGET).eep + $(COPY) $(TARGET).eep $(TARGET)eep.hex + batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + $(REMOVE) $(TARGET)eep.hex + +dfu-ee: $(TARGET).hex $(TARGET).eep + dfu-programmer $(MCU) eeprom-flash $(TARGET).eep + dfu-programmer $(MCU) reset + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation \($(TARGET)\)... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +checksource: + @for f in $(SRC) $(CPPSRC) $(ASRC); do \ + if [ -f $$f ]; then \ + echo "Found Source File: $$f" ; \ + else \ + echo "Source File Not Found: $$f" ; \ + fi; done + + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff doxygen clean \ +clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ +debug gdb-config checksource diff --git a/hal/at90usb646/LUFA/CodeTemplates/makefile_template.uc3 b/hal/at90usb646/LUFA/CodeTemplates/makefile_template.uc3 index 21eae2d..647a956 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/makefile_template.uc3 +++ b/hal/at90usb646/LUFA/CodeTemplates/makefile_template.uc3 @@ -1,486 +1,486 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. -# >> Modified for use with the LUFA project. << -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# Dean Camera -# Opendous Inc. -# Denver Gingerich -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make dfu = Download the hex file to the device, using dfu-programmer (must -# have dfu-programmer installed). -# -# make flip = Download the hex file to the device, using Atmel FLIP (must -# have Atmel FLIP installed). -# -# make doxygen = Generate DoxyGen documentation for the project (must have -# DoxyGen installed) -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ### - - -# Targeted chip architecture (see library "Architectures" documentation) -ARCH = UC3 - - -# Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called -# "Board" inside the application directory. -BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ### - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This should be the frequency the system core runs at, after the system clock -# has been set up correctly and started. -F_CPU = ### INSERT PRESCALED SYSTEM CLOCK SPEED HERE, IN HZ ### - - -# USB controller master clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency of the USB controller's clock generator in Hz. -# -# For the UC3 chips, this should be equal to 48MHz or 96MHz. -F_USB = ### INSERT CLOCK TO USB MODULE HERE, IN HZ ### - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = ### INSERT NAME OF MAIN FILENAME HERE, WITHOUT EXTENSION ### - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = . - - -# Path to the LUFA library -LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ### - - -# LUFA library compile-time options and predefined tokens (add '-D' before each token) -LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKENS HERE ### - - -# Create the LUFA source path variables by including the LUFA root makefile -include $(LUFA_PATH)/LUFA/makefile - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c \ - $(LUFA_SRC_USB) \ - $(LUFA_SRC_USBCLASS) - ### INSERT ADDITIONAL PROJECT SOURCE FILENAMES OR LUFA MODULE NAMES HERE ### - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = $(LUFA_PATH)/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL -CDEFS += -DF_USB=$(F_USB)UL -CDEFS += -DBOARD=BOARD_$(BOARD) -CDEFS += -DARCH=ARCH_$(ARCH) -CDEFS += $(LUFA_OPTS) - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) -ADEFS += -DF_USB=$(F_USB)UL -ADEFS += -DBOARD=BOARD_$(BOARD) -ADEFS += -DARCH=ARCH_$(ARCH) -ADEFS += $(LUFA_OPTS) - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -CPPDEFS += -DF_USB=$(F_USB)UL -CPPDEFS += -DBOARD=BOARD_$(BOARD) -CPPDEFS += -DARCH=ARCH_$(ARCH) -CPPDEFS += $(LUFA_OPTS) - - -# Debugging level. -DEBUG = 3 - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -ffunction-sections -CFLAGS += -fno-strict-aliasing -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -CFLAGS += -masm-addr-pseudos -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -ffunction-sections -CPPFLAGS += -fno-strict-aliasing -CPPFLAGS += -fno-exceptions -CPPFLAGS += -masm-addr-pseudos -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--gc-sections --rodata-writable -LDFLAGS += -Wl,--direct-data -#LDFLAGS += -T linker_script.x - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr32-gcc -OBJCOPY = avr32-objcopy -OBJDUMP = avr32-objdump -SIZE = avr32-size -AR = avr32-ar rcs -NM = avr32-nm -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mpart=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mpart=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mpart=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -build: elf hex lss sym -#build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=lib$(TARGET).a -lib: $(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf -MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) -FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) - - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - -# Program the device. -flip: $(TARGET).hex - batchisp -hardware usb -device $(MCU) -operation erase f - batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program - batchisp -hardware usb -device $(MCU) -operation start reset 0 - -dfu: $(TARGET).hex - dfu-programmer $(MCU) erase - dfu-programmer $(MCU) flash $(TARGET).hex - dfu-programmer $(MCU) reset - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVEDIR) .dep - -doxygen: - @echo Generating Project Documentation \($(TARGET)\)... - @doxygen Doxygen.conf - @echo Documentation Generation Complete. - -clean_doxygen: - rm -rf Documentation - -checksource: - @for f in $(SRC) $(CPPSRC) $(ASRC); do \ - if [ -f $$f ]; then \ - echo "Found Source File: $$f" ; \ - else \ - echo "Source File Not Found: $$f" ; \ - fi; done - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex lss sym doxygen clean clean_list clean_doxygen \ -dfu flip checksource - +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + +# MCU name +MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ### + + +# Targeted chip architecture (see library "Architectures" documentation) +ARCH = UC3 + + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ### + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This should be the frequency the system core runs at, after the system clock +# has been set up correctly and started. +F_CPU = ### INSERT PRESCALED SYSTEM CLOCK SPEED HERE, IN HZ ### + + +# USB controller master clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency of the USB controller's clock generator in Hz. +# +# For the UC3 chips, this should be equal to 48MHz or 96MHz. +F_USB = ### INSERT CLOCK TO USB MODULE HERE, IN HZ ### + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = ### INSERT NAME OF MAIN FILENAME HERE, WITHOUT EXTENSION ### + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ### + + +# LUFA library compile-time options and predefined tokens (add '-D' before each token) +LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKENS HERE ### + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) + ### INSERT ADDITIONAL PROJECT SOURCE FILENAMES OR LUFA MODULE NAMES HERE ### + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DF_USB=$(F_USB)UL +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DARCH=ARCH_$(ARCH) +CDEFS += $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_USB=$(F_USB)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +ADEFS += -DARCH=ARCH_$(ARCH) +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_USB=$(F_USB)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CPPDEFS += -DARCH=ARCH_$(ARCH) +CPPDEFS += $(LUFA_OPTS) + + +# Debugging level. +DEBUG = 3 + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +CFLAGS += -masm-addr-pseudos +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -ffunction-sections +CPPFLAGS += -fno-strict-aliasing +CPPFLAGS += -fno-exceptions +CPPFLAGS += -masm-addr-pseudos +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--gc-sections --rodata-writable +LDFLAGS += -Wl,--direct-data +#LDFLAGS += -T linker_script.x + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr32-gcc +OBJCOPY = avr32-objcopy +OBJDUMP = avr32-objdump +SIZE = avr32-size +AR = avr32-ar rcs +NM = avr32-nm +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mpart=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mpart=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mpart=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +flip: $(TARGET).hex + batchisp -hardware usb -device $(MCU) -operation erase f + batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + +dfu: $(TARGET).hex + dfu-programmer $(MCU) erase + dfu-programmer $(MCU) flash $(TARGET).hex + dfu-programmer $(MCU) reset + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation \($(TARGET)\)... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +checksource: + @for f in $(SRC) $(CPPSRC) $(ASRC); do \ + if [ -f $$f ]; then \ + echo "Found Source File: $$f" ; \ + else \ + echo "Source File Not Found: $$f" ; \ + fi; done + + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex lss sym doxygen clean clean_list clean_doxygen \ +dfu flip checksource + diff --git a/hal/at90usb646/LUFA/CodeTemplates/makefile_template.xmega b/hal/at90usb646/LUFA/CodeTemplates/makefile_template.xmega index 245df20..3c09eff 100644 --- a/hal/at90usb646/LUFA/CodeTemplates/makefile_template.xmega +++ b/hal/at90usb646/LUFA/CodeTemplates/makefile_template.xmega @@ -1,705 +1,705 @@ -# Hey Emacs, this is a -*- makefile -*- -#---------------------------------------------------------------------------- -# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. -# >> Modified for use with the LUFA project. << -# -# Released to the Public Domain -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# Dean Camera -# Opendous Inc. -# Denver Gingerich -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# make program = Download the hex file to the device, using avrdude. -# Please customize the avrdude settings below first! -# -# make dfu = Download the hex file to the device, using dfu-programmer (must -# have dfu-programmer installed). -# -# make flip = Download the hex file to the device, using Atmel FLIP (must -# have Atmel FLIP installed). -# -# make dfu-ee = Download the eeprom file to the device, using dfu-programmer -# (must have dfu-programmer installed). -# -# make flip-ee = Download the eeprom file to the device, using Atmel FLIP -# (must have Atmel FLIP installed). -# -# make doxygen = Generate DoxyGen documentation for the project (must have -# DoxyGen installed) -# -# make debug = Start either simulavr or avarice as specified for debugging, -# with avr-gdb or avr-insight as the front end for debugging. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ### - - -# Targeted chip architecture (see library "Architectures" documentation) -ARCH = XMEGA - - -# Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called -# "Board" inside the application directory. -BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ### - - -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This should be the frequency the system core runs at, after the system clock -# has been set up correctly and started. -F_CPU = ### INSERT PRESCALED SYSTEM CLOCK SPEED HERE, IN HZ ### - - -# USB controller master clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency of the USB controller's clock generator in Hz. -# -# For the XMEGA chips, this should be equal to a multiple of 6MHz for Low -# Speed USB mode, or a multiple of 48MHz for Full Speed USB mode. -F_USB = ### INSERT CLOCK TO USB MODULE HERE, IN HZ ### - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = ### INSERT NAME OF MAIN FILENAME HERE, WITHOUT EXTENSION ### - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = . - - -# Path to the LUFA library -LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ### - - -# LUFA library compile-time options and predefined tokens (add '-D' before each token) -LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKENS HERE ### - - -# Create the LUFA source path variables by including the LUFA root makefile -include $(LUFA_PATH)/LUFA/makefile - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c \ - $(LUFA_SRC_USB) \ - $(LUFA_SRC_USBCLASS) - ### INSERT ADDITIONAL PROJECT SOURCE FILENAMES OR LUFA MODULE NAMES HERE ### - - -# List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -OPT = s - - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRAINCDIRS = $(LUFA_PATH)/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL -CDEFS += -DF_USB=$(F_USB)UL -CDEFS += -DBOARD=BOARD_$(BOARD) -CDEFS += -DARCH=ARCH_$(ARCH) -CDEFS += $(LUFA_OPTS) - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) -ADEFS += -DF_USB=$(F_USB)UL -ADEFS += -DBOARD=BOARD_$(BOARD) -ADEFS += -DARCH=ARCH_$(ARCH) -ADEFS += $(LUFA_OPTS) - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -CPPDEFS += -DF_USB=$(F_USB)UL -CPPDEFS += -DBOARD=BOARD_$(BOARD) -CPPDEFS += -DARCH=ARCH_$(ARCH) -CPPDEFS += $(LUFA_OPTS) - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -ffunction-sections -CFLAGS += -fno-inline-small-functions -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -fno-strict-aliasing -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -ffunction-sections -CPPFLAGS += -fno-strict-aliasing -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CPPFLAGS += -Wundef -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# for use in COFF files, additional information about filenames -# and function names needs to be present in the assembler source -# files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex -# dump that will be displayed for a given single line of source input. -ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt - -# If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = -#PRINTF_LIB = $(PRINTF_LIB_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt - -# If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = -#SCANF_LIB = $(SCANF_LIB_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# Each directory must be seperated by a space. -# Use forward slashes for directory separators. -# For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax -LDFLAGS += -Wl,--gc-sections -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x - - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware -# Type: avrdude -c ? -# to get a full listing. -# -AVRDUDE_PROGRAMMER = jtagmkII - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = usb - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -DEBUG_PORT = 4242 - -# Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - -# Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build sizeafter end - -# Change the build target to build a HEX file or a library. -build: elf hex eep lss sym -#build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=lib$(TARGET).a -lib: $(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf -MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) -FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) - - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - - - -# Display compiler version information. -gccversion : - @$(CC) --version - - -# Program the device. -program: $(TARGET).hex $(TARGET).eep - $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) - -flip: $(TARGET).hex - batchisp -hardware usb -device $(MCU) -operation erase f - batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program - batchisp -hardware usb -device $(MCU) -operation start reset 0 - -dfu: $(TARGET).hex - dfu-programmer $(MCU) erase - dfu-programmer $(MCU) flash $(TARGET).hex - dfu-programmer $(MCU) reset - -flip-ee: $(TARGET).hex $(TARGET).eep - $(COPY) $(TARGET).eep $(TARGET)eep.hex - batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase - batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program - batchisp -hardware usb -device $(MCU) -operation start reset 0 - $(REMOVE) $(TARGET)eep.hex - -dfu-ee: $(TARGET).hex $(TARGET).eep - dfu-programmer $(MCU) eeprom-flash $(TARGET).eep - dfu-programmer $(MCU) reset - - -# Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -S -z $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ - - -# Compile: create object files from C++ source files. -$(OBJDIR)/%.o : %.cpp - @echo - @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -clean: begin clean_list end - -clean_list : - @echo - @echo $(MSG_CLEANING) - $(REMOVE) $(TARGET).hex - $(REMOVE) $(TARGET).eep - $(REMOVE) $(TARGET).cof - $(REMOVE) $(TARGET).elf - $(REMOVE) $(TARGET).map - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVEDIR) .dep - -doxygen: - @echo Generating Project Documentation \($(TARGET)\)... - @doxygen Doxygen.conf - @echo Documentation Generation Complete. - -clean_doxygen: - rm -rf Documentation - -checksource: - @for f in $(SRC) $(CPPSRC) $(ASRC); do \ - if [ -f $$f ]; then \ - echo "Found Source File: $$f" ; \ - else \ - echo "Source File Not Found: $$f" ; \ - fi; done - - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all begin finish end sizebefore sizeafter gccversion \ -build elf hex eep lss sym coff extcoff doxygen clean \ -clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ -debug gdb-config checksource +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al. +# >> Modified for use with the LUFA project. << +# +# Released to the Public Domain +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device, using avrdude. +# Please customize the avrdude settings below first! +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make doxygen = Generate DoxyGen documentation for the project (must have +# DoxyGen installed) +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + +# MCU name +MCU = ### INSERT NAME OF MICROCONTROLLER MODEL HERE ### + + +# Targeted chip architecture (see library "Architectures" documentation) +ARCH = XMEGA + + +# Target board (see library "Board Types" documentation, NONE for projects not requiring +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# "Board" inside the application directory. +BOARD = ### INSERT NAME OF BOARD HERE, OR NONE IF NO BOARD DRIVERS USED ### + + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This should be the frequency the system core runs at, after the system clock +# has been set up correctly and started. +F_CPU = ### INSERT PRESCALED SYSTEM CLOCK SPEED HERE, IN HZ ### + + +# USB controller master clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency of the USB controller's clock generator in Hz. +# +# For the XMEGA chips, this should be equal to a multiple of 6MHz for Low +# Speed USB mode, or a multiple of 48MHz for Full Speed USB mode. +F_USB = ### INSERT CLOCK TO USB MODULE HERE, IN HZ ### + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = ### INSERT NAME OF MAIN FILENAME HERE, WITHOUT EXTENSION ### + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ### INSERT PATH TO LUFA LIBRARY RELATIVE TO PROJECT DIRECTORY HERE ### + + +# LUFA library compile-time options and predefined tokens (add '-D' before each token) +LUFA_OPTS = ### INSERT LUFA COMPILE TIME TOKENS HERE ### + + +# Create the LUFA source path variables by including the LUFA root makefile +include $(LUFA_PATH)/LUFA/makefile + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) + ### INSERT ADDITIONAL PROJECT SOURCE FILENAMES OR LUFA MODULE NAMES HERE ### + + +# List C++ source files here. (C dependencies are automatically generated.) +CPPSRC = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) +OPT = s + + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRAINCDIRS = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DF_USB=$(F_USB)UL +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += -DARCH=ARCH_$(ARCH) +CDEFS += $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_USB=$(F_USB)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +ADEFS += -DARCH=ARCH_$(ARCH) +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_USB=$(F_USB)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CPPDEFS += -DARCH=ARCH_$(ARCH) +CPPDEFS += $(LUFA_OPTS) + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -fno-strict-aliasing +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -ffunction-sections +CPPFLAGS += -fno-strict-aliasing +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# for use in COFF files, additional information about filenames +# and function names needs to be present in the assembler source +# files -- see avr-libc docs [FIXME: not yet described there] +# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# dump that will be displayed for a given single line of source input. +ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt + +# If this is left blank, then it will use the Standard printf version. +PRINTF_LIB = +#PRINTF_LIB = $(PRINTF_LIB_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt + +# If this is left blank, then it will use the Standard scanf version. +SCANF_LIB = +#SCANF_LIB = $(SCANF_LIB_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# Each directory must be seperated by a space. +# Use forward slashes for directory separators. +# For a directory that has spaces, enclose it in quotes. +EXTRALIBDIRS = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = jtagmkII + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +DEBUG_PORT = 4242 + +# Debugging host used to communicate between GDB / avarice / simulavr, normally +# just set to localhost unless doing some sort of crazy debugging when +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + +# Define all listing files. +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +program: $(TARGET).hex $(TARGET).eep + $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + +flip: $(TARGET).hex + batchisp -hardware usb -device $(MCU) -operation erase f + batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + +dfu: $(TARGET).hex + dfu-programmer $(MCU) erase + dfu-programmer $(MCU) flash $(TARGET).hex + dfu-programmer $(MCU) reset + +flip-ee: $(TARGET).hex $(TARGET).eep + $(COPY) $(TARGET).eep $(TARGET)eep.hex + batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + $(REMOVE) $(TARGET)eep.hex + +dfu-ee: $(TARGET).hex $(TARGET).eep + dfu-programmer $(MCU) eeprom-flash $(TARGET).eep + dfu-programmer $(MCU) reset + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + @echo $(MSG_COMPILING_CPP) $< + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation \($(TARGET)\)... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +checksource: + @for f in $(SRC) $(CPPSRC) $(ASRC); do \ + if [ -f $$f ]; then \ + echo "Found Source File: $$f" ; \ + else \ + echo "Source File Not Found: $$f" ; \ + fi; done + + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all begin finish end sizebefore sizeafter gccversion \ +build elf hex eep lss sym coff extcoff doxygen clean \ +clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ +debug gdb-config checksource diff --git a/hal/at90usb646/LUFA/Common/ArchitectureSpecific.h b/hal/at90usb646/LUFA/Common/ArchitectureSpecific.h index 6fc888c..3ba7a5c 100644 --- a/hal/at90usb646/LUFA/Common/ArchitectureSpecific.h +++ b/hal/at90usb646/LUFA/Common/ArchitectureSpecific.h @@ -1,148 +1,148 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Architecture specific definitions relating to specific processor architectures. - * - * \copydetails Group_ArchitectureSpecific - * - * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's - * functionality. - */ - -/** \ingroup Group_Common - * \defgroup Group_ArchitectureSpecific Architecture Specific Definitions - * \brief Architecture specific definitions relating to specific processor architectures. - * - * Architecture specific macros, functions and other definitions, which relate to specific architectures. This - * definitions may or may not be available in some form on other architectures, and thus should be protected by - * preprocessor checks in portable code to prevent compile errors. - * - * @{ - */ - -#ifndef __LUFA_ARCHSPEC_H__ -#define __LUFA_ARCHSPEC_H__ - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_COMMON_H) - #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. - #endif - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - #if (ARCH == ARCH_AVR8) || defined(__DOXYGEN__) - /** Disables the AVR's JTAG bus in software, until a system reset. This will override the current JTAG - * status as set by the JTAGEN fuse, disabling JTAG debugging and reverting the JTAG pins back to GPIO - * mode. - * - * \note This macro is not available for all architectures. - */ - #define JTAG_DISABLE() MACROS{ \ - __asm__ __volatile__ ( \ - "in __tmp_reg__,__SREG__" "\n\t" \ - "cli" "\n\t" \ - "out %1, %0" "\n\t" \ - "out __SREG__, __tmp_reg__" "\n\t" \ - "out %1, %0" "\n\t" \ - : \ - : "r" (1 << JTD), \ - "M" (_SFR_IO_ADDR(MCUCR)) \ - : "r0"); \ - }MACROE - - /** Defines a volatile \c NOP statement which cannot be optimized out by the compiler, and thus can always - * be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer - * removes/reorders code to the point where break points cannot reliably be set. - * - * \note This macro is not available for all architectures. - */ - #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::) - - /** Defines an explicit JTAG break point in the resulting binary via the assembly \c BREAK statement. When - * a JTAG is used, this causes the program execution to halt when reached until manually resumed. - * - * \note This macro is not available for all architectures. - */ - #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("break" ::) - - /** Macro for testing condition "x" and breaking via \ref JTAG_DEBUG_BREAK() if the condition is false. - * - * \note This macro is not available for all architectures. - * - * \param[in] Condition Condition that will be evaluated. - */ - #define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE - - /** Macro for testing condition \c "x" and writing debug data to the stdout stream if \c false. The stdout stream - * must be pre-initialized before this macro is run and linked to an output device, such as the microcontroller's - * USART peripheral. - * - * The output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion {Condition} failed." - * - * \note This macro is not available for all architectures. - * - * \param[in] Condition Condition that will be evaluated, - */ - #define STDOUT_ASSERT(Condition) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \ - "Assertion \"%s\" failed.\r\n"), \ - __FILE__, __func__, __LINE__, #Condition); } }MACROE - - #if !defined(pgm_read_ptr) || defined(__DOXYGEN__) - /** Reads a pointer out of PROGMEM space on the AVR8 architecture. This is currently a wrapper for the - * avr-libc \c pgm_read_ptr() macro with a \c void* cast, so that its value can be assigned directly - * to a pointer variable or used in pointer arithmetic without further casting in C. In a future - * avr-libc distribution this will be part of the standard API and will be implemented in a more formal - * manner. - * - * \note This macro is not available for all architectures. - * - * \param[in] Address Address of the pointer to read. - * - * \return Pointer retrieved from PROGMEM space. - */ - #define pgm_read_ptr(Address) (void*)pgm_read_word(Address) - #endif - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Architecture specific definitions relating to specific processor architectures. + * + * \copydetails Group_ArchitectureSpecific + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_ArchitectureSpecific Architecture Specific Definitions + * \brief Architecture specific definitions relating to specific processor architectures. + * + * Architecture specific macros, functions and other definitions, which relate to specific architectures. This + * definitions may or may not be available in some form on other architectures, and thus should be protected by + * preprocessor checks in portable code to prevent compile errors. + * + * @{ + */ + +#ifndef __LUFA_ARCHSPEC_H__ +#define __LUFA_ARCHSPEC_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (ARCH == ARCH_AVR8) || defined(__DOXYGEN__) + /** Disables the AVR's JTAG bus in software, until a system reset. This will override the current JTAG + * status as set by the JTAGEN fuse, disabling JTAG debugging and reverting the JTAG pins back to GPIO + * mode. + * + * \note This macro is not available for all architectures. + */ + #define JTAG_DISABLE() MACROS{ \ + __asm__ __volatile__ ( \ + "in __tmp_reg__,__SREG__" "\n\t" \ + "cli" "\n\t" \ + "out %1, %0" "\n\t" \ + "out __SREG__, __tmp_reg__" "\n\t" \ + "out %1, %0" "\n\t" \ + : \ + : "r" (1 << JTD), \ + "M" (_SFR_IO_ADDR(MCUCR)) \ + : "r0"); \ + }MACROE + + /** Defines a volatile \c NOP statement which cannot be optimized out by the compiler, and thus can always + * be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer + * removes/reorders code to the point where break points cannot reliably be set. + * + * \note This macro is not available for all architectures. + */ + #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::) + + /** Defines an explicit JTAG break point in the resulting binary via the assembly \c BREAK statement. When + * a JTAG is used, this causes the program execution to halt when reached until manually resumed. + * + * \note This macro is not available for all architectures. + */ + #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("break" ::) + + /** Macro for testing condition "x" and breaking via \ref JTAG_DEBUG_BREAK() if the condition is false. + * + * \note This macro is not available for all architectures. + * + * \param[in] Condition Condition that will be evaluated. + */ + #define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE + + /** Macro for testing condition \c "x" and writing debug data to the stdout stream if \c false. The stdout stream + * must be pre-initialized before this macro is run and linked to an output device, such as the microcontroller's + * USART peripheral. + * + * The output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion {Condition} failed." + * + * \note This macro is not available for all architectures. + * + * \param[in] Condition Condition that will be evaluated, + */ + #define STDOUT_ASSERT(Condition) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \ + "Assertion \"%s\" failed.\r\n"), \ + __FILE__, __func__, __LINE__, #Condition); } }MACROE + + #if !defined(pgm_read_ptr) || defined(__DOXYGEN__) + /** Reads a pointer out of PROGMEM space on the AVR8 architecture. This is currently a wrapper for the + * avr-libc \c pgm_read_ptr() macro with a \c void* cast, so that its value can be assigned directly + * to a pointer variable or used in pointer arithmetic without further casting in C. In a future + * avr-libc distribution this will be part of the standard API and will be implemented in a more formal + * manner. + * + * \note This macro is not available for all architectures. + * + * \param[in] Address Address of the pointer to read. + * + * \return Pointer retrieved from PROGMEM space. + */ + #define pgm_read_ptr(Address) (void*)pgm_read_word(Address) + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Common/Architectures.h b/hal/at90usb646/LUFA/Common/Architectures.h index 8941f7c..8104d52 100644 --- a/hal/at90usb646/LUFA/Common/Architectures.h +++ b/hal/at90usb646/LUFA/Common/Architectures.h @@ -1,84 +1,84 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Supported library architecture defines. - * - * \copydetails Group_Architectures - * - * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's - * functionality. - */ - -/** \ingroup Group_Common - * \defgroup Group_Architectures Hardware Architectures - * \brief Supported library architecture defines. - * - * Architecture macros for selecting the desired target microcontroller architecture. One of these values should be - * defined as the value of \c ARCH in the user project makefile via the \c -D compiler switch to GCC, to select the - * target architecture. - * - * The selected architecture should remain consistent with the makefile \c ARCH value, which is used to select the - * underlying driver source files for each architecture. - * - * @{ - */ - -#ifndef __LUFA_ARCHITECTURES_H__ -#define __LUFA_ARCHITECTURES_H__ - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_COMMON_H) - #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Selects the Atmel 8-bit AVR (AT90USB* and ATMEGA*U* chips) architecture. */ - #define ARCH_AVR8 0 - - /** Selects the Atmel 32-bit UC3 AVR (AT32UC3* chips) architecture. */ - #define ARCH_UC3 1 - - /** Selects the Atmel XMEGA AVR (ATXMEGA*U chips) architecture. */ - #define ARCH_XMEGA 2 - - #if !defined(__DOXYGEN__) - #define ARCH_ ARCH_AVR8 - - #if !defined(ARCH) - #define ARCH ARCH_AVR8 - #endif - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Supported library architecture defines. + * + * \copydetails Group_Architectures + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_Architectures Hardware Architectures + * \brief Supported library architecture defines. + * + * Architecture macros for selecting the desired target microcontroller architecture. One of these values should be + * defined as the value of \c ARCH in the user project makefile via the \c -D compiler switch to GCC, to select the + * target architecture. + * + * The selected architecture should remain consistent with the makefile \c ARCH value, which is used to select the + * underlying driver source files for each architecture. + * + * @{ + */ + +#ifndef __LUFA_ARCHITECTURES_H__ +#define __LUFA_ARCHITECTURES_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Selects the Atmel 8-bit AVR (AT90USB* and ATMEGA*U* chips) architecture. */ + #define ARCH_AVR8 0 + + /** Selects the Atmel 32-bit UC3 AVR (AT32UC3* chips) architecture. */ + #define ARCH_UC3 1 + + /** Selects the Atmel XMEGA AVR (ATXMEGA*U chips) architecture. */ + #define ARCH_XMEGA 2 + + #if !defined(__DOXYGEN__) + #define ARCH_ ARCH_AVR8 + + #if !defined(ARCH) + #define ARCH ARCH_AVR8 + #endif + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Common/Attributes.h b/hal/at90usb646/LUFA/Common/Attributes.h index 066cafa..ee83db1 100644 --- a/hal/at90usb646/LUFA/Common/Attributes.h +++ b/hal/at90usb646/LUFA/Common/Attributes.h @@ -1,150 +1,150 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Special function/variable attribute macros. - * - * \copydetails Group_FuncVarAttributes - * - * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's - * functionality. - */ - -/** \ingroup Group_Common - * \defgroup Group_FuncVarAttributes Function/Variable Attributes - * \brief Special function/variable attribute macros. - * - * This module contains macros for applying specific attributes to functions and variables to control various - * optimizer and code generation features of the compiler. Attributes may be placed in the function prototype - * or variable declaration in any order, and multiple attributes can be specified for a single item via a space - * separated list. - * - * On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are - * critical to the code's function and thus must throw a compile error when used. - * - * @{ - */ - -#ifndef __LUFA_FUNCATTR_H__ -#define __LUFA_FUNCATTR_H__ - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_COMMON_H) - #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - #if (__GNUC__ >= 3) || defined(__DOXYGEN__) - /** Indicates to the compiler that the function can not ever return, so that any stack restoring or - * return code may be omitted by the compiler in the resulting binary. - */ - #define ATTR_NO_RETURN __attribute__ ((noreturn)) - - /** Indicates that the function returns a value which should not be ignored by the user code. When - * applied, any ignored return value from calling the function will produce a compiler warning. - */ - #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) - - /** Indicates that the specified parameters of the function are pointers which should never be \c NULL. - * When applied as a 1-based comma separated list the compiler will emit a warning if the specified - * parameters are known at compiler time to be \c NULL at the point of calling the function. - */ - #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__))) - - /** Removes any preamble or postamble from the function. When used, the function will not have any - * register or stack saving code. This should be used with caution, and when used the programmer - * is responsible for maintaining stack and register integrity. - */ - #define ATTR_NAKED __attribute__ ((naked)) - - /** Prevents the compiler from considering a specified function for in-lining. When applied, the given - * function will not be in-lined under any circumstances. - */ - #define ATTR_NO_INLINE __attribute__ ((noinline)) - - /** Forces the compiler to inline the specified function. When applied, the given function will be - * in-lined under all circumstances. - */ - #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) - - /** Indicates that the specified function is pure, in that it has no side-effects other than global - * or parameter variable access. - */ - #define ATTR_PURE __attribute__ ((pure)) - - /** Indicates that the specified function is constant, in that it has no side effects other than - * parameter access. - */ - #define ATTR_CONST __attribute__ ((const)) - - /** Marks a given function as deprecated, which produces a warning if the function is called. */ - #define ATTR_DEPRECATED __attribute__ ((deprecated)) - - /** Marks a function as a weak reference, which can be overridden by other functions with an - * identical name (in which case the weak reference is discarded at link time). - */ - #define ATTR_WEAK __attribute__ ((weak)) - #endif - - /** Forces the compiler to not automatically zero the given global variable on startup, so that the - * current RAM contents is retained. Under most conditions this value will be random due to the - * behaviour of volatile memory once power is removed, but may be used in some specific circumstances, - * like the passing of values back after a system watchdog reset. - */ - #define ATTR_NO_INIT __attribute__ ((section (".noinit"))) - - /** Places the function in one of the initialization sections, which execute before the main function - * of the application. Refer to the avr-libc manual for more information on the initialization sections. - * - * \param[in] SectionIndex Initialization section number where the function should be placed. - */ - #define ATTR_INIT_SECTION(SectionIndex) __attribute__ ((used, naked, section (".init" #SectionIndex ))) - - /** Marks a function as an alias for another function. - * - * \param[in] Func Name of the function which the given function name should alias. - */ - #define ATTR_ALIAS(Func) __attribute__ ((alias( #Func ))) - - /** Marks a variable or struct element for packing into the smallest space available, omitting any - * alignment bytes usually added between fields to optimize field accesses. - */ - #define ATTR_PACKED __attribute__ ((packed)) - - /** Indicates the minimum alignment in bytes for a variable or struct element. - * - * \param[in] Bytes Minimum number of bytes the item should be aligned to. - */ - #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Special function/variable attribute macros. + * + * \copydetails Group_FuncVarAttributes + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_FuncVarAttributes Function/Variable Attributes + * \brief Special function/variable attribute macros. + * + * This module contains macros for applying specific attributes to functions and variables to control various + * optimizer and code generation features of the compiler. Attributes may be placed in the function prototype + * or variable declaration in any order, and multiple attributes can be specified for a single item via a space + * separated list. + * + * On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are + * critical to the code's function and thus must throw a compile error when used. + * + * @{ + */ + +#ifndef __LUFA_FUNCATTR_H__ +#define __LUFA_FUNCATTR_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (__GNUC__ >= 3) || defined(__DOXYGEN__) + /** Indicates to the compiler that the function can not ever return, so that any stack restoring or + * return code may be omitted by the compiler in the resulting binary. + */ + #define ATTR_NO_RETURN __attribute__ ((noreturn)) + + /** Indicates that the function returns a value which should not be ignored by the user code. When + * applied, any ignored return value from calling the function will produce a compiler warning. + */ + #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) + + /** Indicates that the specified parameters of the function are pointers which should never be \c NULL. + * When applied as a 1-based comma separated list the compiler will emit a warning if the specified + * parameters are known at compiler time to be \c NULL at the point of calling the function. + */ + #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__))) + + /** Removes any preamble or postamble from the function. When used, the function will not have any + * register or stack saving code. This should be used with caution, and when used the programmer + * is responsible for maintaining stack and register integrity. + */ + #define ATTR_NAKED __attribute__ ((naked)) + + /** Prevents the compiler from considering a specified function for in-lining. When applied, the given + * function will not be in-lined under any circumstances. + */ + #define ATTR_NO_INLINE __attribute__ ((noinline)) + + /** Forces the compiler to inline the specified function. When applied, the given function will be + * in-lined under all circumstances. + */ + #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) + + /** Indicates that the specified function is pure, in that it has no side-effects other than global + * or parameter variable access. + */ + #define ATTR_PURE __attribute__ ((pure)) + + /** Indicates that the specified function is constant, in that it has no side effects other than + * parameter access. + */ + #define ATTR_CONST __attribute__ ((const)) + + /** Marks a given function as deprecated, which produces a warning if the function is called. */ + #define ATTR_DEPRECATED __attribute__ ((deprecated)) + + /** Marks a function as a weak reference, which can be overridden by other functions with an + * identical name (in which case the weak reference is discarded at link time). + */ + #define ATTR_WEAK __attribute__ ((weak)) + #endif + + /** Forces the compiler to not automatically zero the given global variable on startup, so that the + * current RAM contents is retained. Under most conditions this value will be random due to the + * behaviour of volatile memory once power is removed, but may be used in some specific circumstances, + * like the passing of values back after a system watchdog reset. + */ + #define ATTR_NO_INIT __attribute__ ((section (".noinit"))) + + /** Places the function in one of the initialization sections, which execute before the main function + * of the application. Refer to the avr-libc manual for more information on the initialization sections. + * + * \param[in] SectionIndex Initialization section number where the function should be placed. + */ + #define ATTR_INIT_SECTION(SectionIndex) __attribute__ ((used, naked, section (".init" #SectionIndex ))) + + /** Marks a function as an alias for another function. + * + * \param[in] Func Name of the function which the given function name should alias. + */ + #define ATTR_ALIAS(Func) __attribute__ ((alias( #Func ))) + + /** Marks a variable or struct element for packing into the smallest space available, omitting any + * alignment bytes usually added between fields to optimize field accesses. + */ + #define ATTR_PACKED __attribute__ ((packed)) + + /** Indicates the minimum alignment in bytes for a variable or struct element. + * + * \param[in] Bytes Minimum number of bytes the item should be aligned to. + */ + #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Common/BoardTypes.h b/hal/at90usb646/LUFA/Common/BoardTypes.h index 2e6b1b9..5676060 100644 --- a/hal/at90usb646/LUFA/Common/BoardTypes.h +++ b/hal/at90usb646/LUFA/Common/BoardTypes.h @@ -1,212 +1,212 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Supported pre-made board hardware defines. - * - * \copydetails Group_BoardTypes - * - * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's - * functionality. - */ - -/** \ingroup Group_Common - * \defgroup Group_BoardTypes Board Types - * \brief Supported pre-made board hardware defines. - * - * Board macros for indicating the chosen physical board hardware to the library. These macros should be used when - * defining the \c BOARD token to the chosen hardware via the \c -D switch in the project makefile. If a custom - * board is used, the \ref BOARD_NONE or \ref BOARD_USER values should be selected. - * - * @{ - */ - -#ifndef __LUFA_BOARDTYPES_H__ -#define __LUFA_BOARDTYPES_H__ - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_COMMON_H) - #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Selects the user-defined board drivers, which should be placed in the user project's folder - * under a directory named \c /Board/. Each board driver should be named identically to the LUFA - * master board driver (i.e., driver in the \c LUFA/Drivers/Board directory) so that the library - * can correctly identify it. - */ - #define BOARD_USER 0 - - /** Disables board drivers when operation will not be adversely affected (e.g. LEDs) - use of board drivers - * such as the Joystick driver, where the removal would adversely affect the code's operation is still disallowed. */ - #define BOARD_NONE 1 - - /** Selects the USBKEY specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ - #define BOARD_USBKEY 2 - - /** Selects the STK525 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ - #define BOARD_STK525 3 - - /** Selects the STK526 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ - #define BOARD_STK526 4 - - /** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */ - #define BOARD_RZUSBSTICK 5 - - /** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */ - #define BOARD_ATAVRUSBRF01 6 - - /** Selects the BUMBLEB specific board drivers, using the officially recommended peripheral layout. */ - #define BOARD_BUMBLEB 7 - - /** Selects the XPLAIN (Revision 2 or newer) specific board drivers, including LED and Dataflash drivers. */ - #define BOARD_XPLAIN 8 - - /** Selects the XPLAIN (Revision 1) specific board drivers, including LED and Dataflash drivers. */ - #define BOARD_XPLAIN_REV1 9 - - /** Selects the EVK527 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ - #define BOARD_EVK527 10 - - /** Selects the Teensy version 1.x specific board drivers, including the driver for the board LEDs. */ - #define BOARD_TEENSY 11 - - /** Selects the USBTINY MKII specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_USBTINYMKII 12 - - /** Selects the Benito specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_BENITO 13 - - /** Selects the JM-DB-U2 specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_JMDBU2 14 - - /** Selects the Olimex AVR-USB-162 specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_OLIMEX162 15 - - /** Selects the UDIP specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_UDIP 16 - - /** Selects the BUI specific board drivers, including the driver for the board LEDs. */ - #define BOARD_BUI 17 - - /** Selects the Arduino Uno specific board drivers, including the driver for the board LEDs. */ - #define BOARD_UNO 18 - - /** Selects the Busware CUL V3 specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_CULV3 19 - - /** Selects the Blackcat USB JTAG specific board drivers, including the driver for the board LEDs. */ - #define BOARD_BLACKCAT 20 - - /** Selects the Maximus specific board drivers, including the driver for the board LEDs. */ - #define BOARD_MAXIMUS 21 - - /** Selects the Minimus specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_MINIMUS 22 - - /** Selects the Adafruit U4 specific board drivers, including the Button driver. */ - #define BOARD_ADAFRUITU4 23 - - /** Selects the Microsin AVR-USB162 specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_MICROSIN162 24 - - /** Selects the Kernel Concepts USBFOO specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_USBFOO 25 - - /** Selects the Sparkfun ATMEGA8U2 specific board drivers, including the driver for the board LEDs. */ - #define BOARD_SPARKFUN8U2 26 - - /** Selects the Atmel EVK1101 specific board drivers, including the Button, Joystick and LED drivers. */ - #define BOARD_EVK1101 27 - - /** Selects the Busware TUL specific board drivers, including the Button and LED drivers. */ - #define BOARD_TUL 28 - - /** Selects the Atmel EVK1100 specific board drivers, including the Button, Joystick and LED drivers. */ - #define BOARD_EVK1100 29 - - /** Selects the Atmel EVK1104 specific board drivers, including the Button and LED drivers. */ - #define BOARD_EVK1104 30 - - /** Selects the Atmel XMEGA A3BU Xplained specific board drivers, including Dataflash, Button and LED drivers. */ - #define BOARD_A3BU_XPLAINED 31 - - /** Selects the Teensy version 2.x specific board drivers, including the driver for the board LEDs. */ - #define BOARD_TEENSY2 32 - - /** Selects the USB2AX version 1 and 2 specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_USB2AX 33 - - /** Selects the USB2AX version 3 specific board drivers, including the Button and LEDs drivers. */ - #define BOARD_USB2AX_V3 34 - - /** Selects the Micropendous 32U2 specific board drivers, including the Button and LED drivers. */ - #define BOARD_MICROPENDOUS_32U2 35 - - /** Selects the Micropendous A specific board drivers, including the Button. */ - #define BOARD_MICROPENDOUS_A 36 - - /** Selects the Micropendous 1 specific board drivers, including the Button. */ - #define BOARD_MICROPENDOUS_1 37 - - /** Selects the Micropendous 2 specific board drivers, including the Button. */ - #define BOARD_MICROPENDOUS_2 38 - - /** Selects the Micropendous 3 specific board drivers, including the Button. */ - #define BOARD_MICROPENDOUS_3 39 - - /** Selects the Micropendous 4 specific board drivers, including the Button. */ - #define BOARD_MICROPENDOUS_4 40 - - /** Selects the Micropendous DIP specific board drivers, including the Button. */ - #define BOARD_MICROPENDOUS_DIP 41 - - /** Selects the Micropendous (Arduino-like) revision 1 specific board drivers, including the Button and LED drivers. */ - #define BOARD_MICROPENDOUS_REV1 42 - - /** Selects the Micropendous (Arduino-like) revision 2 specific board drivers, including the Button and LED drivers. */ - #define BOARD_MICROPENDOUS_REV2 43 - - /** Selects the XMEGA B1 Xplained specific board drivers, including the Button and LED drivers. */ - #define BOARD_B1_XPLAINED 44 - - #if !defined(__DOXYGEN__) - #define BOARD_ BOARD_NONE - - #if !defined(BOARD) - #define BOARD BOARD_NONE - #endif - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Supported pre-made board hardware defines. + * + * \copydetails Group_BoardTypes + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_BoardTypes Board Types + * \brief Supported pre-made board hardware defines. + * + * Board macros for indicating the chosen physical board hardware to the library. These macros should be used when + * defining the \c BOARD token to the chosen hardware via the \c -D switch in the project makefile. If a custom + * board is used, the \ref BOARD_NONE or \ref BOARD_USER values should be selected. + * + * @{ + */ + +#ifndef __LUFA_BOARDTYPES_H__ +#define __LUFA_BOARDTYPES_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Selects the user-defined board drivers, which should be placed in the user project's folder + * under a directory named \c /Board/. Each board driver should be named identically to the LUFA + * master board driver (i.e., driver in the \c LUFA/Drivers/Board directory) so that the library + * can correctly identify it. + */ + #define BOARD_USER 0 + + /** Disables board drivers when operation will not be adversely affected (e.g. LEDs) - use of board drivers + * such as the Joystick driver, where the removal would adversely affect the code's operation is still disallowed. */ + #define BOARD_NONE 1 + + /** Selects the USBKEY specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_USBKEY 2 + + /** Selects the STK525 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_STK525 3 + + /** Selects the STK526 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_STK526 4 + + /** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */ + #define BOARD_RZUSBSTICK 5 + + /** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */ + #define BOARD_ATAVRUSBRF01 6 + + /** Selects the BUMBLEB specific board drivers, using the officially recommended peripheral layout. */ + #define BOARD_BUMBLEB 7 + + /** Selects the XPLAIN (Revision 2 or newer) specific board drivers, including LED and Dataflash drivers. */ + #define BOARD_XPLAIN 8 + + /** Selects the XPLAIN (Revision 1) specific board drivers, including LED and Dataflash drivers. */ + #define BOARD_XPLAIN_REV1 9 + + /** Selects the EVK527 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_EVK527 10 + + /** Selects the Teensy version 1.x specific board drivers, including the driver for the board LEDs. */ + #define BOARD_TEENSY 11 + + /** Selects the USBTINY MKII specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USBTINYMKII 12 + + /** Selects the Benito specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_BENITO 13 + + /** Selects the JM-DB-U2 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_JMDBU2 14 + + /** Selects the Olimex AVR-USB-162 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_OLIMEX162 15 + + /** Selects the UDIP specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_UDIP 16 + + /** Selects the BUI specific board drivers, including the driver for the board LEDs. */ + #define BOARD_BUI 17 + + /** Selects the Arduino Uno specific board drivers, including the driver for the board LEDs. */ + #define BOARD_UNO 18 + + /** Selects the Busware CUL V3 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_CULV3 19 + + /** Selects the Blackcat USB JTAG specific board drivers, including the driver for the board LEDs. */ + #define BOARD_BLACKCAT 20 + + /** Selects the Maximus specific board drivers, including the driver for the board LEDs. */ + #define BOARD_MAXIMUS 21 + + /** Selects the Minimus specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_MINIMUS 22 + + /** Selects the Adafruit U4 specific board drivers, including the Button driver. */ + #define BOARD_ADAFRUITU4 23 + + /** Selects the Microsin AVR-USB162 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_MICROSIN162 24 + + /** Selects the Kernel Concepts USBFOO specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USBFOO 25 + + /** Selects the Sparkfun ATMEGA8U2 specific board drivers, including the driver for the board LEDs. */ + #define BOARD_SPARKFUN8U2 26 + + /** Selects the Atmel EVK1101 specific board drivers, including the Button, Joystick and LED drivers. */ + #define BOARD_EVK1101 27 + + /** Selects the Busware TUL specific board drivers, including the Button and LED drivers. */ + #define BOARD_TUL 28 + + /** Selects the Atmel EVK1100 specific board drivers, including the Button, Joystick and LED drivers. */ + #define BOARD_EVK1100 29 + + /** Selects the Atmel EVK1104 specific board drivers, including the Button and LED drivers. */ + #define BOARD_EVK1104 30 + + /** Selects the Atmel XMEGA A3BU Xplained specific board drivers, including Dataflash, Button and LED drivers. */ + #define BOARD_A3BU_XPLAINED 31 + + /** Selects the Teensy version 2.x specific board drivers, including the driver for the board LEDs. */ + #define BOARD_TEENSY2 32 + + /** Selects the USB2AX version 1 and 2 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USB2AX 33 + + /** Selects the USB2AX version 3 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USB2AX_V3 34 + + /** Selects the Micropendous 32U2 specific board drivers, including the Button and LED drivers. */ + #define BOARD_MICROPENDOUS_32U2 35 + + /** Selects the Micropendous A specific board drivers, including the Button. */ + #define BOARD_MICROPENDOUS_A 36 + + /** Selects the Micropendous 1 specific board drivers, including the Button. */ + #define BOARD_MICROPENDOUS_1 37 + + /** Selects the Micropendous 2 specific board drivers, including the Button. */ + #define BOARD_MICROPENDOUS_2 38 + + /** Selects the Micropendous 3 specific board drivers, including the Button. */ + #define BOARD_MICROPENDOUS_3 39 + + /** Selects the Micropendous 4 specific board drivers, including the Button. */ + #define BOARD_MICROPENDOUS_4 40 + + /** Selects the Micropendous DIP specific board drivers, including the Button. */ + #define BOARD_MICROPENDOUS_DIP 41 + + /** Selects the Micropendous (Arduino-like) revision 1 specific board drivers, including the Button and LED drivers. */ + #define BOARD_MICROPENDOUS_REV1 42 + + /** Selects the Micropendous (Arduino-like) revision 2 specific board drivers, including the Button and LED drivers. */ + #define BOARD_MICROPENDOUS_REV2 43 + + /** Selects the XMEGA B1 Xplained specific board drivers, including the Button and LED drivers. */ + #define BOARD_B1_XPLAINED 44 + + #if !defined(__DOXYGEN__) + #define BOARD_ BOARD_NONE + + #if !defined(BOARD) + #define BOARD BOARD_NONE + #endif + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Common/Common.h b/hal/at90usb646/LUFA/Common/Common.h index 922747c..4c9aa49 100644 --- a/hal/at90usb646/LUFA/Common/Common.h +++ b/hal/at90usb646/LUFA/Common/Common.h @@ -1,375 +1,375 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common library convenience headers, macros and functions. - * - * \copydetails Group_Common - */ - -/** \defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h - * \brief Common library convenience headers, macros and functions. - * - * Common utility headers containing macros, functions, enums and types which are common to all - * aspects of the library. - * - * @{ - */ - -/** \defgroup Group_GlobalInt Global Interrupt Macros - * \brief Convenience macros for the management of interrupts globally within the device. - * - * Macros and functions to create and control global interrupts within the device. - */ - -#ifndef __LUFA_COMMON_H__ -#define __LUFA_COMMON_H__ - - /* Macros: */ - #define __INCLUDE_FROM_COMMON_H - - /* Includes: */ - #include - #include - #include - #include - - #if defined(USE_LUFA_CONFIG_HEADER) - #include "LUFAConfig.h" - #endif - - #include "Architectures.h" - #include "BoardTypes.h" - #include "ArchitectureSpecific.h" - #include "CompilerSpecific.h" - #include "Attributes.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Architecture specific utility includes: */ - #if defined(__DOXYGEN__) - /** Type define for an unsigned integer the same width as the selected architecture's machine register. - * This is distinct from the non-specific standard int data type, whose width is machine dependant but - * which may not reflect the actual machine register width on some targets (e.g. AVR8). - */ - typedef MACHINE_REG_t uint_reg_t; - #elif (ARCH == ARCH_AVR8) - #include - #include - #include - #include - #include - #include - #include - - typedef uint8_t uint_reg_t; - - #define ARCH_HAS_EEPROM_ADDRESS_SPACE - #define ARCH_HAS_FLASH_ADDRESS_SPACE - #define ARCH_HAS_MULTI_ADDRESS_SPACE - #define ARCH_LITTLE_ENDIAN - - #include "Endianness.h" - #elif (ARCH == ARCH_UC3) - #include - - // === TODO: Find abstracted way to handle these === - #define PROGMEM const - #define pgm_read_byte(x) *x - #define memcmp_P(...) memcmp(__VA_ARGS__) - #define memcpy_P(...) memcpy(__VA_ARGS__) - // ================================================= - - typedef uint32_t uint_reg_t; - - #define ARCH_BIG_ENDIAN - - #include "Endianness.h" - #elif (ARCH == ARCH_XMEGA) - #include - #include - #include - #include - #include - #include - - typedef uint8_t uint_reg_t; - - #define ARCH_HAS_EEPROM_ADDRESS_SPACE - #define ARCH_HAS_FLASH_ADDRESS_SPACE - #define ARCH_HAS_MULTI_ADDRESS_SPACE - #define ARCH_LITTLE_ENDIAN - - #include "Endianness.h" - #else - #error Unknown device architecture specified. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Macro for encasing other multi-statement macros. This should be used along with an opening brace - * before the start of any multi-statement macro, so that the macros contents as a whole are treated - * as a discrete block and not as a list of separate statements which may cause problems when used as - * a block (such as inline \c if statements). - */ - #define MACROS do - - /** Macro for encasing other multi-statement macros. This should be used along with a preceding closing - * brace at the end of any multi-statement macro, so that the macros contents as a whole are treated - * as a discrete block and not as a list of separate statements which may cause problems when used as - * a block (such as inline \c if statements). - */ - #define MACROE while (0) - - /** Convenience macro to determine the larger of two values. - * - * \note This macro should only be used with operands that do not have side effects from being evaluated - * multiple times. - * - * \param[in] x First value to compare - * \param[in] y First value to compare - * - * \return The larger of the two input parameters - */ - #if !defined(MAX) || defined(__DOXYGEN__) - #define MAX(x, y) (((x) > (y)) ? (x) : (y)) - #endif - - /** Convenience macro to determine the smaller of two values. - * - * \note This macro should only be used with operands that do not have side effects from being evaluated - * multiple times. - * - * \param[in] x First value to compare - * \param[in] y First value to compare - * - * \return The smaller of the two input parameters - */ - #if !defined(MIN) || defined(__DOXYGEN__) - #define MIN(x, y) (((x) < (y)) ? (x) : (y)) - #endif - - #if !defined(STRINGIFY) || defined(__DOXYGEN__) - /** Converts the given input into a string, via the C Preprocessor. This macro puts literal quotation - * marks around the input, converting the source into a string literal. - * - * \param[in] x Input to convert into a string literal. - * - * \return String version of the input. - */ - #define STRINGIFY(x) #x - - /** Converts the given input into a string after macro expansion, via the C Preprocessor. This macro puts - * literal quotation marks around the expanded input, converting the source into a string literal. - * - * \param[in] x Input to expand and convert into a string literal. - * - * \return String version of the expanded input. - */ - #define STRINGIFY_EXPANDED(x) STRINGIFY(x) - #endif - - #if !defined(ISR) || defined(__DOXYGEN__) - /** Macro for the definition of interrupt service routines, so that the compiler can insert the required - * prologue and epilogue code to properly manage the interrupt routine without affecting the main thread's - * state with unintentional side-effects. - * - * Interrupt handlers written using this macro may still need to be registered with the microcontroller's - * Interrupt Controller (if present) before they will properly handle incoming interrupt events. - * - * \note This macro is only supplied on some architectures, where the standard library does not include a valid - * definition. If an existing definition exists, the alternative definition here will be ignored. - * - * \ingroup Group_GlobalInt - * - * \param Name Unique name of the interrupt service routine. - */ - #define ISR(Name, ...) void Name (void) __attribute__((__interrupt__)) __VA_ARGS__; void Name (void) - #endif - - /* Inline Functions: */ - /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1, - * etc. - * - * \param[in] Byte Byte of data whose bits are to be reversed. - * - * \return Input data with the individual bits reversed (mirrored). - */ - static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST; - static inline uint8_t BitReverse(uint8_t Byte) - { - Byte = (((Byte & 0xF0) >> 4) | ((Byte & 0x0F) << 4)); - Byte = (((Byte & 0xCC) >> 2) | ((Byte & 0x33) << 2)); - Byte = (((Byte & 0xAA) >> 1) | ((Byte & 0x55) << 1)); - - return Byte; - } - - /** Function to perform a blocking delay for a specified number of milliseconds. The actual delay will be - * at a minimum the specified number of milliseconds, however due to loop overhead and internal calculations - * may be slightly higher. - * - * \param[in] Milliseconds Number of milliseconds to delay - */ - static inline void Delay_MS(uint16_t Milliseconds) ATTR_ALWAYS_INLINE; - static inline void Delay_MS(uint16_t Milliseconds) - { - #if (ARCH == ARCH_AVR8) - if (GCC_IS_COMPILE_CONST(Milliseconds)) - { - _delay_ms(Milliseconds); - } - else - { - while (Milliseconds--) - _delay_ms(1); - } - #elif (ARCH == ARCH_UC3) - while (Milliseconds--) - { - __builtin_mtsr(AVR32_COUNT, 0); - while ((uint32_t)__builtin_mfsr(AVR32_COUNT) < (F_CPU / 1000)); - } - #elif (ARCH == ARCH_XMEGA) - if (GCC_IS_COMPILE_CONST(Milliseconds)) - { - _delay_ms(Milliseconds); - } - else - { - while (Milliseconds--) - _delay_ms(1); - } - #endif - } - - /** Retrieves a mask which contains the current state of the global interrupts for the device. This - * value can be stored before altering the global interrupt enable state, before restoring the - * flag(s) back to their previous values after a critical section using \ref SetGlobalInterruptMask(). - * - * \ingroup Group_GlobalInt - * - * \return Mask containing the current Global Interrupt Enable Mask bit(s). - */ - static inline uint_reg_t GetGlobalInterruptMask(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline uint_reg_t GetGlobalInterruptMask(void) - { - GCC_MEMORY_BARRIER(); - - #if (ARCH == ARCH_AVR8) - return SREG; - #elif (ARCH == ARCH_UC3) - return __builtin_mfsr(AVR32_SR); - #elif (ARCH == ARCH_XMEGA) - return SREG; - #endif - - GCC_MEMORY_BARRIER(); - } - - /** Sets the global interrupt enable state of the microcontroller to the mask passed into the function. - * This can be combined with \ref GetGlobalInterruptMask() to save and restore the Global Interrupt Enable - * Mask bit(s) of the device after a critical section has completed. - * - * \ingroup Group_GlobalInt - * - * \param[in] GlobalIntState Global Interrupt Enable Mask value to use - */ - static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) ATTR_ALWAYS_INLINE; - static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) - { - GCC_MEMORY_BARRIER(); - - #if (ARCH == ARCH_AVR8) - SREG = GlobalIntState; - #elif (ARCH == ARCH_UC3) - if (GlobalIntState & AVR32_SR_GM) - __builtin_ssrf(AVR32_SR_GM_OFFSET); - else - __builtin_csrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - SREG = GlobalIntState; - #endif - - GCC_MEMORY_BARRIER(); - } - - /** Enables global interrupt handling for the device, allowing interrupts to be handled. - * - * \ingroup Group_GlobalInt - */ - static inline void GlobalInterruptEnable(void) ATTR_ALWAYS_INLINE; - static inline void GlobalInterruptEnable(void) - { - GCC_MEMORY_BARRIER(); - - #if (ARCH == ARCH_AVR8) - sei(); - #elif (ARCH == ARCH_UC3) - __builtin_csrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - sei(); - #endif - - GCC_MEMORY_BARRIER(); - } - - /** Disabled global interrupt handling for the device, preventing interrupts from being handled. - * - * \ingroup Group_GlobalInt - */ - static inline void GlobalInterruptDisable(void) ATTR_ALWAYS_INLINE; - static inline void GlobalInterruptDisable(void) - { - GCC_MEMORY_BARRIER(); - - #if (ARCH == ARCH_AVR8) - cli(); - #elif (ARCH == ARCH_UC3) - __builtin_ssrf(AVR32_SR_GM_OFFSET); - #elif (ARCH == ARCH_XMEGA) - cli(); - #endif - - GCC_MEMORY_BARRIER(); - } - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common library convenience headers, macros and functions. + * + * \copydetails Group_Common + */ + +/** \defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h + * \brief Common library convenience headers, macros and functions. + * + * Common utility headers containing macros, functions, enums and types which are common to all + * aspects of the library. + * + * @{ + */ + +/** \defgroup Group_GlobalInt Global Interrupt Macros + * \brief Convenience macros for the management of interrupts globally within the device. + * + * Macros and functions to create and control global interrupts within the device. + */ + +#ifndef __LUFA_COMMON_H__ +#define __LUFA_COMMON_H__ + + /* Macros: */ + #define __INCLUDE_FROM_COMMON_H + + /* Includes: */ + #include + #include + #include + #include + + #if defined(USE_LUFA_CONFIG_HEADER) + #include "LUFAConfig.h" + #endif + + #include "Architectures.h" + #include "BoardTypes.h" + #include "ArchitectureSpecific.h" + #include "CompilerSpecific.h" + #include "Attributes.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Architecture specific utility includes: */ + #if defined(__DOXYGEN__) + /** Type define for an unsigned integer the same width as the selected architecture's machine register. + * This is distinct from the non-specific standard int data type, whose width is machine dependant but + * which may not reflect the actual machine register width on some targets (e.g. AVR8). + */ + typedef MACHINE_REG_t uint_reg_t; + #elif (ARCH == ARCH_AVR8) + #include + #include + #include + #include + #include + #include + #include + + typedef uint8_t uint_reg_t; + + #define ARCH_HAS_EEPROM_ADDRESS_SPACE + #define ARCH_HAS_FLASH_ADDRESS_SPACE + #define ARCH_HAS_MULTI_ADDRESS_SPACE + #define ARCH_LITTLE_ENDIAN + + #include "Endianness.h" + #elif (ARCH == ARCH_UC3) + #include + + // === TODO: Find abstracted way to handle these === + #define PROGMEM const + #define pgm_read_byte(x) *x + #define memcmp_P(...) memcmp(__VA_ARGS__) + #define memcpy_P(...) memcpy(__VA_ARGS__) + // ================================================= + + typedef uint32_t uint_reg_t; + + #define ARCH_BIG_ENDIAN + + #include "Endianness.h" + #elif (ARCH == ARCH_XMEGA) + #include + #include + #include + #include + #include + #include + + typedef uint8_t uint_reg_t; + + #define ARCH_HAS_EEPROM_ADDRESS_SPACE + #define ARCH_HAS_FLASH_ADDRESS_SPACE + #define ARCH_HAS_MULTI_ADDRESS_SPACE + #define ARCH_LITTLE_ENDIAN + + #include "Endianness.h" + #else + #error Unknown device architecture specified. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Macro for encasing other multi-statement macros. This should be used along with an opening brace + * before the start of any multi-statement macro, so that the macros contents as a whole are treated + * as a discrete block and not as a list of separate statements which may cause problems when used as + * a block (such as inline \c if statements). + */ + #define MACROS do + + /** Macro for encasing other multi-statement macros. This should be used along with a preceding closing + * brace at the end of any multi-statement macro, so that the macros contents as a whole are treated + * as a discrete block and not as a list of separate statements which may cause problems when used as + * a block (such as inline \c if statements). + */ + #define MACROE while (0) + + /** Convenience macro to determine the larger of two values. + * + * \note This macro should only be used with operands that do not have side effects from being evaluated + * multiple times. + * + * \param[in] x First value to compare + * \param[in] y First value to compare + * + * \return The larger of the two input parameters + */ + #if !defined(MAX) || defined(__DOXYGEN__) + #define MAX(x, y) (((x) > (y)) ? (x) : (y)) + #endif + + /** Convenience macro to determine the smaller of two values. + * + * \note This macro should only be used with operands that do not have side effects from being evaluated + * multiple times. + * + * \param[in] x First value to compare + * \param[in] y First value to compare + * + * \return The smaller of the two input parameters + */ + #if !defined(MIN) || defined(__DOXYGEN__) + #define MIN(x, y) (((x) < (y)) ? (x) : (y)) + #endif + + #if !defined(STRINGIFY) || defined(__DOXYGEN__) + /** Converts the given input into a string, via the C Preprocessor. This macro puts literal quotation + * marks around the input, converting the source into a string literal. + * + * \param[in] x Input to convert into a string literal. + * + * \return String version of the input. + */ + #define STRINGIFY(x) #x + + /** Converts the given input into a string after macro expansion, via the C Preprocessor. This macro puts + * literal quotation marks around the expanded input, converting the source into a string literal. + * + * \param[in] x Input to expand and convert into a string literal. + * + * \return String version of the expanded input. + */ + #define STRINGIFY_EXPANDED(x) STRINGIFY(x) + #endif + + #if !defined(ISR) || defined(__DOXYGEN__) + /** Macro for the definition of interrupt service routines, so that the compiler can insert the required + * prologue and epilogue code to properly manage the interrupt routine without affecting the main thread's + * state with unintentional side-effects. + * + * Interrupt handlers written using this macro may still need to be registered with the microcontroller's + * Interrupt Controller (if present) before they will properly handle incoming interrupt events. + * + * \note This macro is only supplied on some architectures, where the standard library does not include a valid + * definition. If an existing definition exists, the alternative definition here will be ignored. + * + * \ingroup Group_GlobalInt + * + * \param Name Unique name of the interrupt service routine. + */ + #define ISR(Name, ...) void Name (void) __attribute__((__interrupt__)) __VA_ARGS__; void Name (void) + #endif + + /* Inline Functions: */ + /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1, + * etc. + * + * \param[in] Byte Byte of data whose bits are to be reversed. + * + * \return Input data with the individual bits reversed (mirrored). + */ + static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST; + static inline uint8_t BitReverse(uint8_t Byte) + { + Byte = (((Byte & 0xF0) >> 4) | ((Byte & 0x0F) << 4)); + Byte = (((Byte & 0xCC) >> 2) | ((Byte & 0x33) << 2)); + Byte = (((Byte & 0xAA) >> 1) | ((Byte & 0x55) << 1)); + + return Byte; + } + + /** Function to perform a blocking delay for a specified number of milliseconds. The actual delay will be + * at a minimum the specified number of milliseconds, however due to loop overhead and internal calculations + * may be slightly higher. + * + * \param[in] Milliseconds Number of milliseconds to delay + */ + static inline void Delay_MS(uint16_t Milliseconds) ATTR_ALWAYS_INLINE; + static inline void Delay_MS(uint16_t Milliseconds) + { + #if (ARCH == ARCH_AVR8) + if (GCC_IS_COMPILE_CONST(Milliseconds)) + { + _delay_ms(Milliseconds); + } + else + { + while (Milliseconds--) + _delay_ms(1); + } + #elif (ARCH == ARCH_UC3) + while (Milliseconds--) + { + __builtin_mtsr(AVR32_COUNT, 0); + while ((uint32_t)__builtin_mfsr(AVR32_COUNT) < (F_CPU / 1000)); + } + #elif (ARCH == ARCH_XMEGA) + if (GCC_IS_COMPILE_CONST(Milliseconds)) + { + _delay_ms(Milliseconds); + } + else + { + while (Milliseconds--) + _delay_ms(1); + } + #endif + } + + /** Retrieves a mask which contains the current state of the global interrupts for the device. This + * value can be stored before altering the global interrupt enable state, before restoring the + * flag(s) back to their previous values after a critical section using \ref SetGlobalInterruptMask(). + * + * \ingroup Group_GlobalInt + * + * \return Mask containing the current Global Interrupt Enable Mask bit(s). + */ + static inline uint_reg_t GetGlobalInterruptMask(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint_reg_t GetGlobalInterruptMask(void) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + return SREG; + #elif (ARCH == ARCH_UC3) + return __builtin_mfsr(AVR32_SR); + #elif (ARCH == ARCH_XMEGA) + return SREG; + #endif + + GCC_MEMORY_BARRIER(); + } + + /** Sets the global interrupt enable state of the microcontroller to the mask passed into the function. + * This can be combined with \ref GetGlobalInterruptMask() to save and restore the Global Interrupt Enable + * Mask bit(s) of the device after a critical section has completed. + * + * \ingroup Group_GlobalInt + * + * \param[in] GlobalIntState Global Interrupt Enable Mask value to use + */ + static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) ATTR_ALWAYS_INLINE; + static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + SREG = GlobalIntState; + #elif (ARCH == ARCH_UC3) + if (GlobalIntState & AVR32_SR_GM) + __builtin_ssrf(AVR32_SR_GM_OFFSET); + else + __builtin_csrf(AVR32_SR_GM_OFFSET); + #elif (ARCH == ARCH_XMEGA) + SREG = GlobalIntState; + #endif + + GCC_MEMORY_BARRIER(); + } + + /** Enables global interrupt handling for the device, allowing interrupts to be handled. + * + * \ingroup Group_GlobalInt + */ + static inline void GlobalInterruptEnable(void) ATTR_ALWAYS_INLINE; + static inline void GlobalInterruptEnable(void) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + sei(); + #elif (ARCH == ARCH_UC3) + __builtin_csrf(AVR32_SR_GM_OFFSET); + #elif (ARCH == ARCH_XMEGA) + sei(); + #endif + + GCC_MEMORY_BARRIER(); + } + + /** Disabled global interrupt handling for the device, preventing interrupts from being handled. + * + * \ingroup Group_GlobalInt + */ + static inline void GlobalInterruptDisable(void) ATTR_ALWAYS_INLINE; + static inline void GlobalInterruptDisable(void) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + cli(); + #elif (ARCH == ARCH_UC3) + __builtin_ssrf(AVR32_SR_GM_OFFSET); + #elif (ARCH == ARCH_XMEGA) + cli(); + #endif + + GCC_MEMORY_BARRIER(); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Common/CompilerSpecific.h b/hal/at90usb646/LUFA/Common/CompilerSpecific.h index 22afe94..ad2d075 100644 --- a/hal/at90usb646/LUFA/Common/CompilerSpecific.h +++ b/hal/at90usb646/LUFA/Common/CompilerSpecific.h @@ -1,97 +1,97 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Compiler specific definitions for code optimization and correctness. - * - * \copydetails Group_CompilerSpecific - * - * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's - * functionality. - */ - -/** \ingroup Group_Common - * \defgroup Group_CompilerSpecific Compiler Specific Definitions - * \brief Compiler specific definitions for code optimization and correctness. - * - * Compiler specific definitions to expose certain compiler features which may increase the level of code optimization - * for a specific compiler, or correct certain issues that may be present such as memory barriers for use in conjunction - * with atomic variable access. - * - * Where possible, on alternative compilers, these macros will either have no effect, or default to returning a sane value - * so that they can be used in existing code without the need for extra compiler checks in the user application code. - * - * @{ - */ - -#ifndef __LUFA_COMPILERSPEC_H__ -#define __LUFA_COMPILERSPEC_H__ - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_COMMON_H) - #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - #if defined(__GNUC__) || defined(__DOXYGEN__) - /** Forces GCC to use pointer indirection (via the device's pointer register pairs) when accessing the given - * struct pointer. In some cases GCC will emit non-optimal assembly code when accessing a structure through - * a pointer, resulting in a larger binary. When this macro is used on a (non \c const) structure pointer before - * use, it will force GCC to use pointer indirection on the elements rather than direct store and load - * instructions. - * - * \param[in, out] StructPtr Pointer to a structure which is to be forced into indirect access mode. - */ - #define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr)) - - /** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point. - * This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting - * assembly output in an unexpected manner on sections of code that are ordering-specific. - */ - #define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory"); - - /** Determines if the specified value can be determined at compile-time to be a constant value when compiling under GCC. - * - * \param[in] x Value to check compile-time constantness of. - * - * \return Boolean true if the given value is known to be a compile time constant, false otherwise. - */ - #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x) - #else - #define GCC_FORCE_POINTER_ACCESS(StructPtr) - #define GCC_MEMORY_BARRIER() - #define GCC_IS_COMPILE_CONST(x) 0 - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Compiler specific definitions for code optimization and correctness. + * + * \copydetails Group_CompilerSpecific + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_CompilerSpecific Compiler Specific Definitions + * \brief Compiler specific definitions for code optimization and correctness. + * + * Compiler specific definitions to expose certain compiler features which may increase the level of code optimization + * for a specific compiler, or correct certain issues that may be present such as memory barriers for use in conjunction + * with atomic variable access. + * + * Where possible, on alternative compilers, these macros will either have no effect, or default to returning a sane value + * so that they can be used in existing code without the need for extra compiler checks in the user application code. + * + * @{ + */ + +#ifndef __LUFA_COMPILERSPEC_H__ +#define __LUFA_COMPILERSPEC_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if defined(__GNUC__) || defined(__DOXYGEN__) + /** Forces GCC to use pointer indirection (via the device's pointer register pairs) when accessing the given + * struct pointer. In some cases GCC will emit non-optimal assembly code when accessing a structure through + * a pointer, resulting in a larger binary. When this macro is used on a (non \c const) structure pointer before + * use, it will force GCC to use pointer indirection on the elements rather than direct store and load + * instructions. + * + * \param[in, out] StructPtr Pointer to a structure which is to be forced into indirect access mode. + */ + #define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr)) + + /** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point. + * This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting + * assembly output in an unexpected manner on sections of code that are ordering-specific. + */ + #define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory"); + + /** Determines if the specified value can be determined at compile-time to be a constant value when compiling under GCC. + * + * \param[in] x Value to check compile-time constantness of. + * + * \return Boolean true if the given value is known to be a compile time constant, false otherwise. + */ + #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x) + #else + #define GCC_FORCE_POINTER_ACCESS(StructPtr) + #define GCC_MEMORY_BARRIER() + #define GCC_IS_COMPILE_CONST(x) 0 + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Common/Endianness.h b/hal/at90usb646/LUFA/Common/Endianness.h index d0812e4..2a618ac 100644 --- a/hal/at90usb646/LUFA/Common/Endianness.h +++ b/hal/at90usb646/LUFA/Common/Endianness.h @@ -1,489 +1,489 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Endianness and Byte Ordering macros and functions. - * - * \copydetails Group_Endianness - */ - -/** \ingroup Group_Endianness - * \defgroup Group_ByteSwapping Byte Reordering - * \brief Macros and functions for forced byte reordering. - */ - -/** \ingroup Group_Endianness - * \defgroup Group_EndianConversion Endianness Conversion - * \brief Macros and functions for automatic endianness conversion. - */ - -/** \ingroup Group_Common - * \defgroup Group_Endianness Endianness and Byte Ordering - * \brief Convenience macros and functions relating to byte (re-)ordering - * - * Common library convenience macros and functions relating to byte (re-)ordering. - * - * @{ - */ - -#ifndef __LUFA_ENDIANNESS_H__ -#define __LUFA_ENDIANNESS_H__ - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_COMMON_H) - #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. - #endif - - #if !(defined(ARCH_BIG_ENDIAN) || defined(ARCH_LITTLE_ENDIAN)) - #error ARCH_BIG_ENDIAN or ARCH_LITTLE_ENDIAN not set for the specified architecture. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Swaps the byte ordering of a 16-bit value at compile-time. Do not use this macro for swapping byte orderings - * of dynamic values computed at runtime, use \ref SwapEndian_16() instead. The result of this macro can be used - * inside struct or other variable initializers outside of a function, something that is not possible with the - * inline function variant. - * - * \ingroup Group_ByteSwapping - * - * \param[in] x 16-bit value whose byte ordering is to be swapped. - * - * \return Input value with the byte ordering reversed. - */ - #define SWAPENDIAN_16(x) (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) - - /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings - * of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used - * inside struct or other variable initializers outside of a function, something that is not possible with the - * inline function variant. - * - * \ingroup Group_ByteSwapping - * - * \param[in] x 32-bit value whose byte ordering is to be swapped. - * - * \return Input value with the byte ordering reversed. - */ - #define SWAPENDIAN_32(x) (uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \ - (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL)) - - #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu) - #define le16_to_cpu(x) SwapEndian_16(x) - #define le32_to_cpu(x) SwapEndian_32(x) - #define be16_to_cpu(x) (x) - #define be32_to_cpu(x) (x) - #define cpu_to_le16(x) SwapEndian_16(x) - #define cpu_to_le32(x) SwapEndian_32(x) - #define cpu_to_be16(x) (x) - #define cpu_to_be32(x) (x) - #define LE16_TO_CPU(x) SWAPENDIAN_16(x) - #define LE32_TO_CPU(x) SWAPENDIAN_32(x) - #define BE16_TO_CPU(x) (x) - #define BE32_TO_CPU(x) (x) - #define CPU_TO_LE16(x) SWAPENDIAN_16(x) - #define CPU_TO_LE32(x) SWAPENDIAN_32(x) - #define CPU_TO_BE16(x) (x) - #define CPU_TO_BE32(x) (x) - #elif !defined(le16_to_cpu) - /** \name Run-time endianness conversion */ - //@{ - - /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref LE16_TO_CPU instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define le16_to_cpu(x) (x) - - /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref LE32_TO_CPU instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define le32_to_cpu(x) (x) - - /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref BE16_TO_CPU instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define be16_to_cpu(x) SwapEndian_16(x) - - /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref BE32_TO_CPU instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define be32_to_cpu(x) SwapEndian_32(x) - - /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it - * is in Little Endian format regardless of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref CPU_TO_LE16 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define cpu_to_le16(x) (x) - - /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it - * is in Little Endian format regardless of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref CPU_TO_LE32 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define cpu_to_le32(x) (x) - - /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it - * is in Big Endian format regardless of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref CPU_TO_BE16 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define cpu_to_be16(x) SwapEndian_16(x) - - /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it - * is in Big Endian format regardless of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for run-time conversion of data - for compile-time endianness - * conversion, use \ref CPU_TO_BE32 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define cpu_to_be32(x) SwapEndian_32(x) - - //@} - - /** \name Compile-time endianness conversion */ - //@{ - - /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run time endianness - * conversion, use \ref le16_to_cpu instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define LE16_TO_CPU(x) (x) - - /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run time endianness - * conversion, use \ref le32_to_cpu instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define LE32_TO_CPU(x) (x) - - /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run-time endianness - * conversion, use \ref be16_to_cpu instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define BE16_TO_CPU(x) SWAPENDIAN_16(x) - - /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the - * Endianness of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run-time endianness - * conversion, use \ref be32_to_cpu instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define BE32_TO_CPU(x) SWAPENDIAN_32(x) - - /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it - * is in Little Endian format regardless of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run-time endianness - * conversion, use \ref cpu_to_le16 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define CPU_TO_LE16(x) (x) - - /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it - * is in Little Endian format regardless of the currently selected CPU architecture. - * - * On little endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run-time endianness - * conversion, use \ref cpu_to_le32 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define CPU_TO_LE32(x) (x) - - /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it - * is in Big Endian format regardless of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run-time endianness - * conversion, use \ref cpu_to_be16 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define CPU_TO_BE16(x) SWAPENDIAN_16(x) - - /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it - * is in Big Endian format regardless of the currently selected CPU architecture. - * - * On big endian architectures, this macro does nothing. - * - * \note This macro is designed for compile-time conversion of data - for run-time endianness - * conversion, use \ref cpu_to_be32 instead. - * - * \ingroup Group_EndianConversion - * - * \param[in] x Data to perform the endianness conversion on. - * - * \return Endian corrected version of the input value. - */ - #define CPU_TO_BE32(x) SWAPENDIAN_32(x) - - //! @} - #endif - - /* Inline Functions: */ - /** Function to reverse the byte ordering of the individual bytes in a 16 bit value. - * - * \ingroup Group_ByteSwapping - * - * \param[in] Word Word of data whose bytes are to be swapped. - * - * \return Input data with the individual bytes reversed. - */ - static inline uint16_t SwapEndian_16(const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST; - static inline uint16_t SwapEndian_16(const uint16_t Word) - { - if (GCC_IS_COMPILE_CONST(Word)) - return SWAPENDIAN_16(Word); - - uint8_t Temp; - - union - { - uint16_t Word; - uint8_t Bytes[2]; - } Data; - - Data.Word = Word; - - Temp = Data.Bytes[0]; - Data.Bytes[0] = Data.Bytes[1]; - Data.Bytes[1] = Temp; - - return Data.Word; - } - - /** Function to reverse the byte ordering of the individual bytes in a 32 bit value. - * - * \ingroup Group_ByteSwapping - * - * \param[in] DWord Double word of data whose bytes are to be swapped. - * - * \return Input data with the individual bytes reversed. - */ - static inline uint32_t SwapEndian_32(const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST; - static inline uint32_t SwapEndian_32(const uint32_t DWord) - { - if (GCC_IS_COMPILE_CONST(DWord)) - return SWAPENDIAN_32(DWord); - - uint8_t Temp; - - union - { - uint32_t DWord; - uint8_t Bytes[4]; - } Data; - - Data.DWord = DWord; - - Temp = Data.Bytes[0]; - Data.Bytes[0] = Data.Bytes[3]; - Data.Bytes[3] = Temp; - - Temp = Data.Bytes[1]; - Data.Bytes[1] = Data.Bytes[2]; - Data.Bytes[2] = Temp; - - return Data.DWord; - } - - /** Function to reverse the byte ordering of the individual bytes in a n byte value. - * - * \ingroup Group_ByteSwapping - * - * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed. - * \param[in] Length Length of the data in bytes. - * - * \return Input data with the individual bytes reversed. - */ - static inline void SwapEndian_n(void* const Data, - uint8_t Length) ATTR_NON_NULL_PTR_ARG(1); - static inline void SwapEndian_n(void* const Data, - uint8_t Length) - { - uint8_t* CurrDataPos = (uint8_t*)Data; - - while (Length > 1) - { - uint8_t Temp = *CurrDataPos; - *CurrDataPos = *(CurrDataPos + Length - 1); - *(CurrDataPos + Length - 1) = Temp; - - CurrDataPos++; - Length -= 2; - } - } - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endianness and Byte Ordering macros and functions. + * + * \copydetails Group_Endianness + */ + +/** \ingroup Group_Endianness + * \defgroup Group_ByteSwapping Byte Reordering + * \brief Macros and functions for forced byte reordering. + */ + +/** \ingroup Group_Endianness + * \defgroup Group_EndianConversion Endianness Conversion + * \brief Macros and functions for automatic endianness conversion. + */ + +/** \ingroup Group_Common + * \defgroup Group_Endianness Endianness and Byte Ordering + * \brief Convenience macros and functions relating to byte (re-)ordering + * + * Common library convenience macros and functions relating to byte (re-)ordering. + * + * @{ + */ + +#ifndef __LUFA_ENDIANNESS_H__ +#define __LUFA_ENDIANNESS_H__ + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + #if !(defined(ARCH_BIG_ENDIAN) || defined(ARCH_LITTLE_ENDIAN)) + #error ARCH_BIG_ENDIAN or ARCH_LITTLE_ENDIAN not set for the specified architecture. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Swaps the byte ordering of a 16-bit value at compile-time. Do not use this macro for swapping byte orderings + * of dynamic values computed at runtime, use \ref SwapEndian_16() instead. The result of this macro can be used + * inside struct or other variable initializers outside of a function, something that is not possible with the + * inline function variant. + * + * \ingroup Group_ByteSwapping + * + * \param[in] x 16-bit value whose byte ordering is to be swapped. + * + * \return Input value with the byte ordering reversed. + */ + #define SWAPENDIAN_16(x) (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) + + /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings + * of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used + * inside struct or other variable initializers outside of a function, something that is not possible with the + * inline function variant. + * + * \ingroup Group_ByteSwapping + * + * \param[in] x 32-bit value whose byte ordering is to be swapped. + * + * \return Input value with the byte ordering reversed. + */ + #define SWAPENDIAN_32(x) (uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \ + (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL)) + + #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu) + #define le16_to_cpu(x) SwapEndian_16(x) + #define le32_to_cpu(x) SwapEndian_32(x) + #define be16_to_cpu(x) (x) + #define be32_to_cpu(x) (x) + #define cpu_to_le16(x) SwapEndian_16(x) + #define cpu_to_le32(x) SwapEndian_32(x) + #define cpu_to_be16(x) (x) + #define cpu_to_be32(x) (x) + #define LE16_TO_CPU(x) SWAPENDIAN_16(x) + #define LE32_TO_CPU(x) SWAPENDIAN_32(x) + #define BE16_TO_CPU(x) (x) + #define BE32_TO_CPU(x) (x) + #define CPU_TO_LE16(x) SWAPENDIAN_16(x) + #define CPU_TO_LE32(x) SWAPENDIAN_32(x) + #define CPU_TO_BE16(x) (x) + #define CPU_TO_BE32(x) (x) + #elif !defined(le16_to_cpu) + /** \name Run-time endianness conversion */ + //@{ + + /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref LE16_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define le16_to_cpu(x) (x) + + /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref LE32_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define le32_to_cpu(x) (x) + + /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref BE16_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define be16_to_cpu(x) SwapEndian_16(x) + + /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref BE32_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define be32_to_cpu(x) SwapEndian_32(x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_LE16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_le16(x) (x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_LE32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_le32(x) (x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_BE16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_be16(x) SwapEndian_16(x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_BE32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_be32(x) SwapEndian_32(x) + + //@} + + /** \name Compile-time endianness conversion */ + //@{ + + /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run time endianness + * conversion, use \ref le16_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define LE16_TO_CPU(x) (x) + + /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run time endianness + * conversion, use \ref le32_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define LE32_TO_CPU(x) (x) + + /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref be16_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define BE16_TO_CPU(x) SWAPENDIAN_16(x) + + /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref be32_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define BE32_TO_CPU(x) SWAPENDIAN_32(x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_le16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_LE16(x) (x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_le32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_LE32(x) (x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_be16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_BE16(x) SWAPENDIAN_16(x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_be32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_BE32(x) SWAPENDIAN_32(x) + + //! @} + #endif + + /* Inline Functions: */ + /** Function to reverse the byte ordering of the individual bytes in a 16 bit value. + * + * \ingroup Group_ByteSwapping + * + * \param[in] Word Word of data whose bytes are to be swapped. + * + * \return Input data with the individual bytes reversed. + */ + static inline uint16_t SwapEndian_16(const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST; + static inline uint16_t SwapEndian_16(const uint16_t Word) + { + if (GCC_IS_COMPILE_CONST(Word)) + return SWAPENDIAN_16(Word); + + uint8_t Temp; + + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; + + Data.Word = Word; + + Temp = Data.Bytes[0]; + Data.Bytes[0] = Data.Bytes[1]; + Data.Bytes[1] = Temp; + + return Data.Word; + } + + /** Function to reverse the byte ordering of the individual bytes in a 32 bit value. + * + * \ingroup Group_ByteSwapping + * + * \param[in] DWord Double word of data whose bytes are to be swapped. + * + * \return Input data with the individual bytes reversed. + */ + static inline uint32_t SwapEndian_32(const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST; + static inline uint32_t SwapEndian_32(const uint32_t DWord) + { + if (GCC_IS_COMPILE_CONST(DWord)) + return SWAPENDIAN_32(DWord); + + uint8_t Temp; + + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.DWord = DWord; + + Temp = Data.Bytes[0]; + Data.Bytes[0] = Data.Bytes[3]; + Data.Bytes[3] = Temp; + + Temp = Data.Bytes[1]; + Data.Bytes[1] = Data.Bytes[2]; + Data.Bytes[2] = Temp; + + return Data.DWord; + } + + /** Function to reverse the byte ordering of the individual bytes in a n byte value. + * + * \ingroup Group_ByteSwapping + * + * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed. + * \param[in] Length Length of the data in bytes. + * + * \return Input data with the individual bytes reversed. + */ + static inline void SwapEndian_n(void* const Data, + uint8_t Length) ATTR_NON_NULL_PTR_ARG(1); + static inline void SwapEndian_n(void* const Data, + uint8_t Length) + { + uint8_t* CurrDataPos = (uint8_t*)Data; + + while (Length > 1) + { + uint8_t Temp = *CurrDataPos; + *CurrDataPos = *(CurrDataPos + Length - 1); + *(CurrDataPos + Length - 1) = Temp; + + CurrDataPos++; + Length -= 2; + } + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Doxygen.conf b/hal/at90usb646/LUFA/Doxygen.conf index ee4ea9d..eb464ed 100644 --- a/hal/at90usb646/LUFA/Doxygen.conf +++ b/hal/at90usb646/LUFA/Doxygen.conf @@ -1,1732 +1,1732 @@ -# Doxyfile 1.7.4 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = "LUFA Library" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 000000 - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = ./DoxygenPages/LUFA_thumb.png - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ./Documentation/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = NO - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given extension. -# Doxygen has a built-in mapping, but you can override or extend it using this -# tag. The format is ext=language, where ext is a file extension, and language -# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, -# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions -# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. - -EXTENSION_MAPPING = - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = YES - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols - -SYMBOL_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = YES - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = NO - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = NO - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = NO - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 15 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = YES - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./ - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = *.h \ - *.txt - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = Documentation/ \ - License.txt - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = _* \ - __* - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = ../ - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = * - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = ./ - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = NO - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is adviced to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = ./DoxygenPages/footer.htm - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 120 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = NO - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = YES - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify -# the documentation publisher. This should be a reverse domain-name style -# string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = com.lufa-lib.library.documentation - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = DeanCamera - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = ../LUFA.chm - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = YES - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 1 - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. - -GENERATE_TREEVIEW = YES - -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. - -USE_INLINE_TREES = YES - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 300 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. - -MATHJAX_RELPATH = http://www.mathjax.org/mathjax - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = YES - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = __DOXYGEN__ \ - PROGMEM \ - EEMEM \ - ATTR_PACKED - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = NO - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will write a font called Helvetica to the output -# directory and reference it in all dot files that doxygen generates. -# When you want a differently looking font you can specify the font name -# using DOT_FONTNAME. You need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. - -DOT_FONTNAME = FreeSans - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = NO - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = NO - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = NO - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 15 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 2 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = YES - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES +# Doxyfile 1.7.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "LUFA Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 000000 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = ./DoxygenPages/LUFA_thumb.png + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = ./Documentation/ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = NO + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = YES + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = NO + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = NO + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = NO + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 15 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ./ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.h \ + *.txt + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = Documentation/ \ + License.txt + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = _* \ + __* + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = ../ + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = ./ + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = NO + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = ./DoxygenPages/footer.htm + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 120 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = NO + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = YES + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = com.lufa-lib.library.documentation + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = DeanCamera + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = ../LUFA.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 1 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = YES + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = YES + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 300 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = __DOXYGEN__ \ + PROGMEM \ + EEMEM \ + ATTR_PACKED + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = NO + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = NO + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = NO + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 15 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 2 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/hal/at90usb646/LUFA/DoxygenPages/AboutLUFA.txt b/hal/at90usb646/LUFA/DoxygenPages/AboutLUFA.txt index 697535c..c7374bc 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/AboutLUFA.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/AboutLUFA.txt @@ -1,20 +1,20 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_AboutLUFA About LUFA - * - * This section of the manual contains information about the library as a whole, including its supported targets, - * past and planned changes, and links to other projects incorporating LUFA. - * - * Subsections: - * \li \subpage Page_DeviceSupport - Current Device and Hardware Support - * \li \subpage Page_Resources - LUFA and USB Related Resources - * \li \subpage Page_ChangeLog - Project Changelog - * \li \subpage Page_FutureChanges - Planned Changes to the Library - * \li \subpage Page_LUFAPoweredProjects - Other Projects Using LUFA - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_AboutLUFA About LUFA + * + * This section of the manual contains information about the library as a whole, including its supported targets, + * past and planned changes, and links to other projects incorporating LUFA. + * + * Subsections: + * \li \subpage Page_DeviceSupport - Current Device and Hardware Support + * \li \subpage Page_Resources - LUFA and USB Related Resources + * \li \subpage Page_ChangeLog - Project Changelog + * \li \subpage Page_FutureChanges - Planned Changes to the Library + * \li \subpage Page_LUFAPoweredProjects - Other Projects Using LUFA + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/AlternativeStacks.txt b/hal/at90usb646/LUFA/DoxygenPages/AlternativeStacks.txt index 889183c..f9d6cbb 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/AlternativeStacks.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/AlternativeStacks.txt @@ -1,69 +1,69 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_AlternativeStacks Alternative USB AVR Stacks - * - * LUFA is not the only stack available for the USB AVRs, although it is perhaps the best (see \ref Page_WhyUseLUFA). - * In the interests of completeness and user choice, other known USB AVR stacks are listed here. - * - * \section Sec_HardwareStacks Hardware USB AVR Stacks - * These are the known alternative USB stacks which are designed for and run exclusively on the USB AVR series microcontrollers, - * which contain on-chip USB controller hardware for maximum features and speed. - * - * - Name: Atmel USB AVR Stack (Atmel Inc.) \n - * Cost: Free \n - * License: Atmel Limited License (see Atmel download for details) \n - * Website: http://atmel.com/dyn/products/app_notes.asp?family_id=607#USB \n - * Description: This is the official Atmel USB AVR stack, for their 8-bit USB AVR lineup. Each series of - * USB AVR is separated into a separate download stack, which is both AVR-GCC and IAR compatible. - * - * - Name: Dr. Stefan Salewski's AT90USB1287 Stack (Dr. Stefan Salewski) \n - * Cost: Free \n - * License: GPL \n - * Website: http://www.ssalewski.de/AT90USB_firmware.html.en \n - * Description: This is a GPL'd library specifically designed for the AT90USB1287, by Dr. Stefan Salewski, a - * German Physicist. It compiles for AVR-GCC and can potentially be modified to work on other USB - * AVR models. - * - * - Name: FreakUSB Stack (FreakLabs) \n - * Cost: Free \n - * License: Modified BSD \n - * Website: http://freaklabs.org/index.php/FreakUSB-Open-Source-USB-Device-Stack.html \n - * Description: An open source simple USB stack for a selection of the USB AVRs. Contains a sample class driver - * for the CDC-ACM class, however other class driver implementations are also possible. - * - * - Name: PJRC Teensy Stack (Paul Stoffregen) \n - * Cost: Free \n - * License: BSD \n - * Website: http://www.pjrc.com/teensy/usb_debug_only.html \n - * Description: Not so much a complete stack as a collection of USB enabled demos, this library is specifically - * designed for the PJRC Teensy line of USB AVRs, and thus may need to be modified for other USB AVR - * chips. These minimal code samples shows the inner workings of the USB controller, without all the - * abstraction present in most other USB AVR stacks. - * - * \section Sec_SoftwareStacks Software AVR Stacks - * These are the known alternative USB stacks which can run on regular AVR models, lacking dedicated hardware USB controllers - * via a bit-banged (emulated) version of the USB protocol. They are limited in their capabilities due to the cycles required - * to be dedicated to managing the USB bus, but offer a cheap way to implement USB functionality into a design. - * - * - Name: AVR309: Software USB (Atmel) \n - * Cost: Free \n - * License: None Stated \n - * Website: http://www.atmel.com/dyn/Products/app_notes.asp?family_id=607 \n - * Description: Atmel's official software USB implementation, an Application Note containing work by Igor Cesko. This - * is a minimal assembly-only implementation of software USB, providing HID functionality. Less compile - * options than V-USB (see below). - * - * - Name: V-USB (Objective Development) \n - * Cost: Free for some uses, see website for licensing \n - * License: Dual GPL2/Custom \n - * Website: http://www.obdev.at/products/vusb/index.html \n - * Description: Well regarded and complete USB 1.1 software stack for several AVR models, implementing Low Speed HID. - * Used in many commercial and non-commercial designs, with user-submitted projects available for viewing - * on the company's website. Uses C language code mixed with assembly for time-critical sections. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_AlternativeStacks Alternative USB AVR Stacks + * + * LUFA is not the only stack available for the USB AVRs, although it is perhaps the best (see \ref Page_WhyUseLUFA). + * In the interests of completeness and user choice, other known USB AVR stacks are listed here. + * + * \section Sec_HardwareStacks Hardware USB AVR Stacks + * These are the known alternative USB stacks which are designed for and run exclusively on the USB AVR series microcontrollers, + * which contain on-chip USB controller hardware for maximum features and speed. + * + * - Name: Atmel USB AVR Stack (Atmel Inc.) \n + * Cost: Free \n + * License: Atmel Limited License (see Atmel download for details) \n + * Website: http://atmel.com/dyn/products/app_notes.asp?family_id=607#USB \n + * Description: This is the official Atmel USB AVR stack, for their 8-bit USB AVR lineup. Each series of + * USB AVR is separated into a separate download stack, which is both AVR-GCC and IAR compatible. + * + * - Name: Dr. Stefan Salewski's AT90USB1287 Stack (Dr. Stefan Salewski) \n + * Cost: Free \n + * License: GPL \n + * Website: http://www.ssalewski.de/AT90USB_firmware.html.en \n + * Description: This is a GPL'd library specifically designed for the AT90USB1287, by Dr. Stefan Salewski, a + * German Physicist. It compiles for AVR-GCC and can potentially be modified to work on other USB + * AVR models. + * + * - Name: FreakUSB Stack (FreakLabs) \n + * Cost: Free \n + * License: Modified BSD \n + * Website: http://freaklabs.org/index.php/FreakUSB-Open-Source-USB-Device-Stack.html \n + * Description: An open source simple USB stack for a selection of the USB AVRs. Contains a sample class driver + * for the CDC-ACM class, however other class driver implementations are also possible. + * + * - Name: PJRC Teensy Stack (Paul Stoffregen) \n + * Cost: Free \n + * License: BSD \n + * Website: http://www.pjrc.com/teensy/usb_debug_only.html \n + * Description: Not so much a complete stack as a collection of USB enabled demos, this library is specifically + * designed for the PJRC Teensy line of USB AVRs, and thus may need to be modified for other USB AVR + * chips. These minimal code samples shows the inner workings of the USB controller, without all the + * abstraction present in most other USB AVR stacks. + * + * \section Sec_SoftwareStacks Software AVR Stacks + * These are the known alternative USB stacks which can run on regular AVR models, lacking dedicated hardware USB controllers + * via a bit-banged (emulated) version of the USB protocol. They are limited in their capabilities due to the cycles required + * to be dedicated to managing the USB bus, but offer a cheap way to implement USB functionality into a design. + * + * - Name: AVR309: Software USB (Atmel) \n + * Cost: Free \n + * License: None Stated \n + * Website: http://www.atmel.com/dyn/Products/app_notes.asp?family_id=607 \n + * Description: Atmel's official software USB implementation, an Application Note containing work by Igor Cesko. This + * is a minimal assembly-only implementation of software USB, providing HID functionality. Less compile + * options than V-USB (see below). + * + * - Name: V-USB (Objective Development) \n + * Cost: Free for some uses, see website for licensing \n + * License: Dual GPL2/Custom \n + * Website: http://www.obdev.at/products/vusb/index.html \n + * Description: Well regarded and complete USB 1.1 software stack for several AVR models, implementing Low Speed HID. + * Used in many commercial and non-commercial designs, with user-submitted projects available for viewing + * on the company's website. Uses C language code mixed with assembly for time-critical sections. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/BuildingLinkableLibraries.txt b/hal/at90usb646/LUFA/DoxygenPages/BuildingLinkableLibraries.txt index ff5fdc5..e5782df 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/BuildingLinkableLibraries.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/BuildingLinkableLibraries.txt @@ -1,23 +1,23 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_BuildLibrary Building as a Linkable Library - * - * The LUFA library can be built as a proper linkable library (with the extention .a) under AVR-GCC, so that - * the library does not need to be recompiled with each revision of a user project. Instructions for creating - * a library from a given source tree can be found in the AVR-GCC user manual included in the WinAVR install - * /Docs/ directory. - * - * However, building the library is not recommended, as the static (compile-time) options will be - * unable to be changed without a recompilation of the LUFA code. Therefore, if the library is to be built - * from the LUFA source, it should be made to be application-specific and compiled with the static options - * that are required for each project (which should be recorded along with the library). - * - * Normal library use has the library components compiled in at the same point as the application code, as - * demonstrated in the library demos and applications. This is the preferred method, as the library is recompiled - * each time to ensure that all static options for a particular application are applied. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_BuildLibrary Building as a Linkable Library + * + * The LUFA library can be built as a proper linkable library (with the extention .a) under AVR-GCC, so that + * the library does not need to be recompiled with each revision of a user project. Instructions for creating + * a library from a given source tree can be found in the AVR-GCC user manual included in the WinAVR install + * /Docs/ directory. + * + * However, building the library is not recommended, as the static (compile-time) options will be + * unable to be changed without a recompilation of the LUFA code. Therefore, if the library is to be built + * from the LUFA source, it should be made to be application-specific and compiled with the static options + * that are required for each project (which should be recorded along with the library). + * + * Normal library use has the library components compiled in at the same point as the application code, as + * demonstrated in the library demos and applications. This is the preferred method, as the library is recompiled + * each time to ensure that all static options for a particular application are applied. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/ChangeLog.txt b/hal/at90usb646/LUFA/DoxygenPages/ChangeLog.txt index 3900ffe..8820869 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/ChangeLog.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/ChangeLog.txt @@ -1,1367 +1,1367 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - - /** \page Page_ChangeLog Project Changelog - * - * \section Sec_ChangeLog120219 Version 120219 - * New: - * - Core: - * - Added support for the XMEGA A3BU Xplained board - * - Added support for the new B series XMEGA devices - * - Added support for version 2 of the Teensy boards (thanks to Christoph Redecker) - * - Added support for the USB2AX boards, hardware revision 1-3 - * - Added new Android Accessory Host class driver - * - Added new USB_Host_GetDescriptor(), USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions - * - Added new CALLBACK_Audio_Device_GetSetInterfaceProperty() callback to the Audio Device Class driver - * - Added new LEDs_Disable(), Buttons_Disable() and Joystick_Disable() functions to the board hardware drivers - * - Added support for the Micropendous family of boards (Arduino-like revisions 1 and 2, DIP, 32U2, A, 1, 2, 3 and 4) - * - Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.) - * - Added support for the Atmel XMEGA B1 Xplained board - * - Added Serial USART peripheral driver for the XMEGA architecture - * - Added Master Mode SPI USART peripheral driver for the XMEGA and AVR8 architectures - * - Added build test to verify correct compilation of as many modules as possible under as many architectures as possible under the C and C++ languages - * - Added build test to verify correct compilation of the USB driver when forced into single USB mode under as many architectures as possible - * - Library Applications: - * - Added User Application APIs to the CDC and DFU class bootloaders - * - Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs) - * - Added new Android Accessory Host demo (thanks to Opendous Inc.) - * - * Changed: - * - Core: - * - When automatic PLL management mode is enabled on the U4 series AVR8 chips, the PLL is now configured for 48MHz and not - * a divided 96MHz, to lower power consumption and to keep the system within the datasheet specs for 3.3V operation (thanks to Scott Vitale) - * - Added Class, ClassDevice, ClassHost and ClassCommon to the internal class driver source filenames to prevent ambiguities - * - Altered the Mass Storage Host class driver so that SCSI data STALLs from the attached device can be recovered from automatically without - * having to reset the Mass Storage interface - * - USB_CONFIG_ATTR_BUSPOWERED constant renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed (thanks to NXP Semiconductors) - * - Reordered board name definition indexes so that a mispelled BOARD compile option will default to BOARD_USER rather than BOARD_USBKEY - * - Altered the HID class driver to only try to construct at maximum one packet per USB frame, to reduce CPU usage - * - All USB Class Driver configuration struct values are now non-const, to allow for run-time modifications if required before configuring an instance - * - Library Applications: - * - Altered the Mass Storage Host LowLevel demo so that SCSI data STALLs from the attached device can be recovered from automatically without - * having to reset the Mass Storage interface - * - Updated the AVRISP-MKII Clone programmer project to be compatible with the latest version of AVR Studio (version 5.1) - * - Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent - * warnings in AVR Studio 5.1 when programming XMEGA devices - * - Allow serial strings to be generated on the older AVR8 devices which do not explicitly state they contain unique values in the datasheet, - * as this appears to be implemented in hardware - * - * Fixed: - * - Core: - * - Fixed ring buffer size limited to 255 elements, instead of the intended 65535 elements. - * - Fixed CDC class drivers not saving and sending all 16-bits of the control line states (thanks to Matthew Swabey) - * - Fixed race conditions in the CDC, HID and Mass Storage class drivers when processing some control requests - * - Fixed misspelled HID_KEYBOARD_MODIFIER_* macros in the HID class driver (thanks to Laszlo Monda) - * - Fixed broken AVR32 endpoint/pipe communications when ORDERED_EP_CONFIG compile time option is not enabled (thanks to Matthias Jahr) - * - Fixed broken compilation for the AVR32 devices if the NO_SOF_EVENTS compile time option was not enabled (thanks to Matthias Jahr) - * - Fixed compiler warning on GCC with \c -wundef compile flag is used (thanks to Georg Glock) - * - Fixed incorrect implementation of LEDs_ToggleLEDs() for the Adafruit-U4 board (thanks to Caroline Saliman) - * - Fixed broken compilation of LUFA under C++ compilers when the Serial peripheral module header file is included in a C++ source file - * - Fixed missing semicolon in the UC3 architecture host pipe functions - * - Fixed failed compilation for the XMEGA architecture if USB_DEVICE_ONLY us not specified - * - Fixed UC3 architecture ignoring the pipe size when Pipe_ConfigurePipe() is called - * - Library Applications: - * - Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair) - * - Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled - * - Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming session is exited - * - Fixed DFU class bootloader not resetting the LED pins as high impedance inputs when a software jump to the user applications is requested - * - Fixed AVRISP-MKII Clone timing out on long programming commands such as programming the EEPROM on an ATMEGA8 (thanks to Martin Kelling) - * - Fixed invalid PID value used in the TempDataLogger project host application (thanks to Anupam Pathak) - * - * \section Sec_ChangeLog111009 Version 111009 - * New: - * - Core: - * - Added USE_LUFA_CONFIG_HEADER compile time option to include a LUFAConfig.h header in the user director for LUFA configuration - * tokens as an alternative to tokens defined in the project makefile - * - Added new USB_Host_SetInterfaceAltSetting() convenience function for the selection of an interface's alternative setting - * - Added Audio class control request definitions - * - Added new CALLBACK_Audio_Device_GetSetEndpointProperty() callback to the Audio Device Class driver to allow for endpoint control manipulations - * such as data sample rates - * - Added support for the Audio class GET STATUS request in the Audio Device Class driver so that it is correctly ACKed when sent by the host - * - Added new EVENT_Audio_Device_StreamStartStop() event to the Audio Device Class driver to detect stream start/stop events - * - Added board driver support for the Busware TUL board - * - Added board hardware driver support for the EVK1100 board - * - Added board hardware driver support for the EVK1104 board - * - Added new Host mode Audio Class driver - * - Added new SPI_GetCurrentMode() function to the SPI peripheral driver - * - Added RingBuffer_GetFreeCount() function to the Ring Buffer driver - * - Added new HID_Host_SetIdlePeriod() function to the HID Host Class driver - * - Added new USB_Host_ConfigurationNumber global variable to indicate the selected configuration in an attached device - * - Added new USB_Host_GetDeviceStatus() function to the host standard request function set - * - Added AVR USB XMEGA architecture port (currently incomplete/experimental) - * - Added new STRINGIFY() and STRINGIFY_EXPANDED() convenience macros - * - Added new JTAG_DISABLE() macro for the AVR8 architecture - * - Added Device Qualifier standard descriptor structure definitions USB_StdDescriptor_DeviceQualifier_t and USB_Descriptor_DeviceQualifier_t - * - Library Applications: - * - Added RNDIS device mode to the Webserver project - * - Added new incomplete AndroidAccessoryHost Host LowLevel demo - * - Added new HIDReportViewer project - * - Added new MediaControl project - * - Added new AudioInputHost Host ClassDriver demo - * - Added new AudioOutputHost Host ClassDriver demo - * - Added new AudioInputHost Host LowLevel demo - * - Added new AudioOutputHost Host LowLevel demo - * - Added new "checksource" target to all library project makefiles - * - Added new VTARGET_USE_INTERNAL_REF configuration option to the AVRISP-MKII clone project (thanks to Volker Bosch) - * - * Changed: - * - Core: - * - Altered the definition of the USB_Audio_Descriptor_Format_t descriptor so that the user is now responsible for supplying - * the supported audio sampling rates, to allow for multiple audio interfaces with different numbers of supported rates and/or - * continuous sample rates - * - Pipe_BoundEndpointNumber() has been renamed to Pipe_GetBoundEndpointAddress(), and now returns the correct endpoint direction - * as part of the endpoint address - * - Renamed global state variables that are specific to a certain USB mode to clearly indicate which mode the variable relates to, - * by changing the USB_* prefix to USB_Device_* or USB_Host_* - * - Removed the HOST_STATE_WaitForDeviceRemoval and HOST_STATE_Suspended host state machine states, as these are no longer required - * - Altered the USB_Host_SetDeviceConfiguration() function to update the global Host state machine state and the new - * USB_Host_ConfigurationNumber global as required - * - Added endian correcting code to the library USB class drivers for multiple architecture support - * - Removed the ENDPOINT_DESCRIPTOR_DIR_* macros, replaced by ENDPOINT_DIR_* instead - * - Renamed the JTAG_DEBUG_ASSERT() macro to JTAG_ASSERT() - * - Added variable number of axis to HID_DESCRIPTOR_JOYSTICK() for multi-axis joysticks above just X and Y - * - Renamed USB_Host_ClearPipeStall() to USB_Host_ClearEndpointStall() as the function works on an endpoint address within the attached device, - * and not a Pipe within the host - * - The MS_Host_ResetMSInterface() now performs a full Mass Storage reset sequence to prevent data corruption in the event of a device - * lock up or timeout (thanks to David Lyons) - * - Added endian-correction to the CDC driver's Line Encoding control request handlers. - * - Library Applications: - * - Modified the Low Level and Class Driver AudioInput and AudioOutput demos to support multiple audio sample rates - * - Updated all host mode demos and projects to use the EVENT_USB_Host_DeviceEnumerationComplete() event callback for device configuration - * instead of manual host state machine manipulations in the main application task - * - Changed the reports in the GenericHID device demos to control the board LEDs, to reduce user confusion over the callback routines - * - Added reliability patches to the AVRISP-MKII Clone project's ISP and PDI/TPI protocols (thanks to Justin Mattair) - * - * Fixed: - * - Core: - * - Large number of documentation and code comment corrections (thanks to Andrey from Microsin.ru) - * - Fixed possibility of the AVR's SPI interface being pulled out of master mode if the /SS pin is a input and pulled low (thanks - * to Andrey from Microsin.ru) - * - Fixed compile error when FIXED_CONTROL_ENDPOINT_SIZE compile time option was disabled, and a USE_*_DESCRIPTORS compile time - * option was not enabled on the AVR8s - * - Fixed lack of C++ compatibility in some internal header files causing compile errors when using LUFA in C++ projects - * - Fixed error in the pipe unordered allocation algorithm for the AVR8 devices breaking compatibility with some devices - * - Fixed USB_USBTask not being called internally in stream transfers between packets when Partial Stream Transfers are used - * - Fixed swapped TWI_ADDRESS_READ and TWI_ADDRESS_WRITE values - * - Fixed TWI_ReadPacket() not releasing the TWI bus on read completion - * - Fixed optimization error in the HID Parser item value USB_SetHIDReportItemInfo() and USB_GetHIDReportItemInfo() routines if the report item was - * \c NULL (which should be allowable according to the API) - * - Fixed HID Parser CALLBACK_HIDParser_FilterHIDReportItem() callback function not being passed a cacheable report item pointer - * - Fixed HID Parser's largest report size bit count not including the size of the last parsed report item - * - Fixed HID host driver's largest HID report size count corrupt when the number of report bits exceeds 255 - * - Library Applications: - * - Fixed incorrect signature in the CDC and DFU class bootloaders for the ATMEGA8U2 - * - Fixed KeyboardHost and KeyboardHostWithParser demos displaying incorrect values when numerical keys were pressed - * - Fixed compile errors in the incomplete BluetoothHost demo application (thanks to Timo Lindfors) - * - Fixed incorrect Dataflash buffer use in the DataflashManager_WriteBlocks_RAM() function of several demos/projects (thanks to Jeremy Willden) - * - Fixed incorrect logging interval (always 500ms longer than requested) in the TempDataLogger project - * - Fixed incorrect buffer size check in the USBtoSerial project (thanks to Yuri A Nikiforov) - * - Fixed port state table corruption in the TCP layer of the RNDIS Ethernet device demos - * - * \section Sec_ChangeLog110528 Version 110528 - * New: - * - Core: - * - Added new ORDERED_EP_CONFIG compile time option to restrict endpoint/pipe configuration to ascending order - * in exchange for a smaller compiled program binary size - * - Added a new general RingBuff.h miscellaneous ring buffer library driver header - * - Added new GCC_FORCE_POINTER_ACCESS() macro to correct GCC's mishandling of struct pointer accesses - * - Added new GCC_MEMORY_BARRIER() macro to prevent instruction reordering across boundaries - * - Added basic driver example use code to the library documentation - * - Added new Endpoint_Null_Stream() and Pipe_Null_Stream() functions - * - Added new ADC_GET_CHANNEL_MASK() convenience macro - * - Added new HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors - * - Added new HID_DESCRIPTOR_MOUSE(), HID_DESCRIPTOR_KEYBOARD(), HID_DESCRIPTOR_JOYSTICK() and HID_DESCRIPTOR_VENDOR() macros - * for easy automatic creation of basic USB HID device reports - * - Added new MAX() and MIN() convenience macros - * - Added new Serial_SendData() function to the Serial driver - * - Added board driver support for the Sparkfun ATMEGA8U2 breakout board - * - Added TWI baud rate prescaler and bit length parameters to the TWI_Init() function (thanks to Thomas Herlinghaus) - * - Internal restructuring for eventual multiple architecture ports - * - Added AVR32 UC3 architecture port (currently incomplete/experimental) - * - Added new architecture independent functions to enable, disable, save and restore the Global Interrupt Enable flags - * - Added new RNDIS Device Class Driver packet send and receive functions - * - Library Applications: - * - Added ability to write protect Mass Storage disk write operations from the host OS - * - Added new MIDIToneGenerator project - * - Added new KeyboardMouseMultiReport Device ClassDriver demo - * - Added new VirtualSerialMassStorage Device ClassDriver demo - * - Added HID class bootloader, compatible with a modified version of the command line Teensy loader from PJRC.com - * - Added LED flashing to the CDC and DFU class bootloaders to indicate when they are running - * - * Changed: - * - Core: - * - Unordered Endpoint/Pipe configuration is now allowed once again by default via the previous reconfig workaround - * - Refactored Host mode Class Driver *_Host_ConfigurePipes() routines to be more space efficient when compiled - * - Added new *_ENUMERROR_PipeConfigurationFailed error codes for the *_Host_ConfigurePipes() routines - * - The USARTStream global is now public and documented in the SerialStream module, allowing for the serial USART - * stream to be accessed via its handle rather than via the implicit stdout and stdin streams - * - The FAST_STREAM_TRANSFERS compile time option has been removed due to lack of use and low cost/benefit ratio - * - Altered all endpoint/pipe stream transfers so that the new BytesProcessed parameter now points to a location - * where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction - * should be performed in one chunk) - * - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature - * - Changed over all project and demo HID report descriptors to use the new HID report item macros - * - Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/ - * - Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index - * - Removed the SerialStream driver, rolled functionality into the regular Serial peripheral driver via the new - * Serial_CreateStream() and Serial_CreateBlockingStream() functions - * - Renamed the low level Serial byte send/receive functions, to be consistent with the CDC class driver byte functions - * - Altered the behaviour of the serial byte reception function so that is is non-blocking, and now returns a negative - * value if no character is received (to remain consistent with the CDC class driver byte reception routines) - * - Renamed the PRNT_Host_SendString(), CDC_Host_SendString() and CDC_Device_SendString() functions to *_SendData(), and - * added new versions of the *_SendString() routines that expect a null terminated string instead - * - Renamed all driver termination *_ShutDown() functions to the more logical name *_Disable() - * - Reduced latency for executing the Start-Of-Frame events (if enabled in the user application) - * - Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called - * - Endpoint_ResetFIFO() renamed to Endpoint_ResetEndpoint(), to be consistent with the Pipe_ResetPipe() function name - * - Implemented on-demand PLL clock generation for the U4, U6 and U7 series USB AVRs when automatic PLL mode is specified - * - F_CLOCK changed to F_USB to be more descriptive, and applicable on future architecture ports - * - Renamed all low level Endpoint_Read_*, Endpoint_Write_* and Endpoint_Discard_* functions to use the number of bits instead of - * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures - * - Renamed all low level Pipe_Read_*, Pipe_Write_* and Pipe_Discard_* functions to use the number of bits instead of - * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures - * - Separated out board drivers by architecture in the library internals for better organisation - * - Library Applications: - * - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode - * via the Input Capture register, to reduce user confusion - * - Combined page and word ISP programming mode code in the AVRISP-MKII clone project to reduce compiled size and - * increase maintainability of the code - * - Changed over library projects to use the new general ring buffer library driver module - * - Added new high level TWI packet read/write commands, altered behaviour of the TWI_StartTransmission() function - * - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition - * - Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to reduce CPU usage and free timer 0 - * for other uses - * - Updated the software USART code in the XPLAIN Bridge application so that the incoming bits are sampled at their mid-point - * instead of starting point, to give maximum reliability (thanks to Anton Staaf) - * - * Fixed: - * - Core: - * - Fixed broken USBFOO board drivers due to missing BOARD_USBFOO define - * - Fixed HID host class driver incorrectly binding to HID devices that do not have an OUT endpoint - * - Fixed incorrect definition of the HID_KEYBOARD_SC_D constant in the HID class driver (thanks to Opendous Inc.) - * - Fixed incorrect definition of the HID_KEYBOARD_SC_RIGHT_ARROW constant in the HID class driver (thanks to Joby Taffey) - * - Fixed incorrect endpoint initialisation order in the several device demos (thanks to Rick Drolet) - * - Fixed inverted Minimus board LEDs - * - Fixed incorrect byte ordering in the Audio_Device_WriteSample24 function (thanks to WZab) - * - Fixed several functions in the Host mode Still Image Class driver returning an error code from the incorrect - * error code enum (thanks to Daniel Seibert) - * - Fixed ReportID not being removed from the feature/out report data array in the HID class driver when Report IDs are used - * - Fixed incorrect BUTTONS_BUTTON1 definition for the Minimus board - * - Fixed Still Image Host class driver exiting the descriptor search routine prematurely if the data pipes (but not event pipe) - * is found - * - Fixed missing call to Pipe_SetInfiniteINRequests() in the Pipe_ConfigurePipe() routine - * - Fixed Remote Wakeup broken on the AVRs due to the mechanism only operating when the SUSPI bit is set (thanks to Holger Steinhaus) - * - Fixed possible invalid program execution when in host mode if corrupt descriptor lengths are supplied by the attached device - * - Library Applications: - * - Fixed Benito project discarding incoming data from the USB virtual serial port when the USART is busy - * - Fixed broken DFU bootloader, added XPLAIN support for bootloader start when XCK jumpered to ground - * - Fixed broken HID_REQ_GetReport request handler in the Low Level GenericHID demo - * - Fixed possible lost data in the XPLAINBridge, USBtoSerial and Benito projects when the host exceeds the packet - * timeout period on received packets as set by USB_STREAM_TIMEOUT_MS (thanks to Justin Rajewski) - * - Fixed possible programming problem in the AVRISP-MKII clone project when programming specific patterns into a target - * memory space that is only byte (not page) addressable - * - Fixed errors in the incomplete Test and Measurement device demo preventing proper operation (thanks to Pavel Plotnikov) - * - Fixed programming errors in the AVRISP-MKII project when the programming packet is a round multiple of the endpoint bank - * size under avrdude (thanks to Steffan Woltjer) - * - * - * \section Sec_ChangeLog101122 Version 101122 - * New: - * - Core: - * - Added new SCSI_ASENSE_NOT_READY_TO_READY_CHANGE constant to the Mass Storage class driver, to indicate when a previously - * not ready removable medium has now become ready for the host's use (thanks to Martin Degelsegger) - * - Moved the Pipe and Endpoint stream related code to two new USB library core source files EndpointStream.c and PipeStream.c - * - Added new USB_Device_GetFrameNumber() and USB_Host_GetFrameNumber() functions to retrieve the current USB frame number - * - Added new USB_Host_EnableSOFEvents(), USB_Host_DisableSOFEvents() and EVENT_USB_Host_StartOfFrame() for the user application - * handling of USB Start of Frame events while in USB Host mode - * - Added new PRNT_Host_BytesReceived(), PRNT_Host_ReceiveByte(), PRNT_Host_SendByte() and PRNT_Host_Flush() functions to the - * Print Host Class driver - * - Added class specific descriptor alternative struct type defines with standard USB-IF element naming - * - Added new project makefile template to the library and moved board driver stub files into in a new "CodeTemplates" directory - * - Added board hardware driver support for the Adafruit U4 breakout board - * - Added board hardware driver support for the Arduino Uno development board - * - Added board hardware driver support for the Blackcat USB JTAG board (thanks to the PSGroove team) - * - Added board hardware driver support for the Busware BUI development board - * - Added board hardware driver support for the Busware CUL V3 868MHZ radio board (thanks to Dirk Tostmann) - * - Added board hardware driver support for the Kernel Concepts USBFOO development board - * - Added board hardware driver support for the Linnix UDIP development board - * - Added board hardware driver support for the Olimex AVR-USB-162 development board (thanks to Steve Fawcett) - * - Added board hardware driver support for the Maximus board (thanks to the PSGroove team) - * - Added board hardware driver support for the Microsin AVR-USB162 breakout board - * - Added board hardware driver support for the Minimus board (thanks to the PSGroove team) - * - Added new NO_CLASS_DRIVER_AUTOFLUSH compile time option to disable automatic flushing of interfaces when the USB management - * tasks for each driver is called - * - Added standard keyboard HID report scan-code defines (thanks to Laszlo Monda) - * - Added new Pipe_GetBusyBanks(), Endpoint_GetBusyBanks() and Endpoint_AbortPendingIN() functions - * - Library Applications: - * - Added default test tone generation mode to the Device mode AudioInput demos - * - Added new NO_BLOCK_SUPPORT, NO_EEPROM_BYTE_SUPPORT, NO_FLASH_BYTE_SUPPORT and NO_LOCK_BYTE_WRITE_SUPPORT compile time options to the - * CDC class bootloader - * - Added new XCK_RESCUE_CLOCK_ENABLE compile time option to the AVRISP-MKII clone programmer project (thanks to Tom Light) - * - * Changed: - * - Core: - * - Removed complicated logic for the Endpoint_ConfigureEndpoint() function to use inlined or function called versions - * depending of if the given bank size is a compile time constant, as the compiler does a better job of optimizing - * with basic code - * - Changed the signature of the CALLBACK_USB_GetDescriptor() callback function so that the descriptor pointer is const, to remove - * the need for extra casting inside the callback (thanks to Jonathan Kollasch) - * - Reduced HOST_DEVICE_SETTLE_DELAY_MS to 1000ms down from 1500ms to improve device compatibility while in USB Host mode - * - Removed the EVENT_USB_InitFailure() event, not specifying a USB mode correctly now defaults to UID selection mode - * - Renamed and moved class driver common constant definitions to make the naming scheme more uniform - * - Moved the USB mode specifier constants into a new enum, so that they are semantically related to one another - * - Renamed ENDPOINT_DOUBLEBANK_SUPPORTED() to ENDPOINT_BANKS_SUPPORTED() and changed it to return the maximum number of supported banks for - * the given endpoint - * - Better algorithm to extract and convert the internal device serial number into a string descriptor (if present) - * - All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be separately included - * - The MIDI class drivers now automatically flushes the MIDI interface when the MIDI class driver's USBTask() function is called - * - Renamed the EVENT_USB_Device_UnhandledControlRequest() event to EVENT_USB_Device_ControlRequest() as it is now fired before the library - * request handlers, not afterwards - * - Library Applications: - * - Changed over all device demos to use a clearer algorithm for the configuring of the application's endpoints - * - Added missing DataflashManager_CheckDataflashOperation() function to the MassStorageKeyboard demo, removed redundant - * SCSI_Codes.h file as these values are part of the MassStorage Class Driver - * - Added compile time error to the AVRISP-MKII project when built for the U4 chips, as the default VTARGET detection ADC channel - * does not exist on these chips (thanks to Marco) - * - Changed all Device mode LowLevel demos and Device Class drivers so that the control request is acknowledged and any data - * transferred as quickly as possible without any processing in between sections, so that long callbacks or event handlers will - * not break communications with the host by exceeding the maximum control request stage timeout period - * - Changed over all demos, drivers and internal functions to use the current frame number over the Start of Frame flag where possible - * to free up the Start of Frame flag for interrupt use in the user application - * - All project makefiles now correctly clean intermediate build files from assembly and C++ sources (thanks to Daniel Czigany) - * - Changed default value for the reset polarity parameter in the AVRISP-MKII project so that it defaults to active low drive - * - Changed configuration descriptor parser for all host mode projects and class drivers to ensure better compatibility with devices - * - All LowLevel demos changed to use the constants and types defined in the USB class drivers - * - Changed AudioInput and AudioOutput demos to reload the next sample via an interrupt rather than polling the sample timer - * - Rescue clock of the AVRISP-MKII moved to the AVR's OCR1A pin, so that the clock can be generated at all times - * - Changed ClassDriver MIDI demos to process all incoming events in a loop until the bank becomes empty rather than one at a time - * - Changed LowLevel MIDI demos to only clear the incoming event bank once it has become empty to support packed event packets - * - * Fixed: - * - Core: - * - Fixed USB_GetHIDReportItemInfo() function modifying the given report item's data when the report item does not exist - * within the supplied report of a multiple report HID device - * - Fixed critical pipe/endpoint memory allocation issue where the bank memory address space could be silently overlapped - * in the USB controller if the endpoints or pipes were allocated in anything other than ascending order (thanks to Martin Degelsegger) - * - Added LEDs_ToggleLEDs() function to several board LED drivers which were missing it (thanks to Andrei Krainev) - * - Fixed SET FEATURE and CLEAR FEATURE control requests directed at an unconfigured endpoint causing request timeouts - * - Fixed USB_Host_ClearPipeStall() incorrectly determining the endpoint direction from the currently selected pipe - * - Fixed JTAG_DEBUG_POINT() and JTAG_DEBUG_BREAK() macros not compiling under pure C99 standards mode - * - Fixed endpoint selection within the CALLBACK_HID_Device_CreateHIDReport() callback function causing broken GET REPORT requests - * - Fixed incorrect command name for EEPROM memory programming in the makefile dfu-ee target - * - Fixed incorrect LEDs_ChangeLEDs() function in the Benito board LED driver - * - Fixed incorrect USB_DeviceState value when unconfiguring the device without an address set - * - Fixed SPI driver not explicitly setting /SS and MISO pins as inputs when SPI_Init() is called - * - Fixed random enumeration failure while in device mode due to interrupts causing the Set Address request to exceed maximum timings - * - Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface was not configured - * - Fixed MIDI class driver send routines silently discarding packets if the endpoint or pipe is busy (thanks to Robin Green) - * - Library Applications: - * - Fixed MassStorage based demos and projects resetting the SCSI sense values before the command is executed, leading to - * missed SCSI sense values when the host retrieves the sense key (thanks to Martin Degelsegger) - * - Fixed USBtoSerial and Benito project SetLineEncoding calls failing if the USART is busy, due to the RX ISR delaying the control - * request handler - * - Fixed LowLevel PrinterHost demo not sending control requests to the attached printer with the correct printer interface wIndex value - * - Fixed incorrect signature reported in the CDC class bootloader for the ATMEGA32U2 - * - Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev) - * - Fixed broken FLASH/EEPROM programming in the AVRISP-MKII clone project when writing in non-paged mode and the polling byte cannot be used - * - Fixed ISR definition conflict in the XPLAIN bridge between the software UART and the AVRISP-MKII ISP modules - * - Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the send buffer becomes full - * - Fixed broken input in the MagStripe reader project due to an incorrect HID report descriptor - * - Fixed incorrect PollingIntervalMS values in the demo/project/bootloader endpoint descriptors (thanks to MCS Electronics) - * - Fixed AVRISP-MKII clone project not starting the target's program automatically after exiting TPI programming mode - * - * - * \section Sec_ChangeLog100807 Version 100807 - * New: - * - Added new ADC_DisableChannel() function (thanks to Mich Davis) - * - Added new VTARGET_REF_VOLTS and VTARGET_SCALE_FACTOR compile time defines to the AVRISP-MKII programmer project to set - * the VTARGET reference voltage and scale factor - * - Added new pgm_read_ptr() macro to Common.h for reading of pointers out of flash memory space - * - Added new SWAPENDIAN_16() and SWAPENDIAN_32() macros to Common.h for statically initialized variables at compile time - * - Added new Drivers/USB/LowLevel/Device.c file to house Device mode specific functions that are more complicated than simple macros - * - Added new AVRStudio 4 project files for all library demos, projects and bootloaders - * - Added ability to set the serial baud rate via the user's terminal in the XPLAINBridge project - * - Added new LUFA module variables for the different source modules in the core library makefile to simplify project makefiles - * - Added start of a new Test and Measurement class demo (thanks to Peter Lawrence) - * - Added new SPI_ORDER_* data order masks to the SPI peripheral driver - * - Added support to the AVRISP-MKII project for ISP speeds slower than 125KHz via a new software SPI driver - * - Added support for the new button/LED on the latest model USBTINY-MKII - * - * Changed: - * - The RingBuff library code has been replaced in the XPLAINBridge, Benito and USBtoSerial projects with an ultra lightweight - * ring buffer to help improve the reliability of the projects - * - The EEPROM stream read/write functions now use eeprom_update_byte() instead of eeprom_write_byte(), so that only - * changed bytes are written to EEPROM to preserve its lifespan - * - Changed over the AVRISP-MKII and TemperatureDataLogger projects to use eeprom_update_byte() when writing non-volatile - * parameters to EEPROM to preserve its lifespan - * - Removed unused line encoding data and control requests from the CDC Bootloader code, to save space - * - Renamed SERIAL_STREAM_ASSERT() macro to STDOUT_ASSERT() - * - The USB_Device_IsRemoteWakeupSent() and USB_Device_IsUSBSuspended() macros have been deleted, as they are now obsolete - * - Rewrote the implementation of the SwapEndian_16() and SwapEndian_32() functions so that they compile down in most instances to - * minimal loads and stores rather than complicated shifts - * - The software UART in the XPLAINBridge has been largely altered to try to improve upon its performance and reliability - * - The USBtoSerial and Benito projects now flushes received data via a flush timer, so that several bytes can be transmitted at once - * - Removed the automated checking of event names in the demo, project and bootloader makefiles due to inconsistencies between the - * behaviour of the command line tools used to perform the check on each platform - * - Internal USB driver source files renamed and moved to ease future possible architecture ports - * - All internal pseudo-function macros have been converted to true inline functions for type-safety and readability - * - Changed LED indicator masks for the AVRISP-MKII project, so that there are defined roles for each LED - * - Altered the CDC Device and Host Class drivers' receive byte routines, so that no data is indicated by the function returning a - * negative value (thanks to Andreas Paulin) - * - Added auto flushing of OUT data to the CDC Host Class driver's USBTask function to automatically flush the send pipe buffer - * - * Fixed: - * - Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs after programming or reading from - * the last page of FLASH (thanks to Gerard Sexton) - * - Fixed AVRISP project not sending a full erase-and-write EEPROM command to XMEGA targets when writing to the EEPROM - * instead of the split write-only command (thanks to Tim Margush) - * - Fixed RNDISEthernet demos crashing when calculating checksums for Ethernet/TCP packets of more than ~500 bytes due to - * an overflow in the checksum calculation loop (thanks to Kevin Malec) - * - Fixed XPLAINBridge project not correctly reading the XMEGA's supply voltage when reporting back to the host - * - Fixed incorrect signature for the ATMEGA32U2 in the DFU bootloader (thanks to Axel Rohde) - * - Fixed internal device serial not being accessible on the ATMEGAXXU2 AVRs (thanks to Axel Rohde) - * - Fixed void pointer arithmetic in ConfigDescriptor.h breaking C++ compatibility (thanks to Michael Hennebry) - * - Fixed broken PDI EEPROM Section Erase functionality in the AVRISP-MKII project - * - Fixed USB_Device_SendRemoteWakeup() not working when the USB clock was frozen during USB bus suspend (thanks to Brian Dickman) - * - Fixed occasional lockup of the AVRISP project due to the timeout extension code incorrectly extending the timeout in - * PDI and TPI programming modes infinitely - * - Fixed HID device class driver still using PrevReportINBuffer for GetReport control requests even when it has been - * set to NULL by the user application (thanks to Axel Rohde) - * - Fixed MIDI_Device_SendEventPacket() not correctly waiting for the endpoint to become ready (thanks to Robin Green) - * - Fixed Benito and USBtoSerial projects not turning off the USART before reconfiguring it, which could cause incorrect - * operation to occur (thanks to Bob Paddock) - * - Fixed Serial peripheral driver not turning off the USART before reconfiguring it, which would cause incorrect operation - * to occur (thanks to Bob Paddock) - * - Fixed software application start command broken in the DFU class bootloader when dfu-programmer is used due to application - * start address corruption - * - * - * \section Sec_ChangeLog100513 Version 100513 - * New: - * - Added incomplete MIDIToneGenerator project - * - Added new Relay Controller Board project (thanks to OBinou) - * - Added board hardware driver support for the Teensy, USBTINY MKII, Benito and JM-DB-U2 lines of third party USB AVR boards - * - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup - * - Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus - * is suspended before or during a transfer - * - Added new EVENT_CDC_Device_BreakSent() event and CDC_Host_SendBreak() function to the Device and Host CDC Class drivers - * - Added ReportType parameter to the HID device class driver CALLBACK_HID_Device_ProcessHIDReport() function so that FEATURE - * reports from the host to the device can be correctly processed - * - Added ReportType parameter to the HID host class driver HID_Host_SendReportByID() function so that FEATURE reports can be - * issued to the attached device - * - * Changed: - * - AVRISP programmer project now has a more robust timeout system - * - Added a timeout value to the TWI_StartTransmission() function, within which the addressed device must respond - * - Webserver project now uses the board LEDs to indicate the current IP configuration state - * - Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable the TELNET server if desired - * - Increased throughput of the USBtoSerial demo on systems that send multiple bytes per packet (thanks to Opendous Inc.) - * - Double bank CDC endpoints in the XPLAIN Bridge project, re-enable JTAG once the mode selection pin has been sampled. - * - Standardized the naming scheme given to configuration descriptor sub-elements in the Device mode demos, bootloaders - * and projects - * - All Class Driver Host mode demos now correctly set the board LEDs to READY once the enumeration process has completed - * - Added LIBUSB_FILTERDRV_COMPAT compile time option to the AVRISP programmer project to make the code compatible with Windows - * builds of avrdude at the expense of AVRStudio compatibility - * - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code - * - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready - * for them to be enabled (thanks to Andrei Krainev) - * - The Audio_Device_IsSampleReceived() and Audio_Device_IsReadyForNextSample() functions are now inline, to reduce overhead - * - Removed the cast to uint16_t on the set baud rate in the USBtoSerial project, so that the higher >1M baud rates can be - * selected (thanks to Steffan Woltjer) - * - Removed software PDI and TPI emulation from the AVRISP-MKII clone project as it was very buggy and slow - PDI and TPI must - * now be implemented via separate programming headers - * - The CDC class bootloader now uses a watchdog reset rather than a soft-reset when exited to ensure that all hardware is - * properly reset to their defaults - * - Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from - * timing out if another request is immediately fired and the device has a lengthy callback routine - * - The TeensyHID bootloader has been removed, per request from Paul at PJRC - * - The LIBUSB_FILTERDRV_COMPAT compile time option in the XPLAINBridge and AVRISP-MKII projects has been renamed - * LIBUSB_DRIVER_COMPAT, as it applies to all software on all platforms using the libUSB driver - * - * Fixed: - * - Fixed possible device lockup when INTERRUPT_CONTROL_ENDPOINT is enabled and the control endpoint is not properly - * selected when the ISR completes - * - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address - * boundary is crossed during programming or read back (thanks to Gerard Sexton) - * - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled - * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin - * - Fixed TWI_StartTransmission() corrupting the contents of the GPIOR0 register - * - Fixed TWI driver not aborting when faced with no response after attempting to address a device on the bus - * - Fixed ADC routines not correctly returning the last result when multiple channels were read - * - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the - * U4 series USB AVR parts - * - Fixed LowLevel MassStorage demo broken on the U2 series USB AVRs due to unsupported double-banked endpoint modes used - * - Fixed compilation error in the AudioInput demos when MICROPHONE_BIASED_TO_HALF_RAIL is defined (thanks to C. Scott Ananian) - * - Fixed incorrect definition of HID_ALIGN_DATA() causing incorrect HID report item data alignment - * - Fixed Still Image Host class driver not resetting the transaction ID when a new session is opened, fixed driver not sending - * a valid session ID to the device - * - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer - * - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host - * - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the - * user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski) - * - Fixed device state not being reset to DEVICE_STATE_Default if the host sets a 0x00 device address - * - Fixed device not stalling configuration requests before the device's address has been set - * - Fixed possibility of internal signature retrieval being corrupted if an interrupt occurs during a signature byte - * read (thanks to Andrei Krainev) - * - Fixed device state not being reset back to the default state if the host sets the address to 0 - * - Fixed Set Configuration requests not being stalled until the host has set the device's address - * - Fixed Host mode HID class driver not sending the correct report type when HID_Host_SendReportByID() was called and the - * HID_HOST_BOOT_PROTOCOL_ONLY compile time option is set - * - Fixed INTERRUPT_CONTROL_ENDPOINT compile time option preventing other interrupts from occurring while the control endpoint - * request is being processed, causing possible lockups if a USB interrupt occurs during a transfer - * - Remove incorrect Abstract Call Management class specific descriptor from the CDC demos, bootloaders and projects - * - * - * \section Sec_ChangeLog100219 Version 100219 - * - * New: - * - Added TPI programming support for 6-pin ATTINY devices to the AVRISP programmer project (thanks to Tom Light) - * - Added command timeout counter to the AVRISP project so that the device no longer freezes when incorrectly connected - * to a target - * - Added new TemperatureDataLogger application, a USB data logger which writes to the device's dataflash and appears to - * the host as a standard Mass Storage device when inserted - * - Added MIDI event packing support to the MIDI Device and Host mode Class drivers, allowing for multiple MIDI events to - * sent or received in packed form in a single USB packet - * - Added new MIDI send buffer flush routines to the MIDI Device and Host mode Class drivers, to flush packed events - * - Added master mode hardware TWI driver for easy TWI peripheral control - * - Added ADC MUX masks for the standard ADC input channels on all AVR models with an ADC, altered demos to use these masks - * as on some models, the channel number is not identical to its single-ended ADC MUX mask - * - New Webserver project, a RNDIS host USB webserver using the open source uIP TCP/IP network stack and FatFS library - * - New BOARD value option BOARD_NONE (equivalent to not specifying BOARD) which will remove all board hardware drivers which - * do not adversely affect the code operation (currently only the LEDs driver) - * - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) and LED report masks (KEYBOARD_LED_*) to the HID class driver and - * Keyboard demos - * - Added .5MHz recovery clock to the AVRISP programmer project when in ISP programming mode to correct mis-set fuses - * - * Changed: - * - Slowed down software USART carried PDI programming in the AVRISP project to prevent transmission errors - * - Renamed the AVRISP project folder to AVRISP-MKII to reduce confusion - * - Renamed the RESET_LINE_* makefile tokens in the AVRISP MKII Project to AUX_LINE_*, as they are not always used for target - * reset - * - Changed over the MassStorageKeyboard Class driver device demo to use Start of Frame events rather than a timer to keep track - * of elapsed milliseconds - * - Inlined currently unused (but standardized) maintenance functions in the Device and Host Class drivers to save space - * - The XPLAINBridge project now selects between a USB to Serial bridge and a PDI programmer on startup, reading the JTAG port's - * TDI pin to determine which mode to use - * - Removed the stream example code from the Low Level VirtualSerial demos, as they were buggy and only served to add clutter - * - * Fixed: - * - Fixed AVRISP project not able to enter programming mode when ISP protocol is used - * - Fixed AVRISP PDI race condition where the guard time between direction changes could be interpreted as a start bit - * - Fixed ADC_IsReadingComplete() returning an inverted result - * - Fixed blocking CDC streams not aborting when the host is disconnected - * - Fixed XPLAIN board Dataflash driver broken due to incorrect preprocessor commands - * - Fixed inverted XPLAIN LED driver output (LED turned on when it was supposed to be turned off, and vice-versa) - * - Fixed Class Driver struct interface numbers in the KeyboardMouse and VirtualSerialMouse demos (thanks to Renaud Cerrato) - * - Fixed invalid USB controller PLL prescaler values for the ATMEGAxxU2 controllers - * - Fixed lack of support for the ATMEGA32U2 in the DFU and CDC class bootloaders - * - Fixed Benito project not resetting the target AVR automatically when programming has completed - * - Fixed DFU bootloader programming not discarding the correct number of filler bytes from the host when non-aligned programming - * ranges are specified (thanks to Thomas Bleeker) - * - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two separate pipes, not one half-duplex pipe - * - Fixed Pipe_IsEndpointBound() not taking the endpoint's direction into account - * - Fixed EEPROM and FLASH ISP programming in the AVRISP project - * - Fixed incorrect values of USB_CONFIG_ATTR_SELFPOWERED and USB_CONFIG_ATTR_REMOTEWAKEUP tokens (thanks to Claus Christensen) - * - Fixed SerialStream driver blocking while waiting for characters to be received instead of returning EOF - * - Fixed SerialStream driver not setting stdin to the created serial stream (thanks to Mike Alexander) - * - Fixed USB_GetHIDReportSize() returning the number of bits in the specified report instead of bytes - * - Fixed AVRISP project not extending the command delay after each successful page/word/byte program - * - Fixed accuracy of the SERIAL_UBBRVAL() and SERIAL_2X_UBBRVAL() macros for higher baud rates (thanks to Renaud Cerrato) - * - * - * \section Sec_ChangeLog091223 Version 091223 - * - * New: - * - Added activity LED indicators to the AVRISP project to indicate when the device is busy processing a command - * - The USB target family and allowable USB mode tokens are now public and documented (USB_CAN_BE_*, USB_SERIES_*_AVR) - * - Added new XPLAIN USB to Serial Bridge project (thanks to John Steggall for initial proof-of-concept, David Prentice - * and Peter Danneger for revised software USART code) - * - Added new RNDIS Ethernet Host LowLevel demo - * - Added new RNDIS Ethernet Host Class Driver - * - Added new RNDIS Ethernet Host ClassDriver demo - * - Added CDC_Host_Flush() function to the CDC Host Class driver to flush sent data to the attached device - * - Added PDI programming support for XMEGA devices to the AVRISP programmer project (thanks to Justin Mattair) - * - Added support for the XPLAIN board Dataflash, with new XPLAIN_REV1 board target for the different dataflash used - * on the first revision boards compared to the one mounted on later revisions - * - Added new HID_ALIGN_DATA() macro to return the pre-retrieved value of a HID report item, left-aligned to a given datatype - * - Added new PreviousValue to the HID Report Parser report item structure, for easy monitoring of previous report item values - * - Added new EVK527 board target - * - Added new USB_Host_GetDeviceStringDescriptor() convenience function - * - Added new LEDNotification project to the library, to give a visual LED notification on new events from the host - * - Added new NO_DEVICE_REMOTE_WAKEUP and NO_DEVICE_SELF_POWER compile time options - * - * Changed: - * - Removed code in the Keyboard demos to send zeroed reports between two reports with differing numbers of key codes - * as this relied on non-standard OS driver behaviour to repeat key groups - * - The SCSI_Request_Sense_Response_t and SCSI_Inquiry_Response_t type defines are now part of the Mass Storage Class - * driver common defines, rather than being defined in the Host mode Class driver section only - * - The USB_MODE_HOST token is now defined even when host mode is not available - * - The CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new ReportType parameter to - * indicate the report type to generate - * - All Class Drivers now return false or the "DeviceDisconnected" error code of their respective error enums when a function - * is called when no host/device is connected where possible - * - The HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to HOST_SENDCONTROL_DeviceDisconnected to be in line - * with the rest of the library error codes - * - Make MIDI device demos also turn off the on board LEDs if MIDI Note On messages are sent with a velocity of zero, - * which some devices use instead of Note Off messages (thanks to Robin Green) - * - The CDC demos are now named "VirtualSerial" instead to indicate the demos' function rather than its implemented USB class, - * to reduce confusion and to be in line with the rest of the LUFA demos - * - The SImage_Host_SendBlockHeader() and SImage_Host_ReceiveBlockHeader() Still Image Host Class driver functions are now public - * - * Fixed: - * - Added missing CDC_Host_CreateBlockingStream() function code to the CDC Host Class driver - * - Fixed incorrect values for REPORT_ITEM_TYPE_* enum values causing corrupt data in the HID Host Parser - * - Fixed misnamed SI_Host_USBTask() and SI_Host_ConfigurePipes() functions - * - Fixed broken USB_GetNextDescriptor() function causing the descriptor to jump ahead double the expected amount - * - Fixed Pipe_IsEndpointBound() not masking the given Endpoint Address against PIPE_EPNUM_MASK - * - Fixed host state machine not enabling Auto VBUS mode when HOST_DEVICE_SETTLE_DELAY_MS is set to zero - * - Fixed misnamed Pipe_SetPipeToken() macro for setting a pipe's direction - * - Fixed CDCHost failing on devices with bidirectional endpoints - * - Fixed USB driver failing to define the PLL prescaler mask for the ATMEGA8U2 and ATMEGA16U2 - * - Fixed HID Parser not distributing the Usage Min and Usage Max values across an array of report items - * - Fixed Mass Storage Host Class driver and Low Level demo not clearing the error condition if an attached device returns a - * STALL to a GET MAX LUN request (thanks to Martin Luxen) - * - Fixed TeensyHID bootloader not properly shutting down the USB interface to trigger a disconnection on the host before resetting - * - Fixed MassStorageHost Class driver demo not having USB_STREAM_TIMEOUT_MS compile time option set properly to prevent slow - * devices from timing out the data pipes - * - Fixed the definition of the Endpoint_BytesInEndpoint() macro for the U4 series AVR parts - * - Fixed MIDI host Class driver MIDI_Host_SendEventPacket() routine not properly checking for Pipe ready before writing - * - Fixed use of deprecated struct initializers, removed library unused parameter warnings when compiled with -Wextra enabled - * - Fixed Still Image Host Class driver truncating the PIMA response code (thanks to Daniel Seibert) - * - Fixed USB_CurrentMode not being reset to USB_MODE_NONE when the USB interface is shut down and both Host and Device modes can be - * used (thanks to Daniel Levy) - * - Fixed TeensyHID bootloader not enumerating to the host correctly (thanks to Clint Fisher) - * - Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott) - * - Fixed STK525 Dataflash driver using incorrect bit-shifting for Dataflash addresses (thanks to Tim Mitchell) - * - * - * \section Sec_ChangeLog091122 Version 091122 - * - * New: - * - Added new Dual Role Keyboard/Mouse demo - * - Added new HID_HOST_BOOT_PROTOCOL_ONLY compile time token to reduce the size of the HID Host Class driver when - * Report protocol is not needed - * - Added new MIDI LowLevel and ClassDriver Host demo, add new MIDI Host Class driver - * - Added new CDC/Mouse ClassDriver device demo - * - Added new Joystick Host ClassDriver and LowLevel demos - * - Added new Printer Host mode Class driver - * - Added new Printer Host mode ClassDriver demo - * - Added optional support for double banked endpoints and pipes in the Device and Host mode Class drivers - * - Added new stream creation function to the CDC Class drivers, to easily make standard I/O streams from CDC Class driver instances - * - * Changed: - * - Removed mostly useless "TestApp" demo, as it was mainly useful only for checking for syntax errors in the library - * - MIDI device demos now receive MIDI events from the host and display note ON messages via the board LEDs - * - Cleanups to the Device mode Mass Storage demo application SCSI routines - * - Changed Audio Class driver sample read/write functions to be inline, to reduce the number of cycles needed to transfer - * samples to and from the device (allowing more time for sample processing and output) - * - Audio class Device mode demos now work at both 16MHz and 8MHz, rather than just at 8MHz - * - The previous USBtoSerial demo has been moved into the projects directory, as it was just a modified CDC demo - * - The Endpoint/Pipe functions now use the const qualifier on the input buffer - * - Changed the CALLBACK_HIDParser_FilterHIDReportItem() callback to pass a HID_ReportItem_t rather than just the current - * item's attributes, to expose more information on the item (including it's type, collection path, etc.) - * - Changed MouseHostWithParser demos to check that the report items have a Mouse usage collection as a parent at some point, - * to prevent Joysticks from enumerating with the demo - * - Corrected the name of the misnamed USB_GetDeviceConfigDescriptor() function to USB_Host_GetDeviceConfigDescriptor(). - * - Keyboard LowLevel/ClassDriver demos now support multiple simultaneous key presses (up to 6) per report - * - * Fixed: - * - Fixed PrinterHost demo returning invalid Device ID data when the attached device does not have a - * device ID (thanks to Andrei Krainev) - * - Changed LUFA_VERSION_INTEGER define to use BCD values, to make comparisons easier - * - Fixed issue in the HID Host class driver's HID_Host_SendReportByID() routine using the incorrect mode (control/pipe) - * to send report to the attached device - * - Fixed ClassDriver AudioOutput device demo not selecting an audio output mode - * - Fixed incorrect SampleFrequencyType value in the AudioInput and AudioOutput ClassDriver demos' descriptors - * - Fixed incorrect event name rule in demo/project/bootloader makefiles - * - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called - * - Corrected HID descriptor in the Joystick Device demos - buttons should be placed outside the pointer collection - * - Fixed HID report parser collection paths invalid due to misplaced semicolon in the free path item search loop - * - Fixed HID host Class driver report send/receive report broken when issued through the control pipe - * - Fixed HOST_STATE_AS_GPIOR compile time option being ignored when in host mode (thanks to David Lyons) - * - Fixed LowLevel Keyboard demo not saving the issues report only after it has been sent to the host - * - Fixed Endpoint_Write_Control_Stream_* functions not sending a terminating IN when given data Length is zero - * - * - * \section Sec_ChangeLog090924 Version 090924 - * - * New: - * - Added new host mode class drivers and matching demos to the library for rapid application development - * - Added flag to the HID report parser to indicate if a device has multiple reports - * - Added new EVENT_USB_Device_StartOfFrame() event, controlled by the new USB_Device_EnableSOFEvents() and - * USB_Device_DisableSOFEvents() macros to give bus-synchronized millisecond interrupts when in USB device mode - * - Added new Endpoint_SetEndpointDirection() macro for bidirectional endpoints - * - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer - * - Added ShutDown() functions for all hardware peripheral drivers, so that peripherals can be turned off after use - * - Added new CDC_Device_Flush() command to the device mode CDC Class driver to flush Device->Host data - * - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set - * - Added new callback to the HID report parser, so that the user application can filter only the items it is interested - * in to be stored into the HIDReportInfo structure to save RAM - * - Added support for the officially recommended external peripheral layout for the BUMBLEB board (thanks to Dave Fletcher) - * - Added new Pipe_IsFrozen() macro to determine if the currently selected pipe is frozen - * - Added new USB_GetHIDReportSize() function to the HID report parser to retrieve the size of a given report by its ID - * - Added new combined Mass Storage and Keyboard demo (thanks to Matthias Hullin) - * - * Changed: - * - SetIdle requests to the HID device driver with a 0 idle period (send changes only) now only affect the requested - * HID interface within the device, not all HID interfaces - * - Added explicit attribute masks to the device mode demos' descriptors - * - Added return values to the CDC and MIDI class driver transmit functions - * - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size - * - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability - * - Added new "Common" section to the class drivers, to hold all mode-independent definitions for clarity - * - Moved SCSI command/sense constants into the Mass Storage Class driver, instead of the user-code - * - Altered the SCSI commands in the LowLevel Mass Storage Host to save on FLASH space by reducing function calls - * - Changed the parameters and behaviour of the USB_GetDeviceConfigDescriptor() function so that it now performs size checks - * and data validations internally, to simplify user code - * - Changed HIDParser to only zero out important values in the Parsed HID Report Item Information structure to save cycles - * - The HID report parser now always processed FEATURE items - HID_ENABLE_FEATURE_PROCESSING token now has no effect - * - The HID report parser now always ignores constant-data items, HID_INCLUDE_CONSTANT_DATA_ITEMS token now has no effect - * - The Benito Programmer project now has its own unique VID/PID pair allocated from the Atmel donated LUFA VID/PID pool - * - Add in new invalid event hook check targets to project makefiles to produce compilation errors when invalid event names - * are used in a project - * - The HID Report Parser now gives information on the total length of each report within a HID interface - * - The USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate USB_Descriptor_* and - * USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so both may be used - * - * Fixed: - * - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the - * endpoint's bank - * - Fixed swapped parameters in the HID state memory copy call while processing a HID PUSH item in the HID report parser - * - Fixed memory corruption HID report parser when too many COLLECTION or PUSH items were processed - * - Fixed HID report parser not resetting the FEATURE item count when a REPORT ID item is encountered - * - Fixed USBtoSerial demos not reading in UDR1 when the USART receives data but the USB interface is not enumerated, - * causing continuous USART receive interrupts - * - Fixed misspelled event name in the Class driver USBtoSerial demo, preventing correct operation - * - Fixed invalid data being returned when a GetStatus request is issued in Device mode with an unhandled data recipient - * - Added hardware USART receive interrupt and software buffering to the Benito project to ensure received data is not - * missed or corrupted - * - Fixed Device mode HID Class driver always sending IN packets, even when nothing to report - * - Fixed Device mode HID Class driver not explicitly initializing the ReportSize parameter to zero before calling callback - * routine, so that ignored callbacks don't cause incorrect data to be sent - * - Fixed StillImageHost not correctly freezing and unfreezing data pipes while waiting for a response block header - * - Fixed error in the PrinterHost demo preventing the full page data from being sent to the attached device (thanks to John Andrews) - * - Fixed CDC based demos and projects' INF driver files under 64 bit versions of Windows (thanks to Ronny Hanson, Thomas Bleeker) - * - Re-add in missing flip, flip-ee, dfu and dfu-ee targets to project makefiles (thanks to Opendous Inc.) - * - Fix allowable F_CPU values comment in project makefiles to more accurately reflect the allowable values on the USB AVRs - * - Fixed DFU and CDC class bootloaders on the series 2 USB AVRs, corrected invalid signatures, added support for the new - * ATMEGAxx2 series 2 variant AVRs to the DFU bootloader - * - Fixed Low Level USBtoSerial demo not storing received characters (thanks to Michael Cooper) - * - Fixed MIDI Device Class driver not sending/receiving MIDI packets of the correct size (thanks to Thomas Bleeker) - * - * - * \section Sec_ChangeLog090810 Version 090810 - * - * New: - * - Added new device class drivers and matching demos to the library for rapid application development - * - Added new PrinterHost demo (thanks to John Andrews) - * - Added USB Missile Launcher project, submitted by Dave Fletcher - * - Added new Benito Arduino Programmer project - * - Added incomplete device and host mode demos for later enhancement - * - Updated MassStorage device block write routines to use ping-pong Dataflash buffering to increase throughput by around 30% - * - Error status LEDs shown when device endpoint configuration fails to complete in all demos and projects - * - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB - * host mode - * - Added new USB_Host_ClearPipeStall() convenience function to clear a stall condition on an attached device's endpoint - * - Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor - * - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers - * - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number, - * added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code - * - Added new DATAFLASH_CHIP_MASK() macro to the Dataflash driver, which returns the Dataflash select mask for the given chip index - * - Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking disabling of device communications until the - * device has been removed (for use when an error occurs or communications with the device have completed) - * - Added new FAST_STREAM_TRANSFERS compile time option for faster stream transfers via multiple bytes copied per stream loop - * - Added stdio stream demo code to the CDC device demos, to show how to create standard streams out of the virtual serial ports - * - Added new EEPROM and FLASH buffer versions of the Endpoint and Pipe stream functions - * - Added new USE_FLASH_DESCRIPTORS and FIXED_NUM_CONFIGURATIONS compile time options - * - Added support for the new ATMEGA32U2, ATMEGA16U2 and ATMEGA8U2 AVR models - * - Added new USB_DeviceState variable to keep track of the current Device mode USB state - * - Added new LEDs_ToggleLEDs() function to the LEDs driver - * - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions - * - Added new DEVICE_STATE_AS_GPIOR and HOST_STATE_AS_GPIOR compile time options - * - Added 404 Not Found errors to the webserver in the RNDIS demos to indicate invalid URLs - * - * Changed: - * - Deprecated pseudo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused) - * - The device-mode CALLBACK_USB_GetDescriptor() function now has an extra parameter so that the memory space in which the requested - * descriptor is located can be specified. This means that descriptors can now be located in multiple memory spaces within a device. - * - Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality - * - Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead - * - Extended USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch - * - Dataflash_WaitWhileBusy() now always ensures that the dataflash is ready for the next command immediately after returning, - * no need to call Dataflash_ToggleSelectedChipCS() afterwards - * - Low level API MIDI device demo no longer blocks if a note change event is sent while the endpoint is not ready - * - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors - * - Pipe stream functions now automatically set the correct pipe token, so that bidirectional pipes can be used - * - Pipe_ConfigurePipe() now automatically defaults IN pipes to accepting infinite IN requests, this can still be changed by calling - * the existing Pipe_SetFiniteINRequests() function - * - Changed F_USB entries in project makefiles to alias to F_CPU by default, as this is the most common case - * - Host mode demos now use sane terminal escape codes, so that text is always readable and events/program output is visually distinguished - * from one another using foreground colours - * - Internal per-device preprocessing conditions changed to per-device series rather than per-controller group for finer-grain - * internal control - * - Interrupts are no longer disabled during the processing of Control Requests on the default endpoint while in device mode - * - AudioOutput demos now always output to board LEDs, regardless of output mode (removed AUDIO_OUT_LEDS project option) - * - Removed SINGLE_DEVICE_CONFIGURATION compile time option in favor of the new FIXED_NUM_CONFIGURATIONS option so that the exact number - * of device configurations can be defined statically - * - Removed VBUS events, as they are already exposed to the user application via the regular device connection and disconnection events - * - Renamed and altered existing events to properly separate out Host and Device mode events - * - All demos switched over from GNU99 standards mode to C99 standards mode, to reduce the dependencies on GCC-only language extensions - * - * Fixed: - * - Changed bootloaders to use FLASHEND rather than the existence of RAMPZ to determine if far FLASH pointers are needed to fix - * bootloaders on some of the USB AVR devices where avr-libc erroneously defines RAMPZ - * - Fixes to MassStorageHost for better device compatibility (increase command timeout, change MassStore_WaitForDataReceived() - * to only unfreeze and check one data pipe at a time) to prevent incorrect device enumerations and freezes while transferring data - * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is - * cleared to prevent endpoint type corruption - * - Fixed issue opening CDC-ACM ports on hosts when the CDC device tries to send data before the host has set the line encoding - * - Fixed USB_OPT_MANUAL_PLL option being ignored during device disconnects on some models (thanks to Brian Dickman) - * - Fixed documentation mentioning Pipe_GetCurrentToken() function when correct function name is Pipe_GetPipeToken() - * - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.) - * - Fixed CDCHost demo unfreezing the pipes at the point of configuration, rather than use - * - Fixed MassStorage demo not clearing the reset flag when a Mass Storage Reset is issued while not processing a command - * - Fixed USB_Host_SendControlRequest() not re-suspending the USB bus when initial device ready-wait fails - * - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used - * - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected - * - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman) - * - Fixed GenericHID failing HID class tests due to incorrect Logical Minimum and Logical Maximum values (thanks to Soren Greiner) - * - Fixed incorrect PIPE_EPNUM_MASK mask causing pipe failures on devices with endpoint addresses of 8 and above (thanks to John Andrews) - * - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits - * - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered - * - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target - * - Fixed RNDIS demos freezing when more than one connection was attempted simultaneously, causing memory corruption - * - Fixed USBtoSerial demo receiving noise from the USART due to pull-up not being enabled - * - * - * \section Sec_ChangeLog090605 Version 090605 - * - * - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data - * - Fixed documentation showing incorrect USB mode support on the supported AVRs list - * - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" RNDIS request which was unhandled - * - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman) - * - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues - * - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman) - * - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token - * - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC - * interface is skipped - * - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype - * inside the library that is able to hold their defined value to save space - * - Removed DESCRIPTOR_ADDRESS() macro as it was largely superfluous and only served to obfuscate code - * - Rewritten event system to remove all macros, to make user code clearer - * - Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley) - * - Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code - * - Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code - * - USB_IsConnected is now cleared before the USB_Disconnect() event is fired in response to VBUS being removed - * - Fixed incorrect PID value being used in the USBtoSerial project (thanks to Phill) - * - Deleted StdDescriptors.c, renamed USB_GetDescriptor() to CALLBACK_USB_GetDescriptor, moved ConfigDescriptor.c/.h from the - * LUFA/Drivers/USB/Class/ directory to LUFA/Drivers/USB/HighLevel/ in preparation for the new USB class APIs - * - Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure - * - Removed Tx interrupt from the USBtoSerial demo; now sends characters via polling to ensure more time for the Rx interrupt - * - Fixed possible enumeration errors from spin-loops which may fail to exit if the USB connection is severed before the exit condition - * becomes true - * - * - * \section Sec_ChangeLog090510 Version 090510 - * - * - Added new GenericHIDHost demo - * - Corrections to the KeyboardHost and MouseHost demos' pipe handling to freeze and unfreeze the data pipes at the point of use - * - KeyboardHost, MouseHost and GenericHIDHost demos now save and restore the currently selected pipe inside the pipe ISR - * - Changed GenericHID device demo to use the LUFA scheduler, added INTERRUPT_DATA_ENDPOINT and INTERRUPT_CONTROL_ENDPOINT compile - * time options - * - All comments in the library, bootloaders, demos and projects have now been spell-checked and spelling mistakes/typos corrected - * - Added new PIMA_DATA_SIZE() define to the Still Image Host demo - * - Add call to MassStore_WaitForDataReceived() in MassStore_GetReturnedStatus() to ensure that the CSW has been received in the - * extended MSC timeout period before continuing, to prevent long processing delays from causing the MassStore_GetReturnedStatus() - * to early-abort (thanks to Dmitry Maksimov) - * - Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver directory to the HighLevel USB driver directory, - * where they are more suited - * - Removed all binary constants and replaced with decimal or hexadecimal constants so that unpatched GCC compilers can still build the - * code without having to be itself patched and recompiled first - * - Added preprocessor checks and documentation to the bootloaders giving information about missing SIGNATURE_x defines due to - * outdated avr-libc versions. - * - Added support to the CDCHost demo for devices with multiple CDC interfaces which are not the correct ACM type preceding the desired - * ACM CDC interface - * - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen) - * - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan Oakley) - * - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint - * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to match the CTC calculations in the AVR datasheet, - * and to fix instances where rounding caused the endpoint to underflow (thanks to Robin Theunis) - * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type - * pipes can be used with the function - * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes - * - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev) - * - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favor of new Endpoint_ClearIN(), Endpoint_ClearOUT(), - * Pipe_ClearIN() and Pipe_ClearOUT() macros (done to allow for the detection of packets of zero length) - * - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API - * - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been - * renamed to Endpoint_ClearSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the - * Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe - * bank management API - * - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel from Curetis AG) - * - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity - * - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity - * - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway - * - Renamed the main Drivers/AT90USBXXX directory to Drivers/Peripheral, renamed the Serial_Stream driver to SerialStream - * - Fixed CDC and USBtoSerial demos freezing where buffers were full while still transmitting or receiving (thanks to Peter Hand) - * - Removed "Host_" section of the function names in ConfigDescriptor.h, as most of the routines can now be used in device mode on the - * device descriptor - * - Renamed functions in the HID parser to have a "USB_" prefix and the acronym "HID" in the name - * - Fixed incorrect HID interface class and subclass values in the Mouse and KeyboardMouse demos (thanks to Brian Dickman) - * - Capitalized the "Descriptor_Search" and "Descriptor_Search_Comp" prefixes of the values in the DSearch_Return_ErrorCodes_t and - * DSearch_Comp_Return_ErrorCodes_t enums - * - Removed "ERROR" from the enum names in the endpoint and pipe stream error code enums - * - Renamed the USB_PowerOnErrorCodes_t enum to USB_InitErrorCodes_t, renamed the POWERON_ERROR_NoUSBModeSpecified enum value to - * USB_INITERROR_NoUSBModeSpecified - * - Renamed USB_PowerOnFail event to USB_InitFailure - * - Renamed OTG.h header functions to be more consistent with the rest of the library API - * - Changed over all deprecated GCC structure tag initializers to the standardized C99 format (thanks to Mike Alexander) - * - USB_HostRequest renamed to USB_ControlRequest, entire control request header is now read into USB_ControlRequest in Device mode - * rather than having the library pass only partially read header data to the application - * - The USB_UnhandledControlPacket event has had its parameters removed, in favor of accessing the new USB_ControlRequest structure - * - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent - * - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled) - * - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE - * - Endpoint configuration is now refined to give better output when all configurations have static inputs - removed the now useless - * STATIC_ENDPOINT_CONFIGURATION compile time token - * - Fixed SPI driver init function not clearing SPI2X bit when not needed - * - Fixed PREVENT ALLOW MEDIUM REMOVAL command issuing in the MassStorageHost demo using incorrect parameters (thanks to Mike Alex) - * - Fixed MassStorageHost demo broken due to an incorrect if statement test in MassStore_GetReturnedStatus() - * - Fixed reversed signature byte ordering in the CDC bootloader (thanks to Johannes Raschke) - * - Changed PIPE_CONTROLPIPE_DEFAULT_SIZE from 8 to 64 to try to prevent problems with faulty devices which do not respect the given - * wLength value when reading in the device descriptor - * - Fixed missing semicolon in the ATAVRUSBRF01 LED board driver code (thanks to Morten Lund) - * - Changed LED board driver code to define dummy LED masks for the first four board LEDs, so that user code can be compiled for boards - * with less than four LEDs without code modifications (thanks to Morten Lund) - * - Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button - * - Serial driver now correctly calculates the baud register value when in double speed mode - * - Init function of the Serial driver is now static inline to product smaller code for the common-case of static init values - * - * - * \section Sec_ChangeLog090401 Version 090401 - * - * - Fixed MagStripe project configuration descriptor containing an unused (blank) endpoint descriptor - * - Incorporated makefile changes by Denver Gingerich to retain compatibility with stock (non-WinAVR) AVR-GCC installations - * - Fixed makefile EEPROM programming targets programming FLASH data in addition to EEPROM data - * - LUFA devices now enumerate correctly with LUFA hosts - * - Fixed Configuration Descriptor search routine freezing when a comparator returned a failure - * - Removed HID report item serial dump in the MouseHostWithParser and KeyboardHostWithParser - useful only for debugging, and - * slowed down the enumeration of HID devices too much - * - Increased the number of bits per track which can be read in the MagStripe project to 8192 when compiled for the AT90USBXXX6/7 - * - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request - * - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission - * next time the device is attached to a host. - * - Added new F_USB compile time constant to the library and makefiles, to give the raw input clock (used to feed the PLL before any - * clock prescaling is performed) frequency, so that the PLL prescale mask can be determined - * - Changed stream wait timeout counter to be 16-bit, so that very long timeout periods can be set for correct communications with - * badly designed hosts or devices which greatly exceed the USB specification limits - * - Mass Storage Host demo now uses a USB_STREAM_TIMEOUT_MS of two seconds to maintain compatibility with poorly designed devices - * - Function attribute ATTR_ALWAYSINLINE renamed to ATTR_ALWAYS_INLINE to match other function attribute macro naming conventions - * - Added ATTR_ALWAYS_INLINE attribute to several key inlined library components, to ensure they are inlined in all circumstances - * - Removed SetSystemClockPrescaler() macro, the clock_prescale_set() avr-libc macro has been corrected in recent avr-libc versions - * - Fixed incorrect/missing control status stage transfers on demos, bootloaders and applications (thanks to Nate Lawson) - * - The NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded - * to also remove parts of the Get Status chapter 9 request to further reduce code usage - * - Makefile updated to include output giving the currently selected BOARD parameter value - * - Board Dataflash driver now allows for dataflash ICs which use different shifts for setting the current page/byte address (thanks - * to Kenneth Clubb) - * - Added DataflashManager_WriteBlocks_RAM() and DataflashManager_ReadBlocks_RAM() functions to the MassStorage demo, to allow for easy - * interfacing with a FAT library for dataflash file level access - * - Corrected CDC class bootloader to fix a few bugs, changed address counter to store x2 addresses for convenience - * - Fixed typos in the SPI driver SPI_SPEED_FCPU_DIV_64 and SPI_SPEED_FCPU_DIV_128 masks (thanks to Markus Zocholl) - * - Keyboard and Mouse device demos (normal, data interrupt and fully interrupt driven) combined into unified keyboard and mouse demos - * - Keyboard and Mouse host demos (normal and data interrupt driven) combined into unified keyboard and mouse demos - * - Removed AVRISP_Programmer project due to code quality concerns - * - Fixed CDC demo not sending an empty packet after each transfer to prevent the host from buffering incoming data - * - Fixed documentation typos and preprocessor checks relating to misspellings of the USE_RAM_DESCRIPTORS token (thanks to Ian Gregg) - * - Fixed USBTask.h not conditionally including HostChapter9.h only when USB_CAN_BE_HOST is defined (thanks to Ian Gregg) - * - Fixed incorrect ADC driver init register manipulation (thanks to Tobias) - * - Added new GenericHID device demo application - * - Fixed Still Image Host SImage_SendData() function not clearing the pipe bank after sending data - * - * - * \section Sec_ChangeLog090209 Version 090209 - * - * - PWM timer mode in AudioOut demo changed to Fast PWM for speed - * - Updated Magstripe project to work with the latest hardware revision - * - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups - * - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface (thanks to - * Nate Lawson) - * - Fixed serious data corruption issue in MassStorage demo dataflash write routine - * - Added new NO_CLEARSET_FEATURE_REQUEST compile time token - * - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled - * - Fixed USB_DeviceEnumerationComplete event firing after each configuration change, rather than once after the initial configuration - * - Added ENDPOINT_DOUBLEBANK_SUPPORTED() macros to Endpoint.h, altered ENDPOINT_MAX_SIZE() to allow user to specify endpoint - * - ENDPOINT_MAX_ENDPOINTS changed to ENDPOINT_TOTAL_ENDPOINTS, PIPE_MAX_PIPES changed to PIPE_TOTAL_PIPES - * - Endpoint and Pipe non-control stream functions now ensure endpoint or pipe is ready before reading or writing - * - Changed Teensy bootloader to use a watchdog reset when exiting rather than a software jump - * - Fixed integer promotion error in MassStorage and MassStorageHost demos, corrupting read/write transfers - * - SPI_SendByte is now SPI_TransferByte, added new SPI_SendByte and SPI_ReceiveByte functions for fast one-way transfer - * - MassStorage demo changed to use new fast one-way SPI transfers to increase throughput - * - MassStorage handling of Mass Storage Reset class request improved - * - Altered MassStorage demo dataflash block read code for speed - * - Added USB_IsSuspended global flag - * - Simplified internal Dual Mode (OTG) USB library code to reduce code size - * - Extended stream timeout period to 100ms from 50ms - * - Mass Storage Host demo commands now all return an error code from the Pipe_Stream_RW_ErrorCodes_t enum - * - Added SubErrorCode parameter to the USB_DeviceEnumerationFailed event - * - VBUS drop interrupt now disabled during the manual-to-auto VBUS delivery handoff - * - Simplified low level backend so that device/host mode initialization uses the same code paths - * - Added workaround for faulty Mass Storage devices which do not implement the required GET_MAX_LUN request - * - Removed buggy Telnet application from the RNDIS demo - * - Moved Mass Storage class requests in the Mass Storage Host demo to wrapper functions in MassStoreCommands.c - * - Fixed incorrect SCSI command size value in the Request Sense command in MassStoreCommands.c - * - Added SetProtocol request to HID class non-parser Mouse and Keyboard demos to force devices to use the correct Boot Protocol - * - Added new "dfu" and "flip" programming targets to project makefiles - * - HID_PARSE_Sucessful enum member typo corrected to HID_PARSE_Successful - * - Changed COLLECTION item structures in the HID descriptor parser to include the collection's Usage Page value - * - Serial driver now sets Tx line as output, enables pull-up on Rx line - * - Fixed smaller USB AVRs raising multiple connection and disconnection events when NO_LIMITED_CONTROLLER_CONNECT is disabled - * - Added HOST_DEVICE_SETTLE_DELAY_MS to give the host delay after a device is connected before it is enumerated - * - Fixed KeyboardHostWithParser demo linking against the wrong global variables - * - Completed doxygen documentation of remaining library bootloaders, demos and projects - * - Fixed incorrect bootloader start address in the TeensyHID bootloader - * - Added HWB button whole-disk ASCII dump functionality to MassStoreHost demo - * - Replaced printf_P(PSTR("%c"), {Variable}) calls with putchar() for speed and size savings - * - Serial driver now accepts baud rates over 16-bits in size, added double speed flag option - * - Fixed incorrect callback abort return value in Pipe.c - * - Added new flip-ee and dfu-ee makefile targets (courtesy of Opendous Inc.) - * - Removed reboot-on-disconnect code from the TeensyHID bootloader, caused problems on some systems - * - Fixed AudioOutput and AudioInput demos looping on the endpoint data, rather than processing a sample at a time and returning - * each time the task runs to allow for other tasks to execute - * - Added support for the Atmel ATAVRUSBRF01 board - * - Added AVRISP Programmer Project, courtesy of Opendous Inc. - * - Fixed CDC Host demo not searching through both CDC interfaces for endpoints - * - Fixed incorrect Product String descriptor length in the DFU class bootloader - * - * - * \section Sec_ChangeLog081224 Version 081224 - * - * - MyUSB name changed to LUFA, the Lightweight USB Framework for AVRs - * - Fixed Mass Storage Host demo's MassStore_SendCommand() delay in the incorrect place - * - Fixed USBtoSerial demo not calling ReconfigureUSART() after a change in the line encoding - * - Fixed infinite loop in host mode Host-to-Device control transfers with data stages - * - HID report parser now supports devices with multiple reports in one interface via Report IDs - * - Fixed RZUSBSTICK board LED driver header incorrect macro definition order causing compile errors - * - Calling USB_Init() when the USB interface is already configured now forces a complete interface reset - * and re-enumeration - fixes MyUSB DFU bootloader not switching to app code correctly when soft reset used - * - Fixed "No newline at end of file" warning when stream callbacks are enabled - * - DFU bootloader now uses fixed signature bytes per device, rather than reading them out dynamically for size - * - Added new FIXED_CONTROL_ENDPOINT_SIZE and USE_SINGLE_DEVICE_CONFIGURATION switches to statically define certain values to - * reduce compiled binary size - * - Added new NO_LIMITED_CONTROLLER_CONNECT switch to prevent the library from trying to determine bus connection - * state from the suspension and wake up events on the smaller USB AVRs - * - Added summary of all library compile time tokens to the documentation - * - Added overview of the LUFA scheduler to the documentation - * - Removed MANUAL_PLL_CONTROL compile time token, replaced with a mask for the USB_Init() Options parameter - * - CDC bootloader now uses the correct non-far or far versions of the pgm_* functions depending on if RAMPZ is defined - * - Doxygen documentation now contains documentation on all the projects, bootloaders and most demos included with the library - * - CDC bootloader now runs user application when USB disconnected rather than waiting for a hard reset - * - MouseHostWithParser and KeyboardHostWithParser now support multiple-report devices - * - RNDIS demo can now close connections correctly using the new TCP_APP_CLOSECONNECTION() macro - used in Webserver - * - Fixed the DFU bootloader, no longer freezes up when certain files are programmed into an AVR, made reading/writing faster - * - Fixed mouse/joystick up/down movements reversed - HID mouse X/Y coordinates use a left-handed coordinate system, not a normal - * right-handed system - * - Added stub code to the CDC and USBtoSerial demos showing how to read and set the RS-232 handshake lines - not currently used in - * the demos, but the example code and supporting defines are now in place - * - Interrupts are now disabled when processing a control request in device mode, to avoid exceeding the strict control request - * timing requirements. - * - All demos now use a central StatusUpdate() function rather than direct calls to the board LED functions, so that the demos can - * easily be altered to show different LED combinations (or do something else entirely) as the demo's status changes - * - Removed LED commands from the CDC bootloader, unused by most AVR910 programming software - * - Fixed RNDIS demo ICMP ping requests echoing back incorrect data - * - Added DHCP server code to RNDIS demo, allowing for hands-free auto configuration on any PC - * - Fixed DFU bootloader PID value for the ATMEGA16U4 AVR - * - Endpoint and Pipe configuration functions now return an error code indicating success or failure - * - USB Reset in device mode now resets and disables all device endpoints - * - Added intermediate states to the host mode state machine, reducing the USB task blocking time to no more than 1ms explicitly per - * invocation when in host mode - * - Added support for the ATMEGA32U6 microcontroller - * - Added STATIC_ENDPOINT_CONFIGURATION compile time option, enabled in the bootloaders to minimize space usage - * - Removed redundant code from the USB device GetStatus() chapter 9 processing routine - * - Added new TeensyHID bootloader, compatible with the Teensy HID protocol (http://www.pjrc.com/teensy/) - * - Versions are now numbered by release dates, rather than arbitrary major/minor revision numbers - * - USB_RemoteWakeupEnabled is now correctly set and cleared by SetFeature and ClearFeature requests from the host - * - Changed prototype of GetDescriptor, so that it now returns the descriptor size (or zero if the descriptor doesn't exist) - * rather than passing the size back to the caller through a parameter and returning a boolean - * - * - * \section Sec_ChangeLog153 Version 1.5.3 - Released 2nd October, 2008 - * - * - Fixed CDC bootloader using pgmspace macros for some descriptors inappropriately - * - Updated all Mouse and Keyboard device demos to include boot protocol support (now works in BIOS) - * - Renamed bootloader directories to remove spaces, which were causing build problems on several OSes - * - Removed serial number strings from all but the MassStore demo where it is required - users were not - * modifying the code to either omit the descriptor or use a unique serial per device causing problems - * when multiple units of the same device were plugged in at the same time - * - AudioOutput and AudioInput demos now correctly silence endpoints when not enabled by the host - * - Added KeyboardMouse demo (Keyboard and Mouse functionality combined into a single demo) - * - Added DriverStubs directory to house board level driver templates, to make MyUSB compatible custom board - * driver creation easier - * - Extended MassStorage demo to support multiple LUNs, 2 by default - * - Fixed incorrect device address mask, preventing the device from enumerating with addresses larger than 63 - * - Fixed incorrect data direction mask in the GetStatus standard request, preventing it from being handled - * - Fixed incorrect GetStatus standard request for endpoints, now returns the endpoint STALL status correctly - * - Added in new USB_RemoteWakeupEnabled and USB_CurrentlySelfPowered flags rather than using fixed values - * - Added DualCDC demo to demonstrate the use of Interface Association Descriptors - * - Added pipe NAK detection and clearing API - * - Added pipe status change (NAK, STALL, etc.) interrupt API - * - Fixed MassStorageHost demo so that it no longer freezes randomly when issuing several commands in a row - * - Host demos configuration descriptor routines now return a unique error code when the returned data does - * not have a valid configuration descriptor header - * - Added Endpoint_WaitUntilReady() and Pipe_WaitUntilReady() functions - * - Stream functions now have software timeouts, timeout period can be set by the USB_STREAM_TIMEOUT_MS token - * - All demos now pass the USB.org automated Chapter 9 device compliance tests - * - All HID demos now pass the USB.org automated HID compliance tests - * - Polling interval of the interrupt endpoint in the CDC based demos changed to 0xFF to fix problems on Linux systems - * - Changed stream functions to accept a new callback function, with NO_STREAM_CALLBACKS used to disable all callbacks - * - Mass Storage demo dataflash management routines changed to use the endpoint stream functions - * - Added AVRStudio project files for each demo in addition to the existing Programmer's Notepad master project file - * - Re-added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes - * are reflected in the hardware (change was previously lost) - * - * - * \section Sec_ChangeLog152 Version 1.5.2 - Released 31st July, 2008 - * - * - Fixed SwapEndian_32() function in Common.h so that it now works correctly (wrong parameter types) - * - Updated RNDIS demo - notification endpoint is no longer blocking so that it works with faulty Linux RNDIS - * implementations (where the notification endpoint is ignored in favor of polling the control endpoint) - * - Fixed incorrect Vendor Description string return size in RNDIS demo for the OID_GEN_VENDOR_DESCRIPTION OID token - * - Added very basic TCP/IP stack and HTTP/TELNET servers to RNDIS demo - * - Fixed DFU bootloader exit causing programming software to complain about failed writes - * - Fixed DFU bootloader EEPROM programming mode wiping first flash page - * - Fixed Clear/Set Feature device standard request processing code (fixing MassStorage demo in the process) - * - Added support for the ATMEGA16U4 AVR microcontroller - * - Library license changed from LGPLv3 to MIT license - * - * - * \section Sec_ChangeLog151 Version 1.5.1 - Released 7th July, 2008 - * - * - Changed host demos to enable the host function task on the firing of the USB_DeviceEnumerationComplete event - * rather than the USB_DeviceAttached event - * - HID Usage Stack now forcefully cleared after an IN/OUT/FEATURE item has been completely processed to remove - * any referenced but not created usages - * - Changed USB_INT_DisableAllInterrupts() and USB_INT_ClearAllInterrupts(), USB_Host_GetNextDescriptorOfType(), - * USB_Host_GetNextDescriptorOfTypeBefore(), USB_Host_GetNextDescriptorOfTypeAfter() to normal functions (from inline) - * - Fixed USBtoSerial demo not sending data, only receiving - * - Fixed main makefile to make all by default, fixed MagStripe directory case to prevent case-sensitive path problems - * - ConfigDescriptor functions made normal, instead of static inline - * - Pipe/Endpoint *_Ignore_* functions changed to *_Discard_*, old names still present as aliases - * - Fixed ENDPOINT_MAX_SIZE define to be correct on limited USB controller AVRs - * - Changed endpoint and pipe size translation routines to use previous IF/ELSE IF cascade code, new algorithmic - * approach was buggy and caused problems - * - Bootloaders now compile with -fno-inline-small-functions option to reduce code size - * - Audio demos now use correct endpoint sizes for full and limited controller USB AVRs, double banking in all cases - * to be in line with the specification (isochronous endpoints MUST be double banked) - * - Added Interface Association descriptor to StdDescriptors.h, based on the relevant USB2.0 ECN - * - Fixed MIDI demo, corrected Audio Streaming descriptor to follow the MIDI-specific AS structure - * - Fixed HID class demo descriptors so that the HID interface's protocol is 0x00 (required for non-boot protocol HID - * devices) to prevent problems on hosts expecting the boot protocol functions to be supported - * - Added read/write control stream functions to Endpoint.h - * - Fixed AudioOut demo not setting port pins to inputs on USB disconnect properly - * - Added RNDISEthernet demo application - * - * - * \section Sec_ChangeLog150 Version 1.5.0 - Released 10 June, 2008 - * - * - Fixed MIDI demo, now correctly waits for the endpoint to be ready between multiple note messages - * - Added CDC Host demo application - * - Added KeyboardFullInt demo application - * - Endpoint and Pipe creation routines now mask endpoint/pipe size with the size mask, to remove transaction - * size bits not required for the routines (improves compatibility with devices) - * - Fixed AudioInput demo - now correctly sends sampled audio to the host PC - * - Fixed AudioOutput demo once more -- apparently Windows requires endpoint packets to be >=192 bytes - * - Shrunk round-robbin scheduler code slightly via the use of struct pointers rather than array indexes - * - Fixed off-by-one error when determining if the Usage Stack is full inside the HID Report parser - * - Renamed Magstripe.h to MagstripeHW.h and moved driver out of the library and into the MagStripe demo folder - * - Added preprocessor checks to enable C linkage on the library components when used with a C++ compiler - * - Added Still Image Host demo application - * - The USB device task now restores the previously selected endpoint, allowing control requests to be transparently - * handled via interrupts while other endpoints are serviced through polling - * - Fixed device signature being sent in reverse order in the CDC bootloader - * - Host demos now have a separate ConfigDescriptor.c/.h file for configuration descriptor processing - * - HostWithParser demos now have a separate HIDReport.c/.h file for HID report processing and dumping - * - Removed non-mandatory commands from MassStorage demo to save space, fixed SENSE ResponseCode value - * - CDC demos now send empty packets after sending a full one to prevent buffering issues on the host - * - Updated demo descriptors to use VID/PID values donated by Atmel - * - Added DoxyGen documentation to the source files - * - Fixed Serial_IsCharReceived() definition, was previously reversed - * - Removed separate USB_Descriptor_Language_t descriptor, USB_Descriptor_String_t is used instead - * - Removed unused Device Qualifier descriptor structure - * - Renamed the USB_CreateEndpoints event to the more appropriate USB_ConfigurationChanged - * - Fixed MassStorageHost demo reading in the block data in reverse - * - Removed outdated typedefs in StdRequestType.h, superseded by the macro masks - * - Corrected OTG.h is now included when the AVR supports both Host and Device modes, for creating OTG products - * - USB_DeviceEnumerationComplete event is now also fired when in device mode and the host has finished its enumeration - * - Interrupt driven demos now properly restore previously selected endpoint when ISR is complete - * - The value of USB_HOST_TIMEOUT_MS can now be overridden in the user project makefile to a custom fixed timeout value - * - Renamed USB_Host_SOFGeneration_* macros to more friendly USB_Host_SuspendBus(), USB_Host_ResumeBus() - * and USB_Host_IsBusSuspended() - * - Renamed *_*_Is* macros to *_Is* to make all flag checking macros consistent, Pipe_SetInterruptFreq() is now - * Pipe_SetInterruptPeriod() to use the correct terminology - * - UnicodeString member of USB_Descriptor_String_t struct changed to an ordinary int array type, so that the GCC - * Unicode strings (prefixed with an L before the opening quotation mark) can be used instead of explicit arrays - * of ASCII characters - * - Fixed Endpoint/Pipes being configured incorrectly if the maximum endpoint/pipe size for the selected USB AVR - * model was given as the bank size - * - HID device demos now use a true raw array for the HID report descriptor rather than a struct wrapped array - * - Added VERSION_BCD() macro, fixed reported HID and USB version numbers in demo descriptors - * - Cleaned up GetDescriptor device chapter 9 handler function - * - Added GET_REPORT class specific request to HID demos to make them complaint to the HID class - * - Cleaned up setting of USB_IsInitialized and USB_IsConnected values to only when needed - * - Removed Atomic.c and ISRMacro.h; the library was already only compatible with recent avr-lib-c for other reasons - * - All demos and library functions now use USB standardized names for the USB data (bRequest, wLength, etc.) - * - Added USE_NONSTANDARD_DESCRIPTOR_NAMES token to switch back to the non-standard descriptor element names - * - * - * \section Sec_ChangeLog141 Version 1.4.1 - Released 19 May, 2008 - * - * - Enhanced KeyboardWithParser demo, now prints out pressed alphanumeric characters like the standard demo - * - Fixed MassStorage demo, read/writes using non mode-10 commands now work correctly - * - Corrected version number in Version.h - * - * - * \section Sec_ChangeLog140 Version 1.4.0 - Released 5 May, 2008 - * - * - Added HID Report Parser API to the library - * - Added Mouse and Keyboard host demo applications, using the new HID report parser engine - * - Added MouseFullInt demo, which demonstrates a fully interrupt (including control requests) mouse device - * - Fixed incorrect length value in the audio control descriptor of the AudioOutput and AudioInput demos - * - Added MIDI device demo application to the library - * - Fixed problem preventing USB devices from being resumed from a suspended state - * - Added new CDC class bootloader to the library, based on the AVR109 bootloader protocol - * - Added header to each demo application indicating the mode, class, subclass, standards used and supported speed - * - Functions expecting endpoint/pipe numbers are no longer automatically masked against ENDPOINT_EPNUM_MASK or - * PIPE_PIPENUM_MASK - this should be manually added to code which requires it - * - Fixed DFU class bootloader - corrected frequency of flash page writes, greatly reducing programming time - * - Renamed AVR_HOST_GetDeviceConfigDescriptor() to USB_Host_GetDeviceConfigDescriptor() and AVR_HOST_GetNextDescriptor() - * to USB_Host_GetNextDescriptor() - * - Added new USB_Host_GetNextDescriptorOfTypeBefore() and USB_Host_GetNextDescriptorOfTypeAfter() routines - * - Moved configuration descriptor routines to MyUSB/Drivers/USB/Class/, new accompanying ConfigDescriptors.c file - * - Added new configuration descriptor comparator API for more powerful descriptor parsing, updated host demos to use the - * new comparator API - * - Fixed MassStorageHost demo capacity printout, and changed data read/write mode from little-endian to the correct - * big-endian for SCSI devices - * - Fixed macro/function naming consistency; USB_HOST is now USB_Host, USB_DEV is now USB_Device - * - Added better error reporting to host demos - * - Added 10 microsecond delay after addressing devices in host mode, to prevent control stalls - * - * - * \section Sec_ChangeLog132 Version 1.3.2 - Released April 1st, 2008 - * - * - Added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes - * are reflected in the hardware - * - Fixed CDC and USBtoSerial demos - Stream commands do not work for control endpoints, and the - * GetLineCoding request had an incorrect RequestType mask preventing it from being processed - * - Improved reliability of the USBtoSerial demo, adding a busy wait while the buffer is full - * - Device control endpoint size is now determined from the device's descriptors rather than being fixed - * - Separated out SPI code into new SPI driver in AT90USBXXX driver directory - * - Bootloader now returns correct PID for the selected USB AVR model, not just the AT90USB128X PID - * - Added support for the RZUSBSTICK board - * - Bicolour driver removed in favor of generic LEDs driver - * - Added support for the ATMEGA32U4 AVR - * - Added MANUAL_PLL_CONTROL compile time option to prevent the USB library from manipulating the PLL - * - * - * \section Sec_ChangeLog131 Version 1.3.1 - Released March 19th 2008 - * - * - Fixed USB to Serial demo - class value in the descriptors was incorrect - * - Control endpoint size changed from 64 bytes to 8 bytes to save on USB FIFO RAM and to allow low - * speed mode devices to enumerate properly - * - USB to Serial demo data endpoints changed to dual-banked 16 byte to allow the demo to work - * on USB AVRs with limited USB FIFO RAM - * - Changed demo endpoint numbers to use endpoints 3 and 4 for double banking, to allow limited - * USB device controller AVRs (AT90USB162, AT90USB82) to function correctly - * - Updated Audio Out demo to use timer 1 for AVRs lacking a timer 3 for the PWM output - * - Fixed incorrect USB_DEV_OPT_HIGHSPEED entry in the Mass Storage device demo makefile - * - Optimized Mass Storage demo for a little extra transfer speed - * - Added LED indicators to the Keyboard demo for Caps Lock, Num Lock and Scroll Lock - * - Added Endpoint_Read_Stream, Endpoint_Write_Stream, Pipe_Read_Stream and Pipe_Write_Stream functions - * (including Big and Little Endian variants) - * - Made Dataflash functions inline for speed, removed now empty Dataflash.c driver file - * - Added new SetSystemClockPrescaler() macro (thanks to Joerg Wunsch) - * - Fixed Endpoint_ClearStall() to function correctly on full USB controller AVRs (AT90USBXXX6/7) - * - Endpoint_Setup_In_Clear() and Endpoint_Setup_Out_Clear() no longer set FIFOCON, in line with the - * directives in the datasheet - * - Fixed PLL prescaler defines for all AVR models and frequencies - * - Fixed ENDPOINT_INT_IN and ENDPOINT_INT_OUT definitions - * - Added interrupt driven keyboard and mouse device demos - * - Combined USB_Device_ClearFeature and USB_Device_SetFeature requests into a single routine for code - * size savings - * - Added missing Pipe_GetCurrentPipe() macro to Pipe.h - * - * - * \section Sec_ChangeLog130 Version 1.3.0 - Released March 7th 2008 - * - * - Unnecessary control endpoint config removed from device mode - * - Fixed device standard request interpreter accidentally processing some class-specific requests - * - Added USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS compile time options to instruct the library - * to use descriptors stored in RAM or EEPROM rather than flash memory - * - All demos now disable watchdog on startup, in case it has been enabled by fuses or the bootloader - * - USB_DEV_OPT_LOWSPEED option now works correctly - * - Added ability to set the USB options statically for a binary size reduction via the USE_STATIC_OPTIONS - * compile time define - * - USB_Init no longer takes a Mode parameter if compiled for a USB device with no host mode option, or - * if forced to a particular mode via the USB_HOST_ONLY or USB_DEVICE_ONLY compile time options - * - USB_Init no longer takes an Options parameter if options statically configured by USE_STATIC_OPTIONS - * - Endpoint_Ignore_* and Pipe_Ignore_* made smaller by making the dummy variable non-volatile so that the - * compiler can throw away the result more efficiently - * - Added in an optional GroupID value to each scheduler entry, so that groups of tasks can once again be - * controlled by the new Scheduler_SetGroupTaskMode() routine - * - Added support for AT90USB162 and AT90USB82 AVR models - * - Added support for the STK525 and STK526 boards - * - Added support for custom board drivers to be supplied by selecting the board type as BOARD_USER, and - * placing board drivers in {Application Directory}/Board/ - * - PLL is now stopped and USB clock is frozen when detached from host in device mode, to save power - * - Joystick defines are now in synch with the schematics - orientation will be rotated for the USBKEY - * - Fixed USB_DEV_IsUSBSuspended() - now checks the correct register - * - Fixed data transfers to devices when in host mode - * - Renamed USB_DEV_OPT_HIGHSPEED to USB_DEV_OPT_FULLSPEED and USB_HOST_IsDeviceHighSpeed() to - * USB_HOST_IsDeviceFullSpeed() to be in line with the official USB speed names (to avoid confusion with - * the real high speed mode, which is unavailable on the USB AVRs) - * - * - * \section Sec_ChangeLog120 Version 1.2.0 - Released February 4th, 2008 - * - * - Added USB_DeviceEnumerationComplete event for host mode - * - Added new Scheduler_Init routine to prepare the scheduler, so that tasks can be started and - * stopped before the scheduler has been started (via Scheduler_Start) - * - Connection events in both Device and Host mode are now interrupt-driven, allowing the USB management - * task to be stopped when the USB is not connected to a host or device - * - All demos updated to stop the USB task when not in use via the appropriate USB events - * - Mass Storage Host demo application updated to function correctly with all USB flash disks - * - Mass Storage Host demo application now prints out the capacity and number of LUNs in the attached - * device, and prints the first block as hexadecimal numbers rather than ASCII characters - * - Endpoint and Pipe clearing routines now clear the Endpoint/Pipe interrupt and status flags - * - Shifted error handling code in the host enum state machine to a single block, to reduce code complexity - * - Added in DESCRIPTOR_TYPE, DESCRIPTOR_SIZE and DESCRIPTOR_CAST macros to make config descriptor processing - * clearer in USB hosts and DESCRIPTOR_ADDRESS for convenience in USB devices - * - Added in alloca macro to common.h, in case the user is using an old version of avr-lib-c missing the macro - * - * - * \section Sec_ChangeLog130 Version 1.1.0 - Released January 25th 2008 - * - * - Fixed DCONNI interrupt being enabled accidentally after a USB reset - * - Fixed DDISCI interrupt not being disabled when a device is not connected - * - Added workaround for powerless pull-up devices causing false disconnect interrupts - * - Added USB_DeviceEnumerationFailed event for Host mode - * - AVR_HOST_GetDeviceConfigDescriptor routine no longer modifies ConfigSizePtr if a valid buffer - * pointer is passed - * - Added ALLOCABLE_BYTES to DynAlloc, and added code to make the size of key storage variables - * dependant on size of memory parameters passed in via the user project's makefile - * - Fixed incorrect device reset routine being called in USBTask - * - Devices which do not connect within the standard 300mS are now supported - * - Removed incorrect ATTR_PURE from Scheduler_SetTaskMode(), which was preventing tasks from being - * started/stopped, as well as USB_InitTaskPointer(), which was breaking dual device/host USB projects - * - Changed scheduler to use the task name rather than IDs for setting the task mode, eliminating the - * need to have a task ID list - * - ID transition interrupt now raises the appropriate device/host disconnect event if device attached - * - Fixed double VBUS change (and VBUS -) event when detaching in device mode - * - Added ability to disable ANSI terminal codes by the defining of DISABLE_TERMINAL_CODES in makefile - * - Removed return from ConfigurePipe and ConfigureEndpoint functions - use Pipe_IsConfigured() and - * Endpoint_IsConfigured() after calling the config functions to determine success - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + + /** \page Page_ChangeLog Project Changelog + * + * \section Sec_ChangeLog120219 Version 120219 + * New: + * - Core: + * - Added support for the XMEGA A3BU Xplained board + * - Added support for the new B series XMEGA devices + * - Added support for version 2 of the Teensy boards (thanks to Christoph Redecker) + * - Added support for the USB2AX boards, hardware revision 1-3 + * - Added new Android Accessory Host class driver + * - Added new USB_Host_GetDescriptor(), USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions + * - Added new CALLBACK_Audio_Device_GetSetInterfaceProperty() callback to the Audio Device Class driver + * - Added new LEDs_Disable(), Buttons_Disable() and Joystick_Disable() functions to the board hardware drivers + * - Added support for the Micropendous family of boards (Arduino-like revisions 1 and 2, DIP, 32U2, A, 1, 2, 3 and 4) + * - Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.) + * - Added support for the Atmel XMEGA B1 Xplained board + * - Added Serial USART peripheral driver for the XMEGA architecture + * - Added Master Mode SPI USART peripheral driver for the XMEGA and AVR8 architectures + * - Added build test to verify correct compilation of as many modules as possible under as many architectures as possible under the C and C++ languages + * - Added build test to verify correct compilation of the USB driver when forced into single USB mode under as many architectures as possible + * - Library Applications: + * - Added User Application APIs to the CDC and DFU class bootloaders + * - Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs) + * - Added new Android Accessory Host demo (thanks to Opendous Inc.) + * + * Changed: + * - Core: + * - When automatic PLL management mode is enabled on the U4 series AVR8 chips, the PLL is now configured for 48MHz and not + * a divided 96MHz, to lower power consumption and to keep the system within the datasheet specs for 3.3V operation (thanks to Scott Vitale) + * - Added Class, ClassDevice, ClassHost and ClassCommon to the internal class driver source filenames to prevent ambiguities + * - Altered the Mass Storage Host class driver so that SCSI data STALLs from the attached device can be recovered from automatically without + * having to reset the Mass Storage interface + * - USB_CONFIG_ATTR_BUSPOWERED constant renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed (thanks to NXP Semiconductors) + * - Reordered board name definition indexes so that a mispelled BOARD compile option will default to BOARD_USER rather than BOARD_USBKEY + * - Altered the HID class driver to only try to construct at maximum one packet per USB frame, to reduce CPU usage + * - All USB Class Driver configuration struct values are now non-const, to allow for run-time modifications if required before configuring an instance + * - Library Applications: + * - Altered the Mass Storage Host LowLevel demo so that SCSI data STALLs from the attached device can be recovered from automatically without + * having to reset the Mass Storage interface + * - Updated the AVRISP-MKII Clone programmer project to be compatible with the latest version of AVR Studio (version 5.1) + * - Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent + * warnings in AVR Studio 5.1 when programming XMEGA devices + * - Allow serial strings to be generated on the older AVR8 devices which do not explicitly state they contain unique values in the datasheet, + * as this appears to be implemented in hardware + * + * Fixed: + * - Core: + * - Fixed ring buffer size limited to 255 elements, instead of the intended 65535 elements. + * - Fixed CDC class drivers not saving and sending all 16-bits of the control line states (thanks to Matthew Swabey) + * - Fixed race conditions in the CDC, HID and Mass Storage class drivers when processing some control requests + * - Fixed misspelled HID_KEYBOARD_MODIFIER_* macros in the HID class driver (thanks to Laszlo Monda) + * - Fixed broken AVR32 endpoint/pipe communications when ORDERED_EP_CONFIG compile time option is not enabled (thanks to Matthias Jahr) + * - Fixed broken compilation for the AVR32 devices if the NO_SOF_EVENTS compile time option was not enabled (thanks to Matthias Jahr) + * - Fixed compiler warning on GCC with \c -wundef compile flag is used (thanks to Georg Glock) + * - Fixed incorrect implementation of LEDs_ToggleLEDs() for the Adafruit-U4 board (thanks to Caroline Saliman) + * - Fixed broken compilation of LUFA under C++ compilers when the Serial peripheral module header file is included in a C++ source file + * - Fixed missing semicolon in the UC3 architecture host pipe functions + * - Fixed failed compilation for the XMEGA architecture if USB_DEVICE_ONLY us not specified + * - Fixed UC3 architecture ignoring the pipe size when Pipe_ConfigurePipe() is called + * - Library Applications: + * - Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair) + * - Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled + * - Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming session is exited + * - Fixed DFU class bootloader not resetting the LED pins as high impedance inputs when a software jump to the user applications is requested + * - Fixed AVRISP-MKII Clone timing out on long programming commands such as programming the EEPROM on an ATMEGA8 (thanks to Martin Kelling) + * - Fixed invalid PID value used in the TempDataLogger project host application (thanks to Anupam Pathak) + * + * \section Sec_ChangeLog111009 Version 111009 + * New: + * - Core: + * - Added USE_LUFA_CONFIG_HEADER compile time option to include a LUFAConfig.h header in the user director for LUFA configuration + * tokens as an alternative to tokens defined in the project makefile + * - Added new USB_Host_SetInterfaceAltSetting() convenience function for the selection of an interface's alternative setting + * - Added Audio class control request definitions + * - Added new CALLBACK_Audio_Device_GetSetEndpointProperty() callback to the Audio Device Class driver to allow for endpoint control manipulations + * such as data sample rates + * - Added support for the Audio class GET STATUS request in the Audio Device Class driver so that it is correctly ACKed when sent by the host + * - Added new EVENT_Audio_Device_StreamStartStop() event to the Audio Device Class driver to detect stream start/stop events + * - Added board driver support for the Busware TUL board + * - Added board hardware driver support for the EVK1100 board + * - Added board hardware driver support for the EVK1104 board + * - Added new Host mode Audio Class driver + * - Added new SPI_GetCurrentMode() function to the SPI peripheral driver + * - Added RingBuffer_GetFreeCount() function to the Ring Buffer driver + * - Added new HID_Host_SetIdlePeriod() function to the HID Host Class driver + * - Added new USB_Host_ConfigurationNumber global variable to indicate the selected configuration in an attached device + * - Added new USB_Host_GetDeviceStatus() function to the host standard request function set + * - Added AVR USB XMEGA architecture port (currently incomplete/experimental) + * - Added new STRINGIFY() and STRINGIFY_EXPANDED() convenience macros + * - Added new JTAG_DISABLE() macro for the AVR8 architecture + * - Added Device Qualifier standard descriptor structure definitions USB_StdDescriptor_DeviceQualifier_t and USB_Descriptor_DeviceQualifier_t + * - Library Applications: + * - Added RNDIS device mode to the Webserver project + * - Added new incomplete AndroidAccessoryHost Host LowLevel demo + * - Added new HIDReportViewer project + * - Added new MediaControl project + * - Added new AudioInputHost Host ClassDriver demo + * - Added new AudioOutputHost Host ClassDriver demo + * - Added new AudioInputHost Host LowLevel demo + * - Added new AudioOutputHost Host LowLevel demo + * - Added new "checksource" target to all library project makefiles + * - Added new VTARGET_USE_INTERNAL_REF configuration option to the AVRISP-MKII clone project (thanks to Volker Bosch) + * + * Changed: + * - Core: + * - Altered the definition of the USB_Audio_Descriptor_Format_t descriptor so that the user is now responsible for supplying + * the supported audio sampling rates, to allow for multiple audio interfaces with different numbers of supported rates and/or + * continuous sample rates + * - Pipe_BoundEndpointNumber() has been renamed to Pipe_GetBoundEndpointAddress(), and now returns the correct endpoint direction + * as part of the endpoint address + * - Renamed global state variables that are specific to a certain USB mode to clearly indicate which mode the variable relates to, + * by changing the USB_* prefix to USB_Device_* or USB_Host_* + * - Removed the HOST_STATE_WaitForDeviceRemoval and HOST_STATE_Suspended host state machine states, as these are no longer required + * - Altered the USB_Host_SetDeviceConfiguration() function to update the global Host state machine state and the new + * USB_Host_ConfigurationNumber global as required + * - Added endian correcting code to the library USB class drivers for multiple architecture support + * - Removed the ENDPOINT_DESCRIPTOR_DIR_* macros, replaced by ENDPOINT_DIR_* instead + * - Renamed the JTAG_DEBUG_ASSERT() macro to JTAG_ASSERT() + * - Added variable number of axis to HID_DESCRIPTOR_JOYSTICK() for multi-axis joysticks above just X and Y + * - Renamed USB_Host_ClearPipeStall() to USB_Host_ClearEndpointStall() as the function works on an endpoint address within the attached device, + * and not a Pipe within the host + * - The MS_Host_ResetMSInterface() now performs a full Mass Storage reset sequence to prevent data corruption in the event of a device + * lock up or timeout (thanks to David Lyons) + * - Added endian-correction to the CDC driver's Line Encoding control request handlers. + * - Library Applications: + * - Modified the Low Level and Class Driver AudioInput and AudioOutput demos to support multiple audio sample rates + * - Updated all host mode demos and projects to use the EVENT_USB_Host_DeviceEnumerationComplete() event callback for device configuration + * instead of manual host state machine manipulations in the main application task + * - Changed the reports in the GenericHID device demos to control the board LEDs, to reduce user confusion over the callback routines + * - Added reliability patches to the AVRISP-MKII Clone project's ISP and PDI/TPI protocols (thanks to Justin Mattair) + * + * Fixed: + * - Core: + * - Large number of documentation and code comment corrections (thanks to Andrey from Microsin.ru) + * - Fixed possibility of the AVR's SPI interface being pulled out of master mode if the /SS pin is a input and pulled low (thanks + * to Andrey from Microsin.ru) + * - Fixed compile error when FIXED_CONTROL_ENDPOINT_SIZE compile time option was disabled, and a USE_*_DESCRIPTORS compile time + * option was not enabled on the AVR8s + * - Fixed lack of C++ compatibility in some internal header files causing compile errors when using LUFA in C++ projects + * - Fixed error in the pipe unordered allocation algorithm for the AVR8 devices breaking compatibility with some devices + * - Fixed USB_USBTask not being called internally in stream transfers between packets when Partial Stream Transfers are used + * - Fixed swapped TWI_ADDRESS_READ and TWI_ADDRESS_WRITE values + * - Fixed TWI_ReadPacket() not releasing the TWI bus on read completion + * - Fixed optimization error in the HID Parser item value USB_SetHIDReportItemInfo() and USB_GetHIDReportItemInfo() routines if the report item was + * \c NULL (which should be allowable according to the API) + * - Fixed HID Parser CALLBACK_HIDParser_FilterHIDReportItem() callback function not being passed a cacheable report item pointer + * - Fixed HID Parser's largest report size bit count not including the size of the last parsed report item + * - Fixed HID host driver's largest HID report size count corrupt when the number of report bits exceeds 255 + * - Library Applications: + * - Fixed incorrect signature in the CDC and DFU class bootloaders for the ATMEGA8U2 + * - Fixed KeyboardHost and KeyboardHostWithParser demos displaying incorrect values when numerical keys were pressed + * - Fixed compile errors in the incomplete BluetoothHost demo application (thanks to Timo Lindfors) + * - Fixed incorrect Dataflash buffer use in the DataflashManager_WriteBlocks_RAM() function of several demos/projects (thanks to Jeremy Willden) + * - Fixed incorrect logging interval (always 500ms longer than requested) in the TempDataLogger project + * - Fixed incorrect buffer size check in the USBtoSerial project (thanks to Yuri A Nikiforov) + * - Fixed port state table corruption in the TCP layer of the RNDIS Ethernet device demos + * + * \section Sec_ChangeLog110528 Version 110528 + * New: + * - Core: + * - Added new ORDERED_EP_CONFIG compile time option to restrict endpoint/pipe configuration to ascending order + * in exchange for a smaller compiled program binary size + * - Added a new general RingBuff.h miscellaneous ring buffer library driver header + * - Added new GCC_FORCE_POINTER_ACCESS() macro to correct GCC's mishandling of struct pointer accesses + * - Added new GCC_MEMORY_BARRIER() macro to prevent instruction reordering across boundaries + * - Added basic driver example use code to the library documentation + * - Added new Endpoint_Null_Stream() and Pipe_Null_Stream() functions + * - Added new ADC_GET_CHANNEL_MASK() convenience macro + * - Added new HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors + * - Added new HID_DESCRIPTOR_MOUSE(), HID_DESCRIPTOR_KEYBOARD(), HID_DESCRIPTOR_JOYSTICK() and HID_DESCRIPTOR_VENDOR() macros + * for easy automatic creation of basic USB HID device reports + * - Added new MAX() and MIN() convenience macros + * - Added new Serial_SendData() function to the Serial driver + * - Added board driver support for the Sparkfun ATMEGA8U2 breakout board + * - Added TWI baud rate prescaler and bit length parameters to the TWI_Init() function (thanks to Thomas Herlinghaus) + * - Internal restructuring for eventual multiple architecture ports + * - Added AVR32 UC3 architecture port (currently incomplete/experimental) + * - Added new architecture independent functions to enable, disable, save and restore the Global Interrupt Enable flags + * - Added new RNDIS Device Class Driver packet send and receive functions + * - Library Applications: + * - Added ability to write protect Mass Storage disk write operations from the host OS + * - Added new MIDIToneGenerator project + * - Added new KeyboardMouseMultiReport Device ClassDriver demo + * - Added new VirtualSerialMassStorage Device ClassDriver demo + * - Added HID class bootloader, compatible with a modified version of the command line Teensy loader from PJRC.com + * - Added LED flashing to the CDC and DFU class bootloaders to indicate when they are running + * + * Changed: + * - Core: + * - Unordered Endpoint/Pipe configuration is now allowed once again by default via the previous reconfig workaround + * - Refactored Host mode Class Driver *_Host_ConfigurePipes() routines to be more space efficient when compiled + * - Added new *_ENUMERROR_PipeConfigurationFailed error codes for the *_Host_ConfigurePipes() routines + * - The USARTStream global is now public and documented in the SerialStream module, allowing for the serial USART + * stream to be accessed via its handle rather than via the implicit stdout and stdin streams + * - The FAST_STREAM_TRANSFERS compile time option has been removed due to lack of use and low cost/benefit ratio + * - Altered all endpoint/pipe stream transfers so that the new BytesProcessed parameter now points to a location + * where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction + * should be performed in one chunk) + * - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature + * - Changed over all project and demo HID report descriptors to use the new HID report item macros + * - Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/ + * - Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index + * - Removed the SerialStream driver, rolled functionality into the regular Serial peripheral driver via the new + * Serial_CreateStream() and Serial_CreateBlockingStream() functions + * - Renamed the low level Serial byte send/receive functions, to be consistent with the CDC class driver byte functions + * - Altered the behaviour of the serial byte reception function so that is is non-blocking, and now returns a negative + * value if no character is received (to remain consistent with the CDC class driver byte reception routines) + * - Renamed the PRNT_Host_SendString(), CDC_Host_SendString() and CDC_Device_SendString() functions to *_SendData(), and + * added new versions of the *_SendString() routines that expect a null terminated string instead + * - Renamed all driver termination *_ShutDown() functions to the more logical name *_Disable() + * - Reduced latency for executing the Start-Of-Frame events (if enabled in the user application) + * - Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called + * - Endpoint_ResetFIFO() renamed to Endpoint_ResetEndpoint(), to be consistent with the Pipe_ResetPipe() function name + * - Implemented on-demand PLL clock generation for the U4, U6 and U7 series USB AVRs when automatic PLL mode is specified + * - F_CLOCK changed to F_USB to be more descriptive, and applicable on future architecture ports + * - Renamed all low level Endpoint_Read_*, Endpoint_Write_* and Endpoint_Discard_* functions to use the number of bits instead of + * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures + * - Renamed all low level Pipe_Read_*, Pipe_Write_* and Pipe_Discard_* functions to use the number of bits instead of + * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures + * - Separated out board drivers by architecture in the library internals for better organisation + * - Library Applications: + * - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode + * via the Input Capture register, to reduce user confusion + * - Combined page and word ISP programming mode code in the AVRISP-MKII clone project to reduce compiled size and + * increase maintainability of the code + * - Changed over library projects to use the new general ring buffer library driver module + * - Added new high level TWI packet read/write commands, altered behaviour of the TWI_StartTransmission() function + * - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition + * - Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to reduce CPU usage and free timer 0 + * for other uses + * - Updated the software USART code in the XPLAIN Bridge application so that the incoming bits are sampled at their mid-point + * instead of starting point, to give maximum reliability (thanks to Anton Staaf) + * + * Fixed: + * - Core: + * - Fixed broken USBFOO board drivers due to missing BOARD_USBFOO define + * - Fixed HID host class driver incorrectly binding to HID devices that do not have an OUT endpoint + * - Fixed incorrect definition of the HID_KEYBOARD_SC_D constant in the HID class driver (thanks to Opendous Inc.) + * - Fixed incorrect definition of the HID_KEYBOARD_SC_RIGHT_ARROW constant in the HID class driver (thanks to Joby Taffey) + * - Fixed incorrect endpoint initialisation order in the several device demos (thanks to Rick Drolet) + * - Fixed inverted Minimus board LEDs + * - Fixed incorrect byte ordering in the Audio_Device_WriteSample24 function (thanks to WZab) + * - Fixed several functions in the Host mode Still Image Class driver returning an error code from the incorrect + * error code enum (thanks to Daniel Seibert) + * - Fixed ReportID not being removed from the feature/out report data array in the HID class driver when Report IDs are used + * - Fixed incorrect BUTTONS_BUTTON1 definition for the Minimus board + * - Fixed Still Image Host class driver exiting the descriptor search routine prematurely if the data pipes (but not event pipe) + * is found + * - Fixed missing call to Pipe_SetInfiniteINRequests() in the Pipe_ConfigurePipe() routine + * - Fixed Remote Wakeup broken on the AVRs due to the mechanism only operating when the SUSPI bit is set (thanks to Holger Steinhaus) + * - Fixed possible invalid program execution when in host mode if corrupt descriptor lengths are supplied by the attached device + * - Library Applications: + * - Fixed Benito project discarding incoming data from the USB virtual serial port when the USART is busy + * - Fixed broken DFU bootloader, added XPLAIN support for bootloader start when XCK jumpered to ground + * - Fixed broken HID_REQ_GetReport request handler in the Low Level GenericHID demo + * - Fixed possible lost data in the XPLAINBridge, USBtoSerial and Benito projects when the host exceeds the packet + * timeout period on received packets as set by USB_STREAM_TIMEOUT_MS (thanks to Justin Rajewski) + * - Fixed possible programming problem in the AVRISP-MKII clone project when programming specific patterns into a target + * memory space that is only byte (not page) addressable + * - Fixed errors in the incomplete Test and Measurement device demo preventing proper operation (thanks to Pavel Plotnikov) + * - Fixed programming errors in the AVRISP-MKII project when the programming packet is a round multiple of the endpoint bank + * size under avrdude (thanks to Steffan Woltjer) + * + * + * \section Sec_ChangeLog101122 Version 101122 + * New: + * - Core: + * - Added new SCSI_ASENSE_NOT_READY_TO_READY_CHANGE constant to the Mass Storage class driver, to indicate when a previously + * not ready removable medium has now become ready for the host's use (thanks to Martin Degelsegger) + * - Moved the Pipe and Endpoint stream related code to two new USB library core source files EndpointStream.c and PipeStream.c + * - Added new USB_Device_GetFrameNumber() and USB_Host_GetFrameNumber() functions to retrieve the current USB frame number + * - Added new USB_Host_EnableSOFEvents(), USB_Host_DisableSOFEvents() and EVENT_USB_Host_StartOfFrame() for the user application + * handling of USB Start of Frame events while in USB Host mode + * - Added new PRNT_Host_BytesReceived(), PRNT_Host_ReceiveByte(), PRNT_Host_SendByte() and PRNT_Host_Flush() functions to the + * Print Host Class driver + * - Added class specific descriptor alternative struct type defines with standard USB-IF element naming + * - Added new project makefile template to the library and moved board driver stub files into in a new "CodeTemplates" directory + * - Added board hardware driver support for the Adafruit U4 breakout board + * - Added board hardware driver support for the Arduino Uno development board + * - Added board hardware driver support for the Blackcat USB JTAG board (thanks to the PSGroove team) + * - Added board hardware driver support for the Busware BUI development board + * - Added board hardware driver support for the Busware CUL V3 868MHZ radio board (thanks to Dirk Tostmann) + * - Added board hardware driver support for the Kernel Concepts USBFOO development board + * - Added board hardware driver support for the Linnix UDIP development board + * - Added board hardware driver support for the Olimex AVR-USB-162 development board (thanks to Steve Fawcett) + * - Added board hardware driver support for the Maximus board (thanks to the PSGroove team) + * - Added board hardware driver support for the Microsin AVR-USB162 breakout board + * - Added board hardware driver support for the Minimus board (thanks to the PSGroove team) + * - Added new NO_CLASS_DRIVER_AUTOFLUSH compile time option to disable automatic flushing of interfaces when the USB management + * tasks for each driver is called + * - Added standard keyboard HID report scan-code defines (thanks to Laszlo Monda) + * - Added new Pipe_GetBusyBanks(), Endpoint_GetBusyBanks() and Endpoint_AbortPendingIN() functions + * - Library Applications: + * - Added default test tone generation mode to the Device mode AudioInput demos + * - Added new NO_BLOCK_SUPPORT, NO_EEPROM_BYTE_SUPPORT, NO_FLASH_BYTE_SUPPORT and NO_LOCK_BYTE_WRITE_SUPPORT compile time options to the + * CDC class bootloader + * - Added new XCK_RESCUE_CLOCK_ENABLE compile time option to the AVRISP-MKII clone programmer project (thanks to Tom Light) + * + * Changed: + * - Core: + * - Removed complicated logic for the Endpoint_ConfigureEndpoint() function to use inlined or function called versions + * depending of if the given bank size is a compile time constant, as the compiler does a better job of optimizing + * with basic code + * - Changed the signature of the CALLBACK_USB_GetDescriptor() callback function so that the descriptor pointer is const, to remove + * the need for extra casting inside the callback (thanks to Jonathan Kollasch) + * - Reduced HOST_DEVICE_SETTLE_DELAY_MS to 1000ms down from 1500ms to improve device compatibility while in USB Host mode + * - Removed the EVENT_USB_InitFailure() event, not specifying a USB mode correctly now defaults to UID selection mode + * - Renamed and moved class driver common constant definitions to make the naming scheme more uniform + * - Moved the USB mode specifier constants into a new enum, so that they are semantically related to one another + * - Renamed ENDPOINT_DOUBLEBANK_SUPPORTED() to ENDPOINT_BANKS_SUPPORTED() and changed it to return the maximum number of supported banks for + * the given endpoint + * - Better algorithm to extract and convert the internal device serial number into a string descriptor (if present) + * - All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be separately included + * - The MIDI class drivers now automatically flushes the MIDI interface when the MIDI class driver's USBTask() function is called + * - Renamed the EVENT_USB_Device_UnhandledControlRequest() event to EVENT_USB_Device_ControlRequest() as it is now fired before the library + * request handlers, not afterwards + * - Library Applications: + * - Changed over all device demos to use a clearer algorithm for the configuring of the application's endpoints + * - Added missing DataflashManager_CheckDataflashOperation() function to the MassStorageKeyboard demo, removed redundant + * SCSI_Codes.h file as these values are part of the MassStorage Class Driver + * - Added compile time error to the AVRISP-MKII project when built for the U4 chips, as the default VTARGET detection ADC channel + * does not exist on these chips (thanks to Marco) + * - Changed all Device mode LowLevel demos and Device Class drivers so that the control request is acknowledged and any data + * transferred as quickly as possible without any processing in between sections, so that long callbacks or event handlers will + * not break communications with the host by exceeding the maximum control request stage timeout period + * - Changed over all demos, drivers and internal functions to use the current frame number over the Start of Frame flag where possible + * to free up the Start of Frame flag for interrupt use in the user application + * - All project makefiles now correctly clean intermediate build files from assembly and C++ sources (thanks to Daniel Czigany) + * - Changed default value for the reset polarity parameter in the AVRISP-MKII project so that it defaults to active low drive + * - Changed configuration descriptor parser for all host mode projects and class drivers to ensure better compatibility with devices + * - All LowLevel demos changed to use the constants and types defined in the USB class drivers + * - Changed AudioInput and AudioOutput demos to reload the next sample via an interrupt rather than polling the sample timer + * - Rescue clock of the AVRISP-MKII moved to the AVR's OCR1A pin, so that the clock can be generated at all times + * - Changed ClassDriver MIDI demos to process all incoming events in a loop until the bank becomes empty rather than one at a time + * - Changed LowLevel MIDI demos to only clear the incoming event bank once it has become empty to support packed event packets + * + * Fixed: + * - Core: + * - Fixed USB_GetHIDReportItemInfo() function modifying the given report item's data when the report item does not exist + * within the supplied report of a multiple report HID device + * - Fixed critical pipe/endpoint memory allocation issue where the bank memory address space could be silently overlapped + * in the USB controller if the endpoints or pipes were allocated in anything other than ascending order (thanks to Martin Degelsegger) + * - Added LEDs_ToggleLEDs() function to several board LED drivers which were missing it (thanks to Andrei Krainev) + * - Fixed SET FEATURE and CLEAR FEATURE control requests directed at an unconfigured endpoint causing request timeouts + * - Fixed USB_Host_ClearPipeStall() incorrectly determining the endpoint direction from the currently selected pipe + * - Fixed JTAG_DEBUG_POINT() and JTAG_DEBUG_BREAK() macros not compiling under pure C99 standards mode + * - Fixed endpoint selection within the CALLBACK_HID_Device_CreateHIDReport() callback function causing broken GET REPORT requests + * - Fixed incorrect command name for EEPROM memory programming in the makefile dfu-ee target + * - Fixed incorrect LEDs_ChangeLEDs() function in the Benito board LED driver + * - Fixed incorrect USB_DeviceState value when unconfiguring the device without an address set + * - Fixed SPI driver not explicitly setting /SS and MISO pins as inputs when SPI_Init() is called + * - Fixed random enumeration failure while in device mode due to interrupts causing the Set Address request to exceed maximum timings + * - Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface was not configured + * - Fixed MIDI class driver send routines silently discarding packets if the endpoint or pipe is busy (thanks to Robin Green) + * - Library Applications: + * - Fixed MassStorage based demos and projects resetting the SCSI sense values before the command is executed, leading to + * missed SCSI sense values when the host retrieves the sense key (thanks to Martin Degelsegger) + * - Fixed USBtoSerial and Benito project SetLineEncoding calls failing if the USART is busy, due to the RX ISR delaying the control + * request handler + * - Fixed LowLevel PrinterHost demo not sending control requests to the attached printer with the correct printer interface wIndex value + * - Fixed incorrect signature reported in the CDC class bootloader for the ATMEGA32U2 + * - Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev) + * - Fixed broken FLASH/EEPROM programming in the AVRISP-MKII clone project when writing in non-paged mode and the polling byte cannot be used + * - Fixed ISR definition conflict in the XPLAIN bridge between the software UART and the AVRISP-MKII ISP modules + * - Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the send buffer becomes full + * - Fixed broken input in the MagStripe reader project due to an incorrect HID report descriptor + * - Fixed incorrect PollingIntervalMS values in the demo/project/bootloader endpoint descriptors (thanks to MCS Electronics) + * - Fixed AVRISP-MKII clone project not starting the target's program automatically after exiting TPI programming mode + * + * + * \section Sec_ChangeLog100807 Version 100807 + * New: + * - Added new ADC_DisableChannel() function (thanks to Mich Davis) + * - Added new VTARGET_REF_VOLTS and VTARGET_SCALE_FACTOR compile time defines to the AVRISP-MKII programmer project to set + * the VTARGET reference voltage and scale factor + * - Added new pgm_read_ptr() macro to Common.h for reading of pointers out of flash memory space + * - Added new SWAPENDIAN_16() and SWAPENDIAN_32() macros to Common.h for statically initialized variables at compile time + * - Added new Drivers/USB/LowLevel/Device.c file to house Device mode specific functions that are more complicated than simple macros + * - Added new AVRStudio 4 project files for all library demos, projects and bootloaders + * - Added ability to set the serial baud rate via the user's terminal in the XPLAINBridge project + * - Added new LUFA module variables for the different source modules in the core library makefile to simplify project makefiles + * - Added start of a new Test and Measurement class demo (thanks to Peter Lawrence) + * - Added new SPI_ORDER_* data order masks to the SPI peripheral driver + * - Added support to the AVRISP-MKII project for ISP speeds slower than 125KHz via a new software SPI driver + * - Added support for the new button/LED on the latest model USBTINY-MKII + * + * Changed: + * - The RingBuff library code has been replaced in the XPLAINBridge, Benito and USBtoSerial projects with an ultra lightweight + * ring buffer to help improve the reliability of the projects + * - The EEPROM stream read/write functions now use eeprom_update_byte() instead of eeprom_write_byte(), so that only + * changed bytes are written to EEPROM to preserve its lifespan + * - Changed over the AVRISP-MKII and TemperatureDataLogger projects to use eeprom_update_byte() when writing non-volatile + * parameters to EEPROM to preserve its lifespan + * - Removed unused line encoding data and control requests from the CDC Bootloader code, to save space + * - Renamed SERIAL_STREAM_ASSERT() macro to STDOUT_ASSERT() + * - The USB_Device_IsRemoteWakeupSent() and USB_Device_IsUSBSuspended() macros have been deleted, as they are now obsolete + * - Rewrote the implementation of the SwapEndian_16() and SwapEndian_32() functions so that they compile down in most instances to + * minimal loads and stores rather than complicated shifts + * - The software UART in the XPLAINBridge has been largely altered to try to improve upon its performance and reliability + * - The USBtoSerial and Benito projects now flushes received data via a flush timer, so that several bytes can be transmitted at once + * - Removed the automated checking of event names in the demo, project and bootloader makefiles due to inconsistencies between the + * behaviour of the command line tools used to perform the check on each platform + * - Internal USB driver source files renamed and moved to ease future possible architecture ports + * - All internal pseudo-function macros have been converted to true inline functions for type-safety and readability + * - Changed LED indicator masks for the AVRISP-MKII project, so that there are defined roles for each LED + * - Altered the CDC Device and Host Class drivers' receive byte routines, so that no data is indicated by the function returning a + * negative value (thanks to Andreas Paulin) + * - Added auto flushing of OUT data to the CDC Host Class driver's USBTask function to automatically flush the send pipe buffer + * + * Fixed: + * - Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs after programming or reading from + * the last page of FLASH (thanks to Gerard Sexton) + * - Fixed AVRISP project not sending a full erase-and-write EEPROM command to XMEGA targets when writing to the EEPROM + * instead of the split write-only command (thanks to Tim Margush) + * - Fixed RNDISEthernet demos crashing when calculating checksums for Ethernet/TCP packets of more than ~500 bytes due to + * an overflow in the checksum calculation loop (thanks to Kevin Malec) + * - Fixed XPLAINBridge project not correctly reading the XMEGA's supply voltage when reporting back to the host + * - Fixed incorrect signature for the ATMEGA32U2 in the DFU bootloader (thanks to Axel Rohde) + * - Fixed internal device serial not being accessible on the ATMEGAXXU2 AVRs (thanks to Axel Rohde) + * - Fixed void pointer arithmetic in ConfigDescriptor.h breaking C++ compatibility (thanks to Michael Hennebry) + * - Fixed broken PDI EEPROM Section Erase functionality in the AVRISP-MKII project + * - Fixed USB_Device_SendRemoteWakeup() not working when the USB clock was frozen during USB bus suspend (thanks to Brian Dickman) + * - Fixed occasional lockup of the AVRISP project due to the timeout extension code incorrectly extending the timeout in + * PDI and TPI programming modes infinitely + * - Fixed HID device class driver still using PrevReportINBuffer for GetReport control requests even when it has been + * set to NULL by the user application (thanks to Axel Rohde) + * - Fixed MIDI_Device_SendEventPacket() not correctly waiting for the endpoint to become ready (thanks to Robin Green) + * - Fixed Benito and USBtoSerial projects not turning off the USART before reconfiguring it, which could cause incorrect + * operation to occur (thanks to Bob Paddock) + * - Fixed Serial peripheral driver not turning off the USART before reconfiguring it, which would cause incorrect operation + * to occur (thanks to Bob Paddock) + * - Fixed software application start command broken in the DFU class bootloader when dfu-programmer is used due to application + * start address corruption + * + * + * \section Sec_ChangeLog100513 Version 100513 + * New: + * - Added incomplete MIDIToneGenerator project + * - Added new Relay Controller Board project (thanks to OBinou) + * - Added board hardware driver support for the Teensy, USBTINY MKII, Benito and JM-DB-U2 lines of third party USB AVR boards + * - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup + * - Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus + * is suspended before or during a transfer + * - Added new EVENT_CDC_Device_BreakSent() event and CDC_Host_SendBreak() function to the Device and Host CDC Class drivers + * - Added ReportType parameter to the HID device class driver CALLBACK_HID_Device_ProcessHIDReport() function so that FEATURE + * reports from the host to the device can be correctly processed + * - Added ReportType parameter to the HID host class driver HID_Host_SendReportByID() function so that FEATURE reports can be + * issued to the attached device + * + * Changed: + * - AVRISP programmer project now has a more robust timeout system + * - Added a timeout value to the TWI_StartTransmission() function, within which the addressed device must respond + * - Webserver project now uses the board LEDs to indicate the current IP configuration state + * - Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable the TELNET server if desired + * - Increased throughput of the USBtoSerial demo on systems that send multiple bytes per packet (thanks to Opendous Inc.) + * - Double bank CDC endpoints in the XPLAIN Bridge project, re-enable JTAG once the mode selection pin has been sampled. + * - Standardized the naming scheme given to configuration descriptor sub-elements in the Device mode demos, bootloaders + * and projects + * - All Class Driver Host mode demos now correctly set the board LEDs to READY once the enumeration process has completed + * - Added LIBUSB_FILTERDRV_COMPAT compile time option to the AVRISP programmer project to make the code compatible with Windows + * builds of avrdude at the expense of AVRStudio compatibility + * - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code + * - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready + * for them to be enabled (thanks to Andrei Krainev) + * - The Audio_Device_IsSampleReceived() and Audio_Device_IsReadyForNextSample() functions are now inline, to reduce overhead + * - Removed the cast to uint16_t on the set baud rate in the USBtoSerial project, so that the higher >1M baud rates can be + * selected (thanks to Steffan Woltjer) + * - Removed software PDI and TPI emulation from the AVRISP-MKII clone project as it was very buggy and slow - PDI and TPI must + * now be implemented via separate programming headers + * - The CDC class bootloader now uses a watchdog reset rather than a soft-reset when exited to ensure that all hardware is + * properly reset to their defaults + * - Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from + * timing out if another request is immediately fired and the device has a lengthy callback routine + * - The TeensyHID bootloader has been removed, per request from Paul at PJRC + * - The LIBUSB_FILTERDRV_COMPAT compile time option in the XPLAINBridge and AVRISP-MKII projects has been renamed + * LIBUSB_DRIVER_COMPAT, as it applies to all software on all platforms using the libUSB driver + * + * Fixed: + * - Fixed possible device lockup when INTERRUPT_CONTROL_ENDPOINT is enabled and the control endpoint is not properly + * selected when the ISR completes + * - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address + * boundary is crossed during programming or read back (thanks to Gerard Sexton) + * - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled + * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin + * - Fixed TWI_StartTransmission() corrupting the contents of the GPIOR0 register + * - Fixed TWI driver not aborting when faced with no response after attempting to address a device on the bus + * - Fixed ADC routines not correctly returning the last result when multiple channels were read + * - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the + * U4 series USB AVR parts + * - Fixed LowLevel MassStorage demo broken on the U2 series USB AVRs due to unsupported double-banked endpoint modes used + * - Fixed compilation error in the AudioInput demos when MICROPHONE_BIASED_TO_HALF_RAIL is defined (thanks to C. Scott Ananian) + * - Fixed incorrect definition of HID_ALIGN_DATA() causing incorrect HID report item data alignment + * - Fixed Still Image Host class driver not resetting the transaction ID when a new session is opened, fixed driver not sending + * a valid session ID to the device + * - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer + * - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host + * - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the + * user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski) + * - Fixed device state not being reset to DEVICE_STATE_Default if the host sets a 0x00 device address + * - Fixed device not stalling configuration requests before the device's address has been set + * - Fixed possibility of internal signature retrieval being corrupted if an interrupt occurs during a signature byte + * read (thanks to Andrei Krainev) + * - Fixed device state not being reset back to the default state if the host sets the address to 0 + * - Fixed Set Configuration requests not being stalled until the host has set the device's address + * - Fixed Host mode HID class driver not sending the correct report type when HID_Host_SendReportByID() was called and the + * HID_HOST_BOOT_PROTOCOL_ONLY compile time option is set + * - Fixed INTERRUPT_CONTROL_ENDPOINT compile time option preventing other interrupts from occurring while the control endpoint + * request is being processed, causing possible lockups if a USB interrupt occurs during a transfer + * - Remove incorrect Abstract Call Management class specific descriptor from the CDC demos, bootloaders and projects + * + * + * \section Sec_ChangeLog100219 Version 100219 + * + * New: + * - Added TPI programming support for 6-pin ATTINY devices to the AVRISP programmer project (thanks to Tom Light) + * - Added command timeout counter to the AVRISP project so that the device no longer freezes when incorrectly connected + * to a target + * - Added new TemperatureDataLogger application, a USB data logger which writes to the device's dataflash and appears to + * the host as a standard Mass Storage device when inserted + * - Added MIDI event packing support to the MIDI Device and Host mode Class drivers, allowing for multiple MIDI events to + * sent or received in packed form in a single USB packet + * - Added new MIDI send buffer flush routines to the MIDI Device and Host mode Class drivers, to flush packed events + * - Added master mode hardware TWI driver for easy TWI peripheral control + * - Added ADC MUX masks for the standard ADC input channels on all AVR models with an ADC, altered demos to use these masks + * as on some models, the channel number is not identical to its single-ended ADC MUX mask + * - New Webserver project, a RNDIS host USB webserver using the open source uIP TCP/IP network stack and FatFS library + * - New BOARD value option BOARD_NONE (equivalent to not specifying BOARD) which will remove all board hardware drivers which + * do not adversely affect the code operation (currently only the LEDs driver) + * - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) and LED report masks (KEYBOARD_LED_*) to the HID class driver and + * Keyboard demos + * - Added .5MHz recovery clock to the AVRISP programmer project when in ISP programming mode to correct mis-set fuses + * + * Changed: + * - Slowed down software USART carried PDI programming in the AVRISP project to prevent transmission errors + * - Renamed the AVRISP project folder to AVRISP-MKII to reduce confusion + * - Renamed the RESET_LINE_* makefile tokens in the AVRISP MKII Project to AUX_LINE_*, as they are not always used for target + * reset + * - Changed over the MassStorageKeyboard Class driver device demo to use Start of Frame events rather than a timer to keep track + * of elapsed milliseconds + * - Inlined currently unused (but standardized) maintenance functions in the Device and Host Class drivers to save space + * - The XPLAINBridge project now selects between a USB to Serial bridge and a PDI programmer on startup, reading the JTAG port's + * TDI pin to determine which mode to use + * - Removed the stream example code from the Low Level VirtualSerial demos, as they were buggy and only served to add clutter + * + * Fixed: + * - Fixed AVRISP project not able to enter programming mode when ISP protocol is used + * - Fixed AVRISP PDI race condition where the guard time between direction changes could be interpreted as a start bit + * - Fixed ADC_IsReadingComplete() returning an inverted result + * - Fixed blocking CDC streams not aborting when the host is disconnected + * - Fixed XPLAIN board Dataflash driver broken due to incorrect preprocessor commands + * - Fixed inverted XPLAIN LED driver output (LED turned on when it was supposed to be turned off, and vice-versa) + * - Fixed Class Driver struct interface numbers in the KeyboardMouse and VirtualSerialMouse demos (thanks to Renaud Cerrato) + * - Fixed invalid USB controller PLL prescaler values for the ATMEGAxxU2 controllers + * - Fixed lack of support for the ATMEGA32U2 in the DFU and CDC class bootloaders + * - Fixed Benito project not resetting the target AVR automatically when programming has completed + * - Fixed DFU bootloader programming not discarding the correct number of filler bytes from the host when non-aligned programming + * ranges are specified (thanks to Thomas Bleeker) + * - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two separate pipes, not one half-duplex pipe + * - Fixed Pipe_IsEndpointBound() not taking the endpoint's direction into account + * - Fixed EEPROM and FLASH ISP programming in the AVRISP project + * - Fixed incorrect values of USB_CONFIG_ATTR_SELFPOWERED and USB_CONFIG_ATTR_REMOTEWAKEUP tokens (thanks to Claus Christensen) + * - Fixed SerialStream driver blocking while waiting for characters to be received instead of returning EOF + * - Fixed SerialStream driver not setting stdin to the created serial stream (thanks to Mike Alexander) + * - Fixed USB_GetHIDReportSize() returning the number of bits in the specified report instead of bytes + * - Fixed AVRISP project not extending the command delay after each successful page/word/byte program + * - Fixed accuracy of the SERIAL_UBBRVAL() and SERIAL_2X_UBBRVAL() macros for higher baud rates (thanks to Renaud Cerrato) + * + * + * \section Sec_ChangeLog091223 Version 091223 + * + * New: + * - Added activity LED indicators to the AVRISP project to indicate when the device is busy processing a command + * - The USB target family and allowable USB mode tokens are now public and documented (USB_CAN_BE_*, USB_SERIES_*_AVR) + * - Added new XPLAIN USB to Serial Bridge project (thanks to John Steggall for initial proof-of-concept, David Prentice + * and Peter Danneger for revised software USART code) + * - Added new RNDIS Ethernet Host LowLevel demo + * - Added new RNDIS Ethernet Host Class Driver + * - Added new RNDIS Ethernet Host ClassDriver demo + * - Added CDC_Host_Flush() function to the CDC Host Class driver to flush sent data to the attached device + * - Added PDI programming support for XMEGA devices to the AVRISP programmer project (thanks to Justin Mattair) + * - Added support for the XPLAIN board Dataflash, with new XPLAIN_REV1 board target for the different dataflash used + * on the first revision boards compared to the one mounted on later revisions + * - Added new HID_ALIGN_DATA() macro to return the pre-retrieved value of a HID report item, left-aligned to a given datatype + * - Added new PreviousValue to the HID Report Parser report item structure, for easy monitoring of previous report item values + * - Added new EVK527 board target + * - Added new USB_Host_GetDeviceStringDescriptor() convenience function + * - Added new LEDNotification project to the library, to give a visual LED notification on new events from the host + * - Added new NO_DEVICE_REMOTE_WAKEUP and NO_DEVICE_SELF_POWER compile time options + * + * Changed: + * - Removed code in the Keyboard demos to send zeroed reports between two reports with differing numbers of key codes + * as this relied on non-standard OS driver behaviour to repeat key groups + * - The SCSI_Request_Sense_Response_t and SCSI_Inquiry_Response_t type defines are now part of the Mass Storage Class + * driver common defines, rather than being defined in the Host mode Class driver section only + * - The USB_MODE_HOST token is now defined even when host mode is not available + * - The CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new ReportType parameter to + * indicate the report type to generate + * - All Class Drivers now return false or the "DeviceDisconnected" error code of their respective error enums when a function + * is called when no host/device is connected where possible + * - The HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to HOST_SENDCONTROL_DeviceDisconnected to be in line + * with the rest of the library error codes + * - Make MIDI device demos also turn off the on board LEDs if MIDI Note On messages are sent with a velocity of zero, + * which some devices use instead of Note Off messages (thanks to Robin Green) + * - The CDC demos are now named "VirtualSerial" instead to indicate the demos' function rather than its implemented USB class, + * to reduce confusion and to be in line with the rest of the LUFA demos + * - The SImage_Host_SendBlockHeader() and SImage_Host_ReceiveBlockHeader() Still Image Host Class driver functions are now public + * + * Fixed: + * - Added missing CDC_Host_CreateBlockingStream() function code to the CDC Host Class driver + * - Fixed incorrect values for REPORT_ITEM_TYPE_* enum values causing corrupt data in the HID Host Parser + * - Fixed misnamed SI_Host_USBTask() and SI_Host_ConfigurePipes() functions + * - Fixed broken USB_GetNextDescriptor() function causing the descriptor to jump ahead double the expected amount + * - Fixed Pipe_IsEndpointBound() not masking the given Endpoint Address against PIPE_EPNUM_MASK + * - Fixed host state machine not enabling Auto VBUS mode when HOST_DEVICE_SETTLE_DELAY_MS is set to zero + * - Fixed misnamed Pipe_SetPipeToken() macro for setting a pipe's direction + * - Fixed CDCHost failing on devices with bidirectional endpoints + * - Fixed USB driver failing to define the PLL prescaler mask for the ATMEGA8U2 and ATMEGA16U2 + * - Fixed HID Parser not distributing the Usage Min and Usage Max values across an array of report items + * - Fixed Mass Storage Host Class driver and Low Level demo not clearing the error condition if an attached device returns a + * STALL to a GET MAX LUN request (thanks to Martin Luxen) + * - Fixed TeensyHID bootloader not properly shutting down the USB interface to trigger a disconnection on the host before resetting + * - Fixed MassStorageHost Class driver demo not having USB_STREAM_TIMEOUT_MS compile time option set properly to prevent slow + * devices from timing out the data pipes + * - Fixed the definition of the Endpoint_BytesInEndpoint() macro for the U4 series AVR parts + * - Fixed MIDI host Class driver MIDI_Host_SendEventPacket() routine not properly checking for Pipe ready before writing + * - Fixed use of deprecated struct initializers, removed library unused parameter warnings when compiled with -Wextra enabled + * - Fixed Still Image Host Class driver truncating the PIMA response code (thanks to Daniel Seibert) + * - Fixed USB_CurrentMode not being reset to USB_MODE_NONE when the USB interface is shut down and both Host and Device modes can be + * used (thanks to Daniel Levy) + * - Fixed TeensyHID bootloader not enumerating to the host correctly (thanks to Clint Fisher) + * - Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott) + * - Fixed STK525 Dataflash driver using incorrect bit-shifting for Dataflash addresses (thanks to Tim Mitchell) + * + * + * \section Sec_ChangeLog091122 Version 091122 + * + * New: + * - Added new Dual Role Keyboard/Mouse demo + * - Added new HID_HOST_BOOT_PROTOCOL_ONLY compile time token to reduce the size of the HID Host Class driver when + * Report protocol is not needed + * - Added new MIDI LowLevel and ClassDriver Host demo, add new MIDI Host Class driver + * - Added new CDC/Mouse ClassDriver device demo + * - Added new Joystick Host ClassDriver and LowLevel demos + * - Added new Printer Host mode Class driver + * - Added new Printer Host mode ClassDriver demo + * - Added optional support for double banked endpoints and pipes in the Device and Host mode Class drivers + * - Added new stream creation function to the CDC Class drivers, to easily make standard I/O streams from CDC Class driver instances + * + * Changed: + * - Removed mostly useless "TestApp" demo, as it was mainly useful only for checking for syntax errors in the library + * - MIDI device demos now receive MIDI events from the host and display note ON messages via the board LEDs + * - Cleanups to the Device mode Mass Storage demo application SCSI routines + * - Changed Audio Class driver sample read/write functions to be inline, to reduce the number of cycles needed to transfer + * samples to and from the device (allowing more time for sample processing and output) + * - Audio class Device mode demos now work at both 16MHz and 8MHz, rather than just at 8MHz + * - The previous USBtoSerial demo has been moved into the projects directory, as it was just a modified CDC demo + * - The Endpoint/Pipe functions now use the const qualifier on the input buffer + * - Changed the CALLBACK_HIDParser_FilterHIDReportItem() callback to pass a HID_ReportItem_t rather than just the current + * item's attributes, to expose more information on the item (including it's type, collection path, etc.) + * - Changed MouseHostWithParser demos to check that the report items have a Mouse usage collection as a parent at some point, + * to prevent Joysticks from enumerating with the demo + * - Corrected the name of the misnamed USB_GetDeviceConfigDescriptor() function to USB_Host_GetDeviceConfigDescriptor(). + * - Keyboard LowLevel/ClassDriver demos now support multiple simultaneous key presses (up to 6) per report + * + * Fixed: + * - Fixed PrinterHost demo returning invalid Device ID data when the attached device does not have a + * device ID (thanks to Andrei Krainev) + * - Changed LUFA_VERSION_INTEGER define to use BCD values, to make comparisons easier + * - Fixed issue in the HID Host class driver's HID_Host_SendReportByID() routine using the incorrect mode (control/pipe) + * to send report to the attached device + * - Fixed ClassDriver AudioOutput device demo not selecting an audio output mode + * - Fixed incorrect SampleFrequencyType value in the AudioInput and AudioOutput ClassDriver demos' descriptors + * - Fixed incorrect event name rule in demo/project/bootloader makefiles + * - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called + * - Corrected HID descriptor in the Joystick Device demos - buttons should be placed outside the pointer collection + * - Fixed HID report parser collection paths invalid due to misplaced semicolon in the free path item search loop + * - Fixed HID host Class driver report send/receive report broken when issued through the control pipe + * - Fixed HOST_STATE_AS_GPIOR compile time option being ignored when in host mode (thanks to David Lyons) + * - Fixed LowLevel Keyboard demo not saving the issues report only after it has been sent to the host + * - Fixed Endpoint_Write_Control_Stream_* functions not sending a terminating IN when given data Length is zero + * + * + * \section Sec_ChangeLog090924 Version 090924 + * + * New: + * - Added new host mode class drivers and matching demos to the library for rapid application development + * - Added flag to the HID report parser to indicate if a device has multiple reports + * - Added new EVENT_USB_Device_StartOfFrame() event, controlled by the new USB_Device_EnableSOFEvents() and + * USB_Device_DisableSOFEvents() macros to give bus-synchronized millisecond interrupts when in USB device mode + * - Added new Endpoint_SetEndpointDirection() macro for bidirectional endpoints + * - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer + * - Added ShutDown() functions for all hardware peripheral drivers, so that peripherals can be turned off after use + * - Added new CDC_Device_Flush() command to the device mode CDC Class driver to flush Device->Host data + * - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set + * - Added new callback to the HID report parser, so that the user application can filter only the items it is interested + * in to be stored into the HIDReportInfo structure to save RAM + * - Added support for the officially recommended external peripheral layout for the BUMBLEB board (thanks to Dave Fletcher) + * - Added new Pipe_IsFrozen() macro to determine if the currently selected pipe is frozen + * - Added new USB_GetHIDReportSize() function to the HID report parser to retrieve the size of a given report by its ID + * - Added new combined Mass Storage and Keyboard demo (thanks to Matthias Hullin) + * + * Changed: + * - SetIdle requests to the HID device driver with a 0 idle period (send changes only) now only affect the requested + * HID interface within the device, not all HID interfaces + * - Added explicit attribute masks to the device mode demos' descriptors + * - Added return values to the CDC and MIDI class driver transmit functions + * - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size + * - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability + * - Added new "Common" section to the class drivers, to hold all mode-independent definitions for clarity + * - Moved SCSI command/sense constants into the Mass Storage Class driver, instead of the user-code + * - Altered the SCSI commands in the LowLevel Mass Storage Host to save on FLASH space by reducing function calls + * - Changed the parameters and behaviour of the USB_GetDeviceConfigDescriptor() function so that it now performs size checks + * and data validations internally, to simplify user code + * - Changed HIDParser to only zero out important values in the Parsed HID Report Item Information structure to save cycles + * - The HID report parser now always processed FEATURE items - HID_ENABLE_FEATURE_PROCESSING token now has no effect + * - The HID report parser now always ignores constant-data items, HID_INCLUDE_CONSTANT_DATA_ITEMS token now has no effect + * - The Benito Programmer project now has its own unique VID/PID pair allocated from the Atmel donated LUFA VID/PID pool + * - Add in new invalid event hook check targets to project makefiles to produce compilation errors when invalid event names + * are used in a project + * - The HID Report Parser now gives information on the total length of each report within a HID interface + * - The USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate USB_Descriptor_* and + * USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so both may be used + * + * Fixed: + * - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the + * endpoint's bank + * - Fixed swapped parameters in the HID state memory copy call while processing a HID PUSH item in the HID report parser + * - Fixed memory corruption HID report parser when too many COLLECTION or PUSH items were processed + * - Fixed HID report parser not resetting the FEATURE item count when a REPORT ID item is encountered + * - Fixed USBtoSerial demos not reading in UDR1 when the USART receives data but the USB interface is not enumerated, + * causing continuous USART receive interrupts + * - Fixed misspelled event name in the Class driver USBtoSerial demo, preventing correct operation + * - Fixed invalid data being returned when a GetStatus request is issued in Device mode with an unhandled data recipient + * - Added hardware USART receive interrupt and software buffering to the Benito project to ensure received data is not + * missed or corrupted + * - Fixed Device mode HID Class driver always sending IN packets, even when nothing to report + * - Fixed Device mode HID Class driver not explicitly initializing the ReportSize parameter to zero before calling callback + * routine, so that ignored callbacks don't cause incorrect data to be sent + * - Fixed StillImageHost not correctly freezing and unfreezing data pipes while waiting for a response block header + * - Fixed error in the PrinterHost demo preventing the full page data from being sent to the attached device (thanks to John Andrews) + * - Fixed CDC based demos and projects' INF driver files under 64 bit versions of Windows (thanks to Ronny Hanson, Thomas Bleeker) + * - Re-add in missing flip, flip-ee, dfu and dfu-ee targets to project makefiles (thanks to Opendous Inc.) + * - Fix allowable F_CPU values comment in project makefiles to more accurately reflect the allowable values on the USB AVRs + * - Fixed DFU and CDC class bootloaders on the series 2 USB AVRs, corrected invalid signatures, added support for the new + * ATMEGAxx2 series 2 variant AVRs to the DFU bootloader + * - Fixed Low Level USBtoSerial demo not storing received characters (thanks to Michael Cooper) + * - Fixed MIDI Device Class driver not sending/receiving MIDI packets of the correct size (thanks to Thomas Bleeker) + * + * + * \section Sec_ChangeLog090810 Version 090810 + * + * New: + * - Added new device class drivers and matching demos to the library for rapid application development + * - Added new PrinterHost demo (thanks to John Andrews) + * - Added USB Missile Launcher project, submitted by Dave Fletcher + * - Added new Benito Arduino Programmer project + * - Added incomplete device and host mode demos for later enhancement + * - Updated MassStorage device block write routines to use ping-pong Dataflash buffering to increase throughput by around 30% + * - Error status LEDs shown when device endpoint configuration fails to complete in all demos and projects + * - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB + * host mode + * - Added new USB_Host_ClearPipeStall() convenience function to clear a stall condition on an attached device's endpoint + * - Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor + * - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers + * - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number, + * added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code + * - Added new DATAFLASH_CHIP_MASK() macro to the Dataflash driver, which returns the Dataflash select mask for the given chip index + * - Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking disabling of device communications until the + * device has been removed (for use when an error occurs or communications with the device have completed) + * - Added new FAST_STREAM_TRANSFERS compile time option for faster stream transfers via multiple bytes copied per stream loop + * - Added stdio stream demo code to the CDC device demos, to show how to create standard streams out of the virtual serial ports + * - Added new EEPROM and FLASH buffer versions of the Endpoint and Pipe stream functions + * - Added new USE_FLASH_DESCRIPTORS and FIXED_NUM_CONFIGURATIONS compile time options + * - Added support for the new ATMEGA32U2, ATMEGA16U2 and ATMEGA8U2 AVR models + * - Added new USB_DeviceState variable to keep track of the current Device mode USB state + * - Added new LEDs_ToggleLEDs() function to the LEDs driver + * - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions + * - Added new DEVICE_STATE_AS_GPIOR and HOST_STATE_AS_GPIOR compile time options + * - Added 404 Not Found errors to the webserver in the RNDIS demos to indicate invalid URLs + * + * Changed: + * - Deprecated pseudo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused) + * - The device-mode CALLBACK_USB_GetDescriptor() function now has an extra parameter so that the memory space in which the requested + * descriptor is located can be specified. This means that descriptors can now be located in multiple memory spaces within a device. + * - Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality + * - Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead + * - Extended USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch + * - Dataflash_WaitWhileBusy() now always ensures that the dataflash is ready for the next command immediately after returning, + * no need to call Dataflash_ToggleSelectedChipCS() afterwards + * - Low level API MIDI device demo no longer blocks if a note change event is sent while the endpoint is not ready + * - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors + * - Pipe stream functions now automatically set the correct pipe token, so that bidirectional pipes can be used + * - Pipe_ConfigurePipe() now automatically defaults IN pipes to accepting infinite IN requests, this can still be changed by calling + * the existing Pipe_SetFiniteINRequests() function + * - Changed F_USB entries in project makefiles to alias to F_CPU by default, as this is the most common case + * - Host mode demos now use sane terminal escape codes, so that text is always readable and events/program output is visually distinguished + * from one another using foreground colours + * - Internal per-device preprocessing conditions changed to per-device series rather than per-controller group for finer-grain + * internal control + * - Interrupts are no longer disabled during the processing of Control Requests on the default endpoint while in device mode + * - AudioOutput demos now always output to board LEDs, regardless of output mode (removed AUDIO_OUT_LEDS project option) + * - Removed SINGLE_DEVICE_CONFIGURATION compile time option in favor of the new FIXED_NUM_CONFIGURATIONS option so that the exact number + * of device configurations can be defined statically + * - Removed VBUS events, as they are already exposed to the user application via the regular device connection and disconnection events + * - Renamed and altered existing events to properly separate out Host and Device mode events + * - All demos switched over from GNU99 standards mode to C99 standards mode, to reduce the dependencies on GCC-only language extensions + * + * Fixed: + * - Changed bootloaders to use FLASHEND rather than the existence of RAMPZ to determine if far FLASH pointers are needed to fix + * bootloaders on some of the USB AVR devices where avr-libc erroneously defines RAMPZ + * - Fixes to MassStorageHost for better device compatibility (increase command timeout, change MassStore_WaitForDataReceived() + * to only unfreeze and check one data pipe at a time) to prevent incorrect device enumerations and freezes while transferring data + * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is + * cleared to prevent endpoint type corruption + * - Fixed issue opening CDC-ACM ports on hosts when the CDC device tries to send data before the host has set the line encoding + * - Fixed USB_OPT_MANUAL_PLL option being ignored during device disconnects on some models (thanks to Brian Dickman) + * - Fixed documentation mentioning Pipe_GetCurrentToken() function when correct function name is Pipe_GetPipeToken() + * - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.) + * - Fixed CDCHost demo unfreezing the pipes at the point of configuration, rather than use + * - Fixed MassStorage demo not clearing the reset flag when a Mass Storage Reset is issued while not processing a command + * - Fixed USB_Host_SendControlRequest() not re-suspending the USB bus when initial device ready-wait fails + * - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used + * - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected + * - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman) + * - Fixed GenericHID failing HID class tests due to incorrect Logical Minimum and Logical Maximum values (thanks to Soren Greiner) + * - Fixed incorrect PIPE_EPNUM_MASK mask causing pipe failures on devices with endpoint addresses of 8 and above (thanks to John Andrews) + * - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits + * - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered + * - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target + * - Fixed RNDIS demos freezing when more than one connection was attempted simultaneously, causing memory corruption + * - Fixed USBtoSerial demo receiving noise from the USART due to pull-up not being enabled + * + * + * \section Sec_ChangeLog090605 Version 090605 + * + * - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data + * - Fixed documentation showing incorrect USB mode support on the supported AVRs list + * - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" RNDIS request which was unhandled + * - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman) + * - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues + * - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman) + * - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token + * - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC + * interface is skipped + * - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype + * inside the library that is able to hold their defined value to save space + * - Removed DESCRIPTOR_ADDRESS() macro as it was largely superfluous and only served to obfuscate code + * - Rewritten event system to remove all macros, to make user code clearer + * - Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley) + * - Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code + * - Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code + * - USB_IsConnected is now cleared before the USB_Disconnect() event is fired in response to VBUS being removed + * - Fixed incorrect PID value being used in the USBtoSerial project (thanks to Phill) + * - Deleted StdDescriptors.c, renamed USB_GetDescriptor() to CALLBACK_USB_GetDescriptor, moved ConfigDescriptor.c/.h from the + * LUFA/Drivers/USB/Class/ directory to LUFA/Drivers/USB/HighLevel/ in preparation for the new USB class APIs + * - Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure + * - Removed Tx interrupt from the USBtoSerial demo; now sends characters via polling to ensure more time for the Rx interrupt + * - Fixed possible enumeration errors from spin-loops which may fail to exit if the USB connection is severed before the exit condition + * becomes true + * + * + * \section Sec_ChangeLog090510 Version 090510 + * + * - Added new GenericHIDHost demo + * - Corrections to the KeyboardHost and MouseHost demos' pipe handling to freeze and unfreeze the data pipes at the point of use + * - KeyboardHost, MouseHost and GenericHIDHost demos now save and restore the currently selected pipe inside the pipe ISR + * - Changed GenericHID device demo to use the LUFA scheduler, added INTERRUPT_DATA_ENDPOINT and INTERRUPT_CONTROL_ENDPOINT compile + * time options + * - All comments in the library, bootloaders, demos and projects have now been spell-checked and spelling mistakes/typos corrected + * - Added new PIMA_DATA_SIZE() define to the Still Image Host demo + * - Add call to MassStore_WaitForDataReceived() in MassStore_GetReturnedStatus() to ensure that the CSW has been received in the + * extended MSC timeout period before continuing, to prevent long processing delays from causing the MassStore_GetReturnedStatus() + * to early-abort (thanks to Dmitry Maksimov) + * - Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver directory to the HighLevel USB driver directory, + * where they are more suited + * - Removed all binary constants and replaced with decimal or hexadecimal constants so that unpatched GCC compilers can still build the + * code without having to be itself patched and recompiled first + * - Added preprocessor checks and documentation to the bootloaders giving information about missing SIGNATURE_x defines due to + * outdated avr-libc versions. + * - Added support to the CDCHost demo for devices with multiple CDC interfaces which are not the correct ACM type preceding the desired + * ACM CDC interface + * - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen) + * - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan Oakley) + * - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint + * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to match the CTC calculations in the AVR datasheet, + * and to fix instances where rounding caused the endpoint to underflow (thanks to Robin Theunis) + * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type + * pipes can be used with the function + * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes + * - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev) + * - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favor of new Endpoint_ClearIN(), Endpoint_ClearOUT(), + * Pipe_ClearIN() and Pipe_ClearOUT() macros (done to allow for the detection of packets of zero length) + * - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API + * - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been + * renamed to Endpoint_ClearSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the + * Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe + * bank management API + * - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel from Curetis AG) + * - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity + * - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity + * - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway + * - Renamed the main Drivers/AT90USBXXX directory to Drivers/Peripheral, renamed the Serial_Stream driver to SerialStream + * - Fixed CDC and USBtoSerial demos freezing where buffers were full while still transmitting or receiving (thanks to Peter Hand) + * - Removed "Host_" section of the function names in ConfigDescriptor.h, as most of the routines can now be used in device mode on the + * device descriptor + * - Renamed functions in the HID parser to have a "USB_" prefix and the acronym "HID" in the name + * - Fixed incorrect HID interface class and subclass values in the Mouse and KeyboardMouse demos (thanks to Brian Dickman) + * - Capitalized the "Descriptor_Search" and "Descriptor_Search_Comp" prefixes of the values in the DSearch_Return_ErrorCodes_t and + * DSearch_Comp_Return_ErrorCodes_t enums + * - Removed "ERROR" from the enum names in the endpoint and pipe stream error code enums + * - Renamed the USB_PowerOnErrorCodes_t enum to USB_InitErrorCodes_t, renamed the POWERON_ERROR_NoUSBModeSpecified enum value to + * USB_INITERROR_NoUSBModeSpecified + * - Renamed USB_PowerOnFail event to USB_InitFailure + * - Renamed OTG.h header functions to be more consistent with the rest of the library API + * - Changed over all deprecated GCC structure tag initializers to the standardized C99 format (thanks to Mike Alexander) + * - USB_HostRequest renamed to USB_ControlRequest, entire control request header is now read into USB_ControlRequest in Device mode + * rather than having the library pass only partially read header data to the application + * - The USB_UnhandledControlPacket event has had its parameters removed, in favor of accessing the new USB_ControlRequest structure + * - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent + * - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled) + * - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE + * - Endpoint configuration is now refined to give better output when all configurations have static inputs - removed the now useless + * STATIC_ENDPOINT_CONFIGURATION compile time token + * - Fixed SPI driver init function not clearing SPI2X bit when not needed + * - Fixed PREVENT ALLOW MEDIUM REMOVAL command issuing in the MassStorageHost demo using incorrect parameters (thanks to Mike Alex) + * - Fixed MassStorageHost demo broken due to an incorrect if statement test in MassStore_GetReturnedStatus() + * - Fixed reversed signature byte ordering in the CDC bootloader (thanks to Johannes Raschke) + * - Changed PIPE_CONTROLPIPE_DEFAULT_SIZE from 8 to 64 to try to prevent problems with faulty devices which do not respect the given + * wLength value when reading in the device descriptor + * - Fixed missing semicolon in the ATAVRUSBRF01 LED board driver code (thanks to Morten Lund) + * - Changed LED board driver code to define dummy LED masks for the first four board LEDs, so that user code can be compiled for boards + * with less than four LEDs without code modifications (thanks to Morten Lund) + * - Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button + * - Serial driver now correctly calculates the baud register value when in double speed mode + * - Init function of the Serial driver is now static inline to product smaller code for the common-case of static init values + * + * + * \section Sec_ChangeLog090401 Version 090401 + * + * - Fixed MagStripe project configuration descriptor containing an unused (blank) endpoint descriptor + * - Incorporated makefile changes by Denver Gingerich to retain compatibility with stock (non-WinAVR) AVR-GCC installations + * - Fixed makefile EEPROM programming targets programming FLASH data in addition to EEPROM data + * - LUFA devices now enumerate correctly with LUFA hosts + * - Fixed Configuration Descriptor search routine freezing when a comparator returned a failure + * - Removed HID report item serial dump in the MouseHostWithParser and KeyboardHostWithParser - useful only for debugging, and + * slowed down the enumeration of HID devices too much + * - Increased the number of bits per track which can be read in the MagStripe project to 8192 when compiled for the AT90USBXXX6/7 + * - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request + * - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission + * next time the device is attached to a host. + * - Added new F_USB compile time constant to the library and makefiles, to give the raw input clock (used to feed the PLL before any + * clock prescaling is performed) frequency, so that the PLL prescale mask can be determined + * - Changed stream wait timeout counter to be 16-bit, so that very long timeout periods can be set for correct communications with + * badly designed hosts or devices which greatly exceed the USB specification limits + * - Mass Storage Host demo now uses a USB_STREAM_TIMEOUT_MS of two seconds to maintain compatibility with poorly designed devices + * - Function attribute ATTR_ALWAYSINLINE renamed to ATTR_ALWAYS_INLINE to match other function attribute macro naming conventions + * - Added ATTR_ALWAYS_INLINE attribute to several key inlined library components, to ensure they are inlined in all circumstances + * - Removed SetSystemClockPrescaler() macro, the clock_prescale_set() avr-libc macro has been corrected in recent avr-libc versions + * - Fixed incorrect/missing control status stage transfers on demos, bootloaders and applications (thanks to Nate Lawson) + * - The NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded + * to also remove parts of the Get Status chapter 9 request to further reduce code usage + * - Makefile updated to include output giving the currently selected BOARD parameter value + * - Board Dataflash driver now allows for dataflash ICs which use different shifts for setting the current page/byte address (thanks + * to Kenneth Clubb) + * - Added DataflashManager_WriteBlocks_RAM() and DataflashManager_ReadBlocks_RAM() functions to the MassStorage demo, to allow for easy + * interfacing with a FAT library for dataflash file level access + * - Corrected CDC class bootloader to fix a few bugs, changed address counter to store x2 addresses for convenience + * - Fixed typos in the SPI driver SPI_SPEED_FCPU_DIV_64 and SPI_SPEED_FCPU_DIV_128 masks (thanks to Markus Zocholl) + * - Keyboard and Mouse device demos (normal, data interrupt and fully interrupt driven) combined into unified keyboard and mouse demos + * - Keyboard and Mouse host demos (normal and data interrupt driven) combined into unified keyboard and mouse demos + * - Removed AVRISP_Programmer project due to code quality concerns + * - Fixed CDC demo not sending an empty packet after each transfer to prevent the host from buffering incoming data + * - Fixed documentation typos and preprocessor checks relating to misspellings of the USE_RAM_DESCRIPTORS token (thanks to Ian Gregg) + * - Fixed USBTask.h not conditionally including HostChapter9.h only when USB_CAN_BE_HOST is defined (thanks to Ian Gregg) + * - Fixed incorrect ADC driver init register manipulation (thanks to Tobias) + * - Added new GenericHID device demo application + * - Fixed Still Image Host SImage_SendData() function not clearing the pipe bank after sending data + * + * + * \section Sec_ChangeLog090209 Version 090209 + * + * - PWM timer mode in AudioOut demo changed to Fast PWM for speed + * - Updated Magstripe project to work with the latest hardware revision + * - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups + * - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface (thanks to + * Nate Lawson) + * - Fixed serious data corruption issue in MassStorage demo dataflash write routine + * - Added new NO_CLEARSET_FEATURE_REQUEST compile time token + * - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled + * - Fixed USB_DeviceEnumerationComplete event firing after each configuration change, rather than once after the initial configuration + * - Added ENDPOINT_DOUBLEBANK_SUPPORTED() macros to Endpoint.h, altered ENDPOINT_MAX_SIZE() to allow user to specify endpoint + * - ENDPOINT_MAX_ENDPOINTS changed to ENDPOINT_TOTAL_ENDPOINTS, PIPE_MAX_PIPES changed to PIPE_TOTAL_PIPES + * - Endpoint and Pipe non-control stream functions now ensure endpoint or pipe is ready before reading or writing + * - Changed Teensy bootloader to use a watchdog reset when exiting rather than a software jump + * - Fixed integer promotion error in MassStorage and MassStorageHost demos, corrupting read/write transfers + * - SPI_SendByte is now SPI_TransferByte, added new SPI_SendByte and SPI_ReceiveByte functions for fast one-way transfer + * - MassStorage demo changed to use new fast one-way SPI transfers to increase throughput + * - MassStorage handling of Mass Storage Reset class request improved + * - Altered MassStorage demo dataflash block read code for speed + * - Added USB_IsSuspended global flag + * - Simplified internal Dual Mode (OTG) USB library code to reduce code size + * - Extended stream timeout period to 100ms from 50ms + * - Mass Storage Host demo commands now all return an error code from the Pipe_Stream_RW_ErrorCodes_t enum + * - Added SubErrorCode parameter to the USB_DeviceEnumerationFailed event + * - VBUS drop interrupt now disabled during the manual-to-auto VBUS delivery handoff + * - Simplified low level backend so that device/host mode initialization uses the same code paths + * - Added workaround for faulty Mass Storage devices which do not implement the required GET_MAX_LUN request + * - Removed buggy Telnet application from the RNDIS demo + * - Moved Mass Storage class requests in the Mass Storage Host demo to wrapper functions in MassStoreCommands.c + * - Fixed incorrect SCSI command size value in the Request Sense command in MassStoreCommands.c + * - Added SetProtocol request to HID class non-parser Mouse and Keyboard demos to force devices to use the correct Boot Protocol + * - Added new "dfu" and "flip" programming targets to project makefiles + * - HID_PARSE_Sucessful enum member typo corrected to HID_PARSE_Successful + * - Changed COLLECTION item structures in the HID descriptor parser to include the collection's Usage Page value + * - Serial driver now sets Tx line as output, enables pull-up on Rx line + * - Fixed smaller USB AVRs raising multiple connection and disconnection events when NO_LIMITED_CONTROLLER_CONNECT is disabled + * - Added HOST_DEVICE_SETTLE_DELAY_MS to give the host delay after a device is connected before it is enumerated + * - Fixed KeyboardHostWithParser demo linking against the wrong global variables + * - Completed doxygen documentation of remaining library bootloaders, demos and projects + * - Fixed incorrect bootloader start address in the TeensyHID bootloader + * - Added HWB button whole-disk ASCII dump functionality to MassStoreHost demo + * - Replaced printf_P(PSTR("%c"), {Variable}) calls with putchar() for speed and size savings + * - Serial driver now accepts baud rates over 16-bits in size, added double speed flag option + * - Fixed incorrect callback abort return value in Pipe.c + * - Added new flip-ee and dfu-ee makefile targets (courtesy of Opendous Inc.) + * - Removed reboot-on-disconnect code from the TeensyHID bootloader, caused problems on some systems + * - Fixed AudioOutput and AudioInput demos looping on the endpoint data, rather than processing a sample at a time and returning + * each time the task runs to allow for other tasks to execute + * - Added support for the Atmel ATAVRUSBRF01 board + * - Added AVRISP Programmer Project, courtesy of Opendous Inc. + * - Fixed CDC Host demo not searching through both CDC interfaces for endpoints + * - Fixed incorrect Product String descriptor length in the DFU class bootloader + * + * + * \section Sec_ChangeLog081224 Version 081224 + * + * - MyUSB name changed to LUFA, the Lightweight USB Framework for AVRs + * - Fixed Mass Storage Host demo's MassStore_SendCommand() delay in the incorrect place + * - Fixed USBtoSerial demo not calling ReconfigureUSART() after a change in the line encoding + * - Fixed infinite loop in host mode Host-to-Device control transfers with data stages + * - HID report parser now supports devices with multiple reports in one interface via Report IDs + * - Fixed RZUSBSTICK board LED driver header incorrect macro definition order causing compile errors + * - Calling USB_Init() when the USB interface is already configured now forces a complete interface reset + * and re-enumeration - fixes MyUSB DFU bootloader not switching to app code correctly when soft reset used + * - Fixed "No newline at end of file" warning when stream callbacks are enabled + * - DFU bootloader now uses fixed signature bytes per device, rather than reading them out dynamically for size + * - Added new FIXED_CONTROL_ENDPOINT_SIZE and USE_SINGLE_DEVICE_CONFIGURATION switches to statically define certain values to + * reduce compiled binary size + * - Added new NO_LIMITED_CONTROLLER_CONNECT switch to prevent the library from trying to determine bus connection + * state from the suspension and wake up events on the smaller USB AVRs + * - Added summary of all library compile time tokens to the documentation + * - Added overview of the LUFA scheduler to the documentation + * - Removed MANUAL_PLL_CONTROL compile time token, replaced with a mask for the USB_Init() Options parameter + * - CDC bootloader now uses the correct non-far or far versions of the pgm_* functions depending on if RAMPZ is defined + * - Doxygen documentation now contains documentation on all the projects, bootloaders and most demos included with the library + * - CDC bootloader now runs user application when USB disconnected rather than waiting for a hard reset + * - MouseHostWithParser and KeyboardHostWithParser now support multiple-report devices + * - RNDIS demo can now close connections correctly using the new TCP_APP_CLOSECONNECTION() macro - used in Webserver + * - Fixed the DFU bootloader, no longer freezes up when certain files are programmed into an AVR, made reading/writing faster + * - Fixed mouse/joystick up/down movements reversed - HID mouse X/Y coordinates use a left-handed coordinate system, not a normal + * right-handed system + * - Added stub code to the CDC and USBtoSerial demos showing how to read and set the RS-232 handshake lines - not currently used in + * the demos, but the example code and supporting defines are now in place + * - Interrupts are now disabled when processing a control request in device mode, to avoid exceeding the strict control request + * timing requirements. + * - All demos now use a central StatusUpdate() function rather than direct calls to the board LED functions, so that the demos can + * easily be altered to show different LED combinations (or do something else entirely) as the demo's status changes + * - Removed LED commands from the CDC bootloader, unused by most AVR910 programming software + * - Fixed RNDIS demo ICMP ping requests echoing back incorrect data + * - Added DHCP server code to RNDIS demo, allowing for hands-free auto configuration on any PC + * - Fixed DFU bootloader PID value for the ATMEGA16U4 AVR + * - Endpoint and Pipe configuration functions now return an error code indicating success or failure + * - USB Reset in device mode now resets and disables all device endpoints + * - Added intermediate states to the host mode state machine, reducing the USB task blocking time to no more than 1ms explicitly per + * invocation when in host mode + * - Added support for the ATMEGA32U6 microcontroller + * - Added STATIC_ENDPOINT_CONFIGURATION compile time option, enabled in the bootloaders to minimize space usage + * - Removed redundant code from the USB device GetStatus() chapter 9 processing routine + * - Added new TeensyHID bootloader, compatible with the Teensy HID protocol (http://www.pjrc.com/teensy/) + * - Versions are now numbered by release dates, rather than arbitrary major/minor revision numbers + * - USB_RemoteWakeupEnabled is now correctly set and cleared by SetFeature and ClearFeature requests from the host + * - Changed prototype of GetDescriptor, so that it now returns the descriptor size (or zero if the descriptor doesn't exist) + * rather than passing the size back to the caller through a parameter and returning a boolean + * + * + * \section Sec_ChangeLog153 Version 1.5.3 - Released 2nd October, 2008 + * + * - Fixed CDC bootloader using pgmspace macros for some descriptors inappropriately + * - Updated all Mouse and Keyboard device demos to include boot protocol support (now works in BIOS) + * - Renamed bootloader directories to remove spaces, which were causing build problems on several OSes + * - Removed serial number strings from all but the MassStore demo where it is required - users were not + * modifying the code to either omit the descriptor or use a unique serial per device causing problems + * when multiple units of the same device were plugged in at the same time + * - AudioOutput and AudioInput demos now correctly silence endpoints when not enabled by the host + * - Added KeyboardMouse demo (Keyboard and Mouse functionality combined into a single demo) + * - Added DriverStubs directory to house board level driver templates, to make MyUSB compatible custom board + * driver creation easier + * - Extended MassStorage demo to support multiple LUNs, 2 by default + * - Fixed incorrect device address mask, preventing the device from enumerating with addresses larger than 63 + * - Fixed incorrect data direction mask in the GetStatus standard request, preventing it from being handled + * - Fixed incorrect GetStatus standard request for endpoints, now returns the endpoint STALL status correctly + * - Added in new USB_RemoteWakeupEnabled and USB_CurrentlySelfPowered flags rather than using fixed values + * - Added DualCDC demo to demonstrate the use of Interface Association Descriptors + * - Added pipe NAK detection and clearing API + * - Added pipe status change (NAK, STALL, etc.) interrupt API + * - Fixed MassStorageHost demo so that it no longer freezes randomly when issuing several commands in a row + * - Host demos configuration descriptor routines now return a unique error code when the returned data does + * not have a valid configuration descriptor header + * - Added Endpoint_WaitUntilReady() and Pipe_WaitUntilReady() functions + * - Stream functions now have software timeouts, timeout period can be set by the USB_STREAM_TIMEOUT_MS token + * - All demos now pass the USB.org automated Chapter 9 device compliance tests + * - All HID demos now pass the USB.org automated HID compliance tests + * - Polling interval of the interrupt endpoint in the CDC based demos changed to 0xFF to fix problems on Linux systems + * - Changed stream functions to accept a new callback function, with NO_STREAM_CALLBACKS used to disable all callbacks + * - Mass Storage demo dataflash management routines changed to use the endpoint stream functions + * - Added AVRStudio project files for each demo in addition to the existing Programmer's Notepad master project file + * - Re-added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes + * are reflected in the hardware (change was previously lost) + * + * + * \section Sec_ChangeLog152 Version 1.5.2 - Released 31st July, 2008 + * + * - Fixed SwapEndian_32() function in Common.h so that it now works correctly (wrong parameter types) + * - Updated RNDIS demo - notification endpoint is no longer blocking so that it works with faulty Linux RNDIS + * implementations (where the notification endpoint is ignored in favor of polling the control endpoint) + * - Fixed incorrect Vendor Description string return size in RNDIS demo for the OID_GEN_VENDOR_DESCRIPTION OID token + * - Added very basic TCP/IP stack and HTTP/TELNET servers to RNDIS demo + * - Fixed DFU bootloader exit causing programming software to complain about failed writes + * - Fixed DFU bootloader EEPROM programming mode wiping first flash page + * - Fixed Clear/Set Feature device standard request processing code (fixing MassStorage demo in the process) + * - Added support for the ATMEGA16U4 AVR microcontroller + * - Library license changed from LGPLv3 to MIT license + * + * + * \section Sec_ChangeLog151 Version 1.5.1 - Released 7th July, 2008 + * + * - Changed host demos to enable the host function task on the firing of the USB_DeviceEnumerationComplete event + * rather than the USB_DeviceAttached event + * - HID Usage Stack now forcefully cleared after an IN/OUT/FEATURE item has been completely processed to remove + * any referenced but not created usages + * - Changed USB_INT_DisableAllInterrupts() and USB_INT_ClearAllInterrupts(), USB_Host_GetNextDescriptorOfType(), + * USB_Host_GetNextDescriptorOfTypeBefore(), USB_Host_GetNextDescriptorOfTypeAfter() to normal functions (from inline) + * - Fixed USBtoSerial demo not sending data, only receiving + * - Fixed main makefile to make all by default, fixed MagStripe directory case to prevent case-sensitive path problems + * - ConfigDescriptor functions made normal, instead of static inline + * - Pipe/Endpoint *_Ignore_* functions changed to *_Discard_*, old names still present as aliases + * - Fixed ENDPOINT_MAX_SIZE define to be correct on limited USB controller AVRs + * - Changed endpoint and pipe size translation routines to use previous IF/ELSE IF cascade code, new algorithmic + * approach was buggy and caused problems + * - Bootloaders now compile with -fno-inline-small-functions option to reduce code size + * - Audio demos now use correct endpoint sizes for full and limited controller USB AVRs, double banking in all cases + * to be in line with the specification (isochronous endpoints MUST be double banked) + * - Added Interface Association descriptor to StdDescriptors.h, based on the relevant USB2.0 ECN + * - Fixed MIDI demo, corrected Audio Streaming descriptor to follow the MIDI-specific AS structure + * - Fixed HID class demo descriptors so that the HID interface's protocol is 0x00 (required for non-boot protocol HID + * devices) to prevent problems on hosts expecting the boot protocol functions to be supported + * - Added read/write control stream functions to Endpoint.h + * - Fixed AudioOut demo not setting port pins to inputs on USB disconnect properly + * - Added RNDISEthernet demo application + * + * + * \section Sec_ChangeLog150 Version 1.5.0 - Released 10 June, 2008 + * + * - Fixed MIDI demo, now correctly waits for the endpoint to be ready between multiple note messages + * - Added CDC Host demo application + * - Added KeyboardFullInt demo application + * - Endpoint and Pipe creation routines now mask endpoint/pipe size with the size mask, to remove transaction + * size bits not required for the routines (improves compatibility with devices) + * - Fixed AudioInput demo - now correctly sends sampled audio to the host PC + * - Fixed AudioOutput demo once more -- apparently Windows requires endpoint packets to be >=192 bytes + * - Shrunk round-robbin scheduler code slightly via the use of struct pointers rather than array indexes + * - Fixed off-by-one error when determining if the Usage Stack is full inside the HID Report parser + * - Renamed Magstripe.h to MagstripeHW.h and moved driver out of the library and into the MagStripe demo folder + * - Added preprocessor checks to enable C linkage on the library components when used with a C++ compiler + * - Added Still Image Host demo application + * - The USB device task now restores the previously selected endpoint, allowing control requests to be transparently + * handled via interrupts while other endpoints are serviced through polling + * - Fixed device signature being sent in reverse order in the CDC bootloader + * - Host demos now have a separate ConfigDescriptor.c/.h file for configuration descriptor processing + * - HostWithParser demos now have a separate HIDReport.c/.h file for HID report processing and dumping + * - Removed non-mandatory commands from MassStorage demo to save space, fixed SENSE ResponseCode value + * - CDC demos now send empty packets after sending a full one to prevent buffering issues on the host + * - Updated demo descriptors to use VID/PID values donated by Atmel + * - Added DoxyGen documentation to the source files + * - Fixed Serial_IsCharReceived() definition, was previously reversed + * - Removed separate USB_Descriptor_Language_t descriptor, USB_Descriptor_String_t is used instead + * - Removed unused Device Qualifier descriptor structure + * - Renamed the USB_CreateEndpoints event to the more appropriate USB_ConfigurationChanged + * - Fixed MassStorageHost demo reading in the block data in reverse + * - Removed outdated typedefs in StdRequestType.h, superseded by the macro masks + * - Corrected OTG.h is now included when the AVR supports both Host and Device modes, for creating OTG products + * - USB_DeviceEnumerationComplete event is now also fired when in device mode and the host has finished its enumeration + * - Interrupt driven demos now properly restore previously selected endpoint when ISR is complete + * - The value of USB_HOST_TIMEOUT_MS can now be overridden in the user project makefile to a custom fixed timeout value + * - Renamed USB_Host_SOFGeneration_* macros to more friendly USB_Host_SuspendBus(), USB_Host_ResumeBus() + * and USB_Host_IsBusSuspended() + * - Renamed *_*_Is* macros to *_Is* to make all flag checking macros consistent, Pipe_SetInterruptFreq() is now + * Pipe_SetInterruptPeriod() to use the correct terminology + * - UnicodeString member of USB_Descriptor_String_t struct changed to an ordinary int array type, so that the GCC + * Unicode strings (prefixed with an L before the opening quotation mark) can be used instead of explicit arrays + * of ASCII characters + * - Fixed Endpoint/Pipes being configured incorrectly if the maximum endpoint/pipe size for the selected USB AVR + * model was given as the bank size + * - HID device demos now use a true raw array for the HID report descriptor rather than a struct wrapped array + * - Added VERSION_BCD() macro, fixed reported HID and USB version numbers in demo descriptors + * - Cleaned up GetDescriptor device chapter 9 handler function + * - Added GET_REPORT class specific request to HID demos to make them complaint to the HID class + * - Cleaned up setting of USB_IsInitialized and USB_IsConnected values to only when needed + * - Removed Atomic.c and ISRMacro.h; the library was already only compatible with recent avr-lib-c for other reasons + * - All demos and library functions now use USB standardized names for the USB data (bRequest, wLength, etc.) + * - Added USE_NONSTANDARD_DESCRIPTOR_NAMES token to switch back to the non-standard descriptor element names + * + * + * \section Sec_ChangeLog141 Version 1.4.1 - Released 19 May, 2008 + * + * - Enhanced KeyboardWithParser demo, now prints out pressed alphanumeric characters like the standard demo + * - Fixed MassStorage demo, read/writes using non mode-10 commands now work correctly + * - Corrected version number in Version.h + * + * + * \section Sec_ChangeLog140 Version 1.4.0 - Released 5 May, 2008 + * + * - Added HID Report Parser API to the library + * - Added Mouse and Keyboard host demo applications, using the new HID report parser engine + * - Added MouseFullInt demo, which demonstrates a fully interrupt (including control requests) mouse device + * - Fixed incorrect length value in the audio control descriptor of the AudioOutput and AudioInput demos + * - Added MIDI device demo application to the library + * - Fixed problem preventing USB devices from being resumed from a suspended state + * - Added new CDC class bootloader to the library, based on the AVR109 bootloader protocol + * - Added header to each demo application indicating the mode, class, subclass, standards used and supported speed + * - Functions expecting endpoint/pipe numbers are no longer automatically masked against ENDPOINT_EPNUM_MASK or + * PIPE_PIPENUM_MASK - this should be manually added to code which requires it + * - Fixed DFU class bootloader - corrected frequency of flash page writes, greatly reducing programming time + * - Renamed AVR_HOST_GetDeviceConfigDescriptor() to USB_Host_GetDeviceConfigDescriptor() and AVR_HOST_GetNextDescriptor() + * to USB_Host_GetNextDescriptor() + * - Added new USB_Host_GetNextDescriptorOfTypeBefore() and USB_Host_GetNextDescriptorOfTypeAfter() routines + * - Moved configuration descriptor routines to MyUSB/Drivers/USB/Class/, new accompanying ConfigDescriptors.c file + * - Added new configuration descriptor comparator API for more powerful descriptor parsing, updated host demos to use the + * new comparator API + * - Fixed MassStorageHost demo capacity printout, and changed data read/write mode from little-endian to the correct + * big-endian for SCSI devices + * - Fixed macro/function naming consistency; USB_HOST is now USB_Host, USB_DEV is now USB_Device + * - Added better error reporting to host demos + * - Added 10 microsecond delay after addressing devices in host mode, to prevent control stalls + * + * + * \section Sec_ChangeLog132 Version 1.3.2 - Released April 1st, 2008 + * + * - Added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes + * are reflected in the hardware + * - Fixed CDC and USBtoSerial demos - Stream commands do not work for control endpoints, and the + * GetLineCoding request had an incorrect RequestType mask preventing it from being processed + * - Improved reliability of the USBtoSerial demo, adding a busy wait while the buffer is full + * - Device control endpoint size is now determined from the device's descriptors rather than being fixed + * - Separated out SPI code into new SPI driver in AT90USBXXX driver directory + * - Bootloader now returns correct PID for the selected USB AVR model, not just the AT90USB128X PID + * - Added support for the RZUSBSTICK board + * - Bicolour driver removed in favor of generic LEDs driver + * - Added support for the ATMEGA32U4 AVR + * - Added MANUAL_PLL_CONTROL compile time option to prevent the USB library from manipulating the PLL + * + * + * \section Sec_ChangeLog131 Version 1.3.1 - Released March 19th 2008 + * + * - Fixed USB to Serial demo - class value in the descriptors was incorrect + * - Control endpoint size changed from 64 bytes to 8 bytes to save on USB FIFO RAM and to allow low + * speed mode devices to enumerate properly + * - USB to Serial demo data endpoints changed to dual-banked 16 byte to allow the demo to work + * on USB AVRs with limited USB FIFO RAM + * - Changed demo endpoint numbers to use endpoints 3 and 4 for double banking, to allow limited + * USB device controller AVRs (AT90USB162, AT90USB82) to function correctly + * - Updated Audio Out demo to use timer 1 for AVRs lacking a timer 3 for the PWM output + * - Fixed incorrect USB_DEV_OPT_HIGHSPEED entry in the Mass Storage device demo makefile + * - Optimized Mass Storage demo for a little extra transfer speed + * - Added LED indicators to the Keyboard demo for Caps Lock, Num Lock and Scroll Lock + * - Added Endpoint_Read_Stream, Endpoint_Write_Stream, Pipe_Read_Stream and Pipe_Write_Stream functions + * (including Big and Little Endian variants) + * - Made Dataflash functions inline for speed, removed now empty Dataflash.c driver file + * - Added new SetSystemClockPrescaler() macro (thanks to Joerg Wunsch) + * - Fixed Endpoint_ClearStall() to function correctly on full USB controller AVRs (AT90USBXXX6/7) + * - Endpoint_Setup_In_Clear() and Endpoint_Setup_Out_Clear() no longer set FIFOCON, in line with the + * directives in the datasheet + * - Fixed PLL prescaler defines for all AVR models and frequencies + * - Fixed ENDPOINT_INT_IN and ENDPOINT_INT_OUT definitions + * - Added interrupt driven keyboard and mouse device demos + * - Combined USB_Device_ClearFeature and USB_Device_SetFeature requests into a single routine for code + * size savings + * - Added missing Pipe_GetCurrentPipe() macro to Pipe.h + * + * + * \section Sec_ChangeLog130 Version 1.3.0 - Released March 7th 2008 + * + * - Unnecessary control endpoint config removed from device mode + * - Fixed device standard request interpreter accidentally processing some class-specific requests + * - Added USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS compile time options to instruct the library + * to use descriptors stored in RAM or EEPROM rather than flash memory + * - All demos now disable watchdog on startup, in case it has been enabled by fuses or the bootloader + * - USB_DEV_OPT_LOWSPEED option now works correctly + * - Added ability to set the USB options statically for a binary size reduction via the USE_STATIC_OPTIONS + * compile time define + * - USB_Init no longer takes a Mode parameter if compiled for a USB device with no host mode option, or + * if forced to a particular mode via the USB_HOST_ONLY or USB_DEVICE_ONLY compile time options + * - USB_Init no longer takes an Options parameter if options statically configured by USE_STATIC_OPTIONS + * - Endpoint_Ignore_* and Pipe_Ignore_* made smaller by making the dummy variable non-volatile so that the + * compiler can throw away the result more efficiently + * - Added in an optional GroupID value to each scheduler entry, so that groups of tasks can once again be + * controlled by the new Scheduler_SetGroupTaskMode() routine + * - Added support for AT90USB162 and AT90USB82 AVR models + * - Added support for the STK525 and STK526 boards + * - Added support for custom board drivers to be supplied by selecting the board type as BOARD_USER, and + * placing board drivers in {Application Directory}/Board/ + * - PLL is now stopped and USB clock is frozen when detached from host in device mode, to save power + * - Joystick defines are now in synch with the schematics - orientation will be rotated for the USBKEY + * - Fixed USB_DEV_IsUSBSuspended() - now checks the correct register + * - Fixed data transfers to devices when in host mode + * - Renamed USB_DEV_OPT_HIGHSPEED to USB_DEV_OPT_FULLSPEED and USB_HOST_IsDeviceHighSpeed() to + * USB_HOST_IsDeviceFullSpeed() to be in line with the official USB speed names (to avoid confusion with + * the real high speed mode, which is unavailable on the USB AVRs) + * + * + * \section Sec_ChangeLog120 Version 1.2.0 - Released February 4th, 2008 + * + * - Added USB_DeviceEnumerationComplete event for host mode + * - Added new Scheduler_Init routine to prepare the scheduler, so that tasks can be started and + * stopped before the scheduler has been started (via Scheduler_Start) + * - Connection events in both Device and Host mode are now interrupt-driven, allowing the USB management + * task to be stopped when the USB is not connected to a host or device + * - All demos updated to stop the USB task when not in use via the appropriate USB events + * - Mass Storage Host demo application updated to function correctly with all USB flash disks + * - Mass Storage Host demo application now prints out the capacity and number of LUNs in the attached + * device, and prints the first block as hexadecimal numbers rather than ASCII characters + * - Endpoint and Pipe clearing routines now clear the Endpoint/Pipe interrupt and status flags + * - Shifted error handling code in the host enum state machine to a single block, to reduce code complexity + * - Added in DESCRIPTOR_TYPE, DESCRIPTOR_SIZE and DESCRIPTOR_CAST macros to make config descriptor processing + * clearer in USB hosts and DESCRIPTOR_ADDRESS for convenience in USB devices + * - Added in alloca macro to common.h, in case the user is using an old version of avr-lib-c missing the macro + * + * + * \section Sec_ChangeLog130 Version 1.1.0 - Released January 25th 2008 + * + * - Fixed DCONNI interrupt being enabled accidentally after a USB reset + * - Fixed DDISCI interrupt not being disabled when a device is not connected + * - Added workaround for powerless pull-up devices causing false disconnect interrupts + * - Added USB_DeviceEnumerationFailed event for Host mode + * - AVR_HOST_GetDeviceConfigDescriptor routine no longer modifies ConfigSizePtr if a valid buffer + * pointer is passed + * - Added ALLOCABLE_BYTES to DynAlloc, and added code to make the size of key storage variables + * dependant on size of memory parameters passed in via the user project's makefile + * - Fixed incorrect device reset routine being called in USBTask + * - Devices which do not connect within the standard 300mS are now supported + * - Removed incorrect ATTR_PURE from Scheduler_SetTaskMode(), which was preventing tasks from being + * started/stopped, as well as USB_InitTaskPointer(), which was breaking dual device/host USB projects + * - Changed scheduler to use the task name rather than IDs for setting the task mode, eliminating the + * need to have a task ID list + * - ID transition interrupt now raises the appropriate device/host disconnect event if device attached + * - Fixed double VBUS change (and VBUS -) event when detaching in device mode + * - Added ability to disable ANSI terminal codes by the defining of DISABLE_TERMINAL_CODES in makefile + * - Removed return from ConfigurePipe and ConfigureEndpoint functions - use Pipe_IsConfigured() and + * Endpoint_IsConfigured() after calling the config functions to determine success + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/CompileTimeTokens.txt b/hal/at90usb646/LUFA/DoxygenPages/CompileTimeTokens.txt index 0da5154..61c6f27 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/CompileTimeTokens.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/CompileTimeTokens.txt @@ -1,219 +1,219 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_TokenSummary Summary of Compile Tokens - * - * The following lists all the possible tokens which can be defined in a project makefile, and passed to the - * compiler via the -D switch, to alter the LUFA library code. These tokens may alter the library behaviour, - * or remove features unused by a given application in order to save flash space. - * - * \note If the \c USE_LUFA_CONFIG_HEADER token is defined, the library will include a header file named \c LUFAConfig.h located - * in the user directory where the below compile time tokens may be defined. This allows for an alternative to makefile - * defined tokens for configuring the library. - * - * \section Sec_SummaryNonUSBTokens Non USB Related Tokens - * This section describes compile tokens which affect non-USB sections of the LUFA library. - * - * - DISABLE_TERMINAL_CODES - (\ref Group_Terminal) - All Architectures \n - * If an application contains ANSI terminal control codes listed in TerminalCodes.h, it might be desired to remove them - * at compile time for use with a terminal which is non-ANSI control code aware, without modifying the source code. If - * this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from - * the source code at compile time. - * - * - * \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens - * This section describes compile tokens which affect USB class-specific drivers in the LUFA library. - * - * - HID_HOST_BOOT_PROTOCOL_ONLY - (\ref Group_USBClassHIDHost) - All Architectures \n - * By default, the USB HID Host class driver is designed to work with HID devices using either the Boot or Report HID - * communication protocols. On devices where the Report protocol is not used (i.e. in applications where only basic - * Mouse or Keyboard operation is desired, using boot compatible devices), the code responsible for the Report protocol - * mode can be removed to save space in the compiled application by defining this token. When defined, it is still necessary - * to explicitly put the attached device into Boot protocol mode via a call to \ref HID_Host_SetBootProtocol(). - * - * - HID_STATETABLE_STACK_DEPTH=x - (\ref Group_HIDParser) - All Architectures \n - * HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This - * allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous - * state table in a compact manner. This token may be defined to a non-zero 8-bit value to give the maximum depth of the state - * table stack. If not defined, this defaults to the value indicated in the HID.h file documentation. - * - * - HID_USAGE_STACK_DEPTH=x - (\ref Group_HIDParser) - All Architectures \n - * HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession - * when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with - * different usages in a compact manner. This token may be defined to a non-zero 8-bit value to set the maximum depth of the - * usage stack, indicating the maximum number of USAGE items which can be stored temporarily until the next INPUT, OUTPUT - * and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation. - * - * - HID_MAX_COLLECTIONS=x - (\ref Group_HIDParser) - All Architectures \n - * HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information - * is stored separately in the processed usage structure (and referred to by the data elements in the structure) to save space. - * This token may be defined to a non-zero 8-bit value to set the maximum number of COLLECTION items which can be processed by the - * parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file - * documentation. - * - * - HID_MAX_REPORTITEMS=x - (\ref Group_HIDParser) - All Architectures \n - * All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID - * device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which - * the report data should be interpreted by the host. This token may be defined to a non-zero 8-bit value to set the maximum number of - * data elements which can be stored in the processed HID report structure, including INPUT, OUTPUT and (if enabled) FEATURE items. - * If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed separately in the - * processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation. - * - * - HID_MAX_REPORT_IDS=x - (\ref Group_HIDParser) - All Architectures \n - * HID reports may contain several report IDs, to logically distinguish grouped device data from one another - for example, a combination - * keyboard and mouse might use report IDs to separate the keyboard reports from the mouse reports. In order to determine the size of each - * report, and thus know how many bytes must be read or written, the size of each report (IN, OUT and FEATURE) must be calculated and - * stored. This token may be defined to a non-zero 8-bit value to set the maximum number of report IDs in a device which can be processed - * and their sizes calculated/stored into the resultant processed report structure. If not defined, this defaults to the value indicated in - * the HID.h file documentation. - * - * - NO_CLASS_DRIVER_AUTOFLUSH - (\ref Group_USBClassDrivers) - All Architectures \n - * Many of the device and host mode class drivers automatically flush any data waiting to be written to an interface, when the corresponding - * USB management task is executed. This is usually desirable to ensure that any queued data is sent as soon as possible once and new data is - * constructed in the main program loop. However, if flushing is to be controlled manually by the user application via the *_Flush() commands, - * the compile time token may be defined in the application's makefile to disable automatic flushing during calls to the class driver USB - * management tasks. - * - * - * \section Sec_SummaryUSBTokens General USB Driver Related Tokens - * This section describes compile tokens which affect USB driver stack as a whole in the LUFA library. - * - * - ORDERED_EP_CONFIG - (\ref Group_EndpointManagement , \ref Group_PipeManagement) - AVR8, UC3 \n - * The USB AVRs do not allow for Endpoints and Pipes to be configured out of order; they must be configured in an ascending order to - * prevent data corruption issues. However, by default LUFA employs a workaround to allow for unordered Endpoint/Pipe initialization. This compile - * time token may be used to restrict the initialization order to ascending indexes only in exchange for a smaller compiled binary size. Use - * caution when applied to applications using the library USB Class drivers; the user application must ensure that all endpoints and pipes are - * allocated sequentially. - * - * - USE_STATIC_OPTIONS=x - (\ref Group_USBManagement) - All Architectures \n - * By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad - * voltage regulator is enabled, and the device speed when in device mode. By defining this token to a mask comprised of the USB options - * mask defines usually passed as the Options parameter to USB_Init(), the resulting compiled binary can be decreased in size by removing - * the dynamic options code, and replacing it with the statically set options. When defined, the USB_Init() function no longer accepts an - * Options parameter. - * - * - USB_DEVICE_ONLY - (\ref Group_USBManagement) - All Architectures \n - * For the USB AVR models supporting both device and host USB modes, the USB_Init() function contains a Mode parameter which specifies the - * mode the library should be initialized to. If only device mode is required, the code for USB host mode can be removed from the binary to - * save space. When defined, the USB_Init() function no longer accepts a Mode parameter. This define is irrelevant on smaller USB AVRs which - * do not support host mode. - * - * - USB_HOST_ONLY - (\ref Group_USBManagement) - All Architectures \n - * Same as USB_DEVICE_ONLY, except the library is fixed to USB host mode rather than USB device mode. Not available on some USB AVR models. - * - * - USB_STREAM_TIMEOUT_MS=x - (\ref Group_USBManagement) - All Architectures \n - * When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host - * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero 16-bit value to set the timeout - * period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead. - * - * - NO_LIMITED_CONTROLLER_CONNECT - (\ref Group_Events) - AVR8 Only \n - * On the smaller USB AVRs, the USB controller lacks VBUS events to determine the physical connection state of the USB bus to a host. In lieu of - * VBUS events, the library attempts to determine the connection state via the bus suspension and wake up events instead. This however may be - * slightly inaccurate due to the possibility of the host suspending the bus while the device is still connected. If accurate connection status is - * required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_DeviceState global - * can be accurately set and the \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events manually raised by the RAISE_EVENT macro. - * When defined, this token disables the library's auto-detection of the connection state by the aforementioned suspension and wake up events. - * - * - NO_SOF_EVENTS - (\ref Group_Events) - All Architectures \n - * By default, there exists a LUFA application event for the start of each USB frame while the USB bus is not suspended in either host or device mode. - * This event can be selectively enabled or disabled by calling the appropriate device or host mode function. When this compile time token is defined, - * the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed, - * reducing the compiled program's binary size. - * - * - * \section Sec_SummaryUSBDeviceTokens USB Device Mode Driver Related Tokens - * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Device mode. - * - * - USE_RAM_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n - * Define this token to indicate to the USB driver that all device descriptors are stored in RAM, rather than being located in any one - * of the AVR's memory spaces. RAM descriptors may be desirable in applications where the descriptors need to be modified at runtime. - * - * - USE_FLASH_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n - * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's FLASH memory rather than RAM. - * - * - USE_EEPROM_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n - * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's EEPROM memory rather than RAM. - * - * - NO_INTERNAL_SERIAL - (\ref Group_StdDescriptors) - All Architectures \n - * Some AVR models contain a unique serial number which can be used as the device serial number, while in device mode. This allows - * the host to uniquely identify the device regardless of if it is moved between USB ports on the same computer, allowing allocated - * resources (such as drivers, COM Port number allocations) to be preserved. This is not needed in many apps, and so the code that - * performs this task can be disabled by defining this option and passing it to the compiler via the -D switch. - * - * - FIXED_CONTROL_ENDPOINT_SIZE=x - (\ref Group_EndpointManagement) - All Architectures \n - * By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor. - * Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if - * descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be - * defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled - * binary. - * - * - DEVICE_STATE_AS_GPIOR - (\ref Group_Device) - AVR8 Only \n - * One of the most frequently used global variables in the stack is the USB_DeviceState global, which indicates the current state of - * the Device State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token - * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR - * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except - * implicitly via the library APIs. - * - * - FIXED_NUM_CONFIGURATIONS=x - (\ref Group_Device) - All Architectures \n - * By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces - * the amount of configuration required to set up the library, and allows the value to change dynamically (if descriptors are stored in - * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this value may be fixed via this token in the project - * makefile to reduce the compiled size of the binary at the expense of flexibility. - * - * - CONTROL_ONLY_DEVICE - (\ref Group_Device) - All Architectures \n - * In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication - * is through control endpoint requests. Defining this token will remove several features related to the selection and control of device - * endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided. - * - * - INTERRUPT_CONTROL_ENDPOINT - (\ref Group_USBManagement) - All Architectures \n - * Some applications prefer to not call the USB_USBTask() management task regularly while in device mode, as it can complicate code significantly. - * Instead, when device mode is used this token can be passed to the library via the -D switch to allow the library to manage the USB control - * endpoint entirely via USB controller interrupts asynchronously to the user application. When defined, USB_USBTask() does not need to be called - * when in USB device mode. - * - * - NO_DEVICE_REMOTE_WAKEUP - (\ref Group_Device) - All Architectures \n - * Many devices do not require the use of the Remote Wakeup features of USB, used to wake up the USB host when suspended. On these devices, - * the code required to manage device Remote Wakeup can be disabled by defining this token and passing it to the library via the -D switch. - * - * - NO_DEVICE_SELF_POWER - (\ref Group_Device) - All Architectures \n - * USB devices may be bus powered, self powered, or a combination of both. When a device can be both bus powered and self powered, the host may - * query the device to determine the current power source, via \ref USB_Device_CurrentlySelfPowered. For solely bus powered devices, this global - * and the code required to manage it may be disabled by passing this token to the library via the -D switch. - * - * - * \section Sec_SummaryUSBHostTokens USB Host Mode Driver Related Tokens - * - * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Host mode. - * - * - HOST_STATE_AS_GPIOR - (\ref Group_Host) - AVR8 Only \n - * One of the most frequently used global variables in the stack is the USB_HostState global, which indicates the current state of - * the Host State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token - * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR - * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except - * implicitly via the library APIs. - * - * - USB_HOST_TIMEOUT_MS=x - (\ref Group_Host) - All Architectures \n - * When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached - * device fails to respond within the timeout period. This token may be defined to a non-zero 16-bit value to set the timeout period for - * control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead. - * - * - HOST_DEVICE_SETTLE_DELAY_MS=x - (\ref Group_Host) - All Architectures \n - * Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or - * they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled - * back to a known idle state before communications occur with the device. This token may be defined to a 16-bit value to set the device - * settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead. - * - * - INVERTED_VBUS_ENABLE_LINE - (\ref Group_Host) - All Architectures \n - * If enabled, this will indicate that the USB target VBUS line polarity is inverted; i.e. it should be pulled low to enable VBUS to the - * target, and pulled high to stop the target VBUS generation. - * - * \note On AVR8 architecture devices, this compile time option requires \c NO_AUTO_VBUS_MANAGEMENT to be set. - * - * - NO_AUTO_VBUS_MANAGEMENT - (\ref Group_Host) - All Architectures \n - * Disables the automatic management of VBUS to the target, i.e. automatic shut down in the even of an overcurrent situation. When enabled, VBUS - * is enabled while the USB controller is initialized in USB Host mode. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_TokenSummary Summary of Compile Tokens + * + * The following lists all the possible tokens which can be defined in a project makefile, and passed to the + * compiler via the -D switch, to alter the LUFA library code. These tokens may alter the library behaviour, + * or remove features unused by a given application in order to save flash space. + * + * \note If the \c USE_LUFA_CONFIG_HEADER token is defined, the library will include a header file named \c LUFAConfig.h located + * in the user directory where the below compile time tokens may be defined. This allows for an alternative to makefile + * defined tokens for configuring the library. + * + * \section Sec_SummaryNonUSBTokens Non USB Related Tokens + * This section describes compile tokens which affect non-USB sections of the LUFA library. + * + * - DISABLE_TERMINAL_CODES - (\ref Group_Terminal) - All Architectures \n + * If an application contains ANSI terminal control codes listed in TerminalCodes.h, it might be desired to remove them + * at compile time for use with a terminal which is non-ANSI control code aware, without modifying the source code. If + * this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from + * the source code at compile time. + * + * + * \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens + * This section describes compile tokens which affect USB class-specific drivers in the LUFA library. + * + * - HID_HOST_BOOT_PROTOCOL_ONLY - (\ref Group_USBClassHIDHost) - All Architectures \n + * By default, the USB HID Host class driver is designed to work with HID devices using either the Boot or Report HID + * communication protocols. On devices where the Report protocol is not used (i.e. in applications where only basic + * Mouse or Keyboard operation is desired, using boot compatible devices), the code responsible for the Report protocol + * mode can be removed to save space in the compiled application by defining this token. When defined, it is still necessary + * to explicitly put the attached device into Boot protocol mode via a call to \ref HID_Host_SetBootProtocol(). + * + * - HID_STATETABLE_STACK_DEPTH=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This + * allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous + * state table in a compact manner. This token may be defined to a non-zero 8-bit value to give the maximum depth of the state + * table stack. If not defined, this defaults to the value indicated in the HID.h file documentation. + * + * - HID_USAGE_STACK_DEPTH=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession + * when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with + * different usages in a compact manner. This token may be defined to a non-zero 8-bit value to set the maximum depth of the + * usage stack, indicating the maximum number of USAGE items which can be stored temporarily until the next INPUT, OUTPUT + * and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation. + * + * - HID_MAX_COLLECTIONS=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information + * is stored separately in the processed usage structure (and referred to by the data elements in the structure) to save space. + * This token may be defined to a non-zero 8-bit value to set the maximum number of COLLECTION items which can be processed by the + * parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file + * documentation. + * + * - HID_MAX_REPORTITEMS=x - (\ref Group_HIDParser) - All Architectures \n + * All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID + * device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which + * the report data should be interpreted by the host. This token may be defined to a non-zero 8-bit value to set the maximum number of + * data elements which can be stored in the processed HID report structure, including INPUT, OUTPUT and (if enabled) FEATURE items. + * If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed separately in the + * processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation. + * + * - HID_MAX_REPORT_IDS=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports may contain several report IDs, to logically distinguish grouped device data from one another - for example, a combination + * keyboard and mouse might use report IDs to separate the keyboard reports from the mouse reports. In order to determine the size of each + * report, and thus know how many bytes must be read or written, the size of each report (IN, OUT and FEATURE) must be calculated and + * stored. This token may be defined to a non-zero 8-bit value to set the maximum number of report IDs in a device which can be processed + * and their sizes calculated/stored into the resultant processed report structure. If not defined, this defaults to the value indicated in + * the HID.h file documentation. + * + * - NO_CLASS_DRIVER_AUTOFLUSH - (\ref Group_USBClassDrivers) - All Architectures \n + * Many of the device and host mode class drivers automatically flush any data waiting to be written to an interface, when the corresponding + * USB management task is executed. This is usually desirable to ensure that any queued data is sent as soon as possible once and new data is + * constructed in the main program loop. However, if flushing is to be controlled manually by the user application via the *_Flush() commands, + * the compile time token may be defined in the application's makefile to disable automatic flushing during calls to the class driver USB + * management tasks. + * + * + * \section Sec_SummaryUSBTokens General USB Driver Related Tokens + * This section describes compile tokens which affect USB driver stack as a whole in the LUFA library. + * + * - ORDERED_EP_CONFIG - (\ref Group_EndpointManagement , \ref Group_PipeManagement) - AVR8, UC3 \n + * The USB AVRs do not allow for Endpoints and Pipes to be configured out of order; they must be configured in an ascending order to + * prevent data corruption issues. However, by default LUFA employs a workaround to allow for unordered Endpoint/Pipe initialization. This compile + * time token may be used to restrict the initialization order to ascending indexes only in exchange for a smaller compiled binary size. Use + * caution when applied to applications using the library USB Class drivers; the user application must ensure that all endpoints and pipes are + * allocated sequentially. + * + * - USE_STATIC_OPTIONS=x - (\ref Group_USBManagement) - All Architectures \n + * By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad + * voltage regulator is enabled, and the device speed when in device mode. By defining this token to a mask comprised of the USB options + * mask defines usually passed as the Options parameter to USB_Init(), the resulting compiled binary can be decreased in size by removing + * the dynamic options code, and replacing it with the statically set options. When defined, the USB_Init() function no longer accepts an + * Options parameter. + * + * - USB_DEVICE_ONLY - (\ref Group_USBManagement) - All Architectures \n + * For the USB AVR models supporting both device and host USB modes, the USB_Init() function contains a Mode parameter which specifies the + * mode the library should be initialized to. If only device mode is required, the code for USB host mode can be removed from the binary to + * save space. When defined, the USB_Init() function no longer accepts a Mode parameter. This define is irrelevant on smaller USB AVRs which + * do not support host mode. + * + * - USB_HOST_ONLY - (\ref Group_USBManagement) - All Architectures \n + * Same as USB_DEVICE_ONLY, except the library is fixed to USB host mode rather than USB device mode. Not available on some USB AVR models. + * + * - USB_STREAM_TIMEOUT_MS=x - (\ref Group_USBManagement) - All Architectures \n + * When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host + * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero 16-bit value to set the timeout + * period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead. + * + * - NO_LIMITED_CONTROLLER_CONNECT - (\ref Group_Events) - AVR8 Only \n + * On the smaller USB AVRs, the USB controller lacks VBUS events to determine the physical connection state of the USB bus to a host. In lieu of + * VBUS events, the library attempts to determine the connection state via the bus suspension and wake up events instead. This however may be + * slightly inaccurate due to the possibility of the host suspending the bus while the device is still connected. If accurate connection status is + * required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_DeviceState global + * can be accurately set and the \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events manually raised by the RAISE_EVENT macro. + * When defined, this token disables the library's auto-detection of the connection state by the aforementioned suspension and wake up events. + * + * - NO_SOF_EVENTS - (\ref Group_Events) - All Architectures \n + * By default, there exists a LUFA application event for the start of each USB frame while the USB bus is not suspended in either host or device mode. + * This event can be selectively enabled or disabled by calling the appropriate device or host mode function. When this compile time token is defined, + * the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed, + * reducing the compiled program's binary size. + * + * + * \section Sec_SummaryUSBDeviceTokens USB Device Mode Driver Related Tokens + * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Device mode. + * + * - USE_RAM_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n + * Define this token to indicate to the USB driver that all device descriptors are stored in RAM, rather than being located in any one + * of the AVR's memory spaces. RAM descriptors may be desirable in applications where the descriptors need to be modified at runtime. + * + * - USE_FLASH_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n + * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's FLASH memory rather than RAM. + * + * - USE_EEPROM_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n + * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's EEPROM memory rather than RAM. + * + * - NO_INTERNAL_SERIAL - (\ref Group_StdDescriptors) - All Architectures \n + * Some AVR models contain a unique serial number which can be used as the device serial number, while in device mode. This allows + * the host to uniquely identify the device regardless of if it is moved between USB ports on the same computer, allowing allocated + * resources (such as drivers, COM Port number allocations) to be preserved. This is not needed in many apps, and so the code that + * performs this task can be disabled by defining this option and passing it to the compiler via the -D switch. + * + * - FIXED_CONTROL_ENDPOINT_SIZE=x - (\ref Group_EndpointManagement) - All Architectures \n + * By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor. + * Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if + * descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be + * defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled + * binary. + * + * - DEVICE_STATE_AS_GPIOR - (\ref Group_Device) - AVR8 Only \n + * One of the most frequently used global variables in the stack is the USB_DeviceState global, which indicates the current state of + * the Device State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token + * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR + * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except + * implicitly via the library APIs. + * + * - FIXED_NUM_CONFIGURATIONS=x - (\ref Group_Device) - All Architectures \n + * By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces + * the amount of configuration required to set up the library, and allows the value to change dynamically (if descriptors are stored in + * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this value may be fixed via this token in the project + * makefile to reduce the compiled size of the binary at the expense of flexibility. + * + * - CONTROL_ONLY_DEVICE - (\ref Group_Device) - All Architectures \n + * In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication + * is through control endpoint requests. Defining this token will remove several features related to the selection and control of device + * endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided. + * + * - INTERRUPT_CONTROL_ENDPOINT - (\ref Group_USBManagement) - All Architectures \n + * Some applications prefer to not call the USB_USBTask() management task regularly while in device mode, as it can complicate code significantly. + * Instead, when device mode is used this token can be passed to the library via the -D switch to allow the library to manage the USB control + * endpoint entirely via USB controller interrupts asynchronously to the user application. When defined, USB_USBTask() does not need to be called + * when in USB device mode. + * + * - NO_DEVICE_REMOTE_WAKEUP - (\ref Group_Device) - All Architectures \n + * Many devices do not require the use of the Remote Wakeup features of USB, used to wake up the USB host when suspended. On these devices, + * the code required to manage device Remote Wakeup can be disabled by defining this token and passing it to the library via the -D switch. + * + * - NO_DEVICE_SELF_POWER - (\ref Group_Device) - All Architectures \n + * USB devices may be bus powered, self powered, or a combination of both. When a device can be both bus powered and self powered, the host may + * query the device to determine the current power source, via \ref USB_Device_CurrentlySelfPowered. For solely bus powered devices, this global + * and the code required to manage it may be disabled by passing this token to the library via the -D switch. + * + * + * \section Sec_SummaryUSBHostTokens USB Host Mode Driver Related Tokens + * + * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Host mode. + * + * - HOST_STATE_AS_GPIOR - (\ref Group_Host) - AVR8 Only \n + * One of the most frequently used global variables in the stack is the USB_HostState global, which indicates the current state of + * the Host State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token + * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR + * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except + * implicitly via the library APIs. + * + * - USB_HOST_TIMEOUT_MS=x - (\ref Group_Host) - All Architectures \n + * When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached + * device fails to respond within the timeout period. This token may be defined to a non-zero 16-bit value to set the timeout period for + * control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead. + * + * - HOST_DEVICE_SETTLE_DELAY_MS=x - (\ref Group_Host) - All Architectures \n + * Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or + * they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled + * back to a known idle state before communications occur with the device. This token may be defined to a 16-bit value to set the device + * settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead. + * + * - INVERTED_VBUS_ENABLE_LINE - (\ref Group_Host) - All Architectures \n + * If enabled, this will indicate that the USB target VBUS line polarity is inverted; i.e. it should be pulled low to enable VBUS to the + * target, and pulled high to stop the target VBUS generation. + * + * \note On AVR8 architecture devices, this compile time option requires \c NO_AUTO_VBUS_MANAGEMENT to be set. + * + * - NO_AUTO_VBUS_MANAGEMENT - (\ref Group_Host) - All Architectures \n + * Disables the automatic management of VBUS to the target, i.e. automatic shut down in the even of an overcurrent situation. When enabled, VBUS + * is enabled while the USB controller is initialized in USB Host mode. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/CompilingApps.txt b/hal/at90usb646/LUFA/DoxygenPages/CompilingApps.txt index ff34534..45cbdd6 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/CompilingApps.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/CompilingApps.txt @@ -1,30 +1,30 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_CompilingApps Compiling the Demos, Bootloaders and Projects - * - * The following details how to compile the included LUFA demos, applications and bootloaders using AVR-GCC. - * - * \section Sec_Prerequisites Prerequisites - * Before you can compile any of the LUFA library code or demos, you will need a recent distribution of avr-libc (1.6.2+) - * and the AVR-GCC (4.2+) compiler. For Windows users, the best way to obtain these is the WinAVR project - * (http://winavr.sourceforge.net) as this provides a single-file setup for everything required to compile your - * own AVR projects. - * - * \section Sec_Compiling Compiling a LUFA Application - * Compiling the LUFA demos, applications and/or bootloaders is very simple. LUFA comes with makefile scripts for - * each individual demo, bootloader and project folder, as well as scripts in the /Demos/, /Bootloaders/, /Projects/ - * and the LUFA root directory. This means that compilation can be started from any of the above directories, with - * a build started from an upper directory in the directory structure executing build of all child directories under it. - * This means that while a build inside a particular demo directory will build only that particular demo, a build stated - * from the /Demos/ directory will build all LUFA demo projects sequentially. - * - * To build a project from the source via the command line, the command "make all" should be executed from the command line in the directory - * of interest. To remove compiled files (including the binary output, all intermediately files and all diagnostic output - * files), execute "make clean". Once a "make all" has been run and no errors were encountered, the resulting binary will - * be located in the generated ".HEX" file. If your project makes use of pre-initialized EEPROM variables, the generated ".EEP" - * file will contain the project's EEPROM data. - */ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_CompilingApps Compiling the Demos, Bootloaders and Projects + * + * The following details how to compile the included LUFA demos, applications and bootloaders using AVR-GCC. + * + * \section Sec_Prerequisites Prerequisites + * Before you can compile any of the LUFA library code or demos, you will need a recent distribution of avr-libc (1.6.2+) + * and the AVR-GCC (4.2+) compiler. For Windows users, the best way to obtain these is the WinAVR project + * (http://winavr.sourceforge.net) as this provides a single-file setup for everything required to compile your + * own AVR projects. + * + * \section Sec_Compiling Compiling a LUFA Application + * Compiling the LUFA demos, applications and/or bootloaders is very simple. LUFA comes with makefile scripts for + * each individual demo, bootloader and project folder, as well as scripts in the /Demos/, /Bootloaders/, /Projects/ + * and the LUFA root directory. This means that compilation can be started from any of the above directories, with + * a build started from an upper directory in the directory structure executing build of all child directories under it. + * This means that while a build inside a particular demo directory will build only that particular demo, a build stated + * from the /Demos/ directory will build all LUFA demo projects sequentially. + * + * To build a project from the source via the command line, the command "make all" should be executed from the command line in the directory + * of interest. To remove compiled files (including the binary output, all intermediately files and all diagnostic output + * files), execute "make clean". Once a "make all" has been run and no errors were encountered, the resulting binary will + * be located in the generated ".HEX" file. If your project makes use of pre-initialized EEPROM variables, the generated ".EEP" + * file will contain the project's EEPROM data. + */ diff --git a/hal/at90usb646/LUFA/DoxygenPages/ConfiguringApps.txt b/hal/at90usb646/LUFA/DoxygenPages/ConfiguringApps.txt index 28f9507..6caf185 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/ConfiguringApps.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/ConfiguringApps.txt @@ -1,89 +1,89 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_ConfiguringApps Configuring the Demos, Bootloaders and Projects - * - * If the target microcontroller model, architecture, clock speed, board or other settings are different from the current - * settings, they must be changed and the project recompiled from the source code before being programmed into the microcontroller. - * Most project configuration options are located in the "makefile" build script inside each LUFA application's folder, however - * some demo or application-specific configuration settings (such as the output format in the AudioOut demo) are located in one or - * more of the source files of the project. See each project's individual documentation for application-specific configuration - * values. - * - * Each project "makefile" contains all the script and configuration data required to compile each project. When opened with - * any regular basic text editor such as Notepad or WordPad (ensure that the save format is a pure ASCII text format) the - * build configuration settings may be altered. - * - * Inside each makefile, a number of configuration variables are located, with the format " = ". For - * each application, the important variables which should be altered are: - * - * - MCU, the target processor model - * - ARCH, the target microcontroller architecture - * - BOARD, the target board hardware - * - F_CPU, the target CPU master clock frequency, after any prescaling - * - F_USB, the target raw input clock to the USB module of the processor - * - CDEFS, the C preprocessor defines which configure options the source code - * - LUFA_PATH, the path to the LUFA library source code - * - LUFA_OPTS, the compile time LUFA options which configure the library features - * - * These values should be changed to reflect the build hardware. - * - * \section Sec_MCU The MCU Parameter - * This parameter indicates the target microcontroller model for the compiled application. This should be set to the model of the target - * microcontroller (such as the AT90USB1287, or the ATMEGA32U4), in all lower-case (e.g. "at90usb1287"). Note that not all demos support all the - * microcontroller models and architectures, as they may make use of peripherals or modes only present in some devices. - * - * For supported processor models, see \ref Page_DeviceSupport. - * - * \section Sec_ARCH The ARCH Parameter - * This parameter indicates the target microcontroller architecture the library is to be compiled for. Different microcontroller - * architectures require different source files to be compiled into the final binary, and so this option must be set to the correct - * architecture for the selected platform. - * - * For supported processor architectures, see \ref Page_DeviceSupport. - * - * \section Sec_BOARD The BOARD Parameter - * This parameter indicates the target board hardware for the compiled application. Some LUFA library drivers are board-specific, - * such as the LED driver, and the library needs to know the layout of the target board. If you are using one of the board models listed - * on the main library page, change this parameter to the board name in all UPPER-case. - * - * If you are not using any board-specific drivers in the LUFA library, or you are using a custom board layout, change this to read - * "USER" (no quotes) instead of a standard board name. If the USER board type is selected and the application makes use of one or more - * board-specific hardware drivers inside the LUFA library, then the appropriate stub drives files should be copied from the \c /CodeTemplates/DriverStubs/ - * directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the - * custom board's hardware. - * - * For boards with built in hardware driver support within the LUFA library, see \ref Page_DeviceSupport. - * - * \section Sec_F_CPU The F_CPU Parameter - * This parameter indicates the target microcontroller's main CPU clock frequency, in Hz. This is used by many libraries (and applications) for - * timing related purposes, and should reflect the actual CPU speed after any prescaling or adjustments are performed. - * - * \section Sec_F_USB The F_USB Parameter - * This parameter indicates the raw input clock frequency to the USB module within the microcontroller in Hz. This may be very different on some platforms - * to the main CPU clock or other peripheral/bus clocks. - * - * \section Sec_CDEFS The CDEFS Parameter - * Many applications have features which can be controlled by the defining of specially named preprocessor tokens at the point of compilation - for example, - * an application might use a compile time token to turn on or off optional or mutually exclusive portions of code. Preprocessor tokens can be - * defined here by listing each one with the -D command line switch, and each token can optionally be defined to a specific value. When defined in the - * project makefile, these behave as if they were defined in every source file via a normal preprocessor define statement. - * - * Most applications will actually have multiple CDEF lines, which are concatenated together with the "+=" operator. This ensures that large - * numbers of configuration options remain readable by splitting up groups of options into separate lines. - * - * \section Sec_LUFA_PATH The LUFA_PATH Parameter - * As each LUFA program requires the LUFA library source code to compile correctly, the application must know where the LUFA library is located. This - * value specifies the path to the LUFA library base relative to the path of the project makefile. - * - * \section Sec_LUFA_OPTS The LUFA_OPTS Parameter - * This value is similar to the CDEFS parameter listed elsewhere -- indeed, it is simply a convenient place to group LUFA related tokens away from the - * application's compile time tokens. Normally, these options do not need to be altered to allow an application to compile and run correctly on a - * different board or microcontroller to the current configuration - if the options are incorrect, then the demo is most likely incompatible with the chosen - * microcontroller model and cannot be made to function through the altering of the makefile settings alone (or at all). Settings such as the USB mode - * (device, host or both), the USB interface speed and other LUFA configuration options can be set here - see \ref Page_TokenSummary documentation for details - * on the available LUFA compile time configuration options. - */ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_ConfiguringApps Configuring the Demos, Bootloaders and Projects + * + * If the target microcontroller model, architecture, clock speed, board or other settings are different from the current + * settings, they must be changed and the project recompiled from the source code before being programmed into the microcontroller. + * Most project configuration options are located in the "makefile" build script inside each LUFA application's folder, however + * some demo or application-specific configuration settings (such as the output format in the AudioOut demo) are located in one or + * more of the source files of the project. See each project's individual documentation for application-specific configuration + * values. + * + * Each project "makefile" contains all the script and configuration data required to compile each project. When opened with + * any regular basic text editor such as Notepad or WordPad (ensure that the save format is a pure ASCII text format) the + * build configuration settings may be altered. + * + * Inside each makefile, a number of configuration variables are located, with the format " = ". For + * each application, the important variables which should be altered are: + * + * - MCU, the target processor model + * - ARCH, the target microcontroller architecture + * - BOARD, the target board hardware + * - F_CPU, the target CPU master clock frequency, after any prescaling + * - F_USB, the target raw input clock to the USB module of the processor + * - CDEFS, the C preprocessor defines which configure options the source code + * - LUFA_PATH, the path to the LUFA library source code + * - LUFA_OPTS, the compile time LUFA options which configure the library features + * + * These values should be changed to reflect the build hardware. + * + * \section Sec_MCU The MCU Parameter + * This parameter indicates the target microcontroller model for the compiled application. This should be set to the model of the target + * microcontroller (such as the AT90USB1287, or the ATMEGA32U4), in all lower-case (e.g. "at90usb1287"). Note that not all demos support all the + * microcontroller models and architectures, as they may make use of peripherals or modes only present in some devices. + * + * For supported processor models, see \ref Page_DeviceSupport. + * + * \section Sec_ARCH The ARCH Parameter + * This parameter indicates the target microcontroller architecture the library is to be compiled for. Different microcontroller + * architectures require different source files to be compiled into the final binary, and so this option must be set to the correct + * architecture for the selected platform. + * + * For supported processor architectures, see \ref Page_DeviceSupport. + * + * \section Sec_BOARD The BOARD Parameter + * This parameter indicates the target board hardware for the compiled application. Some LUFA library drivers are board-specific, + * such as the LED driver, and the library needs to know the layout of the target board. If you are using one of the board models listed + * on the main library page, change this parameter to the board name in all UPPER-case. + * + * If you are not using any board-specific drivers in the LUFA library, or you are using a custom board layout, change this to read + * "USER" (no quotes) instead of a standard board name. If the USER board type is selected and the application makes use of one or more + * board-specific hardware drivers inside the LUFA library, then the appropriate stub drives files should be copied from the \c /CodeTemplates/DriverStubs/ + * directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the + * custom board's hardware. + * + * For boards with built in hardware driver support within the LUFA library, see \ref Page_DeviceSupport. + * + * \section Sec_F_CPU The F_CPU Parameter + * This parameter indicates the target microcontroller's main CPU clock frequency, in Hz. This is used by many libraries (and applications) for + * timing related purposes, and should reflect the actual CPU speed after any prescaling or adjustments are performed. + * + * \section Sec_F_USB The F_USB Parameter + * This parameter indicates the raw input clock frequency to the USB module within the microcontroller in Hz. This may be very different on some platforms + * to the main CPU clock or other peripheral/bus clocks. + * + * \section Sec_CDEFS The CDEFS Parameter + * Many applications have features which can be controlled by the defining of specially named preprocessor tokens at the point of compilation - for example, + * an application might use a compile time token to turn on or off optional or mutually exclusive portions of code. Preprocessor tokens can be + * defined here by listing each one with the -D command line switch, and each token can optionally be defined to a specific value. When defined in the + * project makefile, these behave as if they were defined in every source file via a normal preprocessor define statement. + * + * Most applications will actually have multiple CDEF lines, which are concatenated together with the "+=" operator. This ensures that large + * numbers of configuration options remain readable by splitting up groups of options into separate lines. + * + * \section Sec_LUFA_PATH The LUFA_PATH Parameter + * As each LUFA program requires the LUFA library source code to compile correctly, the application must know where the LUFA library is located. This + * value specifies the path to the LUFA library base relative to the path of the project makefile. + * + * \section Sec_LUFA_OPTS The LUFA_OPTS Parameter + * This value is similar to the CDEFS parameter listed elsewhere -- indeed, it is simply a convenient place to group LUFA related tokens away from the + * application's compile time tokens. Normally, these options do not need to be altered to allow an application to compile and run correctly on a + * different board or microcontroller to the current configuration - if the options are incorrect, then the demo is most likely incompatible with the chosen + * microcontroller model and cannot be made to function through the altering of the makefile settings alone (or at all). Settings such as the USB mode + * (device, host or both), the USB interface speed and other LUFA configuration options can be set here - see \ref Page_TokenSummary documentation for details + * on the available LUFA compile time configuration options. + */ diff --git a/hal/at90usb646/LUFA/DoxygenPages/DevelopingWithLUFA.txt b/hal/at90usb646/LUFA/DoxygenPages/DevelopingWithLUFA.txt index 1b73fa6..4ea3799 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/DevelopingWithLUFA.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/DevelopingWithLUFA.txt @@ -1,21 +1,21 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_DevelopingWithLUFA Developing With LUFA - * - * This section of the manual contains information on LUFA development, such as Getting Started information, - * information on compile-time tuning of the library and other developer-related sections. - * - * Subsections: - * \li \subpage Page_TokenSummary - Summary of Compile Time Tokens - * \li \subpage Page_Migration - Migrating from an Older LUFA Version - * \li \subpage Page_VIDPID - Allocated USB VID and PID Values - * \li \subpage Page_BuildLibrary - Building as a Linkable Library - * \li \subpage Page_WritingBoardDrivers - How to Write Custom Board Drivers - * \li \subpage Page_SoftwareBootloaderStart - How to jump to the bootloader in software - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_DevelopingWithLUFA Developing With LUFA + * + * This section of the manual contains information on LUFA development, such as Getting Started information, + * information on compile-time tuning of the library and other developer-related sections. + * + * Subsections: + * \li \subpage Page_TokenSummary - Summary of Compile Time Tokens + * \li \subpage Page_Migration - Migrating from an Older LUFA Version + * \li \subpage Page_VIDPID - Allocated USB VID and PID Values + * \li \subpage Page_BuildLibrary - Building as a Linkable Library + * \li \subpage Page_WritingBoardDrivers - How to Write Custom Board Drivers + * \li \subpage Page_SoftwareBootloaderStart - How to jump to the bootloader in software + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/DeviceSupport.txt b/hal/at90usb646/LUFA/DoxygenPages/DeviceSupport.txt index 00a11dc..ecf173a 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/DeviceSupport.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/DeviceSupport.txt @@ -1,390 +1,390 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_DeviceSupport Device and Hardware Support - * - * Atmel Microcontrollers: - * \li \subpage Page_AVR8Support - Atmel AVR8 Support - * \li \subpage Page_UC3Support - Atmel AVR32 UC3 Support - * \li \subpage Page_XMEGASupport - Atmel XMEGA Support - */ - -/** - * \page Page_AVR8Support Atmel 8-Bit AVR (AVR8) Support - * - * \section Sec_AVR8Support_Devices Supported Microcontroller Models - * - * Currently supported AVR8 models: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
PartUSB Device ModeUSB Host Mode
AT90USB82YesNo
ATMEGA8U2YesNo
AT90USB162YesNo
ATMEGA16U2YesNo
ATMEGA16U4YesNo
ATMEGA32U2YesNo
ATMEGA32U4YesNo
ATMEGA32U6YesNo
AT90USB646YesNo
AT90USB647YesYes
AT90USB1286YesNo
AT90USB1287YesYes
- * - * \section Sec_AVR8Support_Boards Supported Atmel Boards - * Currently supported Atmel AVR8 boards (see \ref Group_BoardTypes): - * - AT90USBKEY - * - ATAVRUSBRF01 - * - EVK527 - * - RZUSBSTICK - * - STK525 - * - STK526 - * - XPLAIN (Excluding the blue XPLAINED family boards) - * - * \section Sec_AVR8Support_ThirdParty Supported Third Party Models - * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): - * - Adafruit U4 Breakout Board - * - Arduino Uno - * - Busware BUI - * - Busware CUL V3 - * - Busware TUL - * - Fletchtronics Bumble-B (using manufacturer recommended peripheral layout) - * - Kernel Concepts USBFOO - * - Linnix UDIP - * - MattairTech JM-DB-U2 - * - Maximus USB - * - Micropendous Boards (many versions) - * - Microsin AVR-USB162 - * - Minimus USB - * - Olimex AVR-USB-162 - * - Paranoid Studio's US2AX (V1, V2 and V3 hardware revisions) - * - PJRC Teensy (1.x and 2.x versions) - * - Sparkfun U2 Breakout Board - * - TCNISO Blackcat USB JTAG - * - Tempusdictum Benito - * - Tom's USBTINY-MKII (all revisions and versions) - * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) - */ - -/** - * \page Page_UC3Support Atmel 32-Bit UC3 AVR (UC3) - * Note: The AVR32 UC3 device support is currently experimental, and is included for preview purposes only. - * - * \section Sec_UC3Support_Devices Supported Microcontroller Models - * - * Currently supported UC3 models: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
PartUSB Device ModeUSB Host Mode
AT32UC3A064YesYes
AT32UC3A164YesYes
AT32UC3A364YesYes
AT32UC3A364SYesYes
AT32UC3A464YesYes
AT32UC3A464SYesYes
AT32UC3B064YesYes
AT32UC3B164YesYes
AT32UC3A0128YesYes
AT32UC3A1128YesYes
AT32UC3A3128YesYes
AT32UC3A3128SYesYes
AT32UC3A4128YesYes
AT32UC3A4128SYesYes
AT32UC3B0128YesYes
AT32UC3B1128YesYes
AT32UC3A0256YesYes
AT32UC3A1256YesYes
AT32UC3A3256YesYes
AT32UC3A3256SYesYes
AT32UC3A4256YesYes
AT32UC3A4256SYesYes
AT32UC3B0256YesYes
AT32UC3B1256YesYes
AT32UC3A0512YesYes
AT32UC3A1512YesYes
AT32UC3B0512YesYes
AT32UC3B1512YesYes
- * - * \section Sec_UC3Support_Boards Supported Atmel Boards - * - * Currently supported Atmel UC3 boards (see \ref Group_BoardTypes): - * - EVK1100 - * - EVK1101 - * - EVK1104 - * - * \section Sec_UC3Support_ThirdParty Supported Third Party Models - * - * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): - * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) - */ - -/** - * \page Page_XMEGASupport Atmel USB XMEGA AVR (XMEGA) - * Note: The XMEGA device support is currently experimental (incomplete and/or non-functional), and is included for preview purposes only. - * - * \section Sec_XMEGASupport_Devices Supported Microcontroller Models - * - * Currently supported XMEGA models: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
PartUSB Device ModeUSB Host Mode
ATXMEGA16A4UYesNo
ATXMEGA32A4UYesNo
ATXMEGA64A4UYesNo
ATXMEGA128A4UYesNo
ATXMEGA64A3UYesNo
ATXMEGA128A3UYesNo
ATXMEGA192A3UYesNo
ATXMEGA256A3UYesNo
ATXMEGA256A3BUYesNo
ATXMEGA128A1UYesNo
ATXMEGA64B3YesNo
ATXMEGA128B3YesNo
ATXMEGA64B1YesNo
ATXMEGA128B1YesNo
- * - * \section Sec_XMEGASupport_Boards Supported Atmel Boards - * Currently supported Atmel XMEGA boards (see \ref Group_BoardTypes): - * - XMEGA A3BU Xplained - * - XMEGA B1 Xplained - * - * \section Sec_XMEGASupport_ThirdParty Supported Third Party Models - * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): - * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_DeviceSupport Device and Hardware Support + * + * Atmel Microcontrollers: + * \li \subpage Page_AVR8Support - Atmel AVR8 Support + * \li \subpage Page_UC3Support - Atmel AVR32 UC3 Support + * \li \subpage Page_XMEGASupport - Atmel XMEGA Support + */ + +/** + * \page Page_AVR8Support Atmel 8-Bit AVR (AVR8) Support + * + * \section Sec_AVR8Support_Devices Supported Microcontroller Models + * + * Currently supported AVR8 models: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PartUSB Device ModeUSB Host Mode
AT90USB82YesNo
ATMEGA8U2YesNo
AT90USB162YesNo
ATMEGA16U2YesNo
ATMEGA16U4YesNo
ATMEGA32U2YesNo
ATMEGA32U4YesNo
ATMEGA32U6YesNo
AT90USB646YesNo
AT90USB647YesYes
AT90USB1286YesNo
AT90USB1287YesYes
+ * + * \section Sec_AVR8Support_Boards Supported Atmel Boards + * Currently supported Atmel AVR8 boards (see \ref Group_BoardTypes): + * - AT90USBKEY + * - ATAVRUSBRF01 + * - EVK527 + * - RZUSBSTICK + * - STK525 + * - STK526 + * - XPLAIN (Excluding the blue XPLAINED family boards) + * + * \section Sec_AVR8Support_ThirdParty Supported Third Party Models + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): + * - Adafruit U4 Breakout Board + * - Arduino Uno + * - Busware BUI + * - Busware CUL V3 + * - Busware TUL + * - Fletchtronics Bumble-B (using manufacturer recommended peripheral layout) + * - Kernel Concepts USBFOO + * - Linnix UDIP + * - MattairTech JM-DB-U2 + * - Maximus USB + * - Micropendous Boards (many versions) + * - Microsin AVR-USB162 + * - Minimus USB + * - Olimex AVR-USB-162 + * - Paranoid Studio's US2AX (V1, V2 and V3 hardware revisions) + * - PJRC Teensy (1.x and 2.x versions) + * - Sparkfun U2 Breakout Board + * - TCNISO Blackcat USB JTAG + * - Tempusdictum Benito + * - Tom's USBTINY-MKII (all revisions and versions) + * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + +/** + * \page Page_UC3Support Atmel 32-Bit UC3 AVR (UC3) + * Note: The AVR32 UC3 device support is currently experimental, and is included for preview purposes only. + * + * \section Sec_UC3Support_Devices Supported Microcontroller Models + * + * Currently supported UC3 models: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PartUSB Device ModeUSB Host Mode
AT32UC3A064YesYes
AT32UC3A164YesYes
AT32UC3A364YesYes
AT32UC3A364SYesYes
AT32UC3A464YesYes
AT32UC3A464SYesYes
AT32UC3B064YesYes
AT32UC3B164YesYes
AT32UC3A0128YesYes
AT32UC3A1128YesYes
AT32UC3A3128YesYes
AT32UC3A3128SYesYes
AT32UC3A4128YesYes
AT32UC3A4128SYesYes
AT32UC3B0128YesYes
AT32UC3B1128YesYes
AT32UC3A0256YesYes
AT32UC3A1256YesYes
AT32UC3A3256YesYes
AT32UC3A3256SYesYes
AT32UC3A4256YesYes
AT32UC3A4256SYesYes
AT32UC3B0256YesYes
AT32UC3B1256YesYes
AT32UC3A0512YesYes
AT32UC3A1512YesYes
AT32UC3B0512YesYes
AT32UC3B1512YesYes
+ * + * \section Sec_UC3Support_Boards Supported Atmel Boards + * + * Currently supported Atmel UC3 boards (see \ref Group_BoardTypes): + * - EVK1100 + * - EVK1101 + * - EVK1104 + * + * \section Sec_UC3Support_ThirdParty Supported Third Party Models + * + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): + * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + +/** + * \page Page_XMEGASupport Atmel USB XMEGA AVR (XMEGA) + * Note: The XMEGA device support is currently experimental (incomplete and/or non-functional), and is included for preview purposes only. + * + * \section Sec_XMEGASupport_Devices Supported Microcontroller Models + * + * Currently supported XMEGA models: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PartUSB Device ModeUSB Host Mode
ATXMEGA16A4UYesNo
ATXMEGA32A4UYesNo
ATXMEGA64A4UYesNo
ATXMEGA128A4UYesNo
ATXMEGA64A3UYesNo
ATXMEGA128A3UYesNo
ATXMEGA192A3UYesNo
ATXMEGA256A3UYesNo
ATXMEGA256A3BUYesNo
ATXMEGA128A1UYesNo
ATXMEGA64B3YesNo
ATXMEGA128B3YesNo
ATXMEGA64B1YesNo
ATXMEGA128B1YesNo
+ * + * \section Sec_XMEGASupport_Boards Supported Atmel Boards + * Currently supported Atmel XMEGA boards (see \ref Group_BoardTypes): + * - XMEGA A3BU Xplained + * - XMEGA B1 Xplained + * + * \section Sec_XMEGASupport_ThirdParty Supported Third Party Models + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): + * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/DirectorySummaries.txt b/hal/at90usb646/LUFA/DoxygenPages/DirectorySummaries.txt index a975080..e4ef095 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/DirectorySummaries.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/DirectorySummaries.txt @@ -1,254 +1,254 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \dir LUFA/Common - * \brief Common library header files. - * - * This folder contains header files which are common to all parts of the LUFA library. They may be used freely in - * user applications. - * - * \dir LUFA/Drivers - * \brief Library hardware and software drivers. - * - * This folder contains all the library hardware and software drivers for each supported board, architecture and - * microcontroller model. - * - * \dir LUFA/Drivers/Misc - * \brief Miscellaneous driver files. - * - * This folder contains drivers for aspects other than the USB interface, board hardware or microcontroller peripherals. - * - * \dir LUFA/Drivers/Peripheral - * \brief Microcontroller peripheral driver files. - * - * This folder contains drivers for various low level microcontroller peripherals, usually located on the microcontroller - * die within the same physical chip. - * - * \dir LUFA/Drivers/USB - * \brief USB controller peripheral driver files. - * - * This folder contains the complete LUFA USB stack and controller files, including the core driver and stack, as well - * as the USB class driver implementations. - * - * \dir LUFA/Drivers/USB/Core - * \brief Core USB driver files. - * - * This folder contains the core USB stack and controller driver files, to correctly implement USB functionality on the - * target architecture and microcontroller model. This - * - * \dir LUFA/Drivers/USB/Class - * \brief USB Class helper driver files. - * - * This folder contains drivers for implementing functionality of standardized USB classes. These are not used directly by the library, - * but provide a standard and library-maintained way of implementing functionality from some of the defined USB classes without extensive - * development effort. Is is recommended that these drivers be used where possible to reduce maintenance of user applications. - * - * \dir LUFA/Drivers/USB/Class/Device - * \brief USB Device Class helper driver files. - * - * Device mode drivers for the standard USB classes. - * - * \dir LUFA/Drivers/USB/Class/Host - * \brief USB Host Class helper driver files. - * - * Host mode drivers for the standard USB classes. - * - * \dir LUFA/Drivers/Board - * \brief Board hardware driver files. - * - * This folder contains drivers for interfacing with the physical hardware on supported commercial boards, primarily from - * the Atmel corporation. Header files in this folder should be included in user applications requiring the functionality of - * hardware placed on supported boards. - * - * \dir LUFA/Drivers/Board/AVR8/ADAFRUITU4 - * \brief ADAFRUITU4 board hardware driver files. - * - * This folder contains drivers for hardware on the Adafruit U4 breakout board (http://ladyada.net/products/atmega32u4breakout). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * \dir LUFA/Drivers/Board/AVR8/ATAVRUSBRF01 - * \brief ATAVRUSBRF01 board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel ATAVRUSBRF01 board, as used in several Atmel wireless demo kits. The header - * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in - * the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/BENITO - * \brief BENITO board hardware driver files. - * - * This folder contains drivers for hardware on the Benito boards (http://dorkbotpdx.org/wiki/benito). The header files in this - * folder should not be included directly in user applications; the similarly named dispatch header files located in the parent - * Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/BUMBLEB - * \brief BUMBLEB board hardware driver files. - * - * This folder contains drivers for hardware on the Fletchtronics Bumble-B board (http://fletchtronics.net/bumble-b). The header - * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in - * the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/BUI - * \brief BUI board hardware driver files. - * - * This folder contains drivers for hardware on the Busware BUI (http://www.busware.de/tiki-index.php?page=BUI). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/BLACKCAT - * \brief BLACKCAT board hardware driver files. - * - * This folder contains drivers for hardware on the TCNISO Blackcat USB JTAG (http://www.embeddedcomputers.net/products/BlackcatUSB/. - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/CULV3 - * \brief CULV3 board hardware driver files. - * - * This folder contains drivers for hardware on the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/EVK527 - * \brief EVK527 board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel EVK527 development board. The header files in this folder should - * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory - * should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/JMDBU2 - * \brief JM-DB-U2 board hardware driver files. - * - * This folder contains drivers for hardware on the JM-DB-U2 boards (http://u2.mattair.net/). The header files in this folder - * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board - * directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/MAXIMUS - * \brief MAXIMUS board hardware driver files. - * - * This folder contains drivers for hardware on the Maximus boards (http://www.avrusb.com/). The header files in this folder - * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board - * directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/MICROSIN162 - * \brief MICROSIN162 board hardware driver files. - * - * This folder contains drivers for hardware on the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/). The - * header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/MINIMUS - * \brief MINIMUS board hardware driver files. - * - * This folder contains drivers for hardware on the Minimus boards (http://www.minimususb.com/). The header files in this folder - * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board - * directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/OLIMEX162 - * \brief Olimex USB-STK-162 board hardware driver files. - * - * This folder contains drivers for hardware on the Olimex AVR-USB-162 boards (http://www.olimex.com/dev/avr-usb-162.html). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/RZUSBSTICK - * \brief RZUSBSTICK board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel RZUSBSTICK board, as used in the Atmel "Raven" wireless kits. The header - * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in - * the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/SPARKFUN8U2 - * \brief SPARKFUN8U2 board hardware driver files. - * - * This folder contains drivers for hardware on the Sparkfun ATMEGA8U2 breakout board (http://www.sparkfun.com/products/10277). The - * header files in this folder should not be included directly in user applications; the similarly named dispatch header files located - * in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/STK525 - * \brief STK525 board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel STK525 development board. The header files in this folder should - * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory - * should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/STK526 - * \brief STK526 board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel STK526 development board. The header files in this folder should - * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory - * should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/TEENSY - * \brief TEENSY board hardware driver files. - * - * This folder contains drivers for hardware on all revisions of the PJRC Teensy boards (http://www.pjrc.com/teensy/). The header - * files in this folder should not be included directly in user applications; the similarly named dispatch header files located - * in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/TUL - * \brief TUL board hardware driver files. - * - * This folder contains drivers for hardware on the Busware TUL (http://busware.de/tiki-index.php?page=TUL). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/UDIP - * \brief UDIP board hardware driver files. - * - * This folder contains drivers for hardware on the Linnix UDIP boards (http://linnix.com/udip/). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/UNO - * \brief UNO board hardware driver files. - * - * This folder contains drivers for hardware on the Arduino Uno boards (http://www.arduino.cc). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/USBFOO - * \brief USBFOO board hardware driver files. - * - * This folder contains drivers for hardware on the USBFOO boards (http://shop.kernelconcepts.de/product_info.php?products_id=102). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/USBKEY - * \brief USBKEY board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel USBKEY demonstration board. The header files in this folder should - * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory - * should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/USBTINYMKII - * \brief USBTINY-MKII board hardware driver files. - * - * This folder contains drivers for hardware on all revisions of the USBTINY-MKII boards (http://tom-itx.dyndns.org:81/~webpage/). - * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files - * located in the parent Board directory should be included instead. - * - * \dir LUFA/Drivers/Board/AVR8/XPLAIN - * \brief XPLAIN board hardware driver files. - * - * This folder contains drivers for hardware on the Atmel XPLAIN board (all hardware revisions). The header files in this folder - * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board - * directory should be included instead. - * - * \dir LUFA/CodeTemplates - * \brief Code templates for use in LUFA powered applications. - * - * This contains code templates for board drivers, sample LUFA project makefiles and other similar templates that can be copied into - * a LUFA powered application and modified to speed up development. - * - * \dir LUFA/CodeTemplates/DriverStubs - * \brief Driver stub header files for custom boards, to allow the LUFA board drivers to operate. - * - * This contains stub files for the LUFA board drivers. If the LUFA board drivers are used with board hardware other than those - * directly supported by the library, the BOARD parameter of the application's makefile can be set to "USER", and these stub files - * copied to the "/Board/" directory of the application's folder. When fleshed out with working driver code for the custom board, - * the corresponding LUFA board APIs will work correctly with the non-standard board hardware. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \dir LUFA/Common + * \brief Common library header files. + * + * This folder contains header files which are common to all parts of the LUFA library. They may be used freely in + * user applications. + * + * \dir LUFA/Drivers + * \brief Library hardware and software drivers. + * + * This folder contains all the library hardware and software drivers for each supported board, architecture and + * microcontroller model. + * + * \dir LUFA/Drivers/Misc + * \brief Miscellaneous driver files. + * + * This folder contains drivers for aspects other than the USB interface, board hardware or microcontroller peripherals. + * + * \dir LUFA/Drivers/Peripheral + * \brief Microcontroller peripheral driver files. + * + * This folder contains drivers for various low level microcontroller peripherals, usually located on the microcontroller + * die within the same physical chip. + * + * \dir LUFA/Drivers/USB + * \brief USB controller peripheral driver files. + * + * This folder contains the complete LUFA USB stack and controller files, including the core driver and stack, as well + * as the USB class driver implementations. + * + * \dir LUFA/Drivers/USB/Core + * \brief Core USB driver files. + * + * This folder contains the core USB stack and controller driver files, to correctly implement USB functionality on the + * target architecture and microcontroller model. This + * + * \dir LUFA/Drivers/USB/Class + * \brief USB Class helper driver files. + * + * This folder contains drivers for implementing functionality of standardized USB classes. These are not used directly by the library, + * but provide a standard and library-maintained way of implementing functionality from some of the defined USB classes without extensive + * development effort. Is is recommended that these drivers be used where possible to reduce maintenance of user applications. + * + * \dir LUFA/Drivers/USB/Class/Device + * \brief USB Device Class helper driver files. + * + * Device mode drivers for the standard USB classes. + * + * \dir LUFA/Drivers/USB/Class/Host + * \brief USB Host Class helper driver files. + * + * Host mode drivers for the standard USB classes. + * + * \dir LUFA/Drivers/Board + * \brief Board hardware driver files. + * + * This folder contains drivers for interfacing with the physical hardware on supported commercial boards, primarily from + * the Atmel corporation. Header files in this folder should be included in user applications requiring the functionality of + * hardware placed on supported boards. + * + * \dir LUFA/Drivers/Board/AVR8/ADAFRUITU4 + * \brief ADAFRUITU4 board hardware driver files. + * + * This folder contains drivers for hardware on the Adafruit U4 breakout board (http://ladyada.net/products/atmega32u4breakout). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * \dir LUFA/Drivers/Board/AVR8/ATAVRUSBRF01 + * \brief ATAVRUSBRF01 board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel ATAVRUSBRF01 board, as used in several Atmel wireless demo kits. The header + * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in + * the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/BENITO + * \brief BENITO board hardware driver files. + * + * This folder contains drivers for hardware on the Benito boards (http://dorkbotpdx.org/wiki/benito). The header files in this + * folder should not be included directly in user applications; the similarly named dispatch header files located in the parent + * Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/BUMBLEB + * \brief BUMBLEB board hardware driver files. + * + * This folder contains drivers for hardware on the Fletchtronics Bumble-B board (http://fletchtronics.net/bumble-b). The header + * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in + * the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/BUI + * \brief BUI board hardware driver files. + * + * This folder contains drivers for hardware on the Busware BUI (http://www.busware.de/tiki-index.php?page=BUI). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/BLACKCAT + * \brief BLACKCAT board hardware driver files. + * + * This folder contains drivers for hardware on the TCNISO Blackcat USB JTAG (http://www.embeddedcomputers.net/products/BlackcatUSB/. + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/CULV3 + * \brief CULV3 board hardware driver files. + * + * This folder contains drivers for hardware on the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/EVK527 + * \brief EVK527 board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel EVK527 development board. The header files in this folder should + * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory + * should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/JMDBU2 + * \brief JM-DB-U2 board hardware driver files. + * + * This folder contains drivers for hardware on the JM-DB-U2 boards (http://u2.mattair.net/). The header files in this folder + * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board + * directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/MAXIMUS + * \brief MAXIMUS board hardware driver files. + * + * This folder contains drivers for hardware on the Maximus boards (http://www.avrusb.com/). The header files in this folder + * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board + * directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/MICROSIN162 + * \brief MICROSIN162 board hardware driver files. + * + * This folder contains drivers for hardware on the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/). The + * header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/MINIMUS + * \brief MINIMUS board hardware driver files. + * + * This folder contains drivers for hardware on the Minimus boards (http://www.minimususb.com/). The header files in this folder + * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board + * directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/OLIMEX162 + * \brief Olimex USB-STK-162 board hardware driver files. + * + * This folder contains drivers for hardware on the Olimex AVR-USB-162 boards (http://www.olimex.com/dev/avr-usb-162.html). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/RZUSBSTICK + * \brief RZUSBSTICK board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel RZUSBSTICK board, as used in the Atmel "Raven" wireless kits. The header + * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in + * the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/SPARKFUN8U2 + * \brief SPARKFUN8U2 board hardware driver files. + * + * This folder contains drivers for hardware on the Sparkfun ATMEGA8U2 breakout board (http://www.sparkfun.com/products/10277). The + * header files in this folder should not be included directly in user applications; the similarly named dispatch header files located + * in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/STK525 + * \brief STK525 board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel STK525 development board. The header files in this folder should + * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory + * should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/STK526 + * \brief STK526 board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel STK526 development board. The header files in this folder should + * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory + * should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/TEENSY + * \brief TEENSY board hardware driver files. + * + * This folder contains drivers for hardware on all revisions of the PJRC Teensy boards (http://www.pjrc.com/teensy/). The header + * files in this folder should not be included directly in user applications; the similarly named dispatch header files located + * in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/TUL + * \brief TUL board hardware driver files. + * + * This folder contains drivers for hardware on the Busware TUL (http://busware.de/tiki-index.php?page=TUL). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/UDIP + * \brief UDIP board hardware driver files. + * + * This folder contains drivers for hardware on the Linnix UDIP boards (http://linnix.com/udip/). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/UNO + * \brief UNO board hardware driver files. + * + * This folder contains drivers for hardware on the Arduino Uno boards (http://www.arduino.cc). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/USBFOO + * \brief USBFOO board hardware driver files. + * + * This folder contains drivers for hardware on the USBFOO boards (http://shop.kernelconcepts.de/product_info.php?products_id=102). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/USBKEY + * \brief USBKEY board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel USBKEY demonstration board. The header files in this folder should + * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory + * should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/USBTINYMKII + * \brief USBTINY-MKII board hardware driver files. + * + * This folder contains drivers for hardware on all revisions of the USBTINY-MKII boards (http://tom-itx.dyndns.org:81/~webpage/). + * The header files in this folder should not be included directly in user applications; the similarly named dispatch header files + * located in the parent Board directory should be included instead. + * + * \dir LUFA/Drivers/Board/AVR8/XPLAIN + * \brief XPLAIN board hardware driver files. + * + * This folder contains drivers for hardware on the Atmel XPLAIN board (all hardware revisions). The header files in this folder + * should not be included directly in user applications; the similarly named dispatch header files located in the parent Board + * directory should be included instead. + * + * \dir LUFA/CodeTemplates + * \brief Code templates for use in LUFA powered applications. + * + * This contains code templates for board drivers, sample LUFA project makefiles and other similar templates that can be copied into + * a LUFA powered application and modified to speed up development. + * + * \dir LUFA/CodeTemplates/DriverStubs + * \brief Driver stub header files for custom boards, to allow the LUFA board drivers to operate. + * + * This contains stub files for the LUFA board drivers. If the LUFA board drivers are used with board hardware other than those + * directly supported by the library, the BOARD parameter of the application's makefile can be set to "USER", and these stub files + * copied to the "/Board/" directory of the application's folder. When fleshed out with working driver code for the custom board, + * the corresponding LUFA board APIs will work correctly with the non-standard board hardware. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/Donating.txt b/hal/at90usb646/LUFA/DoxygenPages/Donating.txt index 4261159..ef97487 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/Donating.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/Donating.txt @@ -1,24 +1,24 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_Donating Donating to Support This Project - * - * \image html Author.jpg "Dean Camera, LUFA Developer" - * - * I am a 22 year old University student studying for a double degree in Computer Science and Electronics Engineering. - * The development and support of this library requires much effort from myself, as I am the sole developer, maintainer - * and supporter. Please consider donating a small amount to support this and my future Open Source projects - All - * donations are greatly appreciated. - * - * Note that commercial entities can remove the attribution portion of the LUFA license by a one-time fee - see - * \ref Page_LicenseInfo for more details (Note: Please do NOT pay this in advance through the donation link below - - * contact author for payment details.). - * - * \image html "http://www.pledgie.com/campaigns/6927.png?skin_name=chrome" - * Donate to this project via PayPal - Thanks in Advance! - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_Donating Donating to Support This Project + * + * \image html Author.jpg "Dean Camera, LUFA Developer" + * + * I am a 22 year old University student studying for a double degree in Computer Science and Electronics Engineering. + * The development and support of this library requires much effort from myself, as I am the sole developer, maintainer + * and supporter. Please consider donating a small amount to support this and my future Open Source projects - All + * donations are greatly appreciated. + * + * Note that commercial entities can remove the attribution portion of the LUFA license by a one-time fee - see + * \ref Page_LicenseInfo for more details (Note: Please do NOT pay this in advance through the donation link below - + * contact author for payment details.). + * + * \image html "http://www.pledgie.com/campaigns/6927.png?skin_name=chrome" + * Donate to this project via PayPal - Thanks in Advance! + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/FutureChanges.txt b/hal/at90usb646/LUFA/DoxygenPages/FutureChanges.txt index 058a09a..a8e83b1 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/FutureChanges.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/FutureChanges.txt @@ -1,48 +1,48 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - - /** \page Page_FutureChanges Future Changes - * - * Below is a list of future changes which are proposed for the LUFA library, but not yet started/complete. - * This gives an unordered list of future changes which may be available in future releases of the library. - * If you have an item to add to this list, please contact the library author via email, the LUFA mailing list, - * or post your suggestion as an enhancement request to the project bug tracker. - * - * Targeted for Future Releases: - * - Code Features - * -# Add hub support when in Host mode for multiple devices - * -# Investigate virtual hubs when in device mode instead of composite devices - * -# Change makefiles to allow for absolute LUFA location to be used - * -# Re-add interrupt Pipe/Endpoint support - * -# Add makefile includes to reduce boilerplate in user makefiles - * -# Update stream APIs to use DMA transfers on supported architectures - * -# Pull out third party libraries into a separate folder and reference them as required - * -# Add a LUFA_YIELD macro for integration into a third-party RTOS - * -# Abstract out Mass Storage byte send/receive to prevent low level API use in projects - * -# Consider switch from endpoint numbers to full endpoint addresses to ease future architecture expansion - * -# Fix HID report parser usage support for array types - * -# Make HOST_DEVICE_SETTLE_DELAY_MS a global variable that can be changed - * -# Add MANDATORY_EVENT_FUNCTIONS compile time option - * -# Add watchdog support to the library and apps/bootloaders - * -# Re-run USBIF test suite on all classes to formally verify operation - * - Documentation/Support - * -# Add detailed overviews of how each demo works - * -# Add board overviews - * -# Write LUFA tutorials - * - Demos/Projects - * -# Device/Host USB bridge - * -# Finish incomplete demos and projects - * -# Add class driver support for Test and Measurement class - * -# Add class driver support for EEM class - * -# Add class driver support for ECM class - * -# Port all demos to multiple architectures - * - Ports - * -# Finish USB XMEGA port - * -# Add AVR32 UC3C, UC3D and UC3L support - * -# Atmel ARM7 series microcontrollers - * -# Other (commercial) C compilers - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + + /** \page Page_FutureChanges Future Changes + * + * Below is a list of future changes which are proposed for the LUFA library, but not yet started/complete. + * This gives an unordered list of future changes which may be available in future releases of the library. + * If you have an item to add to this list, please contact the library author via email, the LUFA mailing list, + * or post your suggestion as an enhancement request to the project bug tracker. + * + * Targeted for Future Releases: + * - Code Features + * -# Add hub support when in Host mode for multiple devices + * -# Investigate virtual hubs when in device mode instead of composite devices + * -# Change makefiles to allow for absolute LUFA location to be used + * -# Re-add interrupt Pipe/Endpoint support + * -# Add makefile includes to reduce boilerplate in user makefiles + * -# Update stream APIs to use DMA transfers on supported architectures + * -# Pull out third party libraries into a separate folder and reference them as required + * -# Add a LUFA_YIELD macro for integration into a third-party RTOS + * -# Abstract out Mass Storage byte send/receive to prevent low level API use in projects + * -# Consider switch from endpoint numbers to full endpoint addresses to ease future architecture expansion + * -# Fix HID report parser usage support for array types + * -# Make HOST_DEVICE_SETTLE_DELAY_MS a global variable that can be changed + * -# Add MANDATORY_EVENT_FUNCTIONS compile time option + * -# Add watchdog support to the library and apps/bootloaders + * -# Re-run USBIF test suite on all classes to formally verify operation + * - Documentation/Support + * -# Add detailed overviews of how each demo works + * -# Add board overviews + * -# Write LUFA tutorials + * - Demos/Projects + * -# Device/Host USB bridge + * -# Finish incomplete demos and projects + * -# Add class driver support for Test and Measurement class + * -# Add class driver support for EEM class + * -# Add class driver support for ECM class + * -# Port all demos to multiple architectures + * - Ports + * -# Finish USB XMEGA port + * -# Add AVR32 UC3C, UC3D and UC3L support + * -# Atmel ARM7 series microcontrollers + * -# Other (commercial) C compilers + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/GettingStarted.txt b/hal/at90usb646/LUFA/DoxygenPages/GettingStarted.txt index cc936ab..ab460cb 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/GettingStarted.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/GettingStarted.txt @@ -1,27 +1,27 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_GettingStarted Getting Started - * - * Out of the box, LUFA contains a large number of pre-made class demos for you to test, experiment with and - * ultimately build upon for your own projects. All the demos (where possible) come pre-configured to build and - * run correctly on the AT90USB1287 AVR microcontroller, mounted on the Atmel USBKEY board and running at an 8MHz - * master clock. This is due to two reasons; one, it is the hardware the author possesses, and two, it is the most - * popular Atmel USB demonstration board to date. To learn how to reconfigure, recompile and program the included - * LUFA applications using different settings, see the subsections below. - * - * Most of the included demos in the /Demos/ folder come in both ClassDriver and LowLevel varieties. If you are new - * to LUFA, it is highly recommended that you look at the ClassDriver versions first, which use the pre-made USB - * Class Drivers (\ref Group_USBClassDrivers) to simplify the use of the standard USB classes in user applications. - * - * For an overview of the included library applications, bootloaders and demos, see \ref Page_LibraryApps. - * - * Subsections: - * \li \subpage Page_ConfiguringApps - How to Configure the Included Demos, Projects and Bootloaders - * \li \subpage Page_CompilingApps - How to Compile the Included Demos, Projects and Bootloaders - * \li \subpage Page_ProgrammingApps - How to Program an AVR with the Included Demos, Projects and Bootloaders - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_GettingStarted Getting Started + * + * Out of the box, LUFA contains a large number of pre-made class demos for you to test, experiment with and + * ultimately build upon for your own projects. All the demos (where possible) come pre-configured to build and + * run correctly on the AT90USB1287 AVR microcontroller, mounted on the Atmel USBKEY board and running at an 8MHz + * master clock. This is due to two reasons; one, it is the hardware the author possesses, and two, it is the most + * popular Atmel USB demonstration board to date. To learn how to reconfigure, recompile and program the included + * LUFA applications using different settings, see the subsections below. + * + * Most of the included demos in the /Demos/ folder come in both ClassDriver and LowLevel varieties. If you are new + * to LUFA, it is highly recommended that you look at the ClassDriver versions first, which use the pre-made USB + * Class Drivers (\ref Group_USBClassDrivers) to simplify the use of the standard USB classes in user applications. + * + * For an overview of the included library applications, bootloaders and demos, see \ref Page_LibraryApps. + * + * Subsections: + * \li \subpage Page_ConfiguringApps - How to Configure the Included Demos, Projects and Bootloaders + * \li \subpage Page_CompilingApps - How to Compile the Included Demos, Projects and Bootloaders + * \li \subpage Page_ProgrammingApps - How to Program an AVR with the Included Demos, Projects and Bootloaders + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/Groups.txt b/hal/at90usb646/LUFA/DoxygenPages/Groups.txt index 281e450..321779d 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/Groups.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/Groups.txt @@ -1,43 +1,43 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \defgroup Group_BoardDrivers Board Drivers - * - * Functions, macros, variables, enums and types related to the control of physical board hardware. - */ - -/** \defgroup Group_PeripheralDrivers On-chip Peripheral Drivers - * - * Functions, macros, variables, enums and types related to the control of AVR subsystems. - */ - -/** \defgroup Group_MiscDrivers Miscellaneous Drivers - * - * Miscellaneous driver Functions, macros, variables, enums and types. - */ - -/** \defgroup Group_PlatformDrivers System Platform Drivers - * - * Drivers relating to the general architecture platform, such as clock setup and interrupt management. - */ - -/** \defgroup Group_PlatformDrivers_AVR8 AVR8 - * \ingroup Group_PlatformDrivers - * - * Drivers relating to the AVR8 architecture platform, such as clock setup and interrupt management. - */ - -/** \defgroup Group_PlatformDrivers_XMEGA XMEGA - * \ingroup Group_PlatformDrivers - * - * Drivers relating to the XMEGA architecture platform, such as clock setup and interrupt management. - */ - -/** \defgroup Group_PlatformDrivers_UC3 UC3 - * \ingroup Group_PlatformDrivers - * - * Drivers relating to the UC3 architecture platform, such as clock setup and interrupt management. - */ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \defgroup Group_BoardDrivers Board Drivers + * + * Functions, macros, variables, enums and types related to the control of physical board hardware. + */ + +/** \defgroup Group_PeripheralDrivers On-chip Peripheral Drivers + * + * Functions, macros, variables, enums and types related to the control of AVR subsystems. + */ + +/** \defgroup Group_MiscDrivers Miscellaneous Drivers + * + * Miscellaneous driver Functions, macros, variables, enums and types. + */ + +/** \defgroup Group_PlatformDrivers System Platform Drivers + * + * Drivers relating to the general architecture platform, such as clock setup and interrupt management. + */ + +/** \defgroup Group_PlatformDrivers_AVR8 AVR8 + * \ingroup Group_PlatformDrivers + * + * Drivers relating to the AVR8 architecture platform, such as clock setup and interrupt management. + */ + +/** \defgroup Group_PlatformDrivers_XMEGA XMEGA + * \ingroup Group_PlatformDrivers + * + * Drivers relating to the XMEGA architecture platform, such as clock setup and interrupt management. + */ + +/** \defgroup Group_PlatformDrivers_UC3 UC3 + * \ingroup Group_PlatformDrivers + * + * Drivers relating to the UC3 architecture platform, such as clock setup and interrupt management. + */ diff --git a/hal/at90usb646/LUFA/DoxygenPages/LUFAPoweredProjects.txt b/hal/at90usb646/LUFA/DoxygenPages/LUFAPoweredProjects.txt index ad923c9..d15ade2 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/LUFAPoweredProjects.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/LUFAPoweredProjects.txt @@ -1,156 +1,156 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_LUFAPoweredProjects User Projects Powered by LUFA - * - * LUFA is currently in use all around the world, in many applications both commercial and non-commercial. Below is a - * list of known public LUFA powered projects, which all use the LUFA library in some way. Feel free to visit each project's - * home page for more information on each project. - * - * If you have a project that you would like to add to this list, please contact me via the details on the main page of this - * documentation. - * - * \section Sec_BoardsUsingLUFA AVR-USB Development Boards Using LUFA - * - * The following is a list of known AVR USB development boards, which recommend using LUFA for the USB stack. Some of these - * are open design, and all are available for purchase as completed development boards suitable for project development. - * - * - AVR-USB-162, a USBKEY-like development board for the AT90USB162: http://olimex.com/dev/avr-usb-162.html - * - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/wiki/benito - * - JM-DB-U2, an ATMEGA32U2 development board: http://u2.mattair.net/index.html - * - Micropendous, an open design/source set of AVR USB development boards: http://micropendous.org/ - * - Microsin AVR-USB162 breakout board, a DIY AT90USB162 development board: http://microsin.ru/content/view/685/44/ - * - Minimus USB, a board specially designed for PSGroove: http://www.minimususb.com/ - * - Nanduino, a do-it-yourself AT90USB162 board: http://www.makestuff.eu/wordpress/?page_id=569 - * - Sparkfun ATMEGA8U2 breakout board: http://www.sparkfun.com/products/10277 - * - Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html - * - U2DIL/U4DIL, a set of DIP layout USB AVR boards: http://www.reworld.eu/re/en/products/u2dil/ - * - USB2AX, a tiny USB to serial converter board: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX - * - USBFOO 2, AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102 - * - * \section Sec_LUFAProjects Projects Using LUFA (Hobbyist) - * - * The following are known hobbyist projects using LUFA. Most are open source, and show off interesting ways that the LUFA library - * can be incorporated into many different applications. - * - * - Accelerometer Game Joystick: http://www.crictor.co.il/he/episodes/joystick/ - * - Arcade Controller: http://fletchtronics.net/arcade-controller-made-petunia - * - Arcade Joystick: http://jamie.lentin.co.uk/embedded/arcade-joystick/ - * - AVR USB Modem, a 3G Wireless Modem host: http://code.google.com/p/avrusbmodem/ - * - Bicycle POV: http://www.code.google.com/p/bicycleledpov/ - * - Bluetooth Explorerbot: http://code.google.com/p/bluetooth-explorerbot/ - * - Bus Ninja, an AVR clone of the popular BusPirate project: http://blog.hodgepig.org/busninja/ - * - CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig - * - CD Driver Emulator Dongle for ISO Files: http://cdemu.blogspot.com/ - * - ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/ - * - Collection of alternative Arduino Uno firmwares: http://hunt.net.nz/users/darran/ - * - Computer controlled LED matrix (Russian): http://we.easyelectronics.ru/AVR/nebolshoy-primer-s-lufa-hidapi.html - * - CULFW, a 868MHz RF packet encoder/decoder: http://www.koeniglich.de/culfw/culfw.html - * - Dashkey, a custom PC keyboard controller: http://geekhack.org/showwiki.php?title=Island:19096 - * - DIY PS3 controller emulator: https://code.google.com/p/diyps3controller/ - * - EMuSer, a USB-RS422 adapter for E-Mu samplers: http://www.emxp.net/EMuSer.htm - * - Estick JTAG, an ARM JTAG debugger: http://code.google.com/p/estick-jtag/ - * - "Fingerlicking Wingdinger" (WARNING: Bad language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/ - * - Flyatar, a real-time fly tracking system: https://github.com/peterpolidoro/Flyatar - * - Gamecube controller to USB adapter: https://www.facebook.com/media/set/?set=a.10150202447076304.310536.688776303&l=df53851c50 - * - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master - * - Generic HID Device Creator: http://generichid.sourceforge.net/ - * - Generic HID Open Source Framework: http://www.waitingforfriday.com/index.php/USB_Generic_HID_Open_Source_Framework_for_Atmel_AVR_and_Windows - * - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/ - * - Hiduino, a USB-MIDI replacement firmware for the Arduino Uno: http://code.google.com/p/hiduino/ - * - Ikea RGB LED USB modification: http://slashhome.se/p/projects/id/ikea_dioder_usb/#project - * - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html - * - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm - * - Linux Secure Storage Dongle: http://github.com/TomMD/teensy - * - LUFA powered DDR dance mat (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:ddr_repair - * - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g - * - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster - * - MIDI Theremin: http://baldwisdom.com/usb-midi-controller-theremin-style-on-arduino-uno/ - * - MIDI interface hack of a toy Guitar: http://blog.x37v.info/2011/06/26/toy-guitar-hacked-midi-conroller - * - MiniBloq, a graphical Ardunio programming environment : http://minibloq.org/ - * - MiXley, a port of the Teacup 3D printer firmware for the USB AVRs: http://codaset.com/michielh/mixley - * - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3 - * - Moco, a native Arduino Uno MIDI replacement firmware: http://web.mac.com/kuwatay/morecat_lab./MocoLUFA.html - * - Motherboard BIOS flasher: http://www.coreboot.org/InSystemFlasher - * - Multi-button Joystick (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:joystick - * - Music Playing Alarm Clock (Tutorial): http://www.instructables.com/id/Music-Playing-Alarm-Clock/ - * - NeroJTAG, a JTAG dongle: https://github.com/makestuff/neroJtag - * - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm - * - Nikon wireless camera remote control (Norwegian): http://hekta.org/~hpe1119/ - * - Opendous-JTAG, an open source ARM JTAG debugger: http://code.google.com/p/opendous-jtag/ - * - Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/ - * - Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm - * - Programmable keyboard controller: http://41j.com/blog/2011/10/a-programmable-keyboard-controller/ - * - Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/ - * - PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove - * - PS/2 to USB adapter: https://github.com/makestuff/p2ukbd - * - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ - * - RF Transciever using the MRF49XA: http://alternet.us.com/?page_id=1494 - * - SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/ - * - SDR1, a Software Defined Radio firmware: https://code.google.com/p/sdr-mk1/ - * - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 - * - Serial Line bus analyser: http://www.pjrc.com/teensy/projects/SerialAnalyzer.html - * - Smartcard Detective: https://code.google.com/p/smartcarddetective/ - * - SmartportVHD Apple II Mass Storage adapter: http://pcedric3.free.fr/SmartportVHD/ - * - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/ - * - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/ - * - Stylophone, with USB MIDI connectivity: http://www.waitingforfriday.com/index.php/Stylophone_Studio_5 - * - Teensy SD Card .WAV file player: http://elasticsheep.com/2010/04/teensy2-usb-wav-player-part-1/ - * - Touchscreen Input Device: http://capnstech.blogspot.com/2010/07/touchscreen-update.html - * - Universal USB AVR Module: http://usbavr.bplaced.net/ - * - USB2AX, a USB to Dynamixel network adapter: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX - * - USB Infrared Receiver/Transmitter: http://vaton4.web2001.cz/ - * - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001 - * - USB MIDI to DMX controller: http://github.com/hanshuebner/miDiMX - * - USB powered Geiger Counter: http://uhrheber.wordpress.com/2011/04/28/a-usb-powered-geiger-counter-for-the-z2-and-other-computers/ - * - Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/ - * - Wireless MIDI Guitar system: http://www.ise.pw.edu.pl/~wzab/wireless_guitar_system/ - * - Xnormidi, a C MIDI library: http://x37v.info/projects/xnormidi - * - XUM1541, a Commodore 64 floppy drive to USB adapter: http://www.root.org/~nate/c64/xum1541/ - * - Zeus, a touch screen computer for music manipulation: http://www.benbengler.com/developments_zeus.html - * - * \section Sec_LUFACommercialProjects Projects Using LUFA (Commercial) - * - * The following is a list of known commercial products using LUFA. Some of these are open source, although many are "black-box" - * solutions with no source code given. Those companies which have purchased a Commercial License to LUFA (see \ref Page_LicenseInfo) - * are not listed here unless specifically requested. - * - * - Arduino Uno, the official Arduino board: http://www.arduino.cc - * - ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en - * - CFFA3000, a CompactFlash interface for the Apple II: http://www.dreher.net/CFforAppleII - * - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/ - * - FinchRobot, a robot designed for educational use: http://www.finchrobot.com/ - * - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR - * - PIR-1, an IR control interface for consumer electronics: http://www.promixis.com/pir-1.php - * - PIR-4, a USB Connected 4 port IR transmitter: http://promixis.com/pir-4.php - * - KeyGlove, an alternative input system: http://www.keyglove.net/ - * - Many of Busware's Products: http://www.busware.de/ - * - MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/ - * - Norduino, a wireless Arduino: http://norduino.robomotic.com/norduino-is-now-usb-hid/ - * - Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org - * - RFI21.1EU UHF RFID reader: http://www.metra.cz/rfid/uhf-rfid-ctecky/rfi21-1eu-uhf-rfid-ctecka.htm - * - SmartCardDetective, a Smart Card analysis tool: http://www.smartcarddetective.com/ - * - USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php - * - VMeter, a USB MIDI touch strip controller: http://www.vmeter.net/ - * - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/ - * - Zeptoprog, a multifunction AVR programmer: http://www.mattairtech.com/index.php/featured/zeptoprog.html - * - * \section Sec_LUFAPublications Publications Mentioning LUFA - * - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue - * - Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue - * - Elektor Magazine, "20 x Open Source" by Jens Nickel, March 2010 Issue - * - Circuit Cellar Magazine, "Advanced USB Design Debugging" by Collin O'Flynn, August 2010 Issue - * - * \section Sec_PortsAndForks Non-Official LUFA Ports and Forks - * - NXP's official "nxpusblib" LUFA fork, for LPC devices: http://www.lpcware.com/content/project/nxpusblib - * - Kevin Mehall's LUFA port to the NXP LPC13xx: https://github.com/kevinmehall/LUFA-LPC13xx - * - * \section Sec_LUFANotableMentions Other Notable Mentions of LUFA - * - Adafruit "Ask an Engineer", 7th November 2010 - * - Arduino 2010 Keynote speech - * - The Amp Hour podcast blog #11 - * - Blackhat 2011 conference, "Exploiting USB Devices with Arduino" - */ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_LUFAPoweredProjects User Projects Powered by LUFA + * + * LUFA is currently in use all around the world, in many applications both commercial and non-commercial. Below is a + * list of known public LUFA powered projects, which all use the LUFA library in some way. Feel free to visit each project's + * home page for more information on each project. + * + * If you have a project that you would like to add to this list, please contact me via the details on the main page of this + * documentation. + * + * \section Sec_BoardsUsingLUFA AVR-USB Development Boards Using LUFA + * + * The following is a list of known AVR USB development boards, which recommend using LUFA for the USB stack. Some of these + * are open design, and all are available for purchase as completed development boards suitable for project development. + * + * - AVR-USB-162, a USBKEY-like development board for the AT90USB162: http://olimex.com/dev/avr-usb-162.html + * - Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/wiki/benito + * - JM-DB-U2, an ATMEGA32U2 development board: http://u2.mattair.net/index.html + * - Micropendous, an open design/source set of AVR USB development boards: http://micropendous.org/ + * - Microsin AVR-USB162 breakout board, a DIY AT90USB162 development board: http://microsin.ru/content/view/685/44/ + * - Minimus USB, a board specially designed for PSGroove: http://www.minimususb.com/ + * - Nanduino, a do-it-yourself AT90USB162 board: http://www.makestuff.eu/wordpress/?page_id=569 + * - Sparkfun ATMEGA8U2 breakout board: http://www.sparkfun.com/products/10277 + * - Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html + * - U2DIL/U4DIL, a set of DIP layout USB AVR boards: http://www.reworld.eu/re/en/products/u2dil/ + * - USB2AX, a tiny USB to serial converter board: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX + * - USBFOO 2, AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102 + * + * \section Sec_LUFAProjects Projects Using LUFA (Hobbyist) + * + * The following are known hobbyist projects using LUFA. Most are open source, and show off interesting ways that the LUFA library + * can be incorporated into many different applications. + * + * - Accelerometer Game Joystick: http://www.crictor.co.il/he/episodes/joystick/ + * - Arcade Controller: http://fletchtronics.net/arcade-controller-made-petunia + * - Arcade Joystick: http://jamie.lentin.co.uk/embedded/arcade-joystick/ + * - AVR USB Modem, a 3G Wireless Modem host: http://code.google.com/p/avrusbmodem/ + * - Bicycle POV: http://www.code.google.com/p/bicycleledpov/ + * - Bluetooth Explorerbot: http://code.google.com/p/bluetooth-explorerbot/ + * - Bus Ninja, an AVR clone of the popular BusPirate project: http://blog.hodgepig.org/busninja/ + * - CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig + * - CD Driver Emulator Dongle for ISO Files: http://cdemu.blogspot.com/ + * - ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/ + * - Collection of alternative Arduino Uno firmwares: http://hunt.net.nz/users/darran/ + * - Computer controlled LED matrix (Russian): http://we.easyelectronics.ru/AVR/nebolshoy-primer-s-lufa-hidapi.html + * - CULFW, a 868MHz RF packet encoder/decoder: http://www.koeniglich.de/culfw/culfw.html + * - Dashkey, a custom PC keyboard controller: http://geekhack.org/showwiki.php?title=Island:19096 + * - DIY PS3 controller emulator: https://code.google.com/p/diyps3controller/ + * - EMuSer, a USB-RS422 adapter for E-Mu samplers: http://www.emxp.net/EMuSer.htm + * - Estick JTAG, an ARM JTAG debugger: http://code.google.com/p/estick-jtag/ + * - "Fingerlicking Wingdinger" (WARNING: Bad language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/ + * - Flyatar, a real-time fly tracking system: https://github.com/peterpolidoro/Flyatar + * - Gamecube controller to USB adapter: https://www.facebook.com/media/set/?set=a.10150202447076304.310536.688776303&l=df53851c50 + * - Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master + * - Generic HID Device Creator: http://generichid.sourceforge.net/ + * - Generic HID Open Source Framework: http://www.waitingforfriday.com/index.php/USB_Generic_HID_Open_Source_Framework_for_Atmel_AVR_and_Windows + * - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/ + * - Hiduino, a USB-MIDI replacement firmware for the Arduino Uno: http://code.google.com/p/hiduino/ + * - Ikea RGB LED USB modification: http://slashhome.se/p/projects/id/ikea_dioder_usb/#project + * - IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html + * - LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm + * - Linux Secure Storage Dongle: http://github.com/TomMD/teensy + * - LUFA powered DDR dance mat (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:ddr_repair + * - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g + * - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster + * - MIDI Theremin: http://baldwisdom.com/usb-midi-controller-theremin-style-on-arduino-uno/ + * - MIDI interface hack of a toy Guitar: http://blog.x37v.info/2011/06/26/toy-guitar-hacked-midi-conroller + * - MiniBloq, a graphical Ardunio programming environment : http://minibloq.org/ + * - MiXley, a port of the Teacup 3D printer firmware for the USB AVRs: http://codaset.com/michielh/mixley + * - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3 + * - Moco, a native Arduino Uno MIDI replacement firmware: http://web.mac.com/kuwatay/morecat_lab./MocoLUFA.html + * - Motherboard BIOS flasher: http://www.coreboot.org/InSystemFlasher + * - Multi-button Joystick (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:joystick + * - Music Playing Alarm Clock (Tutorial): http://www.instructables.com/id/Music-Playing-Alarm-Clock/ + * - NeroJTAG, a JTAG dongle: https://github.com/makestuff/neroJtag + * - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm + * - Nikon wireless camera remote control (Norwegian): http://hekta.org/~hpe1119/ + * - Opendous-JTAG, an open source ARM JTAG debugger: http://code.google.com/p/opendous-jtag/ + * - Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/ + * - Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm + * - Programmable keyboard controller: http://41j.com/blog/2011/10/a-programmable-keyboard-controller/ + * - Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/ + * - PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove + * - PS/2 to USB adapter: https://github.com/makestuff/p2ukbd + * - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ + * - RF Transciever using the MRF49XA: http://alternet.us.com/?page_id=1494 + * - SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/ + * - SDR1, a Software Defined Radio firmware: https://code.google.com/p/sdr-mk1/ + * - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 + * - Serial Line bus analyser: http://www.pjrc.com/teensy/projects/SerialAnalyzer.html + * - Smartcard Detective: https://code.google.com/p/smartcarddetective/ + * - SmartportVHD Apple II Mass Storage adapter: http://pcedric3.free.fr/SmartportVHD/ + * - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/ + * - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/ + * - Stylophone, with USB MIDI connectivity: http://www.waitingforfriday.com/index.php/Stylophone_Studio_5 + * - Teensy SD Card .WAV file player: http://elasticsheep.com/2010/04/teensy2-usb-wav-player-part-1/ + * - Touchscreen Input Device: http://capnstech.blogspot.com/2010/07/touchscreen-update.html + * - Universal USB AVR Module: http://usbavr.bplaced.net/ + * - USB2AX, a USB to Dynamixel network adapter: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX + * - USB Infrared Receiver/Transmitter: http://vaton4.web2001.cz/ + * - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001 + * - USB MIDI to DMX controller: http://github.com/hanshuebner/miDiMX + * - USB powered Geiger Counter: http://uhrheber.wordpress.com/2011/04/28/a-usb-powered-geiger-counter-for-the-z2-and-other-computers/ + * - Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/ + * - Wireless MIDI Guitar system: http://www.ise.pw.edu.pl/~wzab/wireless_guitar_system/ + * - Xnormidi, a C MIDI library: http://x37v.info/projects/xnormidi + * - XUM1541, a Commodore 64 floppy drive to USB adapter: http://www.root.org/~nate/c64/xum1541/ + * - Zeus, a touch screen computer for music manipulation: http://www.benbengler.com/developments_zeus.html + * + * \section Sec_LUFACommercialProjects Projects Using LUFA (Commercial) + * + * The following is a list of known commercial products using LUFA. Some of these are open source, although many are "black-box" + * solutions with no source code given. Those companies which have purchased a Commercial License to LUFA (see \ref Page_LicenseInfo) + * are not listed here unless specifically requested. + * + * - Arduino Uno, the official Arduino board: http://www.arduino.cc + * - ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en + * - CFFA3000, a CompactFlash interface for the Apple II: http://www.dreher.net/CFforAppleII + * - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/ + * - FinchRobot, a robot designed for educational use: http://www.finchrobot.com/ + * - Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR + * - PIR-1, an IR control interface for consumer electronics: http://www.promixis.com/pir-1.php + * - PIR-4, a USB Connected 4 port IR transmitter: http://promixis.com/pir-4.php + * - KeyGlove, an alternative input system: http://www.keyglove.net/ + * - Many of Busware's Products: http://www.busware.de/ + * - MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/ + * - Norduino, a wireless Arduino: http://norduino.robomotic.com/norduino-is-now-usb-hid/ + * - Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org + * - RFI21.1EU UHF RFID reader: http://www.metra.cz/rfid/uhf-rfid-ctecky/rfi21-1eu-uhf-rfid-ctecka.htm + * - SmartCardDetective, a Smart Card analysis tool: http://www.smartcarddetective.com/ + * - USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php + * - VMeter, a USB MIDI touch strip controller: http://www.vmeter.net/ + * - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/ + * - Zeptoprog, a multifunction AVR programmer: http://www.mattairtech.com/index.php/featured/zeptoprog.html + * + * \section Sec_LUFAPublications Publications Mentioning LUFA + * - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue + * - Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue + * - Elektor Magazine, "20 x Open Source" by Jens Nickel, March 2010 Issue + * - Circuit Cellar Magazine, "Advanced USB Design Debugging" by Collin O'Flynn, August 2010 Issue + * + * \section Sec_PortsAndForks Non-Official LUFA Ports and Forks + * - NXP's official "nxpusblib" LUFA fork, for LPC devices: http://www.lpcware.com/content/project/nxpusblib + * - Kevin Mehall's LUFA port to the NXP LPC13xx: https://github.com/kevinmehall/LUFA-LPC13xx + * + * \section Sec_LUFANotableMentions Other Notable Mentions of LUFA + * - Adafruit "Ask an Engineer", 7th November 2010 + * - Arduino 2010 Keynote speech + * - The Amp Hour podcast blog #11 + * - Blackhat 2011 conference, "Exploiting USB Devices with Arduino" + */ diff --git a/hal/at90usb646/LUFA/DoxygenPages/LUFAvsAtmelStack.txt b/hal/at90usb646/LUFA/DoxygenPages/LUFAvsAtmelStack.txt index 2daca8b..239c277 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/LUFAvsAtmelStack.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/LUFAvsAtmelStack.txt @@ -1,52 +1,52 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_LUFAvsAtmelStack LUFA vs the Atmel 8-bit USB AVR Stack - * - * Atmel offers an official 8-bit USB AVR stack, which may be incorporated into user projects and products. As LUFA and the Atmel - * stack aims to give roughly the same functionality to a design, it is often asked what advantages LUFA carries over the official - * Atmel USB stack for the 8-bit USB AVRs. Below are just some of the advantages to choosing LUFA over the official Atmel stack. - * - * - Licensing: - * LUFA is released under a very permissive MIT license (see \ref Page_LicenseInfo), while the Atmel stack carries several - * restrictions as to how and where it can be used. LUFA's licensing should be suitable for both Commercial and Non-Commercial - * entities alike. - * - * - Demos and Projects: - * Unlike the Atmel stack, LUFA comes with many different Device and Host mode Demos and Projects ready to run out of the box. - * Atmel favors separate downloads for each of their (small set) of USB AVR demos, which requires more time and offers less - * to the end-user. LUFA also contains several open source Bootloaders, which can be modified as the user wishes to suit his or - * her application, instead of being forced to use Atmel's single prebuilt (closed-source) DFU bootloader. - * - * - Central Library Code: - * LUFA is designed to allow the central library core code to be shared amongst several projects, so long as the compiled object - * files are cleaned between different projects. This is in direct contrast to the Atmel library, which is strongly coupled to the - * project it is integrated with. Using LUFA allows for only one copy of the library core to be needed for all applications, and - * makes updating the library used in all projects a trivial copy-and-paste process. - * - * - Clean API: - * One of the main design goals of LUFA is to make the API easy to use. While LUFA is a fluid project which has undergone many - * API improvements, the API is arguably much nicer to use and easier to understand than the equivalent Atmel stack code. LUFA's - * API is also more complete than the Atmel stack, and contains many features to speed up application development. - * - * - Full Hardware Support: - * LUFA supports the full range of Atmel's USB AVR microcontrollers (see \ref Page_DeviceSupport), with porting between chips being - * as simple as a single compile switch in many cases. Atmel's stack requires different libraries to be used based on the USB AVR - * microcontroller series, complicating the process of moving between USB AVR models. In addition, LUFA contains drivers for all the - * hardware contained on Atmel's USB AVR based boards, so you can get started quickly and easily. - * - * - Better Library Support: - * As many people are now using LUFA, there is a community being built around it. You can get answers to your LUFA related questions - * quickly by either emailing the library author (subject to author's schedule) or by posting to the official LUFA support mailing list. - * - * - More Compact Code: - * LUFA is written from the ground up to compile optimally, using clean code and good design. Two demos giving the same functionality - - * the LUFA Low Level API Mouse Demo vs. the Atmel AVR270 HID Mouse application note shows LUFA to be the clear size winner *. - * - * * LUFA Low Level Mouse Demo: 3510 bytes, Atmel AVR270 Mouse Application Note: 4222 bytes, using an identical build environment. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_LUFAvsAtmelStack LUFA vs the Atmel 8-bit USB AVR Stack + * + * Atmel offers an official 8-bit USB AVR stack, which may be incorporated into user projects and products. As LUFA and the Atmel + * stack aims to give roughly the same functionality to a design, it is often asked what advantages LUFA carries over the official + * Atmel USB stack for the 8-bit USB AVRs. Below are just some of the advantages to choosing LUFA over the official Atmel stack. + * + * - Licensing: + * LUFA is released under a very permissive MIT license (see \ref Page_LicenseInfo), while the Atmel stack carries several + * restrictions as to how and where it can be used. LUFA's licensing should be suitable for both Commercial and Non-Commercial + * entities alike. + * + * - Demos and Projects: + * Unlike the Atmel stack, LUFA comes with many different Device and Host mode Demos and Projects ready to run out of the box. + * Atmel favors separate downloads for each of their (small set) of USB AVR demos, which requires more time and offers less + * to the end-user. LUFA also contains several open source Bootloaders, which can be modified as the user wishes to suit his or + * her application, instead of being forced to use Atmel's single prebuilt (closed-source) DFU bootloader. + * + * - Central Library Code: + * LUFA is designed to allow the central library core code to be shared amongst several projects, so long as the compiled object + * files are cleaned between different projects. This is in direct contrast to the Atmel library, which is strongly coupled to the + * project it is integrated with. Using LUFA allows for only one copy of the library core to be needed for all applications, and + * makes updating the library used in all projects a trivial copy-and-paste process. + * + * - Clean API: + * One of the main design goals of LUFA is to make the API easy to use. While LUFA is a fluid project which has undergone many + * API improvements, the API is arguably much nicer to use and easier to understand than the equivalent Atmel stack code. LUFA's + * API is also more complete than the Atmel stack, and contains many features to speed up application development. + * + * - Full Hardware Support: + * LUFA supports the full range of Atmel's USB AVR microcontrollers (see \ref Page_DeviceSupport), with porting between chips being + * as simple as a single compile switch in many cases. Atmel's stack requires different libraries to be used based on the USB AVR + * microcontroller series, complicating the process of moving between USB AVR models. In addition, LUFA contains drivers for all the + * hardware contained on Atmel's USB AVR based boards, so you can get started quickly and easily. + * + * - Better Library Support: + * As many people are now using LUFA, there is a community being built around it. You can get answers to your LUFA related questions + * quickly by either emailing the library author (subject to author's schedule) or by posting to the official LUFA support mailing list. + * + * - More Compact Code: + * LUFA is written from the ground up to compile optimally, using clean code and good design. Two demos giving the same functionality - + * the LUFA Low Level API Mouse Demo vs. the Atmel AVR270 HID Mouse application note shows LUFA to be the clear size winner *. + * + * * LUFA Low Level Mouse Demo: 3510 bytes, Atmel AVR270 Mouse Application Note: 4222 bytes, using an identical build environment. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/LibraryApps.txt b/hal/at90usb646/LUFA/DoxygenPages/LibraryApps.txt index 4c6fad1..76dea8b 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/LibraryApps.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/LibraryApps.txt @@ -1,128 +1,128 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_LibraryApps Included Library Applications - * - * The LUFA library ships with several different host and device demos, located in the /Demos/ subdirectory. Within this - * directory the demos are separated by USB mode (Device, Host, OTG) and further separated by the use or non-use of the - * library USB Class drivers (which abstract out the actual implementation of the USB classes to simplify development even - * further at the expense of a loss of flexibility). - * - * With one or two exceptions (e.g. proprietary classes such as RNDIS) all the included demos will work across all OSes without - * the need for special drivers. On Windows, some demos require the supplied .INF file to be used as the device driver, which - * directs the OS to use its inbuilt class drivers for the device. - * - * Also included with the library are two fully functional bootloaders, located in the /Bootloaders/ subdirectory. - * The DFU class bootloader is compatible with Atmel's FLIP software or the open source dfu-programmer project, while - * the CDC class (AVR109 protocol) is compatible with such open source software as AVRDUDE and AVR-OSP. - * - * User-submitted projects are located in the /Projects/ subdirectory. If you wish to have your LUFA project included, - * please email it to the Library author. - * - * \section Sec_AppOverview Overview of Included Library Applications - * The following shows the folder structure of the included library applications, including demos, bootloaders and user-submitted - * open source projects. - * - * - * - * - Demos - * - Device - * - ClassDriver - * - AudioInput - Audio In (microphone) demo, using the library USB Audio Class driver framework - * - AudioOutput - Audio Out (speaker) demo, using the library USB Audio Class driver framework - * - DualVirtualSerial - Dual Virtual Serial Port demo, using the library USB CDC Class driver framework - * - GenericHID - Generic Human Interface Class demo, using the library USB HID Class driver framework - * - Joystick - USB Joystick demo, using the library USB HID Class driver framework - * - Keyboard - USB Keyboard demo, using the library USB HID Class driver framework - * - KeyboardMouse - Dual Keyboard/Mouse demo, using the library USB HID Class driver framework - * - KeyboardMouseMultiReport - Multi HID report Keyboard/Mouse demo, using the library USB HID Class driver framework - * - MassStorage - Dual Drive Mass Storage demo, using the library USB Mass Storage Class driver framework - * - MassStorageKeyboard - Mass Storage and Keyboard demo, using the library USB Mass Storage/HID Class driver frameworks - * - MIDI - MIDI In demo, using the library USB MIDI-Audio Class driver framework - * - Mouse - USB Mouse demo, using the library USB HID driver framework - * - RNDISEthernet - RNDIS Ethernet Webserver demo, using the library USB RNDIS driver framework - * - VirtualSerial - Virtual Serial Port demo, using the library USB CDC Class driver framework - * - VirtualSerialMassStorage - Virtual Serial Port and Mass Storage demo, using the library USB CDC and Mass Storage Class driver frameworks - * - VirtualSerialMouse - Virtual Serial Port and Mouse demo, using the library USB CDC and HID Class driver frameworks - * - LowLevel - * - AudioInput - Audio In (microphone) demo, using the low level LUFA APIs to implement the USB Audio class - * - AudioOutput - Audio Out (speaker) demo, using the low level LUFA APIs to implement the USB Audio class - * - DualVirtualSerial - Dual Virtual Serial Port demo, using the low level LUFA APIs to implement the USB CDC class - * - GenericHID - Generic Human Interface Class demo, using the low level LUFA APIs to implement the USB HID class - * - Joystick - USB Joystick demo, using the low level LUFA APIs to implement the USB HID class - * - Keyboard - USB Keyboard demo, using the low level LUFA APIs to implement the USB HID class - * - KeyboardMouse - Dual Keyboard/Mouse demo, using the low level LUFA APIs to implement the USB HID class - * - MassStorage - Dual Drive Mass Storage demo, using the low level LUFA APIs to implement the USB Mass Storage class - * - MIDI - MIDI In demo, using the low level LUFA APIs to implement the USB MIDI-Audio class - * - Mouse - USB Mouse demo, using the low level LUFA APIs to implement the USB HID class - * - RNDISEthernet - RNDIS Ethernet Webserver demo, using the low level LUFA APIs to implement the USB RNDIS class - * - VirtualSerial - Virtual Serial Port demo, using the low level LUFA APIs to implement the USB CDC class - * - Incomplete - * - SideShow - Incomplete Windows SideShow demo, using the low level LUFA APIs to implement the USB SideShow class - * - TestAndMeasurement - Incomplete Test and Measurement demo, using the low level LUFA APIs to implement the USB Test and - * Measurement class - * - Host - * - ClassDriver - * - AndroidAccessoryHost - Android Accessory host demo, using the library USB Android Open Accessory Class driver framework - * - AudioInputHost - Audio Input host demo, using the library USB Audio Class driver framework - * - AudioOutputHost - Audio Output host demo, using the library USB Audio Class driver framework - * - JoystickHostWithParser - Joystick host demo with HID Descriptor parser, using the library USB HID Class driver framework - * - KeyboardHost - USB Keyboard host demo, using the library USB HID Class driver framework - * - KeyboardHostWithParser - USB Keyboard host demo with HID Descriptor parser, using the library USB HID Class - * driver framework - * - MassStorageHost - Mass Storage host demo, using the library USB Mass Storage Class driver framework - * - MouseHost - Mouse host demo, using the library USB HID Class driver framework - * - MouseHostWithParser - Mouse host demo with HID Descriptor parser, using the library USB HID Class driver framework - * - RNDISHost - RNDIS Ethernet host demo, using the library USB RNDIS Class driver framework - * - StillImageHost - Still Image Camera host demo, using the library USB Still Image Class driver framework - * - VirtualSerialHost - Virtual Serial Port host demo, using the library USB CDC Class driver framework - * - LowLevel - * - AndroidAccessoryHost - Android Accessory host demo, using the low level LUFA APIs to implement the Android Open Accessory class - * - AudioInputHost - Audio Input host demo, using the low level LUFA APIs to implement the USB Audio class - * - AudioOutputHost - Audio Output host demo, using the low level LUFA APIs to implement the USB Audio class - * - GenericHIDHost - Generic HID host demo, using the low level LUFA APIs to implement the USB HID class - * - JoystickHostWithParser - Joystick host demo with HID Descriptor parser, using the low level LUFA APIs to implement - * the USB HID class - * - KeyboardHost - USB Keyboard host demo, using the low level LUFA APIs to implement the USB HID class - * - KeyboardHostWithParser - USB Keyboard host demo with HID Descriptor parser, using the low level LUFA APIs to - * implement the USB HID class - * - MassStorageHost - Mass Storage host demo, using the low level LUFA APIs to implement the USB Mass Storage class - * - MouseHost - Mouse host demo, using the low level LUFA APIs to implement the USB HID class - * - MouseHostWithParser - Mouse host demo with HID Descriptor parser, using the low level LUFA APIs to implement the - * USB HID class - * - PrinterHost - Printer host demo, using the low level LUFA APIs to implement the USB Printer class - * - RNDISHost - RNDIS Ethernet host demo, using the low level LUFA APIs to implement the RNDIS class - * - StillImageHost - Still Image Camera host demo, using the low level LUFA APIs to implement the USB Still Image class - * - VirtualSerialHost - Virtual Serial Port host demo, using the low level LUFA APIs to implement the USB CDC class - * - Incomplete - * - BluetoothHost - Incomplete Bluetooth host demo, using the low level LUFA APIs to implement the USB Bluetooth class - * - DualRole - * - ClassDriver - * - MouseHostDevice - Dual role Mouse Host and Mouse Device demo, using the library USB CDC Class driver framework - * - Bootloaders - * - CDC - CDC Class USB bootloader, compatible with any AVR910 protocol programming software such as AVRDude - * - DFU - DFU Class USB bootloader, compatible with Atmel's FLIP and the open source dfu-programmer software - * - HID - HID Class USB bootloader, compatible with a modified PJRC TeensyHID protocol loader application software - * - Projects - * - AVRISP-MKII - AVRISP-MKII Programmer Clone project - * - Benito - Benito Board Arduino Programmer project - * - HIDReportViewer - HID Device Report Viewer project - * - LEDNotifier - USB LED Notification project - * - Magstripe - Magnetic Stripe Card Reader project - * - MediaController - Media Playback Controller project - * - MIDIToneGenerator - MIDI Note Tone Generator project - * - MissileLaucher - Toy Missile Launcher Host project - * - RelayBoard - Relay board controller, controllable via the "sismpctl" Linux application - * - TempDataLogger - Temperature Datalogging project, using the FatFS library - * - USBtoSerial - USB to USART Serial Converter project - * - Webserver - RNDIS Host Webserver with DHCP client, powered by uIP TCP/IP stack project and FatFS library - * - XPLAINBridge - XPLAIN alternative PDI Programmer/USB to Serial Bridge firmware project - * - Incomplete - * - StandaloneProgrammer - Incomplete Standalone AVR Programmer application, to program AVRs directly from a Mass Storage disk - * - * - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_LibraryApps Included Library Applications + * + * The LUFA library ships with several different host and device demos, located in the /Demos/ subdirectory. Within this + * directory the demos are separated by USB mode (Device, Host, OTG) and further separated by the use or non-use of the + * library USB Class drivers (which abstract out the actual implementation of the USB classes to simplify development even + * further at the expense of a loss of flexibility). + * + * With one or two exceptions (e.g. proprietary classes such as RNDIS) all the included demos will work across all OSes without + * the need for special drivers. On Windows, some demos require the supplied .INF file to be used as the device driver, which + * directs the OS to use its inbuilt class drivers for the device. + * + * Also included with the library are two fully functional bootloaders, located in the /Bootloaders/ subdirectory. + * The DFU class bootloader is compatible with Atmel's FLIP software or the open source dfu-programmer project, while + * the CDC class (AVR109 protocol) is compatible with such open source software as AVRDUDE and AVR-OSP. + * + * User-submitted projects are located in the /Projects/ subdirectory. If you wish to have your LUFA project included, + * please email it to the Library author. + * + * \section Sec_AppOverview Overview of Included Library Applications + * The following shows the folder structure of the included library applications, including demos, bootloaders and user-submitted + * open source projects. + * + * + * + * - Demos + * - Device + * - ClassDriver + * - AudioInput - Audio In (microphone) demo, using the library USB Audio Class driver framework + * - AudioOutput - Audio Out (speaker) demo, using the library USB Audio Class driver framework + * - DualVirtualSerial - Dual Virtual Serial Port demo, using the library USB CDC Class driver framework + * - GenericHID - Generic Human Interface Class demo, using the library USB HID Class driver framework + * - Joystick - USB Joystick demo, using the library USB HID Class driver framework + * - Keyboard - USB Keyboard demo, using the library USB HID Class driver framework + * - KeyboardMouse - Dual Keyboard/Mouse demo, using the library USB HID Class driver framework + * - KeyboardMouseMultiReport - Multi HID report Keyboard/Mouse demo, using the library USB HID Class driver framework + * - MassStorage - Dual Drive Mass Storage demo, using the library USB Mass Storage Class driver framework + * - MassStorageKeyboard - Mass Storage and Keyboard demo, using the library USB Mass Storage/HID Class driver frameworks + * - MIDI - MIDI In demo, using the library USB MIDI-Audio Class driver framework + * - Mouse - USB Mouse demo, using the library USB HID driver framework + * - RNDISEthernet - RNDIS Ethernet Webserver demo, using the library USB RNDIS driver framework + * - VirtualSerial - Virtual Serial Port demo, using the library USB CDC Class driver framework + * - VirtualSerialMassStorage - Virtual Serial Port and Mass Storage demo, using the library USB CDC and Mass Storage Class driver frameworks + * - VirtualSerialMouse - Virtual Serial Port and Mouse demo, using the library USB CDC and HID Class driver frameworks + * - LowLevel + * - AudioInput - Audio In (microphone) demo, using the low level LUFA APIs to implement the USB Audio class + * - AudioOutput - Audio Out (speaker) demo, using the low level LUFA APIs to implement the USB Audio class + * - DualVirtualSerial - Dual Virtual Serial Port demo, using the low level LUFA APIs to implement the USB CDC class + * - GenericHID - Generic Human Interface Class demo, using the low level LUFA APIs to implement the USB HID class + * - Joystick - USB Joystick demo, using the low level LUFA APIs to implement the USB HID class + * - Keyboard - USB Keyboard demo, using the low level LUFA APIs to implement the USB HID class + * - KeyboardMouse - Dual Keyboard/Mouse demo, using the low level LUFA APIs to implement the USB HID class + * - MassStorage - Dual Drive Mass Storage demo, using the low level LUFA APIs to implement the USB Mass Storage class + * - MIDI - MIDI In demo, using the low level LUFA APIs to implement the USB MIDI-Audio class + * - Mouse - USB Mouse demo, using the low level LUFA APIs to implement the USB HID class + * - RNDISEthernet - RNDIS Ethernet Webserver demo, using the low level LUFA APIs to implement the USB RNDIS class + * - VirtualSerial - Virtual Serial Port demo, using the low level LUFA APIs to implement the USB CDC class + * - Incomplete + * - SideShow - Incomplete Windows SideShow demo, using the low level LUFA APIs to implement the USB SideShow class + * - TestAndMeasurement - Incomplete Test and Measurement demo, using the low level LUFA APIs to implement the USB Test and + * Measurement class + * - Host + * - ClassDriver + * - AndroidAccessoryHost - Android Accessory host demo, using the library USB Android Open Accessory Class driver framework + * - AudioInputHost - Audio Input host demo, using the library USB Audio Class driver framework + * - AudioOutputHost - Audio Output host demo, using the library USB Audio Class driver framework + * - JoystickHostWithParser - Joystick host demo with HID Descriptor parser, using the library USB HID Class driver framework + * - KeyboardHost - USB Keyboard host demo, using the library USB HID Class driver framework + * - KeyboardHostWithParser - USB Keyboard host demo with HID Descriptor parser, using the library USB HID Class + * driver framework + * - MassStorageHost - Mass Storage host demo, using the library USB Mass Storage Class driver framework + * - MouseHost - Mouse host demo, using the library USB HID Class driver framework + * - MouseHostWithParser - Mouse host demo with HID Descriptor parser, using the library USB HID Class driver framework + * - RNDISHost - RNDIS Ethernet host demo, using the library USB RNDIS Class driver framework + * - StillImageHost - Still Image Camera host demo, using the library USB Still Image Class driver framework + * - VirtualSerialHost - Virtual Serial Port host demo, using the library USB CDC Class driver framework + * - LowLevel + * - AndroidAccessoryHost - Android Accessory host demo, using the low level LUFA APIs to implement the Android Open Accessory class + * - AudioInputHost - Audio Input host demo, using the low level LUFA APIs to implement the USB Audio class + * - AudioOutputHost - Audio Output host demo, using the low level LUFA APIs to implement the USB Audio class + * - GenericHIDHost - Generic HID host demo, using the low level LUFA APIs to implement the USB HID class + * - JoystickHostWithParser - Joystick host demo with HID Descriptor parser, using the low level LUFA APIs to implement + * the USB HID class + * - KeyboardHost - USB Keyboard host demo, using the low level LUFA APIs to implement the USB HID class + * - KeyboardHostWithParser - USB Keyboard host demo with HID Descriptor parser, using the low level LUFA APIs to + * implement the USB HID class + * - MassStorageHost - Mass Storage host demo, using the low level LUFA APIs to implement the USB Mass Storage class + * - MouseHost - Mouse host demo, using the low level LUFA APIs to implement the USB HID class + * - MouseHostWithParser - Mouse host demo with HID Descriptor parser, using the low level LUFA APIs to implement the + * USB HID class + * - PrinterHost - Printer host demo, using the low level LUFA APIs to implement the USB Printer class + * - RNDISHost - RNDIS Ethernet host demo, using the low level LUFA APIs to implement the RNDIS class + * - StillImageHost - Still Image Camera host demo, using the low level LUFA APIs to implement the USB Still Image class + * - VirtualSerialHost - Virtual Serial Port host demo, using the low level LUFA APIs to implement the USB CDC class + * - Incomplete + * - BluetoothHost - Incomplete Bluetooth host demo, using the low level LUFA APIs to implement the USB Bluetooth class + * - DualRole + * - ClassDriver + * - MouseHostDevice - Dual role Mouse Host and Mouse Device demo, using the library USB CDC Class driver framework + * - Bootloaders + * - CDC - CDC Class USB bootloader, compatible with any AVR910 protocol programming software such as AVRDude + * - DFU - DFU Class USB bootloader, compatible with Atmel's FLIP and the open source dfu-programmer software + * - HID - HID Class USB bootloader, compatible with a modified PJRC TeensyHID protocol loader application software + * - Projects + * - AVRISP-MKII - AVRISP-MKII Programmer Clone project + * - Benito - Benito Board Arduino Programmer project + * - HIDReportViewer - HID Device Report Viewer project + * - LEDNotifier - USB LED Notification project + * - Magstripe - Magnetic Stripe Card Reader project + * - MediaController - Media Playback Controller project + * - MIDIToneGenerator - MIDI Note Tone Generator project + * - MissileLaucher - Toy Missile Launcher Host project + * - RelayBoard - Relay board controller, controllable via the "sismpctl" Linux application + * - TempDataLogger - Temperature Datalogging project, using the FatFS library + * - USBtoSerial - USB to USART Serial Converter project + * - Webserver - RNDIS Host Webserver with DHCP client, powered by uIP TCP/IP stack project and FatFS library + * - XPLAINBridge - XPLAIN alternative PDI Programmer/USB to Serial Bridge firmware project + * - Incomplete + * - StandaloneProgrammer - Incomplete Standalone AVR Programmer application, to program AVRs directly from a Mass Storage disk + * + * + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/LibraryResources.txt b/hal/at90usb646/LUFA/DoxygenPages/LibraryResources.txt index 15c13ad..7137a56 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/LibraryResources.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/LibraryResources.txt @@ -1,33 +1,33 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_Resources Library Resources - * - * \section Sec_UnofficialResources Unofficial Resources - * Unofficial Russian LUFA documentation translation: http://microsin.ru/Download.cnt/doc/LUFA/ \n - * - * \section Sec_ProjectPages LUFA Related Webpages - * Project Homepage: http://www.lufa-lib.org \n - * Commercial Licenses: http://www.lufa-lib.org/license \n - * Author's Website: http://www.fourwalledcubicle.com \n - * Development Blog: http://www.fourwalledcubicle.com/blog \n - * - * \section Sec_ProjectHelp Assistance With LUFA - * Discussion Group: http://www.lufa-lib.org/support \n - * Author's Email: dean [at] fourwalledcubicle [dot] com \n - * - * \section Sec_InDevelopment Latest In-Development Source Code - * Issue Tracker: http://www.lufa-lib.org/tracker \n - * SVN Access: http://www.lufa-lib.org/svn \n - * GIT Access: http://www.lufa-lib.org/git \n - * Latest Repository Source Archive: http://www.lufa-lib.org/latest-archive \n - * Commit RSS Feed: http://www.lufa-lib.org/rss \n - * - * \section Sec_USBResources USB Resources - * USB-IF Website: http://www.usb.org \n - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_Resources Library Resources + * + * \section Sec_UnofficialResources Unofficial Resources + * Unofficial Russian LUFA documentation translation: http://microsin.ru/Download.cnt/doc/LUFA/ \n + * + * \section Sec_ProjectPages LUFA Related Webpages + * Project Homepage: http://www.lufa-lib.org \n + * Commercial Licenses: http://www.lufa-lib.org/license \n + * Author's Website: http://www.fourwalledcubicle.com \n + * Development Blog: http://www.fourwalledcubicle.com/blog \n + * + * \section Sec_ProjectHelp Assistance With LUFA + * Discussion Group: http://www.lufa-lib.org/support \n + * Author's Email: dean [at] fourwalledcubicle [dot] com \n + * + * \section Sec_InDevelopment Latest In-Development Source Code + * Issue Tracker: http://www.lufa-lib.org/tracker \n + * SVN Access: http://www.lufa-lib.org/svn \n + * GIT Access: http://www.lufa-lib.org/git \n + * Latest Repository Source Archive: http://www.lufa-lib.org/latest-archive \n + * Commit RSS Feed: http://www.lufa-lib.org/rss \n + * + * \section Sec_USBResources USB Resources + * USB-IF Website: http://www.usb.org \n + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/LicenseInfo.txt b/hal/at90usb646/LUFA/DoxygenPages/LicenseInfo.txt index 091ce94..447bec6 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/LicenseInfo.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/LicenseInfo.txt @@ -1,22 +1,22 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_LicenseInfo Source Code License - * - * The LUFA library is currently released under the MIT license, included below. - * - * Commercial entities can opt out of the public disclosure clause in this license - * for a one-time US$1500 payment. This provides a non-exclusive modified MIT licensed which - * allows for the free use of the LUFA library, bootloaders and (where the sole copyright - * is attributed to Dean Camera) demos without public disclosure within an organization, in - * addition to three free hours of consultation with the library author, and priority support. - * Please visit the Commercial License link on \ref Page_Resources for more information on - * ordering a commercial license for your company. - * - * \verbinclude License.txt - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_LicenseInfo Source Code License + * + * The LUFA library is currently released under the MIT license, included below. + * + * Commercial entities can opt out of the public disclosure clause in this license + * for a one-time US$1500 payment. This provides a non-exclusive modified MIT licensed which + * allows for the free use of the LUFA library, bootloaders and (where the sole copyright + * is attributed to Dean Camera) demos without public disclosure within an organization, in + * addition to three free hours of consultation with the library author, and priority support. + * Please visit the Commercial License link on \ref Page_Resources for more information on + * ordering a commercial license for your company. + * + * \verbinclude License.txt + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/MainPage.txt b/hal/at90usb646/LUFA/DoxygenPages/MainPage.txt index 99452d2..0ab9d56 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/MainPage.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/MainPage.txt @@ -1,48 +1,48 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \mainpage - * - * \image html LUFA.png - * - * \n - * - * \n - * - * LUFA is donationware. For author and donation information, see \ref Page_Donating. - * - * LUFA is an open-source USB library for the USB-enabled AVR microcontrollers, released under the MIT license (see \ref Page_LicenseInfo). - * It supports a large number of USB AVR models and boards (see \ref Page_DeviceSupport). It is designed to provide an easy to use, - * feature rich framework for the development of USB peripherals and hosts. - * - * LUFA focuses on the microcontroller side of USB development only; it includes no PC host USB driver development facilities - other projects - * such as the Windows Driver Development Kit, Windows USB Device Mode Framework and libusb may be of interest for developing custom OS drivers. - * While custom USB devices can be made with LUFA using such tools, the included demos all use the inbuilt OS drivers for each USB class for - * simplicity. - * - * The library is currently in a stable release, suitable for download and incorporation into user projects for - * both host and device modes. For information about the project progression, see the blog link at \ref Page_Resources. - * - * LUFA is written specifically for the free AVR-GCC compiler, and uses several GCC-only extensions to make the - * library API more streamlined and robust. You can download AVR-GCC for free in a convenient windows package, - * from the the WinAVR website (see \ref Page_Resources). - * - * The only required AVR peripherals for LUFA is the USB controller itself and interrupts - LUFA does not require the use of the - * microcontroller's timers or other hardware, leaving more hardware to the application developer. - * - * Accompanying LUFA in the download package is a set of example demo applications, plus several Bootloaders of different classes - * and open source LUFA powered projects. - * - * Subsections: - * \li \subpage Page_WhyUseLUFA - What are the advantages of using LUFA? - * \li \subpage Page_LUFAvsAtmelStack - How does LUFA compare to the Atmel USB AVR stack? - * \li \subpage Page_AlternativeStacks - Alternative USB AVR Stacks - * \li \subpage Page_LicenseInfo - Project source license and commercial use information - * \li \subpage Page_Donating - Donating to support this project - * \li \subpage Page_LibraryApps - Overview of included Demos, Bootloaders and Projects - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \mainpage + * + * \image html LUFA.png + * + * \n + * + * \n + * + * LUFA is donationware. For author and donation information, see \ref Page_Donating. + * + * LUFA is an open-source USB library for the USB-enabled AVR microcontrollers, released under the MIT license (see \ref Page_LicenseInfo). + * It supports a large number of USB AVR models and boards (see \ref Page_DeviceSupport). It is designed to provide an easy to use, + * feature rich framework for the development of USB peripherals and hosts. + * + * LUFA focuses on the microcontroller side of USB development only; it includes no PC host USB driver development facilities - other projects + * such as the Windows Driver Development Kit, Windows USB Device Mode Framework and libusb may be of interest for developing custom OS drivers. + * While custom USB devices can be made with LUFA using such tools, the included demos all use the inbuilt OS drivers for each USB class for + * simplicity. + * + * The library is currently in a stable release, suitable for download and incorporation into user projects for + * both host and device modes. For information about the project progression, see the blog link at \ref Page_Resources. + * + * LUFA is written specifically for the free AVR-GCC compiler, and uses several GCC-only extensions to make the + * library API more streamlined and robust. You can download AVR-GCC for free in a convenient windows package, + * from the the WinAVR website (see \ref Page_Resources). + * + * The only required AVR peripherals for LUFA is the USB controller itself and interrupts - LUFA does not require the use of the + * microcontroller's timers or other hardware, leaving more hardware to the application developer. + * + * Accompanying LUFA in the download package is a set of example demo applications, plus several Bootloaders of different classes + * and open source LUFA powered projects. + * + * Subsections: + * \li \subpage Page_WhyUseLUFA - What are the advantages of using LUFA? + * \li \subpage Page_LUFAvsAtmelStack - How does LUFA compare to the Atmel USB AVR stack? + * \li \subpage Page_AlternativeStacks - Alternative USB AVR Stacks + * \li \subpage Page_LicenseInfo - Project source license and commercial use information + * \li \subpage Page_Donating - Donating to support this project + * \li \subpage Page_LibraryApps - Overview of included Demos, Bootloaders and Projects + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/MigrationInformation.txt b/hal/at90usb646/LUFA/DoxygenPages/MigrationInformation.txt index 260228b..d2cc0a1 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/MigrationInformation.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/MigrationInformation.txt @@ -1,636 +1,636 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_Migration Migrating from Older Versions - * - * Below is migration information for updating existing projects based on previous versions of the LUFA library - * to the next version released. It does not indicate all new additions to the library in each version change, only - * areas relevant to making older projects compatible with the API changes of each new release. - * - * \section Sec_Migration120219 Migrating from 111009 to 120219 - * USB Core - * - The HID_KEYBOARD_MODIFER_* macros in the HID class driver have been corrected to HID_KEYBOARD_MODIFIER_* (note the spelling of "modifier"). - * Existing applications should switch over to the correctly spelled macro names. - * - The names of the USB Device and USB Host class driver files have changed; a new "ClassDevice" and "ClassHost" postfix has been added to the - * respective class driver files. Projects referencing the class driver source files by filename rather than the LUFA_SRC_USBCLASS makefile - * variable should append these postfixes to the source file names. Projects including the USB class driver dispatch headers directly should either - * switch to including the main USB driver header instead, or use the updated header filenames. - * - The USB_CONFIG_ATTR_BUSPOWERED constant has been renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed. All devices must set this bit in - * the Configuration descriptor's attributes field. As all devices are assumed to be bus-powered unless stated otherwise with the - * USB_CONFIG_ATTR_SELFPOWERED flag a replacement constant for bus powered devices is not provided. - * - * Device Mode - * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetInterfaceProperty(). - * Existing applications must implement this new callback, however if no audio entities are defined in the audio device's descriptors, - * this function may be hard-coded to always return false for previous behaviour to be retained. - * - * \section Sec_Migration111009 Migrating from 110528 to 111009 - * Non-USB Library Components - * - The \c JTAG_DEBUG_ASSERT() macro has been renamed \ref JTAG_ASSERT() to be consistent with \ref STDOUT_ASSERT(). - * - * USB Core - * - By default, unordered Endpoint and Pipe configuration is now allowed once again, via the previous workaround of - * reconfiguring all Endpoints/Pipes in order each time a new Endpoint/Pipe is created. To minimize the compiled program - * size, the new \c ORDERED_EP_CONFIG compile time option may be defined in the project makefile to restrict the ordering - * in exchange for a smaller compiled binary size. - * - The previous \c F_CLOCK symbol, required in the project makefile, has been renamed to \c F_USB. This is due to the previous name - * being far too generic for use in future architecture ports, where multiple clock domains are used. - * - * Device Mode - * - The Endpoint stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter. - * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes - * processed in the current transaction can be stored. If the \c BytesProcessed parameter is non \c NULL, each time the endpoint - * bank becomes full and the packet is sent, the routine will exit with the new \ref ENDPOINT_RWSTREAM_IncompleteTransfer - * error code to allow the user application to determine when to send the next chunk of data. - * - The \ref CDC_Device_SendString() function now expects a null terminated string instead of an explicit length. Existing code - * should use the new \ref CDC_Device_SendData() function, or remove the length parameter from the function call. - * - The \c Endpoint_ResetFIFO() function has been renamed to \ref Endpoint_ResetEndpoint(), to make the API function names more - * consistent. Existing applications using the old function name should simply replace it with a call to the new function name. - * - The \c Endpoint_*_Byte() functions have been renamed Endpoint_*_8() to ensure they are correct across all architectures. Existing - * code using these functions should replace the previous function names with the new function names. - * - The \c Endpoint_*_Word() functions have been renamed Endpoint_*_16() to ensure they are correct across all architectures. Existing - * code using these functions should replace the previous function names with the new function names. - * - The \c Endpoint_*_DWord() functions have been renamed Endpoint_*_32() to ensure they are correct across all architectures. Existing - * code using these functions should replace the previous function names with the new function names. - * - The Device mode RNDIS class driver no longer stores the incoming and outgoing packets in the class driver instance; the user is - * now expected to manually define a storage location for the packet data. Packets must now be sent and received manually via a call - * to \ref RNDIS_Device_ReadPacket() and/or \ref RNDIS_Device_SendPacket(). - * - The definition of the Audio class \ref USB_Audio_Descriptor_Format_t has been altered, to remove the fixed singular - * audio sample rate in the descriptor definition, and to rename the \c SampleFrequencyType to the more appropriate - * \c TotalDiscreteSampleRates. Existing applications will need to add an array of \ref USB_Audio_SampleFreq_t elements - * immediately following any \ref USB_Audio_Descriptor_Format_t descriptors, and insert the appropriate sampling rates - * supported by the device, as well as rename the descriptor elements to match the updated element names. - * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetEndpointProperty(). - * Existing applications must implement this new callback, however if multiple sample rates or pitch control is not used, - * this function may be hard-coded to always return false for previous behaviour to be retained. - * - The \c USB_ConfigurationNumber, \c USB_RemoteWakeupEnabled and \c USB_CurrentlySelfPowered globals have been renamed to - * \ref USB_Device_ConfigurationNumber, \ref USB_Device_RemoteWakeupEnabled and \ref USB_Device_CurrentlySelfPowered to clearly indicate - * the USB mode they relate to. Existing applications using these variables should rename all references to the previous names. - * - The \c ENDPOINT_DESCRIPTOR_DIR_IN and \c ENDPOINT_DESCRIPTOR_DIR_OUT macros have now been replaced by \ref ENDPOINT_DIR_IN and - * \ref ENDPOINT_DIR_OUT to improve code clarity. - * - The \ref HID_DESCRIPTOR_JOYSTICK() macro now takes an additional (first) parameter indicating the number of axis in the joystick. - * - * Host Mode - * - The Pipe stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter. - * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes - * processed in the current transaction can be stored. If the BytesProcessed parameter is non \c NULL, each time the pipe - * bank becomes full and the packet is sent, the routine will exit with the new \ref PIPE_RWSTREAM_IncompleteTransfer - * error code to allow the user application to determine when to send the next chunk of data. - * - The \ref PRNT_Host_SendString() and \ref CDC_Host_SendString() functions now expect a null terminated string instead of an explicit - * length. Existing code should use the new \ref PRNT_Host_SendData() and \ref CDC_Host_SendData() functions, or remove the - * length parameter from the function call. - * - The \c Pipe_ClearErrorFlags() function has been removed, as the pipe error flags are now automatically cleared when the - * \ref Pipe_ClearError() function is called. - * - The \c Pipe_*_Byte() functions have been renamed Pipe_*_8() to ensure they are correct across all architectures. Existing code using - * these functions should replace the previous function names with the new function names. - * - The \c Pipe_*_Word() functions have been renamed Pipe_*_16() to ensure they are correct across all architectures. Existing code using - * these functions should replace the previous function names with the new function names. - * - The \c Pipe_*_DWord() functions have been renamed Pipe_*_32() to ensure they are correct across all architectures. Existing code using - * these functions should replace the previous function names with the new function names. - * - The \c USB_Host_ClearPipeStall() function has been renamed to USB_Host_ClearEndpointStall(), as it operates on a full endpoing address - * within the attached device and not a pipe within the host. Existing code using the old function name should update the function calls and - * check for correct usage. - * - * \section Sec_Migration101122 Migrating from 100807 to 101122 - * USB Core - * - A new USB driver source file, \c Drivers/USB/HighLevel/EndpointStream.c now exists. This source file should be added - * to all project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source - * variables. - * - A new USB driver source file, \c Drivers/USB/HighLevel/PipeStream.c now exists. This source file should be added to all - * project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables. - * - The \c EVENT_USB_InitFailure() event has been removed, as the \ref USB_Init() function will no longer fail; if not USB mode is - * specified, the controller will default to UID selection mode. - * - The USB mode specifier constants have been moved into a new enum and renamed. Existing projects should use the equivalent - * value in the new \ref USB_Modes_t enum. - * - All class driver headers are now included as part of the standard \c LUFA/Drivers/USB/USB.h master dispatch header, and should - * no longer be included separately. Class driver module source files must still be added as a separate module in the project's - * makefile if used. - * - * Device Mode - * - Endpoints MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application - * allocated endpoints in ascending order - or if your application uses the USB device mode class drivers, ensure that each instance's - * endpoint indexes are not overlapped with other interface's endpoints. - * - The signature for the \ref CALLBACK_USB_GetDescriptor() callback has changed, the \c void** \c const \c DescriptorAddress parameter is - * now \c const \c void** \c const \c DescriptorAddress. Existing applications should update their callback signatures to match this, and - * eliminate any casting of descriptor pointers to a non \c const pointer. - * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation - * for each class driver for the new class specific descriptor type names. - * - The \c ENDPOINT_DOUBLEBANK_SUPPORTED() macro is has been renamed \ref ENDPOINT_BANKS_SUPPORTED() and now returns the total number of - * banks supported by the given endpoint. Existing code should switch to the new naming scheme, and test that the return value of the - * macro is equal to or greater than 2 to regain the previous functionality. - * - The \c EVENT_USB_Device_UnhandledControlRequest() event is now named \ref EVENT_USB_Device_ControlRequest() and fires before (not after) - * the internal library event handlers. Existing code should rename the event handlers in the user application to match the new event - * name, and should ensure that the new execution order does not affect the application's operation. - * - * Host Mode - * - Pipes MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application - * allocated pipes in ascending order - or if your application uses the USB host mode class drivers, ensure that each instance's - * pipe indexes are not overlapped with other interface's pipes. - * - The \c PRNT_Host_SendData() function has been renamed to \ref PRNT_Host_SendString(). Existing applications should simply - * replace all references to the obsolete function name with the new function name. - * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation - * for each class driver for the new class specific descriptor type names. - * - The Still Image Host class' function prefix has been changed from \c SImage_ to \c SI_, to remain consistent with the rest of the - * driver's enums, type defines and constants. - * - * \section Sec_Migration100807 Migrating from 100513 to 100807 - * - * Non-USB Library Components - * - The Dataflash board driver stub file has changed, as dataflash functions previously located in the internal - * Dataflash driver of the library have now been moved to the individual board files. Existing drivers can - * copy-paste the new functions from the board Dataflash stub driver. - * - * USB Core - * - A new USB driver source file, \c Drivers/USB/LowLevel/Device.c now exists. This source file should be added to all project - * makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables. - * - The \c Drivers/USB/LowLevel/DevChapter9.c source file has moved to \c Drivers/USB/HighLevel/DeviceStandardReq.c - this should - * be updated in all project makefiles, or the makefile should be updated to use the new module source variables. - * - The \c Drivers/USB/LowLevel/HostChapter9.h source file has moved to \c Drivers/USB/HighLevel/HostStandardReq.c - this should - * be updated in all project makefiles, or the makefile should be updated to use the new module source variables. - * - The \c Drivers/USB/LowLevel/LowLevel.c source file has moved to \c Drivers/LowLevel/USBController.c - this should be updated - * in all project makefiles, or the makefile should be updated to use the new module source variables. - * - * Device Mode - * - The \c USB_Device_IsRemoteWakeupSent() macro has been removed, as the remote wakeup request is now fully handled by the - * enhanced \ref USB_Device_SendRemoteWakeup() function. Existing code may now discard any checks to \c USB_Device_IsRemoteWakeupSent(). - * - The \c USB_Device_IsUSBSuspended() macro has been removed, as it is obsolete. Existing code should compare \ref USB_DeviceState - * to see if it the device is in the \ref DEVICE_STATE_Suspended state instead. - * - The \ref CDC_Device_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was - * received. This allows for more efficient coding, as a call to \ref CDC_Device_BytesReceived() is no longer needed if the exact - * number of queued bytes received is not needed. - * - * Host Mode - * - The \ref CDC_Host_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was - * received. This allows for more efficient coding, as a call to \ref CDC_Host_BytesReceived() is no longer needed if the exact - * number of queued bytes received is not needed. - * - The \ref CDC_Host_USBTask() now calls \ref CDC_Host_Flush() automatically, flushing any queued data to the attached device. Manual - * flushing of the interface is no longer needed if the flushes should be in sync with calls to \ref CDC_Host_USBTask(). - * - * \section Sec_Migration100513 Migrating from 100219 to 100513 - * - * Non-USB Library Components - * - The \ref TWI_StartTransmission() function now takes in a timeout period, expressed in milliseconds, within which the addressed - * device must respond or the function will abort. - * - * Device Mode - * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need - * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible - * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process - * functions correctly. - * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel. - * Projects must update their makefile SRC values accordingly. - * - The HID Device Class driver's function signature for the \ref CALLBACK_HID_Device_ProcessHIDReport() function has been changed, to - * allow for a new \c ReportType parameter. This new parameter must be added in all user applications using the Device mode HID Class - * Driver, but may be ignored unless Host-to-Device FEATURE HID reports are used. - * - * Host Mode - * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need - * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible - * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process - * functions correctly. - * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel. - * Projects must update their makefile \c SRC values accordingly. - * - The HID Host Class driver's function signature for the \ref HID_Host_SendReportByID() function has been changed, to allow for a new - * ReportType parameter. Existing calls to this function should substitute \c REPORT_ITEM_TYPE_Out as this parameter's value. - * - * \section Sec_Migration100219 Migrating from 091223 to 100219 - * - * Non-USB Library Components - * - Due to some ADC channels not being identical to their ADC MUX selection masks for single-ended conversions on some AVR models, - * the ADC driver now has explicit masks for each of the standard ADC channels (see \ref Group_ADC). These masks should be used - * when calling the ADC functions to ensure proper operation across all AVR models. Note that the \ref ADC_SetupChannel() function - * is an exception, and should always be called with a channel number rather than a channel mask. - * - * Host Mode - * - The MIDI Host Class driver send and receive routines now operate on packed events, where multiple MIDI events may be - * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send - * pipe bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually - * flush the queued event(s) to the device by calling \ref MIDI_Host_Flush(). - * - The \ref Pipe_IsEndpointBound() function now takes the endpoint's direction into account, by checking if the MSB of the endpoint's address - * is set to denote IN endpoints. If the previous functionality where the direction is to be discounted is required, mask the endpoint - * address against the \ref PIPE_EPNUM_MASK token before calling \ref Pipe_IsEndpointBound(). - * - * Device Mode - * - The MIDI Device Class driver send and receive routines now operate on packed events, where multiple MIDI events may be - * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send - * endpoint bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually - * flush the queued event(s) to the host by calling \ref MIDI_Device_Flush(). - * - * \section Sec_Migration091223 Migrating from 091122 to 091223 - * - * Host Mode - * - The Still Image Host Class driver \ref SI_Host_USBTask() and \ref SI_Host_ConfigurePipes() functions were misnamed, and are - * now named \c SImage_Host_USBTask() and \c SImage_Host_ConfigurePipes() respectively. - * - The \c HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to \ref HOST_SENDCONTROL_DeviceDisconnected to be in - * line with the rest of the library error codes. - * - The HID Parser item usages no longer contain separate minimum and maximum values, as this was a violation of the HID - * specification. Instead, the values are distributed evenly across each item as its usage value, to ensure that all items - * can be distinguished from one-another. - * - * Device Mode - * - The \ref CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new \c ReportType parameter to - * indicate the report type to generate. Existing applications may simply add and ignore this additional parameter. - * - * \section Sec_Migration091122 Migrating from 090924 to 091122 - * - * Host Mode - * - The \c HID_PARSE_UsageStackOverflow HID parser error constant is now named \ref HID_PARSE_UsageListOverflow - * - The \ref CALLBACK_HIDParser_FilterHIDReportItem() HID Parser callback now passes a complete \ref HID_ReportItem_t to the - * user application, instead of just its attributes. - * - The \c USB_GetDeviceConfigDescriptor() function was incorrectly named and is now called \ref USB_Host_GetDeviceConfigDescriptor(). - * - * \section Sec_Migration090924 Migrating from 090810 to 090924 - * - * Non-USB Library Components - * - The \c ADC_Off() function has been renamed to \c ADC_ShutDown() to be consistent with the rest of the library. - * - The \ref SPI_Init() routine's parameters have changed, so that the clock polarity and data sampling modes can be set. See - * the \ref SPI_Init() function documentation for more details - * - The \ref Dataflash_Init() routine no longer initializes the SPI bus - the SPI bus should be initialized manually via a - * call to \ref SPI_Init() before using the Dataflash driver - * - * Host Mode - * - The \c USB_GetDeviceConfigDescriptor() function's parameters and behaviour has changed; the user is required to - * preallocate the largest allowable buffer, and pass the size of the buffer to the function. This allows for a single - * call to the function to retrieve, size check and validate the Configuration Descriptor rather than having the user - * application perform these intermediary steps. - * - The HID report parser now requires a mandatory callback in the user code, to filter only the items the application - * is interested in into the processed HID report item structure to save RAM. See \ref CALLBACK_HIDParser_FilterHIDReportItem(). - * - The HID report parser now always parses FEATURE and always ignores constant-data items - the \c HID_ENABLE_FEATURE_PROCESSING - * and \c HID_INCLUDE_CONSTANT_DATA_ITEMS compile time tokens now have no effect. - * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_* - * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in - * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants. - * - * Device Mode - * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_* - * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in - * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants. - * - * \section Sec_Migration090810 Migrating from 090605 to 090810 - * - * All - * - The "Simple Scheduler" has been deprecated, as it was little more than an abstracted loop and caused much confusion. - * User applications using the scheduler should switch to regular loops instead. The scheduler code will be removed in a future - * release. - * - The "Dynamic Memory Block Allocator" has been removed, as it was unused in (and unrelated to) the LUFA library and never - * used in user applications. - * - * Non-USB Library Components - * - The \c ATTR_NOINLINE function attribute macro has been renamed to \ref ATTR_NO_INLINE to be in line with the rest of the function attribute - * macro names. - * - * Library Demos - * - Most demos now have a corresponding Class Driver implementation, which uses the new internal library class drivers for the standard - * USB classes. This allows for more rapid device and host development, and so should be used in preference to the low level APIs where - * possible so that fixes to the class drivers propagate to all applications which use them automatically with each new LUFA release. - * - * Host Mode - * - The \c HIDParser.c module has moved from \c LUFA/Drivers/USB/Class/ to \c LUFA/Drivers/USB/Class/Host/. - * - The \c USB_GetDeviceConfigDescriptor() function now requires the desired configuration index within the device as its first - * parameter, to add support for multi-configuration devices. Existing code should use a configuration index of 1 to indicate the - * first configuration descriptor within the device. - * - The non-standard "Ready" host state has been removed. Existing \ref HOST_STATE_Configured code should be moved to the end of - * the existing \ref HOST_STATE_Addressed state, and the existing HOST_STATE_Ready state code should be moved to the \ref HOST_STATE_Configured - * state. - * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_HostState explicitly to ensure the host is - * in the desired state instead. - * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode - * events. See the \ref Group_Events page for details on the new event names and firing conditions. - * - * Device Mode - * - The \ref CALLBACK_USB_GetDescriptor() function now takes an extra parameter to specify the descriptor's memory space so that - * descriptors in mixed memory spaces can be used. The previous functionality can be returned by defining the \c USE_FLASH_DESCRIPTORS - * token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter. - * - The \c USB_IsSuspended global has been removed - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead. - * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_DeviceState explicitly to ensure the device - * is in the desired state instead. - * - The VBUS events have been removed, as they are already exposed to the user via the \c USB_Connect and \c USB_Disconnect events. - * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode - * events. See the \ref Group_Events page for details on the new event names and firing conditions. - * - * \section Sec_Migration090605 Migrating from 090510 to 090605 - * - * Device Mode - * - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing - * projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can - * manage the control endpoint via interrupts automatically by compiling with the \c INTERRUPT_CONTROL_ENDPOINT token defined. - * - The \c DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory - * address. - * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See - * \ref Group_Events for new API details. - * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular - * function signatures of a function accepting no arguments and returning a \c uint8_t value. - * - The \c Event_DeviceError() event no longer exists, as its sole caller (unlinked \c USB_GetDescriptor() function) now produces a - * compilation error rather than a runtime error. The \c StdDescriptors.c file no longer exists as a result, and should be removed - * from project makefiles. - * - The \c USB_GetDescriptor() function has been renamed to \ref CALLBACK_USB_GetDescriptor() to be in line with the new \c CALLBACK_ - * function prefixes for functions which must be implemented in the user application. - * - * Host Mode - * - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing - * projects using interrupts on non-control pipes should switch to polling. - * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See - * \ref Group_Events for new API details. - * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular - * function signatures of a function accepting no arguments and returning a \c uint8_t value. - * - The \c DESCRIPTOR_COMPARATOR() macro has been removed. User applications should replace all instances of the macro with - * regular function signatures of a function accepting a void pointer to the descriptor to test, and returning a \c uint8_t value. - * - * \section Sec_Migration090510 Migrating from 090401 to 090510 - * - * All - * - The \c ButtLoadTag.h header has been removed, as it was never used for its intended purpose. Projects should either remove all - * \c BUTTLOADTAG() elements, or download and extract \c ButtLoadTag.h header from the ButtLoad project. - * - The \c Drivers/AT90USBXXX/ directory has been renamed to \c Drivers/Peripheral/. - * - The \c Serial_Stream driver has been renamed to \c SerialStream to remain consistent with the rest of the library naming scheme. - * - The HWB driver has changed to the \c Buttons driver. See the board Buttons driver documentation for the new API. - * - * Dual Role Mode - * - The \c USB_PowerOnFail event has been renamed to \c USB_InitFailure. - * - The functions in \c OTG.h have been renamed to remain more consistent with the library API. See the functions in \c OTG.h for more - * details. - * - * Device Mode - * - The \c Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the \ref Endpoint_ClearIN(), \ref Endpoint_ClearOUT() - * macros. See \c Endpoint.h documentation for more details on the new endpoint management macros. - * - The \c Endpoint_ReadWriteAllowed() macro has been renamed to \ref Endpoint_IsReadWriteAllowed() to be more consistent with the rest of - * the API naming scheme. - * - The \c Endpoint_IsSetupINReady() and \c Endpoint_IsSetupOUTReceived() macros have been renamed to \ref Endpoint_IsINReady() and - * \ref Endpoint_IsOUTReceived() respectively. - * - The \c Endpoint_IsSetupReceived() macro has been renamed to \ref Endpoint_IsSETUPReceived(). - * - The \c Endpoint_ClearSetupReceived() macro has been renamed to \ref Endpoint_ClearSETUP(). - * - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Endpoint_Read_Word()) have - * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions. - * - The \c USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of - * the Control Request header as all Control Request header data is now preloaded by the library and made available in the - * USB_ControlRequest structure. - * - The \c FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to \c CONTROL_ONLY_DEVICE. - * - The \c STATIC_ENDPOINT_CONFIGURATION is no longer applicable as the library will apply this optimization when appropriate automatically. - * - The values of the \ref Endpoint_Stream_RW_ErrorCodes_t and \ref Endpoint_ControlStream_RW_ErrorCodes_t enums have had the \c ERROR_ portion - * of their names removed. - * - * Host Mode - * - The \ref USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on - * other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called - * in existing projects where the Control pipe is to be operated on. - * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer - * need to manage this manually when calling the USB management task. - * - The \c Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT() macros. See - * Pipe.h documentation for more details on the new pipe management macros. - * - The \c Pipe_ReadWriteAllowed() macro has been renamed to \ref Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API - * naming scheme. - * - The \c Pipe_IsSetupINReceived() and \c Pipe_IsOutReady() macros have been renamed to \ref Pipe_IsINReceived() and \ref Pipe_IsOUTReady() - * respectively. - * - The new \ref Pipe_ClearSETUP() macro should be used to send SETUP transactions, rather than the previous \c Pipe_ClearSetupOUT() macro. - * - The \c Pipe_IsSetupSent() macro has been renamed to \ref Pipe_IsSETUPSent(). - * - The \c Pipe_ClearSetupSent() macro is no longer applicable and should be removed. - * - All pipe read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Pipe_Read_Word()) have - * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions. - * - The \c Host_IsResetBusDone() macro has been renamed to \c Host_IsBusResetComplete(). - * - The \c Pipe_Ignore_Word() and \c Pipe_Ignore_DWord() functions have been renamed to \c Pipe_Discard_Word() and \c Pipe_Discard_DWord() - * to remain consistent with the rest of the pipe API. - * - It is no longer needed to manually include the headers from \c LUFA/Drivers/USB/Class, as they are now included along with the rest - * of the USB headers when \c LUFA/Drivers/USB/USB.h is included. - * - Functions in the \c ConfigDescriptor.h header file no longer have \c Host_ as part of their names. - * - The \c ProcessHIDReport() has been renamed to \ref USB_ProcessHIDReport(), \c GetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo() - * and \c SetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo(). - * - The values of the \ref DSearch_Return_ErrorCodes_t and \ref DSearch_Comp_Return_ErrorCodes_t enums have had their respective \c Descriptor_Search - * and \c Descriptor_Search_Comp prefixes changed to all caps. - * - The \c USB_HostRequest global has been renamed to \ref USB_ControlRequest, and is used in Device mode also. The \c USB_Host_Request_Header_t - * structure type has been renamed to \ref USB_Request_Header_t. - * - The values of the \ref Pipe_Stream_RW_ErrorCodes_t enum have had the \c ERROR_ portion of their names removed. - * - * \section Sec_Migration090401 Migrating from 090209 to 090401 - * - * All - * - LUFA projects must now give the raw input clock frequency (before any prescaling) as a compile time constant \c F_USB, - * defined in the project makefile and passed to the compiler via the -D switch. - * - The makefile EEPROM programming targets for FLIP and dfu-programmer no longer program in the FLASH data in addition to the - * EEPROM data into the device. If both are to be programmed, both the EEPROM and FLASH programming targets must be called. - * - As the avr-libc macro has been corrected in recent avr-libc distributions, the \c SetSystemClockPrescaler() macro has been removed. - * Include \c and call \c clock_prescale_set(clock_div_1); instead on recent avr-libc distributions. - * - * Library Demos - * - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission. - * - * Non-USB Library Components - * - The \c ATTR_ALWAYSINLINE function attribute macro has been renamed to \ref ATTR_ALWAYS_INLINE. - * - Custom board Dataflash drivers now require the implementation of \ref Dataflash_SelectChipFromPage() and \ref Dataflash_SendAddressBytes(). - * - * Device Mode - * - The \c NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to \c FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded - * to also remove parts of the Get Status chapter 9 request to further reduce code usage. On all applications currently using the - * \c NO_CLEARSET_FEATURE_REQUEST compile time token, it can be replaced with the \c FEATURELESS_CONTROL_ONLY_DEVICE token with no further - * modifications required. - * - * \section Sec_Migration090209 Migrating from 081217 to 090209 - * - * Device Mode - * - The \c ENDPOINT_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c ENDPOINT_TOTAL_ENDPOINTS. - * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user - * makefile if desired to restore the previous 50ms timeout. - * - * Host Mode - * - The \c PIPE_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c PIPE_TOTAL_ENDPOINTS. - * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user - * makefile if desired to restore the previous 50ms timeout. - * - The \c USB_DeviceEnumerationFailed event now contains a second \c SubErrorCode parameter, giving the error code of the function - * which failed. - * - The \c HID_PARSE_Sucessful enum member constant name has been corrected to \ref HID_PARSE_Successful. - * - * Non-USB Library Components - * - The previous \c SPI_SendByte() functionality is now located in \ref SPI_TransferByte(). \ref SPI_SendByte() now discards the return byte - * for speed, to compliment the new \ref SPI_ReceiveByte() function. If bidirectional SPI transfers are required, calls to \ref SPI_SendByte() - * should be changed to \ref SPI_TransferByte(). - * - The serial driver now sets the Tx line as an output explicitly, and enables the pull-up of the Rx line. - * - The \ref Serial_Init() and \c SerialStream_Init() functions now take a second \c DoubleSpeed parameter, which indicates if the USART - * should be initialized in double speed mode - useful in some circumstances for attaining baud rates not usually possible at the given AVR - * clock speed. - * - * \section Sec_Migration171208 Migrating from V1.5.3 to 081217 - * - * All - * - The MyUSB project name has been changed to LUFA (Lightweight Framework for USB AVRs). All references to MyUSB, including macro names, - * have been changed to LUFA. - * - * Library Demos - * - The ReconfigureUSART() routine in the USBtoSerial demo was not being called after new line encoding - * parameters were set by the host. Projects built on the USBtoSerial code should update to the latest version. - * - The HID Parser now supports multiple report (on a single endpoint) HID devices. The MouseHostWithParser and - * KeyboardHostWithPaser demos use the updated API functions to function correctly on such devices. Projects - * built on either "WithParser" demo should update to the latest code. - * - The RNDIS demo TCP stack has been modified so that connections can be properly closed. It is still not - * recommended that the MyUSB RNDIS demo TCP/IP stack be used for anything other than demonstration purposes, - * as it is neither a full nor a standards compliant implementation. - * - * Non-USB Library Components - * - The Serial_IsCharReceived() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h. - * - * Device Mode - * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask - * to be used in the Options parameter of the USB_Init() function. - * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is - * currently initialized. - * - Interrupts are now disabled when processing control requests, to avoid problems with interrupts causing the library - * or user request processing code to exceed the strict USB timing requirements on control transfers. - * - The USB Reset event now resets and disables all device endpoints. If user code depends on endpoints remaining configured - * after a Reset event, it should be altered to explicitly re-initialize all user endpoints. - * - The prototype for the GetDescriptor function has been changed, as the return value was redundant. The function now - * returns the size of the descriptor, rather than passing it back via a parameter, or returns NO_DESCRIPTOR if the specified - * descriptor does not exist. - * - The NO_DESCRIPTOR_STRING macro has been renamed NO_DESCRIPTOR, and is now also used as a possible return value for the - * GetDescriptor function. - * - * Host Mode - * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask - * to be used in the Options parameter of the USB_Init() function. - * - The HID report parser now supports multiple Report IDs. The HID report parser GetReportItemInfo() and - * SetReportItemInfo() routines now return a boolean, set if the requested report item was located in the - * current report. If sending a report to a multi-report device, the first byte of the report is automatically - * set to the report ID of the given report item. - * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is - * currently initialized. - * - * \section Sec_Migration152 Migrating from V1.5.2 to V1.5.3 - * - * Library Demos - * - Previously, all demos contained a serial number string descriptor, filled with all zeros. A serial number - * string is required in Mass Storage devices, or devices which are to retain settings when moved between - * ports on a machine. As people were not changing the serial number value, this was causing conflicts and so - * the serial number descriptor has been removed from all but the Mass Storage demo, which requires it. - * - The AudioOut and AudioIn demos did not previously silence their endpoints when the host has deactivated - * them. Projects built upon either demo should upgrade to the latest code. - * - The FEATURE_ENDPOINT macro has been renamed FEATURE_ENDPOINT_HALT, and is now correctly documented. - * - The MassStoreHost demo contained errors which caused it to lock up randomly on certain devices. Projects built - * on the MassStoreDemo code should update to the latest version. - * - The Interrupt type endpoint in the CDC based demos previously had a polling interval of 0x02, which caused - * problems on some Linux systems. This has been changed to 0xFF, projects built on the CDC demos should upgrade - * to the latest code. - * - The HID keyboard and mouse demos were not previously boot mode compatible. To enable boot mode support, projects - * built on the keyboard or mouse demos (or derivatives) should upgrade to the latest code. - * - The Mass Storage demo was not previously standards compliant. Projects built on the Mass Storage demo should - * upgrade to the latest code. - * - The USART was not being reconfigured after the host sent new encoding settings in the USBtoSerial demo. This was - * previously discovered and fixed, but the change was lost. Projects built on the USBtoSerial demo should update - * to the latest code. - * - * Device Mode - * - The endpoint non-control stream functions now have a default timeout of 50ms between packets in the stream. - * If this timeout is exceeded, the function returns the new ENDPOINT_RWSTREAM_ERROR_Timeout error value. The - * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired - * timeout duration in ms. - * - Rather than returning fixed values, the flags indicating if the device has Remote Wakeup currently enabled - * and/or is self-powered are now accessed and set through the new USB_RemoteWakeupEnabled and - * USB_CurrentlySelfPowered macros. See the DevChapter9.h documentation for more details. - * - All endpoint stream functions now require an extra Callback function parameter. Existing code may be updated - * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing - * the token NO_STREAM_CALLBACKS to the compiler using the -D switch. - * - * Host Mode - * - The pipe non-control stream functions now have a default timeout of 50ms between packets in the stream. - * If this timeout is exceeded, the function returns the new PIPE_RWSTREAM_ERROR_Timeout error value. The - * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired - * timeout duration in ms. - * - CollectionPath_t has been renamed to HID_CollectionPath_t to be more in line with the other HID parser structures. - * - All pipe stream functions now require an extra Callback function parameter. Existing code may be updated - * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing - * the token NO_STREAM_CALLBACKS to the compiler using the -D switch. - * - * \section Sec_Migration151 Migrating from V1.5.1 to V1.5.2 - * - * Library Demos - * - The RNDIS demo application has been updated so that it is functional on Linux under earlier implementations - * of the RNDIS specification, which had non-standard behaviour. Projects built upon the demo should upgrade - * to the latest code. - * - The DFU class bootloader has had several bugs corrected in this release. It is recommended that where - * possible any existing devices upgrade to the latest bootloader code. - * - * \section Sec_Migration150 Migrating from V1.5.0 to V1.5.1 - * - * Library Demos - * - The USBtoSerial demo was broken in the 1.5.0 release, due to incorrect register polling in place of the - * global "Transmitting" flag. The change has been reverted in this release. Projects built upon the demo - * should upgrade to the latest code. - * - The HID class demos did not implement the mandatory GetReport HID class request. Projects built upon the HID - * demos should upgrade to the latest code. - * - The HID class demos incorrectly reported themselves as boot-protocol enabled HID devices in their descriptors. - * Projects built upon the HID demos should upgrade to the latest code. - * - The MIDI device demo had incorrect AudioStreaming interface descriptors. Projects built upon the MIDI demo - * should upgrade to the latest code. - * - The AudioOut demo did not correctly tristate the speaker pins when USB was disconnected, wasting power. - * Projects built upon the AudioOut demo should upgrade to the latest code. - * - * \section Sec_Migration141 Migrating from V1.4.1 to V1.5.0 - * - * Library Demos - * - Previous versions of the library demos had incorrectly encoded BCD version numbers in the descriptors. To - * avoid such mistakes in the future, the VERSION_BCD macro has been added to StdDescriptors.h. Existing - * projects should at least manually correct the BCD version numbers, or preferably update the descriptors to - * encode the version number in BCD format using the new macro. - * - The mandatory GetReport class-specific request was accidentally omitted from previous versions of the demos - * based on the Human Interface Device (HID) class. This has been corrected, and any user projects based on the - * HID demos should also be updated accordingly. - * - The CDC demos now correctly send an empty packet directly after a full packet, to end the transmission. - * Failure to do this on projects which always or frequently send full packets will cause buffering issues on - * the host OS. All CDC user projects are advised to update their transmission routines in the same manner as - * the library CDC demos. - * - The previous interrupt-driven Endpoint/Pipe demos did not properly save and restore the currently selected - * Endpoint/Pipe when the ISR fired. This has been corrected - user projects based on the interrupt driven - * demos should also update to properly save and restore the selected Endpoint/Pipe. - * - * Non-USB Library Components - * - The Atomic.h and ISRMacro.h header files in MyUSB/Common have been removed, as the library is now only - * compatible with avr-libc library versions newer than the time before the functionality of the deleted - * headers was available. - * - * Device Mode - * - The GetDescriptor function (see StdDescriptors.h) now has a new prototype, with altered parameter names and - * functions. Existing projects will need to update the GetDescriptor implementation to reflect the new API. - * The previously split Type and Index parameters are now passed as the original wValue parameter to the - * function, to make way for the USB specification wIndex parameter which is not the same as the - * previous Index parameter. - * - The USB_UnhandledControlPacket event (see Events.h) now has new parameter names, to be in line with the - * official USB specification. Existing code will need to be altered to use the new parameter names. - * - The USB_CreateEndpoints event (see Events.h) has been renamed to USB_ConfigurationChanged, which is more - * appropriate. It fires in an identical manner to the previously named event, thus the only change to be made - * is the event name itself in the user project. - * - The USB_Descriptor_Language_t structure no longer exists in StdDescriptors.h, as this was a - * pseudo-descriptor modeled on the string descriptor. It is replaced by the true USB_Descriptor_String_t type - * descriptor as indicated in the USB specification, thus all device code must be updated accordingly. - * - The names of several Endpoint macros have been changed to be more consistent with the rest of the library, - * with no implementation changes. This means that existing code can be altered to use the new macro names - * with no other considerations required. See Endpoint.h for the new macro names. - * - The previous version of the MassStorage demo had an incorrect value in the SCSI_Request_Sense_Response_t - * structure named SenseData in SCSI.c which caused some problems with some hosts. User projects based on this - * demo should correct the structure value to maintain compatibility across multiple OS platforms. - * - By default, the descriptor structures use the official USB specification names for the elements. Previous - * versions of the library used non-standard (but more verbose) names, which are still usable in the current - * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file - * documentation for more details. - * - * Host Mode - * - The USB_Host_Request_Header_t structure in HostChapter9.h (used for issuing control requests) has had its - * members renamed to the official USB specification names for requests. Existing code will need to be updated - * to use the new names. - * - The names of several Pipe macros have been changed to be more consistent with the rest of the library, - * with no implementation changes. This means that existing code can be altered to use the new macro names - * with no other considerations required. See Pipe.h for the new macro names. - * - By default, the descriptor structures use the official USB specification names for the elements. Previous - * versions of the library used non-standard (but more verbose) names, which are still usable in the current - * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file - * documentation for more details. - * - The names of the macros in Host.h for controlling the SOF generation have been renamed, see the Host.h - * module documentation for the new macro names. - * - * Dual Role Mode - * - The OTG.h header file has been corrected so that the macros now perform their stated functions. Any existing - * projects using custom headers to fix the broken OTG header should now be altered to once again use the OTG - * header inside the library. - * - The USB_DeviceEnumerationComplete event (see Events.h) now also fires in Device mode, when the host has - * finished enumerating the device. Projects relying on the event only firing in Host mode should be updated - * so that the event action only occurs when the USB_Mode global is set to USB_MODE_HOST. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_Migration Migrating from Older Versions + * + * Below is migration information for updating existing projects based on previous versions of the LUFA library + * to the next version released. It does not indicate all new additions to the library in each version change, only + * areas relevant to making older projects compatible with the API changes of each new release. + * + * \section Sec_Migration120219 Migrating from 111009 to 120219 + * USB Core + * - The HID_KEYBOARD_MODIFER_* macros in the HID class driver have been corrected to HID_KEYBOARD_MODIFIER_* (note the spelling of "modifier"). + * Existing applications should switch over to the correctly spelled macro names. + * - The names of the USB Device and USB Host class driver files have changed; a new "ClassDevice" and "ClassHost" postfix has been added to the + * respective class driver files. Projects referencing the class driver source files by filename rather than the LUFA_SRC_USBCLASS makefile + * variable should append these postfixes to the source file names. Projects including the USB class driver dispatch headers directly should either + * switch to including the main USB driver header instead, or use the updated header filenames. + * - The USB_CONFIG_ATTR_BUSPOWERED constant has been renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed. All devices must set this bit in + * the Configuration descriptor's attributes field. As all devices are assumed to be bus-powered unless stated otherwise with the + * USB_CONFIG_ATTR_SELFPOWERED flag a replacement constant for bus powered devices is not provided. + * + * Device Mode + * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetInterfaceProperty(). + * Existing applications must implement this new callback, however if no audio entities are defined in the audio device's descriptors, + * this function may be hard-coded to always return false for previous behaviour to be retained. + * + * \section Sec_Migration111009 Migrating from 110528 to 111009 + * Non-USB Library Components + * - The \c JTAG_DEBUG_ASSERT() macro has been renamed \ref JTAG_ASSERT() to be consistent with \ref STDOUT_ASSERT(). + * + * USB Core + * - By default, unordered Endpoint and Pipe configuration is now allowed once again, via the previous workaround of + * reconfiguring all Endpoints/Pipes in order each time a new Endpoint/Pipe is created. To minimize the compiled program + * size, the new \c ORDERED_EP_CONFIG compile time option may be defined in the project makefile to restrict the ordering + * in exchange for a smaller compiled binary size. + * - The previous \c F_CLOCK symbol, required in the project makefile, has been renamed to \c F_USB. This is due to the previous name + * being far too generic for use in future architecture ports, where multiple clock domains are used. + * + * Device Mode + * - The Endpoint stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter. + * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes + * processed in the current transaction can be stored. If the \c BytesProcessed parameter is non \c NULL, each time the endpoint + * bank becomes full and the packet is sent, the routine will exit with the new \ref ENDPOINT_RWSTREAM_IncompleteTransfer + * error code to allow the user application to determine when to send the next chunk of data. + * - The \ref CDC_Device_SendString() function now expects a null terminated string instead of an explicit length. Existing code + * should use the new \ref CDC_Device_SendData() function, or remove the length parameter from the function call. + * - The \c Endpoint_ResetFIFO() function has been renamed to \ref Endpoint_ResetEndpoint(), to make the API function names more + * consistent. Existing applications using the old function name should simply replace it with a call to the new function name. + * - The \c Endpoint_*_Byte() functions have been renamed Endpoint_*_8() to ensure they are correct across all architectures. Existing + * code using these functions should replace the previous function names with the new function names. + * - The \c Endpoint_*_Word() functions have been renamed Endpoint_*_16() to ensure they are correct across all architectures. Existing + * code using these functions should replace the previous function names with the new function names. + * - The \c Endpoint_*_DWord() functions have been renamed Endpoint_*_32() to ensure they are correct across all architectures. Existing + * code using these functions should replace the previous function names with the new function names. + * - The Device mode RNDIS class driver no longer stores the incoming and outgoing packets in the class driver instance; the user is + * now expected to manually define a storage location for the packet data. Packets must now be sent and received manually via a call + * to \ref RNDIS_Device_ReadPacket() and/or \ref RNDIS_Device_SendPacket(). + * - The definition of the Audio class \ref USB_Audio_Descriptor_Format_t has been altered, to remove the fixed singular + * audio sample rate in the descriptor definition, and to rename the \c SampleFrequencyType to the more appropriate + * \c TotalDiscreteSampleRates. Existing applications will need to add an array of \ref USB_Audio_SampleFreq_t elements + * immediately following any \ref USB_Audio_Descriptor_Format_t descriptors, and insert the appropriate sampling rates + * supported by the device, as well as rename the descriptor elements to match the updated element names. + * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetEndpointProperty(). + * Existing applications must implement this new callback, however if multiple sample rates or pitch control is not used, + * this function may be hard-coded to always return false for previous behaviour to be retained. + * - The \c USB_ConfigurationNumber, \c USB_RemoteWakeupEnabled and \c USB_CurrentlySelfPowered globals have been renamed to + * \ref USB_Device_ConfigurationNumber, \ref USB_Device_RemoteWakeupEnabled and \ref USB_Device_CurrentlySelfPowered to clearly indicate + * the USB mode they relate to. Existing applications using these variables should rename all references to the previous names. + * - The \c ENDPOINT_DESCRIPTOR_DIR_IN and \c ENDPOINT_DESCRIPTOR_DIR_OUT macros have now been replaced by \ref ENDPOINT_DIR_IN and + * \ref ENDPOINT_DIR_OUT to improve code clarity. + * - The \ref HID_DESCRIPTOR_JOYSTICK() macro now takes an additional (first) parameter indicating the number of axis in the joystick. + * + * Host Mode + * - The Pipe stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter. + * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes + * processed in the current transaction can be stored. If the BytesProcessed parameter is non \c NULL, each time the pipe + * bank becomes full and the packet is sent, the routine will exit with the new \ref PIPE_RWSTREAM_IncompleteTransfer + * error code to allow the user application to determine when to send the next chunk of data. + * - The \ref PRNT_Host_SendString() and \ref CDC_Host_SendString() functions now expect a null terminated string instead of an explicit + * length. Existing code should use the new \ref PRNT_Host_SendData() and \ref CDC_Host_SendData() functions, or remove the + * length parameter from the function call. + * - The \c Pipe_ClearErrorFlags() function has been removed, as the pipe error flags are now automatically cleared when the + * \ref Pipe_ClearError() function is called. + * - The \c Pipe_*_Byte() functions have been renamed Pipe_*_8() to ensure they are correct across all architectures. Existing code using + * these functions should replace the previous function names with the new function names. + * - The \c Pipe_*_Word() functions have been renamed Pipe_*_16() to ensure they are correct across all architectures. Existing code using + * these functions should replace the previous function names with the new function names. + * - The \c Pipe_*_DWord() functions have been renamed Pipe_*_32() to ensure they are correct across all architectures. Existing code using + * these functions should replace the previous function names with the new function names. + * - The \c USB_Host_ClearPipeStall() function has been renamed to USB_Host_ClearEndpointStall(), as it operates on a full endpoing address + * within the attached device and not a pipe within the host. Existing code using the old function name should update the function calls and + * check for correct usage. + * + * \section Sec_Migration101122 Migrating from 100807 to 101122 + * USB Core + * - A new USB driver source file, \c Drivers/USB/HighLevel/EndpointStream.c now exists. This source file should be added + * to all project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source + * variables. + * - A new USB driver source file, \c Drivers/USB/HighLevel/PipeStream.c now exists. This source file should be added to all + * project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables. + * - The \c EVENT_USB_InitFailure() event has been removed, as the \ref USB_Init() function will no longer fail; if not USB mode is + * specified, the controller will default to UID selection mode. + * - The USB mode specifier constants have been moved into a new enum and renamed. Existing projects should use the equivalent + * value in the new \ref USB_Modes_t enum. + * - All class driver headers are now included as part of the standard \c LUFA/Drivers/USB/USB.h master dispatch header, and should + * no longer be included separately. Class driver module source files must still be added as a separate module in the project's + * makefile if used. + * + * Device Mode + * - Endpoints MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application + * allocated endpoints in ascending order - or if your application uses the USB device mode class drivers, ensure that each instance's + * endpoint indexes are not overlapped with other interface's endpoints. + * - The signature for the \ref CALLBACK_USB_GetDescriptor() callback has changed, the \c void** \c const \c DescriptorAddress parameter is + * now \c const \c void** \c const \c DescriptorAddress. Existing applications should update their callback signatures to match this, and + * eliminate any casting of descriptor pointers to a non \c const pointer. + * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation + * for each class driver for the new class specific descriptor type names. + * - The \c ENDPOINT_DOUBLEBANK_SUPPORTED() macro is has been renamed \ref ENDPOINT_BANKS_SUPPORTED() and now returns the total number of + * banks supported by the given endpoint. Existing code should switch to the new naming scheme, and test that the return value of the + * macro is equal to or greater than 2 to regain the previous functionality. + * - The \c EVENT_USB_Device_UnhandledControlRequest() event is now named \ref EVENT_USB_Device_ControlRequest() and fires before (not after) + * the internal library event handlers. Existing code should rename the event handlers in the user application to match the new event + * name, and should ensure that the new execution order does not affect the application's operation. + * + * Host Mode + * - Pipes MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application + * allocated pipes in ascending order - or if your application uses the USB host mode class drivers, ensure that each instance's + * pipe indexes are not overlapped with other interface's pipes. + * - The \c PRNT_Host_SendData() function has been renamed to \ref PRNT_Host_SendString(). Existing applications should simply + * replace all references to the obsolete function name with the new function name. + * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation + * for each class driver for the new class specific descriptor type names. + * - The Still Image Host class' function prefix has been changed from \c SImage_ to \c SI_, to remain consistent with the rest of the + * driver's enums, type defines and constants. + * + * \section Sec_Migration100807 Migrating from 100513 to 100807 + * + * Non-USB Library Components + * - The Dataflash board driver stub file has changed, as dataflash functions previously located in the internal + * Dataflash driver of the library have now been moved to the individual board files. Existing drivers can + * copy-paste the new functions from the board Dataflash stub driver. + * + * USB Core + * - A new USB driver source file, \c Drivers/USB/LowLevel/Device.c now exists. This source file should be added to all project + * makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables. + * - The \c Drivers/USB/LowLevel/DevChapter9.c source file has moved to \c Drivers/USB/HighLevel/DeviceStandardReq.c - this should + * be updated in all project makefiles, or the makefile should be updated to use the new module source variables. + * - The \c Drivers/USB/LowLevel/HostChapter9.h source file has moved to \c Drivers/USB/HighLevel/HostStandardReq.c - this should + * be updated in all project makefiles, or the makefile should be updated to use the new module source variables. + * - The \c Drivers/USB/LowLevel/LowLevel.c source file has moved to \c Drivers/LowLevel/USBController.c - this should be updated + * in all project makefiles, or the makefile should be updated to use the new module source variables. + * + * Device Mode + * - The \c USB_Device_IsRemoteWakeupSent() macro has been removed, as the remote wakeup request is now fully handled by the + * enhanced \ref USB_Device_SendRemoteWakeup() function. Existing code may now discard any checks to \c USB_Device_IsRemoteWakeupSent(). + * - The \c USB_Device_IsUSBSuspended() macro has been removed, as it is obsolete. Existing code should compare \ref USB_DeviceState + * to see if it the device is in the \ref DEVICE_STATE_Suspended state instead. + * - The \ref CDC_Device_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was + * received. This allows for more efficient coding, as a call to \ref CDC_Device_BytesReceived() is no longer needed if the exact + * number of queued bytes received is not needed. + * + * Host Mode + * - The \ref CDC_Host_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was + * received. This allows for more efficient coding, as a call to \ref CDC_Host_BytesReceived() is no longer needed if the exact + * number of queued bytes received is not needed. + * - The \ref CDC_Host_USBTask() now calls \ref CDC_Host_Flush() automatically, flushing any queued data to the attached device. Manual + * flushing of the interface is no longer needed if the flushes should be in sync with calls to \ref CDC_Host_USBTask(). + * + * \section Sec_Migration100513 Migrating from 100219 to 100513 + * + * Non-USB Library Components + * - The \ref TWI_StartTransmission() function now takes in a timeout period, expressed in milliseconds, within which the addressed + * device must respond or the function will abort. + * + * Device Mode + * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need + * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible + * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process + * functions correctly. + * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel. + * Projects must update their makefile SRC values accordingly. + * - The HID Device Class driver's function signature for the \ref CALLBACK_HID_Device_ProcessHIDReport() function has been changed, to + * allow for a new \c ReportType parameter. This new parameter must be added in all user applications using the Device mode HID Class + * Driver, but may be ignored unless Host-to-Device FEATURE HID reports are used. + * + * Host Mode + * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need + * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible + * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process + * functions correctly. + * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel. + * Projects must update their makefile \c SRC values accordingly. + * - The HID Host Class driver's function signature for the \ref HID_Host_SendReportByID() function has been changed, to allow for a new + * ReportType parameter. Existing calls to this function should substitute \c REPORT_ITEM_TYPE_Out as this parameter's value. + * + * \section Sec_Migration100219 Migrating from 091223 to 100219 + * + * Non-USB Library Components + * - Due to some ADC channels not being identical to their ADC MUX selection masks for single-ended conversions on some AVR models, + * the ADC driver now has explicit masks for each of the standard ADC channels (see \ref Group_ADC). These masks should be used + * when calling the ADC functions to ensure proper operation across all AVR models. Note that the \ref ADC_SetupChannel() function + * is an exception, and should always be called with a channel number rather than a channel mask. + * + * Host Mode + * - The MIDI Host Class driver send and receive routines now operate on packed events, where multiple MIDI events may be + * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send + * pipe bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually + * flush the queued event(s) to the device by calling \ref MIDI_Host_Flush(). + * - The \ref Pipe_IsEndpointBound() function now takes the endpoint's direction into account, by checking if the MSB of the endpoint's address + * is set to denote IN endpoints. If the previous functionality where the direction is to be discounted is required, mask the endpoint + * address against the \ref PIPE_EPNUM_MASK token before calling \ref Pipe_IsEndpointBound(). + * + * Device Mode + * - The MIDI Device Class driver send and receive routines now operate on packed events, where multiple MIDI events may be + * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send + * endpoint bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually + * flush the queued event(s) to the host by calling \ref MIDI_Device_Flush(). + * + * \section Sec_Migration091223 Migrating from 091122 to 091223 + * + * Host Mode + * - The Still Image Host Class driver \ref SI_Host_USBTask() and \ref SI_Host_ConfigurePipes() functions were misnamed, and are + * now named \c SImage_Host_USBTask() and \c SImage_Host_ConfigurePipes() respectively. + * - The \c HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to \ref HOST_SENDCONTROL_DeviceDisconnected to be in + * line with the rest of the library error codes. + * - The HID Parser item usages no longer contain separate minimum and maximum values, as this was a violation of the HID + * specification. Instead, the values are distributed evenly across each item as its usage value, to ensure that all items + * can be distinguished from one-another. + * + * Device Mode + * - The \ref CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new \c ReportType parameter to + * indicate the report type to generate. Existing applications may simply add and ignore this additional parameter. + * + * \section Sec_Migration091122 Migrating from 090924 to 091122 + * + * Host Mode + * - The \c HID_PARSE_UsageStackOverflow HID parser error constant is now named \ref HID_PARSE_UsageListOverflow + * - The \ref CALLBACK_HIDParser_FilterHIDReportItem() HID Parser callback now passes a complete \ref HID_ReportItem_t to the + * user application, instead of just its attributes. + * - The \c USB_GetDeviceConfigDescriptor() function was incorrectly named and is now called \ref USB_Host_GetDeviceConfigDescriptor(). + * + * \section Sec_Migration090924 Migrating from 090810 to 090924 + * + * Non-USB Library Components + * - The \c ADC_Off() function has been renamed to \c ADC_ShutDown() to be consistent with the rest of the library. + * - The \ref SPI_Init() routine's parameters have changed, so that the clock polarity and data sampling modes can be set. See + * the \ref SPI_Init() function documentation for more details + * - The \ref Dataflash_Init() routine no longer initializes the SPI bus - the SPI bus should be initialized manually via a + * call to \ref SPI_Init() before using the Dataflash driver + * + * Host Mode + * - The \c USB_GetDeviceConfigDescriptor() function's parameters and behaviour has changed; the user is required to + * preallocate the largest allowable buffer, and pass the size of the buffer to the function. This allows for a single + * call to the function to retrieve, size check and validate the Configuration Descriptor rather than having the user + * application perform these intermediary steps. + * - The HID report parser now requires a mandatory callback in the user code, to filter only the items the application + * is interested in into the processed HID report item structure to save RAM. See \ref CALLBACK_HIDParser_FilterHIDReportItem(). + * - The HID report parser now always parses FEATURE and always ignores constant-data items - the \c HID_ENABLE_FEATURE_PROCESSING + * and \c HID_INCLUDE_CONSTANT_DATA_ITEMS compile time tokens now have no effect. + * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_* + * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in + * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants. + * + * Device Mode + * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_* + * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in + * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants. + * + * \section Sec_Migration090810 Migrating from 090605 to 090810 + * + * All + * - The "Simple Scheduler" has been deprecated, as it was little more than an abstracted loop and caused much confusion. + * User applications using the scheduler should switch to regular loops instead. The scheduler code will be removed in a future + * release. + * - The "Dynamic Memory Block Allocator" has been removed, as it was unused in (and unrelated to) the LUFA library and never + * used in user applications. + * + * Non-USB Library Components + * - The \c ATTR_NOINLINE function attribute macro has been renamed to \ref ATTR_NO_INLINE to be in line with the rest of the function attribute + * macro names. + * + * Library Demos + * - Most demos now have a corresponding Class Driver implementation, which uses the new internal library class drivers for the standard + * USB classes. This allows for more rapid device and host development, and so should be used in preference to the low level APIs where + * possible so that fixes to the class drivers propagate to all applications which use them automatically with each new LUFA release. + * + * Host Mode + * - The \c HIDParser.c module has moved from \c LUFA/Drivers/USB/Class/ to \c LUFA/Drivers/USB/Class/Host/. + * - The \c USB_GetDeviceConfigDescriptor() function now requires the desired configuration index within the device as its first + * parameter, to add support for multi-configuration devices. Existing code should use a configuration index of 1 to indicate the + * first configuration descriptor within the device. + * - The non-standard "Ready" host state has been removed. Existing \ref HOST_STATE_Configured code should be moved to the end of + * the existing \ref HOST_STATE_Addressed state, and the existing HOST_STATE_Ready state code should be moved to the \ref HOST_STATE_Configured + * state. + * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_HostState explicitly to ensure the host is + * in the desired state instead. + * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode + * events. See the \ref Group_Events page for details on the new event names and firing conditions. + * + * Device Mode + * - The \ref CALLBACK_USB_GetDescriptor() function now takes an extra parameter to specify the descriptor's memory space so that + * descriptors in mixed memory spaces can be used. The previous functionality can be returned by defining the \c USE_FLASH_DESCRIPTORS + * token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter. + * - The \c USB_IsSuspended global has been removed - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead. + * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_DeviceState explicitly to ensure the device + * is in the desired state instead. + * - The VBUS events have been removed, as they are already exposed to the user via the \c USB_Connect and \c USB_Disconnect events. + * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode + * events. See the \ref Group_Events page for details on the new event names and firing conditions. + * + * \section Sec_Migration090605 Migrating from 090510 to 090605 + * + * Device Mode + * - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing + * projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can + * manage the control endpoint via interrupts automatically by compiling with the \c INTERRUPT_CONTROL_ENDPOINT token defined. + * - The \c DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory + * address. + * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See + * \ref Group_Events for new API details. + * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular + * function signatures of a function accepting no arguments and returning a \c uint8_t value. + * - The \c Event_DeviceError() event no longer exists, as its sole caller (unlinked \c USB_GetDescriptor() function) now produces a + * compilation error rather than a runtime error. The \c StdDescriptors.c file no longer exists as a result, and should be removed + * from project makefiles. + * - The \c USB_GetDescriptor() function has been renamed to \ref CALLBACK_USB_GetDescriptor() to be in line with the new \c CALLBACK_ + * function prefixes for functions which must be implemented in the user application. + * + * Host Mode + * - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing + * projects using interrupts on non-control pipes should switch to polling. + * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See + * \ref Group_Events for new API details. + * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular + * function signatures of a function accepting no arguments and returning a \c uint8_t value. + * - The \c DESCRIPTOR_COMPARATOR() macro has been removed. User applications should replace all instances of the macro with + * regular function signatures of a function accepting a void pointer to the descriptor to test, and returning a \c uint8_t value. + * + * \section Sec_Migration090510 Migrating from 090401 to 090510 + * + * All + * - The \c ButtLoadTag.h header has been removed, as it was never used for its intended purpose. Projects should either remove all + * \c BUTTLOADTAG() elements, or download and extract \c ButtLoadTag.h header from the ButtLoad project. + * - The \c Drivers/AT90USBXXX/ directory has been renamed to \c Drivers/Peripheral/. + * - The \c Serial_Stream driver has been renamed to \c SerialStream to remain consistent with the rest of the library naming scheme. + * - The HWB driver has changed to the \c Buttons driver. See the board Buttons driver documentation for the new API. + * + * Dual Role Mode + * - The \c USB_PowerOnFail event has been renamed to \c USB_InitFailure. + * - The functions in \c OTG.h have been renamed to remain more consistent with the library API. See the functions in \c OTG.h for more + * details. + * + * Device Mode + * - The \c Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the \ref Endpoint_ClearIN(), \ref Endpoint_ClearOUT() + * macros. See \c Endpoint.h documentation for more details on the new endpoint management macros. + * - The \c Endpoint_ReadWriteAllowed() macro has been renamed to \ref Endpoint_IsReadWriteAllowed() to be more consistent with the rest of + * the API naming scheme. + * - The \c Endpoint_IsSetupINReady() and \c Endpoint_IsSetupOUTReceived() macros have been renamed to \ref Endpoint_IsINReady() and + * \ref Endpoint_IsOUTReceived() respectively. + * - The \c Endpoint_IsSetupReceived() macro has been renamed to \ref Endpoint_IsSETUPReceived(). + * - The \c Endpoint_ClearSetupReceived() macro has been renamed to \ref Endpoint_ClearSETUP(). + * - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Endpoint_Read_Word()) have + * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions. + * - The \c USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of + * the Control Request header as all Control Request header data is now preloaded by the library and made available in the + * USB_ControlRequest structure. + * - The \c FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to \c CONTROL_ONLY_DEVICE. + * - The \c STATIC_ENDPOINT_CONFIGURATION is no longer applicable as the library will apply this optimization when appropriate automatically. + * - The values of the \ref Endpoint_Stream_RW_ErrorCodes_t and \ref Endpoint_ControlStream_RW_ErrorCodes_t enums have had the \c ERROR_ portion + * of their names removed. + * + * Host Mode + * - The \ref USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on + * other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called + * in existing projects where the Control pipe is to be operated on. + * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer + * need to manage this manually when calling the USB management task. + * - The \c Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT() macros. See + * Pipe.h documentation for more details on the new pipe management macros. + * - The \c Pipe_ReadWriteAllowed() macro has been renamed to \ref Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API + * naming scheme. + * - The \c Pipe_IsSetupINReceived() and \c Pipe_IsOutReady() macros have been renamed to \ref Pipe_IsINReceived() and \ref Pipe_IsOUTReady() + * respectively. + * - The new \ref Pipe_ClearSETUP() macro should be used to send SETUP transactions, rather than the previous \c Pipe_ClearSetupOUT() macro. + * - The \c Pipe_IsSetupSent() macro has been renamed to \ref Pipe_IsSETUPSent(). + * - The \c Pipe_ClearSetupSent() macro is no longer applicable and should be removed. + * - All pipe read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Pipe_Read_Word()) have + * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions. + * - The \c Host_IsResetBusDone() macro has been renamed to \c Host_IsBusResetComplete(). + * - The \c Pipe_Ignore_Word() and \c Pipe_Ignore_DWord() functions have been renamed to \c Pipe_Discard_Word() and \c Pipe_Discard_DWord() + * to remain consistent with the rest of the pipe API. + * - It is no longer needed to manually include the headers from \c LUFA/Drivers/USB/Class, as they are now included along with the rest + * of the USB headers when \c LUFA/Drivers/USB/USB.h is included. + * - Functions in the \c ConfigDescriptor.h header file no longer have \c Host_ as part of their names. + * - The \c ProcessHIDReport() has been renamed to \ref USB_ProcessHIDReport(), \c GetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo() + * and \c SetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo(). + * - The values of the \ref DSearch_Return_ErrorCodes_t and \ref DSearch_Comp_Return_ErrorCodes_t enums have had their respective \c Descriptor_Search + * and \c Descriptor_Search_Comp prefixes changed to all caps. + * - The \c USB_HostRequest global has been renamed to \ref USB_ControlRequest, and is used in Device mode also. The \c USB_Host_Request_Header_t + * structure type has been renamed to \ref USB_Request_Header_t. + * - The values of the \ref Pipe_Stream_RW_ErrorCodes_t enum have had the \c ERROR_ portion of their names removed. + * + * \section Sec_Migration090401 Migrating from 090209 to 090401 + * + * All + * - LUFA projects must now give the raw input clock frequency (before any prescaling) as a compile time constant \c F_USB, + * defined in the project makefile and passed to the compiler via the -D switch. + * - The makefile EEPROM programming targets for FLIP and dfu-programmer no longer program in the FLASH data in addition to the + * EEPROM data into the device. If both are to be programmed, both the EEPROM and FLASH programming targets must be called. + * - As the avr-libc macro has been corrected in recent avr-libc distributions, the \c SetSystemClockPrescaler() macro has been removed. + * Include \c and call \c clock_prescale_set(clock_div_1); instead on recent avr-libc distributions. + * + * Library Demos + * - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission. + * + * Non-USB Library Components + * - The \c ATTR_ALWAYSINLINE function attribute macro has been renamed to \ref ATTR_ALWAYS_INLINE. + * - Custom board Dataflash drivers now require the implementation of \ref Dataflash_SelectChipFromPage() and \ref Dataflash_SendAddressBytes(). + * + * Device Mode + * - The \c NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to \c FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded + * to also remove parts of the Get Status chapter 9 request to further reduce code usage. On all applications currently using the + * \c NO_CLEARSET_FEATURE_REQUEST compile time token, it can be replaced with the \c FEATURELESS_CONTROL_ONLY_DEVICE token with no further + * modifications required. + * + * \section Sec_Migration090209 Migrating from 081217 to 090209 + * + * Device Mode + * - The \c ENDPOINT_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c ENDPOINT_TOTAL_ENDPOINTS. + * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user + * makefile if desired to restore the previous 50ms timeout. + * + * Host Mode + * - The \c PIPE_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c PIPE_TOTAL_ENDPOINTS. + * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user + * makefile if desired to restore the previous 50ms timeout. + * - The \c USB_DeviceEnumerationFailed event now contains a second \c SubErrorCode parameter, giving the error code of the function + * which failed. + * - The \c HID_PARSE_Sucessful enum member constant name has been corrected to \ref HID_PARSE_Successful. + * + * Non-USB Library Components + * - The previous \c SPI_SendByte() functionality is now located in \ref SPI_TransferByte(). \ref SPI_SendByte() now discards the return byte + * for speed, to compliment the new \ref SPI_ReceiveByte() function. If bidirectional SPI transfers are required, calls to \ref SPI_SendByte() + * should be changed to \ref SPI_TransferByte(). + * - The serial driver now sets the Tx line as an output explicitly, and enables the pull-up of the Rx line. + * - The \ref Serial_Init() and \c SerialStream_Init() functions now take a second \c DoubleSpeed parameter, which indicates if the USART + * should be initialized in double speed mode - useful in some circumstances for attaining baud rates not usually possible at the given AVR + * clock speed. + * + * \section Sec_Migration171208 Migrating from V1.5.3 to 081217 + * + * All + * - The MyUSB project name has been changed to LUFA (Lightweight Framework for USB AVRs). All references to MyUSB, including macro names, + * have been changed to LUFA. + * + * Library Demos + * - The ReconfigureUSART() routine in the USBtoSerial demo was not being called after new line encoding + * parameters were set by the host. Projects built on the USBtoSerial code should update to the latest version. + * - The HID Parser now supports multiple report (on a single endpoint) HID devices. The MouseHostWithParser and + * KeyboardHostWithPaser demos use the updated API functions to function correctly on such devices. Projects + * built on either "WithParser" demo should update to the latest code. + * - The RNDIS demo TCP stack has been modified so that connections can be properly closed. It is still not + * recommended that the MyUSB RNDIS demo TCP/IP stack be used for anything other than demonstration purposes, + * as it is neither a full nor a standards compliant implementation. + * + * Non-USB Library Components + * - The Serial_IsCharReceived() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h. + * + * Device Mode + * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask + * to be used in the Options parameter of the USB_Init() function. + * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is + * currently initialized. + * - Interrupts are now disabled when processing control requests, to avoid problems with interrupts causing the library + * or user request processing code to exceed the strict USB timing requirements on control transfers. + * - The USB Reset event now resets and disables all device endpoints. If user code depends on endpoints remaining configured + * after a Reset event, it should be altered to explicitly re-initialize all user endpoints. + * - The prototype for the GetDescriptor function has been changed, as the return value was redundant. The function now + * returns the size of the descriptor, rather than passing it back via a parameter, or returns NO_DESCRIPTOR if the specified + * descriptor does not exist. + * - The NO_DESCRIPTOR_STRING macro has been renamed NO_DESCRIPTOR, and is now also used as a possible return value for the + * GetDescriptor function. + * + * Host Mode + * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask + * to be used in the Options parameter of the USB_Init() function. + * - The HID report parser now supports multiple Report IDs. The HID report parser GetReportItemInfo() and + * SetReportItemInfo() routines now return a boolean, set if the requested report item was located in the + * current report. If sending a report to a multi-report device, the first byte of the report is automatically + * set to the report ID of the given report item. + * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is + * currently initialized. + * + * \section Sec_Migration152 Migrating from V1.5.2 to V1.5.3 + * + * Library Demos + * - Previously, all demos contained a serial number string descriptor, filled with all zeros. A serial number + * string is required in Mass Storage devices, or devices which are to retain settings when moved between + * ports on a machine. As people were not changing the serial number value, this was causing conflicts and so + * the serial number descriptor has been removed from all but the Mass Storage demo, which requires it. + * - The AudioOut and AudioIn demos did not previously silence their endpoints when the host has deactivated + * them. Projects built upon either demo should upgrade to the latest code. + * - The FEATURE_ENDPOINT macro has been renamed FEATURE_ENDPOINT_HALT, and is now correctly documented. + * - The MassStoreHost demo contained errors which caused it to lock up randomly on certain devices. Projects built + * on the MassStoreDemo code should update to the latest version. + * - The Interrupt type endpoint in the CDC based demos previously had a polling interval of 0x02, which caused + * problems on some Linux systems. This has been changed to 0xFF, projects built on the CDC demos should upgrade + * to the latest code. + * - The HID keyboard and mouse demos were not previously boot mode compatible. To enable boot mode support, projects + * built on the keyboard or mouse demos (or derivatives) should upgrade to the latest code. + * - The Mass Storage demo was not previously standards compliant. Projects built on the Mass Storage demo should + * upgrade to the latest code. + * - The USART was not being reconfigured after the host sent new encoding settings in the USBtoSerial demo. This was + * previously discovered and fixed, but the change was lost. Projects built on the USBtoSerial demo should update + * to the latest code. + * + * Device Mode + * - The endpoint non-control stream functions now have a default timeout of 50ms between packets in the stream. + * If this timeout is exceeded, the function returns the new ENDPOINT_RWSTREAM_ERROR_Timeout error value. The + * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired + * timeout duration in ms. + * - Rather than returning fixed values, the flags indicating if the device has Remote Wakeup currently enabled + * and/or is self-powered are now accessed and set through the new USB_RemoteWakeupEnabled and + * USB_CurrentlySelfPowered macros. See the DevChapter9.h documentation for more details. + * - All endpoint stream functions now require an extra Callback function parameter. Existing code may be updated + * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing + * the token NO_STREAM_CALLBACKS to the compiler using the -D switch. + * + * Host Mode + * - The pipe non-control stream functions now have a default timeout of 50ms between packets in the stream. + * If this timeout is exceeded, the function returns the new PIPE_RWSTREAM_ERROR_Timeout error value. The + * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired + * timeout duration in ms. + * - CollectionPath_t has been renamed to HID_CollectionPath_t to be more in line with the other HID parser structures. + * - All pipe stream functions now require an extra Callback function parameter. Existing code may be updated + * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing + * the token NO_STREAM_CALLBACKS to the compiler using the -D switch. + * + * \section Sec_Migration151 Migrating from V1.5.1 to V1.5.2 + * + * Library Demos + * - The RNDIS demo application has been updated so that it is functional on Linux under earlier implementations + * of the RNDIS specification, which had non-standard behaviour. Projects built upon the demo should upgrade + * to the latest code. + * - The DFU class bootloader has had several bugs corrected in this release. It is recommended that where + * possible any existing devices upgrade to the latest bootloader code. + * + * \section Sec_Migration150 Migrating from V1.5.0 to V1.5.1 + * + * Library Demos + * - The USBtoSerial demo was broken in the 1.5.0 release, due to incorrect register polling in place of the + * global "Transmitting" flag. The change has been reverted in this release. Projects built upon the demo + * should upgrade to the latest code. + * - The HID class demos did not implement the mandatory GetReport HID class request. Projects built upon the HID + * demos should upgrade to the latest code. + * - The HID class demos incorrectly reported themselves as boot-protocol enabled HID devices in their descriptors. + * Projects built upon the HID demos should upgrade to the latest code. + * - The MIDI device demo had incorrect AudioStreaming interface descriptors. Projects built upon the MIDI demo + * should upgrade to the latest code. + * - The AudioOut demo did not correctly tristate the speaker pins when USB was disconnected, wasting power. + * Projects built upon the AudioOut demo should upgrade to the latest code. + * + * \section Sec_Migration141 Migrating from V1.4.1 to V1.5.0 + * + * Library Demos + * - Previous versions of the library demos had incorrectly encoded BCD version numbers in the descriptors. To + * avoid such mistakes in the future, the VERSION_BCD macro has been added to StdDescriptors.h. Existing + * projects should at least manually correct the BCD version numbers, or preferably update the descriptors to + * encode the version number in BCD format using the new macro. + * - The mandatory GetReport class-specific request was accidentally omitted from previous versions of the demos + * based on the Human Interface Device (HID) class. This has been corrected, and any user projects based on the + * HID demos should also be updated accordingly. + * - The CDC demos now correctly send an empty packet directly after a full packet, to end the transmission. + * Failure to do this on projects which always or frequently send full packets will cause buffering issues on + * the host OS. All CDC user projects are advised to update their transmission routines in the same manner as + * the library CDC demos. + * - The previous interrupt-driven Endpoint/Pipe demos did not properly save and restore the currently selected + * Endpoint/Pipe when the ISR fired. This has been corrected - user projects based on the interrupt driven + * demos should also update to properly save and restore the selected Endpoint/Pipe. + * + * Non-USB Library Components + * - The Atomic.h and ISRMacro.h header files in MyUSB/Common have been removed, as the library is now only + * compatible with avr-libc library versions newer than the time before the functionality of the deleted + * headers was available. + * + * Device Mode + * - The GetDescriptor function (see StdDescriptors.h) now has a new prototype, with altered parameter names and + * functions. Existing projects will need to update the GetDescriptor implementation to reflect the new API. + * The previously split Type and Index parameters are now passed as the original wValue parameter to the + * function, to make way for the USB specification wIndex parameter which is not the same as the + * previous Index parameter. + * - The USB_UnhandledControlPacket event (see Events.h) now has new parameter names, to be in line with the + * official USB specification. Existing code will need to be altered to use the new parameter names. + * - The USB_CreateEndpoints event (see Events.h) has been renamed to USB_ConfigurationChanged, which is more + * appropriate. It fires in an identical manner to the previously named event, thus the only change to be made + * is the event name itself in the user project. + * - The USB_Descriptor_Language_t structure no longer exists in StdDescriptors.h, as this was a + * pseudo-descriptor modeled on the string descriptor. It is replaced by the true USB_Descriptor_String_t type + * descriptor as indicated in the USB specification, thus all device code must be updated accordingly. + * - The names of several Endpoint macros have been changed to be more consistent with the rest of the library, + * with no implementation changes. This means that existing code can be altered to use the new macro names + * with no other considerations required. See Endpoint.h for the new macro names. + * - The previous version of the MassStorage demo had an incorrect value in the SCSI_Request_Sense_Response_t + * structure named SenseData in SCSI.c which caused some problems with some hosts. User projects based on this + * demo should correct the structure value to maintain compatibility across multiple OS platforms. + * - By default, the descriptor structures use the official USB specification names for the elements. Previous + * versions of the library used non-standard (but more verbose) names, which are still usable in the current + * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file + * documentation for more details. + * + * Host Mode + * - The USB_Host_Request_Header_t structure in HostChapter9.h (used for issuing control requests) has had its + * members renamed to the official USB specification names for requests. Existing code will need to be updated + * to use the new names. + * - The names of several Pipe macros have been changed to be more consistent with the rest of the library, + * with no implementation changes. This means that existing code can be altered to use the new macro names + * with no other considerations required. See Pipe.h for the new macro names. + * - By default, the descriptor structures use the official USB specification names for the elements. Previous + * versions of the library used non-standard (but more verbose) names, which are still usable in the current + * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file + * documentation for more details. + * - The names of the macros in Host.h for controlling the SOF generation have been renamed, see the Host.h + * module documentation for the new macro names. + * + * Dual Role Mode + * - The OTG.h header file has been corrected so that the macros now perform their stated functions. Any existing + * projects using custom headers to fix the broken OTG header should now be altered to once again use the OTG + * header inside the library. + * - The USB_DeviceEnumerationComplete event (see Events.h) now also fires in Device mode, when the host has + * finished enumerating the device. Projects relying on the event only firing in Host mode should be updated + * so that the event action only occurs when the USB_Mode global is set to USB_MODE_HOST. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/ProgrammingApps.txt b/hal/at90usb646/LUFA/DoxygenPages/ProgrammingApps.txt index ea5a447..c1b2181 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/ProgrammingApps.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/ProgrammingApps.txt @@ -1,27 +1,27 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_ProgrammingApps Programming an Application into a USB AVR - * - * Once you have built an application, you will need a way to program in the resulting ".HEX" file (and, if your - * application uses EEPROM variables with initial values, also a ".EEP" file) into your USB AVR. Normally, the - * reprogramming of an AVR device must be performed using a special piece of programming hardware, through one of the - * supported AVR programming protocols - ISP, HVSP, HVPP, JTAG or dW. This can be done through a custom programmer, - * a third party programmer, or an official Atmel AVR tool - for more information, see the Atmel.com website. - * - * Alternatively, you can use the bootloader. From the Atmel factory, each USB AVR comes preloaded with the Atmel - * DFU (Device Firmware Update) class bootloader, a small piece of AVR firmware which allows the remainder of the - * AVR to be programmed through a non-standard interface such as the serial USART port, SPI, or (in this case) USB. - * Bootloaders have the advantage of not requiring any special hardware for programming, and cannot usually be erased - * or broken without an external programming device. They have disadvantages however; they cannot change the fuses of - * the AVR (special configuration settings that control the operation of the chip itself) and a small portion of the - * AVR's FLASH program memory must be reserved to contain the bootloader firmware, and thus cannot be used by the - * loaded application. Atmel's DFU bootloader is either 4KB (for the smaller USB AVRs) or 8KB (for the larger USB AVRs). - * - * If you wish to use the DFU bootloader to program in your application, refer to your DFU programmer's documentation. - * Atmel provides a free utility called FLIP which is USB AVR compatible, and an open source (Linux compatible) - * alternative exists called "dfu-programmer". - */ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_ProgrammingApps Programming an Application into a USB AVR + * + * Once you have built an application, you will need a way to program in the resulting ".HEX" file (and, if your + * application uses EEPROM variables with initial values, also a ".EEP" file) into your USB AVR. Normally, the + * reprogramming of an AVR device must be performed using a special piece of programming hardware, through one of the + * supported AVR programming protocols - ISP, HVSP, HVPP, JTAG or dW. This can be done through a custom programmer, + * a third party programmer, or an official Atmel AVR tool - for more information, see the Atmel.com website. + * + * Alternatively, you can use the bootloader. From the Atmel factory, each USB AVR comes preloaded with the Atmel + * DFU (Device Firmware Update) class bootloader, a small piece of AVR firmware which allows the remainder of the + * AVR to be programmed through a non-standard interface such as the serial USART port, SPI, or (in this case) USB. + * Bootloaders have the advantage of not requiring any special hardware for programming, and cannot usually be erased + * or broken without an external programming device. They have disadvantages however; they cannot change the fuses of + * the AVR (special configuration settings that control the operation of the chip itself) and a small portion of the + * AVR's FLASH program memory must be reserved to contain the bootloader firmware, and thus cannot be used by the + * loaded application. Atmel's DFU bootloader is either 4KB (for the smaller USB AVRs) or 8KB (for the larger USB AVRs). + * + * If you wish to use the DFU bootloader to program in your application, refer to your DFU programmer's documentation. + * Atmel provides a free utility called FLIP which is USB AVR compatible, and an open source (Linux compatible) + * alternative exists called "dfu-programmer". + */ diff --git a/hal/at90usb646/LUFA/DoxygenPages/SoftwareBootloaderJump.txt b/hal/at90usb646/LUFA/DoxygenPages/SoftwareBootloaderJump.txt index b867ef4..1fad85f 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/SoftwareBootloaderJump.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/SoftwareBootloaderJump.txt @@ -1,71 +1,71 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_SoftwareBootloaderStart Entering the Bootloader via Software - * - * A common requirement of many applications is the ability to jump to the programmed bootloader of a chip - * on demand, via the code's firmware (i.e. not as a result of any physical user interaction with the - * hardware). This might be required because the device does not have any physical user input, or simply - * just to streamline the device upgrade process on the host PC. - * - * The following C code snippets may be used to enter the bootloader upon request by the user application. - * By using the watchdog to physically reset the controller, it is ensured that all system hardware is - * completely reset to their defaults before the bootloader is run. This is important; since bootloaders - * are written to occupy a very limited space, they usually make assumptions about the register states based - * on the default values after a hard-reset of the chip. - * - * \section Sec_SoftareBootAVR8 AVR8 Architecture - * The following software bootloader jump code is written for the AVR8 architecture. - * - * \code - * #include - * #include - * #include - * - * #include - * #include - * - * uint32_t Boot_Key ATTR_NO_INIT; - * - * #define MAGIC_BOOT_KEY 0xDC42ACCA - * #define BOOTLOADER_START_ADDRESS (FLASH_SIZE_BYTES - BOOTLOADER_SEC_SIZE_BYTES) - * - * void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3); - * void Bootloader_Jump_Check(void) - * { - * // If the reset source was the bootloader and the key is correct, clear it and jump to the bootloader - * if ((MCUSR & (1 << WDRF)) && (Boot_Key == MAGIC_BOOT_KEY)) - * { - * Boot_Key = 0; - * ((void (*)(void))BOOTLOADER_START_ADDRESS)(); - * } - * } - * - * void Jump_To_Bootloader(void) - * { - * // If USB is used, detach from the bus and reset it - * USB_Disable(); - * - * // Disable all interrupts - * cli(); - * - * // Wait two seconds for the USB detachment to register on the host - * Delay_MS(2000); - * - * // Set the bootloader key to the magic value and force a reset - * Boot_Key = MAGIC_BOOT_KEY; - * wdt_enable(WDTO_250MS); - * for (;;); - * } - * \endcode - * - * Note that the bootloader magic key can be any arbitrary value. The FLASH_SIZE_BYTES and - * BOOTLOADER_SEC_SIZE_BYTES tokens should be replaced with the total flash size of the AVR - * in bytes, and the allocated size of the bootloader section for the target AVR. - * - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_SoftwareBootloaderStart Entering the Bootloader via Software + * + * A common requirement of many applications is the ability to jump to the programmed bootloader of a chip + * on demand, via the code's firmware (i.e. not as a result of any physical user interaction with the + * hardware). This might be required because the device does not have any physical user input, or simply + * just to streamline the device upgrade process on the host PC. + * + * The following C code snippets may be used to enter the bootloader upon request by the user application. + * By using the watchdog to physically reset the controller, it is ensured that all system hardware is + * completely reset to their defaults before the bootloader is run. This is important; since bootloaders + * are written to occupy a very limited space, they usually make assumptions about the register states based + * on the default values after a hard-reset of the chip. + * + * \section Sec_SoftareBootAVR8 AVR8 Architecture + * The following software bootloader jump code is written for the AVR8 architecture. + * + * \code + * #include + * #include + * #include + * + * #include + * #include + * + * uint32_t Boot_Key ATTR_NO_INIT; + * + * #define MAGIC_BOOT_KEY 0xDC42ACCA + * #define BOOTLOADER_START_ADDRESS (FLASH_SIZE_BYTES - BOOTLOADER_SEC_SIZE_BYTES) + * + * void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3); + * void Bootloader_Jump_Check(void) + * { + * // If the reset source was the bootloader and the key is correct, clear it and jump to the bootloader + * if ((MCUSR & (1 << WDRF)) && (Boot_Key == MAGIC_BOOT_KEY)) + * { + * Boot_Key = 0; + * ((void (*)(void))BOOTLOADER_START_ADDRESS)(); + * } + * } + * + * void Jump_To_Bootloader(void) + * { + * // If USB is used, detach from the bus and reset it + * USB_Disable(); + * + * // Disable all interrupts + * cli(); + * + * // Wait two seconds for the USB detachment to register on the host + * Delay_MS(2000); + * + * // Set the bootloader key to the magic value and force a reset + * Boot_Key = MAGIC_BOOT_KEY; + * wdt_enable(WDTO_250MS); + * for (;;); + * } + * \endcode + * + * Note that the bootloader magic key can be any arbitrary value. The FLASH_SIZE_BYTES and + * BOOTLOADER_SEC_SIZE_BYTES tokens should be replaced with the total flash size of the AVR + * in bytes, and the allocated size of the bootloader section for the target AVR. + * + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/VIDAndPIDValues.txt b/hal/at90usb646/LUFA/DoxygenPages/VIDAndPIDValues.txt index 38d34ac..17d9e17 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/VIDAndPIDValues.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/VIDAndPIDValues.txt @@ -1,424 +1,424 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_VIDPID VID and PID values - * - * \section Sec_VIDPID_Allocations - * The LUFA library uses VID/PID combinations generously donated by Atmel. The following VID/PID combinations - * are used within the LUFA demos, and thus may be re-used by derivations of each demo. Free PID values may be - * used by future LUFA demo projects. - * - * These VID/PID values should not be used in commercial designs under any circumstances. Private projects - * may use the following values freely, but must accept any collisions due to other LUFA derived private projects - * sharing identical values. It is suggested that private projects using interfaces compatible with existing - * demos share the same VID/PID value. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- * VID - * - * PID - * - * Usage - *
- * 0x03EB - * - * 0x2040 - * - * Test VID/PID (See below) - *
- * 0x03EB - * - * 0x2041 - * - * Mouse Demo Application - *
- * 0x03EB - * - * 0x2042 - * - * Keyboard Demo Application - *
- * 0x03EB - * - * 0x2043 - * - * Joystick Demo Application - *
- * 0x03EB - * - * 0x2044 - * - * CDC Demo Application - *
- * 0x03EB - * - * 0x2045 - * - * Mass Storage Demo Application - *
- * 0x03EB - * - * 0x2046 - * - * Audio Output Demo Application - *
- * 0x03EB - * - * 0x2047 - * - * Audio Input Demo Application - *
- * 0x03EB - * - * 0x2048 - * - * MIDI Demo Application - *
- * 0x03EB - * - * 0x2049 - * - * MagStripe Project - *
- * 0x03EB - * - * 0x204A - * - * CDC Bootloader - *
- * 0x03EB - * - * 0x204B - * - * USB to Serial Demo Application - *
- * 0x03EB - * - * 0x204C - * - * RNDIS Demo Application - *
- * 0x03EB - * - * 0x204D - * - * Combined Keyboard and Mouse Demo Application - *
- * 0x03EB - * - * 0x204E - * - * Dual CDC Demo Application - *
- * 0x03EB - * - * 0x204F - * - * Generic HID Demo Application - *
- * 0x03EB - * - * 0x2060 - * - * Benito Programmer Project - *
- * 0x03EB - * - * 0x2061 - * - * Combined Mass Storage and Keyboard Demo - *
- * 0x03EB - * - * 0x2062 - * - * Combined CDC and Mouse Demo - *
- * 0x03EB - * - * 0x2063 - * - * Mass Storage/HID Interface Datalogger Project - *
- * 0x03EB - * - * 0x2064 - * - * Interfaceless Control-Only LUFA Devices - *
- * 0x03EB - * - * 0x2065 - * - * Test and Measurement Demo - *
- * 0x03EB - * - * 0x2066 - * - * Multiple Report Keyboard/Mouse HID Demo - *
- * 0x03EB - * - * 0x2067 - * - * HID Class Bootloader - *
- * 0x03EB - * - * 0x2068 - * - * Virtual Serial/Mass Storage Demo - *
- * 0x03EB - * - * 0x2069 - * - * Webserver Project - *
- * 0x03EB - * - * 0x206A - * - * Media Control Project - *
- * 0x03EB - * - * 0x206B - * - * Currently Unallocated - *
- * 0x03EB - * - * 0x206C - * - * Currently Unallocated - *
- * 0x03EB - * - * 0x206D - * - * Currently Unallocated - *
- * 0x03EB - * - * 0x206E - * - * Currently Unallocated - *
- * 0x03EB - * - * 0x206F - * - * Currently Unallocated - *
- * - * \section Sec_Test_VIDPID The Test VID/PID Combination: - * For use in testing of LUFA powered devices during development only, by non-commercial entities. - * All devices must accept collisions on this VID/PID range (from other in-development LUFA devices) - * to be resolved by using a unique release number in the Device Descriptor. No devices using this - * VID/PID combination may be released to the general public. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_VIDPID VID and PID values + * + * \section Sec_VIDPID_Allocations + * The LUFA library uses VID/PID combinations generously donated by Atmel. The following VID/PID combinations + * are used within the LUFA demos, and thus may be re-used by derivations of each demo. Free PID values may be + * used by future LUFA demo projects. + * + * These VID/PID values should not be used in commercial designs under any circumstances. Private projects + * may use the following values freely, but must accept any collisions due to other LUFA derived private projects + * sharing identical values. It is suggested that private projects using interfaces compatible with existing + * demos share the same VID/PID value. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
+ * VID + * + * PID + * + * Usage + *
+ * 0x03EB + * + * 0x2040 + * + * Test VID/PID (See below) + *
+ * 0x03EB + * + * 0x2041 + * + * Mouse Demo Application + *
+ * 0x03EB + * + * 0x2042 + * + * Keyboard Demo Application + *
+ * 0x03EB + * + * 0x2043 + * + * Joystick Demo Application + *
+ * 0x03EB + * + * 0x2044 + * + * CDC Demo Application + *
+ * 0x03EB + * + * 0x2045 + * + * Mass Storage Demo Application + *
+ * 0x03EB + * + * 0x2046 + * + * Audio Output Demo Application + *
+ * 0x03EB + * + * 0x2047 + * + * Audio Input Demo Application + *
+ * 0x03EB + * + * 0x2048 + * + * MIDI Demo Application + *
+ * 0x03EB + * + * 0x2049 + * + * MagStripe Project + *
+ * 0x03EB + * + * 0x204A + * + * CDC Bootloader + *
+ * 0x03EB + * + * 0x204B + * + * USB to Serial Demo Application + *
+ * 0x03EB + * + * 0x204C + * + * RNDIS Demo Application + *
+ * 0x03EB + * + * 0x204D + * + * Combined Keyboard and Mouse Demo Application + *
+ * 0x03EB + * + * 0x204E + * + * Dual CDC Demo Application + *
+ * 0x03EB + * + * 0x204F + * + * Generic HID Demo Application + *
+ * 0x03EB + * + * 0x2060 + * + * Benito Programmer Project + *
+ * 0x03EB + * + * 0x2061 + * + * Combined Mass Storage and Keyboard Demo + *
+ * 0x03EB + * + * 0x2062 + * + * Combined CDC and Mouse Demo + *
+ * 0x03EB + * + * 0x2063 + * + * Mass Storage/HID Interface Datalogger Project + *
+ * 0x03EB + * + * 0x2064 + * + * Interfaceless Control-Only LUFA Devices + *
+ * 0x03EB + * + * 0x2065 + * + * Test and Measurement Demo + *
+ * 0x03EB + * + * 0x2066 + * + * Multiple Report Keyboard/Mouse HID Demo + *
+ * 0x03EB + * + * 0x2067 + * + * HID Class Bootloader + *
+ * 0x03EB + * + * 0x2068 + * + * Virtual Serial/Mass Storage Demo + *
+ * 0x03EB + * + * 0x2069 + * + * Webserver Project + *
+ * 0x03EB + * + * 0x206A + * + * Media Control Project + *
+ * 0x03EB + * + * 0x206B + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206C + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206D + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206E + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206F + * + * Currently Unallocated + *
+ * + * \section Sec_Test_VIDPID The Test VID/PID Combination: + * For use in testing of LUFA powered devices during development only, by non-commercial entities. + * All devices must accept collisions on this VID/PID range (from other in-development LUFA devices) + * to be resolved by using a unique release number in the Device Descriptor. No devices using this + * VID/PID combination may be released to the general public. + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/WhyUseLUFA.txt b/hal/at90usb646/LUFA/DoxygenPages/WhyUseLUFA.txt index 9fba3df..5644be0 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/WhyUseLUFA.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/WhyUseLUFA.txt @@ -1,43 +1,43 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** - * \page Page_WhyUseLUFA Why Use LUFA? - * - * The LUFA Library has many advantages over implementing the code required to drive the USB AVRs directly. - * It is much more preferable to incorporate LUFA into your existing projects - or even make a new project - * using LUFA - than it is to start from scratch and use the USB AVR registers directly. Some of these reasons - * are: - * - * - Portability: - * The LUFA stack is designed to run (at some capacity) on the entire Atmel range of USB AVRs, regardless of the - * exact USB controller revision used. If you decide to implement your own USB stack, you will either need to - * code around the differences between each USB AVR controller's implementation between different chip models, or - * require your code to run on only one specific USB AVR model series. - * - * - Speed of Development: - * LUFA ships with a wide range of pre-made demos, bootloaders and projects for you to try, learn and extend. Each - * of these demos are tested (where possible) across as many USB AVRs and Operating Systems as possible, to ensure - * that they work under as many conditions as possible. In addition, there are inbuilt class drivers for several of - * the USB classes which you can make use of in your projects with minimal effort. - * - * - Maintainability: - * As LUFA takes care of much of the USB implementation, you can be left to focusing on your actual project's - * functionality, rather than being held back developing and debugging the USB stack code. Since LUFA uses clear APIs - * for USB development, your code will be more readable than if it had the low level USB stack code integrated into - * it directly. Updating the LUFA library is a simple folder-replacement and gives new features and bug fixes in - * seconds each time a new release is made. - * - * - Size: - * Not just requiring less code to make complex USB devices, LUFA is written to compile down as much as possible into - * optimal code, to occupy only a small space for its feature set. - * - * - Support: - * Since many people are now using LUFA in their own projects, you can take advantage of other's knowledge when you run - * into difficulties or need some advice. In addition, you can also email the library author to receive personalized - * support when you need it (subject to author's schedule). - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_WhyUseLUFA Why Use LUFA? + * + * The LUFA Library has many advantages over implementing the code required to drive the USB AVRs directly. + * It is much more preferable to incorporate LUFA into your existing projects - or even make a new project + * using LUFA - than it is to start from scratch and use the USB AVR registers directly. Some of these reasons + * are: + * + * - Portability: + * The LUFA stack is designed to run (at some capacity) on the entire Atmel range of USB AVRs, regardless of the + * exact USB controller revision used. If you decide to implement your own USB stack, you will either need to + * code around the differences between each USB AVR controller's implementation between different chip models, or + * require your code to run on only one specific USB AVR model series. + * + * - Speed of Development: + * LUFA ships with a wide range of pre-made demos, bootloaders and projects for you to try, learn and extend. Each + * of these demos are tested (where possible) across as many USB AVRs and Operating Systems as possible, to ensure + * that they work under as many conditions as possible. In addition, there are inbuilt class drivers for several of + * the USB classes which you can make use of in your projects with minimal effort. + * + * - Maintainability: + * As LUFA takes care of much of the USB implementation, you can be left to focusing on your actual project's + * functionality, rather than being held back developing and debugging the USB stack code. Since LUFA uses clear APIs + * for USB development, your code will be more readable than if it had the low level USB stack code integrated into + * it directly. Updating the LUFA library is a simple folder-replacement and gives new features and bug fixes in + * seconds each time a new release is made. + * + * - Size: + * Not just requiring less code to make complex USB devices, LUFA is written to compile down as much as possible into + * optimal code, to occupy only a small space for its feature set. + * + * - Support: + * Since many people are now using LUFA in their own projects, you can take advantage of other's knowledge when you run + * into difficulties or need some advice. In addition, you can also email the library author to receive personalized + * support when you need it (subject to author's schedule). + */ + diff --git a/hal/at90usb646/LUFA/DoxygenPages/WritingBoardDrivers.txt b/hal/at90usb646/LUFA/DoxygenPages/WritingBoardDrivers.txt index 1b33269..e09e7d0 100644 --- a/hal/at90usb646/LUFA/DoxygenPages/WritingBoardDrivers.txt +++ b/hal/at90usb646/LUFA/DoxygenPages/WritingBoardDrivers.txt @@ -1,27 +1,27 @@ -/** \file - * - * This file contains special DoxyGen information for the generation of the main page and other special - * documentation pages. It is not a project source file. - */ - -/** \page Page_WritingBoardDrivers Writing LUFA Board Drivers - * - * LUFA ships with several basic pre-made board drivers, to control hardware present on the supported board - * hardware - such as Dataflash ICs, LEDs, Joysticks, or other hardware peripherals. When compiling an application - * which makes use of one or more board drivers located in LUFA/Drivers/Board, you must also indicate what board - * hardware you are using in your project makefile. This is done by defining the BOARD macro using the -D switch - * passed to the compiler, with a constant of BOARD_{Name}. For example -DBOARD=BOARD_USBKEY instructs the - * compiler to use the USBKEY board hardware drivers. - * - * If your application does not use *any* board level drivers, you can omit the definition of the BOARD macro. - * However, some users may wish to write their own custom board hardware drivers which are to remain compatible - * with the LUFA hardware API. To do this, the BOARD macro should be defined to the value BOARD_USER. This indicates - * that the board level drivers should be located in a folder named "Board" located inside the application's folder. - * - * When used, the driver stub files located in the LUFA/CodeTemplates/DriverStubs folder should be copied to the user - * Board/ directory, and fleshed out to include the values and code needed to control the custom board hardware. Once - * done, the existing LUFA board level APIs (accessed in the regular LUFA/Drivers/Board/ folder) will redirect to the - * user board drivers, maintaining code compatibility and allowing for a different board to be selected through the - * project makefile with no code changes. - */ - +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_WritingBoardDrivers Writing LUFA Board Drivers + * + * LUFA ships with several basic pre-made board drivers, to control hardware present on the supported board + * hardware - such as Dataflash ICs, LEDs, Joysticks, or other hardware peripherals. When compiling an application + * which makes use of one or more board drivers located in LUFA/Drivers/Board, you must also indicate what board + * hardware you are using in your project makefile. This is done by defining the BOARD macro using the -D switch + * passed to the compiler, with a constant of BOARD_{Name}. For example -DBOARD=BOARD_USBKEY instructs the + * compiler to use the USBKEY board hardware drivers. + * + * If your application does not use *any* board level drivers, you can omit the definition of the BOARD macro. + * However, some users may wish to write their own custom board hardware drivers which are to remain compatible + * with the LUFA hardware API. To do this, the BOARD macro should be defined to the value BOARD_USER. This indicates + * that the board level drivers should be located in a folder named "Board" located inside the application's folder. + * + * When used, the driver stub files located in the LUFA/CodeTemplates/DriverStubs folder should be copied to the user + * Board/ directory, and fleshed out to include the values and code needed to control the custom board hardware. Once + * done, the existing LUFA board level APIs (accessed in the regular LUFA/Drivers/Board/ folder) will redirect to the + * user board drivers, maintaining code compatibility and allowing for a different board to be selected through the + * project makefile with no code changes. + */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Class/CDCClass.h b/hal/at90usb646/LUFA/Drivers/USB/Class/CDCClass.h index 6bfd384..baa52be 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Class/CDCClass.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Class/CDCClass.h @@ -1,80 +1,80 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Master include file for the library USB CDC-ACM Class driver. - * - * Master include file for the library USB CDC Class driver, for both host and device modes, where available. - * - * This file should be included in all user projects making use of this optional class driver, instead of - * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. - */ - -/** \ingroup Group_USBClassDrivers - * \defgroup Group_USBClassCDC CDC-ACM (Virtual Serial) Class Driver - * - * \section Sec_Dependencies Module Source Dependencies - * The following files must be built with any user project that uses this module: - * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) - * - LUFA/Drivers/USB/Class/Host/CDCClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) - * - * \section Sec_ModDescription Module Description - * CDC Class Driver module. This module contains an internal implementation of the USB CDC-ACM class Virtual Serial - * Ports, for both Device and Host USB modes. User applications can use this class driver instead of implementing the - * CDC class manually via the low-level LUFA APIs. - * - * This module is designed to simplify the user code by exposing only the required interface needed to interface with - * Hosts or Devices using the USB CDC Class. - * - * @{ - */ - -#ifndef _CDC_CLASS_H_ -#define _CDC_CLASS_H_ - - /* Macros: */ - #define __INCLUDE_FROM_USB_DRIVER - #define __INCLUDE_FROM_CDC_DRIVER - - /* Includes: */ - #include "../Core/USBMode.h" - - #if defined(USB_CAN_BE_DEVICE) - #include "Device/CDCClassDevice.h" - #endif - - #if defined(USB_CAN_BE_HOST) - #include "Host/CDCClassHost.h" - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB CDC-ACM Class driver. + * + * Master include file for the library USB CDC Class driver, for both host and device modes, where available. + * + * This file should be included in all user projects making use of this optional class driver, instead of + * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. + */ + +/** \ingroup Group_USBClassDrivers + * \defgroup Group_USBClassCDC CDC-ACM (Virtual Serial) Class Driver + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/CDCClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * CDC Class Driver module. This module contains an internal implementation of the USB CDC-ACM class Virtual Serial + * Ports, for both Device and Host USB modes. User applications can use this class driver instead of implementing the + * CDC class manually via the low-level LUFA APIs. + * + * This module is designed to simplify the user code by exposing only the required interface needed to interface with + * Hosts or Devices using the USB CDC Class. + * + * @{ + */ + +#ifndef _CDC_CLASS_H_ +#define _CDC_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_CDC_DRIVER + + /* Includes: */ + #include "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/CDCClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/CDCClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h b/hal/at90usb646/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h index f14a766..d612a05 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h @@ -1,386 +1,386 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common definitions and declarations for the library USB CDC Class driver. - * - * Common definitions and declarations for the library USB CDC Class driver. - * - * \note This file should not be included directly. It is automatically included as needed by the USB module driver - * dispatch header located in LUFA/Drivers/USB.h. - */ - -/** \ingroup Group_USBClassCDC - * \defgroup Group_USBClassCDCCommon Common Class Definitions - * - * \section Sec_ModDescription Module Description - * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB - * CDC Class. - * - * @{ - */ - -#ifndef _CDC_CLASS_COMMON_H_ -#define _CDC_CLASS_COMMON_H_ - - /* Includes: */ - #include "../../Core/StdDescriptors.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_CDC_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. - #endif - - /* Macros: */ - /** \name Virtual Control Line Masks */ - //@{ - /** Mask for the DTR handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request - * from the host, to indicate that the DTR line state should be high. - */ - #define CDC_CONTROL_LINE_OUT_DTR (1 << 0) - - /** Mask for the RTS handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request - * from the host, to indicate that the RTS line state should be high. - */ - #define CDC_CONTROL_LINE_OUT_RTS (1 << 1) - - /** Mask for the DCD handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification - * from the device to the host, to indicate that the DCD line state is currently high. - */ - #define CDC_CONTROL_LINE_IN_DCD (1 << 0) - - /** Mask for the DSR handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification - * from the device to the host, to indicate that the DSR line state is currently high. - */ - #define CDC_CONTROL_LINE_IN_DSR (1 << 1) - - /** Mask for the BREAK handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification - * from the device to the host, to indicate that the BREAK line state is currently high. - */ - #define CDC_CONTROL_LINE_IN_BREAK (1 << 2) - - /** Mask for the RING handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification - * from the device to the host, to indicate that the RING line state is currently high. - */ - #define CDC_CONTROL_LINE_IN_RING (1 << 3) - - /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, - * to indicate that a framing error has occurred on the virtual serial port. - */ - #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4) - - /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, - * to indicate that a parity error has occurred on the virtual serial port. - */ - #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5) - - /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, - * to indicate that a data overrun error has occurred on the virtual serial port. - */ - #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6) - //@} - - /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a - * uniform structure but variable sized data payloads, thus cannot be represented accurately by - * a single typedef struct. A macro is used instead so that functional descriptors can be created - * easily by specifying the size of the payload. This allows \c sizeof() to work correctly. - * - * \param[in] DataSize Size in bytes of the CDC functional descriptor's data payload. - */ - #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \ - struct \ - { \ - USB_Descriptor_Header_t Header; \ - uint8_t SubType; \ - uint8_t Data[DataSize]; \ - } - - /* Enums: */ - /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CDC - * device class. - */ - enum CDC_Descriptor_ClassSubclassProtocol_t - { - CDC_CSCP_CDCClass = 0x02, /**< Descriptor Class value indicating that the device or interface - * belongs to the CDC class. - */ - CDC_CSCP_NoSpecificSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface - * belongs to no specific subclass of the CDC class. - */ - CDC_CSCP_ACMSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or interface - * belongs to the Abstract Control Model CDC subclass. - */ - CDC_CSCP_ATCommandProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface - * belongs to the AT Command protocol of the CDC class. - */ - CDC_CSCP_NoSpecificProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface - * belongs to no specific protocol of the CDC class. - */ - CDC_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device or interface - * belongs to a vendor-specific protocol of the CDC class. - */ - CDC_CSCP_CDCDataClass = 0x0A, /**< Descriptor Class value indicating that the device or interface - * belongs to the CDC Data class. - */ - CDC_CSCP_NoDataSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface - * belongs to no specific subclass of the CDC data class. - */ - CDC_CSCP_NoDataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface - * belongs to no specific protocol of the CDC data class. - */ - }; - - /** Enum for the CDC class specific control requests that can be issued by the USB bus host. */ - enum CDC_ClassRequests_t - { - CDC_REQ_SendEncapsulatedCommand = 0x00, /**< CDC class-specific request to send an encapsulated command to the device. */ - CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */ - CDC_REQ_SetLineEncoding = 0x20, /**< CDC class-specific request to set the current virtual serial port configuration settings. */ - CDC_REQ_GetLineEncoding = 0x21, /**< CDC class-specific request to get the current virtual serial port configuration settings. */ - CDC_REQ_SetControlLineState = 0x22, /**< CDC class-specific request to set the current virtual serial port handshake line states. */ - CDC_REQ_SendBreak = 0x23, /**< CDC class-specific request to send a break to the receiver via the carrier channel. */ - }; - - /** Enum for the CDC class specific notification requests that can be issued by a CDC device to a host. */ - enum CDC_ClassNotifications_t - { - CDC_NOTIF_SerialState = 0x20, /**< Notification type constant for a change in the virtual serial port - * handshake line states, for use with a \ref USB_Request_Header_t - * notification structure when sent to the host via the CDC notification - * endpoint. - */ - }; - - /** Enum for the CDC class specific interface descriptor subtypes. */ - enum CDC_DescriptorSubtypes_t - { - CDC_DSUBTYPE_CSInterface_Header = 0x00, /**< CDC class-specific Header functional descriptor. */ - CDC_DSUBTYPE_CSInterface_CallManagement = 0x01, /**< CDC class-specific Call Management functional descriptor. */ - CDC_DSUBTYPE_CSInterface_ACM = 0x02, /**< CDC class-specific Abstract Control Model functional descriptor. */ - CDC_DSUBTYPE_CSInterface_DirectLine = 0x03, /**< CDC class-specific Direct Line functional descriptor. */ - CDC_DSUBTYPE_CSInterface_TelephoneRinger = 0x04, /**< CDC class-specific Telephone Ringer functional descriptor. */ - CDC_DSUBTYPE_CSInterface_TelephoneCall = 0x05, /**< CDC class-specific Telephone Call functional descriptor. */ - CDC_DSUBTYPE_CSInterface_Union = 0x06, /**< CDC class-specific Union functional descriptor. */ - CDC_DSUBTYPE_CSInterface_CountrySelection = 0x07, /**< CDC class-specific Country Selection functional descriptor. */ - CDC_DSUBTYPE_CSInterface_TelephoneOpModes = 0x08, /**< CDC class-specific Telephone Operation Modes functional descriptor. */ - CDC_DSUBTYPE_CSInterface_USBTerminal = 0x09, /**< CDC class-specific USB Terminal functional descriptor. */ - CDC_DSUBTYPE_CSInterface_NetworkChannel = 0x0A, /**< CDC class-specific Network Channel functional descriptor. */ - CDC_DSUBTYPE_CSInterface_ProtocolUnit = 0x0B, /**< CDC class-specific Protocol Unit functional descriptor. */ - CDC_DSUBTYPE_CSInterface_ExtensionUnit = 0x0C, /**< CDC class-specific Extension Unit functional descriptor. */ - CDC_DSUBTYPE_CSInterface_MultiChannel = 0x0D, /**< CDC class-specific Multi-Channel Management functional descriptor. */ - CDC_DSUBTYPE_CSInterface_CAPI = 0x0E, /**< CDC class-specific Common ISDN API functional descriptor. */ - CDC_DSUBTYPE_CSInterface_Ethernet = 0x0F, /**< CDC class-specific Ethernet functional descriptor. */ - CDC_DSUBTYPE_CSInterface_ATM = 0x10, /**< CDC class-specific Asynchronous Transfer Mode functional descriptor. */ - }; - - /** Enum for the possible line encoding formats of a virtual serial port. */ - enum CDC_LineEncodingFormats_t - { - CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit. */ - CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits. */ - CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits. */ - }; - - /** Enum for the possible line encoding parity settings of a virtual serial port. */ - enum CDC_LineEncodingParity_t - { - CDC_PARITY_None = 0, /**< No parity bit mode on each frame. */ - CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame. */ - CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame. */ - CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame. */ - CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame. */ - }; - - /* Type Defines: */ - /** \brief CDC class-specific Functional Header Descriptor (LUFA naming conventions). - * - * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device - * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. - * See the CDC class specification for more details. - * - * \see \ref USB_CDC_StdDescriptor_FunctionalHeader_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ - uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, - * must be \ref CDC_DSUBTYPE_CSInterface_Header. - */ - uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device, - * encoded in BCD format. - */ - } ATTR_PACKED USB_CDC_Descriptor_FunctionalHeader_t; - - /** \brief CDC class-specific Functional Header Descriptor (USB-IF naming conventions). - * - * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device - * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. - * See the CDC class specification for more details. - * - * \see \ref USB_CDC_Descriptor_FunctionalHeader_t for the version of this type with non-standard LUFA specific - * element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, - * must be \ref CDC_DSUBTYPE_CSInterface_Header. - */ - uint16_t bcdCDC; /**< Version number of the CDC specification implemented by the device, encoded in BCD format. */ - } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalHeader_t; - - /** \brief CDC class-specific Functional ACM Descriptor (LUFA naming conventions). - * - * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface - * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. - * - * \see \ref USB_CDC_StdDescriptor_FunctionalACM_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ - uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, - * must be \ref CDC_DSUBTYPE_CSInterface_ACM. - */ - uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, - * this should be set to a fixed value of 0x06 - for other capabilities, refer - * to the CDC ACM specification. - */ - } ATTR_PACKED USB_CDC_Descriptor_FunctionalACM_t; - - /** \brief CDC class-specific Functional ACM Descriptor (USB-IF naming conventions). - * - * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface - * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. - * - * \see \ref USB_CDC_Descriptor_FunctionalACM_t for the version of this type with non-standard LUFA specific - * element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, - * must be \ref CDC_DSUBTYPE_CSInterface_ACM. - */ - uint8_t bmCapabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, - * this should be set to a fixed value of 0x06 - for other capabilities, refer - * to the CDC ACM specification. - */ - } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalACM_t; - - /** \brief CDC class-specific Functional Union Descriptor (LUFA naming conventions). - * - * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific - * CDC control and data interfaces are related. See the CDC class specification for more details. - * - * \see \ref USB_CDC_StdDescriptor_FunctionalUnion_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ - uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, - * must be \ref CDC_DSUBTYPE_CSInterface_Union. - */ - uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */ - uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */ - } ATTR_PACKED USB_CDC_Descriptor_FunctionalUnion_t; - - /** \brief CDC class-specific Functional Union Descriptor (USB-IF naming conventions). - * - * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific - * CDC control and data interfaces are related. See the CDC class specification for more details. - * - * \see \ref USB_CDC_Descriptor_FunctionalUnion_t for the version of this type with non-standard LUFA specific - * element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, - * must be \ref CDC_DSUBTYPE_CSInterface_Union. - */ - uint8_t bMasterInterface; /**< Interface number of the CDC Control interface. */ - uint8_t bSlaveInterface0; /**< Interface number of the CDC Data interface. */ - } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalUnion_t; - - /** \brief CDC Virtual Serial Port Line Encoding Settings Structure. - * - * Type define for a CDC Line Encoding structure, used to hold the various encoding parameters for a virtual - * serial port. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second. */ - uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the - * \ref CDC_LineEncodingFormats_t enum. - */ - uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the - * \ref CDC_LineEncodingParity_t enum. - */ - uint8_t DataBits; /**< Bits of data per character of the virtual serial port. */ - } ATTR_PACKED CDC_LineEncoding_t; - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB CDC Class driver. + * + * Common definitions and declarations for the library USB CDC Class driver. + * + * \note This file should not be included directly. It is automatically included as needed by the USB module driver + * dispatch header located in LUFA/Drivers/USB.h. + */ + +/** \ingroup Group_USBClassCDC + * \defgroup Group_USBClassCDCCommon Common Class Definitions + * + * \section Sec_ModDescription Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * CDC Class. + * + * @{ + */ + +#ifndef _CDC_CLASS_COMMON_H_ +#define _CDC_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../Core/StdDescriptors.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_CDC_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** \name Virtual Control Line Masks */ + //@{ + /** Mask for the DTR handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request + * from the host, to indicate that the DTR line state should be high. + */ + #define CDC_CONTROL_LINE_OUT_DTR (1 << 0) + + /** Mask for the RTS handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request + * from the host, to indicate that the RTS line state should be high. + */ + #define CDC_CONTROL_LINE_OUT_RTS (1 << 1) + + /** Mask for the DCD handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the DCD line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_DCD (1 << 0) + + /** Mask for the DSR handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the DSR line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_DSR (1 << 1) + + /** Mask for the BREAK handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the BREAK line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_BREAK (1 << 2) + + /** Mask for the RING handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the RING line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_RING (1 << 3) + + /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, + * to indicate that a framing error has occurred on the virtual serial port. + */ + #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4) + + /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, + * to indicate that a parity error has occurred on the virtual serial port. + */ + #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5) + + /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, + * to indicate that a data overrun error has occurred on the virtual serial port. + */ + #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6) + //@} + + /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a + * uniform structure but variable sized data payloads, thus cannot be represented accurately by + * a single typedef struct. A macro is used instead so that functional descriptors can be created + * easily by specifying the size of the payload. This allows \c sizeof() to work correctly. + * + * \param[in] DataSize Size in bytes of the CDC functional descriptor's data payload. + */ + #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \ + struct \ + { \ + USB_Descriptor_Header_t Header; \ + uint8_t SubType; \ + uint8_t Data[DataSize]; \ + } + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CDC + * device class. + */ + enum CDC_Descriptor_ClassSubclassProtocol_t + { + CDC_CSCP_CDCClass = 0x02, /**< Descriptor Class value indicating that the device or interface + * belongs to the CDC class. + */ + CDC_CSCP_NoSpecificSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface + * belongs to no specific subclass of the CDC class. + */ + CDC_CSCP_ACMSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or interface + * belongs to the Abstract Control Model CDC subclass. + */ + CDC_CSCP_ATCommandProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the AT Command protocol of the CDC class. + */ + CDC_CSCP_NoSpecificProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface + * belongs to no specific protocol of the CDC class. + */ + CDC_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device or interface + * belongs to a vendor-specific protocol of the CDC class. + */ + CDC_CSCP_CDCDataClass = 0x0A, /**< Descriptor Class value indicating that the device or interface + * belongs to the CDC Data class. + */ + CDC_CSCP_NoDataSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface + * belongs to no specific subclass of the CDC data class. + */ + CDC_CSCP_NoDataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface + * belongs to no specific protocol of the CDC data class. + */ + }; + + /** Enum for the CDC class specific control requests that can be issued by the USB bus host. */ + enum CDC_ClassRequests_t + { + CDC_REQ_SendEncapsulatedCommand = 0x00, /**< CDC class-specific request to send an encapsulated command to the device. */ + CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */ + CDC_REQ_SetLineEncoding = 0x20, /**< CDC class-specific request to set the current virtual serial port configuration settings. */ + CDC_REQ_GetLineEncoding = 0x21, /**< CDC class-specific request to get the current virtual serial port configuration settings. */ + CDC_REQ_SetControlLineState = 0x22, /**< CDC class-specific request to set the current virtual serial port handshake line states. */ + CDC_REQ_SendBreak = 0x23, /**< CDC class-specific request to send a break to the receiver via the carrier channel. */ + }; + + /** Enum for the CDC class specific notification requests that can be issued by a CDC device to a host. */ + enum CDC_ClassNotifications_t + { + CDC_NOTIF_SerialState = 0x20, /**< Notification type constant for a change in the virtual serial port + * handshake line states, for use with a \ref USB_Request_Header_t + * notification structure when sent to the host via the CDC notification + * endpoint. + */ + }; + + /** Enum for the CDC class specific interface descriptor subtypes. */ + enum CDC_DescriptorSubtypes_t + { + CDC_DSUBTYPE_CSInterface_Header = 0x00, /**< CDC class-specific Header functional descriptor. */ + CDC_DSUBTYPE_CSInterface_CallManagement = 0x01, /**< CDC class-specific Call Management functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ACM = 0x02, /**< CDC class-specific Abstract Control Model functional descriptor. */ + CDC_DSUBTYPE_CSInterface_DirectLine = 0x03, /**< CDC class-specific Direct Line functional descriptor. */ + CDC_DSUBTYPE_CSInterface_TelephoneRinger = 0x04, /**< CDC class-specific Telephone Ringer functional descriptor. */ + CDC_DSUBTYPE_CSInterface_TelephoneCall = 0x05, /**< CDC class-specific Telephone Call functional descriptor. */ + CDC_DSUBTYPE_CSInterface_Union = 0x06, /**< CDC class-specific Union functional descriptor. */ + CDC_DSUBTYPE_CSInterface_CountrySelection = 0x07, /**< CDC class-specific Country Selection functional descriptor. */ + CDC_DSUBTYPE_CSInterface_TelephoneOpModes = 0x08, /**< CDC class-specific Telephone Operation Modes functional descriptor. */ + CDC_DSUBTYPE_CSInterface_USBTerminal = 0x09, /**< CDC class-specific USB Terminal functional descriptor. */ + CDC_DSUBTYPE_CSInterface_NetworkChannel = 0x0A, /**< CDC class-specific Network Channel functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ProtocolUnit = 0x0B, /**< CDC class-specific Protocol Unit functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ExtensionUnit = 0x0C, /**< CDC class-specific Extension Unit functional descriptor. */ + CDC_DSUBTYPE_CSInterface_MultiChannel = 0x0D, /**< CDC class-specific Multi-Channel Management functional descriptor. */ + CDC_DSUBTYPE_CSInterface_CAPI = 0x0E, /**< CDC class-specific Common ISDN API functional descriptor. */ + CDC_DSUBTYPE_CSInterface_Ethernet = 0x0F, /**< CDC class-specific Ethernet functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ATM = 0x10, /**< CDC class-specific Asynchronous Transfer Mode functional descriptor. */ + }; + + /** Enum for the possible line encoding formats of a virtual serial port. */ + enum CDC_LineEncodingFormats_t + { + CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit. */ + CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits. */ + CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits. */ + }; + + /** Enum for the possible line encoding parity settings of a virtual serial port. */ + enum CDC_LineEncodingParity_t + { + CDC_PARITY_None = 0, /**< No parity bit mode on each frame. */ + CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame. */ + CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame. */ + CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame. */ + CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame. */ + }; + + /* Type Defines: */ + /** \brief CDC class-specific Functional Header Descriptor (LUFA naming conventions). + * + * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device + * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. + * See the CDC class specification for more details. + * + * \see \ref USB_CDC_StdDescriptor_FunctionalHeader_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Header. + */ + uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device, + * encoded in BCD format. + */ + } ATTR_PACKED USB_CDC_Descriptor_FunctionalHeader_t; + + /** \brief CDC class-specific Functional Header Descriptor (USB-IF naming conventions). + * + * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device + * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. + * See the CDC class specification for more details. + * + * \see \ref USB_CDC_Descriptor_FunctionalHeader_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Header. + */ + uint16_t bcdCDC; /**< Version number of the CDC specification implemented by the device, encoded in BCD format. */ + } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalHeader_t; + + /** \brief CDC class-specific Functional ACM Descriptor (LUFA naming conventions). + * + * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface + * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. + * + * \see \ref USB_CDC_StdDescriptor_FunctionalACM_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_ACM. + */ + uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, + * this should be set to a fixed value of 0x06 - for other capabilities, refer + * to the CDC ACM specification. + */ + } ATTR_PACKED USB_CDC_Descriptor_FunctionalACM_t; + + /** \brief CDC class-specific Functional ACM Descriptor (USB-IF naming conventions). + * + * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface + * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. + * + * \see \ref USB_CDC_Descriptor_FunctionalACM_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_ACM. + */ + uint8_t bmCapabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, + * this should be set to a fixed value of 0x06 - for other capabilities, refer + * to the CDC ACM specification. + */ + } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalACM_t; + + /** \brief CDC class-specific Functional Union Descriptor (LUFA naming conventions). + * + * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific + * CDC control and data interfaces are related. See the CDC class specification for more details. + * + * \see \ref USB_CDC_StdDescriptor_FunctionalUnion_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Union. + */ + uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */ + uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */ + } ATTR_PACKED USB_CDC_Descriptor_FunctionalUnion_t; + + /** \brief CDC class-specific Functional Union Descriptor (USB-IF naming conventions). + * + * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific + * CDC control and data interfaces are related. See the CDC class specification for more details. + * + * \see \ref USB_CDC_Descriptor_FunctionalUnion_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Union. + */ + uint8_t bMasterInterface; /**< Interface number of the CDC Control interface. */ + uint8_t bSlaveInterface0; /**< Interface number of the CDC Data interface. */ + } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalUnion_t; + + /** \brief CDC Virtual Serial Port Line Encoding Settings Structure. + * + * Type define for a CDC Line Encoding structure, used to hold the various encoding parameters for a virtual + * serial port. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second. */ + uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the + * \ref CDC_LineEncodingFormats_t enum. + */ + uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the + * \ref CDC_LineEncodingParity_t enum. + */ + uint8_t DataBits; /**< Bits of data per character of the virtual serial port. */ + } ATTR_PACKED CDC_LineEncoding_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c b/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c index 39b3ee0..427c968 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c @@ -1,365 +1,365 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../../Core/USBMode.h" - -#if defined(USB_CAN_BE_DEVICE) - -#define __INCLUDE_FROM_CDC_DRIVER -#define __INCLUDE_FROM_CDC_DEVICE_C -#include "CDCClassDevice.h" - -void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - if (!(Endpoint_IsSETUPReceived())) - return; - - if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) - return; - - switch (USB_ControlRequest.bRequest) - { - case CDC_REQ_GetLineEncoding: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - - while (!(Endpoint_IsINReady())); - - Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); - Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits); - - Endpoint_ClearIN(); - Endpoint_ClearStatusStage(); - } - - break; - case CDC_REQ_SetLineEncoding: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); - CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); - CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); - CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8(); - - Endpoint_ClearOUT(); - Endpoint_ClearStatusStage(); - - EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); - } - - break; - case CDC_REQ_SetControlLineState: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - Endpoint_ClearStatusStage(); - - CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; - - EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); - } - - break; - case CDC_REQ_SendBreak: - if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) - { - Endpoint_ClearSETUP(); - Endpoint_ClearStatusStage(); - - EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); - } - - break; - } -} - -bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State)); - - for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) - { - uint16_t Size; - uint8_t Type; - uint8_t Direction; - bool DoubleBanked; - - if (EndpointNum == CDCInterfaceInfo->Config.DataINEndpointNumber) - { - Size = CDCInterfaceInfo->Config.DataINEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_BULK; - DoubleBanked = CDCInterfaceInfo->Config.DataINEndpointDoubleBank; - } - else if (EndpointNum == CDCInterfaceInfo->Config.DataOUTEndpointNumber) - { - Size = CDCInterfaceInfo->Config.DataOUTEndpointSize; - Direction = ENDPOINT_DIR_OUT; - Type = EP_TYPE_BULK; - DoubleBanked = CDCInterfaceInfo->Config.DataOUTEndpointDoubleBank; - } - else if (EndpointNum == CDCInterfaceInfo->Config.NotificationEndpointNumber) - { - Size = CDCInterfaceInfo->Config.NotificationEndpointSize; - Direction = ENDPOINT_DIR_IN; - Type = EP_TYPE_INTERRUPT; - DoubleBanked = CDCInterfaceInfo->Config.NotificationEndpointDoubleBank; - } - else - { - continue; - } - - if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, - DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) - { - return false; - } - } - - return true; -} - -void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return; - - #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) - CDC_Device_Flush(CDCInterfaceInfo); - #endif -} - -uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const char* const String) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return ENDPOINT_RWSTREAM_DeviceDisconnected; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); - return Endpoint_Write_Stream_LE(String, strlen(String), NULL); -} - -uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const char* const Buffer, - const uint16_t Length) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return ENDPOINT_RWSTREAM_DeviceDisconnected; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); - return Endpoint_Write_Stream_LE(Buffer, Length, NULL); -} - -uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const uint8_t Data) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return ENDPOINT_RWSTREAM_DeviceDisconnected; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); - - if (!(Endpoint_IsReadWriteAllowed())) - { - Endpoint_ClearIN(); - - uint8_t ErrorCode; - - if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) - return ErrorCode; - } - - Endpoint_Write_8(Data); - return ENDPOINT_READYWAIT_NoError; -} - -uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return ENDPOINT_RWSTREAM_DeviceDisconnected; - - uint8_t ErrorCode; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); - - if (!(Endpoint_BytesInEndpoint())) - return ENDPOINT_READYWAIT_NoError; - - bool BankFull = !(Endpoint_IsReadWriteAllowed()); - - Endpoint_ClearIN(); - - if (BankFull) - { - if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) - return ErrorCode; - - Endpoint_ClearIN(); - } - - return ENDPOINT_READYWAIT_NoError; -} - -uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return 0; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); - - if (Endpoint_IsOUTReceived()) - { - if (!(Endpoint_BytesInEndpoint())) - { - Endpoint_ClearOUT(); - return 0; - } - else - { - return Endpoint_BytesInEndpoint(); - } - } - else - { - return 0; - } -} - -int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return -1; - - int16_t ReceivedByte = -1; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); - - if (Endpoint_IsOUTReceived()) - { - if (Endpoint_BytesInEndpoint()) - ReceivedByte = Endpoint_Read_8(); - - if (!(Endpoint_BytesInEndpoint())) - Endpoint_ClearOUT(); - } - - return ReceivedByte; -} - -void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) -{ - if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) - return; - - Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber); - - USB_Request_Header_t Notification = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), - .bRequest = CDC_NOTIF_SerialState, - .wValue = CPU_TO_LE16(0), - .wIndex = CPU_TO_LE16(0), - .wLength = CPU_TO_LE16(sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost)), - }; - - Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL); - Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost, - sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), - NULL); - Endpoint_ClearIN(); -} - -#if defined(FDEV_SETUP_STREAM) -void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - FILE* const Stream) -{ - *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar, _FDEV_SETUP_RW); - fdev_set_udata(Stream, CDCInterfaceInfo); -} - -void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - FILE* const Stream) -{ - *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar_Blocking, _FDEV_SETUP_RW); - fdev_set_udata(Stream, CDCInterfaceInfo); -} - -static int CDC_Device_putchar(char c, - FILE* Stream) -{ - return CDC_Device_SendByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0; -} - -static int CDC_Device_getchar(FILE* Stream) -{ - int16_t ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); - - if (ReceivedByte < 0) - return _FDEV_EOF; - - return ReceivedByte; -} - -static int CDC_Device_getchar_Blocking(FILE* Stream) -{ - int16_t ReceivedByte; - - while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return _FDEV_EOF; - - CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); - USB_USBTask(); - } - - return ReceivedByte; -} -#endif - -void CDC_Device_Event_Stub(void) -{ - -} - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_CDC_DRIVER +#define __INCLUDE_FROM_CDC_DEVICE_C +#include "CDCClassDevice.h" + +void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) + return; + + switch (USB_ControlRequest.bRequest) + { + case CDC_REQ_GetLineEncoding: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + + while (!(Endpoint_IsINReady())); + + Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); + Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); + Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); + Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits); + + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + + break; + case CDC_REQ_SetLineEncoding: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); + CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); + CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); + CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8(); + + Endpoint_ClearOUT(); + Endpoint_ClearStatusStage(); + + EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); + } + + break; + case CDC_REQ_SetControlLineState: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; + + EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); + } + + break; + case CDC_REQ_SendBreak: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); + } + + break; + } +} + +bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State)); + + for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) + { + uint16_t Size; + uint8_t Type; + uint8_t Direction; + bool DoubleBanked; + + if (EndpointNum == CDCInterfaceInfo->Config.DataINEndpointNumber) + { + Size = CDCInterfaceInfo->Config.DataINEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_BULK; + DoubleBanked = CDCInterfaceInfo->Config.DataINEndpointDoubleBank; + } + else if (EndpointNum == CDCInterfaceInfo->Config.DataOUTEndpointNumber) + { + Size = CDCInterfaceInfo->Config.DataOUTEndpointSize; + Direction = ENDPOINT_DIR_OUT; + Type = EP_TYPE_BULK; + DoubleBanked = CDCInterfaceInfo->Config.DataOUTEndpointDoubleBank; + } + else if (EndpointNum == CDCInterfaceInfo->Config.NotificationEndpointNumber) + { + Size = CDCInterfaceInfo->Config.NotificationEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_INTERRUPT; + DoubleBanked = CDCInterfaceInfo->Config.NotificationEndpointDoubleBank; + } + else + { + continue; + } + + if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, + DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) + { + return false; + } + } + + return true; +} + +void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return; + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + CDC_Device_Flush(CDCInterfaceInfo); + #endif +} + +uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const String) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + return Endpoint_Write_Stream_LE(String, strlen(String), NULL); +} + +uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const Buffer, + const uint16_t Length) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + return Endpoint_Write_Stream_LE(Buffer, Length, NULL); +} + +uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Data) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) + return ErrorCode; + } + + Endpoint_Write_8(Data); + return ENDPOINT_READYWAIT_NoError; +} + +uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpointNumber); + + if (!(Endpoint_BytesInEndpoint())) + return ENDPOINT_READYWAIT_NoError; + + bool BankFull = !(Endpoint_IsReadWriteAllowed()); + + Endpoint_ClearIN(); + + if (BankFull) + { + if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) + return ErrorCode; + + Endpoint_ClearIN(); + } + + return ENDPOINT_READYWAIT_NoError; +} + +uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return 0; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); + + if (Endpoint_IsOUTReceived()) + { + if (!(Endpoint_BytesInEndpoint())) + { + Endpoint_ClearOUT(); + return 0; + } + else + { + return Endpoint_BytesInEndpoint(); + } + } + else + { + return 0; + } +} + +int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return -1; + + int16_t ReceivedByte = -1; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpointNumber); + + if (Endpoint_IsOUTReceived()) + { + if (Endpoint_BytesInEndpoint()) + ReceivedByte = Endpoint_Read_8(); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + } + + return ReceivedByte; +} + +void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpointNumber); + + USB_Request_Header_t Notification = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = CDC_NOTIF_SerialState, + .wValue = CPU_TO_LE16(0), + .wIndex = CPU_TO_LE16(0), + .wLength = CPU_TO_LE16(sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost)), + }; + + Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL); + Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost, + sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), + NULL); + Endpoint_ClearIN(); +} + +#if defined(FDEV_SETUP_STREAM) +void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar, _FDEV_SETUP_RW); + fdev_set_udata(Stream, CDCInterfaceInfo); +} + +void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar_Blocking, _FDEV_SETUP_RW); + fdev_set_udata(Stream, CDCInterfaceInfo); +} + +static int CDC_Device_putchar(char c, + FILE* Stream) +{ + return CDC_Device_SendByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0; +} + +static int CDC_Device_getchar(FILE* Stream) +{ + int16_t ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); + + if (ReceivedByte < 0) + return _FDEV_EOF; + + return ReceivedByte; +} + +static int CDC_Device_getchar_Blocking(FILE* Stream) +{ + int16_t ReceivedByte; + + while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return _FDEV_EOF; + + CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); + USB_USBTask(); + } + + return ReceivedByte; +} +#endif + +void CDC_Device_Event_Stub(void) +{ + +} + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h b/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h index f803e2d..998b0a7 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h @@ -1,357 +1,357 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Device mode driver for the library USB CDC Class driver. - * - * Device mode driver for the library USB CDC Class driver. - * - * \note This file should not be included directly. It is automatically included as needed by the USB module driver - * dispatch header located in LUFA/Drivers/USB.h. - */ - -/** \ingroup Group_USBClassCDC - * \defgroup Group_USBClassCDCDevice CDC Class Device Mode Driver - * - * \section Sec_Dependencies Module Source Dependencies - * The following files must be built with any user project that uses this module: - * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) - * - * \section Sec_ModDescription Module Description - * Device Mode USB Class driver framework interface, for the CDC USB Class driver. - * - * \note There are several major drawbacks to the CDC-ACM standard USB class, however - * it is very standardized and thus usually available as a built-in driver on - * most platforms, and so is a better choice than a proprietary serial class. - * - * One major issue with CDC-ACM is that it requires two Interface descriptors, - * which will upset most hosts when part of a multi-function "Composite" USB - * device, as each interface will be loaded into a separate driver instance. To - * combat this, you should use the "Interface Association Descriptor" addendum to - * the USB standard which is available on most OSes when creating Composite devices. - * - * Another major oversight is that there is no mechanism for the host to notify the - * device that there is a data sink on the host side ready to accept data. This - * means that the device may try to send data while the host isn't listening, causing - * lengthy blocking timeouts in the transmission routines. To combat this, it is - * recommended that the virtual serial line DTR (Data Terminal Ready) be used where - * possible to determine if a host application is ready for data. - * - * @{ - */ - -#ifndef _CDC_CLASS_DEVICE_H_ -#define _CDC_CLASS_DEVICE_H_ - - /* Includes: */ - #include "../../USB.h" - #include "../Common/CDCClassCommon.h" - - #include - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_CDC_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Type Defines: */ - /** \brief CDC Class Device Mode Configuration and State Structure. - * - * Class state structure. An instance of this structure should be made for each CDC interface - * within the user application, and passed to each of the CDC class driver functions as the - * CDCInterfaceInfo parameter. This stores each CDC interface's configuration and state information. - */ - typedef struct - { - struct - { - uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device. */ - - uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint. */ - uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint. */ - bool DataINEndpointDoubleBank; /**< Indicates if the CDC interface's IN data endpoint should use double banking. */ - - uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint. */ - uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint. */ - bool DataOUTEndpointDoubleBank; /**< Indicates if the CDC interface's OUT data endpoint should use double banking. */ - - uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used. */ - uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used. */ - bool NotificationEndpointDoubleBank; /**< Indicates if the CDC interface's notification endpoint should use double banking. */ - } Config; /**< Config data for the USB class interface within the device. All elements in this section - * must be set or the interface will fail to enumerate and operate correctly. - */ - struct - { - struct - { - uint16_t HostToDevice; /**< Control line states from the host to device, as a set of \c CDC_CONTROL_LINE_OUT_* - * masks. This value is updated each time \ref CDC_Device_USBTask() is called. - */ - uint16_t DeviceToHost; /**< Control line states from the device to host, as a set of \c CDC_CONTROL_LINE_IN_* - * masks - to notify the host of changes to these values, call the - * \ref CDC_Device_SendControlLineStateChange() function. - */ - } ControlLineStates; /**< Current states of the virtual serial port's control lines between the device and host. */ - - CDC_LineEncoding_t LineEncoding; /** Line encoding used in the virtual serial port, for the device's information. - * This is generally only used if the virtual serial port data is to be - * reconstructed on a physical UART. - */ - } State; /**< State data for the USB class interface within the device. All elements in this section - * are reset to their defaults when the interface is enumerated. - */ - } USB_ClassInfo_CDC_Device_t; - - /* Function Prototypes: */ - /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library - * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing - * the given CDC interface is selected. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise. - */ - bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** Processes incoming control requests from the host, that are directed to the given CDC class interface. This should be - * linked to the library \ref EVENT_USB_Device_ControlRequest() event. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** General management task for a given CDC class interface, required for the correct operation of the interface. This should - * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a - * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the - * user program by declaring a handler function with the same name and parameters listed here. The new line encoding - * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a - * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the - * user program by declaring a handler function with the same name and parameters listed here. The new control line states - * are available in the \c ControlLineStates.HostToDevice value inside the CDC interface structure passed as a parameter, set as - * a mask of \c CDC_CONTROL_LINE_OUT_* masks. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** CDC class driver event for a send break request sent to the device from the host. This is generally used to separate - * data or to indicate a special condition to the receiving device. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param[in] Duration Duration of the break that has been sent by the host, in milliseconds. - */ - void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1); - - /** Sends a given data buffer to the attached USB host, if connected. If a host is not connected when the function is - * called, the string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank - * becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows - * for multiple bytes to be packed into a single endpoint packet, increasing data throughput. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param[in] Buffer Pointer to a buffer containing the data to send to the device. - * \param[in] Length Length of the data to send to the host. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const char* const Buffer, - const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /** Sends a given null terminated string to the attached USB host, if connected. If a host is not connected when - * the function is called, the string is discarded. Bytes will be queued for transmission to the host until either - * the endpoint bank becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to - * the host. This allows for multiple bytes to be packed into a single endpoint packet, increasing data throughput. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param[in] String Pointer to the null terminated string to send to the host. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the - * byte is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the - * \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be - * packed into a single endpoint packet, increasing data throughput. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param[in] Data Byte of data to send to the host. - * - * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. - */ - uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); - - /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. This indicates the number - * of bytes in the OUT endpoint bank only, and thus the number of calls to \ref CDC_Device_ReceiveByte() which are guaranteed to - * succeed immediately. If multiple bytes are to be received, they should be buffered by the user application, as the endpoint - * bank will not be released back to the USB controller until all bytes are read. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return Total number of buffered bytes received from the host. - */ - uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function - * returns a negative value. The \ref CDC_Device_BytesReceived() function may be queried in advance to determine how many - * bytes are currently buffered in the CDC interface's data receive endpoint bank, and thus how many repeated calls to this - * function which are guaranteed to succeed. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return Next received byte from the host, or a negative value if no data received. - */ - int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * - * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. - */ - uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial - * control lines (DCD, DSR, etc.) have changed states, or to give BREAK notifications to the host. Line states persist - * until they are cleared via a second notification. This should be called each time the CDC class driver's - * \c ControlLineStates.DeviceToHost value is updated to push the new states to the USB host. - * - * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or - * the call will fail. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - */ - void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); - - /** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular - * functions in the standard library that accept a \c FILE stream as a destination (e.g. \c fprintf()). The created - * stream is bidirectional and can be used for both input and output functions. - * - * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single - * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may - * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own - * line buffering. - * - * \note The created stream can be given as stdout if desired to direct the standard output from all functions - * to the given CDC interface. - * \n\n - * - * \note This function is not available on all microcontroller architectures. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. - */ - void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates - * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications. - * - * \note This function is not available on all microcontroller architectures. - * - * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. - * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. - */ - void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Function Prototypes: */ - #if defined(__INCLUDE_FROM_CDC_DEVICE_C) - #if defined(FDEV_SETUP_STREAM) - static int CDC_Device_putchar(char c, - FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); - static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); - static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); - #endif - - void CDC_Device_Event_Stub(void) ATTR_CONST; - - void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) - ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub); - void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) - ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub); - void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, - const uint8_t Duration) ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) - ATTR_ALIAS(CDC_Device_Event_Stub); - #endif - - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB CDC Class driver. + * + * Device mode driver for the library USB CDC Class driver. + * + * \note This file should not be included directly. It is automatically included as needed by the USB module driver + * dispatch header located in LUFA/Drivers/USB.h. + */ + +/** \ingroup Group_USBClassCDC + * \defgroup Group_USBClassCDCDevice CDC Class Device Mode Driver + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * Device Mode USB Class driver framework interface, for the CDC USB Class driver. + * + * \note There are several major drawbacks to the CDC-ACM standard USB class, however + * it is very standardized and thus usually available as a built-in driver on + * most platforms, and so is a better choice than a proprietary serial class. + * + * One major issue with CDC-ACM is that it requires two Interface descriptors, + * which will upset most hosts when part of a multi-function "Composite" USB + * device, as each interface will be loaded into a separate driver instance. To + * combat this, you should use the "Interface Association Descriptor" addendum to + * the USB standard which is available on most OSes when creating Composite devices. + * + * Another major oversight is that there is no mechanism for the host to notify the + * device that there is a data sink on the host side ready to accept data. This + * means that the device may try to send data while the host isn't listening, causing + * lengthy blocking timeouts in the transmission routines. To combat this, it is + * recommended that the virtual serial line DTR (Data Terminal Ready) be used where + * possible to determine if a host application is ready for data. + * + * @{ + */ + +#ifndef _CDC_CLASS_DEVICE_H_ +#define _CDC_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/CDCClassCommon.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_CDC_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief CDC Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each CDC interface + * within the user application, and passed to each of the CDC class driver functions as the + * CDCInterfaceInfo parameter. This stores each CDC interface's configuration and state information. + */ + typedef struct + { + struct + { + uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device. */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint. */ + uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint. */ + bool DataINEndpointDoubleBank; /**< Indicates if the CDC interface's IN data endpoint should use double banking. */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint. */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint. */ + bool DataOUTEndpointDoubleBank; /**< Indicates if the CDC interface's OUT data endpoint should use double banking. */ + + uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used. */ + uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used. */ + bool NotificationEndpointDoubleBank; /**< Indicates if the CDC interface's notification endpoint should use double banking. */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + struct + { + uint16_t HostToDevice; /**< Control line states from the host to device, as a set of \c CDC_CONTROL_LINE_OUT_* + * masks. This value is updated each time \ref CDC_Device_USBTask() is called. + */ + uint16_t DeviceToHost; /**< Control line states from the device to host, as a set of \c CDC_CONTROL_LINE_IN_* + * masks - to notify the host of changes to these values, call the + * \ref CDC_Device_SendControlLineStateChange() function. + */ + } ControlLineStates; /**< Current states of the virtual serial port's control lines between the device and host. */ + + CDC_LineEncoding_t LineEncoding; /** Line encoding used in the virtual serial port, for the device's information. + * This is generally only used if the virtual serial port data is to be + * reconstructed on a physical UART. + */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * are reset to their defaults when the interface is enumerated. + */ + } USB_ClassInfo_CDC_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library + * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing + * the given CDC interface is selected. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise. + */ + bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Processes incoming control requests from the host, that are directed to the given CDC class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** General management task for a given CDC class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a + * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the + * user program by declaring a handler function with the same name and parameters listed here. The new line encoding + * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a + * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the + * user program by declaring a handler function with the same name and parameters listed here. The new control line states + * are available in the \c ControlLineStates.HostToDevice value inside the CDC interface structure passed as a parameter, set as + * a mask of \c CDC_CONTROL_LINE_OUT_* masks. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** CDC class driver event for a send break request sent to the device from the host. This is generally used to separate + * data or to indicate a special condition to the receiving device. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] Duration Duration of the break that has been sent by the host, in milliseconds. + */ + void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a given data buffer to the attached USB host, if connected. If a host is not connected when the function is + * called, the string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank + * becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows + * for multiple bytes to be packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] Buffer Pointer to a buffer containing the data to send to the device. + * \param[in] Length Length of the data to send to the host. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const Buffer, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given null terminated string to the attached USB host, if connected. If a host is not connected when + * the function is called, the string is discarded. Bytes will be queued for transmission to the host until either + * the endpoint bank becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to + * the host. This allows for multiple bytes to be packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] String Pointer to the null terminated string to send to the host. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the + * byte is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the + * \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] Data Byte of data to send to the host. + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); + + /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. This indicates the number + * of bytes in the OUT endpoint bank only, and thus the number of calls to \ref CDC_Device_ReceiveByte() which are guaranteed to + * succeed immediately. If multiple bytes are to be received, they should be buffered by the user application, as the endpoint + * bank will not be released back to the USB controller until all bytes are read. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Total number of buffered bytes received from the host. + */ + uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function + * returns a negative value. The \ref CDC_Device_BytesReceived() function may be queried in advance to determine how many + * bytes are currently buffered in the CDC interface's data receive endpoint bank, and thus how many repeated calls to this + * function which are guaranteed to succeed. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Next received byte from the host, or a negative value if no data received. + */ + int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial + * control lines (DCD, DSR, etc.) have changed states, or to give BREAK notifications to the host. Line states persist + * until they are cleared via a second notification. This should be called each time the CDC class driver's + * \c ControlLineStates.DeviceToHost value is updated to push the new states to the USB host. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular + * functions in the standard library that accept a \c FILE stream as a destination (e.g. \c fprintf()). The created + * stream is bidirectional and can be used for both input and output functions. + * + * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single + * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may + * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own + * line buffering. + * + * \note The created stream can be given as stdout if desired to direct the standard output from all functions + * to the given CDC interface. + * \n\n + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates + * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications. + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_CDC_DEVICE_C) + #if defined(FDEV_SETUP_STREAM) + static int CDC_Device_putchar(char c, + FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); + static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + #endif + + void CDC_Device_Event_Stub(void) ATTR_CONST; + + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) + ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub); + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) + ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub); + void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Duration) ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) + ATTR_ALIAS(CDC_Device_Event_Stub); + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c index acb77b9..61f4456 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c @@ -1,53 +1,53 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBMode.h" - -#if defined(USB_CAN_BE_DEVICE) - -#include "../Device.h" - -void USB_Device_SendRemoteWakeup(void) -{ - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - USB_PLL_On(); - while (!(USB_PLL_IsReady())); - } - - USB_CLK_Unfreeze(); - - UDCON |= (1 << RMWKUP); - while (UDCON & (1 << RMWKUP)); -} - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Device.h" + +void USB_Device_SendRemoteWakeup(void) +{ + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + USB_CLK_Unfreeze(); + + UDCON |= (1 << RMWKUP); + while (UDCON & (1 << RMWKUP)); +} + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index 2e84b79..74920d5 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -1,264 +1,264 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Device definitions for the AVR8 microcontrollers. - * \copydetails Group_Device_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_Device - * \defgroup Group_Device_AVR8 Device Management (AVR8) - * \brief USB Device definitions for the AVR8 microcontrollers. - * - * Architecture specific USB Device definitions for the Atmel 8-bit AVR microcontrollers. - * - * @{ - */ - -#ifndef __USBDEVICE_AVR8_H__ -#define __USBDEVICE_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../USBController.h" - #include "../StdDescriptors.h" - #include "../USBInterrupt.h" - #include "../Endpoint.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) - #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. - #endif - - #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) - #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. - #endif - - #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)) - #error USE_FLASH_DESCRIPTORS and USE_RAM_DESCRIPTORS are mutually exclusive. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** \name USB Device Mode Option Masks */ - //@{ - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) - /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the - * USB interface should be initialized in low speed (1.5Mb/s) mode. - * - * \note Low Speed mode is not available on all USB AVR models. - * \n - * - * \note Restrictions apply on the number, size and type of endpoints which can be used - * when running in low speed mode - refer to the USB 2.0 specification. - */ - #define USB_DEVICE_OPT_LOWSPEED (1 << 0) - #endif - - /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the - * USB interface should be initialized in full speed (12Mb/s) mode. - */ - #define USB_DEVICE_OPT_FULLSPEED (0 << 0) - //@} - - #if (!defined(NO_INTERNAL_SERIAL) && \ - (defined(USB_SERIES_7_AVR) || defined(USB_SERIES_6_AVR) || \ - defined(USB_SERIES_4_AVR) || defined(USB_SERIES_2_AVR) || \ - defined(__DOXYGEN__))) - /** String descriptor index for the device's unique serial number string descriptor within the device. - * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port - * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain - * a unique serial number internally, and setting the device descriptors serial number string index to this value - * will cause it to use the internal serial number. - * - * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial - * number for the device. - */ - #define USE_INTERNAL_SERIAL 0xDC - - /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller - * model. - */ - #define INTERNAL_SERIAL_LENGTH_BITS 80 - - /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller - * model. - */ - #define INTERNAL_SERIAL_START_ADDRESS 0x0E - #else - #define USE_INTERNAL_SERIAL NO_DESCRIPTOR - - #define INTERNAL_SERIAL_LENGTH_BITS 0 - #define INTERNAL_SERIAL_START_ADDRESS 0 - #endif - - /* Function Prototypes: */ - /** Sends a Remote Wakeup request to the host. This signals to the host that the device should - * be taken out of suspended mode, and communications should resume. - * - * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the - * host computer when the host has suspended all USB devices to enter a low power state. - * - * \note This macro should only be used if the device has indicated to the host that it - * supports the Remote Wakeup feature in the device descriptors, and should only be - * issued if the host is currently allowing remote wakeup events from the device (i.e., - * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP - * compile time option is used, this macro is unavailable. - * \n\n - * - * \note The USB clock must be running for this function to operate. If the stack is initialized with - * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running - * before attempting to call this function. - * - * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors. - */ - void USB_Device_SendRemoteWakeup(void); - - /* Inline Functions: */ - /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) - * the frame number is incremented by one. - * - * \return Current USB frame number from the USB controller. - */ - static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline uint16_t USB_Device_GetFrameNumber(void) - { - return UDFNUM; - } - - #if !defined(NO_SOF_EVENTS) - /** Enables the device mode Start Of Frame events. When enabled, this causes the - * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, - * at the start of each USB frame when enumerated in device mode. - * - * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. - */ - static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; - static inline void USB_Device_EnableSOFEvents(void) - { - USB_INT_Enable(USB_INT_SOFI); - } - - /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the - * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode. - * - * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. - */ - static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; - static inline void USB_Device_DisableSOFEvents(void) - { - USB_INT_Disable(USB_INT_SOFI); - } - #endif - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Inline Functions: */ - #if defined(USB_DEVICE_OPT_LOWSPEED) - static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE; - static inline void USB_Device_SetLowSpeed(void) - { - UDCON |= (1 << LSM); - } - - static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE; - static inline void USB_Device_SetFullSpeed(void) - { - UDCON &= ~(1 << LSM); - } - #endif - - static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; - static inline void USB_Device_SetDeviceAddress(const uint8_t Address) - { - uint8_t Temp = (UDADDR & (1 << ADDEN)) | (Address & 0x7F); - - UDADDR = Temp; - UDADDR = Temp | (1 << ADDEN); - } - - static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline bool USB_Device_IsAddressSet(void) - { - return (UDADDR & (1 << ADDEN)); - } - - #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) - static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1); - static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) - { - uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); - GlobalInterruptDisable(); - - uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; - - for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) - { - uint8_t SerialByte = boot_signature_byte_get(SigReadAddress); - - if (SerialCharNum & 0x01) - { - SerialByte >>= 4; - SigReadAddress++; - } - - SerialByte &= 0x0F; - - UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? - (('A' - 10) + SerialByte) : ('0' + SerialByte)); - } - - SetGlobalInterruptMask(CurrentGlobalInt); - } - #endif - - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Device definitions for the AVR8 microcontrollers. + * \copydetails Group_Device_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Device + * \defgroup Group_Device_AVR8 Device Management (AVR8) + * \brief USB Device definitions for the AVR8 microcontrollers. + * + * Architecture specific USB Device definitions for the Atmel 8-bit AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBDEVICE_AVR8_H__ +#define __USBDEVICE_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBController.h" + #include "../StdDescriptors.h" + #include "../USBInterrupt.h" + #include "../Endpoint.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)) + #error USE_FLASH_DESCRIPTORS and USE_RAM_DESCRIPTORS are mutually exclusive. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Device Mode Option Masks */ + //@{ + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) + /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the + * USB interface should be initialized in low speed (1.5Mb/s) mode. + * + * \note Low Speed mode is not available on all USB AVR models. + * \n + * + * \note Restrictions apply on the number, size and type of endpoints which can be used + * when running in low speed mode - refer to the USB 2.0 specification. + */ + #define USB_DEVICE_OPT_LOWSPEED (1 << 0) + #endif + + /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the + * USB interface should be initialized in full speed (12Mb/s) mode. + */ + #define USB_DEVICE_OPT_FULLSPEED (0 << 0) + //@} + + #if (!defined(NO_INTERNAL_SERIAL) && \ + (defined(USB_SERIES_7_AVR) || defined(USB_SERIES_6_AVR) || \ + defined(USB_SERIES_4_AVR) || defined(USB_SERIES_2_AVR) || \ + defined(__DOXYGEN__))) + /** String descriptor index for the device's unique serial number string descriptor within the device. + * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port + * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain + * a unique serial number internally, and setting the device descriptors serial number string index to this value + * will cause it to use the internal serial number. + * + * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial + * number for the device. + */ + #define USE_INTERNAL_SERIAL 0xDC + + /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_LENGTH_BITS 80 + + /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_START_ADDRESS 0x0E + #else + #define USE_INTERNAL_SERIAL NO_DESCRIPTOR + + #define INTERNAL_SERIAL_LENGTH_BITS 0 + #define INTERNAL_SERIAL_START_ADDRESS 0 + #endif + + /* Function Prototypes: */ + /** Sends a Remote Wakeup request to the host. This signals to the host that the device should + * be taken out of suspended mode, and communications should resume. + * + * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the + * host computer when the host has suspended all USB devices to enter a low power state. + * + * \note This macro should only be used if the device has indicated to the host that it + * supports the Remote Wakeup feature in the device descriptors, and should only be + * issued if the host is currently allowing remote wakeup events from the device (i.e., + * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP + * compile time option is used, this macro is unavailable. + * \n\n + * + * \note The USB clock must be running for this function to operate. If the stack is initialized with + * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running + * before attempting to call this function. + * + * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors. + */ + void USB_Device_SendRemoteWakeup(void); + + /* Inline Functions: */ + /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint16_t USB_Device_GetFrameNumber(void) + { + return UDFNUM; + } + + #if !defined(NO_SOF_EVENTS) + /** Enables the device mode Start Of Frame events. When enabled, this causes the + * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, + * at the start of each USB frame when enumerated in device mode. + * + * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_EnableSOFEvents(void) + { + USB_INT_Enable(USB_INT_SOFI); + } + + /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the + * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode. + * + * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_DisableSOFEvents(void) + { + USB_INT_Disable(USB_INT_SOFI); + } + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Inline Functions: */ + #if defined(USB_DEVICE_OPT_LOWSPEED) + static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetLowSpeed(void) + { + UDCON |= (1 << LSM); + } + + static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetFullSpeed(void) + { + UDCON &= ~(1 << LSM); + } + #endif + + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) + { + uint8_t Temp = (UDADDR & (1 << ADDEN)) | (Address & 0x7F); + + UDADDR = Temp; + UDADDR = Temp | (1 << ADDEN); + } + + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_Device_IsAddressSet(void) + { + return (UDADDR & (1 << ADDEN)); + } + + #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1); + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) + { + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; + + for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) + { + uint8_t SerialByte = boot_signature_byte_get(SigReadAddress); + + if (SerialCharNum & 0x01) + { + SerialByte >>= 4; + SigReadAddress++; + } + + SerialByte &= 0x0F; + + UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte)); + } + + SetGlobalInterruptMask(CurrentGlobalInt); + } + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c index 1e7ed9c..b7da76a 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c @@ -1,271 +1,271 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBMode.h" - -#if defined(USB_CAN_BE_DEVICE) - -#include "EndpointStream_AVR8.h" - -#if !defined(CONTROL_ONLY_DEVICE) -uint8_t Endpoint_Discard_Stream(uint16_t Length, - uint16_t* const BytesProcessed) -{ - uint8_t ErrorCode; - uint16_t BytesInTransfer = 0; - - if ((ErrorCode = Endpoint_WaitUntilReady())) - return ErrorCode; - - if (BytesProcessed != NULL) - Length -= *BytesProcessed; - - while (Length) - { - if (!(Endpoint_IsReadWriteAllowed())) - { - Endpoint_ClearOUT(); - - if (BytesProcessed != NULL) - { - *BytesProcessed += BytesInTransfer; - return ENDPOINT_RWSTREAM_IncompleteTransfer; - } - - if ((ErrorCode = Endpoint_WaitUntilReady())) - return ErrorCode; - } - else - { - Endpoint_Discard_8(); - - Length--; - BytesInTransfer++; - } - } - - return ENDPOINT_RWSTREAM_NoError; -} - -uint8_t Endpoint_Null_Stream(uint16_t Length, - uint16_t* const BytesProcessed) -{ - uint8_t ErrorCode; - uint16_t BytesInTransfer = 0; - - if ((ErrorCode = Endpoint_WaitUntilReady())) - return ErrorCode; - - if (BytesProcessed != NULL) - Length -= *BytesProcessed; - - while (Length) - { - if (!(Endpoint_IsReadWriteAllowed())) - { - Endpoint_ClearIN(); - - if (BytesProcessed != NULL) - { - *BytesProcessed += BytesInTransfer; - return ENDPOINT_RWSTREAM_IncompleteTransfer; - } - - if ((ErrorCode = Endpoint_WaitUntilReady())) - return ErrorCode; - } - else - { - Endpoint_Write_8(0); - - Length--; - BytesInTransfer++; - } - } - - return ENDPOINT_RWSTREAM_NoError; -} - -/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, - * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ - -#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) -#include "Template/Template_Endpoint_RW.c" - -#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) -#include "Template/Template_Endpoint_RW.c" - -#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() -#include "Template/Template_Endpoint_RW.c" - -#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() -#include "Template/Template_Endpoint_RW.c" - -#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) - #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE - #define TEMPLATE_BUFFER_TYPE const void* - #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() - #define TEMPLATE_BUFFER_OFFSET(Length) 0 - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_RW.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE - #define TEMPLATE_BUFFER_TYPE const void* - #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() - #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_RW.c" -#endif - -#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) - #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE - #define TEMPLATE_BUFFER_TYPE const void* - #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() - #define TEMPLATE_BUFFER_OFFSET(Length) 0 - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_RW.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE - #define TEMPLATE_BUFFER_TYPE const void* - #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() - #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_RW.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE - #define TEMPLATE_BUFFER_TYPE void* - #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() - #define TEMPLATE_BUFFER_OFFSET(Length) 0 - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) - #include "Template/Template_Endpoint_RW.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE - #define TEMPLATE_BUFFER_TYPE void* - #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() - #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) - #include "Template/Template_Endpoint_RW.c" -#endif - -#endif - -#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) -#include "Template/Template_Endpoint_Control_W.c" - -#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) -#include "Template/Template_Endpoint_Control_W.c" - -#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() -#include "Template/Template_Endpoint_Control_R.c" - -#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() -#include "Template/Template_Endpoint_Control_R.c" - -#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) - #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE - #define TEMPLATE_BUFFER_OFFSET(Length) 0 - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_Control_W.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE - #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_Control_W.c" -#endif - -#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) - #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE - #define TEMPLATE_BUFFER_OFFSET(Length) 0 - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_Control_W.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE - #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) - #include "Template/Template_Endpoint_Control_W.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE - #define TEMPLATE_BUFFER_OFFSET(Length) 0 - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) - #include "Template/Template_Endpoint_Control_R.c" - - #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE - #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) - #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount - #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) - #include "Template/Template_Endpoint_Control_R.c" -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "EndpointStream_AVR8.h" + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" +#endif + +#endif + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_Control_R.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_Control_R.c" +#endif + #endif diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h index ecc1fb0..8b5c1e6 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h @@ -1,648 +1,648 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Endpoint data stream transmission and reception management for the AVR8 microcontrollers. - * \copydetails Group_EndpointStreamRW_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_EndpointStreamRW - * \defgroup Group_EndpointStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8) - * \brief Endpoint data stream transmission and reception management for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to data reading and writing of data streams from - * and to endpoints. - * - * @{ - */ - -#ifndef __ENDPOINT_STREAM_AVR8_H__ -#define __ENDPOINT_STREAM_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../USBMode.h" - #include "../USBTask.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Function Prototypes: */ - /** \name Stream functions for null data */ - //@{ - - /** Reads and discards the given number of bytes from the currently selected endpoint's bank, - * discarding fully read packets from the host as needed. The last packet is not automatically - * discarded once the remaining bytes has been read; the user is responsible for manually - * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, - * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid - * storage location, the transfer will instead be performed as a series of chunks. Each time - * the endpoint bank becomes empty while there is still data to process (and after the current - * packet has been acknowledged) the BytesProcessed location will be updated with the total number - * of bytes processed in the stream, and the function will exit with an error code of - * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed - * in the user code - to continue the transfer, call the function again with identical parameters - * and it will resume until the BytesProcessed value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t ErrorCode; - * - * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note This routine should not be used on CONTROL type endpoints. - * - * \param[in] Length Number of bytes to discard via the currently selected endpoint. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Discard_Stream(uint16_t Length, - uint16_t* const BytesProcessed); - - /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending - * full packets to the host as needed. The last packet is not automatically sent once the - * remaining bytes have been written; the user is responsible for manually sending the last - * packet to the host via the \ref Endpoint_ClearIN() macro. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, - * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid - * storage location, the transfer will instead be performed as a series of chunks. Each time - * the endpoint bank becomes full while there is still data to process (and after the current - * packet transmission has been initiated) the BytesProcessed location will be updated with the - * total number of bytes processed in the stream, and the function will exit with an error code of - * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed - * in the user code - to continue the transfer, call the function again with identical parameters - * and it will resume until the BytesProcessed value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t ErrorCode; - * - * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note This routine should not be used on CONTROL type endpoints. - * - * \param[in] Length Number of zero bytes to send via the currently selected endpoint. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Null_Stream(uint16_t Length, - uint16_t* const BytesProcessed); - - //@} - - /** \name Stream functions for RAM source/destination data */ - //@{ - - /** Writes the given number of bytes to the endpoint from the given buffer in little endian, - * sending full packets to the host as needed. The last packet filled is not automatically sent; - * the user is responsible for manually sending the last written packet to the host via the - * \ref Endpoint_ClearIN() macro. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, - * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid - * storage location, the transfer will instead be performed as a series of chunks. Each time - * the endpoint bank becomes full while there is still data to process (and after the current - * packet transmission has been initiated) the BytesProcessed location will be updated with the - * total number of bytes processed in the stream, and the function will exit with an error code of - * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed - * in the user code - to continue the transfer, call the function again with identical parameters - * and it will resume until the BytesProcessed value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * - * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), - * NULL)) != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), - * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note This routine should not be used on CONTROL type endpoints. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Stream_LE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Writes the given number of bytes to the endpoint from the given buffer in big endian, - * sending full packets to the host as needed. The last packet filled is not automatically sent; - * the user is responsible for manually sending the last written packet to the host via the - * \ref Endpoint_ClearIN() macro. - * - * \note This routine should not be used on CONTROL type endpoints. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Stream_BE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads the given number of bytes from the endpoint from the given buffer in little endian, - * discarding fully read packets from the host as needed. The last packet is not automatically - * discarded once the remaining bytes has been read; the user is responsible for manually - * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, - * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid - * storage location, the transfer will instead be performed as a series of chunks. Each time - * the endpoint bank becomes empty while there is still data to process (and after the current - * packet has been acknowledged) the BytesProcessed location will be updated with the total number - * of bytes processed in the stream, and the function will exit with an error code of - * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed - * in the user code - to continue the transfer, call the function again with identical parameters - * and it will resume until the BytesProcessed value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * - * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), - * NULL)) != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), - * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note This routine should not be used on CONTROL type endpoints. - * - * \param[out] Buffer Pointer to the destination data buffer to write to. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_Stream_LE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads the given number of bytes from the endpoint from the given buffer in big endian, - * discarding fully read packets from the host as needed. The last packet is not automatically - * discarded once the remaining bytes has been read; the user is responsible for manually - * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. - * - * \note This routine should not be used on CONTROL type endpoints. - * - * \param[out] Buffer Pointer to the destination data buffer to write to. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_Stream_BE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, - * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared - * in both failure and success states; the user is responsible for manually clearing the setup OUT to - * finalize the transfer via the \ref Endpoint_ClearOUT() macro. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, - * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared - * in both failure and success states; the user is responsible for manually clearing the setup OUT to - * finalize the transfer via the \ref Endpoint_ClearOUT() macro. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, - * discarding fully read packets from the host as needed. The device IN acknowledgement is not - * automatically sent after success or failure states; the user is responsible for manually sending the - * setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[out] Buffer Pointer to the destination data buffer to write to. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, - * discarding fully read packets from the host as needed. The device IN acknowledgement is not - * automatically sent after success or failure states; the user is responsible for manually sending the - * setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[out] Buffer Pointer to the destination data buffer to write to. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - //@} - - /** \name Stream functions for EEPROM source/destination data */ - //@{ - - /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE(). - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_EStream_LE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE(). - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_EStream_BE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE(). - * - * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_EStream_LE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE(). - * - * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_EStream_BE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * \n\n - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE(). - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * \n\n - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE(). - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * \n\n - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[out] Buffer Pointer to the destination data buffer to write to. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE(). - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * \n\n - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[out] Buffer Pointer to the destination data buffer to write to. - * \param[in] Length Number of bytes to send via the currently selected endpoint. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - //@} - - /** \name Stream functions for PROGMEM source/destination data */ - //@{ - - /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE(). - * - * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_PStream_LE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE(). - * - * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current - * transaction should be updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_PStream_BE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE(). - * - * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * \n\n - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - - /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE(). - * - * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. - * - * \note This function automatically clears the control transfer's status stage. Do not manually attempt - * to clear the status stage when using this routine in a control transaction. - * \n\n - * - * \note This routine should only be used on CONTROL type endpoints. - * \n\n - * - * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained - * together; i.e. the entire stream data must be read or written at the one time. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. - * - * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. - */ - uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer, - uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); - //@} - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endpoint data stream transmission and reception management for the AVR8 microcontrollers. + * \copydetails Group_EndpointStreamRW_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointStreamRW + * \defgroup Group_EndpointStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8) + * \brief Endpoint data stream transmission and reception management for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to endpoints. + * + * @{ + */ + +#ifndef __ENDPOINT_STREAM_AVR8_H__ +#define __ENDPOINT_STREAM_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the currently selected endpoint's bank, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of bytes to discard via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending + * full packets to the host as needed. The last packet is not automatically sent once the + * remaining bytes have been written; the user is responsible for manually sending the last + * packet to the host via the \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of zero bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the setup OUT to + * finalize the transfer via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the setup OUT to + * finalize the transfer via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for EEPROM source/destination data */ + //@{ + + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE(). + * + * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE(). + * + * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for PROGMEM source/destination data */ + //@{ + + /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c index 2eab484..a6032a6 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c @@ -1,182 +1,182 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBMode.h" - -#if defined(USB_CAN_BE_DEVICE) - -#include "../Endpoint.h" - -#if !defined(FIXED_CONTROL_ENDPOINT_SIZE) -uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; -#endif - -bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, - const uint8_t UECFG0XData, - const uint8_t UECFG1XData) -{ -#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG) - Endpoint_SelectEndpoint(Number); - Endpoint_EnableEndpoint(); - - UECFG1X = 0; - UECFG0X = UECFG0XData; - UECFG1X = UECFG1XData; - - return Endpoint_IsConfigured(); -#else - for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - uint8_t UECFG0XTemp; - uint8_t UECFG1XTemp; - uint8_t UEIENXTemp; - - Endpoint_SelectEndpoint(EPNum); - - if (EPNum == Number) - { - UECFG0XTemp = UECFG0XData; - UECFG1XTemp = UECFG1XData; - UEIENXTemp = 0; - } - else - { - UECFG0XTemp = UECFG0X; - UECFG1XTemp = UECFG1X; - UEIENXTemp = UEIENX; - } - - if (!(UECFG1XTemp & (1 << ALLOC))) - continue; - - Endpoint_DisableEndpoint(); - UECFG1X &= ~(1 << ALLOC); - - Endpoint_EnableEndpoint(); - UECFG0X = UECFG0XTemp; - UECFG1X = UECFG1XTemp; - UEIENX = UEIENXTemp; - - if (!(Endpoint_IsConfigured())) - return false; - } - - Endpoint_SelectEndpoint(Number); - return true; -#endif -} - -void Endpoint_ClearEndpoints(void) -{ - UEINT = 0; - - for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) - { - Endpoint_SelectEndpoint(EPNum); - UEIENX = 0; - UEINTX = 0; - UECFG1X = 0; - Endpoint_DisableEndpoint(); - } -} - -void Endpoint_ClearStatusStage(void) -{ - if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) - { - while (!(Endpoint_IsOUTReceived())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - Endpoint_ClearOUT(); - } - else - { - while (!(Endpoint_IsINReady())) - { - if (USB_DeviceState == DEVICE_STATE_Unattached) - return; - } - - Endpoint_ClearIN(); - } -} - -#if !defined(CONTROL_ONLY_DEVICE) -uint8_t Endpoint_WaitUntilReady(void) -{ - #if (USB_STREAM_TIMEOUT_MS < 0xFF) - uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; - #else - uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; - #endif - - uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber(); - - for (;;) - { - if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN) - { - if (Endpoint_IsINReady()) - return ENDPOINT_READYWAIT_NoError; - } - else - { - if (Endpoint_IsOUTReceived()) - return ENDPOINT_READYWAIT_NoError; - } - - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_READYWAIT_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_READYWAIT_BusSuspended; - else if (Endpoint_IsStalled()) - return ENDPOINT_READYWAIT_EndpointStalled; - - uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber(); - - if (CurrentFrameNumber != PreviousFrameNumber) - { - PreviousFrameNumber = CurrentFrameNumber; - - if (!(TimeoutMSRem--)) - return ENDPOINT_READYWAIT_Timeout; - } - } -} -#endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Endpoint.h" + +#if !defined(FIXED_CONTROL_ENDPOINT_SIZE) +uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; +#endif + +bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, + const uint8_t UECFG0XData, + const uint8_t UECFG1XData) +{ +#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG) + Endpoint_SelectEndpoint(Number); + Endpoint_EnableEndpoint(); + + UECFG1X = 0; + UECFG0X = UECFG0XData; + UECFG1X = UECFG1XData; + + return Endpoint_IsConfigured(); +#else + for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + uint8_t UECFG0XTemp; + uint8_t UECFG1XTemp; + uint8_t UEIENXTemp; + + Endpoint_SelectEndpoint(EPNum); + + if (EPNum == Number) + { + UECFG0XTemp = UECFG0XData; + UECFG1XTemp = UECFG1XData; + UEIENXTemp = 0; + } + else + { + UECFG0XTemp = UECFG0X; + UECFG1XTemp = UECFG1X; + UEIENXTemp = UEIENX; + } + + if (!(UECFG1XTemp & (1 << ALLOC))) + continue; + + Endpoint_DisableEndpoint(); + UECFG1X &= ~(1 << ALLOC); + + Endpoint_EnableEndpoint(); + UECFG0X = UECFG0XTemp; + UECFG1X = UECFG1XTemp; + UEIENX = UEIENXTemp; + + if (!(Endpoint_IsConfigured())) + return false; + } + + Endpoint_SelectEndpoint(Number); + return true; +#endif +} + +void Endpoint_ClearEndpoints(void) +{ + UEINT = 0; + + for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + Endpoint_SelectEndpoint(EPNum); + UEIENX = 0; + UEINTX = 0; + UECFG1X = 0; + Endpoint_DisableEndpoint(); + } +} + +void Endpoint_ClearStatusStage(void) +{ + if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) + { + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + Endpoint_ClearOUT(); + } + else + { + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + Endpoint_ClearIN(); + } +} + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_WaitUntilReady(void) +{ + #if (USB_STREAM_TIMEOUT_MS < 0xFF) + uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #else + uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #endif + + uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber(); + + for (;;) + { + if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN) + { + if (Endpoint_IsINReady()) + return ENDPOINT_READYWAIT_NoError; + } + else + { + if (Endpoint_IsOUTReceived()) + return ENDPOINT_READYWAIT_NoError; + } + + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_READYWAIT_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_READYWAIT_BusSuspended; + else if (Endpoint_IsStalled()) + return ENDPOINT_READYWAIT_EndpointStalled; + + uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return ENDPOINT_READYWAIT_Timeout; + } + } +} +#endif + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h index 5bdbda8..066fc3d 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h @@ -1,873 +1,873 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Endpoint definitions for the AVR8 microcontrollers. - * \copydetails Group_EndpointManagement_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_EndpointRW - * \defgroup Group_EndpointRW_AVR8 Endpoint Data Reading and Writing (AVR8) - * \brief Endpoint data read/write definitions for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. - */ - -/** \ingroup Group_EndpointPrimitiveRW - * \defgroup Group_EndpointPrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8) - * \brief Endpoint primitive read/write definitions for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to data reading and writing of primitive data types - * from and to endpoints. - */ - -/** \ingroup Group_EndpointPacketManagement - * \defgroup Group_EndpointPacketManagement_AVR8 Endpoint Packet Management (AVR8) - * \brief Endpoint packet management definitions for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to packet management of endpoints. - */ - -/** \ingroup Group_EndpointManagement - * \defgroup Group_EndpointManagement_AVR8 Endpoint Management (AVR8) - * \brief Endpoint management definitions for the Atmel AVR8 architecture. - * - * Functions, macros and enums related to endpoint management when in USB Device mode. This - * module contains the endpoint management macros, as well as endpoint interrupt and data - * send/receive functions for various data types. - * - * @{ - */ - -#ifndef __ENDPOINT_AVR8_H__ -#define __ENDPOINT_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../USBTask.h" - #include "../USBInterrupt.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Macros: */ - #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex) - #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails) - #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize) - - #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex) - #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails) - #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks) - - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - #define ENDPOINT_DETAILS_MAXEP 7 - - #define ENDPOINT_DETAILS_EP0 64, 1 - #define ENDPOINT_DETAILS_EP1 256, 2 - #define ENDPOINT_DETAILS_EP2 64, 2 - #define ENDPOINT_DETAILS_EP3 64, 2 - #define ENDPOINT_DETAILS_EP4 64, 2 - #define ENDPOINT_DETAILS_EP5 64, 2 - #define ENDPOINT_DETAILS_EP6 64, 2 - #else - #define ENDPOINT_DETAILS_MAXEP 5 - - #define ENDPOINT_DETAILS_EP0 64, 1 - #define ENDPOINT_DETAILS_EP1 64, 1 - #define ENDPOINT_DETAILS_EP2 64, 1 - #define ENDPOINT_DETAILS_EP3 64, 2 - #define ENDPOINT_DETAILS_EP4 64, 2 - #endif - - /* Inline Functions: */ - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST - ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) - { - uint8_t MaskVal = 0; - uint16_t CheckBytes = 8; - - while (CheckBytes < Bytes) - { - MaskVal++; - CheckBytes <<= 1; - } - - return (MaskVal << EPSIZE0); - } - - /* Function Prototypes: */ - void Endpoint_ClearEndpoints(void); - bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, - const uint8_t UECFG0XData, - const uint8_t UECFG1XData); - - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** \name Endpoint Bank Mode Masks */ - //@{ - /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates - * that the endpoint should have one single bank, which requires less USB FIFO memory but results - * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's - * bank at the one time. - */ - #define ENDPOINT_BANK_SINGLE (0 << EPBK0) - - /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates - * that the endpoint should have two banks, which requires more USB FIFO memory but results - * in faster transfers as one USB device (the AVR or the host) can access one bank while the other - * accesses the second bank. - */ - #define ENDPOINT_BANK_DOUBLE (1 << EPBK0) - //@} - - #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) - /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size - * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined. - */ - #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 - #endif - - /** Retrieves the maximum bank size in bytes of a given endpoint. - * - * \note This macro will only work correctly on endpoint indexes that are compile-time constants - * defined by the preprocessor. - * - * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1) - */ - #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex) - - /** Retrieves the total number of banks supported by the given endpoint. - * - * \note This macro will only work correctly on endpoint indexes that are compile-time constants - * defined by the preprocessor. - * - * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1) - */ - #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex) - - #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__) - /** Total number of endpoints (including the default control endpoint at address 0) which may - * be used in the device. Different USB AVR models support different amounts of endpoints, - * this value reflects the maximum number of endpoints for the currently selected AVR model. - */ - #define ENDPOINT_TOTAL_ENDPOINTS ENDPOINT_DETAILS_MAXEP - #else - #define ENDPOINT_TOTAL_ENDPOINTS 1 - #endif - - /* Enums: */ - /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function. - * - * \ingroup Group_EndpointRW_AVR8 - */ - enum Endpoint_WaitUntilReady_ErrorCodes_t - { - ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */ - ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream - * transfer by the host or device. - */ - ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while - * waiting for the endpoint to become ready. - */ - ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and - * no USB endpoint traffic can occur until the bus - * has resumed. - */ - ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet - * within the software timeout period set by the - * \ref USB_STREAM_TIMEOUT_MS macro. - */ - }; - - /* Inline Functions: */ - /** Configures the specified endpoint number with the given endpoint type, direction, bank size - * and banking mode. Once configured, the endpoint may be read from or written to, depending - * on its direction. - * - * \param[in] Number Endpoint number to configure. This must be more than 0 and less than - * \ref ENDPOINT_TOTAL_ENDPOINTS. - * - * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types - * are available on Low Speed USB devices - refer to the USB 2.0 specification. - * - * \param[in] Direction Endpoint data direction, either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN. - * All endpoints (except Control type) are unidirectional - data may only be read - * from or written to the endpoint bank based on its direction, not both. - * - * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted - * to the USB host, or after they have been received from the USB host (depending on - * the endpoint's data direction). The bank size must indicate the maximum packet size - * that the endpoint can handle. - * - * \param[in] Banks Number of banks to use for the endpoint being configured, an \c ENDPOINT_BANK_* mask. - * More banks uses more USB DPRAM, but offers better performance. Isochronous type - * endpoints must have at least two banks. - * - * \note When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints must be configured in - * ascending order, or bank corruption will occur. - * \n\n - * - * \note Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to - * the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint. - * \n\n - * - * \note The default control endpoint should not be manually configured by the user application, as - * it is automatically configured by the library internally. - * \n\n - * - * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint - * which failed to reconfigure correctly will be selected. - * - * \return Boolean \c true if the configuration succeeded, \c false otherwise. - */ - static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number, - const uint8_t Type, - const uint8_t Direction, - const uint16_t Size, - const uint8_t Banks) ATTR_ALWAYS_INLINE; - static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number, - const uint8_t Type, - const uint8_t Direction, - const uint16_t Size, - const uint8_t Banks) - { - return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << EPTYPE0) | (Direction ? (1 << EPDIR) : 0)), - ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size))); - } - - /** Indicates the number of bytes currently stored in the current endpoint's selected bank. - * - * \note The return width of this function may differ, depending on the maximum endpoint bank size - * of the selected AVR model. - * - * \ingroup Group_EndpointRW_AVR8 - * - * \return Total number of bytes in the currently selected Endpoint's FIFO buffer. - */ - static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Endpoint_BytesInEndpoint(void) - { - #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - return UEBCX; - #elif defined(USB_SERIES_4_AVR) - return (((uint16_t)UEBCHX << 8) | UEBCLX); - #elif defined(USB_SERIES_2_AVR) - return UEBCLX; - #endif - } - - /** Get the endpoint address of the currently selected endpoint. This is typically used to save - * the currently selected endpoint number so that it can be restored after another endpoint has - * been manipulated. - * - * \return Index of the currently selected endpoint. - */ - static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_GetCurrentEndpoint(void) - { - #if !defined(CONTROL_ONLY_DEVICE) - return (UENUM & ENDPOINT_EPNUM_MASK); - #else - return ENDPOINT_CONTROLEP; - #endif - } - - /** Selects the given endpoint number. If the address from the device descriptors is used, the - * value should be masked with the \ref ENDPOINT_EPNUM_MASK constant to extract only the endpoint - * number (and discarding the endpoint direction bit). - * - * Any endpoint operations which do not require the endpoint number to be indicated will operate on - * the currently selected endpoint. - * - * \param[in] EndpointNumber Endpoint number to select. - */ - static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE; - static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) - { - #if !defined(CONTROL_ONLY_DEVICE) - UENUM = EndpointNumber; - #endif - } - - /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's - * data In and Out pointers to the bank's contents. - * - * \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset. - */ - static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) - { - UERST = (1 << EndpointNumber); - UERST = 0; - } - - /** Enables the currently selected endpoint so that data can be sent and received through it to - * and from a host. - * - * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint(). - */ - static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_EnableEndpoint(void) - { - UECONX |= (1 << EPEN); - } - - /** Disables the currently selected endpoint so that data cannot be sent and received through it - * to and from a host. - */ - static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_DisableEndpoint(void) - { - UECONX &= ~(1 << EPEN); - } - - /** Determines if the currently selected endpoint is enabled, but not necessarily configured. - * - * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise. - */ - static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsEnabled(void) - { - return ((UECONX & (1 << EPEN)) ? true : false); - } - - /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for - * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the - * \ref Endpoint_ClearOUT() command. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \return Total number of busy banks in the selected endpoint. - */ - static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline uint8_t Endpoint_GetBusyBanks(void) - { - return (UESTA0X & (0x03 << NBUSYBK0)); - } - - /** Aborts all pending IN transactions on the currently selected endpoint, once the bank - * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function - * will terminate all queued transactions, resetting the endpoint banks ready for a new - * packet. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - */ - static inline void Endpoint_AbortPendingIN(void) - { - while (Endpoint_GetBusyBanks() != 0) - { - UEINTX |= (1 << RXOUTI); - while (UEINTX & (1 << RXOUTI)); - } - } - - /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint - * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN - * direction). This function will return false if an error has occurred in the endpoint, if the endpoint - * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN - * direction and the endpoint bank is full. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending - * on its direction. - */ - static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsReadWriteAllowed(void) - { - return ((UEINTX & (1 << RWAL)) ? true : false); - } - - /** Determines if the currently selected endpoint is configured. - * - * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise. - */ - static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsConfigured(void) - { - return ((UESTA0X & (1 << CFGOK)) ? true : false); - } - - /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their - * interrupt duration has elapsed. Which endpoints have interrupted can be determined by - * masking the return value against (1 << {Endpoint Number}). - * - * \return Mask whose bits indicate which endpoints have interrupted. - */ - static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_GetEndpointInterrupts(void) - { - return UEINT; - } - - /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type - * endpoints). - * - * \param[in] EndpointNumber Index of the endpoint whose interrupt flag should be tested. - * - * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise. - */ - static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) - { - return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false); - } - - /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise. - */ - static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsINReady(void) - { - return ((UEINTX & (1 << TXINI)) ? true : false); - } - - /** Determines if the selected OUT endpoint has received new packet from the host. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise. - */ - static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsOUTReceived(void) - { - return ((UEINTX & (1 << RXOUTI)) ? true : false); - } - - /** Determines if the current CONTROL type endpoint has received a SETUP packet. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise. - */ - static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsSETUPReceived(void) - { - return ((UEINTX & (1 << RXSTPI)) ? true : false); - } - - /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the - * endpoint for the next packet. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \note This is not applicable for non CONTROL type endpoints. - */ - static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ClearSETUP(void) - { - UEINTX &= ~(1 << RXSTPI); - } - - /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the - * next packet and switching to the alternative endpoint bank if double banked. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - */ - static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ClearIN(void) - { - #if !defined(CONTROL_ONLY_DEVICE) - UEINTX &= ~((1 << TXINI) | (1 << FIFOCON)); - #else - UEINTX &= ~(1 << TXINI); - #endif - } - - /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint - * for the next packet and switching to the alternative endpoint bank if double banked. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - */ - static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ClearOUT(void) - { - #if !defined(CONTROL_ONLY_DEVICE) - UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON)); - #else - UEINTX &= ~(1 << RXOUTI); - #endif - } - - /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the - * indicated endpoint and that the current transfer sequence should be aborted. This provides a - * way for devices to indicate invalid commands to the host so that the current transfer can be - * aborted and the host can begin its own recovery sequence. - * - * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro - * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected - * endpoint. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - */ - static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_StallTransaction(void) - { - UECONX |= (1 << STALLRQ); - } - - /** Clears the STALL condition on the currently selected endpoint. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - */ - static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ClearStall(void) - { - UECONX |= (1 << STALLRQC); - } - - /** Determines if the currently selected endpoint is stalled, false otherwise. - * - * \ingroup Group_EndpointPacketManagement_AVR8 - * - * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. - */ - static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Endpoint_IsStalled(void) - { - return ((UECONX & (1 << STALLRQ)) ? true : false); - } - - /** Resets the data toggle of the currently selected endpoint. */ - static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_ResetDataToggle(void) - { - UECONX |= (1 << RSTDT); - } - - /** Determines the currently selected endpoint's direction. - * - * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. - */ - static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_GetEndpointDirection(void) - { - return (UECFG0X & (1 << EPDIR)) ? ENDPOINT_DIR_IN : ENDPOINT_DIR_OUT; - } - - /** Sets the direction of the currently selected endpoint. - * - * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask. - */ - static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) ATTR_ALWAYS_INLINE; - static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) - { - UECFG0X = ((UECFG0X & ~(1 << EPDIR)) | (DirectionMask ? (1 << EPDIR) : 0)); - } - - /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \return Next byte in the currently selected endpoint's FIFO buffer. - */ - static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Endpoint_Read_8(void) - { - return UEDATX; - } - - /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_8(const uint8_t Data) - { - UEDATX = Data; - } - - /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - */ - static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Discard_8(void) - { - uint8_t Dummy; - - Dummy = UEDATX; - - (void)Dummy; - } - - /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \return Next two bytes in the currently selected endpoint's FIFO buffer. - */ - static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Endpoint_Read_16_LE(void) - { - union - { - uint16_t Value; - uint8_t Bytes[2]; - } Data; - - Data.Bytes[0] = UEDATX; - Data.Bytes[1] = UEDATX; - - return Data.Value; - } - - /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \return Next two bytes in the currently selected endpoint's FIFO buffer. - */ - static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Endpoint_Read_16_BE(void) - { - union - { - uint16_t Value; - uint8_t Bytes[2]; - } Data; - - Data.Bytes[1] = UEDATX; - Data.Bytes[0] = UEDATX; - - return Data.Value; - } - - /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_16_LE(const uint16_t Data) - { - UEDATX = (Data & 0xFF); - UEDATX = (Data >> 8); - } - - /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_16_BE(const uint16_t Data) - { - UEDATX = (Data >> 8); - UEDATX = (Data & 0xFF); - } - - /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - */ - static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Discard_16(void) - { - uint8_t Dummy; - - Dummy = UEDATX; - Dummy = UEDATX; - - (void)Dummy; - } - - /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \return Next four bytes in the currently selected endpoint's FIFO buffer. - */ - static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint32_t Endpoint_Read_32_LE(void) - { - union - { - uint32_t Value; - uint8_t Bytes[4]; - } Data; - - Data.Bytes[0] = UEDATX; - Data.Bytes[1] = UEDATX; - Data.Bytes[2] = UEDATX; - Data.Bytes[3] = UEDATX; - - return Data.Value; - } - - /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \return Next four bytes in the currently selected endpoint's FIFO buffer. - */ - static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint32_t Endpoint_Read_32_BE(void) - { - union - { - uint32_t Value; - uint8_t Bytes[4]; - } Data; - - Data.Bytes[3] = UEDATX; - Data.Bytes[2] = UEDATX; - Data.Bytes[1] = UEDATX; - Data.Bytes[0] = UEDATX; - - return Data.Value; - } - - /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_32_LE(const uint32_t Data) - { - UEDATX = (Data & 0xFF); - UEDATX = (Data >> 8); - UEDATX = (Data >> 16); - UEDATX = (Data >> 24); - } - - /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN - * direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. - */ - static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Write_32_BE(const uint32_t Data) - { - UEDATX = (Data >> 24); - UEDATX = (Data >> 16); - UEDATX = (Data >> 8); - UEDATX = (Data & 0xFF); - } - - /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. - * - * \ingroup Group_EndpointPrimitiveRW_AVR8 - */ - static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE; - static inline void Endpoint_Discard_32(void) - { - uint8_t Dummy; - - Dummy = UEDATX; - Dummy = UEDATX; - Dummy = UEDATX; - Dummy = UEDATX; - - (void)Dummy; - } - - /* External Variables: */ - /** Global indicating the maximum packet size of the default control endpoint located at address - * 0 in the device. This value is set to the value indicated in the device descriptor in the user - * project once the USB interface is initialized into device mode. - * - * If space is an issue, it is possible to fix this to a static value by defining the control - * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile - * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically - * read from the descriptors at runtime and instead fixed to the given value. When used, it is - * important that the descriptor control endpoint size value matches the size given as the - * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token - * be used in the device descriptors to ensure this. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - */ - #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) - extern uint8_t USB_Device_ControlEndpointSize; - #else - #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE - #endif - - /* Function Prototypes: */ - /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically, - * with respect to the data direction. This is a convenience function which can be used to - * simplify user control request handling. - */ - void Endpoint_ClearStatusStage(void); - - /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data - * to be read or written to it. - * - * \note This routine should not be called on CONTROL type endpoints. - * - * \ingroup Group_EndpointRW_AVR8 - * - * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. - */ - uint8_t Endpoint_WaitUntilReady(void); - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Endpoint definitions for the AVR8 microcontrollers. + * \copydetails Group_EndpointManagement_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointRW_AVR8 Endpoint Data Reading and Writing (AVR8) + * \brief Endpoint data read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. + */ + +/** \ingroup Group_EndpointPrimitiveRW + * \defgroup Group_EndpointPrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8) + * \brief Endpoint primitive read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to endpoints. + */ + +/** \ingroup Group_EndpointPacketManagement + * \defgroup Group_EndpointPacketManagement_AVR8 Endpoint Packet Management (AVR8) + * \brief Endpoint packet management definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointManagement_AVR8 Endpoint Management (AVR8) + * \brief Endpoint management definitions for the Atmel AVR8 architecture. + * + * Functions, macros and enums related to endpoint management when in USB Device mode. This + * module contains the endpoint management macros, as well as endpoint interrupt and data + * send/receive functions for various data types. + * + * @{ + */ + +#ifndef __ENDPOINT_AVR8_H__ +#define __ENDPOINT_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex) + #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails) + #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize) + + #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex) + #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails) + #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks) + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + #define ENDPOINT_DETAILS_MAXEP 7 + + #define ENDPOINT_DETAILS_EP0 64, 1 + #define ENDPOINT_DETAILS_EP1 256, 2 + #define ENDPOINT_DETAILS_EP2 64, 2 + #define ENDPOINT_DETAILS_EP3 64, 2 + #define ENDPOINT_DETAILS_EP4 64, 2 + #define ENDPOINT_DETAILS_EP5 64, 2 + #define ENDPOINT_DETAILS_EP6 64, 2 + #else + #define ENDPOINT_DETAILS_MAXEP 5 + + #define ENDPOINT_DETAILS_EP0 64, 1 + #define ENDPOINT_DETAILS_EP1 64, 1 + #define ENDPOINT_DETAILS_EP2 64, 1 + #define ENDPOINT_DETAILS_EP3 64, 2 + #define ENDPOINT_DETAILS_EP4 64, 2 + #endif + + /* Inline Functions: */ + static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST + ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) + { + uint8_t MaskVal = 0; + uint16_t CheckBytes = 8; + + while (CheckBytes < Bytes) + { + MaskVal++; + CheckBytes <<= 1; + } + + return (MaskVal << EPSIZE0); + } + + /* Function Prototypes: */ + void Endpoint_ClearEndpoints(void); + bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, + const uint8_t UECFG0XData, + const uint8_t UECFG1XData); + + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Endpoint Bank Mode Masks */ + //@{ + /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates + * that the endpoint should have one single bank, which requires less USB FIFO memory but results + * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's + * bank at the one time. + */ + #define ENDPOINT_BANK_SINGLE (0 << EPBK0) + + /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates + * that the endpoint should have two banks, which requires more USB FIFO memory but results + * in faster transfers as one USB device (the AVR or the host) can access one bank while the other + * accesses the second bank. + */ + #define ENDPOINT_BANK_DOUBLE (1 << EPBK0) + //@} + + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size + * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined. + */ + #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 + #endif + + /** Retrieves the maximum bank size in bytes of a given endpoint. + * + * \note This macro will only work correctly on endpoint indexes that are compile-time constants + * defined by the preprocessor. + * + * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1) + */ + #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex) + + /** Retrieves the total number of banks supported by the given endpoint. + * + * \note This macro will only work correctly on endpoint indexes that are compile-time constants + * defined by the preprocessor. + * + * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1) + */ + #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex) + + #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__) + /** Total number of endpoints (including the default control endpoint at address 0) which may + * be used in the device. Different USB AVR models support different amounts of endpoints, + * this value reflects the maximum number of endpoints for the currently selected AVR model. + */ + #define ENDPOINT_TOTAL_ENDPOINTS ENDPOINT_DETAILS_MAXEP + #else + #define ENDPOINT_TOTAL_ENDPOINTS 1 + #endif + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function. + * + * \ingroup Group_EndpointRW_AVR8 + */ + enum Endpoint_WaitUntilReady_ErrorCodes_t + { + ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */ + ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream + * transfer by the host or device. + */ + ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while + * waiting for the endpoint to become ready. + */ + ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + }; + + /* Inline Functions: */ + /** Configures the specified endpoint number with the given endpoint type, direction, bank size + * and banking mode. Once configured, the endpoint may be read from or written to, depending + * on its direction. + * + * \param[in] Number Endpoint number to configure. This must be more than 0 and less than + * \ref ENDPOINT_TOTAL_ENDPOINTS. + * + * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types + * are available on Low Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] Direction Endpoint data direction, either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN. + * All endpoints (except Control type) are unidirectional - data may only be read + * from or written to the endpoint bank based on its direction, not both. + * + * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted + * to the USB host, or after they have been received from the USB host (depending on + * the endpoint's data direction). The bank size must indicate the maximum packet size + * that the endpoint can handle. + * + * \param[in] Banks Number of banks to use for the endpoint being configured, an \c ENDPOINT_BANK_* mask. + * More banks uses more USB DPRAM, but offers better performance. Isochronous type + * endpoints must have at least two banks. + * + * \note When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints must be configured in + * ascending order, or bank corruption will occur. + * \n\n + * + * \note Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to + * the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint. + * \n\n + * + * \note The default control endpoint should not be manually configured by the user application, as + * it is automatically configured by the library internally. + * \n\n + * + * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint + * which failed to reconfigure correctly will be selected. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number, + const uint8_t Type, + const uint8_t Direction, + const uint16_t Size, + const uint8_t Banks) ATTR_ALWAYS_INLINE; + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number, + const uint8_t Type, + const uint8_t Direction, + const uint16_t Size, + const uint8_t Banks) + { + return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << EPTYPE0) | (Direction ? (1 << EPDIR) : 0)), + ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size))); + } + + /** Indicates the number of bytes currently stored in the current endpoint's selected bank. + * + * \note The return width of this function may differ, depending on the maximum endpoint bank size + * of the selected AVR model. + * + * \ingroup Group_EndpointRW_AVR8 + * + * \return Total number of bytes in the currently selected Endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_BytesInEndpoint(void) + { + #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + return UEBCX; + #elif defined(USB_SERIES_4_AVR) + return (((uint16_t)UEBCHX << 8) | UEBCLX); + #elif defined(USB_SERIES_2_AVR) + return UEBCLX; + #endif + } + + /** Get the endpoint address of the currently selected endpoint. This is typically used to save + * the currently selected endpoint number so that it can be restored after another endpoint has + * been manipulated. + * + * \return Index of the currently selected endpoint. + */ + static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_GetCurrentEndpoint(void) + { + #if !defined(CONTROL_ONLY_DEVICE) + return (UENUM & ENDPOINT_EPNUM_MASK); + #else + return ENDPOINT_CONTROLEP; + #endif + } + + /** Selects the given endpoint number. If the address from the device descriptors is used, the + * value should be masked with the \ref ENDPOINT_EPNUM_MASK constant to extract only the endpoint + * number (and discarding the endpoint direction bit). + * + * Any endpoint operations which do not require the endpoint number to be indicated will operate on + * the currently selected endpoint. + * + * \param[in] EndpointNumber Endpoint number to select. + */ + static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE; + static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) + { + #if !defined(CONTROL_ONLY_DEVICE) + UENUM = EndpointNumber; + #endif + } + + /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's + * data In and Out pointers to the bank's contents. + * + * \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset. + */ + static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) + { + UERST = (1 << EndpointNumber); + UERST = 0; + } + + /** Enables the currently selected endpoint so that data can be sent and received through it to + * and from a host. + * + * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint(). + */ + static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_EnableEndpoint(void) + { + UECONX |= (1 << EPEN); + } + + /** Disables the currently selected endpoint so that data cannot be sent and received through it + * to and from a host. + */ + static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_DisableEndpoint(void) + { + UECONX &= ~(1 << EPEN); + } + + /** Determines if the currently selected endpoint is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise. + */ + static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsEnabled(void) + { + return ((UECONX & (1 << EPEN)) ? true : false); + } + + /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for + * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the + * \ref Endpoint_ClearOUT() command. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Total number of busy banks in the selected endpoint. + */ + static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Endpoint_GetBusyBanks(void) + { + return (UESTA0X & (0x03 << NBUSYBK0)); + } + + /** Aborts all pending IN transactions on the currently selected endpoint, once the bank + * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function + * will terminate all queued transactions, resetting the endpoint banks ready for a new + * packet. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_AbortPendingIN(void) + { + while (Endpoint_GetBusyBanks() != 0) + { + UEINTX |= (1 << RXOUTI); + while (UEINTX & (1 << RXOUTI)); + } + } + + /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint + * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN + * direction). This function will return false if an error has occurred in the endpoint, if the endpoint + * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN + * direction and the endpoint bank is full. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending + * on its direction. + */ + static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsReadWriteAllowed(void) + { + return ((UEINTX & (1 << RWAL)) ? true : false); + } + + /** Determines if the currently selected endpoint is configured. + * + * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise. + */ + static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsConfigured(void) + { + return ((UESTA0X & (1 << CFGOK)) ? true : false); + } + + /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their + * interrupt duration has elapsed. Which endpoints have interrupted can be determined by + * masking the return value against (1 << {Endpoint Number}). + * + * \return Mask whose bits indicate which endpoints have interrupted. + */ + static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_GetEndpointInterrupts(void) + { + return UEINT; + } + + /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type + * endpoints). + * + * \param[in] EndpointNumber Index of the endpoint whose interrupt flag should be tested. + * + * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise. + */ + static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) + { + return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false); + } + + /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise. + */ + static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsINReady(void) + { + return ((UEINTX & (1 << TXINI)) ? true : false); + } + + /** Determines if the selected OUT endpoint has received new packet from the host. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise. + */ + static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsOUTReceived(void) + { + return ((UEINTX & (1 << RXOUTI)) ? true : false); + } + + /** Determines if the current CONTROL type endpoint has received a SETUP packet. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise. + */ + static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsSETUPReceived(void) + { + return ((UEINTX & (1 << RXSTPI)) ? true : false); + } + + /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the + * endpoint for the next packet. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \note This is not applicable for non CONTROL type endpoints. + */ + static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearSETUP(void) + { + UEINTX &= ~(1 << RXSTPI); + } + + /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the + * next packet and switching to the alternative endpoint bank if double banked. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearIN(void) + { + #if !defined(CONTROL_ONLY_DEVICE) + UEINTX &= ~((1 << TXINI) | (1 << FIFOCON)); + #else + UEINTX &= ~(1 << TXINI); + #endif + } + + /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint + * for the next packet and switching to the alternative endpoint bank if double banked. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearOUT(void) + { + #if !defined(CONTROL_ONLY_DEVICE) + UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON)); + #else + UEINTX &= ~(1 << RXOUTI); + #endif + } + + /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the + * indicated endpoint and that the current transfer sequence should be aborted. This provides a + * way for devices to indicate invalid commands to the host so that the current transfer can be + * aborted and the host can begin its own recovery sequence. + * + * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro + * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected + * endpoint. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_StallTransaction(void) + { + UECONX |= (1 << STALLRQ); + } + + /** Clears the STALL condition on the currently selected endpoint. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearStall(void) + { + UECONX |= (1 << STALLRQC); + } + + /** Determines if the currently selected endpoint is stalled, false otherwise. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. + */ + static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsStalled(void) + { + return ((UECONX & (1 << STALLRQ)) ? true : false); + } + + /** Resets the data toggle of the currently selected endpoint. */ + static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetDataToggle(void) + { + UECONX |= (1 << RSTDT); + } + + /** Determines the currently selected endpoint's direction. + * + * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_GetEndpointDirection(void) + { + return (UECFG0X & (1 << EPDIR)) ? ENDPOINT_DIR_IN : ENDPOINT_DIR_OUT; + } + + /** Sets the direction of the currently selected endpoint. + * + * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) ATTR_ALWAYS_INLINE; + static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) + { + UECFG0X = ((UECFG0X & ~(1 << EPDIR)) | (DirectionMask ? (1 << EPDIR) : 0)); + } + + /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next byte in the currently selected endpoint's FIFO buffer. + */ + static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_Read_8(void) + { + return UEDATX; + } + + /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_8(const uint8_t Data) + { + UEDATX = Data; + } + + /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + */ + static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_8(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + + (void)Dummy; + } + + /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_LE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; + + return Data.Value; + } + + /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_BE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; + + return Data.Value; + } + + /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_LE(const uint16_t Data) + { + UEDATX = (Data & 0xFF); + UEDATX = (Data >> 8); + } + + /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_BE(const uint16_t Data) + { + UEDATX = (Data >> 8); + UEDATX = (Data & 0xFF); + } + + /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + */ + static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_16(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + Dummy = UEDATX; + + (void)Dummy; + } + + /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_LE(void) + { + union + { + uint32_t Value; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[2] = UEDATX; + Data.Bytes[3] = UEDATX; + + return Data.Value; + } + + /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_BE(void) + { + union + { + uint32_t Value; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[3] = UEDATX; + Data.Bytes[2] = UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; + + return Data.Value; + } + + /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_LE(const uint32_t Data) + { + UEDATX = (Data & 0xFF); + UEDATX = (Data >> 8); + UEDATX = (Data >> 16); + UEDATX = (Data >> 24); + } + + /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_BE(const uint32_t Data) + { + UEDATX = (Data >> 24); + UEDATX = (Data >> 16); + UEDATX = (Data >> 8); + UEDATX = (Data & 0xFF); + } + + /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + */ + static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_32(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + Dummy = UEDATX; + Dummy = UEDATX; + Dummy = UEDATX; + + (void)Dummy; + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control endpoint located at address + * 0 in the device. This value is set to the value indicated in the device descriptor in the user + * project once the USB interface is initialized into device mode. + * + * If space is an issue, it is possible to fix this to a static value by defining the control + * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile + * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically + * read from the descriptors at runtime and instead fixed to the given value. When used, it is + * important that the descriptor control endpoint size value matches the size given as the + * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token + * be used in the device descriptors to ensure this. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + extern uint8_t USB_Device_ControlEndpointSize; + #else + #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE + #endif + + /* Function Prototypes: */ + /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically, + * with respect to the data direction. This is a convenience function which can be used to + * simplify user control request handling. + */ + void Endpoint_ClearStatusStage(void); + + /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data + * to be read or written to it. + * + * \note This routine should not be called on CONTROL type endpoints. + * + * \ingroup Group_EndpointRW_AVR8 + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t Endpoint_WaitUntilReady(void); + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c index 9055370..6d7e968 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -1,297 +1,297 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBMode.h" - -#if defined(USB_CAN_BE_HOST) - -#define __INCLUDE_FROM_HOST_C -#include "../Host.h" - -void USB_Host_ProcessNextHostState(void) -{ - uint8_t ErrorCode = HOST_ENUMERROR_NoError; - uint8_t SubErrorCode = HOST_ENUMERROR_NoError; - - static uint16_t WaitMSRemaining; - static uint8_t PostWaitState; - - switch (USB_HostState) - { - case HOST_STATE_WaitForDevice: - if (WaitMSRemaining) - { - if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) - { - USB_HostState = PostWaitState; - ErrorCode = HOST_ENUMERROR_WaitStage; - break; - } - - if (!(--WaitMSRemaining)) - USB_HostState = PostWaitState; - } - - break; - case HOST_STATE_Powered: - WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS; - - USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle; - break; - case HOST_STATE_Powered_WaitForDeviceSettle: - if (WaitMSRemaining--) - { - Delay_MS(1); - break; - } - else - { - USB_Host_VBUS_Manual_Off(); - - USB_OTGPAD_On(); - USB_Host_VBUS_Auto_Enable(); - USB_Host_VBUS_Auto_On(); - - #if defined(NO_AUTO_VBUS_MANAGEMENT) - USB_Host_VBUS_Manual_Enable(); - USB_Host_VBUS_Manual_On(); - #endif - - USB_HostState = HOST_STATE_Powered_WaitForConnect; - } - - break; - case HOST_STATE_Powered_WaitForConnect: - if (USB_INT_HasOccurred(USB_INT_DCONNI)) - { - USB_INT_Clear(USB_INT_DCONNI); - USB_INT_Clear(USB_INT_DDISCI); - - USB_INT_Clear(USB_INT_VBERRI); - USB_INT_Enable(USB_INT_VBERRI); - - USB_Host_ResumeBus(); - Pipe_ClearPipes(); - - HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset); - } - - break; - case HOST_STATE_Powered_DoReset: - USB_Host_ResetDevice(); - - HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe); - break; - case HOST_STATE_Powered_ConfigPipe: - Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, - PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP, - PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE); - - if (!(Pipe_IsConfigured())) - { - ErrorCode = HOST_ENUMERROR_PipeConfigError; - SubErrorCode = 0; - break; - } - - USB_HostState = HOST_STATE_Default; - break; - case HOST_STATE_Default: - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_GetDescriptor, - .wValue = (DTYPE_Device << 8), - .wIndex = 0, - .wLength = 8, - }; - - uint8_t DataBuffer[8]; - - if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful) - { - ErrorCode = HOST_ENUMERROR_ControlError; - break; - } - - USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; - - USB_Host_ResetDevice(); - - HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset); - break; - case HOST_STATE_Default_PostReset: - Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, - PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP, - USB_Host_ControlPipeSize, PIPE_BANK_SINGLE); - - if (!(Pipe_IsConfigured())) - { - ErrorCode = HOST_ENUMERROR_PipeConfigError; - SubErrorCode = 0; - break; - } - - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_SetAddress, - .wValue = USB_HOST_DEVICEADDRESS, - .wIndex = 0, - .wLength = 0, - }; - - if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) - { - ErrorCode = HOST_ENUMERROR_ControlError; - break; - } - - HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet); - break; - case HOST_STATE_Default_PostAddressSet: - USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS); - - USB_HostState = HOST_STATE_Addressed; - - EVENT_USB_Host_DeviceEnumerationComplete(); - break; - } - - if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached)) - { - EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode); - - USB_Host_VBUS_Auto_Off(); - - EVENT_USB_Host_DeviceUnattached(); - - USB_ResetInterface(); - } -} - -uint8_t USB_Host_WaitMS(uint8_t MS) -{ - bool BusSuspended = USB_Host_IsBusSuspended(); - uint8_t ErrorCode = HOST_WAITERROR_Successful; - bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); - - USB_INT_Disable(USB_INT_HSOFI); - USB_INT_Clear(USB_INT_HSOFI); - - USB_Host_ResumeBus(); - - while (MS) - { - if (USB_INT_HasOccurred(USB_INT_HSOFI)) - { - USB_INT_Clear(USB_INT_HSOFI); - MS--; - } - - if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host)) - { - ErrorCode = HOST_WAITERROR_DeviceDisconnect; - - break; - } - - if (Pipe_IsError()) - { - Pipe_ClearError(); - ErrorCode = HOST_WAITERROR_PipeError; - - break; - } - - if (Pipe_IsStalled()) - { - Pipe_ClearStall(); - ErrorCode = HOST_WAITERROR_SetupStalled; - - break; - } - } - - if (BusSuspended) - USB_Host_SuspendBus(); - - if (HSOFIEnabled) - USB_INT_Enable(USB_INT_HSOFI); - - return ErrorCode; -} - -static void USB_Host_ResetDevice(void) -{ - bool BusSuspended = USB_Host_IsBusSuspended(); - - USB_INT_Disable(USB_INT_DDISCI); - - USB_Host_ResetBus(); - while (!(USB_Host_IsBusResetComplete())); - USB_Host_ResumeBus(); - - USB_Host_ConfigurationNumber = 0; - - bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); - - USB_INT_Disable(USB_INT_HSOFI); - USB_INT_Clear(USB_INT_HSOFI); - - for (uint8_t MSRem = 10; MSRem != 0; MSRem--) - { - /* Workaround for powerless-pull-up devices. After a USB bus reset, - all disconnection interrupts are suppressed while a USB frame is - looked for - if it is found within 10ms, the device is still - present. */ - - if (USB_INT_HasOccurred(USB_INT_HSOFI)) - { - USB_INT_Clear(USB_INT_HSOFI); - USB_INT_Clear(USB_INT_DDISCI); - break; - } - - Delay_MS(1); - } - - if (HSOFIEnabled) - USB_INT_Enable(USB_INT_HSOFI); - - if (BusSuspended) - USB_Host_SuspendBus(); - - USB_INT_Enable(USB_INT_DDISCI); -} - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HOST_C +#include "../Host.h" + +void USB_Host_ProcessNextHostState(void) +{ + uint8_t ErrorCode = HOST_ENUMERROR_NoError; + uint8_t SubErrorCode = HOST_ENUMERROR_NoError; + + static uint16_t WaitMSRemaining; + static uint8_t PostWaitState; + + switch (USB_HostState) + { + case HOST_STATE_WaitForDevice: + if (WaitMSRemaining) + { + if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + { + USB_HostState = PostWaitState; + ErrorCode = HOST_ENUMERROR_WaitStage; + break; + } + + if (!(--WaitMSRemaining)) + USB_HostState = PostWaitState; + } + + break; + case HOST_STATE_Powered: + WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS; + + USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle; + break; + case HOST_STATE_Powered_WaitForDeviceSettle: + if (WaitMSRemaining--) + { + Delay_MS(1); + break; + } + else + { + USB_Host_VBUS_Manual_Off(); + + USB_OTGPAD_On(); + USB_Host_VBUS_Auto_Enable(); + USB_Host_VBUS_Auto_On(); + + #if defined(NO_AUTO_VBUS_MANAGEMENT) + USB_Host_VBUS_Manual_Enable(); + USB_Host_VBUS_Manual_On(); + #endif + + USB_HostState = HOST_STATE_Powered_WaitForConnect; + } + + break; + case HOST_STATE_Powered_WaitForConnect: + if (USB_INT_HasOccurred(USB_INT_DCONNI)) + { + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Clear(USB_INT_DDISCI); + + USB_INT_Clear(USB_INT_VBERRI); + USB_INT_Enable(USB_INT_VBERRI); + + USB_Host_ResumeBus(); + Pipe_ClearPipes(); + + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset); + } + + break; + case HOST_STATE_Powered_DoReset: + USB_Host_ResetDevice(); + + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe); + break; + case HOST_STATE_Powered_ConfigPipe: + Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, + PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP, + PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE); + + if (!(Pipe_IsConfigured())) + { + ErrorCode = HOST_ENUMERROR_PipeConfigError; + SubErrorCode = 0; + break; + } + + USB_HostState = HOST_STATE_Default; + break; + case HOST_STATE_Default: + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetDescriptor, + .wValue = (DTYPE_Device << 8), + .wIndex = 0, + .wLength = 8, + }; + + uint8_t DataBuffer[8]; + + if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful) + { + ErrorCode = HOST_ENUMERROR_ControlError; + break; + } + + USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; + + USB_Host_ResetDevice(); + + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset); + break; + case HOST_STATE_Default_PostReset: + Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, + PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP, + USB_Host_ControlPipeSize, PIPE_BANK_SINGLE); + + if (!(Pipe_IsConfigured())) + { + ErrorCode = HOST_ENUMERROR_PipeConfigError; + SubErrorCode = 0; + break; + } + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_SetAddress, + .wValue = USB_HOST_DEVICEADDRESS, + .wIndex = 0, + .wLength = 0, + }; + + if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + { + ErrorCode = HOST_ENUMERROR_ControlError; + break; + } + + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet); + break; + case HOST_STATE_Default_PostAddressSet: + USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS); + + USB_HostState = HOST_STATE_Addressed; + + EVENT_USB_Host_DeviceEnumerationComplete(); + break; + } + + if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached)) + { + EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode); + + USB_Host_VBUS_Auto_Off(); + + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } +} + +uint8_t USB_Host_WaitMS(uint8_t MS) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + uint8_t ErrorCode = HOST_WAITERROR_Successful; + bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); + + USB_INT_Disable(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_HSOFI); + + USB_Host_ResumeBus(); + + while (MS) + { + if (USB_INT_HasOccurred(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + MS--; + } + + if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host)) + { + ErrorCode = HOST_WAITERROR_DeviceDisconnect; + + break; + } + + if (Pipe_IsError()) + { + Pipe_ClearError(); + ErrorCode = HOST_WAITERROR_PipeError; + + break; + } + + if (Pipe_IsStalled()) + { + Pipe_ClearStall(); + ErrorCode = HOST_WAITERROR_SetupStalled; + + break; + } + } + + if (BusSuspended) + USB_Host_SuspendBus(); + + if (HSOFIEnabled) + USB_INT_Enable(USB_INT_HSOFI); + + return ErrorCode; +} + +static void USB_Host_ResetDevice(void) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + + USB_INT_Disable(USB_INT_DDISCI); + + USB_Host_ResetBus(); + while (!(USB_Host_IsBusResetComplete())); + USB_Host_ResumeBus(); + + USB_Host_ConfigurationNumber = 0; + + bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); + + USB_INT_Disable(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_HSOFI); + + for (uint8_t MSRem = 10; MSRem != 0; MSRem--) + { + /* Workaround for powerless-pull-up devices. After a USB bus reset, + all disconnection interrupts are suppressed while a USB frame is + looked for - if it is found within 10ms, the device is still + present. */ + + if (USB_INT_HasOccurred(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_DDISCI); + break; + } + + Delay_MS(1); + } + + if (HSOFIEnabled) + USB_INT_Enable(USB_INT_HSOFI); + + if (BusSuspended) + USB_Host_SuspendBus(); + + USB_INT_Enable(USB_INT_DDISCI); +} + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h index 3126105..09c58bc 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h @@ -1,372 +1,372 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Host definitions for the AVR8 microcontrollers. - * \copydetails Group_Host_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_Host - * \defgroup Group_Host_AVR8 Host Management (AVR8) - * \brief USB Host definitions for the AVR8 microcontrollers. - * - * Architecture specific USB Host definitions for the Atmel 8-bit AVR microcontrollers. - * - * @{ - */ - -#ifndef __USBHOST_AVR8_H__ -#define __USBHOST_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../StdDescriptors.h" - #include "../Pipe.h" - #include "../USBInterrupt.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - #if defined(INVERTED_VBUS_ENABLE_LINE) && !defined(NO_AUTO_VBUS_MANAGEMENT) - #error The INVERTED_VBUS_ENABLE_LINE compile option requires NO_AUTO_VBUS_MANAGEMENT for the AVR8 architecture. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Indicates the fixed USB device address which any attached device is enumerated to when in - * host mode. As only one USB device may be attached to the AVR in host mode at any one time - * and that the address used is not important (other than the fact that it is non-zero), a - * fixed value is specified by the library. - */ - #define USB_HOST_DEVICEADDRESS 1 - - #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__) - /** Constant for the delay in milliseconds after a device is connected before the library - * will start the enumeration process. Some devices require a delay of up to 5 seconds - * after connection before the enumeration process can start or incorrect operation will - * occur. - * - * The default delay value may be overridden in the user project makefile by defining the - * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the - * compiler using the -D switch. - */ - #define HOST_DEVICE_SETTLE_DELAY_MS 1000 - #endif - - /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event. - * - * \see \ref Group_Events for more information on this event. - */ - enum USB_Host_ErrorCodes_t - { - HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This - * error may be the result of an attached device drawing - * too much current from the VBUS line, or due to the - * AVR's power source being unable to supply sufficient - * current. - */ - }; - - /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event. - * - * \see \ref Group_Events for more information on this event. - */ - enum USB_Host_EnumerationErrorCodes_t - { - HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid - * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed() - * event. - */ - HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed - * to complete successfully, due to a timeout or other - * error. - */ - HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines - * indicating the attachment of a device. - */ - HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to - * complete successfully. - */ - HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to - * configure correctly. - */ - }; - - /* Inline Functions: */ - /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended) - * the frame number is incremented by one. - * - * \return Current USB frame number from the USB controller. - */ - static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t USB_Host_GetFrameNumber(void) - { - return UHFNUM; - } - - #if !defined(NO_SOF_EVENTS) - /** Enables the host mode Start Of Frame events. When enabled, this causes the - * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, - * at the start of each USB frame when a device is enumerated while in host mode. - * - * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. - */ - static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_EnableSOFEvents(void) - { - USB_INT_Enable(USB_INT_HSOFI); - } - - /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the - * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode. - * - * \note Not available when the NO_SOF_EVENTS compile time token is defined. - */ - static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_DisableSOFEvents(void) - { - USB_INT_Disable(USB_INT_HSOFI); - } - #endif - - /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host. - * USB bus resets leave the default control pipe configured (if already configured). - * - * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be - * woken up automatically and the bus resumed after the reset has been correctly issued. - */ - static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_ResetBus(void) - { - UHCON |= (1 << RESET); - } - - /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has - * completed. - * - * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise. - */ - static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_Host_IsBusResetComplete(void) - { - return ((UHCON & (1 << RESET)) ? false : true); - } - - /** Resumes USB communications with an attached and enumerated device, by resuming the transmission - * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the - * host and attached device may occur. - */ - static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_ResumeBus(void) - { - UHCON |= (1 << SOFEN); - } - - /** Suspends the USB bus, preventing any communications from occurring between the host and attached - * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame - * messages to the device. - * - * \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that - * some events (such as device disconnections) will not fire until the bus is resumed. - */ - static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_SuspendBus(void) - { - UHCON &= ~(1 << SOFEN); - } - - /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro, - * false otherwise. While suspended, no USB communications can occur until the bus is resumed, - * except for the Remote Wakeup event from the device if supported. - * - * \return Boolean \c true if the bus is currently suspended, \c false otherwise. - */ - static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_Host_IsBusSuspended(void) - { - return ((UHCON & (1 << SOFEN)) ? false : true); - } - - /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or - * false if the attached device is enumerated in Low Speed mode (1.5Mb/s). - * - * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise. - */ - static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_Host_IsDeviceFullSpeed(void) - { - return ((USBSTA & (1 << SPEED)) ? true : false); - } - - /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting - * that the host resume the USB bus and wake up the device, false otherwise. - * - * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise. - */ - static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_Host_IsRemoteWakeupSent(void) - { - return ((UHINT & (1 << RXRSMI)) ? true : false); - } - - /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */ - static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_ClearRemoteWakeupSent(void) - { - UHINT &= ~(1 << RXRSMI); - } - - /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to - * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to - * be resumed. - */ - static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_ResumeFromWakeupRequest(void) - { - UHCON |= (1 << RESUME); - } - - /** Determines if a resume from Remote Wakeup request is currently being sent to an attached - * device. - * - * \return Boolean \c true if no resume request is currently being sent, \c false otherwise. - */ - static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) - { - return ((UHCON & (1 << RESUME)) ? false : true); - } - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Macros: */ - static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_HostMode_On(void) - { - USBCON |= (1 << HOST); - } - - static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_HostMode_Off(void) - { - USBCON &= ~(1 << HOST); - } - - static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_VBUS_Auto_Enable(void) - { - OTGCON &= ~(1 << VBUSHWC); - UHWCON |= (1 << UVCONE); - } - - static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_VBUS_Manual_Enable(void) - { - OTGCON |= (1 << VBUSHWC); - UHWCON &= ~(1 << UVCONE); - - DDRE |= (1 << 7); - } - - static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_VBUS_Auto_On(void) - { - OTGCON |= (1 << VBUSREQ); - } - - static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_VBUS_Manual_On(void) - { - #if defined(INVERTED_VBUS_ENABLE_LINE) - PORTE &= ~(1 << 7); - #else - PORTE |= (1 << 7); - #endif - } - - static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_VBUS_Auto_Off(void) - { - OTGCON |= (1 << VBUSRQC); - } - - static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE; - static inline void USB_Host_VBUS_Manual_Off(void) - { - #if defined(INVERTED_VBUS_ENABLE_LINE) - PORTE |= (1 << 7); - #else - PORTE &= ~(1 << 7); - #endif - } - - static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; - static inline void USB_Host_SetDeviceAddress(const uint8_t Address) - { - UHADDR = (Address & 0x7F); - } - - /* Enums: */ - enum USB_Host_WaitMSErrorCodes_t - { - HOST_WAITERROR_Successful = 0, - HOST_WAITERROR_DeviceDisconnect = 1, - HOST_WAITERROR_PipeError = 2, - HOST_WAITERROR_SetupStalled = 3, - }; - - /* Function Prototypes: */ - void USB_Host_ProcessNextHostState(void); - uint8_t USB_Host_WaitMS(uint8_t MS); - - #if defined(__INCLUDE_FROM_HOST_C) - static void USB_Host_ResetDevice(void); - #endif - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Host definitions for the AVR8 microcontrollers. + * \copydetails Group_Host_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Host + * \defgroup Group_Host_AVR8 Host Management (AVR8) + * \brief USB Host definitions for the AVR8 microcontrollers. + * + * Architecture specific USB Host definitions for the Atmel 8-bit AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBHOST_AVR8_H__ +#define __USBHOST_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../StdDescriptors.h" + #include "../Pipe.h" + #include "../USBInterrupt.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if defined(INVERTED_VBUS_ENABLE_LINE) && !defined(NO_AUTO_VBUS_MANAGEMENT) + #error The INVERTED_VBUS_ENABLE_LINE compile option requires NO_AUTO_VBUS_MANAGEMENT for the AVR8 architecture. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates the fixed USB device address which any attached device is enumerated to when in + * host mode. As only one USB device may be attached to the AVR in host mode at any one time + * and that the address used is not important (other than the fact that it is non-zero), a + * fixed value is specified by the library. + */ + #define USB_HOST_DEVICEADDRESS 1 + + #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__) + /** Constant for the delay in milliseconds after a device is connected before the library + * will start the enumeration process. Some devices require a delay of up to 5 seconds + * after connection before the enumeration process can start or incorrect operation will + * occur. + * + * The default delay value may be overridden in the user project makefile by defining the + * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the + * compiler using the -D switch. + */ + #define HOST_DEVICE_SETTLE_DELAY_MS 1000 + #endif + + /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event. + * + * \see \ref Group_Events for more information on this event. + */ + enum USB_Host_ErrorCodes_t + { + HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This + * error may be the result of an attached device drawing + * too much current from the VBUS line, or due to the + * AVR's power source being unable to supply sufficient + * current. + */ + }; + + /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event. + * + * \see \ref Group_Events for more information on this event. + */ + enum USB_Host_EnumerationErrorCodes_t + { + HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid + * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed() + * event. + */ + HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed + * to complete successfully, due to a timeout or other + * error. + */ + HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines + * indicating the attachment of a device. + */ + HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to + * complete successfully. + */ + HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to + * configure correctly. + */ + }; + + /* Inline Functions: */ + /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t USB_Host_GetFrameNumber(void) + { + return UHFNUM; + } + + #if !defined(NO_SOF_EVENTS) + /** Enables the host mode Start Of Frame events. When enabled, this causes the + * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, + * at the start of each USB frame when a device is enumerated while in host mode. + * + * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_EnableSOFEvents(void) + { + USB_INT_Enable(USB_INT_HSOFI); + } + + /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the + * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode. + * + * \note Not available when the NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_DisableSOFEvents(void) + { + USB_INT_Disable(USB_INT_HSOFI); + } + #endif + + /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host. + * USB bus resets leave the default control pipe configured (if already configured). + * + * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be + * woken up automatically and the bus resumed after the reset has been correctly issued. + */ + static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ResetBus(void) + { + UHCON |= (1 << RESET); + } + + /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has + * completed. + * + * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise. + */ + static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsBusResetComplete(void) + { + return ((UHCON & (1 << RESET)) ? false : true); + } + + /** Resumes USB communications with an attached and enumerated device, by resuming the transmission + * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the + * host and attached device may occur. + */ + static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ResumeBus(void) + { + UHCON |= (1 << SOFEN); + } + + /** Suspends the USB bus, preventing any communications from occurring between the host and attached + * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame + * messages to the device. + * + * \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that + * some events (such as device disconnections) will not fire until the bus is resumed. + */ + static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_SuspendBus(void) + { + UHCON &= ~(1 << SOFEN); + } + + /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro, + * false otherwise. While suspended, no USB communications can occur until the bus is resumed, + * except for the Remote Wakeup event from the device if supported. + * + * \return Boolean \c true if the bus is currently suspended, \c false otherwise. + */ + static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsBusSuspended(void) + { + return ((UHCON & (1 << SOFEN)) ? false : true); + } + + /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or + * false if the attached device is enumerated in Low Speed mode (1.5Mb/s). + * + * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise. + */ + static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsDeviceFullSpeed(void) + { + return ((USBSTA & (1 << SPEED)) ? true : false); + } + + /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting + * that the host resume the USB bus and wake up the device, false otherwise. + * + * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise. + */ + static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsRemoteWakeupSent(void) + { + return ((UHINT & (1 << RXRSMI)) ? true : false); + } + + /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */ + static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ClearRemoteWakeupSent(void) + { + UHINT &= ~(1 << RXRSMI); + } + + /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to + * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to + * be resumed. + */ + static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ResumeFromWakeupRequest(void) + { + UHCON |= (1 << RESUME); + } + + /** Determines if a resume from Remote Wakeup request is currently being sent to an attached + * device. + * + * \return Boolean \c true if no resume request is currently being sent, \c false otherwise. + */ + static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) + { + return ((UHCON & (1 << RESUME)) ? false : true); + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_HostMode_On(void) + { + USBCON |= (1 << HOST); + } + + static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_HostMode_Off(void) + { + USBCON &= ~(1 << HOST); + } + + static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_Enable(void) + { + OTGCON &= ~(1 << VBUSHWC); + UHWCON |= (1 << UVCONE); + } + + static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_Enable(void) + { + OTGCON |= (1 << VBUSHWC); + UHWCON &= ~(1 << UVCONE); + + DDRE |= (1 << 7); + } + + static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_On(void) + { + OTGCON |= (1 << VBUSREQ); + } + + static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_On(void) + { + #if defined(INVERTED_VBUS_ENABLE_LINE) + PORTE &= ~(1 << 7); + #else + PORTE |= (1 << 7); + #endif + } + + static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_Off(void) + { + OTGCON |= (1 << VBUSRQC); + } + + static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_Off(void) + { + #if defined(INVERTED_VBUS_ENABLE_LINE) + PORTE |= (1 << 7); + #else + PORTE &= ~(1 << 7); + #endif + } + + static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Host_SetDeviceAddress(const uint8_t Address) + { + UHADDR = (Address & 0x7F); + } + + /* Enums: */ + enum USB_Host_WaitMSErrorCodes_t + { + HOST_WAITERROR_Successful = 0, + HOST_WAITERROR_DeviceDisconnect = 1, + HOST_WAITERROR_PipeError = 2, + HOST_WAITERROR_SetupStalled = 3, + }; + + /* Function Prototypes: */ + void USB_Host_ProcessNextHostState(void); + uint8_t USB_Host_WaitMS(uint8_t MS); + + #if defined(__INCLUDE_FROM_HOST_C) + static void USB_Host_ResetDevice(void); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h index 5296beb..e981b53 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h @@ -1,159 +1,159 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB OTG definitions for the AVR8 microcontrollers. - * \copydetails Group_OTG_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_OTG - * \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8) - * \brief USB OTG definitions for the AVR8 microcontrollers. - * - * Architecture specific USB OTG definitions for the Atmel 8-bit AVR microcontrollers. - * - * @{ - */ - -#ifndef __USBOTG_AVR8_H__ -#define __USBOTG_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices. - * - * \see \ref USB_OTG_Device_InitiateSRP(). - */ - #define USB_OTG_SRP_VBUS (1 << SRPSEL) - - /** Mask for the Data + pulsing method of SRP, supported by some OTG devices. - * - * \see \ref USB_OTG_Device_InitiateSRP(). - */ - #define USB_OTG_STP_DATA 0 - - /* Inline Functions: */ - /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device - * that the device wishes to change device/host roles. - */ - static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE; - static inline void USB_OTG_Device_RequestHNP(void) - { - OTGCON |= (1 << HNPREQ); - } - - /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other - * connected device. - */ - static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE; - static inline void USB_OTG_Device_CancelHNPRequest(void) - { - OTGCON &= ~(1 << HNPREQ); - } - - /** Determines if the device is currently sending a HNP to an attached host. - * - * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise - */ - static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_OTG_Device_IsSendingHNP(void) - { - return ((OTGCON & (1 << HNPREQ)) ? true : false); - } - - /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB - * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in - * host mode indicates that VBUS should be applied and a session started. - * - * There are two different methods of sending a SRP - either pulses on the VBUS line, or by - * pulsing the Data + line via the internal pull-up resistor. - * - * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or - * \ref USB_OTG_STP_DATA. - */ - static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE; - static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) - { - OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ))); - } - - /** Accepts a HNP from a connected device, indicating that both devices should exchange - * device/host roles. - */ - static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE; - static inline void USB_OTG_Host_AcceptHNP(void) - { - OTGCON |= (1 << HNPREQ); - } - - /** Rejects a HNP from a connected device, indicating that both devices should remain in their - * current device/host roles. - */ - static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE; - static inline void USB_OTG_Host_RejectHNP(void) - { - OTGCON &= ~(1 << HNPREQ); - } - - /** Indicates if the connected device is currently sending a HNP request. - * - * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise. - */ - static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_OTG_Host_IsHNPReceived(void) - { - return ((OTGCON & (1 << HNPREQ)) ? true : false); - } - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB OTG definitions for the AVR8 microcontrollers. + * \copydetails Group_OTG_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_OTG + * \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8) + * \brief USB OTG definitions for the AVR8 microcontrollers. + * + * Architecture specific USB OTG definitions for the Atmel 8-bit AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBOTG_AVR8_H__ +#define __USBOTG_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices. + * + * \see \ref USB_OTG_Device_InitiateSRP(). + */ + #define USB_OTG_SRP_VBUS (1 << SRPSEL) + + /** Mask for the Data + pulsing method of SRP, supported by some OTG devices. + * + * \see \ref USB_OTG_Device_InitiateSRP(). + */ + #define USB_OTG_STP_DATA 0 + + /* Inline Functions: */ + /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device + * that the device wishes to change device/host roles. + */ + static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Device_RequestHNP(void) + { + OTGCON |= (1 << HNPREQ); + } + + /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other + * connected device. + */ + static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Device_CancelHNPRequest(void) + { + OTGCON &= ~(1 << HNPREQ); + } + + /** Determines if the device is currently sending a HNP to an attached host. + * + * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise + */ + static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_OTG_Device_IsSendingHNP(void) + { + return ((OTGCON & (1 << HNPREQ)) ? true : false); + } + + /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB + * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in + * host mode indicates that VBUS should be applied and a session started. + * + * There are two different methods of sending a SRP - either pulses on the VBUS line, or by + * pulsing the Data + line via the internal pull-up resistor. + * + * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or + * \ref USB_OTG_STP_DATA. + */ + static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) + { + OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ))); + } + + /** Accepts a HNP from a connected device, indicating that both devices should exchange + * device/host roles. + */ + static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Host_AcceptHNP(void) + { + OTGCON |= (1 << HNPREQ); + } + + /** Rejects a HNP from a connected device, indicating that both devices should remain in their + * current device/host roles. + */ + static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Host_RejectHNP(void) + { + OTGCON &= ~(1 << HNPREQ); + } + + /** Indicates if the connected device is currently sending a HNP request. + * + * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise. + */ + static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_OTG_Host_IsHNPReceived(void) + { + return ((OTGCON & (1 << HNPREQ)) ? true : false); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c index 2d8e0f7..afc36d6 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c @@ -1,216 +1,216 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBMode.h" - -#if defined(USB_CAN_BE_HOST) - -#include "PipeStream_AVR8.h" - -uint8_t Pipe_Discard_Stream(uint16_t Length, - uint16_t* const BytesProcessed) -{ - uint8_t ErrorCode; - uint16_t BytesInTransfer = 0; - - Pipe_SetPipeToken(PIPE_TOKEN_IN); - - if ((ErrorCode = Pipe_WaitUntilReady())) - return ErrorCode; - - if (BytesProcessed != NULL) - Length -= *BytesProcessed; - - while (Length) - { - if (!(Pipe_IsReadWriteAllowed())) - { - Pipe_ClearIN(); - - if (BytesProcessed != NULL) - { - *BytesProcessed += BytesInTransfer; - return PIPE_RWSTREAM_IncompleteTransfer; - } - - if ((ErrorCode = Pipe_WaitUntilReady())) - return ErrorCode; - } - else - { - Pipe_Discard_8(); - - Length--; - BytesInTransfer++; - } - } - - return PIPE_RWSTREAM_NoError; -} - -uint8_t Pipe_Null_Stream(uint16_t Length, - uint16_t* const BytesProcessed) -{ - uint8_t ErrorCode; - uint16_t BytesInTransfer = 0; - - Pipe_SetPipeToken(PIPE_TOKEN_OUT); - - if ((ErrorCode = Pipe_WaitUntilReady())) - return ErrorCode; - - if (BytesProcessed != NULL) - Length -= *BytesProcessed; - - while (Length) - { - if (!(Pipe_IsReadWriteAllowed())) - { - Pipe_ClearOUT(); - - if (BytesProcessed != NULL) - { - *BytesProcessed += BytesInTransfer; - return PIPE_RWSTREAM_IncompleteTransfer; - } - - USB_USBTask(); - - if ((ErrorCode = Pipe_WaitUntilReady())) - return ErrorCode; - } - else - { - Pipe_Write_8(0); - - Length--; - BytesInTransfer++; - } - } - - return PIPE_RWSTREAM_NoError; -} - -/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, - * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ - -#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_TOKEN PIPE_TOKEN_IN -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_TOKEN PIPE_TOKEN_IN -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_LE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr)) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_BE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr)) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr)) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE -#define TEMPLATE_BUFFER_TYPE const void* -#define TEMPLATE_TOKEN PIPE_TOKEN_OUT -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr)) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_TOKEN PIPE_TOKEN_IN -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) 0 -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8()) -#include "Template/Template_Pipe_RW.c" - -#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE -#define TEMPLATE_BUFFER_TYPE void* -#define TEMPLATE_TOKEN PIPE_TOKEN_IN -#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() -#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) -#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount -#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8()) -#include "Template/Template_Pipe_RW.c" - -#endif +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "PipeStream_AVR8.h" + +uint8_t Pipe_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + Pipe_SetPipeToken(PIPE_TOKEN_IN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +uint8_t Pipe_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + Pipe_SetPipeToken(PIPE_TOKEN_OUT); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + USB_USBTask(); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8()) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8()) +#include "Template/Template_Pipe_RW.c" + +#endif diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h index e9da422..b15b4c7 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h @@ -1,442 +1,442 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Pipe data stream transmission and reception management for the AVR8 microcontrollers - * \copydetails Group_PipeStreamRW_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_PipeStreamRW - * \defgroup Group_PipeStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8) - * \brief Pipe data stream transmission and reception management for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to data reading and writing of data streams from - * and to pipes. - * - * @{ - */ - -#ifndef __PIPE_STREAM_AVR8_H__ -#define __PIPE_STREAM_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../USBMode.h" - #include "../USBTask.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Function Prototypes: */ - /** \name Stream functions for null data */ - //@{ - - /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host - * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the - * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or - * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer - * will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data - * to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with - * the total number of bytes processed in the stream, and the function will exit with an error code of - * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to - * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed - * value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t ErrorCode; - * - * if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without - * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). - * - * \param[in] Length Number of bytes to discard via the currently selected pipe. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be processed at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Discard_Stream(uint16_t Length, - uint16_t* const BytesProcessed); - - /** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device - * as needed. The last packet is not automatically sent once the remaining bytes has been written; the - * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or - * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer - * will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data - * to process (and after the current packet transmission has been initiated) the BytesProcessed location will be - * updated with the total number of bytes processed in the stream, and the function will exit with an error code of - * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to - * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed - * value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t ErrorCode; - * - * if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without - * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). - * - * \param[in] Length Number of zero bytes to write via the currently selected pipe. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be processed at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Null_Stream(uint16_t Length, - uint16_t* const BytesProcessed); - - //@} - - /** \name Stream functions for RAM source/destination data */ - //@{ - - /** Writes the given number of bytes to the pipe from the given buffer in little endian, - * sending full packets to the device as needed. The last packet filled is not automatically sent; - * the user is responsible for manually sending the last written packet to the host via the - * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is - * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, - * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid - * storage location, the transfer will instead be performed as a series of chunks. Each time - * the pipe bank becomes full while there is still data to process (and after the current - * packet transmission has been initiated) the BytesProcessed location will be updated with the - * total number of bytes processed in the stream, and the function will exit with an error code of - * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed - * in the user code - to continue the transfer, call the function again with identical parameters - * and it will resume until the BytesProcessed value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * - * if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), - * NULL)) != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), - * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without - * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Write_Stream_LE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Writes the given number of bytes to the pipe from the given buffer in big endian, - * sending full packets to the device as needed. The last packet filled is not automatically sent; - * the user is responsible for manually sending the last written packet to the host via the - * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is - * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. - * - * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without - * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Write_Stream_BE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads the given number of bytes from the pipe into the given buffer in little endian, - * sending full packets to the device as needed. The last packet filled is not automatically sent; - * the user is responsible for manually sending the last written packet to the host via the - * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is - * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. - * - * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, - * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid - * storage location, the transfer will instead be performed as a series of chunks. Each time - * the pipe bank becomes empty while there is still data to process (and after the current - * packet has been acknowledged) the BytesProcessed location will be updated with the total number - * of bytes processed in the stream, and the function will exit with an error code of - * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed - * in the user code - to continue the transfer, call the function again with identical parameters - * and it will resume until the BytesProcessed value reaches the total transfer length. - * - * Single Stream Transfer Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * - * if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), - * NULL)) != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * Partial Stream Transfers Example: - * \code - * uint8_t DataStream[512]; - * uint8_t ErrorCode; - * uint16_t BytesProcessed; - * - * BytesProcessed = 0; - * while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), - * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) - * { - * // Stream not yet complete - do other actions here, abort if required - * } - * - * if (ErrorCode != PIPE_RWSTREAM_NoError) - * { - * // Stream failed to complete - check ErrorCode here - * } - * \endcode - * - * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without - * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). - * - * \param[out] Buffer Pointer to the source data buffer to write to. - * \param[in] Length Number of bytes to read for the currently selected pipe to read from. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Read_Stream_LE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** Reads the given number of bytes from the pipe into the given buffer in big endian, - * sending full packets to the device as needed. The last packet filled is not automatically sent; - * the user is responsible for manually sending the last written packet to the host via the - * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is - * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. - * - * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without - * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). - * - * \param[out] Buffer Pointer to the source data buffer to write to. - * \param[in] Length Number of bytes to read for the currently selected pipe to read from. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Read_Stream_BE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - //@} - - /** \name Stream functions for EEPROM source/destination data */ - //@{ - - /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE(). - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Write_EStream_LE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE(). - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Write_EStream_BE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE(). - * - * \param[out] Buffer Pointer to the source data buffer to write to. - * \param[in] Length Number of bytes to read for the currently selected pipe to read from. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Read_EStream_LE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE(). - * - * \param[out] Buffer Pointer to the source data buffer to write to. - * \param[in] Length Number of bytes to read for the currently selected pipe to read from. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be read at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Read_EStream_BE(void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - //@} - - /** \name Stream functions for PROGMEM source/destination data */ - //@{ - - /** FLASH buffer source version of \ref Pipe_Write_Stream_LE(). - * - * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Write_PStream_LE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - - /** FLASH buffer source version of \ref Pipe_Write_Stream_BE(). - * - * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. - * - * \param[in] Buffer Pointer to the source data buffer to read from. - * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. - * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should - * updated, \c NULL if the entire stream should be written at once. - * - * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. - */ - uint8_t Pipe_Write_PStream_BE(const void* const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); - //@} - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Pipe data stream transmission and reception management for the AVR8 microcontrollers + * \copydetails Group_PipeStreamRW_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeStreamRW + * \defgroup Group_PipeStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8) + * \brief Pipe data stream transmission and reception management for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to pipes. + * + * @{ + */ + +#ifndef __PIPE_STREAM_AVR8_H__ +#define __PIPE_STREAM_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host + * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the + * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or + * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer + * will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data + * to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with + * the total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to + * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed + * value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Length Number of bytes to discard via the currently selected pipe. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be processed at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device + * as needed. The last packet is not automatically sent once the remaining bytes has been written; the + * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or + * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer + * will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data + * to process (and after the current packet transmission has been initiated) the BytesProcessed location will be + * updated with the total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to + * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed + * value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Length Number of zero bytes to write via the currently selected pipe. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be processed at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the pipe from the given buffer in little endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the pipe bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the pipe from the given buffer in big endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the pipe into the given buffer in little endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the pipe bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the pipe into the given buffer in big endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for EEPROM source/destination data */ + //@{ + + /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_EStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_EStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_EStream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_EStream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for PROGMEM source/destination data */ + //@{ + + /** FLASH buffer source version of \ref Pipe_Write_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_PStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Pipe_Write_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_PStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c index c287002..a6e629c 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c @@ -1,181 +1,181 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBMode.h" - -#if defined(USB_CAN_BE_HOST) - -#include "../Pipe.h" - -uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; - -bool Pipe_ConfigurePipe(const uint8_t Number, - const uint8_t Type, - const uint8_t Token, - const uint8_t EndpointNumber, - const uint16_t Size, - const uint8_t Banks) -{ -#if defined(ORDERED_EP_CONFIG) - Pipe_SelectPipe(Number); - Pipe_EnablePipe(); - - UPCFG1X = 0; - - UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0)); - UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size)); - - Pipe_SetInfiniteINRequests(); - - return Pipe_IsConfigured(); -#else - for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++) - { - uint8_t UPCFG0XTemp; - uint8_t UPCFG1XTemp; - uint8_t UPCFG2XTemp; - uint8_t UPIENXTemp; - - Pipe_SelectPipe(PNum); - - if (PNum == Number) - { - UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0)); - UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size)); - UPCFG2XTemp = 0; - UPIENXTemp = 0; - } - else - { - UPCFG0XTemp = UPCFG0X; - UPCFG1XTemp = UPCFG1X; - UPCFG2XTemp = UPCFG2X; - UPIENXTemp = UPIENX; - } - - if (!(UPCFG1XTemp & (1 << ALLOC))) - continue; - - Pipe_DisablePipe(); - UPCFG1X &= ~(1 << ALLOC); - - Pipe_EnablePipe(); - UPCFG0X = UPCFG0XTemp; - UPCFG1X = UPCFG1XTemp; - UPCFG2X = UPCFG2XTemp; - UPIENX = UPIENXTemp; - - Pipe_SetInfiniteINRequests(); - - if (!(Pipe_IsConfigured())) - return false; - } - - Pipe_SelectPipe(Number); - return true; -#endif -} - -void Pipe_ClearPipes(void) -{ - UPINT = 0; - - for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) - { - Pipe_SelectPipe(PNum); - UPIENX = 0; - UPINTX = 0; - UPCFG1X = 0; - Pipe_DisablePipe(); - } -} - -bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) -{ - uint8_t PrevPipeNumber = Pipe_GetCurrentPipe(); - - for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) - { - Pipe_SelectPipe(PNum); - - if (!(Pipe_IsConfigured())) - continue; - - if (Pipe_GetBoundEndpointAddress() == EndpointAddress) - return true; - } - - Pipe_SelectPipe(PrevPipeNumber); - return false; -} - -uint8_t Pipe_WaitUntilReady(void) -{ - #if (USB_STREAM_TIMEOUT_MS < 0xFF) - uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; - #else - uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; - #endif - - uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber(); - - for (;;) - { - if (Pipe_GetPipeToken() == PIPE_TOKEN_IN) - { - if (Pipe_IsINReceived()) - return PIPE_READYWAIT_NoError; - } - else - { - if (Pipe_IsOUTReady()) - return PIPE_READYWAIT_NoError; - } - - if (Pipe_IsStalled()) - return PIPE_READYWAIT_PipeStalled; - else if (USB_HostState == HOST_STATE_Unattached) - return PIPE_READYWAIT_DeviceDisconnected; - - uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); - - if (CurrentFrameNumber != PreviousFrameNumber) - { - PreviousFrameNumber = CurrentFrameNumber; - - if (!(TimeoutMSRem--)) - return PIPE_READYWAIT_Timeout; - } - } -} - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "../Pipe.h" + +uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + +bool Pipe_ConfigurePipe(const uint8_t Number, + const uint8_t Type, + const uint8_t Token, + const uint8_t EndpointNumber, + const uint16_t Size, + const uint8_t Banks) +{ +#if defined(ORDERED_EP_CONFIG) + Pipe_SelectPipe(Number); + Pipe_EnablePipe(); + + UPCFG1X = 0; + + UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0)); + UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size)); + + Pipe_SetInfiniteINRequests(); + + return Pipe_IsConfigured(); +#else + for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++) + { + uint8_t UPCFG0XTemp; + uint8_t UPCFG1XTemp; + uint8_t UPCFG2XTemp; + uint8_t UPIENXTemp; + + Pipe_SelectPipe(PNum); + + if (PNum == Number) + { + UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0)); + UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size)); + UPCFG2XTemp = 0; + UPIENXTemp = 0; + } + else + { + UPCFG0XTemp = UPCFG0X; + UPCFG1XTemp = UPCFG1X; + UPCFG2XTemp = UPCFG2X; + UPIENXTemp = UPIENX; + } + + if (!(UPCFG1XTemp & (1 << ALLOC))) + continue; + + Pipe_DisablePipe(); + UPCFG1X &= ~(1 << ALLOC); + + Pipe_EnablePipe(); + UPCFG0X = UPCFG0XTemp; + UPCFG1X = UPCFG1XTemp; + UPCFG2X = UPCFG2XTemp; + UPIENX = UPIENXTemp; + + Pipe_SetInfiniteINRequests(); + + if (!(Pipe_IsConfigured())) + return false; + } + + Pipe_SelectPipe(Number); + return true; +#endif +} + +void Pipe_ClearPipes(void) +{ + UPINT = 0; + + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + UPIENX = 0; + UPINTX = 0; + UPCFG1X = 0; + Pipe_DisablePipe(); + } +} + +bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) +{ + uint8_t PrevPipeNumber = Pipe_GetCurrentPipe(); + + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + + if (!(Pipe_IsConfigured())) + continue; + + if (Pipe_GetBoundEndpointAddress() == EndpointAddress) + return true; + } + + Pipe_SelectPipe(PrevPipeNumber); + return false; +} + +uint8_t Pipe_WaitUntilReady(void) +{ + #if (USB_STREAM_TIMEOUT_MS < 0xFF) + uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #else + uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #endif + + uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber(); + + for (;;) + { + if (Pipe_GetPipeToken() == PIPE_TOKEN_IN) + { + if (Pipe_IsINReceived()) + return PIPE_READYWAIT_NoError; + } + else + { + if (Pipe_IsOUTReady()) + return PIPE_READYWAIT_NoError; + } + + if (Pipe_IsStalled()) + return PIPE_READYWAIT_PipeStalled; + else if (USB_HostState == HOST_STATE_Unattached) + return PIPE_READYWAIT_DeviceDisconnected; + + uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return PIPE_READYWAIT_Timeout; + } + } +} + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h index a1802de..5d33da8 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h @@ -1,923 +1,923 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Pipe definitions for the AVR8 microcontrollers. - * \copydetails Group_PipeManagement_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_PipeRW - * \defgroup Group_PipeRW_AVR8 Pipe Data Reading and Writing (AVR8) - * \brief Pipe data read/write definitions for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. - */ - -/** \ingroup Group_PipePrimitiveRW - * \defgroup Group_PipePrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8) - * \brief Pipe primitive data read/write definitions for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to data reading and writing of primitive data types - * from and to pipes. - */ - -/** \ingroup Group_PipePacketManagement - * \defgroup Group_PipePacketManagement_AVR8 Pipe Packet Management (AVR8) - * \brief Pipe packet management definitions for the Atmel AVR8 architecture. - * - * Functions, macros, variables, enums and types related to packet management of pipes. - */ - -/** \ingroup Group_PipeControlReq - * \defgroup Group_PipeControlReq_AVR8 Pipe Control Request Management (AVR8) - * \brief Pipe control request management definitions for the Atmel AVR8 architecture. - * - * Module for host mode request processing. This module allows for the transmission of standard, class and - * vendor control requests to the default control endpoint of an attached device while in host mode. - * - * \see Chapter 9 of the USB 2.0 specification. - */ - -/** \ingroup Group_PipeManagement - * \defgroup Group_PipeManagement_AVR8 Pipe Management (AVR8) - * \brief Pipe management definitions for the Atmel AVR8 architecture. - * - * This module contains functions, macros and enums related to pipe management when in USB Host mode. This - * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions - * for various data types. - * - * @{ - */ - -#ifndef __PIPE_AVR8_H__ -#define __PIPE_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../USBTask.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** \name Pipe Error Flag Masks */ - //@{ - /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */ - #define PIPE_ERRORFLAG_OVERFLOW (1 << 6) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */ - #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */ - #define PIPE_ERRORFLAG_CRC16 (1 << 4) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */ - #define PIPE_ERRORFLAG_TIMEOUT (1 << 3) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */ - #define PIPE_ERRORFLAG_PID (1 << 2) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */ - #define PIPE_ERRORFLAG_DATAPID (1 << 1) - - /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */ - #define PIPE_ERRORFLAG_DATATGL (1 << 0) - //@} - - /** \name Pipe Token Masks */ - //@{ - /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes), - * which will trigger a control request on the attached device when data is written to the pipe. - */ - #define PIPE_TOKEN_SETUP (0 << PTOKEN0) - - /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes), - * indicating that the pipe data will flow from device to host. - */ - #define PIPE_TOKEN_IN (1 << PTOKEN0) - - /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes), - * indicating that the pipe data will flow from host to device. - */ - #define PIPE_TOKEN_OUT (2 << PTOKEN0) - //@} - - /** \name Pipe Bank Mode Masks */ - //@{ - /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe - * should have one single bank, which requires less USB FIFO memory but results in slower transfers as - * only one USB device (the AVR or the attached device) can access the pipe's bank at the one time. - */ - #define PIPE_BANK_SINGLE (0 << EPBK0) - - /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe - * should have two banks, which requires more USB FIFO memory but results in faster transfers as one - * USB device (the AVR or the attached device) can access one bank while the other accesses the second - * bank. - */ - #define PIPE_BANK_DOUBLE (1 << EPBK0) - //@} - - /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value - * in the device descriptor of the attached device. - */ - #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64 - - /** Total number of pipes (including the default control pipe at address 0) which may be used in - * the device. Different USB AVR models support different amounts of pipes, this value reflects - * the maximum number of pipes for the currently selected AVR model. - */ - #define PIPE_TOTAL_PIPES 7 - - /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR - * model supports the largest bank size possible on the device; different pipe numbers support - * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the - * currently selected USB AVR model. - */ - #define PIPE_MAX_SIZE 256 - - /* Enums: */ - /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function. - * - * \ingroup Group_PipeRW_AVR8 - */ - enum Pipe_WaitUntilReady_ErrorCodes_t - { - PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */ - PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */ - PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */ - PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet - * within the software timeout period set by the - * \ref USB_STREAM_TIMEOUT_MS macro. - */ - }; - - /* Inline Functions: */ - /** Indicates the number of bytes currently stored in the current pipes's selected bank. - * - * \note The return width of this function may differ, depending on the maximum pipe bank size - * of the selected AVR model. - * - * \ingroup Group_PipeRW_AVR8 - * - * \return Total number of bytes in the currently selected pipe's FIFO buffer. - */ - static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Pipe_BytesInPipe(void) - { - return UPBCX; - } - - /** Returns the pipe address of the currently selected pipe. This is typically used to save the - * currently selected pipe number so that it can be restored after another pipe has been manipulated. - * - * \return Index of the currently selected pipe. - */ - static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_GetCurrentPipe(void) - { - return (UPNUM & PIPE_PIPENUM_MASK); - } - - /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be - * indicated will operate on the currently selected pipe. - * - * \param[in] PipeNumber Index of the pipe to select. - */ - static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE; - static inline void Pipe_SelectPipe(const uint8_t PipeNumber) - { - UPNUM = PipeNumber; - } - - /** Resets the desired pipe, including the pipe banks and flags. - * - * \param[in] PipeNumber Index of the pipe to reset. - */ - static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE; - static inline void Pipe_ResetPipe(const uint8_t PipeNumber) - { - UPRST = (1 << PipeNumber); - UPRST = 0; - } - - /** Enables the currently selected pipe so that data can be sent and received through it to and from - * an attached device. - * - * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe(). - */ - static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_EnablePipe(void) - { - UPCONX |= (1 << PEN); - } - - /** Disables the currently selected pipe so that data cannot be sent and received through it to and - * from an attached device. - */ - static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_DisablePipe(void) - { - UPCONX &= ~(1 << PEN); - } - - /** Determines if the currently selected pipe is enabled, but not necessarily configured. - * - * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise. - */ - static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsEnabled(void) - { - return ((UPCONX & (1 << PEN)) ? true : false); - } - - /** Gets the current pipe token, indicating the pipe's data direction and type. - * - * \return The current pipe token, as a \c PIPE_TOKEN_* mask. - */ - static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_GetPipeToken(void) - { - return (UPCFG0X & (0x03 << PTOKEN0)); - } - - /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_* - * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during - * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices - * which have two endpoints of opposite direction sharing the same endpoint address within the device. - * - * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask. - */ - static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE; - static inline void Pipe_SetPipeToken(const uint8_t Token) - { - UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token); - } - - /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */ - static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_SetInfiniteINRequests(void) - { - UPCONX |= (1 << INMODE); - } - - /** Configures the currently selected pipe to only allow the specified number of IN requests to be - * accepted by the pipe before it is automatically frozen. - * - * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing. - */ - static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE; - static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) - { - UPCONX &= ~(1 << INMODE); - UPINRQX = TotalINRequests; - } - - /** Determines if the currently selected pipe is configured. - * - * \return Boolean \c true if the selected pipe is configured, \c false otherwise. - */ - static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsConfigured(void) - { - return ((UPSTAX & (1 << CFGOK)) ? true : false); - } - - /** Retrieves the endpoint address of the endpoint within the attached device that the currently selected - * pipe is bound to. - * - * \return Endpoint address the currently selected pipe is bound to. - */ - static inline uint8_t Pipe_GetBoundEndpointAddress(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_GetBoundEndpointAddress(void) - { - return (((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK) | - ((Pipe_GetPipeToken() == PIPE_TOKEN_IN) ? PIPE_EPDIR_MASK : 0)); - } - - /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds. - * - * \param[in] Milliseconds Number of milliseconds between each pipe poll. - */ - static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE; - static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) - { - UPCFG2X = Milliseconds; - } - - /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should - * be serviced. - * - * \return Mask whose bits indicate which pipes have interrupted. - */ - static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_GetPipeInterrupts(void) - { - return UPINT; - } - - /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type - * pipes). - * - * \param[in] PipeNumber Index of the pipe whose interrupt flag should be tested. - * - * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise. - */ - static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) - { - return ((UPINT & (1 << PipeNumber)) ? true : false); - } - - /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */ - static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_Unfreeze(void) - { - UPCONX &= ~(1 << PFREEZE); - } - - /** Freezes the selected pipe, preventing it from communicating with an attached device. */ - static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_Freeze(void) - { - UPCONX |= (1 << PFREEZE); - } - - /** Determines if the currently selected pipe is frozen, and not able to accept data. - * - * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise. - */ - static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsFrozen(void) - { - return ((UPCONX & (1 << PFREEZE)) ? true : false); - } - - /** Clears the error flags for the currently selected pipe. */ - static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_ClearError(void) - { - UPERRX = 0; - UPINTX &= ~(1 << PERRI); - } - - /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that - * some sort of hardware error has occurred on the pipe. - * - * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag. - * - * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise. - */ - static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsError(void) - { - return ((UPINTX & (1 << PERRI)) ? true : false); - } - - /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This - * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred. - * - * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe. - */ - static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_GetErrorFlags(void) - { - return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | - PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID | - PIPE_ERRORFLAG_DATATGL)) | - (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW))); - } - - /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for - * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the - * \ref Pipe_ClearIN() command. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Total number of busy banks in the selected pipe. - */ - static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_GetBusyBanks(void) - { - return (UPSTAX & (0x03 << NBUSYBK0)); - } - - /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe - * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT - * direction). This function will return false if an error has occurred in the pipe, or if the pipe - * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT - * direction and the pipe bank is full. - * - * \note This function is not valid on CONTROL type pipes. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Boolean \c true if the currently selected pipe may be read from or written to, depending - * on its direction. - */ - static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsReadWriteAllowed(void) - { - return ((UPINTX & (1 << RWAL)) ? true : false); - } - - /** Determines if a packet has been received on the currently selected IN pipe from the attached device. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise. - */ - static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsINReceived(void) - { - return ((UPINTX & (1 << RXINI)) ? true : false); - } - - /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise. - */ - static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsOUTReady(void) - { - return ((UPINTX & (1 << TXOUTI)) ? true : false); - } - - /** Determines if no SETUP request is currently being sent to the attached device on the selected - * CONTROL type pipe. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise. - */ - static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsSETUPSent(void) - { - return ((UPINTX & (1 << TXSTPI)) ? true : false); - } - - /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet. - * - * \ingroup Group_PipePacketManagement_AVR8 - */ - static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_ClearSETUP(void) - { - UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON)); - } - - /** Acknowledges the reception of a setup IN request from the attached device on the currently selected - * pipe, freeing the bank ready for the next packet. - * - * \ingroup Group_PipePacketManagement_AVR8 - */ - static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_ClearIN(void) - { - UPINTX &= ~((1 << RXINI) | (1 << FIFOCON)); - } - - /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing - * the bank ready for the next packet. - * - * \ingroup Group_PipePacketManagement_AVR8 - */ - static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_ClearOUT(void) - { - UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON)); - } - - /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on - * the currently selected pipe. This occurs when the host sends a packet to the device, but the device - * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been - * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet - * can be re-sent. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise. - */ - static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsNAKReceived(void) - { - return ((UPINTX & (1 << NAKEDI)) ? true : false); - } - - /** Clears the NAK condition on the currently selected pipe. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \see \ref Pipe_IsNAKReceived() for more details. - */ - static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_ClearNAKReceived(void) - { - UPINTX &= ~(1 << NAKEDI); - } - - /** Determines if the currently selected pipe has had the STALL condition set by the attached device. - * - * \ingroup Group_PipePacketManagement_AVR8 - * - * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise. - */ - static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool Pipe_IsStalled(void) - { - return ((UPINTX & (1 << RXSTALLI)) ? true : false); - } - - /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the - * STALL condition itself (this must be done via a ClearFeature control request to the device). - * - * \ingroup Group_PipePacketManagement_AVR8 - */ - static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_ClearStall(void) - { - UPINTX &= ~(1 << RXSTALLI); - } - - /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \return Next byte in the currently selected pipe's FIFO buffer. - */ - static inline uint8_t Pipe_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_Read_8(void) - { - return UPDATX; - } - - /** Writes one byte to the currently selected pipe's bank, for IN direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \param[in] Data Data to write into the the currently selected pipe's FIFO buffer. - */ - static inline void Pipe_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; - static inline void Pipe_Write_8(const uint8_t Data) - { - UPDATX = Data; - } - - /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - */ - static inline void Pipe_Discard_8(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_Discard_8(void) - { - uint8_t Dummy; - - Dummy = UPDATX; - - (void)Dummy; - } - - /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \return Next two bytes in the currently selected pipe's FIFO buffer. - */ - static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Pipe_Read_16_LE(void) - { - union - { - uint16_t Value; - uint8_t Bytes[2]; - } Data; - - Data.Bytes[0] = UPDATX; - Data.Bytes[1] = UPDATX; - - return Data.Value; - } - - /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \return Next two bytes in the currently selected pipe's FIFO buffer. - */ - static inline uint16_t Pipe_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint16_t Pipe_Read_16_BE(void) - { - union - { - uint16_t Value; - uint8_t Bytes[2]; - } Data; - - Data.Bytes[1] = UPDATX; - Data.Bytes[0] = UPDATX; - - return Data.Value; - } - - /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. - */ - static inline void Pipe_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; - static inline void Pipe_Write_16_LE(const uint16_t Data) - { - UPDATX = (Data & 0xFF); - UPDATX = (Data >> 8); - } - - /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. - */ - static inline void Pipe_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; - static inline void Pipe_Write_16_BE(const uint16_t Data) - { - UPDATX = (Data >> 8); - UPDATX = (Data & 0xFF); - } - - /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - */ - static inline void Pipe_Discard_16(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_Discard_16(void) - { - uint8_t Dummy; - - Dummy = UPDATX; - Dummy = UPDATX; - - (void)Dummy; - } - - /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \return Next four bytes in the currently selected pipe's FIFO buffer. - */ - static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint32_t Pipe_Read_32_LE(void) - { - union - { - uint32_t Value; - uint8_t Bytes[4]; - } Data; - - Data.Bytes[0] = UPDATX; - Data.Bytes[1] = UPDATX; - Data.Bytes[2] = UPDATX; - Data.Bytes[3] = UPDATX; - - return Data.Value; - } - - /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \return Next four bytes in the currently selected pipe's FIFO buffer. - */ - static inline uint32_t Pipe_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint32_t Pipe_Read_32_BE(void) - { - union - { - uint32_t DWord; - uint8_t Bytes[4]; - } Data; - - Data.Bytes[3] = UPDATX; - Data.Bytes[2] = UPDATX; - Data.Bytes[1] = UPDATX; - Data.Bytes[0] = UPDATX; - - return Data.DWord; - } - - /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. - */ - static inline void Pipe_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; - static inline void Pipe_Write_32_LE(const uint32_t Data) - { - UPDATX = (Data & 0xFF); - UPDATX = (Data >> 8); - UPDATX = (Data >> 16); - UPDATX = (Data >> 24); - } - - /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN - * direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - * - * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. - */ - static inline void Pipe_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; - static inline void Pipe_Write_32_BE(const uint32_t Data) - { - UPDATX = (Data >> 24); - UPDATX = (Data >> 16); - UPDATX = (Data >> 8); - UPDATX = (Data & 0xFF); - } - - /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. - * - * \ingroup Group_PipePrimitiveRW_AVR8 - */ - static inline void Pipe_Discard_32(void) ATTR_ALWAYS_INLINE; - static inline void Pipe_Discard_32(void) - { - uint8_t Dummy; - - Dummy = UPDATX; - Dummy = UPDATX; - Dummy = UPDATX; - Dummy = UPDATX; - - (void)Dummy; - } - - /* External Variables: */ - /** Global indicating the maximum packet size of the default control pipe located at address - * 0 in the device. This value is set to the value indicated in the attached device's device - * descriptor once the USB interface is initialized into host mode and a device is attached - * to the USB bus. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - */ - extern uint8_t USB_Host_ControlPipeSize; - - /* Function Prototypes: */ - /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the - * attached device, bank size and banking mode. - * - * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze() - * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or - * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite - * numbers of IN requests without automatic freezing - this can be overridden by a call to - * \ref Pipe_SetFiniteINRequests(). - * - * \param[in] Number Pipe number to configure. This must be more than 0 and less than \ref PIPE_TOTAL_PIPES. - * - * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low - * Speed USB devices - refer to the USB 2.0 specification. - * - * \param[in] Token Pipe data token, either \ref PIPE_TOKEN_SETUP, \ref PIPE_TOKEN_OUT or \ref PIPE_TOKEN_IN. - * All pipes (except Control type) are unidirectional - data may only be read from or - * written to the pipe bank based on its direction, not both. - * - * \param[in] EndpointNumber Endpoint index within the attached device that the pipe should interface to. - * - * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to - * the USB device, or after they have been received from the USB device (depending on - * the pipe's data direction). The bank size must indicate the maximum packet size that - * the pipe can handle. - * - * \param[in] Banks Number of banks to use for the pipe being configured, a \c PIPE_BANK_* mask. More banks - * uses more USB DPRAM, but offers better performance. Isochronous type pipes must - * have at least two banks. - * - * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes must be configured in ascending order, - * or bank corruption will occur. - * \n\n - * - * \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's - * index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe. - * \n\n - * - * \note The default control pipe should not be manually configured by the user application, as it is - * automatically configured by the library internally. - * \n\n - * - * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which - * failed to reconfigure correctly will be selected. - * - * \return Boolean \c true if the configuration succeeded, \c false otherwise. - */ - bool Pipe_ConfigurePipe(const uint8_t Number, - const uint8_t Type, - const uint8_t Token, - const uint8_t EndpointNumber, - const uint16_t Size, - const uint8_t Banks); - - /** Spin-loops until the currently selected non-control pipe is ready for the next packet of data to be read - * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect). - * - * \ingroup Group_PipeRW_AVR8 - * - * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. - */ - uint8_t Pipe_WaitUntilReady(void); - - /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given - * endpoint is found, it is automatically selected. - * - * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check. - * - * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found, - * \c false otherwise. - */ - bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT; - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Macros: */ - #if !defined(ENDPOINT_CONTROLEP) - #define ENDPOINT_CONTROLEP 0 - #endif - - /* Inline Functions: */ - static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE; - static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) - { - uint8_t MaskVal = 0; - uint16_t CheckBytes = 8; - - while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE)) - { - MaskVal++; - CheckBytes <<= 1; - } - - return (MaskVal << EPSIZE0); - } - - /* Function Prototypes: */ - void Pipe_ClearPipes(void); - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Pipe definitions for the AVR8 microcontrollers. + * \copydetails Group_PipeManagement_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipeRW_AVR8 Pipe Data Reading and Writing (AVR8) + * \brief Pipe data read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. + */ + +/** \ingroup Group_PipePrimitiveRW + * \defgroup Group_PipePrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8) + * \brief Pipe primitive data read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to pipes. + */ + +/** \ingroup Group_PipePacketManagement + * \defgroup Group_PipePacketManagement_AVR8 Pipe Packet Management (AVR8) + * \brief Pipe packet management definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to packet management of pipes. + */ + +/** \ingroup Group_PipeControlReq + * \defgroup Group_PipeControlReq_AVR8 Pipe Control Request Management (AVR8) + * \brief Pipe control request management definitions for the Atmel AVR8 architecture. + * + * Module for host mode request processing. This module allows for the transmission of standard, class and + * vendor control requests to the default control endpoint of an attached device while in host mode. + * + * \see Chapter 9 of the USB 2.0 specification. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeManagement_AVR8 Pipe Management (AVR8) + * \brief Pipe management definitions for the Atmel AVR8 architecture. + * + * This module contains functions, macros and enums related to pipe management when in USB Host mode. This + * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions + * for various data types. + * + * @{ + */ + +#ifndef __PIPE_AVR8_H__ +#define __PIPE_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Pipe Error Flag Masks */ + //@{ + /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_OVERFLOW (1 << 6) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_CRC16 (1 << 4) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */ + #define PIPE_ERRORFLAG_TIMEOUT (1 << 3) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */ + #define PIPE_ERRORFLAG_PID (1 << 2) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */ + #define PIPE_ERRORFLAG_DATAPID (1 << 1) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */ + #define PIPE_ERRORFLAG_DATATGL (1 << 0) + //@} + + /** \name Pipe Token Masks */ + //@{ + /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes), + * which will trigger a control request on the attached device when data is written to the pipe. + */ + #define PIPE_TOKEN_SETUP (0 << PTOKEN0) + + /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes), + * indicating that the pipe data will flow from device to host. + */ + #define PIPE_TOKEN_IN (1 << PTOKEN0) + + /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes), + * indicating that the pipe data will flow from host to device. + */ + #define PIPE_TOKEN_OUT (2 << PTOKEN0) + //@} + + /** \name Pipe Bank Mode Masks */ + //@{ + /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe + * should have one single bank, which requires less USB FIFO memory but results in slower transfers as + * only one USB device (the AVR or the attached device) can access the pipe's bank at the one time. + */ + #define PIPE_BANK_SINGLE (0 << EPBK0) + + /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe + * should have two banks, which requires more USB FIFO memory but results in faster transfers as one + * USB device (the AVR or the attached device) can access one bank while the other accesses the second + * bank. + */ + #define PIPE_BANK_DOUBLE (1 << EPBK0) + //@} + + /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value + * in the device descriptor of the attached device. + */ + #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64 + + /** Total number of pipes (including the default control pipe at address 0) which may be used in + * the device. Different USB AVR models support different amounts of pipes, this value reflects + * the maximum number of pipes for the currently selected AVR model. + */ + #define PIPE_TOTAL_PIPES 7 + + /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR + * model supports the largest bank size possible on the device; different pipe numbers support + * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the + * currently selected USB AVR model. + */ + #define PIPE_MAX_SIZE 256 + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function. + * + * \ingroup Group_PipeRW_AVR8 + */ + enum Pipe_WaitUntilReady_ErrorCodes_t + { + PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */ + PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */ + PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */ + PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + }; + + /* Inline Functions: */ + /** Indicates the number of bytes currently stored in the current pipes's selected bank. + * + * \note The return width of this function may differ, depending on the maximum pipe bank size + * of the selected AVR model. + * + * \ingroup Group_PipeRW_AVR8 + * + * \return Total number of bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_BytesInPipe(void) + { + return UPBCX; + } + + /** Returns the pipe address of the currently selected pipe. This is typically used to save the + * currently selected pipe number so that it can be restored after another pipe has been manipulated. + * + * \return Index of the currently selected pipe. + */ + static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetCurrentPipe(void) + { + return (UPNUM & PIPE_PIPENUM_MASK); + } + + /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be + * indicated will operate on the currently selected pipe. + * + * \param[in] PipeNumber Index of the pipe to select. + */ + static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE; + static inline void Pipe_SelectPipe(const uint8_t PipeNumber) + { + UPNUM = PipeNumber; + } + + /** Resets the desired pipe, including the pipe banks and flags. + * + * \param[in] PipeNumber Index of the pipe to reset. + */ + static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE; + static inline void Pipe_ResetPipe(const uint8_t PipeNumber) + { + UPRST = (1 << PipeNumber); + UPRST = 0; + } + + /** Enables the currently selected pipe so that data can be sent and received through it to and from + * an attached device. + * + * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe(). + */ + static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_EnablePipe(void) + { + UPCONX |= (1 << PEN); + } + + /** Disables the currently selected pipe so that data cannot be sent and received through it to and + * from an attached device. + */ + static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_DisablePipe(void) + { + UPCONX &= ~(1 << PEN); + } + + /** Determines if the currently selected pipe is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise. + */ + static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsEnabled(void) + { + return ((UPCONX & (1 << PEN)) ? true : false); + } + + /** Gets the current pipe token, indicating the pipe's data direction and type. + * + * \return The current pipe token, as a \c PIPE_TOKEN_* mask. + */ + static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeToken(void) + { + return (UPCFG0X & (0x03 << PTOKEN0)); + } + + /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_* + * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during + * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices + * which have two endpoints of opposite direction sharing the same endpoint address within the device. + * + * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask. + */ + static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetPipeToken(const uint8_t Token) + { + UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token); + } + + /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */ + static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetInfiniteINRequests(void) + { + UPCONX |= (1 << INMODE); + } + + /** Configures the currently selected pipe to only allow the specified number of IN requests to be + * accepted by the pipe before it is automatically frozen. + * + * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing. + */ + static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) + { + UPCONX &= ~(1 << INMODE); + UPINRQX = TotalINRequests; + } + + /** Determines if the currently selected pipe is configured. + * + * \return Boolean \c true if the selected pipe is configured, \c false otherwise. + */ + static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsConfigured(void) + { + return ((UPSTAX & (1 << CFGOK)) ? true : false); + } + + /** Retrieves the endpoint address of the endpoint within the attached device that the currently selected + * pipe is bound to. + * + * \return Endpoint address the currently selected pipe is bound to. + */ + static inline uint8_t Pipe_GetBoundEndpointAddress(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetBoundEndpointAddress(void) + { + return (((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK) | + ((Pipe_GetPipeToken() == PIPE_TOKEN_IN) ? PIPE_EPDIR_MASK : 0)); + } + + /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds. + * + * \param[in] Milliseconds Number of milliseconds between each pipe poll. + */ + static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) + { + UPCFG2X = Milliseconds; + } + + /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should + * be serviced. + * + * \return Mask whose bits indicate which pipes have interrupted. + */ + static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeInterrupts(void) + { + return UPINT; + } + + /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type + * pipes). + * + * \param[in] PipeNumber Index of the pipe whose interrupt flag should be tested. + * + * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise. + */ + static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) + { + return ((UPINT & (1 << PipeNumber)) ? true : false); + } + + /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */ + static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Unfreeze(void) + { + UPCONX &= ~(1 << PFREEZE); + } + + /** Freezes the selected pipe, preventing it from communicating with an attached device. */ + static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Freeze(void) + { + UPCONX |= (1 << PFREEZE); + } + + /** Determines if the currently selected pipe is frozen, and not able to accept data. + * + * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise. + */ + static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsFrozen(void) + { + return ((UPCONX & (1 << PFREEZE)) ? true : false); + } + + /** Clears the error flags for the currently selected pipe. */ + static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearError(void) + { + UPERRX = 0; + UPINTX &= ~(1 << PERRI); + } + + /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that + * some sort of hardware error has occurred on the pipe. + * + * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag. + * + * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise. + */ + static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsError(void) + { + return ((UPINTX & (1 << PERRI)) ? true : false); + } + + /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This + * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred. + * + * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe. + */ + static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetErrorFlags(void) + { + return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | + PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID | + PIPE_ERRORFLAG_DATATGL)) | + (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW))); + } + + /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for + * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the + * \ref Pipe_ClearIN() command. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Total number of busy banks in the selected pipe. + */ + static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetBusyBanks(void) + { + return (UPSTAX & (0x03 << NBUSYBK0)); + } + + /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe + * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT + * direction). This function will return false if an error has occurred in the pipe, or if the pipe + * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT + * direction and the pipe bank is full. + * + * \note This function is not valid on CONTROL type pipes. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the currently selected pipe may be read from or written to, depending + * on its direction. + */ + static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsReadWriteAllowed(void) + { + return ((UPINTX & (1 << RWAL)) ? true : false); + } + + /** Determines if a packet has been received on the currently selected IN pipe from the attached device. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise. + */ + static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsINReceived(void) + { + return ((UPINTX & (1 << RXINI)) ? true : false); + } + + /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise. + */ + static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsOUTReady(void) + { + return ((UPINTX & (1 << TXOUTI)) ? true : false); + } + + /** Determines if no SETUP request is currently being sent to the attached device on the selected + * CONTROL type pipe. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise. + */ + static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsSETUPSent(void) + { + return ((UPINTX & (1 << TXSTPI)) ? true : false); + } + + /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet. + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearSETUP(void) + { + UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON)); + } + + /** Acknowledges the reception of a setup IN request from the attached device on the currently selected + * pipe, freeing the bank ready for the next packet. + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearIN(void) + { + UPINTX &= ~((1 << RXINI) | (1 << FIFOCON)); + } + + /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing + * the bank ready for the next packet. + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearOUT(void) + { + UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON)); + } + + /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on + * the currently selected pipe. This occurs when the host sends a packet to the device, but the device + * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been + * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet + * can be re-sent. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise. + */ + static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsNAKReceived(void) + { + return ((UPINTX & (1 << NAKEDI)) ? true : false); + } + + /** Clears the NAK condition on the currently selected pipe. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \see \ref Pipe_IsNAKReceived() for more details. + */ + static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearNAKReceived(void) + { + UPINTX &= ~(1 << NAKEDI); + } + + /** Determines if the currently selected pipe has had the STALL condition set by the attached device. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise. + */ + static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsStalled(void) + { + return ((UPINTX & (1 << RXSTALLI)) ? true : false); + } + + /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the + * STALL condition itself (this must be done via a ClearFeature control request to the device). + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearStall(void) + { + UPINTX &= ~(1 << RXSTALLI); + } + + /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next byte in the currently selected pipe's FIFO buffer. + */ + static inline uint8_t Pipe_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_Read_8(void) + { + return UPDATX; + } + + /** Writes one byte to the currently selected pipe's bank, for IN direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write into the the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_8(const uint8_t Data) + { + UPDATX = Data; + } + + /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + */ + static inline void Pipe_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_8(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + + (void)Dummy; + } + + /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_16_LE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; + + return Data.Value; + } + + /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_16_BE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[1] = UPDATX; + Data.Bytes[0] = UPDATX; + + return Data.Value; + } + + /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_16_LE(const uint16_t Data) + { + UPDATX = (Data & 0xFF); + UPDATX = (Data >> 8); + } + + /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_16_BE(const uint16_t Data) + { + UPDATX = (Data >> 8); + UPDATX = (Data & 0xFF); + } + + /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + */ + static inline void Pipe_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_16(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + Dummy = UPDATX; + + (void)Dummy; + } + + /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_32_LE(void) + { + union + { + uint32_t Value; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; + Data.Bytes[2] = UPDATX; + Data.Bytes[3] = UPDATX; + + return Data.Value; + } + + /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_32_BE(void) + { + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[3] = UPDATX; + Data.Bytes[2] = UPDATX; + Data.Bytes[1] = UPDATX; + Data.Bytes[0] = UPDATX; + + return Data.DWord; + } + + /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_32_LE(const uint32_t Data) + { + UPDATX = (Data & 0xFF); + UPDATX = (Data >> 8); + UPDATX = (Data >> 16); + UPDATX = (Data >> 24); + } + + /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_32_BE(const uint32_t Data) + { + UPDATX = (Data >> 24); + UPDATX = (Data >> 16); + UPDATX = (Data >> 8); + UPDATX = (Data & 0xFF); + } + + /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + */ + static inline void Pipe_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_32(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + Dummy = UPDATX; + Dummy = UPDATX; + Dummy = UPDATX; + + (void)Dummy; + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control pipe located at address + * 0 in the device. This value is set to the value indicated in the attached device's device + * descriptor once the USB interface is initialized into host mode and a device is attached + * to the USB bus. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + extern uint8_t USB_Host_ControlPipeSize; + + /* Function Prototypes: */ + /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the + * attached device, bank size and banking mode. + * + * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze() + * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or + * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite + * numbers of IN requests without automatic freezing - this can be overridden by a call to + * \ref Pipe_SetFiniteINRequests(). + * + * \param[in] Number Pipe number to configure. This must be more than 0 and less than \ref PIPE_TOTAL_PIPES. + * + * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low + * Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] Token Pipe data token, either \ref PIPE_TOKEN_SETUP, \ref PIPE_TOKEN_OUT or \ref PIPE_TOKEN_IN. + * All pipes (except Control type) are unidirectional - data may only be read from or + * written to the pipe bank based on its direction, not both. + * + * \param[in] EndpointNumber Endpoint index within the attached device that the pipe should interface to. + * + * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to + * the USB device, or after they have been received from the USB device (depending on + * the pipe's data direction). The bank size must indicate the maximum packet size that + * the pipe can handle. + * + * \param[in] Banks Number of banks to use for the pipe being configured, a \c PIPE_BANK_* mask. More banks + * uses more USB DPRAM, but offers better performance. Isochronous type pipes must + * have at least two banks. + * + * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes must be configured in ascending order, + * or bank corruption will occur. + * \n\n + * + * \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's + * index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe. + * \n\n + * + * \note The default control pipe should not be manually configured by the user application, as it is + * automatically configured by the library internally. + * \n\n + * + * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which + * failed to reconfigure correctly will be selected. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + bool Pipe_ConfigurePipe(const uint8_t Number, + const uint8_t Type, + const uint8_t Token, + const uint8_t EndpointNumber, + const uint16_t Size, + const uint8_t Banks); + + /** Spin-loops until the currently selected non-control pipe is ready for the next packet of data to be read + * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect). + * + * \ingroup Group_PipeRW_AVR8 + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t Pipe_WaitUntilReady(void); + + /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given + * endpoint is found, it is automatically selected. + * + * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check. + * + * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found, + * \c false otherwise. + */ + bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #if !defined(ENDPOINT_CONTROLEP) + #define ENDPOINT_CONTROLEP 0 + #endif + + /* Inline Functions: */ + static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) + { + uint8_t MaskVal = 0; + uint16_t CheckBytes = 8; + + while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE)) + { + MaskVal++; + CheckBytes <<= 1; + } + + return (MaskVal << EPSIZE0); + } + + /* Function Prototypes: */ + void Pipe_ClearPipes(void); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c index c237f70..4216d56 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c @@ -1,84 +1,84 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#if defined(TEMPLATE_FUNC_NAME) - -uint8_t TEMPLATE_FUNC_NAME (void* const Buffer, - uint16_t Length) -{ - uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - - if (!(Length)) - Endpoint_ClearOUT(); - - while (Length) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - else if (Endpoint_IsSETUPReceived()) - return ENDPOINT_RWCSTREAM_HostAborted; - - if (Endpoint_IsOUTReceived()) - { - while (Length && Endpoint_BytesInEndpoint()) - { - TEMPLATE_TRANSFER_BYTE(DataStream); - TEMPLATE_BUFFER_MOVE(DataStream, 1); - Length--; - } - - Endpoint_ClearOUT(); - } - } - - while (!(Endpoint_IsINReady())) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; -} - -#undef TEMPLATE_BUFFER_OFFSET -#undef TEMPLATE_BUFFER_MOVE -#undef TEMPLATE_FUNC_NAME -#undef TEMPLATE_TRANSFER_BYTE - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +uint8_t TEMPLATE_FUNC_NAME (void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + + if (!(Length)) + Endpoint_ClearOUT(); + + while (Length) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + + if (Endpoint_IsOUTReceived()) + { + while (Length && Endpoint_BytesInEndpoint()) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + } + + Endpoint_ClearOUT(); + } + } + + while (!(Endpoint_IsINReady())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c index 9eaeaec..1c0d526 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c @@ -1,93 +1,93 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#if defined(TEMPLATE_FUNC_NAME) - -uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, - uint16_t Length) -{ - uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - bool LastPacketFull = false; - - if (Length > USB_ControlRequest.wLength) - Length = USB_ControlRequest.wLength; - else if (!(Length)) - Endpoint_ClearIN(); - - while (Length || LastPacketFull) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - else if (Endpoint_IsSETUPReceived()) - return ENDPOINT_RWCSTREAM_HostAborted; - else if (Endpoint_IsOUTReceived()) - break; - - if (Endpoint_IsINReady()) - { - uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); - - while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) - { - TEMPLATE_TRANSFER_BYTE(DataStream); - TEMPLATE_BUFFER_MOVE(DataStream, 1); - Length--; - BytesInEndpoint++; - } - - LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); - Endpoint_ClearIN(); - } - } - - while (!(Endpoint_IsOUTReceived())) - { - uint8_t USB_DeviceState_LCL = USB_DeviceState; - - if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) - return ENDPOINT_RWCSTREAM_DeviceDisconnected; - else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) - return ENDPOINT_RWCSTREAM_BusSuspended; - } - - return ENDPOINT_RWCSTREAM_NoError; -} - -#undef TEMPLATE_BUFFER_OFFSET -#undef TEMPLATE_BUFFER_MOVE -#undef TEMPLATE_FUNC_NAME -#undef TEMPLATE_TRANSFER_BYTE - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + bool LastPacketFull = false; + + if (Length > USB_ControlRequest.wLength) + Length = USB_ControlRequest.wLength; + else if (!(Length)) + Endpoint_ClearIN(); + + while (Length || LastPacketFull) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + else if (Endpoint_IsOUTReceived()) + break; + + if (Endpoint_IsINReady()) + { + uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); + + while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInEndpoint++; + } + + LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); + Endpoint_ClearIN(); + } + } + + while (!(Endpoint_IsOUTReceived())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c index 22938ff..bc685ab 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c @@ -1,89 +1,89 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#if defined(TEMPLATE_FUNC_NAME) - -uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) -{ - uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - uint16_t BytesInTransfer = 0; - uint8_t ErrorCode; - - if ((ErrorCode = Endpoint_WaitUntilReady())) - return ErrorCode; - - if (BytesProcessed != NULL) - { - Length -= *BytesProcessed; - TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); - } - - while (Length) - { - if (!(Endpoint_IsReadWriteAllowed())) - { - TEMPLATE_CLEAR_ENDPOINT(); - - #if !defined(INTERRUPT_CONTROL_ENDPOINT) - USB_USBTask(); - #endif - - if (BytesProcessed != NULL) - { - *BytesProcessed += BytesInTransfer; - return ENDPOINT_RWSTREAM_IncompleteTransfer; - } - - if ((ErrorCode = Endpoint_WaitUntilReady())) - return ErrorCode; - } - else - { - TEMPLATE_TRANSFER_BYTE(DataStream); - TEMPLATE_BUFFER_MOVE(DataStream, 1); - Length--; - BytesInTransfer++; - } - } - - return ENDPOINT_RWSTREAM_NoError; -} - -#undef TEMPLATE_FUNC_NAME -#undef TEMPLATE_BUFFER_TYPE -#undef TEMPLATE_TRANSFER_BYTE -#undef TEMPLATE_CLEAR_ENDPOINT -#undef TEMPLATE_BUFFER_OFFSET -#undef TEMPLATE_BUFFER_MOVE - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_ENDPOINT(); + + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_ENDPOINT +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c index 3602631..a49102b 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c @@ -1,88 +1,88 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#if defined(TEMPLATE_FUNC_NAME) - -uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, - uint16_t Length, - uint16_t* const BytesProcessed) -{ - uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); - uint16_t BytesInTransfer = 0; - uint8_t ErrorCode; - - Pipe_SetPipeToken(TEMPLATE_TOKEN); - - if ((ErrorCode = Pipe_WaitUntilReady())) - return ErrorCode; - - if (BytesProcessed != NULL) - { - Length -= *BytesProcessed; - TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); - } - - while (Length) - { - if (!(Pipe_IsReadWriteAllowed())) - { - TEMPLATE_CLEAR_PIPE(); - - if (BytesProcessed != NULL) - { - *BytesProcessed += BytesInTransfer; - return PIPE_RWSTREAM_IncompleteTransfer; - } - - if ((ErrorCode = Pipe_WaitUntilReady())) - return ErrorCode; - } - else - { - TEMPLATE_TRANSFER_BYTE(DataStream); - TEMPLATE_BUFFER_MOVE(DataStream, 1); - Length--; - BytesInTransfer++; - } - } - - return PIPE_RWSTREAM_NoError; -} - -#undef TEMPLATE_FUNC_NAME -#undef TEMPLATE_BUFFER_TYPE -#undef TEMPLATE_TOKEN -#undef TEMPLATE_TRANSFER_BYTE -#undef TEMPLATE_CLEAR_PIPE -#undef TEMPLATE_BUFFER_OFFSET -#undef TEMPLATE_BUFFER_MOVE - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + Pipe_SetPipeToken(TEMPLATE_TOKEN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_PIPE(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TOKEN +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_PIPE +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c index 90d85de..239373c 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c @@ -1,262 +1,262 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#define __INCLUDE_FROM_USB_CONTROLLER_C -#include "../USBController.h" - -#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) -volatile uint8_t USB_CurrentMode = USB_MODE_None; -#endif - -#if !defined(USE_STATIC_OPTIONS) -volatile uint8_t USB_Options; -#endif - -void USB_Init( - #if defined(USB_CAN_BE_BOTH) - const uint8_t Mode - #endif - - #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) - , - #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) - void - #endif - - #if !defined(USE_STATIC_OPTIONS) - const uint8_t Options - #endif - ) -{ - #if !defined(USE_STATIC_OPTIONS) - USB_Options = Options; - #endif - - if (!(USB_Options & USB_OPT_REG_DISABLED)) - USB_REG_On(); - else - USB_REG_Off(); - - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - #if defined(USB_SERIES_4_AVR) - PLLFRQ = (1 << PDIV2); - #endif - } - - #if defined(USB_CAN_BE_BOTH) - if (Mode == USB_MODE_UID) - { - UHWCON |= (1 << UIDE); - USB_INT_Enable(USB_INT_IDTI); - USB_CurrentMode = USB_GetUSBModeFromUID(); - } - else - { - UHWCON &= ~(1 << UIDE); - USB_CurrentMode = Mode; - } - #endif - - USB_IsInitialized = true; - - USB_ResetInterface(); -} - -void USB_Disable(void) -{ - USB_INT_DisableAllInterrupts(); - USB_INT_ClearAllInterrupts(); - - USB_Detach(); - USB_Controller_Disable(); - - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - USB_PLL_Off(); - - USB_REG_Off(); - - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - USB_OTGPAD_Off(); - #endif - - #if defined(USB_CAN_BE_BOTH) - USB_CurrentMode = USB_MODE_None; - #endif - - USB_IsInitialized = false; -} - -void USB_ResetInterface(void) -{ - #if defined(USB_CAN_BE_BOTH) - bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0); - #endif - - USB_INT_DisableAllInterrupts(); - USB_INT_ClearAllInterrupts(); - - USB_Controller_Reset(); - - #if defined(USB_CAN_BE_BOTH) - if (UIDModeSelectEnabled) - USB_INT_Enable(USB_INT_IDTI); - #endif - - USB_CLK_Unfreeze(); - - if (USB_CurrentMode == USB_MODE_Device) - { - #if defined(USB_CAN_BE_DEVICE) - #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - UHWCON |= (1 << UIMOD); - #endif - - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - #if defined(USB_SERIES_2_AVR) - USB_PLL_On(); - while (!(USB_PLL_IsReady())); - #else - USB_PLL_Off(); - #endif - } - - USB_Init_Device(); - #endif - } - else if (USB_CurrentMode == USB_MODE_Host) - { - #if defined(USB_CAN_BE_HOST) - UHWCON &= ~(1 << UIMOD); - - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - #if defined(USB_CAN_BE_HOST) - USB_PLL_On(); - while (!(USB_PLL_IsReady())); - #endif - } - - USB_Init_Host(); - #endif - } - - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - USB_OTGPAD_On(); - #endif -} - -#if defined(USB_CAN_BE_DEVICE) -static void USB_Init_Device(void) -{ - USB_DeviceState = DEVICE_STATE_Unattached; - USB_Device_ConfigurationNumber = 0; - - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - USB_Device_RemoteWakeupEnabled = false; - #endif - - #if !defined(NO_DEVICE_SELF_POWER) - USB_Device_CurrentlySelfPowered = false; - #endif - - #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) - USB_Descriptor_Device_t* DeviceDescriptorPtr; - - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ - !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) - uint8_t DescriptorAddressSpace; - - if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR) - { - if (DescriptorAddressSpace == MEMSPACE_FLASH) - USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); - else if (DescriptorAddressSpace == MEMSPACE_EEPROM) - USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); - else - USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; - } - #else - if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) - { - #if defined(USE_RAM_DESCRIPTORS) - USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; - #elif defined(USE_EEPROM_DESCRIPTORS) - USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); - #else - USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); - #endif - } - #endif - #endif - - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - if (USB_Options & USB_DEVICE_OPT_LOWSPEED) - USB_Device_SetLowSpeed(); - else - USB_Device_SetFullSpeed(); - - USB_INT_Enable(USB_INT_VBUSTI); - #endif - - Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, - ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, - ENDPOINT_BANK_SINGLE); - - USB_INT_Clear(USB_INT_SUSPI); - USB_INT_Enable(USB_INT_SUSPI); - USB_INT_Enable(USB_INT_EORSTI); - - USB_Attach(); -} -#endif - -#if defined(USB_CAN_BE_HOST) -static void USB_Init_Host(void) -{ - USB_HostState = HOST_STATE_Unattached; - USB_Host_ConfigurationNumber = 0; - USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; - - USB_Host_HostMode_On(); - - USB_Host_VBUS_Auto_Off(); - USB_Host_VBUS_Manual_Enable(); - USB_Host_VBUS_Manual_On(); - - USB_INT_Enable(USB_INT_SRPI); - USB_INT_Enable(USB_INT_BCERRI); - - USB_Attach(); -} -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#define __INCLUDE_FROM_USB_CONTROLLER_C +#include "../USBController.h" + +#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) +volatile uint8_t USB_CurrentMode = USB_MODE_None; +#endif + +#if !defined(USE_STATIC_OPTIONS) +volatile uint8_t USB_Options; +#endif + +void USB_Init( + #if defined(USB_CAN_BE_BOTH) + const uint8_t Mode + #endif + + #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) + , + #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) + void + #endif + + #if !defined(USE_STATIC_OPTIONS) + const uint8_t Options + #endif + ) +{ + #if !defined(USE_STATIC_OPTIONS) + USB_Options = Options; + #endif + + if (!(USB_Options & USB_OPT_REG_DISABLED)) + USB_REG_On(); + else + USB_REG_Off(); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_4_AVR) + PLLFRQ = (1 << PDIV2); + #endif + } + + #if defined(USB_CAN_BE_BOTH) + if (Mode == USB_MODE_UID) + { + UHWCON |= (1 << UIDE); + USB_INT_Enable(USB_INT_IDTI); + USB_CurrentMode = USB_GetUSBModeFromUID(); + } + else + { + UHWCON &= ~(1 << UIDE); + USB_CurrentMode = Mode; + } + #endif + + USB_IsInitialized = true; + + USB_ResetInterface(); +} + +void USB_Disable(void) +{ + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Detach(); + USB_Controller_Disable(); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + + USB_REG_Off(); + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + USB_OTGPAD_Off(); + #endif + + #if defined(USB_CAN_BE_BOTH) + USB_CurrentMode = USB_MODE_None; + #endif + + USB_IsInitialized = false; +} + +void USB_ResetInterface(void) +{ + #if defined(USB_CAN_BE_BOTH) + bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0); + #endif + + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Controller_Reset(); + + #if defined(USB_CAN_BE_BOTH) + if (UIDModeSelectEnabled) + USB_INT_Enable(USB_INT_IDTI); + #endif + + USB_CLK_Unfreeze(); + + if (USB_CurrentMode == USB_MODE_Device) + { + #if defined(USB_CAN_BE_DEVICE) + #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + UHWCON |= (1 << UIMOD); + #endif + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_2_AVR) + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + #else + USB_PLL_Off(); + #endif + } + + USB_Init_Device(); + #endif + } + else if (USB_CurrentMode == USB_MODE_Host) + { + #if defined(USB_CAN_BE_HOST) + UHWCON &= ~(1 << UIMOD); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_CAN_BE_HOST) + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + #endif + } + + USB_Init_Host(); + #endif + } + + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + USB_OTGPAD_On(); + #endif +} + +#if defined(USB_CAN_BE_DEVICE) +static void USB_Init_Device(void) +{ + USB_DeviceState = DEVICE_STATE_Unattached; + USB_Device_ConfigurationNumber = 0; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + USB_Device_RemoteWakeupEnabled = false; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + USB_Device_CurrentlySelfPowered = false; + #endif + + #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) + USB_Descriptor_Device_t* DeviceDescriptorPtr; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + uint8_t DescriptorAddressSpace; + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR) + { + if (DescriptorAddressSpace == MEMSPACE_FLASH) + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else if (DescriptorAddressSpace == MEMSPACE_EEPROM) + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + } + #else + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) + { + #if defined(USE_RAM_DESCRIPTORS) + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + #elif defined(USE_EEPROM_DESCRIPTORS) + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #else + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #endif + } + #endif + #endif + + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + if (USB_Options & USB_DEVICE_OPT_LOWSPEED) + USB_Device_SetLowSpeed(); + else + USB_Device_SetFullSpeed(); + + USB_INT_Enable(USB_INT_VBUSTI); + #endif + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, + ENDPOINT_BANK_SINGLE); + + USB_INT_Clear(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_EORSTI); + + USB_Attach(); +} +#endif + +#if defined(USB_CAN_BE_HOST) +static void USB_Init_Host(void) +{ + USB_HostState = HOST_STATE_Unattached; + USB_Host_ConfigurationNumber = 0; + USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + + USB_Host_HostMode_On(); + + USB_Host_VBUS_Auto_Off(); + USB_Host_VBUS_Manual_Enable(); + USB_Host_VBUS_Manual_On(); + + USB_INT_Enable(USB_INT_SRPI); + USB_INT_Enable(USB_INT_BCERRI); + + USB_Attach(); +} +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h index 1cc9f26..c9d1a08 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h @@ -1,437 +1,437 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Controller definitions for the AVR8 microcontrollers. - * \copydetails Group_USBManagement_AVR8 - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USBManagement - * \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8) - * \brief USB Controller definitions for the AVR8 microcontrollers. - * - * Functions, macros, variables, enums and types related to the setup and management of the USB interface. - * - * @{ - */ - -#ifndef __USBCONTROLLER_AVR8_H__ -#define __USBCONTROLLER_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - #include "../USBMode.h" - #include "../Events.h" - #include "../USBTask.h" - #include "../USBInterrupt.h" - - #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) - #include "../Host.h" - #include "../OTG.h" - #include "../Pipe.h" - #include "../HostStandardReq.h" - #include "../PipeStream.h" - #endif - - #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) - #include "../Device.h" - #include "../Endpoint.h" - #include "../DeviceStandardReq.h" - #include "../EndpointStream.h" - #endif - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks and Defines: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - #if !defined(F_USB) - #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile. - #endif - - #if (F_USB == 8000000) - #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \ - defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \ - defined(__AVR_ATmega32U2__)) - #define USB_PLL_PSC 0 - #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) - #define USB_PLL_PSC 0 - #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__)) - #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0)) - #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) - #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0)) - #endif - #elif (F_USB == 16000000) - #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \ - defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \ - defined(__AVR_ATmega32U2__)) - #define USB_PLL_PSC (1 << PLLP0) - #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) - #define USB_PLL_PSC (1 << PINDIV) - #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__)) - #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1)) - #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)) - #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0)) - #endif - #endif - - #if !defined(USB_PLL_PSC) - #error No PLL prescale value available for chosen F_USB value and AVR model. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** \name USB Controller Option Masks */ - //@{ - /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad - * regulator should be disabled and the AVR's VCC level used for the data pads. - * - * \note See USB AVR data sheet for more information on the internal pad regulator. - */ - #define USB_OPT_REG_DISABLED (1 << 1) - - /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad - * regulator should be enabled to regulate the data pin voltages from the VBUS level down to a level within - * the range allowable by the USB standard. - * - * \note See USB AVR data sheet for more information on the internal pad regulator. - */ - #define USB_OPT_REG_ENABLED (0 << 1) - - /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application - * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock - * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations. - */ - #define USB_OPT_MANUAL_PLL (1 << 2) - - /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should - * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock - * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations. - */ - #define USB_OPT_AUTO_PLL (0 << 2) - //@} - - #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__) - /** Constant for the maximum software timeout period of the USB data stream transfer functions - * (both control and standard) when in either device or host mode. If the next packet of a stream - * is not received or acknowledged within this time period, the stream function will fail. - * - * This value may be overridden in the user project makefile as the value of the - * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch. - */ - #define USB_STREAM_TIMEOUT_MS 100 - #endif - - /* Inline Functions: */ - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) - /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power). - * - * \note This function is not available on some AVR models which do not support hardware VBUS monitoring. - * - * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise. - */ - static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_VBUS_GetStatus(void) - { - return ((USBSTA & (1 << VBUS)) ? true : false); - } - #endif - - /** Detaches the device from the USB bus. This has the effect of removing the device from any - * attached host, ceasing USB communications. If no host is present, this prevents any host from - * enumerating the device once attached until \ref USB_Attach() is called. - */ - static inline void USB_Detach(void) ATTR_ALWAYS_INLINE; - static inline void USB_Detach(void) - { - UDCON |= (1 << DETACH); - } - - /** Attaches the device to the USB bus. This announces the device's presence to any attached - * USB host, starting the enumeration process. If no host is present, attaching the device - * will allow for enumeration once a host is connected to the device. - * - * This is inexplicably also required for proper operation while in host mode, to enable the - * attachment of a device to the host. This is despite the bit being located in the device-mode - * register and despite the datasheet making no mention of its requirement in host mode. - */ - static inline void USB_Attach(void) ATTR_ALWAYS_INLINE; - static inline void USB_Attach(void) - { - UDCON &= ~(1 << DETACH); - } - - /* Function Prototypes: */ - /** Main function to initialize and start the USB interface. Once active, the USB interface will - * allow for device connection to a host when in device mode, or for device enumeration while in - * host mode. - * - * As the USB library relies on interrupts for the device and host mode enumeration processes, - * the user must enable global interrupts before or shortly after this function is called. In - * device mode, interrupts must be enabled within 500ms of this function being called to ensure - * that the host does not time out whilst enumerating the device. In host mode, interrupts may be - * enabled at the application's leisure however enumeration will not begin of an attached device - * until after this has occurred. - * - * Calling this function when the USB interface is already initialized will cause a complete USB - * interface reset and re-enumeration. - * - * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value - * from the \ref USB_Modes_t enum. - * - * \param[in] Options Mask indicating the options which should be used when initializing the USB - * interface to control the USB interface's behaviour. This should be comprised of - * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the - * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device - * mode speed. - * - * \note To reduce the FLASH requirements of the library if only device or host mode is required, - * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY - * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler - * via the -D switch. If the mode is statically set, this parameter does not exist in the - * function prototype. - * \n\n - * - * \note To reduce the FLASH requirements of the library if only fixed settings are are required, - * the options may be set statically in the same manner as the mode (see the Mode parameter of - * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token, - * defined to the appropriate options masks. When the options are statically set, this - * parameter does not exist in the function prototype. - * \n\n - * - * \note The mode parameter does not exist on devices where only one mode is possible, such as USB - * AVR models which only implement the USB device mode in hardware. - * - * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks. - */ - void USB_Init( - #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) - const uint8_t Mode - #endif - - #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__) - , - #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) - void - #endif - - #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) - const uint8_t Options - #endif - ); - - /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO - * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface - * is restarted with the \ref USB_Init() function. - */ - void USB_Disable(void); - - /** Resets the interface, when already initialized. This will re-enumerate the device if already connected - * to a host, or re-enumerate an already attached device when in host mode. - */ - void USB_ResetInterface(void); - - /* Global Variables: */ - #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__) - /** Indicates the mode that the USB interface is currently initialized to, a value from the - * \ref USB_Modes_t enum. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - * \n\n - * - * \note When the controller is initialized into UID auto-detection mode, this variable will hold the - * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller - * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time - * options, or a limitation of the USB controller in the chosen device model) this will evaluate to - * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the - * USB interface is not initialized. - */ - extern volatile uint8_t USB_CurrentMode; - #elif defined(USB_HOST_ONLY) - #define USB_CurrentMode USB_MODE_Host - #elif defined(USB_DEVICE_ONLY) - #define USB_CurrentMode USB_MODE_Device - #endif - - #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) - /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init() - * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - */ - extern volatile uint8_t USB_Options; - #elif defined(USE_STATIC_OPTIONS) - #define USB_Options USE_STATIC_OPTIONS - #endif - - /* Enums: */ - /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the - * user application via \ref USB_CurrentMode. - */ - enum USB_Modes_t - { - USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */ - USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */ - USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */ - USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the - * USB connector. - */ - }; - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Function Prototypes: */ - #if defined(__INCLUDE_FROM_USB_CONTROLLER_C) - #if defined(USB_CAN_BE_DEVICE) - static void USB_Init_Device(void); - #endif - - #if defined(USB_CAN_BE_HOST) - static void USB_Init_Host(void); - #endif - #endif - - /* Inline Functions: */ - static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE; - static inline void USB_PLL_On(void) - { - PLLCSR = USB_PLL_PSC; - PLLCSR = (USB_PLL_PSC | (1 << PLLE)); - } - - static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE; - static inline void USB_PLL_Off(void) - { - PLLCSR = 0; - } - - static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline bool USB_PLL_IsReady(void) - { - return ((PLLCSR & (1 << PLOCK)) ? true : false); - } - - static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE; - static inline void USB_REG_On(void) - { - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - UHWCON |= (1 << UVREGE); - #else - REGCR &= ~(1 << REGDIS); - #endif - } - - static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE; - static inline void USB_REG_Off(void) - { - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - UHWCON &= ~(1 << UVREGE); - #else - REGCR |= (1 << REGDIS); - #endif - } - - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE; - static inline void USB_OTGPAD_On(void) - { - USBCON |= (1 << OTGPADE); - } - - static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE; - static inline void USB_OTGPAD_Off(void) - { - USBCON &= ~(1 << OTGPADE); - } - #endif - - static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE; - static inline void USB_CLK_Freeze(void) - { - USBCON |= (1 << FRZCLK); - } - - static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE; - static inline void USB_CLK_Unfreeze(void) - { - USBCON &= ~(1 << FRZCLK); - } - - static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE; - static inline void USB_Controller_Enable(void) - { - USBCON |= (1 << USBE); - } - - static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE; - static inline void USB_Controller_Disable(void) - { - USBCON &= ~(1 << USBE); - } - - static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; - static inline void USB_Controller_Reset(void) - { - USBCON &= ~(1 << USBE); - USBCON |= (1 << USBE); - } - - #if defined(USB_CAN_BE_BOTH) - static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; - static inline uint8_t USB_GetUSBModeFromUID(void) - { - if (USBSTA & (1 << ID)) - return USB_MODE_Device; - else - return USB_MODE_Host; - } - #endif - - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller definitions for the AVR8 microcontrollers. + * \copydetails Group_USBManagement_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USBManagement + * \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8) + * \brief USB Controller definitions for the AVR8 microcontrollers. + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_AVR8_H__ +#define __USBCONTROLLER_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../Events.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "../Host.h" + #include "../OTG.h" + #include "../Pipe.h" + #include "../HostStandardReq.h" + #include "../PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "../Device.h" + #include "../Endpoint.h" + #include "../DeviceStandardReq.h" + #include "../EndpointStream.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks and Defines: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if !defined(F_USB) + #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile. + #endif + + #if (F_USB == 8000000) + #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \ + defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \ + defined(__AVR_ATmega32U2__)) + #define USB_PLL_PSC 0 + #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) + #define USB_PLL_PSC 0 + #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__)) + #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0)) + #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) + #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0)) + #endif + #elif (F_USB == 16000000) + #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \ + defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \ + defined(__AVR_ATmega32U2__)) + #define USB_PLL_PSC (1 << PLLP0) + #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) + #define USB_PLL_PSC (1 << PINDIV) + #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__)) + #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1)) + #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)) + #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0)) + #endif + #endif + + #if !defined(USB_PLL_PSC) + #error No PLL prescale value available for chosen F_USB value and AVR model. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Controller Option Masks */ + //@{ + /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad + * regulator should be disabled and the AVR's VCC level used for the data pads. + * + * \note See USB AVR data sheet for more information on the internal pad regulator. + */ + #define USB_OPT_REG_DISABLED (1 << 1) + + /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad + * regulator should be enabled to regulate the data pin voltages from the VBUS level down to a level within + * the range allowable by the USB standard. + * + * \note See USB AVR data sheet for more information on the internal pad regulator. + */ + #define USB_OPT_REG_ENABLED (0 << 1) + + /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application + * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock + * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations. + */ + #define USB_OPT_MANUAL_PLL (1 << 2) + + /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should + * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock + * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations. + */ + #define USB_OPT_AUTO_PLL (0 << 2) + //@} + + #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__) + /** Constant for the maximum software timeout period of the USB data stream transfer functions + * (both control and standard) when in either device or host mode. If the next packet of a stream + * is not received or acknowledged within this time period, the stream function will fail. + * + * This value may be overridden in the user project makefile as the value of the + * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch. + */ + #define USB_STREAM_TIMEOUT_MS 100 + #endif + + /* Inline Functions: */ + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) + /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power). + * + * \note This function is not available on some AVR models which do not support hardware VBUS monitoring. + * + * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise. + */ + static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_VBUS_GetStatus(void) + { + return ((USBSTA & (1 << VBUS)) ? true : false); + } + #endif + + /** Detaches the device from the USB bus. This has the effect of removing the device from any + * attached host, ceasing USB communications. If no host is present, this prevents any host from + * enumerating the device once attached until \ref USB_Attach() is called. + */ + static inline void USB_Detach(void) ATTR_ALWAYS_INLINE; + static inline void USB_Detach(void) + { + UDCON |= (1 << DETACH); + } + + /** Attaches the device to the USB bus. This announces the device's presence to any attached + * USB host, starting the enumeration process. If no host is present, attaching the device + * will allow for enumeration once a host is connected to the device. + * + * This is inexplicably also required for proper operation while in host mode, to enable the + * attachment of a device to the host. This is despite the bit being located in the device-mode + * register and despite the datasheet making no mention of its requirement in host mode. + */ + static inline void USB_Attach(void) ATTR_ALWAYS_INLINE; + static inline void USB_Attach(void) + { + UDCON &= ~(1 << DETACH); + } + + /* Function Prototypes: */ + /** Main function to initialize and start the USB interface. Once active, the USB interface will + * allow for device connection to a host when in device mode, or for device enumeration while in + * host mode. + * + * As the USB library relies on interrupts for the device and host mode enumeration processes, + * the user must enable global interrupts before or shortly after this function is called. In + * device mode, interrupts must be enabled within 500ms of this function being called to ensure + * that the host does not time out whilst enumerating the device. In host mode, interrupts may be + * enabled at the application's leisure however enumeration will not begin of an attached device + * until after this has occurred. + * + * Calling this function when the USB interface is already initialized will cause a complete USB + * interface reset and re-enumeration. + * + * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value + * from the \ref USB_Modes_t enum. + * + * \param[in] Options Mask indicating the options which should be used when initializing the USB + * interface to control the USB interface's behaviour. This should be comprised of + * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the + * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device + * mode speed. + * + * \note To reduce the FLASH requirements of the library if only device or host mode is required, + * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY + * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler + * via the -D switch. If the mode is statically set, this parameter does not exist in the + * function prototype. + * \n\n + * + * \note To reduce the FLASH requirements of the library if only fixed settings are are required, + * the options may be set statically in the same manner as the mode (see the Mode parameter of + * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token, + * defined to the appropriate options masks. When the options are statically set, this + * parameter does not exist in the function prototype. + * \n\n + * + * \note The mode parameter does not exist on devices where only one mode is possible, such as USB + * AVR models which only implement the USB device mode in hardware. + * + * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks. + */ + void USB_Init( + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + const uint8_t Mode + #endif + + #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__) + , + #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) + void + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + const uint8_t Options + #endif + ); + + /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO + * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface + * is restarted with the \ref USB_Init() function. + */ + void USB_Disable(void); + + /** Resets the interface, when already initialized. This will re-enumerate the device if already connected + * to a host, or re-enumerate an already attached device when in host mode. + */ + void USB_ResetInterface(void); + + /* Global Variables: */ + #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__) + /** Indicates the mode that the USB interface is currently initialized to, a value from the + * \ref USB_Modes_t enum. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + * \n\n + * + * \note When the controller is initialized into UID auto-detection mode, this variable will hold the + * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller + * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time + * options, or a limitation of the USB controller in the chosen device model) this will evaluate to + * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the + * USB interface is not initialized. + */ + extern volatile uint8_t USB_CurrentMode; + #elif defined(USB_HOST_ONLY) + #define USB_CurrentMode USB_MODE_Host + #elif defined(USB_DEVICE_ONLY) + #define USB_CurrentMode USB_MODE_Device + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init() + * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + extern volatile uint8_t USB_Options; + #elif defined(USE_STATIC_OPTIONS) + #define USB_Options USE_STATIC_OPTIONS + #endif + + /* Enums: */ + /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the + * user application via \ref USB_CurrentMode. + */ + enum USB_Modes_t + { + USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */ + USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */ + USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */ + USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the + * USB connector. + */ + }; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_USB_CONTROLLER_C) + #if defined(USB_CAN_BE_DEVICE) + static void USB_Init_Device(void); + #endif + + #if defined(USB_CAN_BE_HOST) + static void USB_Init_Host(void); + #endif + #endif + + /* Inline Functions: */ + static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_PLL_On(void) + { + PLLCSR = USB_PLL_PSC; + PLLCSR = (USB_PLL_PSC | (1 << PLLE)); + } + + static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_PLL_Off(void) + { + PLLCSR = 0; + } + + static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_PLL_IsReady(void) + { + return ((PLLCSR & (1 << PLOCK)) ? true : false); + } + + static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_REG_On(void) + { + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + UHWCON |= (1 << UVREGE); + #else + REGCR &= ~(1 << REGDIS); + #endif + } + + static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_REG_Off(void) + { + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + UHWCON &= ~(1 << UVREGE); + #else + REGCR |= (1 << REGDIS); + #endif + } + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTGPAD_On(void) + { + USBCON |= (1 << OTGPADE); + } + + static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTGPAD_Off(void) + { + USBCON &= ~(1 << OTGPADE); + } + #endif + + static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE; + static inline void USB_CLK_Freeze(void) + { + USBCON |= (1 << FRZCLK); + } + + static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE; + static inline void USB_CLK_Unfreeze(void) + { + USBCON &= ~(1 << FRZCLK); + } + + static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Enable(void) + { + USBCON |= (1 << USBE); + } + + static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Disable(void) + { + USBCON &= ~(1 << USBE); + } + + static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Reset(void) + { + USBCON &= ~(1 << USBE); + USBCON |= (1 << USBE); + } + + #if defined(USB_CAN_BE_BOTH) + static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t USB_GetUSBModeFromUID(void) + { + if (USBSTA & (1 << ID)) + return USB_MODE_Device; + else + return USB_MODE_Host; + } + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c index f8e4cd0..8dfb092 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c @@ -1,275 +1,275 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "../USBInterrupt.h" - -void USB_INT_DisableAllInterrupts(void) -{ - #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); - #elif defined(USB_SERIES_4_AVR) - USBCON &= ~(1 << VBUSTE); - #endif - - #if defined(USB_CAN_BE_BOTH) - OTGIEN = 0; - #endif - - #if defined(USB_CAN_BE_HOST) - UHIEN = 0; - #endif - - #if defined(USB_CAN_BE_DEVICE) - UDIEN = 0; - #endif -} - -void USB_INT_ClearAllInterrupts(void) -{ - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - USBINT = 0; - #endif - - #if defined(USB_CAN_BE_BOTH) - OTGINT = 0; - #endif - - #if defined(USB_CAN_BE_HOST) - UHINT = 0; - #endif - - #if defined(USB_CAN_BE_DEVICE) - UDINT = 0; - #endif -} - -ISR(USB_GEN_vect, ISR_BLOCK) -{ - #if defined(USB_CAN_BE_DEVICE) - #if !defined(NO_SOF_EVENTS) - if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) - { - USB_INT_Clear(USB_INT_SOFI); - - EVENT_USB_Device_StartOfFrame(); - } - #endif - - #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) - if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI)) - { - USB_INT_Clear(USB_INT_VBUSTI); - - if (USB_VBUS_GetStatus()) - { - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - USB_PLL_On(); - while (!(USB_PLL_IsReady())); - } - - USB_DeviceState = DEVICE_STATE_Powered; - EVENT_USB_Device_Connect(); - } - else - { - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - USB_PLL_Off(); - - USB_DeviceState = DEVICE_STATE_Unattached; - EVENT_USB_Device_Disconnect(); - } - } - #endif - - if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI)) - { - USB_INT_Disable(USB_INT_SUSPI); - USB_INT_Enable(USB_INT_WAKEUPI); - - USB_CLK_Freeze(); - - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - USB_PLL_Off(); - - #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) - USB_DeviceState = DEVICE_STATE_Unattached; - EVENT_USB_Device_Disconnect(); - #else - USB_DeviceState = DEVICE_STATE_Suspended; - EVENT_USB_Device_Suspend(); - #endif - } - - if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI)) - { - if (!(USB_Options & USB_OPT_MANUAL_PLL)) - { - USB_PLL_On(); - while (!(USB_PLL_IsReady())); - } - - USB_CLK_Unfreeze(); - - USB_INT_Clear(USB_INT_WAKEUPI); - - USB_INT_Disable(USB_INT_WAKEUPI); - USB_INT_Enable(USB_INT_SUSPI); - - if (USB_Device_ConfigurationNumber) - USB_DeviceState = DEVICE_STATE_Configured; - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; - - #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) - EVENT_USB_Device_Connect(); - #else - EVENT_USB_Device_WakeUp(); - #endif - } - - if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) - { - USB_INT_Clear(USB_INT_EORSTI); - - USB_DeviceState = DEVICE_STATE_Default; - USB_Device_ConfigurationNumber = 0; - - USB_INT_Clear(USB_INT_SUSPI); - USB_INT_Disable(USB_INT_SUSPI); - USB_INT_Enable(USB_INT_WAKEUPI); - - Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, - ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, - ENDPOINT_BANK_SINGLE); - - #if defined(INTERRUPT_CONTROL_ENDPOINT) - USB_INT_Enable(USB_INT_RXSTPI); - #endif - - EVENT_USB_Device_Reset(); - } - #endif - - #if defined(USB_CAN_BE_HOST) - #if !defined(NO_SOF_EVENTS) - if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI)) - { - USB_INT_Clear(USB_INT_HSOFI); - - EVENT_USB_Host_StartOfFrame(); - } - #endif - - if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI)) - { - USB_INT_Clear(USB_INT_DDISCI); - USB_INT_Clear(USB_INT_DCONNI); - USB_INT_Disable(USB_INT_DDISCI); - - EVENT_USB_Host_DeviceUnattached(); - - USB_ResetInterface(); - } - - if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI)) - { - USB_INT_Clear(USB_INT_VBERRI); - - USB_Host_VBUS_Manual_Off(); - USB_Host_VBUS_Auto_Off(); - - EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip); - EVENT_USB_Host_DeviceUnattached(); - - USB_HostState = HOST_STATE_Unattached; - } - - if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI)) - { - USB_INT_Clear(USB_INT_SRPI); - USB_INT_Disable(USB_INT_SRPI); - - EVENT_USB_Host_DeviceAttached(); - - USB_INT_Enable(USB_INT_DDISCI); - - USB_HostState = HOST_STATE_Powered; - } - - if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI)) - { - USB_INT_Clear(USB_INT_BCERRI); - - EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0); - EVENT_USB_Host_DeviceUnattached(); - - USB_ResetInterface(); - } - #endif - - #if defined(USB_CAN_BE_BOTH) - if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI)) - { - USB_INT_Clear(USB_INT_IDTI); - - if (USB_DeviceState != DEVICE_STATE_Unattached) - EVENT_USB_Device_Disconnect(); - - if (USB_HostState != HOST_STATE_Unattached) - EVENT_USB_Host_DeviceUnattached(); - - USB_CurrentMode = USB_GetUSBModeFromUID(); - USB_ResetInterface(); - - EVENT_USB_UIDChange(); - } - #endif -} - -#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE) -ISR(USB_COM_vect, ISR_BLOCK) -{ - uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - USB_INT_Disable(USB_INT_RXSTPI); - - GlobalInterruptEnable(); - - USB_Device_ProcessControlRequest(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - USB_INT_Enable(USB_INT_RXSTPI); - Endpoint_SelectEndpoint(PrevSelectedEndpoint); -} -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBInterrupt.h" + +void USB_INT_DisableAllInterrupts(void) +{ + #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); + #elif defined(USB_SERIES_4_AVR) + USBCON &= ~(1 << VBUSTE); + #endif + + #if defined(USB_CAN_BE_BOTH) + OTGIEN = 0; + #endif + + #if defined(USB_CAN_BE_HOST) + UHIEN = 0; + #endif + + #if defined(USB_CAN_BE_DEVICE) + UDIEN = 0; + #endif +} + +void USB_INT_ClearAllInterrupts(void) +{ + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + USBINT = 0; + #endif + + #if defined(USB_CAN_BE_BOTH) + OTGINT = 0; + #endif + + #if defined(USB_CAN_BE_HOST) + UHINT = 0; + #endif + + #if defined(USB_CAN_BE_DEVICE) + UDINT = 0; + #endif +} + +ISR(USB_GEN_vect, ISR_BLOCK) +{ + #if defined(USB_CAN_BE_DEVICE) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) + { + USB_INT_Clear(USB_INT_SOFI); + + EVENT_USB_Device_StartOfFrame(); + } + #endif + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI)) + { + USB_INT_Clear(USB_INT_VBUSTI); + + if (USB_VBUS_GetStatus()) + { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + USB_DeviceState = DEVICE_STATE_Powered; + EVENT_USB_Device_Connect(); + } + else + { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + + USB_DeviceState = DEVICE_STATE_Unattached; + EVENT_USB_Device_Disconnect(); + } + } + #endif + + if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI)) + { + USB_INT_Disable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_WAKEUPI); + + USB_CLK_Freeze(); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + + #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) + USB_DeviceState = DEVICE_STATE_Unattached; + EVENT_USB_Device_Disconnect(); + #else + USB_DeviceState = DEVICE_STATE_Suspended; + EVENT_USB_Device_Suspend(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI)) + { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + USB_CLK_Unfreeze(); + + USB_INT_Clear(USB_INT_WAKEUPI); + + USB_INT_Disable(USB_INT_WAKEUPI); + USB_INT_Enable(USB_INT_SUSPI); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) + EVENT_USB_Device_Connect(); + #else + EVENT_USB_Device_WakeUp(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) + { + USB_INT_Clear(USB_INT_EORSTI); + + USB_DeviceState = DEVICE_STATE_Default; + USB_Device_ConfigurationNumber = 0; + + USB_INT_Clear(USB_INT_SUSPI); + USB_INT_Disable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_WAKEUPI); + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + ENDPOINT_DIR_OUT, USB_Device_ControlEndpointSize, + ENDPOINT_BANK_SINGLE); + + #if defined(INTERRUPT_CONTROL_ENDPOINT) + USB_INT_Enable(USB_INT_RXSTPI); + #endif + + EVENT_USB_Device_Reset(); + } + #endif + + #if defined(USB_CAN_BE_HOST) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + + EVENT_USB_Host_StartOfFrame(); + } + #endif + + if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI)) + { + USB_INT_Clear(USB_INT_DDISCI); + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Disable(USB_INT_DDISCI); + + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } + + if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI)) + { + USB_INT_Clear(USB_INT_VBERRI); + + USB_Host_VBUS_Manual_Off(); + USB_Host_VBUS_Auto_Off(); + + EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip); + EVENT_USB_Host_DeviceUnattached(); + + USB_HostState = HOST_STATE_Unattached; + } + + if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI)) + { + USB_INT_Clear(USB_INT_SRPI); + USB_INT_Disable(USB_INT_SRPI); + + EVENT_USB_Host_DeviceAttached(); + + USB_INT_Enable(USB_INT_DDISCI); + + USB_HostState = HOST_STATE_Powered; + } + + if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI)) + { + USB_INT_Clear(USB_INT_BCERRI); + + EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0); + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } + #endif + + #if defined(USB_CAN_BE_BOTH) + if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI)) + { + USB_INT_Clear(USB_INT_IDTI); + + if (USB_DeviceState != DEVICE_STATE_Unattached) + EVENT_USB_Device_Disconnect(); + + if (USB_HostState != HOST_STATE_Unattached) + EVENT_USB_Host_DeviceUnattached(); + + USB_CurrentMode = USB_GetUSBModeFromUID(); + USB_ResetInterface(); + + EVENT_USB_UIDChange(); + } + #endif +} + +#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE) +ISR(USB_COM_vect, ISR_BLOCK) +{ + uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Disable(USB_INT_RXSTPI); + + GlobalInterruptEnable(); + + USB_Device_ProcessControlRequest(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Enable(USB_INT_RXSTPI); + Endpoint_SelectEndpoint(PrevSelectedEndpoint); +} +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h index 9e9210e..a702247 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h @@ -1,369 +1,369 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Controller Interrupt definitions for the AVR8 microcontrollers. - * - * This file contains definitions required for the correct handling of low level USB service routine interrupts - * from the USB controller. - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -#ifndef __USBINTERRUPT_AVR8_H__ -#define __USBINTERRUPT_AVR8_H__ - - /* Includes: */ - #include "../../../../Common/Common.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Enums: */ - enum USB_Interrupts_t - { - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)) - USB_INT_VBUSTI = 0, - #endif - #if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)) - USB_INT_IDTI = 1, - #endif - #if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)) - USB_INT_WAKEUPI = 2, - USB_INT_SUSPI = 3, - USB_INT_EORSTI = 4, - USB_INT_SOFI = 5, - USB_INT_RXSTPI = 6, - #endif - #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)) - USB_INT_HSOFI = 7, - USB_INT_DCONNI = 8, - USB_INT_DDISCI = 9, - USB_INT_RSTI = 10, - USB_INT_BCERRI = 11, - USB_INT_VBERRI = 12, - USB_INT_SRPI = 13, - #endif - }; - - /* Inline Functions: */ - static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; - static inline void USB_INT_Enable(const uint8_t Interrupt) - { - switch (Interrupt) - { - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - case USB_INT_VBUSTI: - USBCON |= (1 << VBUSTE); - break; - #endif - #if defined(USB_CAN_BE_BOTH) - case USB_INT_IDTI: - USBCON |= (1 << IDTE); - break; - #endif - #if defined(USB_CAN_BE_DEVICE) - case USB_INT_WAKEUPI: - UDIEN |= (1 << WAKEUPE); - break; - case USB_INT_SUSPI: - UDIEN |= (1 << SUSPE); - break; - case USB_INT_EORSTI: - UDIEN |= (1 << EORSTE); - break; - case USB_INT_SOFI: - UDIEN |= (1 << SOFE); - break; - case USB_INT_RXSTPI: - UEIENX |= (1 << RXSTPE); - break; - #endif - #if defined(USB_CAN_BE_HOST) - case USB_INT_HSOFI: - UHIEN |= (1 << HSOFE); - break; - case USB_INT_DCONNI: - UHIEN |= (1 << DCONNE); - break; - case USB_INT_DDISCI: - UHIEN |= (1 << DDISCE); - break; - case USB_INT_RSTI: - UHIEN |= (1 << RSTE); - break; - case USB_INT_BCERRI: - OTGIEN |= (1 << BCERRE); - break; - case USB_INT_VBERRI: - OTGIEN |= (1 << VBERRE); - break; - case USB_INT_SRPI: - OTGIEN |= (1 << SRPE); - break; - #endif - } - } - - static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; - static inline void USB_INT_Disable(const uint8_t Interrupt) - { - switch (Interrupt) - { - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - case USB_INT_VBUSTI: - USBCON &= ~(1 << VBUSTE); - break; - #endif - #if defined(USB_CAN_BE_BOTH) - case USB_INT_IDTI: - USBCON &= ~(1 << IDTE); - break; - #endif - #if defined(USB_CAN_BE_DEVICE) - case USB_INT_WAKEUPI: - UDIEN &= ~(1 << WAKEUPE); - break; - case USB_INT_SUSPI: - UDIEN &= ~(1 << SUSPE); - break; - case USB_INT_EORSTI: - UDIEN &= ~(1 << EORSTE); - break; - case USB_INT_SOFI: - UDIEN &= ~(1 << SOFE); - break; - case USB_INT_RXSTPI: - UEIENX &= ~(1 << RXSTPE); - break; - #endif - #if defined(USB_CAN_BE_HOST) - case USB_INT_HSOFI: - UHIEN &= ~(1 << HSOFE); - break; - case USB_INT_DCONNI: - UHIEN &= ~(1 << DCONNE); - break; - case USB_INT_DDISCI: - UHIEN &= ~(1 << DDISCE); - break; - case USB_INT_RSTI: - UHIEN &= ~(1 << RSTE); - break; - case USB_INT_BCERRI: - OTGIEN &= ~(1 << BCERRE); - break; - case USB_INT_VBERRI: - OTGIEN &= ~(1 << VBERRE); - break; - case USB_INT_SRPI: - OTGIEN &= ~(1 << SRPE); - break; - #endif - } - } - - static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; - static inline void USB_INT_Clear(const uint8_t Interrupt) - { - switch (Interrupt) - { - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - case USB_INT_VBUSTI: - USBINT &= ~(1 << VBUSTI); - break; - #endif - #if defined(USB_CAN_BE_BOTH) - case USB_INT_IDTI: - USBINT &= ~(1 << IDTI); - break; - #endif - #if defined(USB_CAN_BE_DEVICE) - case USB_INT_WAKEUPI: - UDINT &= ~(1 << WAKEUPI); - break; - case USB_INT_SUSPI: - UDINT &= ~(1 << SUSPI); - break; - case USB_INT_EORSTI: - UDINT &= ~(1 << EORSTI); - break; - case USB_INT_SOFI: - UDINT &= ~(1 << SOFI); - break; - case USB_INT_RXSTPI: - UEINTX &= ~(1 << RXSTPI); - break; - #endif - #if defined(USB_CAN_BE_HOST) - case USB_INT_HSOFI: - UHINT &= ~(1 << HSOFI); - break; - case USB_INT_DCONNI: - UHINT &= ~(1 << DCONNI); - break; - case USB_INT_DDISCI: - UHINT &= ~(1 << DDISCI); - break; - case USB_INT_RSTI: - UHINT &= ~(1 << RSTI); - break; - case USB_INT_BCERRI: - OTGINT &= ~(1 << BCERRI); - break; - case USB_INT_VBERRI: - OTGINT &= ~(1 << VBERRI); - break; - case USB_INT_SRPI: - OTGINT &= ~(1 << SRPI); - break; - #endif - } - } - - static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) - { - switch (Interrupt) - { - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - case USB_INT_VBUSTI: - return (USBCON & (1 << VBUSTE)); - #endif - #if defined(USB_CAN_BE_BOTH) - case USB_INT_IDTI: - return (USBCON & (1 << IDTE)); - #endif - #if defined(USB_CAN_BE_DEVICE) - case USB_INT_WAKEUPI: - return (UDIEN & (1 << WAKEUPE)); - case USB_INT_SUSPI: - return (UDIEN & (1 << SUSPE)); - case USB_INT_EORSTI: - return (UDIEN & (1 << EORSTE)); - case USB_INT_SOFI: - return (UDIEN & (1 << SOFE)); - case USB_INT_RXSTPI: - return (UEIENX & (1 << RXSTPE)); - #endif - #if defined(USB_CAN_BE_HOST) - case USB_INT_HSOFI: - return (UHIEN & (1 << HSOFE)); - case USB_INT_DCONNI: - return (UHIEN & (1 << DCONNE)); - case USB_INT_DDISCI: - return (UHIEN & (1 << DDISCE)); - case USB_INT_RSTI: - return (UHIEN & (1 << RSTE)); - case USB_INT_BCERRI: - return (OTGIEN & (1 << BCERRE)); - case USB_INT_VBERRI: - return (OTGIEN & (1 << VBERRE)); - case USB_INT_SRPI: - return (OTGIEN & (1 << SRPE)); - #endif - } - - return false; - } - - static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; - static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) - { - switch (Interrupt) - { - #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) - case USB_INT_VBUSTI: - return (USBINT & (1 << VBUSTI)); - #endif - #if defined(USB_CAN_BE_BOTH) - case USB_INT_IDTI: - return (USBINT & (1 << IDTI)); - #endif - #if defined(USB_CAN_BE_DEVICE) - case USB_INT_WAKEUPI: - return (UDINT & (1 << WAKEUPI)); - case USB_INT_SUSPI: - return (UDINT & (1 << SUSPI)); - case USB_INT_EORSTI: - return (UDINT & (1 << EORSTI)); - case USB_INT_SOFI: - return (UDINT & (1 << SOFI)); - case USB_INT_RXSTPI: - return (UEINTX & (1 << RXSTPI)); - #endif - #if defined(USB_CAN_BE_HOST) - case USB_INT_HSOFI: - return (UHINT & (1 << HSOFI)); - case USB_INT_DCONNI: - return (UHINT & (1 << DCONNI)); - case USB_INT_DDISCI: - return (UHINT & (1 << DDISCI)); - case USB_INT_RSTI: - return (UHINT & (1 << RSTI)); - case USB_INT_BCERRI: - return (OTGINT & (1 << BCERRI)); - case USB_INT_VBERRI: - return (OTGINT & (1 << VBERRI)); - case USB_INT_SRPI: - return (OTGINT & (1 << SRPI)); - #endif - } - - return false; - } - - /* Includes: */ - #include "../USBMode.h" - #include "../Events.h" - #include "../USBController.h" - - /* Function Prototypes: */ - void USB_INT_ClearAllInterrupts(void); - void USB_INT_DisableAllInterrupts(void); - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller Interrupt definitions for the AVR8 microcontrollers. + * + * This file contains definitions required for the correct handling of low level USB service routine interrupts + * from the USB controller. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBINTERRUPT_AVR8_H__ +#define __USBINTERRUPT_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Enums: */ + enum USB_Interrupts_t + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)) + USB_INT_VBUSTI = 0, + #endif + #if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)) + USB_INT_IDTI = 1, + #endif + #if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)) + USB_INT_WAKEUPI = 2, + USB_INT_SUSPI = 3, + USB_INT_EORSTI = 4, + USB_INT_SOFI = 5, + USB_INT_RXSTPI = 6, + #endif + #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)) + USB_INT_HSOFI = 7, + USB_INT_DCONNI = 8, + USB_INT_DDISCI = 9, + USB_INT_RSTI = 10, + USB_INT_BCERRI = 11, + USB_INT_VBERRI = 12, + USB_INT_SRPI = 13, + #endif + }; + + /* Inline Functions: */ + static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Enable(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + USBCON |= (1 << VBUSTE); + break; + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + USBCON |= (1 << IDTE); + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + UDIEN |= (1 << WAKEUPE); + break; + case USB_INT_SUSPI: + UDIEN |= (1 << SUSPE); + break; + case USB_INT_EORSTI: + UDIEN |= (1 << EORSTE); + break; + case USB_INT_SOFI: + UDIEN |= (1 << SOFE); + break; + case USB_INT_RXSTPI: + UEIENX |= (1 << RXSTPE); + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + UHIEN |= (1 << HSOFE); + break; + case USB_INT_DCONNI: + UHIEN |= (1 << DCONNE); + break; + case USB_INT_DDISCI: + UHIEN |= (1 << DDISCE); + break; + case USB_INT_RSTI: + UHIEN |= (1 << RSTE); + break; + case USB_INT_BCERRI: + OTGIEN |= (1 << BCERRE); + break; + case USB_INT_VBERRI: + OTGIEN |= (1 << VBERRE); + break; + case USB_INT_SRPI: + OTGIEN |= (1 << SRPE); + break; + #endif + } + } + + static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Disable(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + USBCON &= ~(1 << VBUSTE); + break; + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + USBCON &= ~(1 << IDTE); + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + UDIEN &= ~(1 << WAKEUPE); + break; + case USB_INT_SUSPI: + UDIEN &= ~(1 << SUSPE); + break; + case USB_INT_EORSTI: + UDIEN &= ~(1 << EORSTE); + break; + case USB_INT_SOFI: + UDIEN &= ~(1 << SOFE); + break; + case USB_INT_RXSTPI: + UEIENX &= ~(1 << RXSTPE); + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + UHIEN &= ~(1 << HSOFE); + break; + case USB_INT_DCONNI: + UHIEN &= ~(1 << DCONNE); + break; + case USB_INT_DDISCI: + UHIEN &= ~(1 << DDISCE); + break; + case USB_INT_RSTI: + UHIEN &= ~(1 << RSTE); + break; + case USB_INT_BCERRI: + OTGIEN &= ~(1 << BCERRE); + break; + case USB_INT_VBERRI: + OTGIEN &= ~(1 << VBERRE); + break; + case USB_INT_SRPI: + OTGIEN &= ~(1 << SRPE); + break; + #endif + } + } + + static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Clear(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + USBINT &= ~(1 << VBUSTI); + break; + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + USBINT &= ~(1 << IDTI); + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + UDINT &= ~(1 << WAKEUPI); + break; + case USB_INT_SUSPI: + UDINT &= ~(1 << SUSPI); + break; + case USB_INT_EORSTI: + UDINT &= ~(1 << EORSTI); + break; + case USB_INT_SOFI: + UDINT &= ~(1 << SOFI); + break; + case USB_INT_RXSTPI: + UEINTX &= ~(1 << RXSTPI); + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + UHINT &= ~(1 << HSOFI); + break; + case USB_INT_DCONNI: + UHINT &= ~(1 << DCONNI); + break; + case USB_INT_DDISCI: + UHINT &= ~(1 << DDISCI); + break; + case USB_INT_RSTI: + UHINT &= ~(1 << RSTI); + break; + case USB_INT_BCERRI: + OTGINT &= ~(1 << BCERRI); + break; + case USB_INT_VBERRI: + OTGINT &= ~(1 << VBERRI); + break; + case USB_INT_SRPI: + OTGINT &= ~(1 << SRPI); + break; + #endif + } + } + + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + return (USBCON & (1 << VBUSTE)); + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + return (USBCON & (1 << IDTE)); + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + return (UDIEN & (1 << WAKEUPE)); + case USB_INT_SUSPI: + return (UDIEN & (1 << SUSPE)); + case USB_INT_EORSTI: + return (UDIEN & (1 << EORSTE)); + case USB_INT_SOFI: + return (UDIEN & (1 << SOFE)); + case USB_INT_RXSTPI: + return (UEIENX & (1 << RXSTPE)); + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + return (UHIEN & (1 << HSOFE)); + case USB_INT_DCONNI: + return (UHIEN & (1 << DCONNE)); + case USB_INT_DDISCI: + return (UHIEN & (1 << DDISCE)); + case USB_INT_RSTI: + return (UHIEN & (1 << RSTE)); + case USB_INT_BCERRI: + return (OTGIEN & (1 << BCERRE)); + case USB_INT_VBERRI: + return (OTGIEN & (1 << VBERRE)); + case USB_INT_SRPI: + return (OTGIEN & (1 << SRPE)); + #endif + } + + return false; + } + + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + return (USBINT & (1 << VBUSTI)); + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + return (USBINT & (1 << IDTI)); + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + return (UDINT & (1 << WAKEUPI)); + case USB_INT_SUSPI: + return (UDINT & (1 << SUSPI)); + case USB_INT_EORSTI: + return (UDINT & (1 << EORSTI)); + case USB_INT_SOFI: + return (UDINT & (1 << SOFI)); + case USB_INT_RXSTPI: + return (UEINTX & (1 << RXSTPI)); + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + return (UHINT & (1 << HSOFI)); + case USB_INT_DCONNI: + return (UHINT & (1 << DCONNI)); + case USB_INT_DDISCI: + return (UHINT & (1 << DDISCI)); + case USB_INT_RSTI: + return (UHINT & (1 << RSTI)); + case USB_INT_BCERRI: + return (OTGINT & (1 << BCERRI)); + case USB_INT_VBERRI: + return (OTGINT & (1 << VBERRI)); + case USB_INT_SRPI: + return (OTGINT & (1 << SRPI)); + #endif + } + + return false; + } + + /* Includes: */ + #include "../USBMode.h" + #include "../Events.h" + #include "../USBController.h" + + /* Function Prototypes: */ + void USB_INT_ClearAllInterrupts(void); + void USB_INT_DisableAllInterrupts(void); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.c b/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.c index 3b8b482..5bdcdc6 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.c @@ -1,146 +1,146 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "ConfigDescriptor.h" - -#if defined(USB_CAN_BE_HOST) -uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber, - uint16_t* const ConfigSizePtr, - void* const BufferPtr, - const uint16_t BufferSize) -{ - uint8_t ErrorCode; - uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)]; - - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_GetDescriptor, - .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)), - .wIndex = 0, - .wLength = sizeof(USB_Descriptor_Configuration_Header_t), - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful) - return ErrorCode; - - *ConfigSizePtr = le16_to_cpu(DESCRIPTOR_PCAST(ConfigHeader, USB_Descriptor_Configuration_Header_t)->TotalConfigurationSize); - - if (*ConfigSizePtr > BufferSize) - return HOST_GETCONFIG_BuffOverflow; - - USB_ControlRequest.wLength = *ConfigSizePtr; - - if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful) - return ErrorCode; - - if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration) - return HOST_GETCONFIG_InvalidData; - - return HOST_GETCONFIG_Successful; -} -#endif - -void USB_GetNextDescriptorOfType(uint16_t* const BytesRem, - void** const CurrConfigLoc, - const uint8_t Type) -{ - while (*BytesRem) - { - USB_GetNextDescriptor(BytesRem, CurrConfigLoc); - - if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type) - return; - } -} - -void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem, - void** const CurrConfigLoc, - const uint8_t Type, - const uint8_t BeforeType) -{ - while (*BytesRem) - { - USB_GetNextDescriptor(BytesRem, CurrConfigLoc); - - if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type) - { - return; - } - else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType) - { - *BytesRem = 0; - return; - } - } -} - -void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, - void** const CurrConfigLoc, - const uint8_t Type, - const uint8_t AfterType) -{ - USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType); - - if (*BytesRem) - USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type); -} - -uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, - void** const CurrConfigLoc, - ConfigComparatorPtr_t const ComparatorRoutine) -{ - uint8_t ErrorCode; - - while (*BytesRem) - { - uint8_t* PrevDescLoc = *CurrConfigLoc; - uint16_t PrevBytesRem = *BytesRem; - - USB_GetNextDescriptor(BytesRem, CurrConfigLoc); - - if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound) - { - if (ErrorCode == DESCRIPTOR_SEARCH_Fail) - { - *CurrConfigLoc = PrevDescLoc; - *BytesRem = PrevBytesRem; - } - - return ErrorCode; - } - } - - return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor; -} - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "ConfigDescriptor.h" + +#if defined(USB_CAN_BE_HOST) +uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber, + uint16_t* const ConfigSizePtr, + void* const BufferPtr, + const uint16_t BufferSize) +{ + uint8_t ErrorCode; + uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)]; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetDescriptor, + .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)), + .wIndex = 0, + .wLength = sizeof(USB_Descriptor_Configuration_Header_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + *ConfigSizePtr = le16_to_cpu(DESCRIPTOR_PCAST(ConfigHeader, USB_Descriptor_Configuration_Header_t)->TotalConfigurationSize); + + if (*ConfigSizePtr > BufferSize) + return HOST_GETCONFIG_BuffOverflow; + + USB_ControlRequest.wLength = *ConfigSizePtr; + + if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration) + return HOST_GETCONFIG_InvalidData; + + return HOST_GETCONFIG_Successful; +} +#endif + +void USB_GetNextDescriptorOfType(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type) +{ + while (*BytesRem) + { + USB_GetNextDescriptor(BytesRem, CurrConfigLoc); + + if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type) + return; + } +} + +void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t BeforeType) +{ + while (*BytesRem) + { + USB_GetNextDescriptor(BytesRem, CurrConfigLoc); + + if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type) + { + return; + } + else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType) + { + *BytesRem = 0; + return; + } + } +} + +void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t AfterType) +{ + USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType); + + if (*BytesRem) + USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type); +} + +uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, + void** const CurrConfigLoc, + ConfigComparatorPtr_t const ComparatorRoutine) +{ + uint8_t ErrorCode; + + while (*BytesRem) + { + uint8_t* PrevDescLoc = *CurrConfigLoc; + uint16_t PrevBytesRem = *BytesRem; + + USB_GetNextDescriptor(BytesRem, CurrConfigLoc); + + if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound) + { + if (ErrorCode == DESCRIPTOR_SEARCH_Fail) + { + *CurrConfigLoc = PrevDescLoc; + *BytesRem = PrevBytesRem; + } + + return ErrorCode; + } + } + + return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor; +} + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.h b/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.h index 820a991..3101908 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/ConfigDescriptor.h @@ -1,285 +1,285 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Configuration Descriptor definitions. - * \copydetails Group_ConfigDescriptorParser - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_Descriptors - * \defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser - * \brief USB Configuration Descriptor definitions. - * - * This section of the library gives a friendly API which can be used in host applications to easily - * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor - * data can be extracted and used as needed. - * - * @{ - */ - -#ifndef __CONFIGDESCRIPTOR_H__ -#define __CONFIGDESCRIPTOR_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - #include "HostStandardReq.h" - #include "StdDescriptors.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given - * descriptor type. - * - * Usage Example: - * \code - * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header - * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor, - * USB_Descriptor_Configuration_Header_t); - * - * // Can now access elements of the configuration header struct using the -> indirection operator - * \endcode - */ - #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr)) - - /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor - * type (as an actual struct instance rather than a pointer to a struct). - * - * Usage Example: - * \code - * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header - * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor, - * USB_Descriptor_Configuration_Header_t); - * - * // Can now access elements of the configuration header struct using the . operator - * \endcode - */ - #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type)) - - /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor. - * This value's meaning depends on the descriptor's placement in the descriptor, but standard type - * values can be accessed in the \ref USB_DescriptorTypes_t enum. - */ - #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Type - - /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */ - #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Size - - /* Type Defines: */ - /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array - * of type void, returning a uint8_t value). - * - * \see \ref USB_GetNextDescriptorComp function for more details. - */ - typedef uint8_t (* ConfigComparatorPtr_t)(void*); - - /* Enums: */ - /** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */ - enum USB_Host_GetConfigDescriptor_ErrorCodes_t - { - HOST_GETCONFIG_Successful = 0, /**< No error occurred while retrieving the configuration descriptor. */ - HOST_GETCONFIG_DeviceDisconnect = 1, /**< The attached device was disconnected while retrieving the configuration - * descriptor. - */ - HOST_GETCONFIG_PipeError = 2, /**< An error occurred in the pipe while sending the request. */ - HOST_GETCONFIG_SetupStalled = 3, /**< The attached device stalled the request to retrieve the configuration - * descriptor. - */ - HOST_GETCONFIG_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */ - HOST_GETCONFIG_BuffOverflow = 5, /**< The device's configuration descriptor is too large to fit into the allocated - * buffer. - */ - HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data. */ - }; - - /** Enum for return values of a descriptor comparator function. */ - enum DSearch_Return_ErrorCodes_t - { - DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */ - DESCRIPTOR_SEARCH_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */ - DESCRIPTOR_SEARCH_NotFound = 2, /**< Current descriptor does not match comparator criteria. */ - }; - - /** Enum for return values of \ref USB_GetNextDescriptorComp(). */ - enum DSearch_Comp_Return_ErrorCodes_t - { - DESCRIPTOR_SEARCH_COMP_Found = 0, /**< Configuration descriptor now points to descriptor which matches - * search criteria of the given comparator function. */ - DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned \ref DESCRIPTOR_SEARCH_Fail. */ - DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */ - }; - - /* Function Prototypes: */ - /** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer, - * including validity and size checking to prevent a buffer overflow. - * - * \param[in] ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for - * single configuration devices). - * \param[in,out] ConfigSizePtr Pointer to a location for storing the retrieved configuration descriptor size. - * \param[out] BufferPtr Pointer to the buffer for storing the configuration descriptor data. - * \param[out] BufferSize Size of the allocated buffer where the configuration descriptor is to be stored. - * - * \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum. - */ - uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber, - uint16_t* const ConfigSizePtr, - void* const BufferPtr, - const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3); - - /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value. - * The bytes remaining value is automatically decremented. - * - * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. - * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. - * \param[in] Type Descriptor type value to search for. - */ - void USB_GetNextDescriptorOfType(uint16_t* const BytesRem, - void** const CurrConfigLoc, - const uint8_t Type) - ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value, - * which must come before a descriptor of the second given type value. If the BeforeType type - * descriptor is reached first, the number of bytes remaining to process is set to zero and the - * function exits. The bytes remaining value is automatically decremented. - * - * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. - * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. - * \param[in] Type Descriptor type value to search for. - * \param[in] BeforeType Descriptor type value which must not be reached before the given Type descriptor. - */ - void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem, - void** const CurrConfigLoc, - const uint8_t Type, - const uint8_t BeforeType) - ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value, - * which must come after a descriptor of the second given type value. The bytes remaining value is - * automatically decremented. - * - * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. - * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. - * \param[in] Type Descriptor type value to search for. - * \param[in] AfterType Descriptor type value which must be reached before the given Type descriptor. - */ - void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, - void** const CurrConfigLoc, - const uint8_t Type, - const uint8_t AfterType) - ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - - /** Searches for the next descriptor in the given configuration descriptor using a pre-made comparator - * function. The routine updates the position and remaining configuration descriptor bytes values - * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back - * so that the next descriptor search invocation will start from the descriptor which first caused the - * original search to fail. This behaviour allows for one comparator to be used immediately after another - * has failed, starting the second search from the descriptor which failed the first. - * - * Comparator functions should be standard functions which accept a pointer to the header of the current - * descriptor inside the configuration descriptor which is being compared, and should return a value from - * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value. - * - * \note This function is available in USB Host mode only. - * - * \param[in,out] BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor. - * \param[in,out] CurrConfigLoc Pointer to the current position in the configuration descriptor. - * \param[in] ComparatorRoutine Name of the comparator search function to use on the configuration descriptor. - * - * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum. - * - * Usage Example: - * \code - * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype - * - * uint8_t EndpointSearcher(void* CurrentDescriptor) - * { - * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) - * return DESCRIPTOR_SEARCH_Found; - * else - * return DESCRIPTOR_SEARCH_NotFound; - * } - * - * //... - * // After retrieving configuration descriptor: - * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &CurrentConfigLoc, EndpointSearcher) == - * Descriptor_Search_Comp_Found) - * { - * // Do something with the endpoint descriptor - * } - * \endcode - */ - uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, - void** const CurrConfigLoc, - ConfigComparatorPtr_t const ComparatorRoutine); - - /* Inline Functions: */ - /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then - points to the next sub-descriptor. The bytes remaining value is automatically decremented. - * - * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. - * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. - */ - static inline void USB_GetNextDescriptor(uint16_t* const BytesRem, - void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); - static inline void USB_GetNextDescriptor(uint16_t* const BytesRem, - void** CurrConfigLoc) - { - uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size; - - if (*BytesRem < CurrDescriptorSize) - CurrDescriptorSize = *BytesRem; - - *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize); - *BytesRem -= CurrDescriptorSize; - } - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Configuration Descriptor definitions. + * \copydetails Group_ConfigDescriptorParser + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Descriptors + * \defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser + * \brief USB Configuration Descriptor definitions. + * + * This section of the library gives a friendly API which can be used in host applications to easily + * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor + * data can be extracted and used as needed. + * + * @{ + */ + +#ifndef __CONFIGDESCRIPTOR_H__ +#define __CONFIGDESCRIPTOR_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "HostStandardReq.h" + #include "StdDescriptors.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given + * descriptor type. + * + * Usage Example: + * \code + * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header + * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor, + * USB_Descriptor_Configuration_Header_t); + * + * // Can now access elements of the configuration header struct using the -> indirection operator + * \endcode + */ + #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr)) + + /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor + * type (as an actual struct instance rather than a pointer to a struct). + * + * Usage Example: + * \code + * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header + * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor, + * USB_Descriptor_Configuration_Header_t); + * + * // Can now access elements of the configuration header struct using the . operator + * \endcode + */ + #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type)) + + /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor. + * This value's meaning depends on the descriptor's placement in the descriptor, but standard type + * values can be accessed in the \ref USB_DescriptorTypes_t enum. + */ + #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Type + + /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */ + #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Size + + /* Type Defines: */ + /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array + * of type void, returning a uint8_t value). + * + * \see \ref USB_GetNextDescriptorComp function for more details. + */ + typedef uint8_t (* ConfigComparatorPtr_t)(void*); + + /* Enums: */ + /** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */ + enum USB_Host_GetConfigDescriptor_ErrorCodes_t + { + HOST_GETCONFIG_Successful = 0, /**< No error occurred while retrieving the configuration descriptor. */ + HOST_GETCONFIG_DeviceDisconnect = 1, /**< The attached device was disconnected while retrieving the configuration + * descriptor. + */ + HOST_GETCONFIG_PipeError = 2, /**< An error occurred in the pipe while sending the request. */ + HOST_GETCONFIG_SetupStalled = 3, /**< The attached device stalled the request to retrieve the configuration + * descriptor. + */ + HOST_GETCONFIG_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */ + HOST_GETCONFIG_BuffOverflow = 5, /**< The device's configuration descriptor is too large to fit into the allocated + * buffer. + */ + HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data. */ + }; + + /** Enum for return values of a descriptor comparator function. */ + enum DSearch_Return_ErrorCodes_t + { + DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */ + DESCRIPTOR_SEARCH_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */ + DESCRIPTOR_SEARCH_NotFound = 2, /**< Current descriptor does not match comparator criteria. */ + }; + + /** Enum for return values of \ref USB_GetNextDescriptorComp(). */ + enum DSearch_Comp_Return_ErrorCodes_t + { + DESCRIPTOR_SEARCH_COMP_Found = 0, /**< Configuration descriptor now points to descriptor which matches + * search criteria of the given comparator function. */ + DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned \ref DESCRIPTOR_SEARCH_Fail. */ + DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */ + }; + + /* Function Prototypes: */ + /** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer, + * including validity and size checking to prevent a buffer overflow. + * + * \param[in] ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for + * single configuration devices). + * \param[in,out] ConfigSizePtr Pointer to a location for storing the retrieved configuration descriptor size. + * \param[out] BufferPtr Pointer to the buffer for storing the configuration descriptor data. + * \param[out] BufferSize Size of the allocated buffer where the configuration descriptor is to be stored. + * + * \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum. + */ + uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber, + uint16_t* const ConfigSizePtr, + void* const BufferPtr, + const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3); + + /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value. + * The bytes remaining value is automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + * \param[in] Type Descriptor type value to search for. + */ + void USB_GetNextDescriptorOfType(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value, + * which must come before a descriptor of the second given type value. If the BeforeType type + * descriptor is reached first, the number of bytes remaining to process is set to zero and the + * function exits. The bytes remaining value is automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + * \param[in] Type Descriptor type value to search for. + * \param[in] BeforeType Descriptor type value which must not be reached before the given Type descriptor. + */ + void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t BeforeType) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value, + * which must come after a descriptor of the second given type value. The bytes remaining value is + * automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + * \param[in] Type Descriptor type value to search for. + * \param[in] AfterType Descriptor type value which must be reached before the given Type descriptor. + */ + void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t AfterType) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Searches for the next descriptor in the given configuration descriptor using a pre-made comparator + * function. The routine updates the position and remaining configuration descriptor bytes values + * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back + * so that the next descriptor search invocation will start from the descriptor which first caused the + * original search to fail. This behaviour allows for one comparator to be used immediately after another + * has failed, starting the second search from the descriptor which failed the first. + * + * Comparator functions should be standard functions which accept a pointer to the header of the current + * descriptor inside the configuration descriptor which is being compared, and should return a value from + * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value. + * + * \note This function is available in USB Host mode only. + * + * \param[in,out] BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current position in the configuration descriptor. + * \param[in] ComparatorRoutine Name of the comparator search function to use on the configuration descriptor. + * + * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum. + * + * Usage Example: + * \code + * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype + * + * uint8_t EndpointSearcher(void* CurrentDescriptor) + * { + * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) + * return DESCRIPTOR_SEARCH_Found; + * else + * return DESCRIPTOR_SEARCH_NotFound; + * } + * + * //... + * // After retrieving configuration descriptor: + * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &CurrentConfigLoc, EndpointSearcher) == + * Descriptor_Search_Comp_Found) + * { + * // Do something with the endpoint descriptor + * } + * \endcode + */ + uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, + void** const CurrConfigLoc, + ConfigComparatorPtr_t const ComparatorRoutine); + + /* Inline Functions: */ + /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then + points to the next sub-descriptor. The bytes remaining value is automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + */ + static inline void USB_GetNextDescriptor(uint16_t* const BytesRem, + void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + static inline void USB_GetNextDescriptor(uint16_t* const BytesRem, + void** CurrConfigLoc) + { + uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size; + + if (*BytesRem < CurrDescriptorSize) + CurrDescriptorSize = *BytesRem; + + *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize); + *BytesRem -= CurrDescriptorSize; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/Device.h b/hal/at90usb646/LUFA/Drivers/USB/Core/Device.h index 06714de..29452be 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/Device.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/Device.h @@ -1,159 +1,159 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common USB Device definitions for all architectures. - * \copydetails Group_Device - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_Device Device Management - * \brief USB Device management definitions for USB device mode. - * - * USB Device mode related definitions common to all architectures. This module contains definitions which - * are used when the USB controller is initialized in device mode. - * - * @{ - */ - -#ifndef __USBDEVICE_H__ -#define __USBDEVICE_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - #include "StdDescriptors.h" - #include "USBInterrupt.h" - #include "Endpoint.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Enums: */ - /** Enum for the various states of the USB Device state machine. Only some states are - * implemented in the LUFA library - other states are left to the user to implement. - * - * For information on each possible USB device state, refer to the USB 2.0 specification. - * - * \see \ref USB_DeviceState, which stores the current device state machine state. - */ - enum USB_Device_States_t - { - DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates - * that the device is not currently connected to a host. - */ - DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates - * that the device is connected to a host, but enumeration has not - * yet begun. - */ - DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates - * that the device's USB bus has been reset by the host and it is - * now waiting for the host to begin the enumeration process. - */ - DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates - * that the device has been addressed by the USB Host, but is not - * yet configured. - */ - DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates - * that the device has been enumerated by the host and is ready - * for USB communications to begin. - */ - DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates - * that the USB bus has been suspended by the host, and the device - * should power down to a minimal power level until the bus is - * resumed. - */ - }; - - /* Function Prototypes: */ - /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value, - * index and language ID. This function MUST be overridden in the user application (added with full, identical - * prototype and name so that the library can call it to retrieve descriptor data. - * - * \param[in] wValue The type of the descriptor to retrieve in the upper byte, and the index in the - * lower byte (when more than one descriptor of the given type exists, such as the - * case of string descriptors). The type may be one of the standard types defined - * in the DescriptorTypes_t enum, or may be a class-specific descriptor type value. - * \param[in] wIndex The language ID of the string to return if the \c wValue type indicates - * \ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a - * class-specific standards. - * \param[out] DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to - * the address of the descriptor. - * \param[out] MemoryAddressSpace A value from the \ref USB_DescriptorMemorySpaces_t enum to indicate the memory - * space in which the descriptor is stored. This parameter does not exist when one - * of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which - * use a unified address space. - * - * \note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute. - * If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to - * allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the - * \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D - * switch. - * - * \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise. - */ - uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, - const uint8_t wIndex, - const void** const DescriptorAddress - #if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \ - !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) - , uint8_t* MemoryAddressSpace - #endif - ) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/Device_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/Device_UC3.h" - #elif (ARCH == ARCH_XMEGA) - #include "XMEGA/Device_XMEGA.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Device definitions for all architectures. + * \copydetails Group_Device + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_Device Device Management + * \brief USB Device management definitions for USB device mode. + * + * USB Device mode related definitions common to all architectures. This module contains definitions which + * are used when the USB controller is initialized in device mode. + * + * @{ + */ + +#ifndef __USBDEVICE_H__ +#define __USBDEVICE_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "StdDescriptors.h" + #include "USBInterrupt.h" + #include "Endpoint.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the various states of the USB Device state machine. Only some states are + * implemented in the LUFA library - other states are left to the user to implement. + * + * For information on each possible USB device state, refer to the USB 2.0 specification. + * + * \see \ref USB_DeviceState, which stores the current device state machine state. + */ + enum USB_Device_States_t + { + DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates + * that the device is not currently connected to a host. + */ + DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates + * that the device is connected to a host, but enumeration has not + * yet begun. + */ + DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates + * that the device's USB bus has been reset by the host and it is + * now waiting for the host to begin the enumeration process. + */ + DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates + * that the device has been addressed by the USB Host, but is not + * yet configured. + */ + DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates + * that the device has been enumerated by the host and is ready + * for USB communications to begin. + */ + DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates + * that the USB bus has been suspended by the host, and the device + * should power down to a minimal power level until the bus is + * resumed. + */ + }; + + /* Function Prototypes: */ + /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value, + * index and language ID. This function MUST be overridden in the user application (added with full, identical + * prototype and name so that the library can call it to retrieve descriptor data. + * + * \param[in] wValue The type of the descriptor to retrieve in the upper byte, and the index in the + * lower byte (when more than one descriptor of the given type exists, such as the + * case of string descriptors). The type may be one of the standard types defined + * in the DescriptorTypes_t enum, or may be a class-specific descriptor type value. + * \param[in] wIndex The language ID of the string to return if the \c wValue type indicates + * \ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a + * class-specific standards. + * \param[out] DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to + * the address of the descriptor. + * \param[out] MemoryAddressSpace A value from the \ref USB_DescriptorMemorySpaces_t enum to indicate the memory + * space in which the descriptor is stored. This parameter does not exist when one + * of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which + * use a unified address space. + * + * \note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute. + * If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to + * allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the + * \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D + * switch. + * + * \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise. + */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + const void** const DescriptorAddress + #if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + , uint8_t* MemoryAddressSpace + #endif + ) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Device_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Device_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/Device_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.c b/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.c index aa6817d..61082cf 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.c @@ -1,380 +1,380 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "USBMode.h" - -#if defined(USB_CAN_BE_DEVICE) - -#define __INCLUDE_FROM_DEVICESTDREQ_C -#include "DeviceStandardReq.h" - -uint8_t USB_Device_ConfigurationNumber; - -#if !defined(NO_DEVICE_SELF_POWER) -bool USB_Device_CurrentlySelfPowered; -#endif - -#if !defined(NO_DEVICE_REMOTE_WAKEUP) -bool USB_Device_RemoteWakeupEnabled; -#endif - -void USB_Device_ProcessControlRequest(void) -{ - #if defined(ARCH_BIG_ENDIAN) - USB_ControlRequest.bmRequestType = Endpoint_Read_8(); - USB_ControlRequest.bRequest = Endpoint_Read_8(); - USB_ControlRequest.wValue = Endpoint_Read_16_LE(); - USB_ControlRequest.wIndex = Endpoint_Read_16_LE(); - USB_ControlRequest.wLength = Endpoint_Read_16_LE(); - #else - uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; - - for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) - *(RequestHeader++) = Endpoint_Read_8(); - #endif - - EVENT_USB_Device_ControlRequest(); - - if (Endpoint_IsSETUPReceived()) - { - uint8_t bmRequestType = USB_ControlRequest.bmRequestType; - - switch (USB_ControlRequest.bRequest) - { - case REQ_GetStatus: - if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || - (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) - { - USB_Device_GetStatus(); - } - - break; - case REQ_ClearFeature: - case REQ_SetFeature: - if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || - (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) - { - USB_Device_ClearSetFeature(); - } - - break; - case REQ_SetAddress: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - USB_Device_SetAddress(); - - break; - case REQ_GetDescriptor: - if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || - (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) - { - USB_Device_GetDescriptor(); - } - - break; - case REQ_GetConfiguration: - if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) - USB_Device_GetConfiguration(); - - break; - case REQ_SetConfiguration: - if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) - USB_Device_SetConfiguration(); - - break; - } - } - - if (Endpoint_IsSETUPReceived()) - { - Endpoint_StallTransaction(); - Endpoint_ClearSETUP(); - } -} - -static void USB_Device_SetAddress(void) -{ - uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F); - uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); - GlobalInterruptDisable(); - - Endpoint_ClearSETUP(); - - Endpoint_ClearStatusStage(); - - while (!(Endpoint_IsINReady())); - - USB_Device_SetDeviceAddress(DeviceAddress); - USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; - - SetGlobalInterruptMask(CurrentGlobalInt); -} - -static void USB_Device_SetConfiguration(void) -{ - #if defined(FIXED_NUM_CONFIGURATIONS) - if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS) - return; - #else - USB_Descriptor_Device_t* DevDescriptorPtr; - - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) - #if defined(USE_FLASH_DESCRIPTORS) - #define MemoryAddressSpace MEMSPACE_FLASH - #elif defined(USE_EEPROM_DESCRIPTORS) - #define MemoryAddressSpace MEMSPACE_EEPROM - #elif defined(USE_SRAM_DESCRIPTORS) - #define MemoryAddressSpace MEMSPACE_SRAM - #else - uint8_t MemoryAddressSpace; - #endif - #endif - - if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ - !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) - , &MemoryAddressSpace - #endif - ) == NO_DESCRIPTOR) - { - return; - } - - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) - if (MemoryAddressSpace == MEMSPACE_FLASH) - { - if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) - return; - } - else if (MemoryAddressSpace == MEMSPACE_EEPROM) - { - if (((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) - return; - } - else - { - if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) - return; - } - #else - if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) - return; - #endif - #endif - - Endpoint_ClearSETUP(); - - USB_Device_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue; - - Endpoint_ClearStatusStage(); - - if (USB_Device_ConfigurationNumber) - USB_DeviceState = DEVICE_STATE_Configured; - else - USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; - - EVENT_USB_Device_ConfigurationChanged(); -} - -static void USB_Device_GetConfiguration(void) -{ - Endpoint_ClearSETUP(); - - Endpoint_Write_8(USB_Device_ConfigurationNumber); - Endpoint_ClearIN(); - - Endpoint_ClearStatusStage(); -} - -#if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) -static void USB_Device_GetInternalSerialDescriptor(void) -{ - struct - { - USB_Descriptor_Header_t Header; - uint16_t UnicodeString[INTERNAL_SERIAL_LENGTH_BITS / 4]; - } SignatureDescriptor; - - SignatureDescriptor.Header.Type = DTYPE_String; - SignatureDescriptor.Header.Size = USB_STRING_LEN(INTERNAL_SERIAL_LENGTH_BITS / 4); - - USB_Device_GetSerialString(SignatureDescriptor.UnicodeString); - - Endpoint_ClearSETUP(); - - Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor)); - Endpoint_ClearOUT(); -} -#endif - -static void USB_Device_GetDescriptor(void) -{ - const void* DescriptorPointer; - uint16_t DescriptorSize; - - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ - !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) - uint8_t DescriptorAddressSpace; - #endif - - #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) - if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL)) - { - USB_Device_GetInternalSerialDescriptor(); - return; - } - #endif - - if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, - &DescriptorPointer - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ - !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) - , &DescriptorAddressSpace - #endif - )) == NO_DESCRIPTOR) - { - return; - } - - Endpoint_ClearSETUP(); - - #if defined(USE_RAM_DESCRIPTORS) || !defined(ARCH_HAS_MULTI_ADDRESS_SPACE) - Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); - #elif defined(USE_EEPROM_DESCRIPTORS) - Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); - #elif defined(USE_FLASH_DESCRIPTORS) - Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); - #else - if (DescriptorAddressSpace == MEMSPACE_FLASH) - Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); - else if (DescriptorAddressSpace == MEMSPACE_EEPROM) - Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); - else - Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); - #endif - - Endpoint_ClearOUT(); -} - -static void USB_Device_GetStatus(void) -{ - uint8_t CurrentStatus = 0; - - switch (USB_ControlRequest.bmRequestType) - { - #if !defined(NO_DEVICE_SELF_POWER) || !defined(NO_DEVICE_REMOTE_WAKEUP) - case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE): - #if !defined(NO_DEVICE_SELF_POWER) - if (USB_Device_CurrentlySelfPowered) - CurrentStatus |= FEATURE_SELFPOWERED_ENABLED; - #endif - - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - if (USB_Device_RemoteWakeupEnabled) - CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED; - #endif - break; - #endif - #if !defined(CONTROL_ONLY_DEVICE) - case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT): - Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); - - CurrentStatus = Endpoint_IsStalled(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - break; - #endif - default: - return; - } - - Endpoint_ClearSETUP(); - - Endpoint_Write_16_LE(CurrentStatus); - Endpoint_ClearIN(); - - Endpoint_ClearStatusStage(); -} - -static void USB_Device_ClearSetFeature(void) -{ - switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) - { - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - case REQREC_DEVICE: - if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_DeviceRemoteWakeup) - USB_Device_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature); - else - return; - - break; - #endif - #if !defined(CONTROL_ONLY_DEVICE) - case REQREC_ENDPOINT: - if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_EndpointHalt) - { - uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); - - if (EndpointIndex == ENDPOINT_CONTROLEP) - return; - - Endpoint_SelectEndpoint(EndpointIndex); - - if (Endpoint_IsEnabled()) - { - if (USB_ControlRequest.bRequest == REQ_SetFeature) - { - Endpoint_StallTransaction(); - } - else - { - Endpoint_ClearStall(); - Endpoint_ResetEndpoint(EndpointIndex); - Endpoint_ResetDataToggle(); - } - } - } - - break; - #endif - default: - return; - } - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - Endpoint_ClearSETUP(); - - Endpoint_ClearStatusStage(); -} - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_DEVICESTDREQ_C +#include "DeviceStandardReq.h" + +uint8_t USB_Device_ConfigurationNumber; + +#if !defined(NO_DEVICE_SELF_POWER) +bool USB_Device_CurrentlySelfPowered; +#endif + +#if !defined(NO_DEVICE_REMOTE_WAKEUP) +bool USB_Device_RemoteWakeupEnabled; +#endif + +void USB_Device_ProcessControlRequest(void) +{ + #if defined(ARCH_BIG_ENDIAN) + USB_ControlRequest.bmRequestType = Endpoint_Read_8(); + USB_ControlRequest.bRequest = Endpoint_Read_8(); + USB_ControlRequest.wValue = Endpoint_Read_16_LE(); + USB_ControlRequest.wIndex = Endpoint_Read_16_LE(); + USB_ControlRequest.wLength = Endpoint_Read_16_LE(); + #else + uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; + + for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) + *(RequestHeader++) = Endpoint_Read_8(); + #endif + + EVENT_USB_Device_ControlRequest(); + + if (Endpoint_IsSETUPReceived()) + { + uint8_t bmRequestType = USB_ControlRequest.bmRequestType; + + switch (USB_ControlRequest.bRequest) + { + case REQ_GetStatus: + if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) + { + USB_Device_GetStatus(); + } + + break; + case REQ_ClearFeature: + case REQ_SetFeature: + if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) + { + USB_Device_ClearSetFeature(); + } + + break; + case REQ_SetAddress: + if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_SetAddress(); + + break; + case REQ_GetDescriptor: + if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) + { + USB_Device_GetDescriptor(); + } + + break; + case REQ_GetConfiguration: + if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_GetConfiguration(); + + break; + case REQ_SetConfiguration: + if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_SetConfiguration(); + + break; + } + } + + if (Endpoint_IsSETUPReceived()) + { + Endpoint_StallTransaction(); + Endpoint_ClearSETUP(); + } +} + +static void USB_Device_SetAddress(void) +{ + uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F); + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + Endpoint_ClearSETUP(); + + Endpoint_ClearStatusStage(); + + while (!(Endpoint_IsINReady())); + + USB_Device_SetDeviceAddress(DeviceAddress); + USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; + + SetGlobalInterruptMask(CurrentGlobalInt); +} + +static void USB_Device_SetConfiguration(void) +{ + #if defined(FIXED_NUM_CONFIGURATIONS) + if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS) + return; + #else + USB_Descriptor_Device_t* DevDescriptorPtr; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) + #if defined(USE_FLASH_DESCRIPTORS) + #define MemoryAddressSpace MEMSPACE_FLASH + #elif defined(USE_EEPROM_DESCRIPTORS) + #define MemoryAddressSpace MEMSPACE_EEPROM + #elif defined(USE_SRAM_DESCRIPTORS) + #define MemoryAddressSpace MEMSPACE_SRAM + #else + uint8_t MemoryAddressSpace; + #endif + #endif + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + , &MemoryAddressSpace + #endif + ) == NO_DESCRIPTOR) + { + return; + } + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) + if (MemoryAddressSpace == MEMSPACE_FLASH) + { + if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) + return; + } + else if (MemoryAddressSpace == MEMSPACE_EEPROM) + { + if (((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) + return; + } + else + { + if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) + return; + } + #else + if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) + return; + #endif + #endif + + Endpoint_ClearSETUP(); + + USB_Device_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue; + + Endpoint_ClearStatusStage(); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + EVENT_USB_Device_ConfigurationChanged(); +} + +static void USB_Device_GetConfiguration(void) +{ + Endpoint_ClearSETUP(); + + Endpoint_Write_8(USB_Device_ConfigurationNumber); + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); +} + +#if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) +static void USB_Device_GetInternalSerialDescriptor(void) +{ + struct + { + USB_Descriptor_Header_t Header; + uint16_t UnicodeString[INTERNAL_SERIAL_LENGTH_BITS / 4]; + } SignatureDescriptor; + + SignatureDescriptor.Header.Type = DTYPE_String; + SignatureDescriptor.Header.Size = USB_STRING_LEN(INTERNAL_SERIAL_LENGTH_BITS / 4); + + USB_Device_GetSerialString(SignatureDescriptor.UnicodeString); + + Endpoint_ClearSETUP(); + + Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor)); + Endpoint_ClearOUT(); +} +#endif + +static void USB_Device_GetDescriptor(void) +{ + const void* DescriptorPointer; + uint16_t DescriptorSize; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + uint8_t DescriptorAddressSpace; + #endif + + #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL)) + { + USB_Device_GetInternalSerialDescriptor(); + return; + } + #endif + + if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, + &DescriptorPointer + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + , &DescriptorAddressSpace + #endif + )) == NO_DESCRIPTOR) + { + return; + } + + Endpoint_ClearSETUP(); + + #if defined(USE_RAM_DESCRIPTORS) || !defined(ARCH_HAS_MULTI_ADDRESS_SPACE) + Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); + #elif defined(USE_EEPROM_DESCRIPTORS) + Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); + #elif defined(USE_FLASH_DESCRIPTORS) + Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); + #else + if (DescriptorAddressSpace == MEMSPACE_FLASH) + Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); + else if (DescriptorAddressSpace == MEMSPACE_EEPROM) + Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); + else + Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); + #endif + + Endpoint_ClearOUT(); +} + +static void USB_Device_GetStatus(void) +{ + uint8_t CurrentStatus = 0; + + switch (USB_ControlRequest.bmRequestType) + { + #if !defined(NO_DEVICE_SELF_POWER) || !defined(NO_DEVICE_REMOTE_WAKEUP) + case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE): + #if !defined(NO_DEVICE_SELF_POWER) + if (USB_Device_CurrentlySelfPowered) + CurrentStatus |= FEATURE_SELFPOWERED_ENABLED; + #endif + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + if (USB_Device_RemoteWakeupEnabled) + CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED; + #endif + break; + #endif + #if !defined(CONTROL_ONLY_DEVICE) + case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT): + Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); + + CurrentStatus = Endpoint_IsStalled(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + break; + #endif + default: + return; + } + + Endpoint_ClearSETUP(); + + Endpoint_Write_16_LE(CurrentStatus); + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); +} + +static void USB_Device_ClearSetFeature(void) +{ + switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) + { + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + case REQREC_DEVICE: + if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_DeviceRemoteWakeup) + USB_Device_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature); + else + return; + + break; + #endif + #if !defined(CONTROL_ONLY_DEVICE) + case REQREC_ENDPOINT: + if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_EndpointHalt) + { + uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); + + if (EndpointIndex == ENDPOINT_CONTROLEP) + return; + + Endpoint_SelectEndpoint(EndpointIndex); + + if (Endpoint_IsEnabled()) + { + if (USB_ControlRequest.bRequest == REQ_SetFeature) + { + Endpoint_StallTransaction(); + } + else + { + Endpoint_ClearStall(); + Endpoint_ResetEndpoint(EndpointIndex); + Endpoint_ResetDataToggle(); + } + } + } + + break; + #endif + default: + return; + } + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + Endpoint_ClearSETUP(); + + Endpoint_ClearStatusStage(); +} + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.h b/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.h index 72f0d78..a319b7a 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/DeviceStandardReq.h @@ -1,159 +1,159 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB device standard request management. - * - * This file contains the function prototypes necessary for the processing of incoming standard control requests - * when the library is in USB device mode. - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -#ifndef __DEVICESTDREQ_H__ -#define __DEVICESTDREQ_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - #include "StdDescriptors.h" - #include "Events.h" - #include "StdRequestType.h" - #include "USBTask.h" - #include "USBController.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Enums: */ - #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__) - /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the - * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS - * compile time options are used, to indicate in which memory space the descriptor is stored. - * - * \ingroup Group_Device - */ - enum USB_DescriptorMemorySpaces_t - { - #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__) - MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory. */ - #endif - #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__) - MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */ - #endif - MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory. */ - }; - #endif - - /* Global Variables: */ - /** Indicates the currently set configuration number of the device. USB devices may have several - * different configurations which the host can select between; this indicates the currently selected - * value, or 0 if no configuration has been selected. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - * - * \ingroup Group_Device - */ - extern uint8_t USB_Device_ConfigurationNumber; - - #if !defined(NO_DEVICE_REMOTE_WAKEUP) - /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this - * flag is cleared, the device should not issue remote wakeup events to the host. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - * \n\n - * - * \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported, - * this global and the underlying management code can be disabled by defining the - * \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via - * the -D switch. - * - * \ingroup Group_Device - */ - extern bool USB_Device_RemoteWakeupEnabled; - #endif - - #if !defined(NO_DEVICE_SELF_POWER) - /** Indicates if the device is currently being powered by its own power supply, rather than being - * powered by the host's USB supply. This flag should remain cleared if the device does not - * support self powered mode, as indicated in the device descriptors. - * - * \ingroup Group_Device - */ - extern bool USB_Device_CurrentlySelfPowered; - #endif - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) - #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. - #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS) - #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive. - #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) - #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. - #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS) - #error Only one of the USE_*_DESCRIPTORS modes should be selected. - #endif - - /* Function Prototypes: */ - void USB_Device_ProcessControlRequest(void); - - #if defined(__INCLUDE_FROM_DEVICESTDREQ_C) - static void USB_Device_SetAddress(void); - static void USB_Device_SetConfiguration(void); - static void USB_Device_GetConfiguration(void); - static void USB_Device_GetDescriptor(void); - static void USB_Device_GetStatus(void); - static void USB_Device_ClearSetFeature(void); - - #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) - static void USB_Device_GetInternalSerialDescriptor(void); - #endif - #endif - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB device standard request management. + * + * This file contains the function prototypes necessary for the processing of incoming standard control requests + * when the library is in USB device mode. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __DEVICESTDREQ_H__ +#define __DEVICESTDREQ_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "StdDescriptors.h" + #include "Events.h" + #include "StdRequestType.h" + #include "USBTask.h" + #include "USBController.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__) + /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the + * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS + * compile time options are used, to indicate in which memory space the descriptor is stored. + * + * \ingroup Group_Device + */ + enum USB_DescriptorMemorySpaces_t + { + #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__) + MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory. */ + #endif + #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__) + MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */ + #endif + MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory. */ + }; + #endif + + /* Global Variables: */ + /** Indicates the currently set configuration number of the device. USB devices may have several + * different configurations which the host can select between; this indicates the currently selected + * value, or 0 if no configuration has been selected. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \ingroup Group_Device + */ + extern uint8_t USB_Device_ConfigurationNumber; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this + * flag is cleared, the device should not issue remote wakeup events to the host. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + * \n\n + * + * \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported, + * this global and the underlying management code can be disabled by defining the + * \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via + * the -D switch. + * + * \ingroup Group_Device + */ + extern bool USB_Device_RemoteWakeupEnabled; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + /** Indicates if the device is currently being powered by its own power supply, rather than being + * powered by the host's USB supply. This flag should remain cleared if the device does not + * support self powered mode, as indicated in the device descriptors. + * + * \ingroup Group_Device + */ + extern bool USB_Device_CurrentlySelfPowered; + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) + #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS) + #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive. + #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) + #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS) + #error Only one of the USE_*_DESCRIPTORS modes should be selected. + #endif + + /* Function Prototypes: */ + void USB_Device_ProcessControlRequest(void); + + #if defined(__INCLUDE_FROM_DEVICESTDREQ_C) + static void USB_Device_SetAddress(void); + static void USB_Device_SetConfiguration(void); + static void USB_Device_GetConfiguration(void); + static void USB_Device_GetDescriptor(void); + static void USB_Device_GetStatus(void); + static void USB_Device_ClearSetFeature(void); + + #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + static void USB_Device_GetInternalSerialDescriptor(void); + #endif + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/Endpoint.h b/hal/at90usb646/LUFA/Drivers/USB/Core/Endpoint.h index b0f92f4..1fcc6b6 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/Endpoint.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/Endpoint.h @@ -1,118 +1,118 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Endpoint definitions for all architectures. - * \copydetails Group_EndpointManagement - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_EndpointManagement - * \defgroup Group_EndpointRW Endpoint Data Reading and Writing - * \brief Endpoint data read/write definitions. - * - * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. - */ - -/** \ingroup Group_EndpointRW - * \defgroup Group_EndpointPrimitiveRW Read/Write of Primitive Data Types - * \brief Endpoint data primitive read/write definitions. - * - * Functions, macros, variables, enums and types related to data reading and writing of primitive data types - * from and to endpoints. - */ - -/** \ingroup Group_EndpointManagement - * \defgroup Group_EndpointPacketManagement Endpoint Packet Management - * \brief USB Endpoint package management definitions. - * - * Functions, macros, variables, enums and types related to packet management of endpoints. - */ - -/** \ingroup Group_USB - * \defgroup Group_EndpointManagement Endpoint Management - * \brief Endpoint management definitions. - * - * Functions, macros and enums related to endpoint management when in USB Device mode. This - * module contains the endpoint management macros, as well as endpoint interrupt and data - * send/receive functions for various data types. - * - * @{ - */ - -#ifndef __ENDPOINT_H__ -#define __ENDPOINT_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's - * numerical address in the device. - */ - #define ENDPOINT_EPNUM_MASK 0x0F - - /** Endpoint address for the default control endpoint, which always resides in address 0. This is - * defined for convenience to give more readable code when used with the endpoint macros. - */ - #define ENDPOINT_CONTROLEP 0 - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/Endpoint_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/Endpoint_UC3.h" - #elif (ARCH == ARCH_XMEGA) - #include "XMEGA/Endpoint_XMEGA.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Endpoint definitions for all architectures. + * \copydetails Group_EndpointManagement + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointRW Endpoint Data Reading and Writing + * \brief Endpoint data read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointPrimitiveRW Read/Write of Primitive Data Types + * \brief Endpoint data primitive read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to endpoints. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointPacketManagement Endpoint Packet Management + * \brief USB Endpoint package management definitions. + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_USB + * \defgroup Group_EndpointManagement Endpoint Management + * \brief Endpoint management definitions. + * + * Functions, macros and enums related to endpoint management when in USB Device mode. This + * module contains the endpoint management macros, as well as endpoint interrupt and data + * send/receive functions for various data types. + * + * @{ + */ + +#ifndef __ENDPOINT_H__ +#define __ENDPOINT_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's + * numerical address in the device. + */ + #define ENDPOINT_EPNUM_MASK 0x0F + + /** Endpoint address for the default control endpoint, which always resides in address 0. This is + * defined for convenience to give more readable code when used with the endpoint macros. + */ + #define ENDPOINT_CONTROLEP 0 + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Endpoint_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Endpoint_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/Endpoint_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/EndpointStream.h b/hal/at90usb646/LUFA/Drivers/USB/Core/EndpointStream.h index 89df381..236590d 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/EndpointStream.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/EndpointStream.h @@ -1,124 +1,124 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Endpoint data stream transmission and reception management. - * \copydetails Group_EndpointStreamRW - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_EndpointRW - * \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams - * \brief Endpoint data stream transmission and reception management. - * - * Functions, macros, variables, enums and types related to data reading and writing of data streams from - * and to endpoints. - * - * @{ - */ - -#ifndef __ENDPOINT_STREAM_H__ -#define __ENDPOINT_STREAM_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Enums: */ - /** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */ - enum Endpoint_Stream_RW_ErrorCodes_t - { - ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */ - ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream - * transfer by the host or device. - */ - ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during - * the transfer. - */ - ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and - * no USB endpoint traffic can occur until the bus - * has resumed. - */ - ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet - * within the software timeout period set by the - * \ref USB_STREAM_TIMEOUT_MS macro. - */ - ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before - * the complete contents of the current stream could be - * transferred. The endpoint stream function should be called - * again to process the next chunk of data in the transfer. - */ - }; - - /** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */ - enum Endpoint_ControlStream_RW_ErrorCodes_t - { - ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */ - ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */ - ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during - * the transfer. - */ - ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and - * no USB endpoint traffic can occur until the bus - * has resumed. - */ - }; - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/EndpointStream_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/EndpointStream_UC3.h" - #elif (ARCH == ARCH_XMEGA) - #include "XMEGA/EndpointStream_XMEGA.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endpoint data stream transmission and reception management. + * \copydetails Group_EndpointStreamRW + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams + * \brief Endpoint data stream transmission and reception management. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to endpoints. + * + * @{ + */ + +#ifndef __ENDPOINT_STREAM_H__ +#define __ENDPOINT_STREAM_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */ + enum Endpoint_Stream_RW_ErrorCodes_t + { + ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */ + ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream + * transfer by the host or device. + */ + ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during + * the transfer. + */ + ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before + * the complete contents of the current stream could be + * transferred. The endpoint stream function should be called + * again to process the next chunk of data in the transfer. + */ + }; + + /** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */ + enum Endpoint_ControlStream_RW_ErrorCodes_t + { + ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */ + ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */ + ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during + * the transfer. + */ + ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + }; + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/EndpointStream_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/EndpointStream_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/EndpointStream_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/Events.c b/hal/at90usb646/LUFA/Drivers/USB/Core/Events.c index b6a7cbf..5733aa8 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/Events.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/Events.c @@ -1,39 +1,39 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_EVENTS_C -#define __INCLUDE_FROM_USB_DRIVER -#include "Events.h" - -void USB_Event_Stub(void) -{ - -} - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_EVENTS_C +#define __INCLUDE_FROM_USB_DRIVER +#include "Events.h" + +void USB_Event_Stub(void) +{ + +} + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/Events.h b/hal/at90usb646/LUFA/Drivers/USB/Core/Events.h index 711e75f..2fff440 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/Events.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/Events.h @@ -1,366 +1,366 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB Event management definitions. - * \copydetails Group_Events - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_Events USB Events - * \brief USB Event management definitions. - * - * This module contains macros and functions relating to the management of library events, which are small - * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from - * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler - * should be written to be as small and fast as possible to prevent possible problems. - * - * Events can be hooked by the user application by declaring a handler function with the same name and parameters - * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an - * internal empty stub function. - * - * Each event must only have one associated event handler, but can be raised by multiple sources by calling the - * event handler function (with any required event parameters). - * - * @{ - */ - -#ifndef __USBEVENTS_H__ -#define __USBEVENTS_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Pseudo-Functions for Doxygen: */ - #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__) - /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role - * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires - * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect - * event has fired (if disconnected before the role change). - * - * \note This event only exists on microcontrollers that support dual role USB modes. - * \n\n - * - * \note This event does not exist if the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY tokens have been supplied - * to the compiler (see \ref Group_USBManagement documentation). - */ - void EVENT_USB_UIDChange(void); - - /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB - * interface is in host mode. - * - * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t. - * - * \note This event only exists on microcontrollers that supports USB host mode. - * \n\n - * - * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - */ - void EVENT_USB_Host_HostError(const uint8_t ErrorCode); - - /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and - * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before - * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB - * management task to reduce CPU consumption. - * - * \note This event only exists on microcontrollers that supports USB host mode. - * \n\n - * - * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - * - * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. - */ - void EVENT_USB_Host_DeviceAttached(void); - - /** Event for USB device removal. This event fires when a the USB interface is in host mode, and - * a USB device has been removed the USB interface whether or not it has been enumerated. This - * can be used to programmatically stop the USB management task to reduce CPU consumption. - * - * \note This event only exists on microcontrollers that supports USB host mode. - * \n\n - * - * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - * - * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. - */ - void EVENT_USB_Host_DeviceUnattached(void); - - /** Event for USB device enumeration failure. This event fires when a the USB interface is - * in host mode, and an attached USB device has failed to enumerate completely. - * - * \param[in] ErrorCode Error code indicating the failure reason, a value in - * \ref USB_Host_EnumerationErrorCodes_t. - * - * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the - * ErrorCode parameter indicates a control error, this will give the error - * code returned by the \ref USB_Host_SendControlRequest() function. - * - * \note This event only exists on microcontrollers that supports USB host mode. - * \n\n - * - * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - */ - void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, - const uint8_t SubErrorCode); - - /** Event for USB device enumeration completion. This event fires when a the USB interface is - * in host mode and an attached USB device has been completely enumerated and is ready to be - * controlled by the user application. - * - * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around - * 1 second) when a transaction is waiting to be processed by the device will prevent break communications - * and cause the host to reset the USB bus. - */ - void EVENT_USB_Host_DeviceEnumerationComplete(void); - - /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB - * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate - * millisecond timer source when the USB bus is not suspended while in host mode. - * - * This event is time-critical; it is run once per millisecond and thus long handlers will significantly - * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. - * - * \note This event is not normally active - it must be manually enabled and disabled via the - * \ref USB_Host_EnableSOFEvents() and \ref USB_Host_DisableSOFEvents() commands after enumeration of - * a USB device. - * \n\n - * - * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - */ - void EVENT_USB_Host_StartOfFrame(void); - - /** Event for USB device connection. This event fires when the microcontroller is in USB Device mode - * and the device is connected to a USB host, beginning the enumeration process measured by a rising - * level on the microcontroller's VBUS sense pin. - * - * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around - * two seconds) will prevent the device from enumerating correctly. - * - * \note For the microcontrollers with limited USB controller functionality, VBUS sensing is not available. - * this means that the current connection state is derived from the bus suspension and wake up events by default, - * which is not always accurate (host may suspend the bus while still connected). If the actual connection state - * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by - * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection - * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. - * \n\n - * - * \note This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers - * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. - * - * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. - */ - void EVENT_USB_Device_Connect(void); - - /** Event for USB device disconnection. This event fires when the microcontroller is in USB Device mode and the device is - * disconnected from a host, measured by a falling level on the microcontroller's VBUS sense pin. - * - * \note For the microcontrollers with limited USB controllers, VBUS sense is not available to the USB controller. - * this means that the current connection state is derived from the bus suspension and wake up events by default, - * which is not always accurate (host may suspend the bus while still connected). If the actual connection state - * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by - * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection - * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. - * \n\n - * - * \note This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers - * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. - * - * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. - */ - void EVENT_USB_Device_Disconnect(void); - - /** Event for control requests. This event fires when a the USB host issues a control request - * to the mandatory device control endpoint (of address 0). This may either be a standard - * request that the library may have a handler code for internally, or a class specific request - * issued to the device which must be handled appropriately. If a request is not processed in the - * user application via this event, it will be passed to the library for processing internally - * if a suitable handler exists. - * - * This event is time-critical; each packet within the request transaction must be acknowledged or - * sent within 50ms or the host will abort the transfer. - * - * The library internally handles all standard control requests with the exceptions of SYNC FRAME, - * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left - * for the user to process via this event if desired. If not handled in the user application or by - * the library internally, unknown requests are automatically STALLed. - * - * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - * \n\n - * - * \note Requests should be handled in the same manner as described in the USB 2.0 Specification, - * or appropriate class specification. In all instances, the library has already read the - * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used - * by the application to determine how to handle the issued request. - */ - void EVENT_USB_Device_ControlRequest(void); - - /** Event for USB configuration number changed. This event fires when a the USB host changes the - * selected configuration number while in device mode. This event should be hooked in device - * applications to create the endpoints and configure the device for the selected configuration. - * - * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around - * one second) will prevent the device from enumerating correctly. - * - * This event fires after the value of \ref USB_Device_ConfigurationNumber has been changed. - * - * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - */ - void EVENT_USB_Device_ConfigurationChanged(void); - - /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its - * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move - * the device over to a low power state until the host wakes up the device. If the USB interface is - * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the - * USB PLL before the event is fired to save power. - * - * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - * \n\n - * - * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities - * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see - * \ref EVENT_USB_Device_Disconnect. - * - * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event. - */ - void EVENT_USB_Device_Suspend(void); - - /** Event for USB wake up. This event fires when a the USB interface is suspended while in device - * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally - * hooked to pull the user application out of a low power state and back into normal operating - * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library - * will automatically restart the USB PLL before the event is fired. - * - * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - * \n\n - * - * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities - * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see - * \ref EVENT_USB_Device_Disconnect. - * - * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event. - */ - void EVENT_USB_Device_WakeUp(void); - - /** Event for USB interface reset. This event fires when the USB interface is in device mode, and - * a the USB host requests that the device reset its interface. This event fires after the control - * endpoint has been automatically configured by the library. - * - * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around - * two seconds) will prevent the device from enumerating correctly. - * - * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - */ - void EVENT_USB_Device_Reset(void); - - /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB - * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate - * millisecond timer source when the USB bus is enumerated in device mode to a USB host. - * - * This event is time-critical; it is run once per millisecond and thus long handlers will significantly - * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. - * - * \pre This event is not normally active - it must be manually enabled and disabled via the - * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration. - * \n\n - * - * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see - * \ref Group_USBManagement documentation). - */ - void EVENT_USB_Device_StartOfFrame(void); - #endif - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Function Prototypes: */ - #if defined(__INCLUDE_FROM_EVENTS_C) - void USB_Event_Stub(void) ATTR_CONST; - - #if defined(USB_CAN_BE_BOTH) - void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - #endif - - #if defined(USB_CAN_BE_HOST) - void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, - const uint8_t SubErrorCode) - ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Host_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - #endif - - #if defined(USB_CAN_BE_DEVICE) - void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_ControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - #endif - #endif - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Event management definitions. + * \copydetails Group_Events + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_Events USB Events + * \brief USB Event management definitions. + * + * This module contains macros and functions relating to the management of library events, which are small + * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from + * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler + * should be written to be as small and fast as possible to prevent possible problems. + * + * Events can be hooked by the user application by declaring a handler function with the same name and parameters + * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an + * internal empty stub function. + * + * Each event must only have one associated event handler, but can be raised by multiple sources by calling the + * event handler function (with any required event parameters). + * + * @{ + */ + +#ifndef __USBEVENTS_H__ +#define __USBEVENTS_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Pseudo-Functions for Doxygen: */ + #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__) + /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role + * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires + * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect + * event has fired (if disconnected before the role change). + * + * \note This event only exists on microcontrollers that support dual role USB modes. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY tokens have been supplied + * to the compiler (see \ref Group_USBManagement documentation). + */ + void EVENT_USB_UIDChange(void); + + /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB + * interface is in host mode. + * + * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); + + /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and + * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before + * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB + * management task to reduce CPU consumption. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * + * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Host_DeviceAttached(void); + + /** Event for USB device removal. This event fires when a the USB interface is in host mode, and + * a USB device has been removed the USB interface whether or not it has been enumerated. This + * can be used to programmatically stop the USB management task to reduce CPU consumption. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * + * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Host_DeviceUnattached(void); + + /** Event for USB device enumeration failure. This event fires when a the USB interface is + * in host mode, and an attached USB device has failed to enumerate completely. + * + * \param[in] ErrorCode Error code indicating the failure reason, a value in + * \ref USB_Host_EnumerationErrorCodes_t. + * + * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the + * ErrorCode parameter indicates a control error, this will give the error + * code returned by the \ref USB_Host_SendControlRequest() function. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, + const uint8_t SubErrorCode); + + /** Event for USB device enumeration completion. This event fires when a the USB interface is + * in host mode and an attached USB device has been completely enumerated and is ready to be + * controlled by the user application. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * 1 second) when a transaction is waiting to be processed by the device will prevent break communications + * and cause the host to reset the USB bus. + */ + void EVENT_USB_Host_DeviceEnumerationComplete(void); + + /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB + * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate + * millisecond timer source when the USB bus is not suspended while in host mode. + * + * This event is time-critical; it is run once per millisecond and thus long handlers will significantly + * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. + * + * \note This event is not normally active - it must be manually enabled and disabled via the + * \ref USB_Host_EnableSOFEvents() and \ref USB_Host_DisableSOFEvents() commands after enumeration of + * a USB device. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_StartOfFrame(void); + + /** Event for USB device connection. This event fires when the microcontroller is in USB Device mode + * and the device is connected to a USB host, beginning the enumeration process measured by a rising + * level on the microcontroller's VBUS sense pin. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * two seconds) will prevent the device from enumerating correctly. + * + * \note For the microcontrollers with limited USB controller functionality, VBUS sensing is not available. + * this means that the current connection state is derived from the bus suspension and wake up events by default, + * which is not always accurate (host may suspend the bus while still connected). If the actual connection state + * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by + * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection + * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. + * \n\n + * + * \note This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers + * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. + * + * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Device_Connect(void); + + /** Event for USB device disconnection. This event fires when the microcontroller is in USB Device mode and the device is + * disconnected from a host, measured by a falling level on the microcontroller's VBUS sense pin. + * + * \note For the microcontrollers with limited USB controllers, VBUS sense is not available to the USB controller. + * this means that the current connection state is derived from the bus suspension and wake up events by default, + * which is not always accurate (host may suspend the bus while still connected). If the actual connection state + * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by + * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection + * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. + * \n\n + * + * \note This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers + * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. + * + * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Device_Disconnect(void); + + /** Event for control requests. This event fires when a the USB host issues a control request + * to the mandatory device control endpoint (of address 0). This may either be a standard + * request that the library may have a handler code for internally, or a class specific request + * issued to the device which must be handled appropriately. If a request is not processed in the + * user application via this event, it will be passed to the library for processing internally + * if a suitable handler exists. + * + * This event is time-critical; each packet within the request transaction must be acknowledged or + * sent within 50ms or the host will abort the transfer. + * + * The library internally handles all standard control requests with the exceptions of SYNC FRAME, + * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left + * for the user to process via this event if desired. If not handled in the user application or by + * the library internally, unknown requests are automatically STALLed. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note Requests should be handled in the same manner as described in the USB 2.0 Specification, + * or appropriate class specification. In all instances, the library has already read the + * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used + * by the application to determine how to handle the issued request. + */ + void EVENT_USB_Device_ControlRequest(void); + + /** Event for USB configuration number changed. This event fires when a the USB host changes the + * selected configuration number while in device mode. This event should be hooked in device + * applications to create the endpoints and configure the device for the selected configuration. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * one second) will prevent the device from enumerating correctly. + * + * This event fires after the value of \ref USB_Device_ConfigurationNumber has been changed. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Device_ConfigurationChanged(void); + + /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its + * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move + * the device over to a low power state until the host wakes up the device. If the USB interface is + * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the + * USB PLL before the event is fired to save power. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities + * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see + * \ref EVENT_USB_Device_Disconnect. + * + * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event. + */ + void EVENT_USB_Device_Suspend(void); + + /** Event for USB wake up. This event fires when a the USB interface is suspended while in device + * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally + * hooked to pull the user application out of a low power state and back into normal operating + * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library + * will automatically restart the USB PLL before the event is fired. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities + * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see + * \ref EVENT_USB_Device_Disconnect. + * + * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event. + */ + void EVENT_USB_Device_WakeUp(void); + + /** Event for USB interface reset. This event fires when the USB interface is in device mode, and + * a the USB host requests that the device reset its interface. This event fires after the control + * endpoint has been automatically configured by the library. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * two seconds) will prevent the device from enumerating correctly. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Device_Reset(void); + + /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB + * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate + * millisecond timer source when the USB bus is enumerated in device mode to a USB host. + * + * This event is time-critical; it is run once per millisecond and thus long handlers will significantly + * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. + * + * \pre This event is not normally active - it must be manually enabled and disabled via the + * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration. + * \n\n + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Device_StartOfFrame(void); + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_EVENTS_C) + void USB_Event_Stub(void) ATTR_CONST; + + #if defined(USB_CAN_BE_BOTH) + void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + #endif + + #if defined(USB_CAN_BE_HOST) + void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, + const uint8_t SubErrorCode) + ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + #endif + + #if defined(USB_CAN_BE_DEVICE) + void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_ControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + #endif + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/Host.h b/hal/at90usb646/LUFA/Drivers/USB/Core/Host.h index bf2225f..dd9983d 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/Host.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/Host.h @@ -1,139 +1,139 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common USB Host definitions for all architectures. - * \copydetails Group_Host - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_Host Host Management - * \brief USB Host management definitions for USB host mode. - * - * USB Host mode related macros and enums. This module contains macros and enums which are used when - * the USB controller is initialized in host mode. - * - * @{ - */ - -#ifndef __USBHOST_H__ -#define __USBHOST_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Enums: */ - /** Enum for the various states of the USB Host state machine. - * - * For information on each possible USB host state, refer to the USB 2.0 specification. - * Several of the USB host states are broken up further into multiple smaller sub-states, - * so that they can be internally implemented inside the library in an efficient manner. - * - * \see \ref USB_HostState, which stores the current host state machine state. - */ - enum USB_Host_States_t - { - HOST_STATE_WaitForDevice = 0, /**< This state indicates that the stack is waiting for an interval - * to elapse before continuing with the next step of the device - * enumeration process. - */ - HOST_STATE_Unattached = 1, /**< This state indicates that the host state machine is waiting for - * a device to be attached so that it can start the enumeration process. - */ - HOST_STATE_Powered = 2, /**< This state indicates that a device has been attached, and the - * library's internals are being configured to begin the enumeration - * process. - */ - HOST_STATE_Powered_WaitForDeviceSettle = 3, /**< This state indicates that the stack is waiting for the initial - * settling period to elapse before beginning the enumeration process. - */ - HOST_STATE_Powered_WaitForConnect = 4, /**< This state indicates that the stack is waiting for a connection event - * from the USB controller to indicate a valid USB device has been attached - * to the bus and is ready to be enumerated. - */ - HOST_STATE_Powered_DoReset = 5, /**< This state indicates that a valid USB device has been attached, and that - * it will now be reset to ensure it is ready for enumeration. - */ - HOST_STATE_Powered_ConfigPipe = 6, /**< This state indicates that the attached device is currently powered and - * reset, and that the control pipe is now being configured by the stack. - */ - HOST_STATE_Default = 7, /**< This state indicates that the stack is currently retrieving the control - * endpoint's size from the device, so that the control pipe can be altered - * to match. - */ - HOST_STATE_Default_PostReset = 8, /**< This state indicates that the control pipe is being reconfigured to match - * the retrieved control endpoint size from the device, and the device's USB - * bus address is being set. - */ - HOST_STATE_Default_PostAddressSet = 9, /**< This state indicates that the device's address has now been set, and the - * stack is has now completed the device enumeration process. This state causes - * the stack to change the current USB device address to that set for the - * connected device, before progressing to the \ref HOST_STATE_Addressed state - * ready for use in the user application. - */ - HOST_STATE_Addressed = 10, /**< Indicates that the device has been enumerated and addressed, and is now waiting - * for the user application to configure the device ready for use. - */ - HOST_STATE_Configured = 11, /**< Indicates that the device has been configured into a valid device configuration, - * ready for general use by the user application. - */ - }; - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/Host_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/Host_UC3.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Host definitions for all architectures. + * \copydetails Group_Host + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_Host Host Management + * \brief USB Host management definitions for USB host mode. + * + * USB Host mode related macros and enums. This module contains macros and enums which are used when + * the USB controller is initialized in host mode. + * + * @{ + */ + +#ifndef __USBHOST_H__ +#define __USBHOST_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the various states of the USB Host state machine. + * + * For information on each possible USB host state, refer to the USB 2.0 specification. + * Several of the USB host states are broken up further into multiple smaller sub-states, + * so that they can be internally implemented inside the library in an efficient manner. + * + * \see \ref USB_HostState, which stores the current host state machine state. + */ + enum USB_Host_States_t + { + HOST_STATE_WaitForDevice = 0, /**< This state indicates that the stack is waiting for an interval + * to elapse before continuing with the next step of the device + * enumeration process. + */ + HOST_STATE_Unattached = 1, /**< This state indicates that the host state machine is waiting for + * a device to be attached so that it can start the enumeration process. + */ + HOST_STATE_Powered = 2, /**< This state indicates that a device has been attached, and the + * library's internals are being configured to begin the enumeration + * process. + */ + HOST_STATE_Powered_WaitForDeviceSettle = 3, /**< This state indicates that the stack is waiting for the initial + * settling period to elapse before beginning the enumeration process. + */ + HOST_STATE_Powered_WaitForConnect = 4, /**< This state indicates that the stack is waiting for a connection event + * from the USB controller to indicate a valid USB device has been attached + * to the bus and is ready to be enumerated. + */ + HOST_STATE_Powered_DoReset = 5, /**< This state indicates that a valid USB device has been attached, and that + * it will now be reset to ensure it is ready for enumeration. + */ + HOST_STATE_Powered_ConfigPipe = 6, /**< This state indicates that the attached device is currently powered and + * reset, and that the control pipe is now being configured by the stack. + */ + HOST_STATE_Default = 7, /**< This state indicates that the stack is currently retrieving the control + * endpoint's size from the device, so that the control pipe can be altered + * to match. + */ + HOST_STATE_Default_PostReset = 8, /**< This state indicates that the control pipe is being reconfigured to match + * the retrieved control endpoint size from the device, and the device's USB + * bus address is being set. + */ + HOST_STATE_Default_PostAddressSet = 9, /**< This state indicates that the device's address has now been set, and the + * stack is has now completed the device enumeration process. This state causes + * the stack to change the current USB device address to that set for the + * connected device, before progressing to the \ref HOST_STATE_Addressed state + * ready for use in the user application. + */ + HOST_STATE_Addressed = 10, /**< Indicates that the device has been enumerated and addressed, and is now waiting + * for the user application to configure the device ready for use. + */ + HOST_STATE_Configured = 11, /**< Indicates that the device has been configured into a valid device configuration, + * ready for general use by the user application. + */ + }; + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Host_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Host_UC3.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.c b/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.c index d5378d2..649ad5e 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.c @@ -1,316 +1,316 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USB_DRIVER -#include "USBMode.h" - -#if defined(USB_CAN_BE_HOST) - -#define __INCLUDE_FROM_HOSTSTDREQ_C -#include "HostStandardReq.h" - -uint8_t USB_Host_ConfigurationNumber; - -uint8_t USB_Host_SendControlRequest(void* const BufferPtr) -{ - uint8_t* DataStream = (uint8_t*)BufferPtr; - bool BusSuspended = USB_Host_IsBusSuspended(); - uint8_t ReturnStatus = HOST_SENDCONTROL_Successful; - uint16_t DataLen = USB_ControlRequest.wLength; - - USB_Host_ResumeBus(); - - if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) - goto End_Of_Control_Send; - - Pipe_SetPipeToken(PIPE_TOKEN_SETUP); - Pipe_ClearError(); - - Pipe_Unfreeze(); - - #if defined(ARCH_BIG_ENDIAN) - Pipe_Write_8(USB_ControlRequest.bmRequestType); - Pipe_Write_8(USB_ControlRequest.bRequest); - Pipe_Write_16_LE(USB_ControlRequest.wValue); - Pipe_Write_16_LE(USB_ControlRequest.wIndex); - Pipe_Write_16_LE(USB_ControlRequest.wLength); - #else - uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest; - - for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Request_Header_t); HeaderByte++) - Pipe_Write_8(*(HeaderStream++)); - #endif - - Pipe_ClearSETUP(); - - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - - Pipe_Freeze(); - - if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) - goto End_Of_Control_Send; - - if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST) - { - Pipe_SetPipeToken(PIPE_TOKEN_IN); - - if (DataStream != NULL) - { - while (DataLen) - { - Pipe_Unfreeze(); - - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - - if (!(Pipe_BytesInPipe())) - DataLen = 0; - - while (Pipe_BytesInPipe() && DataLen) - { - *(DataStream++) = Pipe_Read_8(); - DataLen--; - } - - Pipe_Freeze(); - Pipe_ClearIN(); - } - } - - Pipe_SetPipeToken(PIPE_TOKEN_OUT); - Pipe_Unfreeze(); - - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - - Pipe_ClearOUT(); - - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - } - else - { - if (DataStream != NULL) - { - Pipe_SetPipeToken(PIPE_TOKEN_OUT); - Pipe_Unfreeze(); - - while (DataLen) - { - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - - while (DataLen && (Pipe_BytesInPipe() < USB_Host_ControlPipeSize)) - { - Pipe_Write_8(*(DataStream++)); - DataLen--; - } - - Pipe_ClearOUT(); - } - - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - - Pipe_Freeze(); - } - - Pipe_SetPipeToken(PIPE_TOKEN_IN); - Pipe_Unfreeze(); - - if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful) - goto End_Of_Control_Send; - - Pipe_ClearIN(); - } - -End_Of_Control_Send: - Pipe_Freeze(); - - if (BusSuspended) - USB_Host_SuspendBus(); - - Pipe_ResetPipe(PIPE_CONTROLPIPE); - - return ReturnStatus; -} - -static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType) -{ - #if (USB_HOST_TIMEOUT_MS < 0xFF) - uint8_t TimeoutCounter = USB_HOST_TIMEOUT_MS; - #else - uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS; - #endif - - while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSETUPSent()) || - ((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsINReceived()) || - ((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsOUTReady()))) - { - uint8_t ErrorCode; - - if ((ErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) - return ErrorCode; - - if (!(TimeoutCounter--)) - return HOST_SENDCONTROL_SoftwareTimeOut; - } - - return HOST_SENDCONTROL_Successful; -} - -uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) -{ - uint8_t ErrorCode; - - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_SetConfiguration, - .wValue = ConfigNumber, - .wIndex = 0, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - if ((ErrorCode = USB_Host_SendControlRequest(NULL)) == HOST_SENDCONTROL_Successful) - { - USB_Host_ConfigurationNumber = ConfigNumber; - USB_HostState = (ConfigNumber) ? HOST_STATE_Configured : HOST_STATE_Addressed; - } - - return ErrorCode; -} - -uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_GetConfiguration, - .wValue = 0, - .wIndex = 0, - .wLength = sizeof(uint8_t), - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(ConfigNumber); -} - -uint8_t USB_Host_GetDescriptor(const uint8_t Type, - const uint8_t Index, - void* const Buffer, - const uint8_t BufferLength) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_GetDescriptor, - .wValue = (((uint16_t)Type << 8) | Index), - .wIndex = 0, - .wLength = BufferLength, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(Buffer); -} - -uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), - .bRequest = REQ_GetStatus, - .wValue = 0, - .wIndex = 0, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(FeatureStatus); -} - -uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT), - .bRequest = REQ_ClearFeature, - .wValue = FEATURE_SEL_EndpointHalt, - .wIndex = EndpointAddress, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(NULL); -} - -uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, - const uint8_t AltSetting) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), - .bRequest = REQ_SetInterface, - .wValue = AltSetting, - .wIndex = InterfaceIndex, - .wLength = 0, - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(NULL); -} - -uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, - uint8_t* const AltSetting) -{ - USB_ControlRequest = (USB_Request_Header_t) - { - .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), - .bRequest = REQ_GetInterface, - .wValue = 0, - .wIndex = InterfaceIndex, - .wLength = sizeof(uint8_t), - }; - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - return USB_Host_SendControlRequest(AltSetting); -} - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HOSTSTDREQ_C +#include "HostStandardReq.h" + +uint8_t USB_Host_ConfigurationNumber; + +uint8_t USB_Host_SendControlRequest(void* const BufferPtr) +{ + uint8_t* DataStream = (uint8_t*)BufferPtr; + bool BusSuspended = USB_Host_IsBusSuspended(); + uint8_t ReturnStatus = HOST_SENDCONTROL_Successful; + uint16_t DataLen = USB_ControlRequest.wLength; + + USB_Host_ResumeBus(); + + if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + goto End_Of_Control_Send; + + Pipe_SetPipeToken(PIPE_TOKEN_SETUP); + Pipe_ClearError(); + + Pipe_Unfreeze(); + + #if defined(ARCH_BIG_ENDIAN) + Pipe_Write_8(USB_ControlRequest.bmRequestType); + Pipe_Write_8(USB_ControlRequest.bRequest); + Pipe_Write_16_LE(USB_ControlRequest.wValue); + Pipe_Write_16_LE(USB_ControlRequest.wIndex); + Pipe_Write_16_LE(USB_ControlRequest.wLength); + #else + uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest; + + for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Request_Header_t); HeaderByte++) + Pipe_Write_8(*(HeaderStream++)); + #endif + + Pipe_ClearSETUP(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + + Pipe_Freeze(); + + if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + goto End_Of_Control_Send; + + if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST) + { + Pipe_SetPipeToken(PIPE_TOKEN_IN); + + if (DataStream != NULL) + { + while (DataLen) + { + Pipe_Unfreeze(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + + if (!(Pipe_BytesInPipe())) + DataLen = 0; + + while (Pipe_BytesInPipe() && DataLen) + { + *(DataStream++) = Pipe_Read_8(); + DataLen--; + } + + Pipe_Freeze(); + Pipe_ClearIN(); + } + } + + Pipe_SetPipeToken(PIPE_TOKEN_OUT); + Pipe_Unfreeze(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + + Pipe_ClearOUT(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + } + else + { + if (DataStream != NULL) + { + Pipe_SetPipeToken(PIPE_TOKEN_OUT); + Pipe_Unfreeze(); + + while (DataLen) + { + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + + while (DataLen && (Pipe_BytesInPipe() < USB_Host_ControlPipeSize)) + { + Pipe_Write_8(*(DataStream++)); + DataLen--; + } + + Pipe_ClearOUT(); + } + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + + Pipe_Freeze(); + } + + Pipe_SetPipeToken(PIPE_TOKEN_IN); + Pipe_Unfreeze(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful) + goto End_Of_Control_Send; + + Pipe_ClearIN(); + } + +End_Of_Control_Send: + Pipe_Freeze(); + + if (BusSuspended) + USB_Host_SuspendBus(); + + Pipe_ResetPipe(PIPE_CONTROLPIPE); + + return ReturnStatus; +} + +static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType) +{ + #if (USB_HOST_TIMEOUT_MS < 0xFF) + uint8_t TimeoutCounter = USB_HOST_TIMEOUT_MS; + #else + uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS; + #endif + + while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSETUPSent()) || + ((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsINReceived()) || + ((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsOUTReady()))) + { + uint8_t ErrorCode; + + if ((ErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + return ErrorCode; + + if (!(TimeoutCounter--)) + return HOST_SENDCONTROL_SoftwareTimeOut; + } + + return HOST_SENDCONTROL_Successful; +} + +uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) +{ + uint8_t ErrorCode; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_SetConfiguration, + .wValue = ConfigNumber, + .wIndex = 0, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) == HOST_SENDCONTROL_Successful) + { + USB_Host_ConfigurationNumber = ConfigNumber; + USB_HostState = (ConfigNumber) ? HOST_STATE_Configured : HOST_STATE_Addressed; + } + + return ErrorCode; +} + +uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetConfiguration, + .wValue = 0, + .wIndex = 0, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(ConfigNumber); +} + +uint8_t USB_Host_GetDescriptor(const uint8_t Type, + const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetDescriptor, + .wValue = (((uint16_t)Type << 8) | Index), + .wIndex = 0, + .wLength = BufferLength, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Buffer); +} + +uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetStatus, + .wValue = 0, + .wIndex = 0, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(FeatureStatus); +} + +uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT), + .bRequest = REQ_ClearFeature, + .wValue = FEATURE_SEL_EndpointHalt, + .wIndex = EndpointAddress, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, + const uint8_t AltSetting) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_SetInterface, + .wValue = AltSetting, + .wIndex = InterfaceIndex, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, + uint8_t* const AltSetting) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_GetInterface, + .wValue = 0, + .wIndex = InterfaceIndex, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(AltSetting); +} + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.h b/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.h index 0692acc..d4f4187 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/HostStandardReq.h @@ -1,291 +1,291 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB host standard request management. - * - * This file contains the function prototypes necessary for the issuing of outgoing standard control requests - * when the library is in USB host mode. - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -#ifndef __HOSTSTDREQ_H__ -#define __HOSTSTDREQ_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - #include "StdRequestType.h" - #include "USBController.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__) - /** Constant for the maximum software timeout period of sent USB control transactions to an attached - * device. If a device fails to respond to a sent control request within this period, the - * library will return a timeout error code. - * - * This value may be overridden in the user project makefile as the value of the - * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch. - */ - #define USB_HOST_TIMEOUT_MS 1000 - #endif - - /* Enums: */ - /** Enum for the \ref USB_Host_SendControlRequest() return code, indicating the reason for the error - * if the transfer of the request is unsuccessful. - * - * \ingroup Group_PipeControlReq - */ - enum USB_Host_SendControlErrorCodes_t - { - HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */ - HOST_SENDCONTROL_DeviceDisconnected = 1, /**< The attached device was disconnected during the - * request transfer. - */ - HOST_SENDCONTROL_PipeError = 2, /**< An error occurred in the pipe while sending the request. */ - HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually - * indicating that the request is unsupported on the device. - */ - HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */ - }; - - /* Global Variables: */ - /** Indicates the currently set configuration number of the attached device. This indicates the currently - * selected configuration value if one has been set sucessfully, or 0 if no configuration has been selected. - * - * To set a device configuration, call the \ref USB_Host_SetDeviceConfiguration() function. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - * - * \ingroup Group_Host - */ - extern uint8_t USB_Host_ConfigurationNumber; - - /* Function Prototypes: */ - /** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device, - * and transfers the data stored in the buffer to the device, or from the device to the buffer - * as requested. The transfer is made on the currently selected pipe. - * - * \ingroup Group_PipeControlReq - * - * \param[in] BufferPtr Pointer to the start of the data buffer if the request has a data stage, or - * \c NULL if the request transfers no data to or from the device. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_SendControlRequest(void* const BufferPtr); - - /** Sends a SET CONFIGURATION standard request to the attached device, with the given configuration index. - * - * This routine will automatically update the \ref USB_HostState and \ref USB_Host_ConfigurationNumber - * state variables according to the given function parameters and the result of the request. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[in] ConfigNumber Configuration index to send to the device. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber); - - /** Sends a GET CONFIGURATION standard request to the attached device, to retrieve the currently selected - * device configuration index. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[out] ConfigNumber Pointer to a location where the retrieved configuration index should be stored. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) ATTR_NON_NULL_PTR_ARG(1); - - /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the descriptor of the - * specified type and index. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[in] Type Type of descriptor to retrieve, a value from the \ref USB_DescriptorTypes_t enum. - * \param[in] Index Index of the descriptor to retrieve. - * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is to be stored. - * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_GetDescriptor(const uint8_t Type, - const uint8_t Index, - void* const Buffer, - const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(3); - - /** Retrieves the current feature status of the attached device, via a GET STATUS standard request. The - * retrieved feature status can then be examined by masking the retrieved value with the various - * \c FEATURE_* masks for bus/self power information and remote wakeup support. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[out] FeatureStatus Location where the retrieved feature status should be stored. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) ATTR_NON_NULL_PTR_ARG(1); - - /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[in] EndpointAddress Address of the endpoint to clear, including the endpoint's direction. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress); - - /** Selects a given alternative setting for the specified interface, via a SET INTERFACE standard request to - * the attached device. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. - * \param[in] AltSetting Index of the interface's alternative setting which is to be selected. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, - const uint8_t AltSetting); - - - /** Retrieves the current alternative setting for the specified interface, via a GET INTERFACE standard request to - * the attached device. - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. - * \param[out] AltSetting Pointer to a location where the retrieved alternative setting value should be stored. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, - uint8_t* const AltSetting) ATTR_NON_NULL_PTR_ARG(2); - - /* Inline Functions: */ - /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the device descriptor. - * This can be used to easily retrieve information about the device such as its VID, PID and power - * requirements. This is a convenience wrapper for \ref USB_Host_GetDescriptor(). - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where - * the read data is to be stored. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) ATTR_NON_NULL_PTR_ARG(1); - static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) - { - return USB_Host_GetDescriptor(DTYPE_Device, 0, DeviceDescriptorPtr, sizeof(USB_Descriptor_Device_t)); - } - - /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the string descriptor - * of the specified index. This can be used to easily retrieve string descriptors from the device by - * index, after the index is obtained from the Device or Configuration descriptors. This is a convenience - * wrapper for \ref USB_Host_GetDescriptor(). - * - * \note After this routine returns, the control pipe will be selected. - * - * \ingroup Group_PipeControlReq - * - * \param[in] Index Index of the string descriptor to retrieve. - * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is - * to be stored. - * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. - * - * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. - */ - static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, - void* const Buffer, - const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(2); - static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, - void* const Buffer, - const uint8_t BufferLength) - { - return USB_Host_GetDescriptor(DTYPE_String, Index, Buffer, BufferLength); - } - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Enums: */ - enum USB_WaitForTypes_t - { - USB_HOST_WAITFOR_SetupSent, - USB_HOST_WAITFOR_InReceived, - USB_HOST_WAITFOR_OutReady, - }; - - /* Function Prototypes: */ - #if defined(__INCLUDE_FROM_HOSTSTDREQ_C) - static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType); - #endif - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB host standard request management. + * + * This file contains the function prototypes necessary for the issuing of outgoing standard control requests + * when the library is in USB host mode. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __HOSTSTDREQ_H__ +#define __HOSTSTDREQ_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "StdRequestType.h" + #include "USBController.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__) + /** Constant for the maximum software timeout period of sent USB control transactions to an attached + * device. If a device fails to respond to a sent control request within this period, the + * library will return a timeout error code. + * + * This value may be overridden in the user project makefile as the value of the + * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch. + */ + #define USB_HOST_TIMEOUT_MS 1000 + #endif + + /* Enums: */ + /** Enum for the \ref USB_Host_SendControlRequest() return code, indicating the reason for the error + * if the transfer of the request is unsuccessful. + * + * \ingroup Group_PipeControlReq + */ + enum USB_Host_SendControlErrorCodes_t + { + HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */ + HOST_SENDCONTROL_DeviceDisconnected = 1, /**< The attached device was disconnected during the + * request transfer. + */ + HOST_SENDCONTROL_PipeError = 2, /**< An error occurred in the pipe while sending the request. */ + HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually + * indicating that the request is unsupported on the device. + */ + HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */ + }; + + /* Global Variables: */ + /** Indicates the currently set configuration number of the attached device. This indicates the currently + * selected configuration value if one has been set sucessfully, or 0 if no configuration has been selected. + * + * To set a device configuration, call the \ref USB_Host_SetDeviceConfiguration() function. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \ingroup Group_Host + */ + extern uint8_t USB_Host_ConfigurationNumber; + + /* Function Prototypes: */ + /** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device, + * and transfers the data stored in the buffer to the device, or from the device to the buffer + * as requested. The transfer is made on the currently selected pipe. + * + * \ingroup Group_PipeControlReq + * + * \param[in] BufferPtr Pointer to the start of the data buffer if the request has a data stage, or + * \c NULL if the request transfers no data to or from the device. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SendControlRequest(void* const BufferPtr); + + /** Sends a SET CONFIGURATION standard request to the attached device, with the given configuration index. + * + * This routine will automatically update the \ref USB_HostState and \ref USB_Host_ConfigurationNumber + * state variables according to the given function parameters and the result of the request. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] ConfigNumber Configuration index to send to the device. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber); + + /** Sends a GET CONFIGURATION standard request to the attached device, to retrieve the currently selected + * device configuration index. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] ConfigNumber Pointer to a location where the retrieved configuration index should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the descriptor of the + * specified type and index. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] Type Type of descriptor to retrieve, a value from the \ref USB_DescriptorTypes_t enum. + * \param[in] Index Index of the descriptor to retrieve. + * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is to be stored. + * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDescriptor(const uint8_t Type, + const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(3); + + /** Retrieves the current feature status of the attached device, via a GET STATUS standard request. The + * retrieved feature status can then be examined by masking the retrieved value with the various + * \c FEATURE_* masks for bus/self power information and remote wakeup support. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] FeatureStatus Location where the retrieved feature status should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) ATTR_NON_NULL_PTR_ARG(1); + + /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] EndpointAddress Address of the endpoint to clear, including the endpoint's direction. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress); + + /** Selects a given alternative setting for the specified interface, via a SET INTERFACE standard request to + * the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. + * \param[in] AltSetting Index of the interface's alternative setting which is to be selected. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, + const uint8_t AltSetting); + + + /** Retrieves the current alternative setting for the specified interface, via a GET INTERFACE standard request to + * the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. + * \param[out] AltSetting Pointer to a location where the retrieved alternative setting value should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, + uint8_t* const AltSetting) ATTR_NON_NULL_PTR_ARG(2); + + /* Inline Functions: */ + /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the device descriptor. + * This can be used to easily retrieve information about the device such as its VID, PID and power + * requirements. This is a convenience wrapper for \ref USB_Host_GetDescriptor(). + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where + * the read data is to be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) ATTR_NON_NULL_PTR_ARG(1); + static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) + { + return USB_Host_GetDescriptor(DTYPE_Device, 0, DeviceDescriptorPtr, sizeof(USB_Descriptor_Device_t)); + } + + /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the string descriptor + * of the specified index. This can be used to easily retrieve string descriptors from the device by + * index, after the index is obtained from the Device or Configuration descriptors. This is a convenience + * wrapper for \ref USB_Host_GetDescriptor(). + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] Index Index of the string descriptor to retrieve. + * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is + * to be stored. + * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(2); + static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) + { + return USB_Host_GetDescriptor(DTYPE_String, Index, Buffer, BufferLength); + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Enums: */ + enum USB_WaitForTypes_t + { + USB_HOST_WAITFOR_SetupSent, + USB_HOST_WAITFOR_InReceived, + USB_HOST_WAITFOR_OutReady, + }; + + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_HOSTSTDREQ_C) + static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/OTG.h b/hal/at90usb646/LUFA/Drivers/USB/Core/OTG.h index ccd7cc1..6e511fb 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/OTG.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/OTG.h @@ -1,80 +1,80 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common USB OTG definitions for all architectures. - * \copydetails Group_OTG - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_OTG USB On The Go (OTG) Management - * \brief USB OTG management definitions. - * - * This module contains macros for embedded USB hosts with dual role On The Go capabilities, for managing role - * exchange. OTG is a way for two USB dual role devices to talk to one another directly without fixed device/host - * roles. - * - * @{ - */ - -#ifndef __USBOTG_H__ -#define __USBOTG_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/OTG_AVR8.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB OTG definitions for all architectures. + * \copydetails Group_OTG + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_OTG USB On The Go (OTG) Management + * \brief USB OTG management definitions. + * + * This module contains macros for embedded USB hosts with dual role On The Go capabilities, for managing role + * exchange. OTG is a way for two USB dual role devices to talk to one another directly without fixed device/host + * roles. + * + * @{ + */ + +#ifndef __USBOTG_H__ +#define __USBOTG_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/OTG_AVR8.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/Pipe.h b/hal/at90usb646/LUFA/Drivers/USB/Core/Pipe.h index 2a23fe7..bb56b81 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/Pipe.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/Pipe.h @@ -1,136 +1,136 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common USB Pipe definitions for all architectures. - * \copydetails Group_PipeManagement - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_PipeManagement - * \defgroup Group_PipeRW Pipe Data Reading and Writing - * \brief Pipe data read/write definitions. - * - * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. - */ - -/** \ingroup Group_PipeRW - * \defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types - * \brief Pipe data primitive read/write definitions. - * - * Functions, macros, variables, enums and types related to data reading and writing of primitive data types - * from and to pipes. - */ - -/** \ingroup Group_PipeManagement - * \defgroup Group_PipePacketManagement Pipe Packet Management - * \brief Pipe packet management definitions. - * - * Functions, macros, variables, enums and types related to packet management of pipes. - */ - -/** \ingroup Group_PipeManagement - * \defgroup Group_PipeControlReq Pipe Control Request Management - * \brief Pipe control request definitions. - * - * Module for host mode request processing. This module allows for the transmission of standard, class and - * vendor control requests to the default control endpoint of an attached device while in host mode. - * - * \see Chapter 9 of the USB 2.0 specification. - */ - -/** \ingroup Group_USB - * \defgroup Group_PipeManagement Pipe Management - * \brief Pipe management definitions. - * - * This module contains functions, macros and enums related to pipe management when in USB Host mode. This - * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions - * for various data types. - * - * @{ - */ - -#ifndef __PIPE_H__ -#define __PIPE_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Pipe address for the default control pipe, which always resides in address 0. This is - * defined for convenience to give more readable code when used with the pipe macros. - */ - #define PIPE_CONTROLPIPE 0 - - /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address - * in the device. - */ - #define PIPE_PIPENUM_MASK 0x0F - - /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's - * numerical address in the attached device. - */ - #define PIPE_EPNUM_MASK 0x0F - - /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's - * direction for comparing with the \c ENDPOINT_DIR_* masks. - */ - #define PIPE_EPDIR_MASK 0x80 - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/Pipe_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/Pipe_UC3.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Pipe definitions for all architectures. + * \copydetails Group_PipeManagement + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeRW Pipe Data Reading and Writing + * \brief Pipe data read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types + * \brief Pipe data primitive read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to pipes. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipePacketManagement Pipe Packet Management + * \brief Pipe packet management definitions. + * + * Functions, macros, variables, enums and types related to packet management of pipes. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeControlReq Pipe Control Request Management + * \brief Pipe control request definitions. + * + * Module for host mode request processing. This module allows for the transmission of standard, class and + * vendor control requests to the default control endpoint of an attached device while in host mode. + * + * \see Chapter 9 of the USB 2.0 specification. + */ + +/** \ingroup Group_USB + * \defgroup Group_PipeManagement Pipe Management + * \brief Pipe management definitions. + * + * This module contains functions, macros and enums related to pipe management when in USB Host mode. This + * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions + * for various data types. + * + * @{ + */ + +#ifndef __PIPE_H__ +#define __PIPE_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Pipe address for the default control pipe, which always resides in address 0. This is + * defined for convenience to give more readable code when used with the pipe macros. + */ + #define PIPE_CONTROLPIPE 0 + + /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address + * in the device. + */ + #define PIPE_PIPENUM_MASK 0x0F + + /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's + * numerical address in the attached device. + */ + #define PIPE_EPNUM_MASK 0x0F + + /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's + * direction for comparing with the \c ENDPOINT_DIR_* masks. + */ + #define PIPE_EPDIR_MASK 0x80 + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Pipe_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Pipe_UC3.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/PipeStream.h b/hal/at90usb646/LUFA/Drivers/USB/Core/PipeStream.h index 002d6ff..8309cbd 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/PipeStream.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/PipeStream.h @@ -1,100 +1,100 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Pipe data stream transmission and reception management. - * \copydetails Group_PipeStreamRW - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_PipeRW - * \defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams - * \brief Pipe data stream transmission and reception management. - * - * Functions, macros, variables, enums and types related to data reading and writing of data streams from - * and to pipes. - * - * @{ - */ - -#ifndef __PIPE_STREAM_H__ -#define __PIPE_STREAM_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Enums: */ - /** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */ - enum Pipe_Stream_RW_ErrorCodes_t - { - PIPE_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */ - PIPE_RWSTREAM_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */ - PIPE_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during - * the transfer. - */ - PIPE_RWSTREAM_Timeout = 3, /**< The device failed to accept or send the next packet - * within the software timeout period set by the - * \ref USB_STREAM_TIMEOUT_MS macro. - */ - PIPE_RWSTREAM_IncompleteTransfer = 4, /**< Indicates that the pipe bank became full/empty before the - * complete contents of the stream could be transferred. - */ - }; - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/PipeStream_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/PipeStream_UC3.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Pipe data stream transmission and reception management. + * \copydetails Group_PipeStreamRW + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams + * \brief Pipe data stream transmission and reception management. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to pipes. + * + * @{ + */ + +#ifndef __PIPE_STREAM_H__ +#define __PIPE_STREAM_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */ + enum Pipe_Stream_RW_ErrorCodes_t + { + PIPE_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */ + PIPE_RWSTREAM_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */ + PIPE_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during + * the transfer. + */ + PIPE_RWSTREAM_Timeout = 3, /**< The device failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + PIPE_RWSTREAM_IncompleteTransfer = 4, /**< Indicates that the pipe bank became full/empty before the + * complete contents of the stream could be transferred. + */ + }; + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/PipeStream_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/PipeStream_UC3.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/StdDescriptors.h b/hal/at90usb646/LUFA/Drivers/USB/Core/StdDescriptors.h index 8127949..cee2d5e 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/StdDescriptors.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/StdDescriptors.h @@ -1,739 +1,739 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common standard USB Descriptor definitions for all architectures. - * \copydetails Group_StdDescriptors - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_StdDescriptors USB Descriptors - * \brief Standard USB Descriptor definitions. - * - * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains - * structures and macros for the easy creation of standard USB descriptors in USB device projects. - * - * @{ - */ - -#ifndef __USBDESCRIPTORS_H__ -#define __USBDESCRIPTORS_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - #include "Events.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors - * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified - * descriptor does not exist. - */ - #define NO_DESCRIPTOR 0 - - /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. - * - * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected. - */ - #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1) - - /** Macro to calculate the Unicode length of a string with a given number of Unicode characters. - * Should be used in string descriptor's headers for giving the string descriptor's byte length. - * - * \param[in] UnicodeChars Number of Unicode characters in the string text. - */ - #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1)) - - /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded - * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the - * standard device descriptor. - * - * \note This value is automatically converted into Little Endian, suitable for direct use inside device - * descriptors on all architectures without endianness conversion macros. - * - * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number. - */ - #define VERSION_BCD(x) CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \ - ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x))) - - /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors - * to indicate that the English language is supported by the device in its string descriptors. - */ - #define LANGUAGE_ID_ENG 0x0409 - - /** \name USB Configuration Descriptor Attribute Masks */ - //@{ - /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all - * devices for historial purposes. - */ - #define USB_CONFIG_ATTR_RESERVED 0x80 - - /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t - * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power - * from the device's own power source. - */ - #define USB_CONFIG_ATTR_SELFPOWERED 0x40 - - /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t - * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the - * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon - * request. - */ - #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20 - //@} - - /** \name Endpoint Descriptor Attribute Masks */ - //@{ - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is not synchronized. - * - * \see The USB specification for more details on the possible Endpoint attributes. - */ - #define ENDPOINT_ATTR_NO_SYNC (0 << 2) - - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is asynchronous. - * - * \see The USB specification for more details on the possible Endpoint attributes. - */ - #define ENDPOINT_ATTR_ASYNC (1 << 2) - - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is adaptive. - * - * \see The USB specification for more details on the possible Endpoint attributes. - */ - #define ENDPOINT_ATTR_ADAPTIVE (2 << 2) - - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is synchronized. - * - * \see The USB specification for more details on the possible Endpoint attributes. - */ - #define ENDPOINT_ATTR_SYNC (3 << 2) - //@} - - /** \name Endpoint Descriptor Usage Masks */ - //@{ - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is used for data transfers. - * - * \see The USB specification for more details on the possible Endpoint usage attributes. - */ - #define ENDPOINT_USAGE_DATA (0 << 4) - - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is used for feedback. - * - * \see The USB specification for more details on the possible Endpoint usage attributes. - */ - #define ENDPOINT_USAGE_FEEDBACK (1 << 4) - - /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's - * \c Attributes value to indicate that the specified endpoint is used for implicit feedback. - * - * \see The USB specification for more details on the possible Endpoint usage attributes. - */ - #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4) - //@} - - /* Enums: */ - /** Enum for the possible standard descriptor types, as given in each descriptor's header. */ - enum USB_DescriptorTypes_t - { - DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */ - DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */ - DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */ - DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */ - DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */ - DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */ - DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */ - DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */ - DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */ - DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */ - DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */ - }; - - /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */ - enum USB_Descriptor_ClassSubclassProtocol_t - { - USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong - * to a particular class at the device level. - */ - USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong - * to a particular subclass at the device level. - */ - USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong - * to a particular protocol at the device level. - */ - USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs - * to a vendor specific class. - */ - USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs - * to a vendor specific subclass. - */ - USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs - * to a vendor specific protocol. - */ - USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the - * Interface Association Descriptor class. - */ - USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the - * Interface Association Descriptor subclass. - */ - USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the - * Interface Association Descriptor protocol. - */ - }; - - /* Type Defines: */ - /** \brief Standard USB Descriptor Header (LUFA naming conventions). - * - * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure - * uses LUFA-specific element names to make each element's purpose clearer. - * - * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t Size; /**< Size of the descriptor, in bytes. */ - uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - } ATTR_PACKED USB_Descriptor_Header_t; - - /** \brief Standard USB Descriptor Header (USB-IF naming conventions). - * - * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure - * uses the relevant standard's given element names to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - } ATTR_PACKED USB_StdDescriptor_Header_t; - - /** \brief Standard USB Device Descriptor (LUFA naming conventions). - * - * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each - * element's purpose clearer. - * - * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - uint16_t USBSpecification; /**< BCD of the supported USB specification. */ - uint8_t Class; /**< USB device class. */ - uint8_t SubClass; /**< USB device subclass. */ - uint8_t Protocol; /**< USB device protocol. */ - - uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */ - - uint16_t VendorID; /**< Vendor ID for the USB product. */ - uint16_t ProductID; /**< Unique product ID for the USB product. */ - uint16_t ReleaseNumber; /**< Product release (version) number. */ - - uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The - * host will request this string via a separate - * control request for the string descriptor. - * - * \note If no string supplied, use \ref NO_DESCRIPTOR. - */ - uint8_t ProductStrIndex; /**< String index for the product name/details. - * - * \see ManufacturerStrIndex structure entry. - */ - uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal - * serial number, in uppercase Unicode ASCII. - * - * \note On some microcontroller models, there is an embedded serial number - * in the chip which can be used for the device serial number. - * To use this serial number, set this to USE_INTERNAL_SERIAL. - * On unsupported devices, this will evaluate to 0 and will cause - * the host to generate a pseudo-unique value for the device upon - * insertion. - * - * \see ManufacturerStrIndex structure entry. - */ - uint8_t NumberOfConfigurations; /**< Total number of configurations supported by - * the device. - */ - } ATTR_PACKED USB_Descriptor_Device_t; - - /** \brief Standard USB Device Descriptor (USB-IF naming conventions). - * - * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names - * to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint16_t bcdUSB; /**< BCD of the supported USB specification. */ - uint8_t bDeviceClass; /**< USB device class. */ - uint8_t bDeviceSubClass; /**< USB device subclass. */ - uint8_t bDeviceProtocol; /**< USB device protocol. */ - uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */ - uint16_t idVendor; /**< Vendor ID for the USB product. */ - uint16_t idProduct; /**< Unique product ID for the USB product. */ - uint16_t bcdDevice; /**< Product release (version) number. */ - uint8_t iManufacturer; /**< String index for the manufacturer's name. The - * host will request this string via a separate - * control request for the string descriptor. - * - * \note If no string supplied, use \ref NO_DESCRIPTOR. - */ - uint8_t iProduct; /**< String index for the product name/details. - * - * \see ManufacturerStrIndex structure entry. - */ - uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal - * serial number, in uppercase Unicode ASCII. - * - * \note On some microcontroller models, there is an embedded serial number - * in the chip which can be used for the device serial number. - * To use this serial number, set this to USE_INTERNAL_SERIAL. - * On unsupported devices, this will evaluate to 0 and will cause - * the host to generate a pseudo-unique value for the device upon - * insertion. - * - * \see ManufacturerStrIndex structure entry. - */ - uint8_t bNumConfigurations; /**< Total number of configurations supported by - * the device. - */ - } ATTR_PACKED USB_StdDescriptor_Device_t; - - /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions). - * - * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names - * to make each element's purpose clearer. - * - * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - uint16_t USBSpecification; /**< BCD of the supported USB specification. */ - uint8_t Class; /**< USB device class. */ - uint8_t SubClass; /**< USB device subclass. */ - uint8_t Protocol; /**< USB device protocol. */ - - uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */ - uint8_t NumberOfConfigurations; /**< Total number of configurations supported by - * the device. - */ - uint8_t Reserved; /**< Reserved for future use, must be 0. */ - } ATTR_PACKED USB_Descriptor_DeviceQualifier_t; - - /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions). - * - * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names - * to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint16_t bcdUSB; /**< BCD of the supported USB specification. */ - uint8_t bDeviceClass; /**< USB device class. */ - uint8_t bDeviceSubClass; /**< USB device subclass. */ - uint8_t bDeviceProtocol; /**< USB device protocol. */ - uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */ - uint8_t bNumConfigurations; /**< Total number of configurations supported by - * the device. - */ - uint8_t bReserved; /**< Reserved for future use, must be 0. */ - } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t; - - /** \brief Standard USB Configuration Descriptor (LUFA naming conventions). - * - * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names - * to make each element's purpose clearer. - * - * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header, - * and all sub descriptors inside the configuration. - */ - uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */ - - uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */ - uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */ - - uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. - * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. - */ - - uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the - * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() - * macro. - */ - } ATTR_PACKED USB_Descriptor_Configuration_Header_t; - - /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions). - * - * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names - * to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint16_t wTotalLength; /**< Size of the configuration descriptor header, - * and all sub descriptors inside the configuration. - */ - uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */ - uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */ - uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */ - uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. - * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. - */ - uint8_t bMaxPower; /**< Maximum power consumption of the device while in the - * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() - * macro. - */ - } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t; - - /** \brief Standard USB Interface Descriptor (LUFA naming conventions). - * - * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names - * to make each element's purpose clearer. - * - * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */ - uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same - * interface number can have multiple alternate settings - * with different endpoint configurations, which can be - * selected by the host. - */ - uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */ - - uint8_t Class; /**< Interface class ID. */ - uint8_t SubClass; /**< Interface subclass ID. */ - uint8_t Protocol; /**< Interface protocol ID. */ - - uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */ - } ATTR_PACKED USB_Descriptor_Interface_t; - - /** \brief Standard USB Interface Descriptor (USB-IF naming conventions). - * - * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names - * to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */ - uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same - * interface number can have multiple alternate settings - * with different endpoint configurations, which can be - * selected by the host. - */ - uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */ - uint8_t bInterfaceClass; /**< Interface class ID. */ - uint8_t bInterfaceSubClass; /**< Interface subclass ID. */ - uint8_t bInterfaceProtocol; /**< Interface protocol ID. */ - uint8_t iInterface; /**< Index of the string descriptor describing the - * interface. - */ - } ATTR_PACKED USB_StdDescriptor_Interface_t; - - /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions). - * - * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names - * to make each element's purpose clearer. - * - * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at - * http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf. It allows composite - * devices with multiple interfaces related to the same function to have the multiple interfaces bound - * together at the point of enumeration, loading one generic driver for all the interfaces in the single - * function. Read the ECN for more information. - * - * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */ - uint8_t TotalInterfaces; /**< Total number of associated interfaces. */ - - uint8_t Class; /**< Interface class ID. */ - uint8_t SubClass; /**< Interface subclass ID. */ - uint8_t Protocol; /**< Interface protocol ID. */ - - uint8_t IADStrIndex; /**< Index of the string descriptor describing the - * interface association. - */ - } ATTR_PACKED USB_Descriptor_Interface_Association_t; - - /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions). - * - * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given - * element names to ensure compatibility with the standard. - * - * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at - * http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf. It allows composite - * devices with multiple interfaces related to the same function to have the multiple interfaces bound - * together at the point of enumeration, loading one generic driver for all the interfaces in the single - * function. Read the ECN for more information. - * - * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific - * element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value - * given by the specific class. - */ - uint8_t bFirstInterface; /**< Index of the first associated interface. */ - uint8_t bInterfaceCount; /**< Total number of associated interfaces. */ - uint8_t bFunctionClass; /**< Interface class ID. */ - uint8_t bFunctionSubClass; /**< Interface subclass ID. */ - uint8_t bFunctionProtocol; /**< Interface protocol ID. */ - uint8_t iFunction; /**< Index of the string descriptor describing the - * interface association. - */ - } ATTR_PACKED USB_StdDescriptor_Interface_Association_t; - - /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions). - * - * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names - * to make each element's purpose clearer. - * - * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current - * configuration, including direction mask. - */ - uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) - * and attributes (ENDPOINT_ATTR_*) masks. - */ - uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet - * size that the endpoint can receive at a time. - */ - uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT - * or ISOCHRONOUS type. - */ - } ATTR_PACKED USB_Descriptor_Endpoint_t; - - /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions). - * - * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given - * element names to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific - * element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a - * value given by the specific class. - */ - uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current - * configuration, including direction mask. - */ - uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) - * and attributes (ENDPOINT_ATTR_*) masks. - */ - uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size - * that the endpoint can receive at a time. - */ - uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or - * ISOCHRONOUS type. - */ - } ATTR_PACKED USB_StdDescriptor_Endpoint_t; - - /** \brief Standard USB String Descriptor (LUFA naming conventions). - * - * Type define for a standard string descriptor. Unlike other standard descriptors, the length - * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() - * macro rather than by the size of the descriptor structure, as the length is not fixed. - * - * This structure should also be used for string index 0, which contains the supported language IDs for - * the device as an array. - * - * This structure uses LUFA-specific element names to make each element's purpose clearer. - * - * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ - - #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__)) - wchar_t UnicodeString[]; - #else - uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively, - * string language IDs). If normal ASCII characters are - * to be used, they must be added as an array of characters - * rather than a normal C string so that they are widened to - * Unicode size. - * - * Under GCC, strings prefixed with the "L" character (before - * the opening string quotation mark) are considered to be - * Unicode strings, and may be used instead of an explicit - * array of ASCII characters on little endian devices with - * UTF-16-LE \c wchar_t encoding. - */ - #endif - } ATTR_PACKED USB_Descriptor_String_t; - - /** \brief Standard USB String Descriptor (USB-IF naming conventions). - * - * Type define for a standard string descriptor. Unlike other standard descriptors, the length - * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() - * macro rather than by the size of the descriptor structure, as the length is not fixed. - * - * This structure should also be used for string index 0, which contains the supported language IDs for - * the device as an array. - * - * This structure uses the relevant standard's given element names to ensure compatibility with the standard. - * - * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific - * element names. - * - * \note Regardless of CPU architecture, these values should be stored as little endian. - */ - typedef struct - { - uint8_t bLength; /**< Size of the descriptor, in bytes. */ - uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t - * or a value given by the specific class. - */ - uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs). - * If normal ASCII characters are to be used, they must be added as an array - * of characters rather than a normal C string so that they are widened to - * Unicode size. - * - * Under GCC, strings prefixed with the "L" character (before the opening string - * quotation mark) are considered to be Unicode strings, and may be used instead - * of an explicit array of ASCII characters. - */ - } ATTR_PACKED USB_StdDescriptor_String_t; - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Macros: */ - #define VERSION_TENS(x) (int)((x) / 10) - #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x))) - #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10) - #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x))) - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common standard USB Descriptor definitions for all architectures. + * \copydetails Group_StdDescriptors + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_StdDescriptors USB Descriptors + * \brief Standard USB Descriptor definitions. + * + * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains + * structures and macros for the easy creation of standard USB descriptors in USB device projects. + * + * @{ + */ + +#ifndef __USBDESCRIPTORS_H__ +#define __USBDESCRIPTORS_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "Events.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors + * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified + * descriptor does not exist. + */ + #define NO_DESCRIPTOR 0 + + /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. + * + * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected. + */ + #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1) + + /** Macro to calculate the Unicode length of a string with a given number of Unicode characters. + * Should be used in string descriptor's headers for giving the string descriptor's byte length. + * + * \param[in] UnicodeChars Number of Unicode characters in the string text. + */ + #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1)) + + /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded + * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the + * standard device descriptor. + * + * \note This value is automatically converted into Little Endian, suitable for direct use inside device + * descriptors on all architectures without endianness conversion macros. + * + * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number. + */ + #define VERSION_BCD(x) CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \ + ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x))) + + /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors + * to indicate that the English language is supported by the device in its string descriptors. + */ + #define LANGUAGE_ID_ENG 0x0409 + + /** \name USB Configuration Descriptor Attribute Masks */ + //@{ + /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all + * devices for historial purposes. + */ + #define USB_CONFIG_ATTR_RESERVED 0x80 + + /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t + * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power + * from the device's own power source. + */ + #define USB_CONFIG_ATTR_SELFPOWERED 0x40 + + /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t + * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the + * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon + * request. + */ + #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20 + //@} + + /** \name Endpoint Descriptor Attribute Masks */ + //@{ + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is not synchronized. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_NO_SYNC (0 << 2) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is asynchronous. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_ASYNC (1 << 2) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is adaptive. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_ADAPTIVE (2 << 2) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is synchronized. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_SYNC (3 << 2) + //@} + + /** \name Endpoint Descriptor Usage Masks */ + //@{ + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is used for data transfers. + * + * \see The USB specification for more details on the possible Endpoint usage attributes. + */ + #define ENDPOINT_USAGE_DATA (0 << 4) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is used for feedback. + * + * \see The USB specification for more details on the possible Endpoint usage attributes. + */ + #define ENDPOINT_USAGE_FEEDBACK (1 << 4) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is used for implicit feedback. + * + * \see The USB specification for more details on the possible Endpoint usage attributes. + */ + #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4) + //@} + + /* Enums: */ + /** Enum for the possible standard descriptor types, as given in each descriptor's header. */ + enum USB_DescriptorTypes_t + { + DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */ + DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */ + DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */ + DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */ + DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */ + DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */ + DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */ + DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */ + DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */ + DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */ + DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */ + }; + + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */ + enum USB_Descriptor_ClassSubclassProtocol_t + { + USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong + * to a particular class at the device level. + */ + USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong + * to a particular subclass at the device level. + */ + USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong + * to a particular protocol at the device level. + */ + USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs + * to a vendor specific class. + */ + USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs + * to a vendor specific subclass. + */ + USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs + * to a vendor specific protocol. + */ + USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the + * Interface Association Descriptor class. + */ + USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the + * Interface Association Descriptor subclass. + */ + USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the + * Interface Association Descriptor protocol. + */ + }; + + /* Type Defines: */ + /** \brief Standard USB Descriptor Header (LUFA naming conventions). + * + * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure + * uses LUFA-specific element names to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t Size; /**< Size of the descriptor, in bytes. */ + uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + } ATTR_PACKED USB_Descriptor_Header_t; + + /** \brief Standard USB Descriptor Header (USB-IF naming conventions). + * + * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure + * uses the relevant standard's given element names to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + } ATTR_PACKED USB_StdDescriptor_Header_t; + + /** \brief Standard USB Device Descriptor (LUFA naming conventions). + * + * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each + * element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint16_t USBSpecification; /**< BCD of the supported USB specification. */ + uint8_t Class; /**< USB device class. */ + uint8_t SubClass; /**< USB device subclass. */ + uint8_t Protocol; /**< USB device protocol. */ + + uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */ + + uint16_t VendorID; /**< Vendor ID for the USB product. */ + uint16_t ProductID; /**< Unique product ID for the USB product. */ + uint16_t ReleaseNumber; /**< Product release (version) number. */ + + uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The + * host will request this string via a separate + * control request for the string descriptor. + * + * \note If no string supplied, use \ref NO_DESCRIPTOR. + */ + uint8_t ProductStrIndex; /**< String index for the product name/details. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal + * serial number, in uppercase Unicode ASCII. + * + * \note On some microcontroller models, there is an embedded serial number + * in the chip which can be used for the device serial number. + * To use this serial number, set this to USE_INTERNAL_SERIAL. + * On unsupported devices, this will evaluate to 0 and will cause + * the host to generate a pseudo-unique value for the device upon + * insertion. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t NumberOfConfigurations; /**< Total number of configurations supported by + * the device. + */ + } ATTR_PACKED USB_Descriptor_Device_t; + + /** \brief Standard USB Device Descriptor (USB-IF naming conventions). + * + * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint16_t bcdUSB; /**< BCD of the supported USB specification. */ + uint8_t bDeviceClass; /**< USB device class. */ + uint8_t bDeviceSubClass; /**< USB device subclass. */ + uint8_t bDeviceProtocol; /**< USB device protocol. */ + uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */ + uint16_t idVendor; /**< Vendor ID for the USB product. */ + uint16_t idProduct; /**< Unique product ID for the USB product. */ + uint16_t bcdDevice; /**< Product release (version) number. */ + uint8_t iManufacturer; /**< String index for the manufacturer's name. The + * host will request this string via a separate + * control request for the string descriptor. + * + * \note If no string supplied, use \ref NO_DESCRIPTOR. + */ + uint8_t iProduct; /**< String index for the product name/details. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal + * serial number, in uppercase Unicode ASCII. + * + * \note On some microcontroller models, there is an embedded serial number + * in the chip which can be used for the device serial number. + * To use this serial number, set this to USE_INTERNAL_SERIAL. + * On unsupported devices, this will evaluate to 0 and will cause + * the host to generate a pseudo-unique value for the device upon + * insertion. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t bNumConfigurations; /**< Total number of configurations supported by + * the device. + */ + } ATTR_PACKED USB_StdDescriptor_Device_t; + + /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions). + * + * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint16_t USBSpecification; /**< BCD of the supported USB specification. */ + uint8_t Class; /**< USB device class. */ + uint8_t SubClass; /**< USB device subclass. */ + uint8_t Protocol; /**< USB device protocol. */ + + uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */ + uint8_t NumberOfConfigurations; /**< Total number of configurations supported by + * the device. + */ + uint8_t Reserved; /**< Reserved for future use, must be 0. */ + } ATTR_PACKED USB_Descriptor_DeviceQualifier_t; + + /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions). + * + * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint16_t bcdUSB; /**< BCD of the supported USB specification. */ + uint8_t bDeviceClass; /**< USB device class. */ + uint8_t bDeviceSubClass; /**< USB device subclass. */ + uint8_t bDeviceProtocol; /**< USB device protocol. */ + uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */ + uint8_t bNumConfigurations; /**< Total number of configurations supported by + * the device. + */ + uint8_t bReserved; /**< Reserved for future use, must be 0. */ + } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t; + + /** \brief Standard USB Configuration Descriptor (LUFA naming conventions). + * + * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header, + * and all sub descriptors inside the configuration. + */ + uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */ + + uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */ + uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */ + + uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. + * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. + */ + + uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the + * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() + * macro. + */ + } ATTR_PACKED USB_Descriptor_Configuration_Header_t; + + /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions). + * + * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint16_t wTotalLength; /**< Size of the configuration descriptor header, + * and all sub descriptors inside the configuration. + */ + uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */ + uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */ + uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */ + uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. + * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. + */ + uint8_t bMaxPower; /**< Maximum power consumption of the device while in the + * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() + * macro. + */ + } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t; + + /** \brief Standard USB Interface Descriptor (LUFA naming conventions). + * + * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */ + uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same + * interface number can have multiple alternate settings + * with different endpoint configurations, which can be + * selected by the host. + */ + uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */ + + uint8_t Class; /**< Interface class ID. */ + uint8_t SubClass; /**< Interface subclass ID. */ + uint8_t Protocol; /**< Interface protocol ID. */ + + uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */ + } ATTR_PACKED USB_Descriptor_Interface_t; + + /** \brief Standard USB Interface Descriptor (USB-IF naming conventions). + * + * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */ + uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same + * interface number can have multiple alternate settings + * with different endpoint configurations, which can be + * selected by the host. + */ + uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */ + uint8_t bInterfaceClass; /**< Interface class ID. */ + uint8_t bInterfaceSubClass; /**< Interface subclass ID. */ + uint8_t bInterfaceProtocol; /**< Interface protocol ID. */ + uint8_t iInterface; /**< Index of the string descriptor describing the + * interface. + */ + } ATTR_PACKED USB_StdDescriptor_Interface_t; + + /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions). + * + * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at + * http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf. It allows composite + * devices with multiple interfaces related to the same function to have the multiple interfaces bound + * together at the point of enumeration, loading one generic driver for all the interfaces in the single + * function. Read the ECN for more information. + * + * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */ + uint8_t TotalInterfaces; /**< Total number of associated interfaces. */ + + uint8_t Class; /**< Interface class ID. */ + uint8_t SubClass; /**< Interface subclass ID. */ + uint8_t Protocol; /**< Interface protocol ID. */ + + uint8_t IADStrIndex; /**< Index of the string descriptor describing the + * interface association. + */ + } ATTR_PACKED USB_Descriptor_Interface_Association_t; + + /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions). + * + * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given + * element names to ensure compatibility with the standard. + * + * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at + * http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf. It allows composite + * devices with multiple interfaces related to the same function to have the multiple interfaces bound + * together at the point of enumeration, loading one generic driver for all the interfaces in the single + * function. Read the ECN for more information. + * + * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bFirstInterface; /**< Index of the first associated interface. */ + uint8_t bInterfaceCount; /**< Total number of associated interfaces. */ + uint8_t bFunctionClass; /**< Interface class ID. */ + uint8_t bFunctionSubClass; /**< Interface subclass ID. */ + uint8_t bFunctionProtocol; /**< Interface protocol ID. */ + uint8_t iFunction; /**< Index of the string descriptor describing the + * interface association. + */ + } ATTR_PACKED USB_StdDescriptor_Interface_Association_t; + + /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions). + * + * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current + * configuration, including direction mask. + */ + uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) + * and attributes (ENDPOINT_ATTR_*) masks. + */ + uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet + * size that the endpoint can receive at a time. + */ + uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT + * or ISOCHRONOUS type. + */ + } ATTR_PACKED USB_Descriptor_Endpoint_t; + + /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions). + * + * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given + * element names to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a + * value given by the specific class. + */ + uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current + * configuration, including direction mask. + */ + uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) + * and attributes (ENDPOINT_ATTR_*) masks. + */ + uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size + * that the endpoint can receive at a time. + */ + uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or + * ISOCHRONOUS type. + */ + } ATTR_PACKED USB_StdDescriptor_Endpoint_t; + + /** \brief Standard USB String Descriptor (LUFA naming conventions). + * + * Type define for a standard string descriptor. Unlike other standard descriptors, the length + * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() + * macro rather than by the size of the descriptor structure, as the length is not fixed. + * + * This structure should also be used for string index 0, which contains the supported language IDs for + * the device as an array. + * + * This structure uses LUFA-specific element names to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__)) + wchar_t UnicodeString[]; + #else + uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively, + * string language IDs). If normal ASCII characters are + * to be used, they must be added as an array of characters + * rather than a normal C string so that they are widened to + * Unicode size. + * + * Under GCC, strings prefixed with the "L" character (before + * the opening string quotation mark) are considered to be + * Unicode strings, and may be used instead of an explicit + * array of ASCII characters on little endian devices with + * UTF-16-LE \c wchar_t encoding. + */ + #endif + } ATTR_PACKED USB_Descriptor_String_t; + + /** \brief Standard USB String Descriptor (USB-IF naming conventions). + * + * Type define for a standard string descriptor. Unlike other standard descriptors, the length + * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() + * macro rather than by the size of the descriptor structure, as the length is not fixed. + * + * This structure should also be used for string index 0, which contains the supported language IDs for + * the device as an array. + * + * This structure uses the relevant standard's given element names to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t + * or a value given by the specific class. + */ + uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs). + * If normal ASCII characters are to be used, they must be added as an array + * of characters rather than a normal C string so that they are widened to + * Unicode size. + * + * Under GCC, strings prefixed with the "L" character (before the opening string + * quotation mark) are considered to be Unicode strings, and may be used instead + * of an explicit array of ASCII characters. + */ + } ATTR_PACKED USB_StdDescriptor_String_t; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define VERSION_TENS(x) (int)((x) / 10) + #define VERSION_ONES(x) (int)((x) - (10 * VERSION_TENS(x))) + #define VERSION_TENTHS(x) (int)(((x) - (int)(x)) * 10) + #define VERSION_HUNDREDTHS(x) (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x))) + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/StdRequestType.h b/hal/at90usb646/LUFA/Drivers/USB/Core/StdRequestType.h index a841f8f..c94da4d 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/StdRequestType.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/StdRequestType.h @@ -1,258 +1,258 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB control endpoint request definitions. - * \copydetails Group_StdRequest - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_StdRequest Standard USB Requests - * \brief USB control endpoint request definitions. - * - * This module contains definitions for the various control request parameters, so that the request - * details (such as data direction, request recipient, etc.) can be extracted via masking. - * - * @{ - */ - -#ifndef __STDREQTYPE_H__ -#define __STDREQTYPE_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device - * or Device to Host). The result of this mask should then be compared to the request direction masks. - * - * \see \c REQDIR_* macros for masks indicating the request data direction. - */ - #define CONTROL_REQTYPE_DIRECTION 0x80 - - /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor - * Specific). The result of this mask should then be compared to the request type masks. - * - * \see \c REQTYPE_* macros for masks indicating the request type. - */ - #define CONTROL_REQTYPE_TYPE 0x60 - - /** Mask for the request type parameter, to indicate the recipient of the request (Device, Interface - * Endpoint or Other). The result of this mask should then be compared to the request recipient - * masks. - * - * \see \c REQREC_* macros for masks indicating the request recipient. - */ - #define CONTROL_REQTYPE_RECIPIENT 0x1F - - /** \name Control Request Data Direction Masks */ - //@{ - /** Request data direction mask, indicating that the request data will flow from host to device. - * - * \see \ref CONTROL_REQTYPE_DIRECTION macro. - */ - #define REQDIR_HOSTTODEVICE (0 << 7) - - /** Request data direction mask, indicating that the request data will flow from device to host. - * - * \see \ref CONTROL_REQTYPE_DIRECTION macro. - */ - #define REQDIR_DEVICETOHOST (1 << 7) - //@} - - /** \name Control Request Type Masks */ - //@{ - /** Request type mask, indicating that the request is a standard request. - * - * \see \ref CONTROL_REQTYPE_TYPE macro. - */ - #define REQTYPE_STANDARD (0 << 5) - - /** Request type mask, indicating that the request is a class-specific request. - * - * \see \ref CONTROL_REQTYPE_TYPE macro. - */ - #define REQTYPE_CLASS (1 << 5) - - /** Request type mask, indicating that the request is a vendor specific request. - * - * \see \ref CONTROL_REQTYPE_TYPE macro. - */ - #define REQTYPE_VENDOR (2 << 5) - //@} - - /** \name Control Request Recipient Masks */ - //@{ - /** Request recipient mask, indicating that the request is to be issued to the device as a whole. - * - * \see \ref CONTROL_REQTYPE_RECIPIENT macro. - */ - #define REQREC_DEVICE (0 << 0) - - /** Request recipient mask, indicating that the request is to be issued to an interface in the - * currently selected configuration. - * - * \see \ref CONTROL_REQTYPE_RECIPIENT macro. - */ - #define REQREC_INTERFACE (1 << 0) - - /** Request recipient mask, indicating that the request is to be issued to an endpoint in the - * currently selected configuration. - * - * \see \ref CONTROL_REQTYPE_RECIPIENT macro. - */ - #define REQREC_ENDPOINT (2 << 0) - - /** Request recipient mask, indicating that the request is to be issued to an unspecified element - * in the currently selected configuration. - * - * \see \ref CONTROL_REQTYPE_RECIPIENT macro. - */ - #define REQREC_OTHER (3 << 0) - //@} - - /* Type Defines: */ - /** \brief Standard USB Control Request - * - * Type define for a standard USB control request. - * - * \see The USB 2.0 specification for more information on standard control requests. - */ - typedef struct - { - uint8_t bmRequestType; /**< Type of the request. */ - uint8_t bRequest; /**< Request command code. */ - uint16_t wValue; /**< wValue parameter of the request. */ - uint16_t wIndex; /**< wIndex parameter of the request. */ - uint16_t wLength; /**< Length of the data to transfer in bytes. */ - } ATTR_PACKED USB_Request_Header_t; - - /* Enums: */ - /** Enumeration for the various standard request commands. These commands are applicable when the - * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always - * handled regardless of the request type value). - * - * \see Chapter 9 of the USB 2.0 Specification. - */ - enum USB_Control_Request_t - { - REQ_GetStatus = 0, /**< Implemented in the library for device and endpoint recipients. Passed - * to the user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_ClearFeature = 1, /**< Implemented in the library for device and endpoint recipients. Passed - * to the user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_SetFeature = 3, /**< Implemented in the library for device and endpoint recipients. Passed - * to the user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed - * to the user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_GetDescriptor = 6, /**< Implemented in the library for device and interface recipients. Passed to the - * user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed - * to the user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed - * to the user application for other recipients via the - * \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application - * via the \ref EVENT_USB_Device_ControlRequest() event when received in - * device mode. */ - }; - - /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface - * and endpoint recipients. - */ - enum USB_Feature_Selectors_t - { - FEATURE_SEL_EndpointHalt = 0x00, /**< Feature selector for Clear Feature or Set Feature commands. When - * used in a Set Feature or Clear Feature request this indicates that an - * endpoint (whose address is given elsewhere in the request) should have - * its stall condition changed. - */ - FEATURE_SEL_DeviceRemoteWakeup = 0x01, /**< Feature selector for Device level Remote Wakeup enable set or clear. - * This feature can be controlled by the host on devices which indicate - * remote wakeup support in their descriptors to selectively disable or - * enable remote wakeup. - */ - FEATURE_SEL_TestMode = 0x02, /**< Feature selector for Test Mode features, used to test the USB controller - * to check for incorrect operation. - */ - }; - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Macros: */ - #define FEATURE_SELFPOWERED_ENABLED (1 << 0) - #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1) - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB control endpoint request definitions. + * \copydetails Group_StdRequest + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_StdRequest Standard USB Requests + * \brief USB control endpoint request definitions. + * + * This module contains definitions for the various control request parameters, so that the request + * details (such as data direction, request recipient, etc.) can be extracted via masking. + * + * @{ + */ + +#ifndef __STDREQTYPE_H__ +#define __STDREQTYPE_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device + * or Device to Host). The result of this mask should then be compared to the request direction masks. + * + * \see \c REQDIR_* macros for masks indicating the request data direction. + */ + #define CONTROL_REQTYPE_DIRECTION 0x80 + + /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor + * Specific). The result of this mask should then be compared to the request type masks. + * + * \see \c REQTYPE_* macros for masks indicating the request type. + */ + #define CONTROL_REQTYPE_TYPE 0x60 + + /** Mask for the request type parameter, to indicate the recipient of the request (Device, Interface + * Endpoint or Other). The result of this mask should then be compared to the request recipient + * masks. + * + * \see \c REQREC_* macros for masks indicating the request recipient. + */ + #define CONTROL_REQTYPE_RECIPIENT 0x1F + + /** \name Control Request Data Direction Masks */ + //@{ + /** Request data direction mask, indicating that the request data will flow from host to device. + * + * \see \ref CONTROL_REQTYPE_DIRECTION macro. + */ + #define REQDIR_HOSTTODEVICE (0 << 7) + + /** Request data direction mask, indicating that the request data will flow from device to host. + * + * \see \ref CONTROL_REQTYPE_DIRECTION macro. + */ + #define REQDIR_DEVICETOHOST (1 << 7) + //@} + + /** \name Control Request Type Masks */ + //@{ + /** Request type mask, indicating that the request is a standard request. + * + * \see \ref CONTROL_REQTYPE_TYPE macro. + */ + #define REQTYPE_STANDARD (0 << 5) + + /** Request type mask, indicating that the request is a class-specific request. + * + * \see \ref CONTROL_REQTYPE_TYPE macro. + */ + #define REQTYPE_CLASS (1 << 5) + + /** Request type mask, indicating that the request is a vendor specific request. + * + * \see \ref CONTROL_REQTYPE_TYPE macro. + */ + #define REQTYPE_VENDOR (2 << 5) + //@} + + /** \name Control Request Recipient Masks */ + //@{ + /** Request recipient mask, indicating that the request is to be issued to the device as a whole. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_DEVICE (0 << 0) + + /** Request recipient mask, indicating that the request is to be issued to an interface in the + * currently selected configuration. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_INTERFACE (1 << 0) + + /** Request recipient mask, indicating that the request is to be issued to an endpoint in the + * currently selected configuration. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_ENDPOINT (2 << 0) + + /** Request recipient mask, indicating that the request is to be issued to an unspecified element + * in the currently selected configuration. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_OTHER (3 << 0) + //@} + + /* Type Defines: */ + /** \brief Standard USB Control Request + * + * Type define for a standard USB control request. + * + * \see The USB 2.0 specification for more information on standard control requests. + */ + typedef struct + { + uint8_t bmRequestType; /**< Type of the request. */ + uint8_t bRequest; /**< Request command code. */ + uint16_t wValue; /**< wValue parameter of the request. */ + uint16_t wIndex; /**< wIndex parameter of the request. */ + uint16_t wLength; /**< Length of the data to transfer in bytes. */ + } ATTR_PACKED USB_Request_Header_t; + + /* Enums: */ + /** Enumeration for the various standard request commands. These commands are applicable when the + * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always + * handled regardless of the request type value). + * + * \see Chapter 9 of the USB 2.0 Specification. + */ + enum USB_Control_Request_t + { + REQ_GetStatus = 0, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_ClearFeature = 1, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetFeature = 3, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_GetDescriptor = 6, /**< Implemented in the library for device and interface recipients. Passed to the + * user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + }; + + /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface + * and endpoint recipients. + */ + enum USB_Feature_Selectors_t + { + FEATURE_SEL_EndpointHalt = 0x00, /**< Feature selector for Clear Feature or Set Feature commands. When + * used in a Set Feature or Clear Feature request this indicates that an + * endpoint (whose address is given elsewhere in the request) should have + * its stall condition changed. + */ + FEATURE_SEL_DeviceRemoteWakeup = 0x01, /**< Feature selector for Device level Remote Wakeup enable set or clear. + * This feature can be controlled by the host on devices which indicate + * remote wakeup support in their descriptors to selectively disable or + * enable remote wakeup. + */ + FEATURE_SEL_TestMode = 0x02, /**< Feature selector for Test Mode features, used to test the USB controller + * to check for incorrect operation. + */ + }; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define FEATURE_SELFPOWERED_ENABLED (1 << 0) + #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1) + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/USBController.h b/hal/at90usb646/LUFA/Drivers/USB/Core/USBController.h index ab6844d..a91e18c 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/USBController.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/USBController.h @@ -1,133 +1,133 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Common USB Controller definitions for all architectures. - * \copydetails Group_USBManagement - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_USBManagement USB Interface Management - * \brief USB Controller definitions for general USB controller management. - * - * Functions, macros, variables, enums and types related to the setup and management of the USB interface. - * - * @{ - */ - -#ifndef __USBCONTROLLER_H__ -#define __USBCONTROLLER_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks and Defines: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Defines: */ - /** \name Endpoint Direction Masks */ - //@{ - /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's - * direction for comparing with the \c ENDPOINT_DIR_* masks. - */ - #define ENDPOINT_DIR_MASK 0x80 - - /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with - * the index of the address within a device to obtain the full endpoint address. - */ - #define ENDPOINT_DIR_OUT 0x00 - - /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with - * the index of the address within a device to obtain the full endpoint address. - */ - #define ENDPOINT_DIR_IN 0x80 - //@} - - /** \name Endpoint/Pipe Type Masks */ - //@{ - /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared - * with the \c EP_TYPE_* masks to determine the exact type of the endpoint. - */ - #define EP_TYPE_MASK 0x03 - - /** Mask for a CONTROL type endpoint or pipe. - * - * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. - */ - #define EP_TYPE_CONTROL 0x00 - - /** Mask for an ISOCHRONOUS type endpoint or pipe. - * - * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. - */ - #define EP_TYPE_ISOCHRONOUS 0x01 - - /** Mask for a BULK type endpoint or pipe. - * - * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. - */ - #define EP_TYPE_BULK 0x02 - - /** Mask for an INTERRUPT type endpoint or pipe. - * - * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. - */ - #define EP_TYPE_INTERRUPT 0x03 - //@} - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/USBController_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/USBController_UC3.h" - #elif (ARCH == ARCH_XMEGA) - #include "XMEGA/USBController_XMEGA.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Controller definitions for all architectures. + * \copydetails Group_USBManagement + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_USBManagement USB Interface Management + * \brief USB Controller definitions for general USB controller management. + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_H__ +#define __USBCONTROLLER_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks and Defines: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Defines: */ + /** \name Endpoint Direction Masks */ + //@{ + /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's + * direction for comparing with the \c ENDPOINT_DIR_* masks. + */ + #define ENDPOINT_DIR_MASK 0x80 + + /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with + * the index of the address within a device to obtain the full endpoint address. + */ + #define ENDPOINT_DIR_OUT 0x00 + + /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with + * the index of the address within a device to obtain the full endpoint address. + */ + #define ENDPOINT_DIR_IN 0x80 + //@} + + /** \name Endpoint/Pipe Type Masks */ + //@{ + /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared + * with the \c EP_TYPE_* masks to determine the exact type of the endpoint. + */ + #define EP_TYPE_MASK 0x03 + + /** Mask for a CONTROL type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_CONTROL 0x00 + + /** Mask for an ISOCHRONOUS type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_ISOCHRONOUS 0x01 + + /** Mask for a BULK type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_BULK 0x02 + + /** Mask for an INTERRUPT type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_INTERRUPT 0x03 + //@} + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/USBController_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/USBController_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/USBController_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/USBInterrupt.h b/hal/at90usb646/LUFA/Drivers/USB/Core/USBInterrupt.h index 5838602..05b83a1 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/USBInterrupt.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/USBInterrupt.h @@ -1,73 +1,73 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB controller interrupt service routine management. - * - * This file contains definitions required for the correct handling of low level USB service routine interrupts - * from the USB controller. - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -#ifndef __USBINTERRUPT_H__ -#define __USBINTERRUPT_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Architecture Includes: */ - #if (ARCH == ARCH_AVR8) - #include "AVR8/USBInterrupt_AVR8.h" - #elif (ARCH == ARCH_UC3) - #include "UC3/USBInterrupt_UC3.h" - #elif (ARCH == ARCH_XMEGA) - #include "XMEGA/USBInterrupt_XMEGA.h" - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB controller interrupt service routine management. + * + * This file contains definitions required for the correct handling of low level USB service routine interrupts + * from the USB controller. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBINTERRUPT_H__ +#define __USBINTERRUPT_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/USBInterrupt_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/USBInterrupt_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/USBInterrupt_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/USBMode.h b/hal/at90usb646/LUFA/Drivers/USB/Core/USBMode.h index 2cb1c0f..bc2f86d 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/USBMode.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/USBMode.h @@ -1,263 +1,263 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief USB mode and feature support definitions. - * \copydetails Group_USBMode - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -/** \ingroup Group_USB - * \defgroup Group_USBMode USB Mode Tokens - * \brief USB mode and feature support definitions. - * - * This file defines macros indicating the type of USB controller the library is being compiled for, and its - * capabilities. These macros may then be referenced in the user application to selectively enable or disable - * code sections depending on if they are defined or not. - * - * After the inclusion of the master USB driver header, one or more of the following tokens may be defined, to - * allow the user code to conditionally enable or disable code based on the USB controller family and allowable - * USB modes. These tokens may be tested against to eliminate code relating to a USB mode which is not enabled for - * the given compilation. - * - * @{ - */ - -#ifndef __USBMODE_H__ -#define __USBMODE_H__ - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - #if defined(__DOXYGEN__) - /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller - * (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined. - */ - #define USB_SERIES_2_AVR - - /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller - * (i.e. ATMEGAxxU4) when defined. - */ - #define USB_SERIES_4_AVR - - /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller - * (i.e. AT90USBxxx6) when defined. - */ - #define USB_SERIES_6_AVR - - /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller - * (i.e. AT90USBxxx7) when defined. - */ - #define USB_SERIES_7_AVR - - /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller - * (i.e. AT32UC3A0*) when defined. - */ - #define USB_SERIES_UC3A0_AVR - - /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller - * (i.e. AT32UC3A1*) when defined. - */ - #define USB_SERIES_UC3A1_AVR - - /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller - * (i.e. AT32UC3A3*) when defined. - */ - #define USB_SERIES_UC3A3_AVR - - /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller - * (i.e. AT32UC3B0*) when defined. - */ - #define USB_SERIES_UC3B0_AVR - - /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller - * (i.e. AT32UC3B1*) when defined. - */ - #define USB_SERIES_UC3B1_AVR - - /** Indicates that the target AVR microcontroller belongs to the XMEGA A1U Series USB controller - * (i.e. ATXMEGA*A1U) when defined. - */ - #define USB_SERIES_A1U_XMEGA - - /** Indicates that the target AVR microcontroller belongs to the XMEGA A3U Series USB controller - * (i.e. ATXMEGA*A3U) when defined. - */ - #define USB_SERIES_A3U_XMEGA - - /** Indicates that the target AVR microcontroller belongs to the XMEGA A4U Series USB controller - * (i.e. ATXMEGA*A4U) when defined. - */ - #define USB_SERIES_A4U_XMEGA - - /** Indicates that the target AVR microcontroller belongs to the XMEGA B1 Series USB controller - * (i.e. ATXMEGA*B1) when defined. - */ - #define USB_SERIES_B1_XMEGA - - /** Indicates that the target AVR microcontroller belongs to the XMEGA B3 Series USB controller - * (i.e. ATXMEGA*B3) when defined. - */ - #define USB_SERIES_B3_XMEGA - - /** Indicates that the target microcontroller and compilation settings allow for the - * target to be configured in USB Device mode when defined. - */ - #define USB_CAN_BE_DEVICE - - /** Indicates that the target microcontroller and compilation settings allow for the - * target to be configured in USB Host mode when defined. - */ - #define USB_CAN_BE_HOST - - /** Indicates that the target microcontroller and compilation settings allow for the - * target to be configured in either USB Device or Host mode when defined. - */ - #define USB_CAN_BE_BOTH - #else - /* Macros: */ - #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \ - defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) - #define USB_SERIES_2_AVR - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)) - #define USB_SERIES_4_AVR - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) - #define USB_SERIES_6_AVR - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) - #define USB_SERIES_7_AVR - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \ - defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__)) - #define USB_SERIES_UC3A0_AVR32 - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \ - defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__)) - #define USB_SERIES_UC3A1_AVR32 - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \ - defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \ - defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A364S__)) - #define USB_SERIES_UC3A3_AVR32 - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \ - defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \ - defined(__AVR32_UC3A464__) || defined(__AVR32_UC3A464S__)) - #define USB_SERIES_UC3A4_AVR32 - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \ - defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__)) - #define USB_SERIES_UC3B0_AVR32 - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \ - defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__)) - #define USB_SERIES_UC3B1_AVR32 - #define USB_CAN_BE_DEVICE - #define USB_CAN_BE_HOST - #elif (defined(__AVR_ATxmega128A1U__) || defined(__AVR_ATxmega64A1U__)) - #define USB_SERIES_A1U_XMEGA - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATxmega64A3U__) || defined(__AVR_ATxmega128A3U__) || \ - defined(__AVR_ATxmega192A3U__) || defined(__AVR_ATxmega256A3U__)) - #define USB_SERIES_A3U_XMEGA - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATxmega256A3BU__)) - #define USB_SERIES_A3BU_XMEGA - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATxmega16A4U__) || defined(__AVR_ATxmega32A4U__) || \ - defined(__AVR_ATxmega64A4U__) || defined(__AVR_ATxmega128A4U__)) - #define USB_SERIES_A4U_XMEGA - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATxmega128B1__) || defined(__AVR_ATxmega64B1__)) - #define USB_SERIES_B1_XMEGA - #define USB_CAN_BE_DEVICE - #elif (defined(__AVR_ATxmega128B3__) || defined(__AVR_ATxmega64B3__)) - #define USB_SERIES_B3_XMEGA - #define USB_CAN_BE_DEVICE - #endif - - #if (defined(USB_CAN_BE_DEVICE) && defined(USB_CAN_BE_HOST)) - #define USB_CAN_BE_BOTH - #endif - - #if defined(USB_HOST_ONLY) - #if !defined(USB_CAN_BE_HOST) - #error USB_HOST_ONLY is not available for the currently selected microcontroller model. - #else - #undef USB_CAN_BE_DEVICE - #undef USB_CAN_BE_BOTH - #endif - #endif - - #if defined(USB_DEVICE_ONLY) - #if !defined(USB_CAN_BE_DEVICE) - #error USB_DEVICE_ONLY is not available for the currently selected microcontroller model. - #else - #undef USB_CAN_BE_HOST - #undef USB_CAN_BE_BOTH - #endif - #endif - - #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY)) - #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive. - #endif - - #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST)) - #error The currently selected device or architecture is not supported under the USB component of the library. - #endif - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - -/** @} */ - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB mode and feature support definitions. + * \copydetails Group_USBMode + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_USBMode USB Mode Tokens + * \brief USB mode and feature support definitions. + * + * This file defines macros indicating the type of USB controller the library is being compiled for, and its + * capabilities. These macros may then be referenced in the user application to selectively enable or disable + * code sections depending on if they are defined or not. + * + * After the inclusion of the master USB driver header, one or more of the following tokens may be defined, to + * allow the user code to conditionally enable or disable code based on the USB controller family and allowable + * USB modes. These tokens may be tested against to eliminate code relating to a USB mode which is not enabled for + * the given compilation. + * + * @{ + */ + +#ifndef __USBMODE_H__ +#define __USBMODE_H__ + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + #if defined(__DOXYGEN__) + /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller + * (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined. + */ + #define USB_SERIES_2_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller + * (i.e. ATMEGAxxU4) when defined. + */ + #define USB_SERIES_4_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller + * (i.e. AT90USBxxx6) when defined. + */ + #define USB_SERIES_6_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller + * (i.e. AT90USBxxx7) when defined. + */ + #define USB_SERIES_7_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller + * (i.e. AT32UC3A0*) when defined. + */ + #define USB_SERIES_UC3A0_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller + * (i.e. AT32UC3A1*) when defined. + */ + #define USB_SERIES_UC3A1_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller + * (i.e. AT32UC3A3*) when defined. + */ + #define USB_SERIES_UC3A3_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller + * (i.e. AT32UC3B0*) when defined. + */ + #define USB_SERIES_UC3B0_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller + * (i.e. AT32UC3B1*) when defined. + */ + #define USB_SERIES_UC3B1_AVR + + /** Indicates that the target AVR microcontroller belongs to the XMEGA A1U Series USB controller + * (i.e. ATXMEGA*A1U) when defined. + */ + #define USB_SERIES_A1U_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA A3U Series USB controller + * (i.e. ATXMEGA*A3U) when defined. + */ + #define USB_SERIES_A3U_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA A4U Series USB controller + * (i.e. ATXMEGA*A4U) when defined. + */ + #define USB_SERIES_A4U_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA B1 Series USB controller + * (i.e. ATXMEGA*B1) when defined. + */ + #define USB_SERIES_B1_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA B3 Series USB controller + * (i.e. ATXMEGA*B3) when defined. + */ + #define USB_SERIES_B3_XMEGA + + /** Indicates that the target microcontroller and compilation settings allow for the + * target to be configured in USB Device mode when defined. + */ + #define USB_CAN_BE_DEVICE + + /** Indicates that the target microcontroller and compilation settings allow for the + * target to be configured in USB Host mode when defined. + */ + #define USB_CAN_BE_HOST + + /** Indicates that the target microcontroller and compilation settings allow for the + * target to be configured in either USB Device or Host mode when defined. + */ + #define USB_CAN_BE_BOTH + #else + /* Macros: */ + #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \ + defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) + #define USB_SERIES_2_AVR + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)) + #define USB_SERIES_4_AVR + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) + #define USB_SERIES_6_AVR + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) + #define USB_SERIES_7_AVR + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \ + defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__)) + #define USB_SERIES_UC3A0_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \ + defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__)) + #define USB_SERIES_UC3A1_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \ + defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \ + defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A364S__)) + #define USB_SERIES_UC3A3_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \ + defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \ + defined(__AVR32_UC3A464__) || defined(__AVR32_UC3A464S__)) + #define USB_SERIES_UC3A4_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \ + defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__)) + #define USB_SERIES_UC3B0_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \ + defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__)) + #define USB_SERIES_UC3B1_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR_ATxmega128A1U__) || defined(__AVR_ATxmega64A1U__)) + #define USB_SERIES_A1U_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega64A3U__) || defined(__AVR_ATxmega128A3U__) || \ + defined(__AVR_ATxmega192A3U__) || defined(__AVR_ATxmega256A3U__)) + #define USB_SERIES_A3U_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega256A3BU__)) + #define USB_SERIES_A3BU_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega16A4U__) || defined(__AVR_ATxmega32A4U__) || \ + defined(__AVR_ATxmega64A4U__) || defined(__AVR_ATxmega128A4U__)) + #define USB_SERIES_A4U_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega128B1__) || defined(__AVR_ATxmega64B1__)) + #define USB_SERIES_B1_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega128B3__) || defined(__AVR_ATxmega64B3__)) + #define USB_SERIES_B3_XMEGA + #define USB_CAN_BE_DEVICE + #endif + + #if (defined(USB_CAN_BE_DEVICE) && defined(USB_CAN_BE_HOST)) + #define USB_CAN_BE_BOTH + #endif + + #if defined(USB_HOST_ONLY) + #if !defined(USB_CAN_BE_HOST) + #error USB_HOST_ONLY is not available for the currently selected microcontroller model. + #else + #undef USB_CAN_BE_DEVICE + #undef USB_CAN_BE_BOTH + #endif + #endif + + #if defined(USB_DEVICE_ONLY) + #if !defined(USB_CAN_BE_DEVICE) + #error USB_DEVICE_ONLY is not available for the currently selected microcontroller model. + #else + #undef USB_CAN_BE_HOST + #undef USB_CAN_BE_BOTH + #endif + #endif + + #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY)) + #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive. + #endif + + #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST)) + #error The currently selected device or architecture is not supported under the USB component of the library. + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.c b/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.c index e0a9915..b0b6914 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.c +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.c @@ -1,91 +1,91 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define __INCLUDE_FROM_USBTASK_C -#define __INCLUDE_FROM_USB_DRIVER -#include "USBTask.h" - -volatile bool USB_IsInitialized; -USB_Request_Header_t USB_ControlRequest; - -#if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR) -volatile uint8_t USB_HostState; -#endif - -#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR) -volatile uint8_t USB_DeviceState; -#endif - -void USB_USBTask(void) -{ - #if defined(USB_HOST_ONLY) - USB_HostTask(); - #elif defined(USB_DEVICE_ONLY) - USB_DeviceTask(); - #else - if (USB_CurrentMode == USB_MODE_Device) - USB_DeviceTask(); - #if defined(USB_CAN_BE_HOST) - else if (USB_CurrentMode == USB_MODE_Host) - USB_HostTask(); - #endif - #endif -} - -#if defined(USB_CAN_BE_DEVICE) -static void USB_DeviceTask(void) -{ - if (USB_DeviceState != DEVICE_STATE_Unattached) - { - uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); - - Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); - - if (Endpoint_IsSETUPReceived()) - USB_Device_ProcessControlRequest(); - - Endpoint_SelectEndpoint(PrevEndpoint); - } -} -#endif - -#if defined(USB_CAN_BE_HOST) -static void USB_HostTask(void) -{ - uint8_t PrevPipe = Pipe_GetCurrentPipe(); - - Pipe_SelectPipe(PIPE_CONTROLPIPE); - - USB_Host_ProcessNextHostState(); - - Pipe_SelectPipe(PrevPipe); -} -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USBTASK_C +#define __INCLUDE_FROM_USB_DRIVER +#include "USBTask.h" + +volatile bool USB_IsInitialized; +USB_Request_Header_t USB_ControlRequest; + +#if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR) +volatile uint8_t USB_HostState; +#endif + +#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR) +volatile uint8_t USB_DeviceState; +#endif + +void USB_USBTask(void) +{ + #if defined(USB_HOST_ONLY) + USB_HostTask(); + #elif defined(USB_DEVICE_ONLY) + USB_DeviceTask(); + #else + if (USB_CurrentMode == USB_MODE_Device) + USB_DeviceTask(); + #if defined(USB_CAN_BE_HOST) + else if (USB_CurrentMode == USB_MODE_Host) + USB_HostTask(); + #endif + #endif +} + +#if defined(USB_CAN_BE_DEVICE) +static void USB_DeviceTask(void) +{ + if (USB_DeviceState != DEVICE_STATE_Unattached) + { + uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + if (Endpoint_IsSETUPReceived()) + USB_Device_ProcessControlRequest(); + + Endpoint_SelectEndpoint(PrevEndpoint); + } +} +#endif + +#if defined(USB_CAN_BE_HOST) +static void USB_HostTask(void) +{ + uint8_t PrevPipe = Pipe_GetCurrentPipe(); + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + USB_Host_ProcessNextHostState(); + + Pipe_SelectPipe(PrevPipe); +} +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.h b/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.h index 223cfab..bd367b2 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.h +++ b/hal/at90usb646/LUFA/Drivers/USB/Core/USBTask.h @@ -1,204 +1,204 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Main USB service task management. - * - * This file contains the function definitions required for the main USB service task, which must be called - * from the user application to ensure that the USB connection to or from a connected USB device is maintained. - * - * \note This file should not be included directly. It is automatically included as needed by the USB driver - * dispatch header located in LUFA/Drivers/USB/USB.h. - */ - -#ifndef __USBTASK_H__ -#define __USBTASK_H__ - - /* Includes: */ - #include "../../../Common/Common.h" - #include "USBMode.h" - #include "USBController.h" - #include "Events.h" - #include "StdRequestType.h" - #include "StdDescriptors.h" - - #if defined(USB_CAN_BE_DEVICE) - #include "DeviceStandardReq.h" - #endif - - #if defined(USB_CAN_BE_HOST) - #include "HostStandardReq.h" - #endif - - /* Enable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - extern "C" { - #endif - - /* Preprocessor Checks: */ - #if !defined(__INCLUDE_FROM_USB_DRIVER) - #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. - #endif - - /* Public Interface - May be used in end-application: */ - /* Global Variables: */ - /** Indicates if the USB interface is currently initialized but not necessarily connected to a host - * or device (i.e. if \ref USB_Init() has been run). If this is false, all other library globals related - * to the USB driver are invalid. - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value. - * - * \ingroup Group_USBManagement - */ - extern volatile bool USB_IsInitialized; - - /** Structure containing the last received Control request when in Device mode (for use in user-applications - * inside of the \ref EVENT_USB_Device_ControlRequest() event, or for filling up with a control request to - * issue when in Host mode before calling \ref USB_Host_SendControlRequest(). - * - * \note The contents of this structure is automatically endian-corrected for the current CPU architecture. - * - * \ingroup Group_USBManagement - */ - extern USB_Request_Header_t USB_ControlRequest; - - #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) - #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__) - /** Indicates the current host state machine state. When in host mode, this indicates the state - * via one of the values of the \ref USB_Host_States_t enum values. - * - * This value should not be altered by the user application as it is handled automatically by the - * library. - * - * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be - * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the - * \c HOST_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to - * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used - * in the user application except implicitly via the library APIs. - * - * \note This global is only present if the user application can be a USB host. - * - * \see \ref USB_Host_States_t for a list of possible device states. - * - * \ingroup Group_Host - */ - extern volatile uint8_t USB_HostState; - #else - #define _GET_HOST_GPIOR_NAME2(y) GPIOR ## y - #define _GET_HOST_GPIOR_NAME(x) _GET_HOST_GPIOR_NAME2(x) - #define USB_HostState _GET_HOST_GPIOR_NAME(HOST_STATE_AS_GPIOR) - #endif - #endif - - #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) - #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__) - /** Indicates the current device state machine state. When in device mode, this indicates the state - * via one of the values of the \ref USB_Device_States_t enum values. - * - * This value should not be altered by the user application as it is handled automatically by the - * library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used - * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events). - * - * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be - * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the - * \c DEVICE_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to - * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used - * in the user application except implicitly via the library APIs. - * - * \note This global is only present if the user application can be a USB device. - * \n\n - * - * \note This variable should be treated as read-only in the user application, and never manually - * changed in value except in the circumstances outlined above. - * - * \see \ref USB_Device_States_t for a list of possible device states. - * - * \ingroup Group_Device - */ - extern volatile uint8_t USB_DeviceState; - #else - #define _GET_DEVICE_GPIOR_NAME2(y) GPIOR ## y - #define _GET_DEVICE_GPIOR_NAME(x) _GET_DEVICE_GPIOR_NAME2(x) - #define USB_DeviceState _GET_DEVICE_GPIOR_NAME(DEVICE_STATE_AS_GPIOR) - #endif - #endif - - /* Function Prototypes: */ - /** This is the main USB management task. The USB driver requires this task to be executed - * continuously when the USB system is active (device attached in host mode, or attached to a host - * in device mode) in order to manage USB communications. This task may be executed inside an RTOS, - * fast timer ISR or the main user application loop. - * - * The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode. - * The task may be serviced at all times, or (for minimum CPU consumption): - * - * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect() - * event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event. - * - * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached() - * event and disabled again on the firing of the \ref EVENT_USB_Host_DeviceEnumerationComplete() or - * \ref EVENT_USB_Host_DeviceEnumerationFailed() events. - * - * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library - * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch. - * - * \see \ref Group_Events for more information on the USB events. - * - * \ingroup Group_USBManagement - */ - void USB_USBTask(void); - - /* Private Interface - For use in library only: */ - #if !defined(__DOXYGEN__) - /* Function Prototypes: */ - #if defined(__INCLUDE_FROM_USBTASK_C) - #if defined(USB_CAN_BE_HOST) - static void USB_HostTask(void); - #endif - - #if defined(USB_CAN_BE_DEVICE) - static void USB_DeviceTask(void); - #endif - #endif - - /* Macros: */ - #define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \ - WaitMSRemaining = (Duration); \ - PostWaitState = (NextState); }MACROE - #endif - - /* Disable C linkage for C++ Compilers: */ - #if defined(__cplusplus) - } - #endif - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Main USB service task management. + * + * This file contains the function definitions required for the main USB service task, which must be called + * from the user application to ensure that the USB connection to or from a connected USB device is maintained. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBTASK_H__ +#define __USBTASK_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "USBController.h" + #include "Events.h" + #include "StdRequestType.h" + #include "StdDescriptors.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "DeviceStandardReq.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "HostStandardReq.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Global Variables: */ + /** Indicates if the USB interface is currently initialized but not necessarily connected to a host + * or device (i.e. if \ref USB_Init() has been run). If this is false, all other library globals related + * to the USB driver are invalid. + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \ingroup Group_USBManagement + */ + extern volatile bool USB_IsInitialized; + + /** Structure containing the last received Control request when in Device mode (for use in user-applications + * inside of the \ref EVENT_USB_Device_ControlRequest() event, or for filling up with a control request to + * issue when in Host mode before calling \ref USB_Host_SendControlRequest(). + * + * \note The contents of this structure is automatically endian-corrected for the current CPU architecture. + * + * \ingroup Group_USBManagement + */ + extern USB_Request_Header_t USB_ControlRequest; + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__) + /** Indicates the current host state machine state. When in host mode, this indicates the state + * via one of the values of the \ref USB_Host_States_t enum values. + * + * This value should not be altered by the user application as it is handled automatically by the + * library. + * + * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be + * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the + * \c HOST_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to + * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used + * in the user application except implicitly via the library APIs. + * + * \note This global is only present if the user application can be a USB host. + * + * \see \ref USB_Host_States_t for a list of possible device states. + * + * \ingroup Group_Host + */ + extern volatile uint8_t USB_HostState; + #else + #define _GET_HOST_GPIOR_NAME2(y) GPIOR ## y + #define _GET_HOST_GPIOR_NAME(x) _GET_HOST_GPIOR_NAME2(x) + #define USB_HostState _GET_HOST_GPIOR_NAME(HOST_STATE_AS_GPIOR) + #endif + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__) + /** Indicates the current device state machine state. When in device mode, this indicates the state + * via one of the values of the \ref USB_Device_States_t enum values. + * + * This value should not be altered by the user application as it is handled automatically by the + * library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used + * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events). + * + * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be + * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the + * \c DEVICE_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to + * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used + * in the user application except implicitly via the library APIs. + * + * \note This global is only present if the user application can be a USB device. + * \n\n + * + * \note This variable should be treated as read-only in the user application, and never manually + * changed in value except in the circumstances outlined above. + * + * \see \ref USB_Device_States_t for a list of possible device states. + * + * \ingroup Group_Device + */ + extern volatile uint8_t USB_DeviceState; + #else + #define _GET_DEVICE_GPIOR_NAME2(y) GPIOR ## y + #define _GET_DEVICE_GPIOR_NAME(x) _GET_DEVICE_GPIOR_NAME2(x) + #define USB_DeviceState _GET_DEVICE_GPIOR_NAME(DEVICE_STATE_AS_GPIOR) + #endif + #endif + + /* Function Prototypes: */ + /** This is the main USB management task. The USB driver requires this task to be executed + * continuously when the USB system is active (device attached in host mode, or attached to a host + * in device mode) in order to manage USB communications. This task may be executed inside an RTOS, + * fast timer ISR or the main user application loop. + * + * The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode. + * The task may be serviced at all times, or (for minimum CPU consumption): + * + * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect() + * event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event. + * + * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached() + * event and disabled again on the firing of the \ref EVENT_USB_Host_DeviceEnumerationComplete() or + * \ref EVENT_USB_Host_DeviceEnumerationFailed() events. + * + * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library + * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch. + * + * \see \ref Group_Events for more information on the USB events. + * + * \ingroup Group_USBManagement + */ + void USB_USBTask(void); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_USBTASK_C) + #if defined(USB_CAN_BE_HOST) + static void USB_HostTask(void); + #endif + + #if defined(USB_CAN_BE_DEVICE) + static void USB_DeviceTask(void); + #endif + #endif + + /* Macros: */ + #define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \ + WaitMSRemaining = (Duration); \ + PostWaitState = (NextState); }MACROE + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/hal/at90usb646/LUFA/Drivers/USB/USB.h b/hal/at90usb646/LUFA/Drivers/USB/USB.h index 1941e1d..8d85916 100644 --- a/hal/at90usb646/LUFA/Drivers/USB/USB.h +++ b/hal/at90usb646/LUFA/Drivers/USB/USB.h @@ -1,414 +1,414 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * \brief Master include file for the library USB functionality. - * - * Master include file for the library USB functionality. - * - * This file should be included in all user projects making use of the USB portions of the library, instead of - * the individual USB driver submodule headers. - */ - -/** \defgroup Group_USB USB Core - LUFA/Drivers/USB/USB.h - * - * \section Sec_Dependencies Module Source Dependencies - * The following files must be built with any user project that uses this module: - * - LUFA/Drivers/USB/Core/ConfigDescriptor.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/DeviceStandardReq.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/Events.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/HostStandardReq.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/USBTask.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/Device_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/Endpoint_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/EndpointStream_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/Host_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/Pipe_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/PipeStream_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/USBController_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Core/ARCH/USBInterrupt_ARCH.c (Makefile source module name: LUFA_SRC_USB) - * - LUFA/Drivers/USB/Class/Common/HIDParser.c (Makefile source module name: LUFA_SRC_USB) - * - * \section Sec_ModDescription Module Description - * Driver and framework for the USB controller of the selected architecture and microcontroller model. This module - * consists of many submodules, and is designed to provide an easy way to configure and control USB host, device - * or OTG mode USB applications. - * - * The USB stack requires the sole control over the USB controller in the microcontroller only; i.e. it does not - * require any additional timers or other peripherals to operate. This ensures that the USB stack requires as few - * resources as possible. - * - * The USB stack can be used in Device Mode for connections to USB Hosts (see \ref Group_Device), in Host mode for - * hosting of other USB devices (see \ref Group_Host), or as a dual role device which can either act as a USB host - * or device depending on what peripheral is connected (see \ref Group_OTG). Both modes also require a common set - * of USB management functions found \ref Group_USBManagement. - */ - -/** \defgroup Group_USBClassDrivers USB Class Drivers - * - * Drivers for both host and device mode of the standard USB classes, for rapid application development. - * Class drivers give a framework which sits on top of the low level library API, allowing for standard - * USB classes to be implemented in a project with minimal user code. These drivers can be used in - * conjunction with the library low level APIs to implement interfaces both via the class drivers and via - * the standard library APIs. - * - * Multiple device mode class drivers can be used within a project, including multiple instances of the - * same class driver. In this way, USB Hosts and Devices can be made quickly using the internal class drivers - * so that more time and effort can be put into the end application instead of the USB protocol. - * - * The available class drivers and their modes are listed below. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -* - * - * - * - * - * - * - * - * - * - * - * - *
USB ClassDevice ModeHost Mode
Android Open AccessoryNoYes
Audio 1.0YesYes
CDC-ACMYesYes
HIDYesYes
MIDIYesYes
Mass StorageYesYes
PrinterNoYes
RNDISYesYes
Still ImageNoYes
- * - * - * \section Sec_UsingClassDrivers Using the Class Drivers - * To make the Class drivers easy to integrate into a user application, they all implement a standardized - * design with similarly named/used function, enums, defines and types. The two different modes are implemented - * slightly differently, and thus will be explained separately. For information on a specific class driver, read - * the class driver's module documentation. - * - * \subsection Sec_ClassDriverDevice Device Mode Class Drivers - * Implementing a Device Mode Class Driver in a user application requires a number of steps to be followed. Firstly, - * the module configuration and state structure must be added to the project source. These structures are named in a - * similar manner between classes, that of USB_ClassInfo_{Class Name}_Device_t, and are used to hold the - * complete state and configuration for each class instance. Multiple class instances is where the power of the class - * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_* - * structure. - * - * Inside the ClassInfo structure lies two sections, a \c Config section, and a \c State section. The \c Config - * section contains the instance's configuration parameters, and must have all fields set by the user application - * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters - * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters. - * - * \note The \c State section of the \c USB_ClassInfo_* structures are designed to be controlled by the Class Drivers only - * for maintaining the Class Driver instance's state, and should not normally be altered by the user application. - * - * The following is an example of a properly initialized instance of the Audio Class Driver structure: - * - * \code - * USB_ClassInfo_Audio_Device_t My_Audio_Interface = - * { - * .Config = - * { - * .StreamingInterfaceNumber = 1, - * - * .DataINEndpointNumber = 1, - * .DataINEndpointSize = 256, - * }, - * }; - * \endcode - * - * \note The class driver's configuration parameters should match those used in the device's descriptors that are - * sent to the host. - * - * To initialize the Class driver instance, the driver's {Class Name}_Device_ConfigureEndpoints() function - * should be called in response to the \ref EVENT_USB_Device_ConfigurationChanged() event. This function will return a - * boolean true value if the driver successfully initialized the instance. Like all the class driver functions, this function - * takes in the address of the specific instance you wish to initialize - in this manner, multiple separate instances of - * the same class type can be initialized like this: - * - * \code - * void EVENT_USB_Device_ConfigurationChanged(void) - * { - * LEDs_SetAllLEDs(LEDMASK_USB_READY); - * - * if (!(Audio_Device_ConfigureEndpoints(&My_Audio_Interface))) - * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - * } - * \endcode - * - * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's - * {Class Name}_Device_USBTask() function in the main program loop. The exact implementation of this - * function varies between class drivers, and can be used for any internal class driver purpose to maintain each - * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each - * separate instance, just like the main USB maintenance routine \ref USB_USBTask(): - * - * \code - * int main(void) - * { - * SetupHardware(); - * - * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - * - * for (;;) - * { - * if (USB_DeviceState != DEVICE_STATE_Configured) - * Create_And_Process_Samples(); - * - * Audio_Device_USBTask(&My_Audio_Interface); - * USB_USBTask(); - * } - * } - * \endcode - * - * The final standardized Device Class Driver function is the Control Request handler function - * {Class Name}_Device_ProcessControlRequest(), which should be called when the - * \ref EVENT_USB_Device_ControlRequest() event fires. This function should also be called for - * each class driver instance, using the address of the instance to operate on as the function's - * parameter. The request handler will abort if it is determined that the current request is not - * targeted at the given class driver instance, thus these methods can safely be called - * one-after-another in the event handler with no form of error checking: - * - * \code - * void EVENT_USB_Device_ControlRequest(void) - * { - * Audio_Device_ProcessControlRequest(&My_Audio_Interface); - * } - * \endcode - * - * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_* - * in the function's name) which must also be added to the user application - refer to each - * individual class driver's documentation for mandatory callbacks. In addition, each class driver may - * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which - * the user application may choose to implement, or ignore if not needed. - * - * The individual Device Mode Class Driver documentation contains more information on the non-standardized, - * class-specific functions which the user application can then use on the driver instances, such as data - * read and write routines. See each driver's individual documentation for more information on the - * class-specific functions. - * - * \subsection Sec_ClassDriverHost Host Mode Class Drivers - * Implementing a Host Mode Class Driver in a user application requires a number of steps to be followed. Firstly, - * the module configuration and state structure must be added to the project source. These structures are named in a - * similar manner between classes, that of USB_ClassInfo_{Class Name}_Host_t, and are used to hold the - * complete state and configuration for each class instance. Multiple class instances is where the power of the class - * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_* - * structure. - * - * Inside the \c USB_ClassInfo_* structure lies two sections, a \c Config section, and a \c State section. The \c Config - * section contains the instance's configuration parameters, and must have all fields set by the user application - * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters - * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters. - * - * \note The \c State section of the \c USB_ClassInfo_* structures are designed to be controlled by the Class Drivers only - * for maintaining the Class Driver instance's state, and should not normally be altered by the user application. - * - * The following is an example of a properly initialized instance of the MIDI Host Class Driver structure: - * - * \code - * USB_ClassInfo_MIDI_Host_t My_MIDI_Interface = - * { - * .Config = - * { - * .DataINPipeNumber = 1, - * .DataINPipeDoubleBank = false, - * - * .DataOUTPipeNumber = 2, - * .DataOUTPipeDoubleBank = false, - * }, - * }; - * \endcode - * - * To initialize the Class driver instance, the driver's {Class Name}_Host_ConfigurePipes() function - * should be called in response to the \c EVENT_USB_Host_DeviceEnumerationComplete() event firing. This function will - * will return an error code from the class driver's {Class Name}_EnumerationFailure_ErrorCodes_t enum - * to indicate if the driver successfully initialized the instance and bound it to an interface in the attached device. - * Like all the class driver functions, this function takes in the address of the specific instance you wish to initialize - - * in this manner, multiple separate instances of the same class type can be initialized. A fragment of a Class Driver - * based Host mode application may look like the following: - * - * \code - * void EVENT_USB_Host_DeviceEnumerationComplete(void) - * { - * LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - * - * uint16_t ConfigDescriptorSize; - * uint8_t ConfigDescriptorData[512]; - * - * if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, - * sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) - * { - * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - * return; - * } - * - * if (MIDI_Host_ConfigurePipes(&Keyboard_MIDI_Interface, - * ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError) - * { - * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - * return; - * } - * - * if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) - * { - * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - * return; - * } - * - * LEDs_SetAllLEDs(LEDMASK_USB_READY); - * } - * \endcode - * - * Note that the function also requires the device's configuration descriptor so that it can determine which interface - * in the device to bind to - this can be retrieved as shown in the above fragment using the - * \ref USB_Host_GetDeviceConfigDescriptor() function. If the device does not implement the interface the class driver - * is looking for, if all the matching interfaces are already bound to class driver instances or if an error occurs while - * binding to a device interface (for example, a device endpoint bank larger that the maximum supported bank size is used) - * the configuration will fail. - * - * To complete the device enumeration after binding the host mode Class Drivers to the attached device, a call to - * \c USB_Host_SetDeviceConfiguration() must be made. If the device configuration is not set within the - * \c EVENT_USB_Host_DeviceEnumerationComplete() event, the host still will assume the device enumeration has failed. - * - * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's - * {Class Name}_Host_USBTask() function in the main program loop. The exact implementation of this - * function varies between class drivers, and can be used for any internal class driver purpose to maintain each - * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each - * separate instance, just like the main USB maintenance routine \ref USB_USBTask(): - * - * \code - * int main(void) - * { - * SetupHardware(); - * - * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - * - * for (;;) - * { - * if (USB_HostState != HOST_STATE_Configured) - * Create_And_Process_Samples(); - * - * MIDI_Host_USBTask(&My_Audio_Interface); - * USB_USBTask(); - * } - * } - * \endcode - * - * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_* - * in the function's name) which must also be added to the user application - refer to each - * individual class driver's documentation for mandatory callbacks. In addition, each class driver may - * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which - * the user application may choose to implement, or ignore if not needed. - * - * The individual Host Mode Class Driver documentation contains more information on the non-standardized, - * class-specific functions which the user application can then use on the driver instances, such as data - * read and write routines. See each driver's individual documentation for more information on the - * class-specific functions. - */ - -#ifndef __USB_H__ -#define __USB_H__ - - /* Macros: */ - #define __INCLUDE_FROM_USB_DRIVER - - /* Includes: */ - #include "../../Common/Common.h" - #include "Core/USBMode.h" - - /* Includes: */ - #include "Core/USBTask.h" - #include "Core/Events.h" - #include "Core/StdDescriptors.h" - #include "Core/ConfigDescriptor.h" - #include "Core/USBController.h" - #include "Core/USBInterrupt.h" - - #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) - #include "Core/Host.h" - #include "Core/Pipe.h" - #include "Core/HostStandardReq.h" - #include "Core/PipeStream.h" - #endif - - #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) - #include "Core/Device.h" - #include "Core/Endpoint.h" - #include "Core/DeviceStandardReq.h" - #include "Core/EndpointStream.h" - #endif - - #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) - #include "Core/OTG.h" - #endif - - //#include "Class/AndroidAccessoryClass.h" - //#include "Class/AudioClass.h" - #include "Class/CDCClass.h" - //#include "Class/HIDClass.h" - //#include "Class/MassStorageClass.h" - //#include "Class/MIDIClass.h" - //#include "Class/PrinterClass.h" - //#include "Class/RNDISClass.h" - //#include "Class/StillImageClass.h" - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB functionality. + * + * Master include file for the library USB functionality. + * + * This file should be included in all user projects making use of the USB portions of the library, instead of + * the individual USB driver submodule headers. + */ + +/** \defgroup Group_USB USB Core - LUFA/Drivers/USB/USB.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Core/ConfigDescriptor.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/DeviceStandardReq.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/Events.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/HostStandardReq.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/USBTask.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Device_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Endpoint_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/EndpointStream_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Host_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Pipe_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/PipeStream_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/USBController_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/USBInterrupt_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Class/Common/HIDParser.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Sec_ModDescription Module Description + * Driver and framework for the USB controller of the selected architecture and microcontroller model. This module + * consists of many submodules, and is designed to provide an easy way to configure and control USB host, device + * or OTG mode USB applications. + * + * The USB stack requires the sole control over the USB controller in the microcontroller only; i.e. it does not + * require any additional timers or other peripherals to operate. This ensures that the USB stack requires as few + * resources as possible. + * + * The USB stack can be used in Device Mode for connections to USB Hosts (see \ref Group_Device), in Host mode for + * hosting of other USB devices (see \ref Group_Host), or as a dual role device which can either act as a USB host + * or device depending on what peripheral is connected (see \ref Group_OTG). Both modes also require a common set + * of USB management functions found \ref Group_USBManagement. + */ + +/** \defgroup Group_USBClassDrivers USB Class Drivers + * + * Drivers for both host and device mode of the standard USB classes, for rapid application development. + * Class drivers give a framework which sits on top of the low level library API, allowing for standard + * USB classes to be implemented in a project with minimal user code. These drivers can be used in + * conjunction with the library low level APIs to implement interfaces both via the class drivers and via + * the standard library APIs. + * + * Multiple device mode class drivers can be used within a project, including multiple instances of the + * same class driver. In this way, USB Hosts and Devices can be made quickly using the internal class drivers + * so that more time and effort can be put into the end application instead of the USB protocol. + * + * The available class drivers and their modes are listed below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * +* + * + * + * + * + * + * + * + * + * + * + * + *
USB ClassDevice ModeHost Mode
Android Open AccessoryNoYes
Audio 1.0YesYes
CDC-ACMYesYes
HIDYesYes
MIDIYesYes
Mass StorageYesYes
PrinterNoYes
RNDISYesYes
Still ImageNoYes
+ * + * + * \section Sec_UsingClassDrivers Using the Class Drivers + * To make the Class drivers easy to integrate into a user application, they all implement a standardized + * design with similarly named/used function, enums, defines and types. The two different modes are implemented + * slightly differently, and thus will be explained separately. For information on a specific class driver, read + * the class driver's module documentation. + * + * \subsection Sec_ClassDriverDevice Device Mode Class Drivers + * Implementing a Device Mode Class Driver in a user application requires a number of steps to be followed. Firstly, + * the module configuration and state structure must be added to the project source. These structures are named in a + * similar manner between classes, that of USB_ClassInfo_{Class Name}_Device_t, and are used to hold the + * complete state and configuration for each class instance. Multiple class instances is where the power of the class + * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_* + * structure. + * + * Inside the ClassInfo structure lies two sections, a \c Config section, and a \c State section. The \c Config + * section contains the instance's configuration parameters, and must have all fields set by the user application + * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters + * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters. + * + * \note The \c State section of the \c USB_ClassInfo_* structures are designed to be controlled by the Class Drivers only + * for maintaining the Class Driver instance's state, and should not normally be altered by the user application. + * + * The following is an example of a properly initialized instance of the Audio Class Driver structure: + * + * \code + * USB_ClassInfo_Audio_Device_t My_Audio_Interface = + * { + * .Config = + * { + * .StreamingInterfaceNumber = 1, + * + * .DataINEndpointNumber = 1, + * .DataINEndpointSize = 256, + * }, + * }; + * \endcode + * + * \note The class driver's configuration parameters should match those used in the device's descriptors that are + * sent to the host. + * + * To initialize the Class driver instance, the driver's {Class Name}_Device_ConfigureEndpoints() function + * should be called in response to the \ref EVENT_USB_Device_ConfigurationChanged() event. This function will return a + * boolean true value if the driver successfully initialized the instance. Like all the class driver functions, this function + * takes in the address of the specific instance you wish to initialize - in this manner, multiple separate instances of + * the same class type can be initialized like this: + * + * \code + * void EVENT_USB_Device_ConfigurationChanged(void) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_READY); + * + * if (!(Audio_Device_ConfigureEndpoints(&My_Audio_Interface))) + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * } + * \endcode + * + * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's + * {Class Name}_Device_USBTask() function in the main program loop. The exact implementation of this + * function varies between class drivers, and can be used for any internal class driver purpose to maintain each + * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each + * separate instance, just like the main USB maintenance routine \ref USB_USBTask(): + * + * \code + * int main(void) + * { + * SetupHardware(); + * + * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + * + * for (;;) + * { + * if (USB_DeviceState != DEVICE_STATE_Configured) + * Create_And_Process_Samples(); + * + * Audio_Device_USBTask(&My_Audio_Interface); + * USB_USBTask(); + * } + * } + * \endcode + * + * The final standardized Device Class Driver function is the Control Request handler function + * {Class Name}_Device_ProcessControlRequest(), which should be called when the + * \ref EVENT_USB_Device_ControlRequest() event fires. This function should also be called for + * each class driver instance, using the address of the instance to operate on as the function's + * parameter. The request handler will abort if it is determined that the current request is not + * targeted at the given class driver instance, thus these methods can safely be called + * one-after-another in the event handler with no form of error checking: + * + * \code + * void EVENT_USB_Device_ControlRequest(void) + * { + * Audio_Device_ProcessControlRequest(&My_Audio_Interface); + * } + * \endcode + * + * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_* + * in the function's name) which must also be added to the user application - refer to each + * individual class driver's documentation for mandatory callbacks. In addition, each class driver may + * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which + * the user application may choose to implement, or ignore if not needed. + * + * The individual Device Mode Class Driver documentation contains more information on the non-standardized, + * class-specific functions which the user application can then use on the driver instances, such as data + * read and write routines. See each driver's individual documentation for more information on the + * class-specific functions. + * + * \subsection Sec_ClassDriverHost Host Mode Class Drivers + * Implementing a Host Mode Class Driver in a user application requires a number of steps to be followed. Firstly, + * the module configuration and state structure must be added to the project source. These structures are named in a + * similar manner between classes, that of USB_ClassInfo_{Class Name}_Host_t, and are used to hold the + * complete state and configuration for each class instance. Multiple class instances is where the power of the class + * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_* + * structure. + * + * Inside the \c USB_ClassInfo_* structure lies two sections, a \c Config section, and a \c State section. The \c Config + * section contains the instance's configuration parameters, and must have all fields set by the user application + * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters + * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters. + * + * \note The \c State section of the \c USB_ClassInfo_* structures are designed to be controlled by the Class Drivers only + * for maintaining the Class Driver instance's state, and should not normally be altered by the user application. + * + * The following is an example of a properly initialized instance of the MIDI Host Class Driver structure: + * + * \code + * USB_ClassInfo_MIDI_Host_t My_MIDI_Interface = + * { + * .Config = + * { + * .DataINPipeNumber = 1, + * .DataINPipeDoubleBank = false, + * + * .DataOUTPipeNumber = 2, + * .DataOUTPipeDoubleBank = false, + * }, + * }; + * \endcode + * + * To initialize the Class driver instance, the driver's {Class Name}_Host_ConfigurePipes() function + * should be called in response to the \c EVENT_USB_Host_DeviceEnumerationComplete() event firing. This function will + * will return an error code from the class driver's {Class Name}_EnumerationFailure_ErrorCodes_t enum + * to indicate if the driver successfully initialized the instance and bound it to an interface in the attached device. + * Like all the class driver functions, this function takes in the address of the specific instance you wish to initialize - + * in this manner, multiple separate instances of the same class type can be initialized. A fragment of a Class Driver + * based Host mode application may look like the following: + * + * \code + * void EVENT_USB_Host_DeviceEnumerationComplete(void) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); + * + * uint16_t ConfigDescriptorSize; + * uint8_t ConfigDescriptorData[512]; + * + * if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + * sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * return; + * } + * + * if (MIDI_Host_ConfigurePipes(&Keyboard_MIDI_Interface, + * ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * return; + * } + * + * if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * return; + * } + * + * LEDs_SetAllLEDs(LEDMASK_USB_READY); + * } + * \endcode + * + * Note that the function also requires the device's configuration descriptor so that it can determine which interface + * in the device to bind to - this can be retrieved as shown in the above fragment using the + * \ref USB_Host_GetDeviceConfigDescriptor() function. If the device does not implement the interface the class driver + * is looking for, if all the matching interfaces are already bound to class driver instances or if an error occurs while + * binding to a device interface (for example, a device endpoint bank larger that the maximum supported bank size is used) + * the configuration will fail. + * + * To complete the device enumeration after binding the host mode Class Drivers to the attached device, a call to + * \c USB_Host_SetDeviceConfiguration() must be made. If the device configuration is not set within the + * \c EVENT_USB_Host_DeviceEnumerationComplete() event, the host still will assume the device enumeration has failed. + * + * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's + * {Class Name}_Host_USBTask() function in the main program loop. The exact implementation of this + * function varies between class drivers, and can be used for any internal class driver purpose to maintain each + * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each + * separate instance, just like the main USB maintenance routine \ref USB_USBTask(): + * + * \code + * int main(void) + * { + * SetupHardware(); + * + * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + * + * for (;;) + * { + * if (USB_HostState != HOST_STATE_Configured) + * Create_And_Process_Samples(); + * + * MIDI_Host_USBTask(&My_Audio_Interface); + * USB_USBTask(); + * } + * } + * \endcode + * + * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_* + * in the function's name) which must also be added to the user application - refer to each + * individual class driver's documentation for mandatory callbacks. In addition, each class driver may + * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which + * the user application may choose to implement, or ignore if not needed. + * + * The individual Host Mode Class Driver documentation contains more information on the non-standardized, + * class-specific functions which the user application can then use on the driver instances, such as data + * read and write routines. See each driver's individual documentation for more information on the + * class-specific functions. + */ + +#ifndef __USB_H__ +#define __USB_H__ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + + /* Includes: */ + #include "../../Common/Common.h" + #include "Core/USBMode.h" + + /* Includes: */ + #include "Core/USBTask.h" + #include "Core/Events.h" + #include "Core/StdDescriptors.h" + #include "Core/ConfigDescriptor.h" + #include "Core/USBController.h" + #include "Core/USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "Core/Host.h" + #include "Core/Pipe.h" + #include "Core/HostStandardReq.h" + #include "Core/PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "Core/Device.h" + #include "Core/Endpoint.h" + #include "Core/DeviceStandardReq.h" + #include "Core/EndpointStream.h" + #endif + + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + #include "Core/OTG.h" + #endif + + //#include "Class/AndroidAccessoryClass.h" + //#include "Class/AudioClass.h" + #include "Class/CDCClass.h" + //#include "Class/HIDClass.h" + //#include "Class/MassStorageClass.h" + //#include "Class/MIDIClass.h" + //#include "Class/PrinterClass.h" + //#include "Class/RNDISClass.h" + //#include "Class/StillImageClass.h" + +#endif + diff --git a/hal/at90usb646/LUFA/License.txt b/hal/at90usb646/LUFA/License.txt index c46c6b0..a2228be 100644 --- a/hal/at90usb646/LUFA/License.txt +++ b/hal/at90usb646/LUFA/License.txt @@ -1,18 +1,18 @@ -Permission to use, copy, modify, and distribute this software -and its documentation for any purpose is hereby granted without -fee, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of the author not be used in -advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -The author disclaim all warranties with regard to this -software, including all implied warranties of merchantability -and fitness. In no event shall the author be liable for any -special, indirect or consequential damages or any damages -whatsoever resulting from loss of use, data or profits, whether -in an action of contract, negligence or other tortious action, -arising out of or in connection with the use or performance of -this software. - +Permission to use, copy, modify, and distribute this software +and its documentation for any purpose is hereby granted without +fee, provided that the above copyright notice appear in all +copies and that both that the copyright notice and this +permission notice and warranty disclaimer appear in supporting +documentation, and that the name of the author not be used in +advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +The author disclaim all warranties with regard to this +software, including all implied warranties of merchantability +and fitness. In no event shall the author be liable for any +special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether +in an action of contract, negligence or other tortious action, +arising out of or in connection with the use or performance of +this software. + diff --git a/hal/at90usb646/LUFA/Version.h b/hal/at90usb646/LUFA/Version.h index 2d9909b..ee0773a 100644 --- a/hal/at90usb646/LUFA/Version.h +++ b/hal/at90usb646/LUFA/Version.h @@ -1,52 +1,52 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2012. - - dean [at] fourwalledcubicle [dot] com - www.lufa-lib.org -*/ - -/* - Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, distribute, and sell this - software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in - all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/** \file - * - * \brief LUFA library version constants. - * - * Version constants for informational purposes and version-specific macro creation. This header file contains the - * current LUFA version number in several forms, for use in the user-application (for example, for printing out - * whilst debugging, or for testing for version compatibility). - */ - -#ifndef __LUFA_VERSION_H__ -#define __LUFA_VERSION_H__ - - /* Public Interface - May be used in end-application: */ - /* Macros: */ - /** Indicates the version number of the library, as an integer. */ - #define LUFA_VERSION_INTEGER 0x120219 - - /** Indicates the version number of the library, as a string. */ - #define LUFA_VERSION_STRING "120219" - -#endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * \brief LUFA library version constants. + * + * Version constants for informational purposes and version-specific macro creation. This header file contains the + * current LUFA version number in several forms, for use in the user-application (for example, for printing out + * whilst debugging, or for testing for version compatibility). + */ + +#ifndef __LUFA_VERSION_H__ +#define __LUFA_VERSION_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates the version number of the library, as an integer. */ + #define LUFA_VERSION_INTEGER 0x120219 + + /** Indicates the version number of the library, as a string. */ + #define LUFA_VERSION_STRING "120219" + +#endif + diff --git a/hal/at90usb646/LUFA/makefile b/hal/at90usb646/LUFA/makefile index 48a675b..bfe9b8a 100644 --- a/hal/at90usb646/LUFA/makefile +++ b/hal/at90usb646/LUFA/makefile @@ -1,92 +1,92 @@ -# -# LUFA Library -# Copyright (C) Dean Camera, 2011. -# -# dean [at] fourwalledcubicle [dot] com -# www.lufa-lib.org -# - -# Makefile for the LUFA library itself. This can be used to generate the library documentation. - - -# Check to see if the LUFA_PATH variable has not been set (the makefile is not being included from a project makefile) -ifeq ($(origin LUFA_PATH), undefined) - LUFA_ROOT_PATH = . - ARCH = {AVR8,UC3,XMEGA} -else - LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA -endif - -# Check to see if the chip architecture has not been defined in the user makefile, set a default architecture if not -ifeq ($(origin ARCH), undefined) - ARCH = AVR8 -endif - -# Define module source file lists -LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/EndpointStream_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/PipeStream_$(ARCH).c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptor.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c -LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/AudioClassDevice.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorageClassDevice.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDISClassDevice.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AudioClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDCClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorageClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/PrinterClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDISClassHost.c \ - $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImageClassHost.c -LUFA_SRC_TEMPERATURE = $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c -LUFA_SRC_SERIAL = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c -LUFA_SRC_TWI = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c -LUFA_SRC_SCHEDULER = $(LUFA_ROOT_PATH)/Scheduler/Scheduler.c - - -# Check to see if the LUFA_PATH variable has not been set (the makefile is not being included from a project makefile) -ifeq ($(origin LUFA_PATH), undefined) - LUFA_SRC_ALL_FILES = $(LUFA_SRC_USB) \ - $(LUFA_SRC_USBCLASS) \ - $(LUFA_SRC_TEMPERATURE) \ - $(LUFA_SRC_SERIAL) \ - $(LUFA_SRC_TWI) \ - $(LUFA_SRC_SCHEDULER) - - all: - - clean: - rm -f $(LUFA_SRC_ALL_FILES:%.c=%.o) - rm -f $(LUFA_SRC_ALL_FILES:%.c=%.lst) - - clean_list: - - doxygen: - @echo Generating LUFA Library Documentation... - ( cat Doxygen.conf ; echo "PROJECT_NUMBER=`grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2`" ) | doxygen - - @echo Documentation Generation Complete. - - clean_doxygen: - rm -rf Documentation - - checksource: - - version: - @echo "LUFA `grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2`" - - .PHONY: all clean clean_list doxygen clean_doxygen version -endif +# +# LUFA Library +# Copyright (C) Dean Camera, 2011. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +# Makefile for the LUFA library itself. This can be used to generate the library documentation. + + +# Check to see if the LUFA_PATH variable has not been set (the makefile is not being included from a project makefile) +ifeq ($(origin LUFA_PATH), undefined) + LUFA_ROOT_PATH = . + ARCH = {AVR8,UC3,XMEGA} +else + LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA +endif + +# Check to see if the chip architecture has not been defined in the user makefile, set a default architecture if not +ifeq ($(origin ARCH), undefined) + ARCH = AVR8 +endif + +# Define module source file lists +LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/EndpointStream_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/PipeStream_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptor.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c +LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/AudioClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorageClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDISClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AudioClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDCClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorageClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/PrinterClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDISClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImageClassHost.c +LUFA_SRC_TEMPERATURE = $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c +LUFA_SRC_SERIAL = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c +LUFA_SRC_TWI = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c +LUFA_SRC_SCHEDULER = $(LUFA_ROOT_PATH)/Scheduler/Scheduler.c + + +# Check to see if the LUFA_PATH variable has not been set (the makefile is not being included from a project makefile) +ifeq ($(origin LUFA_PATH), undefined) + LUFA_SRC_ALL_FILES = $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) \ + $(LUFA_SRC_TEMPERATURE) \ + $(LUFA_SRC_SERIAL) \ + $(LUFA_SRC_TWI) \ + $(LUFA_SRC_SCHEDULER) + + all: + + clean: + rm -f $(LUFA_SRC_ALL_FILES:%.c=%.o) + rm -f $(LUFA_SRC_ALL_FILES:%.c=%.lst) + + clean_list: + + doxygen: + @echo Generating LUFA Library Documentation... + ( cat Doxygen.conf ; echo "PROJECT_NUMBER=`grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2`" ) | doxygen - + @echo Documentation Generation Complete. + + clean_doxygen: + rm -rf Documentation + + checksource: + + version: + @echo "LUFA `grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2`" + + .PHONY: all clean clean_list doxygen clean_doxygen version +endif diff --git a/hal/at90usb646/board.c b/hal/at90usb646/board.c index f4ff01c..0cf5b97 100644 --- a/hal/at90usb646/board.c +++ b/hal/at90usb646/board.c @@ -1,51 +1,51 @@ -/* - * board.c - * - * Created on: Nov 15, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "board_hw.h" -#include - -/// Whether we detected that the board had a brownout event -static bool brownout = false; - -/** Initializes any board hardware-specific stuff - * - */ -void Board_Init(void) -{ - // Figure out if a brownout occurred - if (MCUSR & (1 << BORF)) - { - MCUSR = 0; - brownout = true; - } -} - -/** Determines if a brownout was detected at startup - * - * @return True if a brownout was detected - */ -bool Board_BrownoutDetected(void) -{ - return brownout; -} +/* + * board.c + * + * Created on: Nov 15, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "board_hw.h" +#include + +/// Whether we detected that the board had a brownout event +static bool brownout = false; + +/** Initializes any board hardware-specific stuff + * + */ +void Board_Init(void) +{ + // Figure out if a brownout occurred + if (MCUSR & (1 << BORF)) + { + MCUSR = 0; + brownout = true; + } +} + +/** Determines if a brownout was detected at startup + * + * @return True if a brownout was detected + */ +bool Board_BrownoutDetected(void) +{ + return brownout; +} diff --git a/hal/at90usb646/board_hw.h b/hal/at90usb646/board_hw.h index 4c252f1..e392177 100644 --- a/hal/at90usb646/board_hw.h +++ b/hal/at90usb646/board_hw.h @@ -1,40 +1,40 @@ -/* - * board_hw.h - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_AT90USB646_BOARD_HW_H_ -#define HAL_AT90USB646_BOARD_HW_H_ - -#include "gpio_hw.h" -#include "../gpio.h" - -/** Gets the GPIO pin on the board that controls the status LED - * - * @return The status LED pin - */ -static inline GPIOPin Board_LEDPin(void) -{ - return GPIO_PIN(GPIOD, 7); -} - -#endif /* HAL_AT90USB646_BOARD_HW_H_ */ +/* + * board_hw.h + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_AT90USB646_BOARD_HW_H_ +#define HAL_AT90USB646_BOARD_HW_H_ + +#include "gpio_hw.h" +#include "../gpio.h" + +/** Gets the GPIO pin on the board that controls the status LED + * + * @return The status LED pin + */ +static inline GPIOPin Board_LEDPin(void) +{ + return GPIO_PIN(GPIOD, 7); +} + +#endif /* HAL_AT90USB646_BOARD_HW_H_ */ diff --git a/hal/at90usb646/cdc_device_definition.c b/hal/at90usb646/cdc_device_definition.c index 5cab1f7..10ae3f0 100644 --- a/hal/at90usb646/cdc_device_definition.c +++ b/hal/at90usb646/cdc_device_definition.c @@ -1,46 +1,46 @@ -/* - * cdc_device_definition.c - * - * Created on: Dec 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "LUFA/Drivers/USB/USB.h" -#include "Descriptors.h" - -/// Configuration info for the USB CDC serial interface -USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = -{ - .Config = { - .ControlInterfaceNumber = 0, - - .DataINEndpointNumber = CDC_TX_EPNUM, - .DataINEndpointSize = CDC_TXRX_EPSIZE, - .DataINEndpointDoubleBank = true, - - .DataOUTEndpointNumber = CDC_RX_EPNUM, - .DataOUTEndpointSize = CDC_TXRX_EPSIZE, - .DataOUTEndpointDoubleBank = true, - - .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, - .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, - .NotificationEndpointDoubleBank = false, - }, -}; +/* + * cdc_device_definition.c + * + * Created on: Dec 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "LUFA/Drivers/USB/USB.h" +#include "Descriptors.h" + +/// Configuration info for the USB CDC serial interface +USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = +{ + .Config = { + .ControlInterfaceNumber = 0, + + .DataINEndpointNumber = CDC_TX_EPNUM, + .DataINEndpointSize = CDC_TXRX_EPSIZE, + .DataINEndpointDoubleBank = true, + + .DataOUTEndpointNumber = CDC_RX_EPNUM, + .DataOUTEndpointSize = CDC_TXRX_EPSIZE, + .DataOUTEndpointDoubleBank = true, + + .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, + .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, + .NotificationEndpointDoubleBank = false, + }, +}; diff --git a/hal/at90usb646/cdc_device_definition.h b/hal/at90usb646/cdc_device_definition.h index f4bf5c9..030b34d 100644 --- a/hal/at90usb646/cdc_device_definition.h +++ b/hal/at90usb646/cdc_device_definition.h @@ -1,30 +1,30 @@ -/* - * cdc_device_definition.h - * - * Created on: Dec 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef CDC_DEVICE_DEFINITION_H_ -#define CDC_DEVICE_DEFINITION_H_ - -extern USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface; - -#endif /* CDC_DEVICE_DEFINITION_H_ */ +/* + * cdc_device_definition.h + * + * Created on: Dec 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef CDC_DEVICE_DEFINITION_H_ +#define CDC_DEVICE_DEFINITION_H_ + +extern USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface; + +#endif /* CDC_DEVICE_DEFINITION_H_ */ diff --git a/hal/at90usb646/gpio.c b/hal/at90usb646/gpio.c index a86e4e1..2e49c1a 100644 --- a/hal/at90usb646/gpio.c +++ b/hal/at90usb646/gpio.c @@ -1,116 +1,116 @@ -/* - * gpio.c - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "../gpio.h" -#include - -/// Struct representing the registers belonging to an AVR's GPIO port -typedef struct AVRGPIORegs -{ - /// Address of the PORT register for setting output value or enabling pullups - volatile uint8_t *port; - /// Address of the PIN register for reading input value or toggling outputs - volatile uint8_t *pin; - /// Address of the DDR register for setting whether pins are input or output - volatile uint8_t *ddr; -} AVRGPIORegs; - -/// The GPIO ports available on the AVR -static AVRGPIORegs const gpioRegs[] = { - {&PORTA, &PINA, &DDRA}, - {&PORTB, &PINB, &DDRB}, - {&PORTC, &PINC, &DDRC}, - {&PORTD, &PIND, &DDRD}, - {&PORTE, &PINE, &DDRE}, - {&PORTF, &PINF, &DDRF}, -}; - -/** Sets the direction of a GPIO pin. - * - * @param pin The pin - * @param output True if it should be an output, false if it should be an input - */ -void GPIO_SetDirection(GPIOPin pin, bool output) -{ - if (output) - { - *(gpioRegs[pin.port].ddr) |= (1 << pin.pin); - } - else - { - *(gpioRegs[pin.port].ddr) &= ~(1 << pin.pin); - } -} - -/** Sets whether an input GPIO pin is pulled up - * - * @param pin The pin - * @param pullup True if it should be pulled up, false if not - */ -void GPIO_SetPullup(GPIOPin pin, bool pullup) -{ - // On the AVR, you set pullups using the PORT register that is ordinarily - // used for setting the output value. You just have to make sure the pin - // is configured as an input first. Otherwise you will modify the output. - GPIO_Set(pin, pullup); -} - -/** Turns a GPIO pin on (sets it high) - * - * @param pin The pin - */ -void GPIO_SetOn(GPIOPin pin) -{ - *(gpioRegs[pin.port].port) |= (1 << pin.pin); -} - -/** Turns a GPIO pin off (sets it low) - * - * @param pin The pin - */ -void GPIO_SetOff(GPIOPin pin) -{ - *(gpioRegs[pin.port].port) &= ~(1 << pin.pin); -} - -/** Toggles a GPIO pin - * - * @param pin The pin - */ -void GPIO_Toggle(GPIOPin pin) -{ - // This is a tricky little hack the AVR provides that allows toggling - // without a read/modify/write operation. - *(gpioRegs[pin.port].pin) = (1 << pin.pin); -} - -/** Reads the input status of a GPIO pin - * - * @param pin The pin - * @return True if it's high, false if it's low - */ -bool GPIO_Read(GPIOPin pin) -{ - return *(gpioRegs[pin.port].pin) & (1 << pin.pin); -} +/* + * gpio.c + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "../gpio.h" +#include + +/// Struct representing the registers belonging to an AVR's GPIO port +typedef struct AVRGPIORegs +{ + /// Address of the PORT register for setting output value or enabling pullups + volatile uint8_t *port; + /// Address of the PIN register for reading input value or toggling outputs + volatile uint8_t *pin; + /// Address of the DDR register for setting whether pins are input or output + volatile uint8_t *ddr; +} AVRGPIORegs; + +/// The GPIO ports available on the AVR +static AVRGPIORegs const gpioRegs[] = { + {&PORTA, &PINA, &DDRA}, + {&PORTB, &PINB, &DDRB}, + {&PORTC, &PINC, &DDRC}, + {&PORTD, &PIND, &DDRD}, + {&PORTE, &PINE, &DDRE}, + {&PORTF, &PINF, &DDRF}, +}; + +/** Sets the direction of a GPIO pin. + * + * @param pin The pin + * @param output True if it should be an output, false if it should be an input + */ +void GPIO_SetDirection(GPIOPin pin, bool output) +{ + if (output) + { + *(gpioRegs[pin.port].ddr) |= (1 << pin.pin); + } + else + { + *(gpioRegs[pin.port].ddr) &= ~(1 << pin.pin); + } +} + +/** Sets whether an input GPIO pin is pulled up + * + * @param pin The pin + * @param pullup True if it should be pulled up, false if not + */ +void GPIO_SetPullup(GPIOPin pin, bool pullup) +{ + // On the AVR, you set pullups using the PORT register that is ordinarily + // used for setting the output value. You just have to make sure the pin + // is configured as an input first. Otherwise you will modify the output. + GPIO_Set(pin, pullup); +} + +/** Turns a GPIO pin on (sets it high) + * + * @param pin The pin + */ +void GPIO_SetOn(GPIOPin pin) +{ + *(gpioRegs[pin.port].port) |= (1 << pin.pin); +} + +/** Turns a GPIO pin off (sets it low) + * + * @param pin The pin + */ +void GPIO_SetOff(GPIOPin pin) +{ + *(gpioRegs[pin.port].port) &= ~(1 << pin.pin); +} + +/** Toggles a GPIO pin + * + * @param pin The pin + */ +void GPIO_Toggle(GPIOPin pin) +{ + // This is a tricky little hack the AVR provides that allows toggling + // without a read/modify/write operation. + *(gpioRegs[pin.port].pin) = (1 << pin.pin); +} + +/** Reads the input status of a GPIO pin + * + * @param pin The pin + * @return True if it's high, false if it's low + */ +bool GPIO_Read(GPIOPin pin) +{ + return *(gpioRegs[pin.port].pin) & (1 << pin.pin); +} diff --git a/hal/at90usb646/gpio_hw.h b/hal/at90usb646/gpio_hw.h index 3d03e69..382153c 100644 --- a/hal/at90usb646/gpio_hw.h +++ b/hal/at90usb646/gpio_hw.h @@ -1,39 +1,39 @@ -/* - * gpio_hw.h - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_AT90USB646_GPIO_HW_H_ -#define HAL_AT90USB646_GPIO_HW_H_ - -/// Enum representing the different GPIO ports available on the AVR. -/// Used with the GPIOPin struct. -enum { - GPIOA, - GPIOB, - GPIOC, - GPIOD, - GPIOE, - GPIOF -}; - -#endif /* HAL_AT90USB646_GPIO_HW_H_ */ +/* + * gpio_hw.h + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_AT90USB646_GPIO_HW_H_ +#define HAL_AT90USB646_GPIO_HW_H_ + +/// Enum representing the different GPIO ports available on the AVR. +/// Used with the GPIOPin struct. +enum { + GPIOA, + GPIOB, + GPIOC, + GPIOD, + GPIOE, + GPIOF +}; + +#endif /* HAL_AT90USB646_GPIO_HW_H_ */ diff --git a/hal/at90usb646/hardware.h b/hal/at90usb646/hardware.h index f46e597..8c0549a 100644 --- a/hal/at90usb646/hardware.h +++ b/hal/at90usb646/hardware.h @@ -1,66 +1,66 @@ -/* - * hardware.h - * - * Created on: Dec 4, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_AT90USB646_HARDWARE_H_ -#define HAL_AT90USB646_HARDWARE_H_ - -#include -#include -#include - -/** Disables interrupts - * - */ -static inline void DisableInterrupts(void) -{ - cli(); -} - -/** Enables interrupts - * - */ -static inline void EnableInterrupts(void) -{ - sei(); -} - -/** Blocks for the specified number of milliseconds - * - * @param ms The number of milliseconds to wait - */ -static inline void DelayMS(uint16_t ms) -{ - _delay_ms(ms); -} - -/** Blocks for the specified number of microseconds - * - * @param us The number of microseconds to wait - */ -static inline void DelayUS(uint16_t us) -{ - _delay_us(us); -} - -#endif /* HAL_AT90USB646_HARDWARE_H_ */ +/* + * hardware.h + * + * Created on: Dec 4, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_AT90USB646_HARDWARE_H_ +#define HAL_AT90USB646_HARDWARE_H_ + +#include +#include +#include + +/** Disables interrupts + * + */ +static inline void DisableInterrupts(void) +{ + cli(); +} + +/** Enables interrupts + * + */ +static inline void EnableInterrupts(void) +{ + sei(); +} + +/** Blocks for the specified number of milliseconds + * + * @param ms The number of milliseconds to wait + */ +static inline void DelayMS(uint16_t ms) +{ + _delay_ms(ms); +} + +/** Blocks for the specified number of microseconds + * + * @param us The number of microseconds to wait + */ +static inline void DelayUS(uint16_t us) +{ + _delay_us(us); +} + +#endif /* HAL_AT90USB646_HARDWARE_H_ */ diff --git a/hal/at90usb646/parallel_bus.c b/hal/at90usb646/parallel_bus.c index 6729311..5cde102 100644 --- a/hal/at90usb646/parallel_bus.c +++ b/hal/at90usb646/parallel_bus.c @@ -1,733 +1,733 @@ -/* - * parallel_bus.c - * - * Created on: Nov 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ----------------------------------------------------------------------------- - * - * For some reason, avr-gcc is super inefficient dealing with uint32_t - * variables. Looking at the individual bytes using a union results in much - * more optimized code. Every cycle counts for this. So several of these - * functions may seem weird with the unions, but it's faster than operating - * directly with the uint32_t variables. - * - * There are also a few time-critical places where I had to bypass the GPIO and - * SPI drivers, so it's not 100% clean. Oh well... - */ - -#include "../parallel_bus.h" -#include "../../drivers/mcp23s17.h" -#include "../../util.h" -#include "gpio_hw.h" -#include - -/// The port object where the OE, WE, and CS pins are connected -/// (This also happens to be where the MCP control pins are connected) -#define FLASH_CONTROL_PORT PORTB -/// The index of the MCP23S17 chip select pin -#define MCP_CS_PIN 0 -/// The index of the CS pin -#define FLASH_CS_PIN 4 -/// The index of the OE pin -#define FLASH_OE_PIN 5 -/// The index of the WE pin -#define FLASH_WE_PIN 6 -/// The index of the MCP23S17 reset pin -#define MCP_RESET_PIN 7 -/// The index of the highest address line on the parallel bus -#define PARALLEL_BUS_HIGHEST_ADDRESS_LINE 20 - -static ALWAYS_INLINE uint8_t SPITransfer(uint8_t byte); -static ALWAYS_INLINE void SPITransferNoRead(uint8_t byte); -static ALWAYS_INLINE void AssertControl(uint8_t pin); -static ALWAYS_INLINE void DeassertControl(uint8_t pin); - -/// The MCP23S17 device -static MCP23S17 mcp23s17 = { - .spi = { - .csPin = {GPIOB, MCP_CS_PIN} - } -}; - -/// The reset pin for the MCP23S17 -static const GPIOPin mcpReset = {GPIOB, MCP_RESET_PIN}; -/// The /WE pin for the parallel bus -static const GPIOPin flashWEPin = {GPIOB, FLASH_WE_PIN}; -/// The /OE pin for the parallel bus -static const GPIOPin flashOEPin = {GPIOB, FLASH_OE_PIN}; -/// The /CS pin for the flash chip -static const GPIOPin flashCSPin = {GPIOB, FLASH_CS_PIN}; -/// Whether or not data pins are outputs -static bool dataIsOutput; - -/** Initializes the 32-bit data/21-bit address parallel bus. - * - */ -void ParallelBus_Init(void) -{ - static bool mcpInited = false; - if (!mcpInited) - { - // Set up the MCP23S17 - SPI_InitController(SPI_Controller(0)); - mcp23s17.spi.controller = SPI_Controller(0); - MCP23S17_Init(&mcp23s17, mcpReset); - // Go ahead and let the MCP23S17 take over the SPI bus forever. - // There's nothing else attached to it. - MCP23S17_Begin(&mcp23s17); - mcpInited = true; - } - - // Configure all address lines as outputs, outputting address 0 - ParallelBus_SetAddressDir((1UL << (PARALLEL_BUS_HIGHEST_ADDRESS_LINE + 1)) - 1); - ParallelBus_SetAddress(0); - - // Set all data lines to pulled-up inputs - ParallelBus_SetDataDir(0); - ParallelBus_SetDataPullups(0xFFFFFFFFUL); - dataIsOutput = false; - // Note: During normal operation of read/write cycles, the pullups in the - // MCP23S17 will remember they are enabled, so we can do an optimization - // when using ParallelBus_ReadCycle/WriteCycle and assume they are already - // pulled up. This means we'll bypass ParallelBus_SetDataPullups. - - // Control lines - ParallelBus_SetCSDir(true); - ParallelBus_SetOEDir(true); - ParallelBus_SetWEDir(true); - - // Default to only CS asserted - DeassertControl(FLASH_WE_PIN); - DeassertControl(FLASH_OE_PIN); - AssertControl(FLASH_CS_PIN); -} - -/** Sets the address being output on the 21-bit address bus - * - * @param address The address - */ -void ParallelBus_SetAddress(uint32_t address) -{ - // For efficiency, we talk directly to the PORT registers in this function, - // rather than going through the GPIO class. - - // NOTE: If any of PORTA or PORTC or PORTD pins 0, 1, 4, 5, or 6 are set as - // inputs, this function might mess with their pull-up resistors. - // Only use it under normal operation when all the address pins are being - // used as outputs. - union { - uint32_t addr; - uint8_t addrBytes[4]; - } u; - - u.addr = address; - PORTA = u.addrBytes[0]; // A0-A7 - PORTC = u.addrBytes[1]; // A8-A15 - // A16-A20 are special because they are split up...(We use PORTD pins 0, 1, 4, 5, 6) - u.addrBytes[2] = (u.addrBytes[2] & 0x03) | (uint8_t)((u.addrBytes[2] & 0x1C) << 2) | (PORTD & 0x8C); - PORTD = u.addrBytes[2]; -} - -/** Sets the output data on the 32-bit data bus - * - * @param data The data - */ -void ParallelBus_SetData(uint32_t data) -{ - // For efficiency, we talk directly to the PORT registers in this function, - // rather than going through the GPIO class. - - // NOTE: If any pins of PORTE or PORTF are set as inputs, this - // function might mess with their pull-up resistors. - // Only use it under normal operation when all the data pins are being - // used as outputs - union { - uint32_t data; - uint16_t dataShorts[2]; - uint8_t dataBytes[4]; - } u; - u.data = data; - - // Doing the AVR registers first makes it so we don't have to use the stack - // (at least according to my testing with avr-gcc) - PORTE = u.dataBytes[1]; // D16-D23 - PORTF = u.dataBytes[0]; // D24-D31 - - // D0-D15 are part of the MCP23S17 - MCP23S17_SetOutputs(&mcp23s17, u.dataShorts[1]); -} - -/** Sets the output value of the CS pin - * - * @param high True if it should be high, false if low - */ -void ParallelBus_SetCS(bool high) -{ - GPIO_Set(flashCSPin, high); -} - -/** Sets the output value of the OE pin - * - * @param high True if it should be high, false if low - */ -void ParallelBus_SetOE(bool high) -{ - GPIO_Set(flashOEPin, high); -} - -/** Sets the output value of the WE pin - * - * @param high True if it should be high, false if low - */ -void ParallelBus_SetWE(bool high) -{ - GPIO_Set(flashWEPin, high); -} - -/** Sets which pins on the 21-bit address bus should be outputs - * - * @param outputs Mask of pins that should be outputs. 1 = output, 0 = input - * - * Typically the address pins will be outputs. This flexibility is provided in - * case we want to do electrical testing. - */ -void ParallelBus_SetAddressDir(uint32_t outputs) -{ - DDRA = (outputs & 0xFF); // A0-A7 - DDRC = ((outputs >> 8) & 0xFF); // A8-A15 - - // A16-A20 are special because they are split up...(We use PORTD pins 0, 1, 4, 5, 6) - uint8_t tmp = (outputs >> 16) & 0xFF; - tmp = (tmp & 0x03) | ((tmp & 0x1C) << 2); - - // Now, turn off the DDR bits we have to turn off, - // and turn on the DDR bits we have to turn on - // (without affecting other bits [2, 3, and 7] - // that we aren't supposed to touch) - DDRD &= (0x8C | tmp); // This should turn off all '0' bits in tmp. - DDRD |= tmp; // This should turn on all '1' bits in tmp -} - -/** Sets which pins on the 32-bit data bus should be outputs - * - * @param outputs Mask of pins that should be outputs. 1 = output, 0 = input - * - * Typically all pins would be set as inputs or outputs, and it's automatically - * handled by the read/write cycle functions. This function exists mainly for - * test purposes. - */ -void ParallelBus_SetDataDir(uint32_t outputs) -{ - union { - uint32_t data; - uint16_t dataShorts[2]; - uint8_t dataBytes[4]; - } u; - u.data = outputs; - - // Doing the AVR registers first makes it so we don't have to use the stack - DDRE = u.dataBytes[1]; // D16-D23 - DDRF = u.dataBytes[0]; // D24-D31 - - // D0-D15 are part of the MCP23S17 - MCP23S17_SetDDR(&mcp23s17, u.dataShorts[1]); - - // If none of the pins are outputs, ensure dataIsOutput is false - if (outputs == 0) - { - dataIsOutput = false; - } - // If all of the pins are outputs, ensure dataIsOutput is true - else if (outputs == 0xFFFFFFFFUL) - { - dataIsOutput = true; - } -} - -/** Sets the direction of the CS pin - * - * @param output True if it's an output, false if it's an input - * - * Typically this pin will be an output. This flexibility is provided in case - * we want to do electrical testing. - */ -void ParallelBus_SetCSDir(bool output) -{ - GPIO_SetDirection(flashCSPin, output); -} - -/** Sets the direction of the OE pin - * - * @param output True if it's an output, false if it's an input - * - * Typically this pin will be an output. This flexibility is provided in case - * we want to do electrical testing. - */ -void ParallelBus_SetOEDir(bool output) -{ - GPIO_SetDirection(flashOEPin, output); -} - -/** Sets the direction of the WE pin - * - * @param output True if it's an output, false if it's an input - * - * Typically this pin will be an output. This flexibility is provided in case - * we want to do electrical testing. - */ -void ParallelBus_SetWEDir(bool output) -{ - GPIO_SetDirection(flashWEPin, output); -} - -/** Sets which pins on the 21-bit address bus should be pulled up (if inputs) - * - * @param pullups Mask of pins that should be pullups. - * - * This would typically only be used for testing. Under normal operation, the - * address bus will be outputting, so the pullups are irrelevant. - */ -void ParallelBus_SetAddressPullups(uint32_t pullups) -{ - // Pull-ups are set by writing to the data register when in input mode. - // MAKE SURE THE PINS ARE SET AS INPUTS FIRST! This is a cheat only - // possible on the AVR. Some places like SIMMElectricalTest call SetAddress - // followed by SetAddressPullups, which is kinda weird because it sets the - // same registers. But the way it's called doesn't hurt anything... - ParallelBus_SetAddress(pullups); -} - -/** Sets which pins on the 32-bit data bus should be pulled up (if inputs) - * - * @param pullups Mask of pins that should be pullups. - * - * Typically these will be enabled in order to provide a default value if a - * chip isn't responding properly. Sometimes it's useful to customize it during - * testing though. - */ -void ParallelBus_SetDataPullups(uint32_t pullups) -{ - // NOTE: If any pins of PORTE or PORTF are set as outputs, this - // function might mess with their output values. - // Only use it when all the data pins are being used as inputs - union { - uint32_t data; - uint16_t dataShorts[2]; - uint8_t dataBytes[4]; - } u; - u.data = pullups; - - PORTE = u.dataBytes[1]; // D16-D23 - PORTF = u.dataBytes[0]; // D24-D31 - - // D0-D15 are part of the MCP23S17 - MCP23S17_SetPullups(&mcp23s17, u.dataShorts[1]); -} - -/** Sets whether the CS pin is pulled up, if it's an input. - * - * @param pullup True if the CS pin should be pulled up, false if not - * - * This would typically only be used for testing. Under normal operation, this - * pin will be set as an output, so the pullup state is irrelevant. - */ -void ParallelBus_SetCSPullup(bool pullup) -{ - GPIO_SetPullup(flashCSPin, pullup); -} - -/** Sets whether the OE pin is pulled up, if it's an input. - * - * @param pullup True if the OE pin should be pulled up, false if not - * - * This would typically only be used for testing. Under normal operation, this - * pin will be set as an output, so the pullup state is irrelevant. - */ -void ParallelBus_SetOEPullup(bool pullup) -{ - GPIO_SetPullup(flashOEPin, pullup); -} - -/** Sets whether the WE pin is pulled up, if it's an input. - * - * @param pullup True if the WE pin should be pulled up, false if not - * - * This would typically only be used for testing. Under normal operation, this - * pin will be set as an output, so the pullup state is irrelevant. - */ -void ParallelBus_SetWEPullup(bool pullup) -{ - GPIO_SetPullup(flashWEPin, pullup); -} - -/** Reads the current data on the address bus. - * - * @return The address bus readback - * - * This would typically only be used for testing. Under normal operation, the - * address bus will be outputting, so the readback is irrelevant. - */ -uint32_t ParallelBus_ReadAddress(void) -{ - uint32_t result = PINA; - result |= (((uint32_t)PINC) << 8); - uint8_t tmp = (PIND & 0x03) | ((PIND & 0x70) >> 2); - result |= (((uint32_t)tmp) << 16); - - return result; -} - -/** Reads the current data on the 32-bit data bus. - * - * @return The 32-bit data readback - */ -uint32_t ParallelBus_ReadData(void) -{ - union { - uint32_t data; - uint16_t dataShorts[2]; - uint8_t dataBytes[4]; - } u; - - u.dataShorts[1] = MCP23S17_ReadInputs(&mcp23s17); - - // Grab the other two bytes... - u.dataBytes[1] = PINE; - u.dataBytes[0] = PINF; - - return u.data; -} - -/** Reads the status of the CS pin, if it's set as an input. - * - * @return True if the CS pin is high, false if it's low - * - * This would typically only be used for testing. Under normal operation, this - * pin will be set as an output, so the readback is irrelevant. - */ -bool ParallelBus_ReadCS(void) -{ - return GPIO_Read(flashCSPin); -} - -/** Reads the status of the OE pin, if it's set as an input. - * - * @return True if the OE pin is high, false if it's low - * - * This would typically only be used for testing. Under normal operation, this - * pin will be set as an output, so the readback is irrelevant. - */ -bool ParallelBus_ReadOE(void) -{ - return GPIO_Read(flashOEPin); -} - -/** Reads the status of the WE pin, if it's set as an input. - * - * @return True if the WE pin is high, false if it's low - * - * This would typically only be used for testing. Under normal operation, this - * pin will be set as an output, so the readback is irrelevant. - */ -bool ParallelBus_ReadWE(void) -{ - return GPIO_Read(flashWEPin); -} - -/** Performs a write cycle on the parallel bus. - * - * @param address The address to write to - * @param data The 32-bit data to write to the bus - * - * Because this function is used a lot during programming, it is super - * optimized and bypasses the GPIO and SPI drivers. It's a necessary evil. - * It makes a big difference in programming time. - */ -void ParallelBus_WriteCycle(uint32_t address, uint32_t data) -{ - // Using this union surprisingly speeds things up when assembling or - // interpreting a uint32_t on the AVR. - union { - uint32_t word; - uint8_t bytes[4]; - } u; - - // We should currently be in a state of "CS is asserted, OE/WE not asserted". - // As an optimization, operate under that assumption. - - // Set address. This is basically the exact same code as ParallelBus_SetAddress, - // but repeated in here so we don't have any function call overhead. - u.word = address; - PORTA = u.bytes[0]; - PORTC = u.bytes[1]; - u.bytes[2] = (u.bytes[2] & 0x03) | (uint8_t)((u.bytes[2] & 0x1C) << 2) | (PORTD & 0x8C); - PORTD = u.bytes[2]; - - // If the data port is not already set as outputs, set it to be outputs now - if (!dataIsOutput) - { - // Set data as outputs. Bypass the SPI/GPIO drivers for this for efficiency. - DDRE = 0xFF; - DDRF = 0xFF; - AssertControl(MCP_CS_PIN); - SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); - SPITransferNoRead(MCP23S17_IODIRA); - SPITransferNoRead(0); - SPITransferNoRead(0); - DeassertControl(MCP_CS_PIN); - dataIsOutput = true; - } - - // Set data. Bypass the SPI/GPIO drivers again... - u.word = data; - PORTE = u.bytes[1]; - PORTF = u.bytes[0]; - AssertControl(MCP_CS_PIN); - SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); - SPITransferNoRead(MCP23S17_GPIOA); - SPITransferNoRead(u.bytes[3]); - SPITransferNoRead(u.bytes[2]); - DeassertControl(MCP_CS_PIN); - - // Assert and then deassert WE to actually do the write cycle. - AssertControl(FLASH_WE_PIN); - DeassertControl(FLASH_WE_PIN); - - // Control lines are left as "CS asserted, OE/WE not asserted" here. -} - -/** Performs a read cycle on the parallel bus. - * - * @param address The address to read from - * @return The returned 32-bit data - * - * Because this function is used a lot during programming, it is super - * optimized and bypasses the GPIO and SPI drivers. It's a necessary evil. - * It makes a big difference in programming time. - */ -uint32_t ParallelBus_ReadCycle(uint32_t address) -{ - // Using this union surprisingly speeds things up when assembling or - // interpreting a uint32_t on the AVR. - union { - uint32_t word; - uint8_t bytes[4]; - } u; - - // We should currently be in a state of "CS is asserted, OE/WE not asserted". - // As an optimization, operate under that assumption. - - // If the data pins are set as outputs, change them to inputs - if (dataIsOutput) - { - // Set data as inputs. Bypass the SPI/GPIO drivers for this for efficiency. - DDRE = 0; - DDRF = 0; - AssertControl(MCP_CS_PIN); - SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); - SPITransferNoRead(MCP23S17_IODIRA); - SPITransferNoRead(0xFF); - SPITransferNoRead(0xFF); - DeassertControl(MCP_CS_PIN); - - // Set pull-ups on the AVR data pins so we get a default value if a chip - // isn't responding. We can assume the MCP23S17 has already been configured - // to have its inputs pulled up. On the AVR we can't assume because its - // pull-up state is shared by the same register used for data output. - PORTE = 0xFF; - PORTF = 0xFF; - - dataIsOutput = false; - } - - // Assert OE so we start reading from the chip. Safe to do now that - // the data pins have been set as inputs. - AssertControl(FLASH_OE_PIN); - - // Set address. This is basically the exact same code as ParallelBus_SetAddress, - // but repeated in here so we don't have any function call overhead. - u.word = address; - PORTA = u.bytes[0]; - PORTC = u.bytes[1]; - u.bytes[2] = (u.bytes[2] & 0x03) | (uint8_t)((u.bytes[2] & 0x1C) << 2) | (PORTD & 0x8C); - PORTD = u.bytes[2]; - - // Start the SPI read. Each clock cycle at 16 MHz is 62.5 nanoseconds. We don't want to - // immediately read back the data bus until the address has settled, so do some SPI - // preparation in the meantime. - AssertControl(MCP_CS_PIN); - SPITransferNoRead(MCP23S17_CONTROL_READ(0)); - SPITransferNoRead(MCP23S17_GPIOA); - - // Read data. Bypass the GPIO/SPI drivers again... - u.bytes[1] = PINE; - u.bytes[0] = PINF; - u.bytes[3] = SPITransfer(0); - u.bytes[2] = SPITransfer(0); - DeassertControl(MCP_CS_PIN); - - // Deassert OE, and we're done. - DeassertControl(FLASH_OE_PIN); - - // Control lines are left as "CS asserted, OE/WE not asserted" here. - - // Return the final value - return u.word; -} - -/** Reads a bunch of consecutive data from the parallel bus - * - * @param startAddress The address to start reading from - * @param buf Buffer to store the readback - * @param len The number of 32-bit words to read - * - * This function is just a time saver if we know we will be reading a big block - * of data. It doesn't bother playing with the control lines between each byte. - */ -void ParallelBus_Read(uint32_t startAddress, uint32_t *buf, uint16_t len) -{ - // We should currently be in a state of "CS is asserted, OE/WE not asserted". - // As an optimization, operate under that assumption. - - // Using this union surprisingly speeds things up when assembling or - // interpreting a uint32_t on the AVR. - union { - uint32_t word; - uint8_t bytes[4]; - } u; - - // If the data pins are set as outputs, change them to inputs - if (dataIsOutput) - { - // Set data as inputs. Bypass the SPI/GPIO drivers for this for efficiency. - DDRE = 0; - DDRF = 0; - AssertControl(MCP_CS_PIN); - SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); - SPITransferNoRead(MCP23S17_IODIRA); - SPITransferNoRead(0xFF); - SPITransferNoRead(0xFF); - DeassertControl(MCP_CS_PIN); - - // Set pull-ups on the AVR data pins so we get a default value if a chip - // isn't responding. We can assume the MCP23S17 has already been configured - // to have its inputs pulled up. On the AVR we can't assume because its - // pull-up state is shared by the same register used for data output. - PORTE = 0xFF; - PORTF = 0xFF; - - dataIsOutput = false; - } - - // Assert OE, now the chip will start spitting out data. - AssertControl(FLASH_OE_PIN); - - while (len--) - { - // Set address. This is basically the exact same code as ParallelBus_SetAddress, - // but repeated in here so we don't have any function call overhead. - u.word = startAddress++; - PORTA = u.bytes[0]; - PORTC = u.bytes[1]; - u.bytes[2] = (u.bytes[2] & 0x03) | (uint8_t)((u.bytes[2] & 0x1C) << 2) | (PORTD & 0x8C); - PORTD = u.bytes[2]; - - // Start the SPI read. Each clock cycle at 16 MHz is 62.5 nanoseconds. We don't want to - // immediately read back the data bus until the address has settled, so do some SPI - // preparation in the meantime. - AssertControl(MCP_CS_PIN); - SPITransferNoRead(MCP23S17_CONTROL_READ(0)); - SPITransferNoRead(MCP23S17_GPIOA); - - // Read data. Bypass the GPIO/SPI drivers again... - u.bytes[1] = PINE; - u.bytes[0] = PINF; - u.bytes[3] = SPITransfer(0); - u.bytes[2] = SPITransfer(0); - DeassertControl(MCP_CS_PIN); - *buf++ = u.word; - } - - // Deassert OE once we are done - DeassertControl(FLASH_OE_PIN); - - // Control lines are left as "CS asserted, OE/WE not asserted" here. -} - -/** Writes/reads a byte to/from the MCP23S17. More optimal than using the driver. - * - * @param byte The byte to write - * @return The byte read back - */ -static ALWAYS_INLINE uint8_t SPITransfer(uint8_t byte) -{ - SPDR = byte; - // Crazy optimization. Instead of waiting for the status register - // (see the commented-out "while" statement below), wait for 17 clock - // cycles instead. We know that our SPI bit rate is half the CPU clock. - // After 17 clock cycles, the entire byte has been written out. - __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); - __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); - __asm__ __volatile__ ("nop\n"); - //while (!(SPSR & (1 << SPIF))); - return SPDR; -} - -/** Writes a byte to the MCP23S17 without reading back the result. More optimal - * than using the driver. - * - * @param byte The byte to write - */ -static ALWAYS_INLINE void SPITransferNoRead(uint8_t byte) -{ - SPDR = byte; - // Crazy optimization. Instead of waiting for the status register - // (see the commented-out "while" statement below), wait for 17 clock - // cycles instead. We know that our SPI bit rate is half the CPU clock. - // After 17 clock cycles, the entire byte has been written out. - __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); - __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); - __asm__ __volatile__ ("nop\n"); - //while (!(SPSR & (1 << SPIF))); -} - -/** Asserts a control pin - * - * @param pin Pin number of the control pin to assert - * - * This is slightly faster than using the GPIO driver because it inlines directly - * to a port RMW operation. Just a small optimization for performance. - */ -static ALWAYS_INLINE void AssertControl(uint8_t pin) -{ - FLASH_CONTROL_PORT &= ~(1 << pin); -} - -/** Deasserts a control pin - * - * @param pin Pin number of the control pin to deassert - * - * This is slightly faster than using the GPIO driver because it inlines directly - * to a port RMW operation. Just a small optimization for performance. - */ -static ALWAYS_INLINE void DeassertControl(uint8_t pin) -{ - FLASH_CONTROL_PORT |= (1 << pin); -} +/* + * parallel_bus.c + * + * Created on: Nov 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ----------------------------------------------------------------------------- + * + * For some reason, avr-gcc is super inefficient dealing with uint32_t + * variables. Looking at the individual bytes using a union results in much + * more optimized code. Every cycle counts for this. So several of these + * functions may seem weird with the unions, but it's faster than operating + * directly with the uint32_t variables. + * + * There are also a few time-critical places where I had to bypass the GPIO and + * SPI drivers, so it's not 100% clean. Oh well... + */ + +#include "../parallel_bus.h" +#include "../../drivers/mcp23s17.h" +#include "../../util.h" +#include "gpio_hw.h" +#include + +/// The port object where the OE, WE, and CS pins are connected +/// (This also happens to be where the MCP control pins are connected) +#define FLASH_CONTROL_PORT PORTB +/// The index of the MCP23S17 chip select pin +#define MCP_CS_PIN 0 +/// The index of the CS pin +#define FLASH_CS_PIN 4 +/// The index of the OE pin +#define FLASH_OE_PIN 5 +/// The index of the WE pin +#define FLASH_WE_PIN 6 +/// The index of the MCP23S17 reset pin +#define MCP_RESET_PIN 7 +/// The index of the highest address line on the parallel bus +#define PARALLEL_BUS_HIGHEST_ADDRESS_LINE 20 + +static ALWAYS_INLINE uint8_t SPITransfer(uint8_t byte); +static ALWAYS_INLINE void SPITransferNoRead(uint8_t byte); +static ALWAYS_INLINE void AssertControl(uint8_t pin); +static ALWAYS_INLINE void DeassertControl(uint8_t pin); + +/// The MCP23S17 device +static MCP23S17 mcp23s17 = { + .spi = { + .csPin = {GPIOB, MCP_CS_PIN} + } +}; + +/// The reset pin for the MCP23S17 +static const GPIOPin mcpReset = {GPIOB, MCP_RESET_PIN}; +/// The /WE pin for the parallel bus +static const GPIOPin flashWEPin = {GPIOB, FLASH_WE_PIN}; +/// The /OE pin for the parallel bus +static const GPIOPin flashOEPin = {GPIOB, FLASH_OE_PIN}; +/// The /CS pin for the flash chip +static const GPIOPin flashCSPin = {GPIOB, FLASH_CS_PIN}; +/// Whether or not data pins are outputs +static bool dataIsOutput; + +/** Initializes the 32-bit data/21-bit address parallel bus. + * + */ +void ParallelBus_Init(void) +{ + static bool mcpInited = false; + if (!mcpInited) + { + // Set up the MCP23S17 + SPI_InitController(SPI_Controller(0)); + mcp23s17.spi.controller = SPI_Controller(0); + MCP23S17_Init(&mcp23s17, mcpReset); + // Go ahead and let the MCP23S17 take over the SPI bus forever. + // There's nothing else attached to it. + MCP23S17_Begin(&mcp23s17); + mcpInited = true; + } + + // Configure all address lines as outputs, outputting address 0 + ParallelBus_SetAddressDir((1UL << (PARALLEL_BUS_HIGHEST_ADDRESS_LINE + 1)) - 1); + ParallelBus_SetAddress(0); + + // Set all data lines to pulled-up inputs + ParallelBus_SetDataDir(0); + ParallelBus_SetDataPullups(0xFFFFFFFFUL); + dataIsOutput = false; + // Note: During normal operation of read/write cycles, the pullups in the + // MCP23S17 will remember they are enabled, so we can do an optimization + // when using ParallelBus_ReadCycle/WriteCycle and assume they are already + // pulled up. This means we'll bypass ParallelBus_SetDataPullups. + + // Control lines + ParallelBus_SetCSDir(true); + ParallelBus_SetOEDir(true); + ParallelBus_SetWEDir(true); + + // Default to only CS asserted + DeassertControl(FLASH_WE_PIN); + DeassertControl(FLASH_OE_PIN); + AssertControl(FLASH_CS_PIN); +} + +/** Sets the address being output on the 21-bit address bus + * + * @param address The address + */ +void ParallelBus_SetAddress(uint32_t address) +{ + // For efficiency, we talk directly to the PORT registers in this function, + // rather than going through the GPIO class. + + // NOTE: If any of PORTA or PORTC or PORTD pins 0, 1, 4, 5, or 6 are set as + // inputs, this function might mess with their pull-up resistors. + // Only use it under normal operation when all the address pins are being + // used as outputs. + union { + uint32_t addr; + uint8_t addrBytes[4]; + } u; + + u.addr = address; + PORTA = u.addrBytes[0]; // A0-A7 + PORTC = u.addrBytes[1]; // A8-A15 + // A16-A20 are special because they are split up...(We use PORTD pins 0, 1, 4, 5, 6) + u.addrBytes[2] = (u.addrBytes[2] & 0x03) | (uint8_t)((u.addrBytes[2] & 0x1C) << 2) | (PORTD & 0x8C); + PORTD = u.addrBytes[2]; +} + +/** Sets the output data on the 32-bit data bus + * + * @param data The data + */ +void ParallelBus_SetData(uint32_t data) +{ + // For efficiency, we talk directly to the PORT registers in this function, + // rather than going through the GPIO class. + + // NOTE: If any pins of PORTE or PORTF are set as inputs, this + // function might mess with their pull-up resistors. + // Only use it under normal operation when all the data pins are being + // used as outputs + union { + uint32_t data; + uint16_t dataShorts[2]; + uint8_t dataBytes[4]; + } u; + u.data = data; + + // Doing the AVR registers first makes it so we don't have to use the stack + // (at least according to my testing with avr-gcc) + PORTE = u.dataBytes[1]; // D16-D23 + PORTF = u.dataBytes[0]; // D24-D31 + + // D0-D15 are part of the MCP23S17 + MCP23S17_SetOutputs(&mcp23s17, u.dataShorts[1]); +} + +/** Sets the output value of the CS pin + * + * @param high True if it should be high, false if low + */ +void ParallelBus_SetCS(bool high) +{ + GPIO_Set(flashCSPin, high); +} + +/** Sets the output value of the OE pin + * + * @param high True if it should be high, false if low + */ +void ParallelBus_SetOE(bool high) +{ + GPIO_Set(flashOEPin, high); +} + +/** Sets the output value of the WE pin + * + * @param high True if it should be high, false if low + */ +void ParallelBus_SetWE(bool high) +{ + GPIO_Set(flashWEPin, high); +} + +/** Sets which pins on the 21-bit address bus should be outputs + * + * @param outputs Mask of pins that should be outputs. 1 = output, 0 = input + * + * Typically the address pins will be outputs. This flexibility is provided in + * case we want to do electrical testing. + */ +void ParallelBus_SetAddressDir(uint32_t outputs) +{ + DDRA = (outputs & 0xFF); // A0-A7 + DDRC = ((outputs >> 8) & 0xFF); // A8-A15 + + // A16-A20 are special because they are split up...(We use PORTD pins 0, 1, 4, 5, 6) + uint8_t tmp = (outputs >> 16) & 0xFF; + tmp = (tmp & 0x03) | ((tmp & 0x1C) << 2); + + // Now, turn off the DDR bits we have to turn off, + // and turn on the DDR bits we have to turn on + // (without affecting other bits [2, 3, and 7] + // that we aren't supposed to touch) + DDRD &= (0x8C | tmp); // This should turn off all '0' bits in tmp. + DDRD |= tmp; // This should turn on all '1' bits in tmp +} + +/** Sets which pins on the 32-bit data bus should be outputs + * + * @param outputs Mask of pins that should be outputs. 1 = output, 0 = input + * + * Typically all pins would be set as inputs or outputs, and it's automatically + * handled by the read/write cycle functions. This function exists mainly for + * test purposes. + */ +void ParallelBus_SetDataDir(uint32_t outputs) +{ + union { + uint32_t data; + uint16_t dataShorts[2]; + uint8_t dataBytes[4]; + } u; + u.data = outputs; + + // Doing the AVR registers first makes it so we don't have to use the stack + DDRE = u.dataBytes[1]; // D16-D23 + DDRF = u.dataBytes[0]; // D24-D31 + + // D0-D15 are part of the MCP23S17 + MCP23S17_SetDDR(&mcp23s17, u.dataShorts[1]); + + // If none of the pins are outputs, ensure dataIsOutput is false + if (outputs == 0) + { + dataIsOutput = false; + } + // If all of the pins are outputs, ensure dataIsOutput is true + else if (outputs == 0xFFFFFFFFUL) + { + dataIsOutput = true; + } +} + +/** Sets the direction of the CS pin + * + * @param output True if it's an output, false if it's an input + * + * Typically this pin will be an output. This flexibility is provided in case + * we want to do electrical testing. + */ +void ParallelBus_SetCSDir(bool output) +{ + GPIO_SetDirection(flashCSPin, output); +} + +/** Sets the direction of the OE pin + * + * @param output True if it's an output, false if it's an input + * + * Typically this pin will be an output. This flexibility is provided in case + * we want to do electrical testing. + */ +void ParallelBus_SetOEDir(bool output) +{ + GPIO_SetDirection(flashOEPin, output); +} + +/** Sets the direction of the WE pin + * + * @param output True if it's an output, false if it's an input + * + * Typically this pin will be an output. This flexibility is provided in case + * we want to do electrical testing. + */ +void ParallelBus_SetWEDir(bool output) +{ + GPIO_SetDirection(flashWEPin, output); +} + +/** Sets which pins on the 21-bit address bus should be pulled up (if inputs) + * + * @param pullups Mask of pins that should be pullups. + * + * This would typically only be used for testing. Under normal operation, the + * address bus will be outputting, so the pullups are irrelevant. + */ +void ParallelBus_SetAddressPullups(uint32_t pullups) +{ + // Pull-ups are set by writing to the data register when in input mode. + // MAKE SURE THE PINS ARE SET AS INPUTS FIRST! This is a cheat only + // possible on the AVR. Some places like SIMMElectricalTest call SetAddress + // followed by SetAddressPullups, which is kinda weird because it sets the + // same registers. But the way it's called doesn't hurt anything... + ParallelBus_SetAddress(pullups); +} + +/** Sets which pins on the 32-bit data bus should be pulled up (if inputs) + * + * @param pullups Mask of pins that should be pullups. + * + * Typically these will be enabled in order to provide a default value if a + * chip isn't responding properly. Sometimes it's useful to customize it during + * testing though. + */ +void ParallelBus_SetDataPullups(uint32_t pullups) +{ + // NOTE: If any pins of PORTE or PORTF are set as outputs, this + // function might mess with their output values. + // Only use it when all the data pins are being used as inputs + union { + uint32_t data; + uint16_t dataShorts[2]; + uint8_t dataBytes[4]; + } u; + u.data = pullups; + + PORTE = u.dataBytes[1]; // D16-D23 + PORTF = u.dataBytes[0]; // D24-D31 + + // D0-D15 are part of the MCP23S17 + MCP23S17_SetPullups(&mcp23s17, u.dataShorts[1]); +} + +/** Sets whether the CS pin is pulled up, if it's an input. + * + * @param pullup True if the CS pin should be pulled up, false if not + * + * This would typically only be used for testing. Under normal operation, this + * pin will be set as an output, so the pullup state is irrelevant. + */ +void ParallelBus_SetCSPullup(bool pullup) +{ + GPIO_SetPullup(flashCSPin, pullup); +} + +/** Sets whether the OE pin is pulled up, if it's an input. + * + * @param pullup True if the OE pin should be pulled up, false if not + * + * This would typically only be used for testing. Under normal operation, this + * pin will be set as an output, so the pullup state is irrelevant. + */ +void ParallelBus_SetOEPullup(bool pullup) +{ + GPIO_SetPullup(flashOEPin, pullup); +} + +/** Sets whether the WE pin is pulled up, if it's an input. + * + * @param pullup True if the WE pin should be pulled up, false if not + * + * This would typically only be used for testing. Under normal operation, this + * pin will be set as an output, so the pullup state is irrelevant. + */ +void ParallelBus_SetWEPullup(bool pullup) +{ + GPIO_SetPullup(flashWEPin, pullup); +} + +/** Reads the current data on the address bus. + * + * @return The address bus readback + * + * This would typically only be used for testing. Under normal operation, the + * address bus will be outputting, so the readback is irrelevant. + */ +uint32_t ParallelBus_ReadAddress(void) +{ + uint32_t result = PINA; + result |= (((uint32_t)PINC) << 8); + uint8_t tmp = (PIND & 0x03) | ((PIND & 0x70) >> 2); + result |= (((uint32_t)tmp) << 16); + + return result; +} + +/** Reads the current data on the 32-bit data bus. + * + * @return The 32-bit data readback + */ +uint32_t ParallelBus_ReadData(void) +{ + union { + uint32_t data; + uint16_t dataShorts[2]; + uint8_t dataBytes[4]; + } u; + + u.dataShorts[1] = MCP23S17_ReadInputs(&mcp23s17); + + // Grab the other two bytes... + u.dataBytes[1] = PINE; + u.dataBytes[0] = PINF; + + return u.data; +} + +/** Reads the status of the CS pin, if it's set as an input. + * + * @return True if the CS pin is high, false if it's low + * + * This would typically only be used for testing. Under normal operation, this + * pin will be set as an output, so the readback is irrelevant. + */ +bool ParallelBus_ReadCS(void) +{ + return GPIO_Read(flashCSPin); +} + +/** Reads the status of the OE pin, if it's set as an input. + * + * @return True if the OE pin is high, false if it's low + * + * This would typically only be used for testing. Under normal operation, this + * pin will be set as an output, so the readback is irrelevant. + */ +bool ParallelBus_ReadOE(void) +{ + return GPIO_Read(flashOEPin); +} + +/** Reads the status of the WE pin, if it's set as an input. + * + * @return True if the WE pin is high, false if it's low + * + * This would typically only be used for testing. Under normal operation, this + * pin will be set as an output, so the readback is irrelevant. + */ +bool ParallelBus_ReadWE(void) +{ + return GPIO_Read(flashWEPin); +} + +/** Performs a write cycle on the parallel bus. + * + * @param address The address to write to + * @param data The 32-bit data to write to the bus + * + * Because this function is used a lot during programming, it is super + * optimized and bypasses the GPIO and SPI drivers. It's a necessary evil. + * It makes a big difference in programming time. + */ +void ParallelBus_WriteCycle(uint32_t address, uint32_t data) +{ + // Using this union surprisingly speeds things up when assembling or + // interpreting a uint32_t on the AVR. + union { + uint32_t word; + uint8_t bytes[4]; + } u; + + // We should currently be in a state of "CS is asserted, OE/WE not asserted". + // As an optimization, operate under that assumption. + + // Set address. This is basically the exact same code as ParallelBus_SetAddress, + // but repeated in here so we don't have any function call overhead. + u.word = address; + PORTA = u.bytes[0]; + PORTC = u.bytes[1]; + u.bytes[2] = (u.bytes[2] & 0x03) | (uint8_t)((u.bytes[2] & 0x1C) << 2) | (PORTD & 0x8C); + PORTD = u.bytes[2]; + + // If the data port is not already set as outputs, set it to be outputs now + if (!dataIsOutput) + { + // Set data as outputs. Bypass the SPI/GPIO drivers for this for efficiency. + DDRE = 0xFF; + DDRF = 0xFF; + AssertControl(MCP_CS_PIN); + SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); + SPITransferNoRead(MCP23S17_IODIRA); + SPITransferNoRead(0); + SPITransferNoRead(0); + DeassertControl(MCP_CS_PIN); + dataIsOutput = true; + } + + // Set data. Bypass the SPI/GPIO drivers again... + u.word = data; + PORTE = u.bytes[1]; + PORTF = u.bytes[0]; + AssertControl(MCP_CS_PIN); + SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); + SPITransferNoRead(MCP23S17_GPIOA); + SPITransferNoRead(u.bytes[3]); + SPITransferNoRead(u.bytes[2]); + DeassertControl(MCP_CS_PIN); + + // Assert and then deassert WE to actually do the write cycle. + AssertControl(FLASH_WE_PIN); + DeassertControl(FLASH_WE_PIN); + + // Control lines are left as "CS asserted, OE/WE not asserted" here. +} + +/** Performs a read cycle on the parallel bus. + * + * @param address The address to read from + * @return The returned 32-bit data + * + * Because this function is used a lot during programming, it is super + * optimized and bypasses the GPIO and SPI drivers. It's a necessary evil. + * It makes a big difference in programming time. + */ +uint32_t ParallelBus_ReadCycle(uint32_t address) +{ + // Using this union surprisingly speeds things up when assembling or + // interpreting a uint32_t on the AVR. + union { + uint32_t word; + uint8_t bytes[4]; + } u; + + // We should currently be in a state of "CS is asserted, OE/WE not asserted". + // As an optimization, operate under that assumption. + + // If the data pins are set as outputs, change them to inputs + if (dataIsOutput) + { + // Set data as inputs. Bypass the SPI/GPIO drivers for this for efficiency. + DDRE = 0; + DDRF = 0; + AssertControl(MCP_CS_PIN); + SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); + SPITransferNoRead(MCP23S17_IODIRA); + SPITransferNoRead(0xFF); + SPITransferNoRead(0xFF); + DeassertControl(MCP_CS_PIN); + + // Set pull-ups on the AVR data pins so we get a default value if a chip + // isn't responding. We can assume the MCP23S17 has already been configured + // to have its inputs pulled up. On the AVR we can't assume because its + // pull-up state is shared by the same register used for data output. + PORTE = 0xFF; + PORTF = 0xFF; + + dataIsOutput = false; + } + + // Assert OE so we start reading from the chip. Safe to do now that + // the data pins have been set as inputs. + AssertControl(FLASH_OE_PIN); + + // Set address. This is basically the exact same code as ParallelBus_SetAddress, + // but repeated in here so we don't have any function call overhead. + u.word = address; + PORTA = u.bytes[0]; + PORTC = u.bytes[1]; + u.bytes[2] = (u.bytes[2] & 0x03) | (uint8_t)((u.bytes[2] & 0x1C) << 2) | (PORTD & 0x8C); + PORTD = u.bytes[2]; + + // Start the SPI read. Each clock cycle at 16 MHz is 62.5 nanoseconds. We don't want to + // immediately read back the data bus until the address has settled, so do some SPI + // preparation in the meantime. + AssertControl(MCP_CS_PIN); + SPITransferNoRead(MCP23S17_CONTROL_READ(0)); + SPITransferNoRead(MCP23S17_GPIOA); + + // Read data. Bypass the GPIO/SPI drivers again... + u.bytes[1] = PINE; + u.bytes[0] = PINF; + u.bytes[3] = SPITransfer(0); + u.bytes[2] = SPITransfer(0); + DeassertControl(MCP_CS_PIN); + + // Deassert OE, and we're done. + DeassertControl(FLASH_OE_PIN); + + // Control lines are left as "CS asserted, OE/WE not asserted" here. + + // Return the final value + return u.word; +} + +/** Reads a bunch of consecutive data from the parallel bus + * + * @param startAddress The address to start reading from + * @param buf Buffer to store the readback + * @param len The number of 32-bit words to read + * + * This function is just a time saver if we know we will be reading a big block + * of data. It doesn't bother playing with the control lines between each byte. + */ +void ParallelBus_Read(uint32_t startAddress, uint32_t *buf, uint16_t len) +{ + // We should currently be in a state of "CS is asserted, OE/WE not asserted". + // As an optimization, operate under that assumption. + + // Using this union surprisingly speeds things up when assembling or + // interpreting a uint32_t on the AVR. + union { + uint32_t word; + uint8_t bytes[4]; + } u; + + // If the data pins are set as outputs, change them to inputs + if (dataIsOutput) + { + // Set data as inputs. Bypass the SPI/GPIO drivers for this for efficiency. + DDRE = 0; + DDRF = 0; + AssertControl(MCP_CS_PIN); + SPITransferNoRead(MCP23S17_CONTROL_WRITE(0)); + SPITransferNoRead(MCP23S17_IODIRA); + SPITransferNoRead(0xFF); + SPITransferNoRead(0xFF); + DeassertControl(MCP_CS_PIN); + + // Set pull-ups on the AVR data pins so we get a default value if a chip + // isn't responding. We can assume the MCP23S17 has already been configured + // to have its inputs pulled up. On the AVR we can't assume because its + // pull-up state is shared by the same register used for data output. + PORTE = 0xFF; + PORTF = 0xFF; + + dataIsOutput = false; + } + + // Assert OE, now the chip will start spitting out data. + AssertControl(FLASH_OE_PIN); + + while (len--) + { + // Set address. This is basically the exact same code as ParallelBus_SetAddress, + // but repeated in here so we don't have any function call overhead. + u.word = startAddress++; + PORTA = u.bytes[0]; + PORTC = u.bytes[1]; + u.bytes[2] = (u.bytes[2] & 0x03) | (uint8_t)((u.bytes[2] & 0x1C) << 2) | (PORTD & 0x8C); + PORTD = u.bytes[2]; + + // Start the SPI read. Each clock cycle at 16 MHz is 62.5 nanoseconds. We don't want to + // immediately read back the data bus until the address has settled, so do some SPI + // preparation in the meantime. + AssertControl(MCP_CS_PIN); + SPITransferNoRead(MCP23S17_CONTROL_READ(0)); + SPITransferNoRead(MCP23S17_GPIOA); + + // Read data. Bypass the GPIO/SPI drivers again... + u.bytes[1] = PINE; + u.bytes[0] = PINF; + u.bytes[3] = SPITransfer(0); + u.bytes[2] = SPITransfer(0); + DeassertControl(MCP_CS_PIN); + *buf++ = u.word; + } + + // Deassert OE once we are done + DeassertControl(FLASH_OE_PIN); + + // Control lines are left as "CS asserted, OE/WE not asserted" here. +} + +/** Writes/reads a byte to/from the MCP23S17. More optimal than using the driver. + * + * @param byte The byte to write + * @return The byte read back + */ +static ALWAYS_INLINE uint8_t SPITransfer(uint8_t byte) +{ + SPDR = byte; + // Crazy optimization. Instead of waiting for the status register + // (see the commented-out "while" statement below), wait for 17 clock + // cycles instead. We know that our SPI bit rate is half the CPU clock. + // After 17 clock cycles, the entire byte has been written out. + __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); + __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); + __asm__ __volatile__ ("nop\n"); + //while (!(SPSR & (1 << SPIF))); + return SPDR; +} + +/** Writes a byte to the MCP23S17 without reading back the result. More optimal + * than using the driver. + * + * @param byte The byte to write + */ +static ALWAYS_INLINE void SPITransferNoRead(uint8_t byte) +{ + SPDR = byte; + // Crazy optimization. Instead of waiting for the status register + // (see the commented-out "while" statement below), wait for 17 clock + // cycles instead. We know that our SPI bit rate is half the CPU clock. + // After 17 clock cycles, the entire byte has been written out. + __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); + __asm__ __volatile__ ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop\n"); + __asm__ __volatile__ ("nop\n"); + //while (!(SPSR & (1 << SPIF))); +} + +/** Asserts a control pin + * + * @param pin Pin number of the control pin to assert + * + * This is slightly faster than using the GPIO driver because it inlines directly + * to a port RMW operation. Just a small optimization for performance. + */ +static ALWAYS_INLINE void AssertControl(uint8_t pin) +{ + FLASH_CONTROL_PORT &= ~(1 << pin); +} + +/** Deasserts a control pin + * + * @param pin Pin number of the control pin to deassert + * + * This is slightly faster than using the GPIO driver because it inlines directly + * to a port RMW operation. Just a small optimization for performance. + */ +static ALWAYS_INLINE void DeassertControl(uint8_t pin) +{ + FLASH_CONTROL_PORT |= (1 << pin); +} diff --git a/hal/at90usb646/spi.c b/hal/at90usb646/spi.c index e1c9854..ad45ce4 100644 --- a/hal/at90usb646/spi.c +++ b/hal/at90usb646/spi.c @@ -1,199 +1,199 @@ -/* - * spi.c - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "../spi.h" -#include "gpio_hw.h" -#include -#include - -/// Keep a struct of available dividers, calculate something at runtime. -typedef struct SPIDividerInfo -{ - /// The divider - uint8_t divider; - /// Bit 0 = SPR0, Bit 1 = SPR1, Bit 2 = SPI2X (in SPSR) - uint8_t configBits; -} SPIDividerInfo; - -/// List of possible SPI dividers. Must be in ascending order. -static const SPIDividerInfo dividers[] = { - {2, 0b100}, - {4, 0b000}, - {8, 0b101}, - {16, 0b001}, - {32, 0b110}, - {64, 0b010}, - {128, 0b011} -}; - -/// The lone SPI controller available on this AVR -static SPIController controller = -{ - .sckPin = {GPIOB, 1}, - .mosiPin = {GPIOB, 2}, - .misoPin = {GPIOB, 3} -}; - -/** Gets the SPI hardware controller at the specified index - * - * @param index The index of the controller. Only 0 is valid on this AVR. - * @return The SPI controller, or NULL if an invalid index is supplied - */ -SPIController *SPI_Controller(uint8_t index) -{ - // The AVR only has one SPI controller - return (index == 0) ? &controller : NULL; -} - -/** Initializes the supplied SPI controller - * - * @param c The controller - */ -void SPI_InitController(SPIController *c) -{ - GPIO_SetDirection(c->sckPin, true); - GPIO_SetDirection(c->mosiPin, true); - GPIO_SetDirection(c->misoPin, false); - // Don't do anything with the rest of the registers. - // SPI_RequestController will handle it. -} - -/** Initializes the supplied SPI device - * - * @param spi The device - * @param maxClock The maximum clock rate supported by the device in Hz - * @param mode The SPI mode (see the SPI_MODE_*, SPI_CPHA, and SPI_CPOL defines) - * @return True on success, false on failure - */ -bool SPI_InitDevice(SPIDevice *spi, uint32_t maxClock, uint8_t mode) -{ - GPIO_SetDirection(spi->csPin, true); - SPI_Deassert(spi); - - // Calculate which SPI clock divider to use - int8_t dividerIndex = -1; - for (uint8_t i = 0; dividerIndex < 0 && i < sizeof(dividers)/sizeof(dividers[0]); i++) - { - if (F_CPU / (uint32_t)dividers[i].divider <= maxClock) - { - dividerIndex = (int8_t)i; - } - } - - // Fill in the SPI config registers according to the requested clock - if (dividerIndex >= 0) - { - uint8_t dividerBits = dividers[dividerIndex].configBits; - - spi->private.spcr = - (0 << SPIE) | // No SPI interrupts - (1 << SPE) | // Enable SPI - (0 << DORD) | // MSB first - (1 << MSTR) | // Master mode - (((mode & SPI_CPOL) ? 1 : 0) << CPOL) | - (((mode & SPI_CPHA) ? 1 : 0) << CPHA) | - ((dividerBits & 3) << SPR0); - - // The only writable bit in SPSR is the SPI2X bit. - spi->private.spsr = - ((dividerBits >> 2) << SPI2X); - - return true; - } - else - { - // This SPI device requires a clock slower than what we can divide down to - return true; - } -} - -/** Allows an SPI device to request control of the bus. - * - * @param spi The SPI device - */ -void SPI_RequestBus(SPIDevice *spi) -{ - (void)spi; - - // Set up the controller with the correct speed/mode config for this device - SPCR = spi->private.spcr; - SPSR = spi->private.spsr; -} - -/** Allows an SPI device to relinquish control of the bus. - * - * @param spi The SPI device - */ -void SPI_ReleaseBus(SPIDevice *spi) -{ - (void)spi; -} - -/** Asserts an SPI device's chip select pin - * - * @param spi The SPI device - */ -void SPI_Assert(SPIDevice *spi) -{ - GPIO_SetOff(spi->csPin); - - // Due to the optimization we do in ParallelBus talking directly to the - // SPI hardware without going through this driver, we need to make sure - // that the SPIF flag is cleared here. Otherwise we may think we're done - // too early, which would cause us to screw up the next SPI transfer. - // This happens because the optimized code doesn't look at SPSR, so the - // SPIF flag never gets cleared from the previous SPI operation. - if (SPSR & (1 << SPIF)) - { - // Reading the data register clears the flag if it's set - (void)SPDR; - } -} - -/** Deasserts an SPI device's chip select pin - * - * @param spi The SPI device - */ -void SPI_Deassert(SPIDevice *spi) -{ - GPIO_SetOn(spi->csPin); -} - -/** Transfers a single byte to/from an SPI device - * - * @param spi The SPI device - * @param b The byte to send - * @return The byte that was simultaneously received - */ -uint8_t SPI_RWByte(SPIDevice *spi, uint8_t b) -{ - // Since there's only one controller on this AVR, we don't actually care - // about the SPI device pointer here - (void)spi; - - // Write the byte, wait for the write to complete, read back the result - SPDR = b; - while (!(SPSR & (1 << SPIF))); - return SPDR; -} +/* + * spi.c + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "../spi.h" +#include "gpio_hw.h" +#include +#include + +/// Keep a struct of available dividers, calculate something at runtime. +typedef struct SPIDividerInfo +{ + /// The divider + uint8_t divider; + /// Bit 0 = SPR0, Bit 1 = SPR1, Bit 2 = SPI2X (in SPSR) + uint8_t configBits; +} SPIDividerInfo; + +/// List of possible SPI dividers. Must be in ascending order. +static const SPIDividerInfo dividers[] = { + {2, 0b100}, + {4, 0b000}, + {8, 0b101}, + {16, 0b001}, + {32, 0b110}, + {64, 0b010}, + {128, 0b011} +}; + +/// The lone SPI controller available on this AVR +static SPIController controller = +{ + .sckPin = {GPIOB, 1}, + .mosiPin = {GPIOB, 2}, + .misoPin = {GPIOB, 3} +}; + +/** Gets the SPI hardware controller at the specified index + * + * @param index The index of the controller. Only 0 is valid on this AVR. + * @return The SPI controller, or NULL if an invalid index is supplied + */ +SPIController *SPI_Controller(uint8_t index) +{ + // The AVR only has one SPI controller + return (index == 0) ? &controller : NULL; +} + +/** Initializes the supplied SPI controller + * + * @param c The controller + */ +void SPI_InitController(SPIController *c) +{ + GPIO_SetDirection(c->sckPin, true); + GPIO_SetDirection(c->mosiPin, true); + GPIO_SetDirection(c->misoPin, false); + // Don't do anything with the rest of the registers. + // SPI_RequestController will handle it. +} + +/** Initializes the supplied SPI device + * + * @param spi The device + * @param maxClock The maximum clock rate supported by the device in Hz + * @param mode The SPI mode (see the SPI_MODE_*, SPI_CPHA, and SPI_CPOL defines) + * @return True on success, false on failure + */ +bool SPI_InitDevice(SPIDevice *spi, uint32_t maxClock, uint8_t mode) +{ + GPIO_SetDirection(spi->csPin, true); + SPI_Deassert(spi); + + // Calculate which SPI clock divider to use + int8_t dividerIndex = -1; + for (uint8_t i = 0; dividerIndex < 0 && i < sizeof(dividers)/sizeof(dividers[0]); i++) + { + if (F_CPU / (uint32_t)dividers[i].divider <= maxClock) + { + dividerIndex = (int8_t)i; + } + } + + // Fill in the SPI config registers according to the requested clock + if (dividerIndex >= 0) + { + uint8_t dividerBits = dividers[dividerIndex].configBits; + + spi->private.spcr = + (0 << SPIE) | // No SPI interrupts + (1 << SPE) | // Enable SPI + (0 << DORD) | // MSB first + (1 << MSTR) | // Master mode + (((mode & SPI_CPOL) ? 1 : 0) << CPOL) | + (((mode & SPI_CPHA) ? 1 : 0) << CPHA) | + ((dividerBits & 3) << SPR0); + + // The only writable bit in SPSR is the SPI2X bit. + spi->private.spsr = + ((dividerBits >> 2) << SPI2X); + + return true; + } + else + { + // This SPI device requires a clock slower than what we can divide down to + return true; + } +} + +/** Allows an SPI device to request control of the bus. + * + * @param spi The SPI device + */ +void SPI_RequestBus(SPIDevice *spi) +{ + (void)spi; + + // Set up the controller with the correct speed/mode config for this device + SPCR = spi->private.spcr; + SPSR = spi->private.spsr; +} + +/** Allows an SPI device to relinquish control of the bus. + * + * @param spi The SPI device + */ +void SPI_ReleaseBus(SPIDevice *spi) +{ + (void)spi; +} + +/** Asserts an SPI device's chip select pin + * + * @param spi The SPI device + */ +void SPI_Assert(SPIDevice *spi) +{ + GPIO_SetOff(spi->csPin); + + // Due to the optimization we do in ParallelBus talking directly to the + // SPI hardware without going through this driver, we need to make sure + // that the SPIF flag is cleared here. Otherwise we may think we're done + // too early, which would cause us to screw up the next SPI transfer. + // This happens because the optimized code doesn't look at SPSR, so the + // SPIF flag never gets cleared from the previous SPI operation. + if (SPSR & (1 << SPIF)) + { + // Reading the data register clears the flag if it's set + (void)SPDR; + } +} + +/** Deasserts an SPI device's chip select pin + * + * @param spi The SPI device + */ +void SPI_Deassert(SPIDevice *spi) +{ + GPIO_SetOn(spi->csPin); +} + +/** Transfers a single byte to/from an SPI device + * + * @param spi The SPI device + * @param b The byte to send + * @return The byte that was simultaneously received + */ +uint8_t SPI_RWByte(SPIDevice *spi, uint8_t b) +{ + // Since there's only one controller on this AVR, we don't actually care + // about the SPI device pointer here + (void)spi; + + // Write the byte, wait for the write to complete, read back the result + SPDR = b; + while (!(SPSR & (1 << SPIF))); + return SPDR; +} diff --git a/hal/at90usb646/spi_private.h b/hal/at90usb646/spi_private.h index cd7170b..68bc85d 100644 --- a/hal/at90usb646/spi_private.h +++ b/hal/at90usb646/spi_private.h @@ -1,37 +1,37 @@ -/* - * spi_private.h - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_AT90USB646_SPI_PRIVATE_H_ -#define HAL_AT90USB646_SPI_PRIVATE_H_ - -/// Private data for an SPI device on the AT90USB646 -typedef struct SPIDevicePrivate -{ - /// Value to write into the SPCR register (contains timing/mode info) - uint8_t spcr; - /// Value to write into the SPSR register (contains timing info) - uint8_t spsr; -} SPIDevicePrivate; - -#endif /* HAL_AT90USB646_SPI_PRIVATE_H_ */ +/* + * spi_private.h + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_AT90USB646_SPI_PRIVATE_H_ +#define HAL_AT90USB646_SPI_PRIVATE_H_ + +/// Private data for an SPI device on the AT90USB646 +typedef struct SPIDevicePrivate +{ + /// Value to write into the SPCR register (contains timing/mode info) + uint8_t spcr; + /// Value to write into the SPSR register (contains timing info) + uint8_t spsr; +} SPIDevicePrivate; + +#endif /* HAL_AT90USB646_SPI_PRIVATE_H_ */ diff --git a/hal/at90usb646/usbcdc.c b/hal/at90usb646/usbcdc.c index 66b20f4..baf84d5 100644 --- a/hal/at90usb646/usbcdc.c +++ b/hal/at90usb646/usbcdc.c @@ -1,73 +1,73 @@ -/* - * usbcdc.c - * - * Created on: Nov 22, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "../usbcdc.h" -#include "LUFA/Drivers/USB/USB.h" -#include "cdc_device_definition.h" - -/** Initializes the USB CDC device - * - */ -void USBCDC_Init(void) -{ - // Initialize LUFA - USB_Init(); -} - -/** Disables the USB CDC device - * - */ -void USBCDC_Disable(void) -{ - // Disable LUFA, this will cause us to no longer identify as a USB device - USB_Disable(); -} - -/** Main loop handler for the USB CDC device. Call from the main loop. - * - */ -void USBCDC_Check(void) -{ - // Do the periodic CDC and USB tasks in LUFA - CDC_Device_USBTask(&VirtualSerial_CDC_Interface); - USB_USBTask(); -} - -/** LUFA event handler for when the USB configuration changes. - * - */ -void EVENT_USB_Device_ConfigurationChanged(void) -{ - bool ConfigSuccess = true; - - ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface); -} - -/** LUFA event handler for when a USB control request is received - * - */ -void EVENT_USB_Device_ControlRequest(void) -{ - CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); -} +/* + * usbcdc.c + * + * Created on: Nov 22, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "../usbcdc.h" +#include "LUFA/Drivers/USB/USB.h" +#include "cdc_device_definition.h" + +/** Initializes the USB CDC device + * + */ +void USBCDC_Init(void) +{ + // Initialize LUFA + USB_Init(); +} + +/** Disables the USB CDC device + * + */ +void USBCDC_Disable(void) +{ + // Disable LUFA, this will cause us to no longer identify as a USB device + USB_Disable(); +} + +/** Main loop handler for the USB CDC device. Call from the main loop. + * + */ +void USBCDC_Check(void) +{ + // Do the periodic CDC and USB tasks in LUFA + CDC_Device_USBTask(&VirtualSerial_CDC_Interface); + USB_USBTask(); +} + +/** LUFA event handler for when the USB configuration changes. + * + */ +void EVENT_USB_Device_ConfigurationChanged(void) +{ + bool ConfigSuccess = true; + + ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface); +} + +/** LUFA event handler for when a USB control request is received + * + */ +void EVENT_USB_Device_ControlRequest(void) +{ + CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); +} diff --git a/hal/at90usb646/usbcdc_hw.h b/hal/at90usb646/usbcdc_hw.h index fc81ec5..afc2c42 100644 --- a/hal/at90usb646/usbcdc_hw.h +++ b/hal/at90usb646/usbcdc_hw.h @@ -1,83 +1,83 @@ -/* - * usbcdc_hw.h - * - * Created on: Nov 22, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_AT90USB646_USBCDC_HW_H_ -#define HAL_AT90USB646_USBCDC_HW_H_ - -#include "LUFA/Drivers/USB/USB.h" -#include "cdc_device_definition.h" -#include "../../util.h" - -/** Sends a byte over the USB CDC serial port - * - * @param byte The byte to send - */ -static ALWAYS_INLINE void USBCDC_SendByte(uint8_t byte) -{ - CDC_Device_SendByte(&VirtualSerial_CDC_Interface, byte); -} - -/** Sends a block of data over the USB CDC serial port - * - * @param data The data to send - * @param len The number of bytes - * @return True on success, false on failure - */ -static ALWAYS_INLINE bool USBCDC_SendData(uint8_t const *data, uint16_t len) -{ - return CDC_Device_SendData(&VirtualSerial_CDC_Interface, (char const *)data, len) == ENDPOINT_RWSTREAM_NoError; -} - -/** Attempts to read a byte from the USB CDC serial port - * - * @return The byte read, or -1 if there are no bytes available - */ -static ALWAYS_INLINE int16_t USBCDC_ReadByte(void) -{ - return CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); -} - -/** Reads a byte from the USB CDC serial port. Blocks until one is available. - * - * @return The byte read - */ -static ALWAYS_INLINE uint8_t USBCDC_ReadByteBlocking(void) -{ - int16_t b; - do - { - b = USBCDC_ReadByte(); - } while (b < 0); - return (uint8_t)b; -} - -/** Forces any transmitted data to be sent over USB immediately - * - */ -static ALWAYS_INLINE inline void USBCDC_Flush(void) -{ - CDC_Device_Flush(&VirtualSerial_CDC_Interface); -} - -#endif /* HAL_AT90USB646_USBCDC_HW_H_ */ +/* + * usbcdc_hw.h + * + * Created on: Nov 22, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_AT90USB646_USBCDC_HW_H_ +#define HAL_AT90USB646_USBCDC_HW_H_ + +#include "LUFA/Drivers/USB/USB.h" +#include "cdc_device_definition.h" +#include "../../util.h" + +/** Sends a byte over the USB CDC serial port + * + * @param byte The byte to send + */ +static ALWAYS_INLINE void USBCDC_SendByte(uint8_t byte) +{ + CDC_Device_SendByte(&VirtualSerial_CDC_Interface, byte); +} + +/** Sends a block of data over the USB CDC serial port + * + * @param data The data to send + * @param len The number of bytes + * @return True on success, false on failure + */ +static ALWAYS_INLINE bool USBCDC_SendData(uint8_t const *data, uint16_t len) +{ + return CDC_Device_SendData(&VirtualSerial_CDC_Interface, (char const *)data, len) == ENDPOINT_RWSTREAM_NoError; +} + +/** Attempts to read a byte from the USB CDC serial port + * + * @return The byte read, or -1 if there are no bytes available + */ +static ALWAYS_INLINE int16_t USBCDC_ReadByte(void) +{ + return CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); +} + +/** Reads a byte from the USB CDC serial port. Blocks until one is available. + * + * @return The byte read + */ +static ALWAYS_INLINE uint8_t USBCDC_ReadByteBlocking(void) +{ + int16_t b; + do + { + b = USBCDC_ReadByte(); + } while (b < 0); + return (uint8_t)b; +} + +/** Forces any transmitted data to be sent over USB immediately + * + */ +static ALWAYS_INLINE inline void USBCDC_Flush(void) +{ + CDC_Device_Flush(&VirtualSerial_CDC_Interface); +} + +#endif /* HAL_AT90USB646_USBCDC_HW_H_ */ diff --git a/hal/board.h b/hal/board.h index 82f2f8d..6d77f82 100644 --- a/hal/board.h +++ b/hal/board.h @@ -1,38 +1,38 @@ -/* - * board.h - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_BOARD_H_ -#define HAL_BOARD_H_ - -#include "gpio.h" -#include "spi.h" - -// Commented-out functions should be static inline in each board-specific header file. -//GPIOPin Board_LEDPin(void); -#include "board_hw.h" - -void Board_Init(void); -bool Board_BrownoutDetected(void); - -#endif /* HAL_BOARD_H_ */ +/* + * board.h + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_BOARD_H_ +#define HAL_BOARD_H_ + +#include "gpio.h" +#include "spi.h" + +// Commented-out functions should be static inline in each board-specific header file. +//GPIOPin Board_LEDPin(void); +#include "board_hw.h" + +void Board_Init(void); +bool Board_BrownoutDetected(void); + +#endif /* HAL_BOARD_H_ */ diff --git a/hal/gpio.h b/hal/gpio.h index 685bb96..b96350c 100644 --- a/hal/gpio.h +++ b/hal/gpio.h @@ -1,72 +1,72 @@ -/* - * gpio.h - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_GPIO_H_ -#define HAL_GPIO_H_ - -#include -#include - -/// Creates a temporary GPIOPin struct. Used when assigning to a GPIOPin variable. -#define GPIO_PIN(port, pin) ((GPIOPin){port, pin}) -/// A NULL GPIO pin -#define GPIO_PIN_NULL ((GPIOPin){0xFF, 0xFF}) - -/// The GPIO pin struct -typedef struct GPIOPin -{ - /// The port the pin belongs to - uint8_t port; - /// The index of the pin on the port - uint8_t pin; -} GPIOPin; - -void GPIO_SetDirection(GPIOPin pin, bool output); -void GPIO_SetPullup(GPIOPin pin, bool pullup); -void GPIO_SetOn(GPIOPin pin); -void GPIO_SetOff(GPIOPin pin); -void GPIO_Toggle(GPIOPin pin); -bool GPIO_Read(GPIOPin pin); - -/** Sets whether a GPIO pin is outputting high or low - * - * @param pin The pin - * @param on True if it's high, false if it's low - */ -static inline void GPIO_Set(GPIOPin pin, bool on) -{ - on ? GPIO_SetOn(pin) : GPIO_SetOff(pin); -} - -/** Determines if a GPIO pin is null - * - * @param pin The pin - * @return True if it's null, false if not - */ -static inline bool GPIO_IsNull(GPIOPin pin) -{ - return pin.pin == 0xFF && pin.port == 0xFF; -} - -#endif /* HAL_GPIO_H_ */ +/* + * gpio.h + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_GPIO_H_ +#define HAL_GPIO_H_ + +#include +#include + +/// Creates a temporary GPIOPin struct. Used when assigning to a GPIOPin variable. +#define GPIO_PIN(port, pin) ((GPIOPin){port, pin}) +/// A NULL GPIO pin +#define GPIO_PIN_NULL ((GPIOPin){0xFF, 0xFF}) + +/// The GPIO pin struct +typedef struct GPIOPin +{ + /// The port the pin belongs to + uint8_t port; + /// The index of the pin on the port + uint8_t pin; +} GPIOPin; + +void GPIO_SetDirection(GPIOPin pin, bool output); +void GPIO_SetPullup(GPIOPin pin, bool pullup); +void GPIO_SetOn(GPIOPin pin); +void GPIO_SetOff(GPIOPin pin); +void GPIO_Toggle(GPIOPin pin); +bool GPIO_Read(GPIOPin pin); + +/** Sets whether a GPIO pin is outputting high or low + * + * @param pin The pin + * @param on True if it's high, false if it's low + */ +static inline void GPIO_Set(GPIOPin pin, bool on) +{ + on ? GPIO_SetOn(pin) : GPIO_SetOff(pin); +} + +/** Determines if a GPIO pin is null + * + * @param pin The pin + * @return True if it's null, false if not + */ +static inline bool GPIO_IsNull(GPIOPin pin) +{ + return pin.pin == 0xFF && pin.port == 0xFF; +} + +#endif /* HAL_GPIO_H_ */ diff --git a/hal/parallel_bus.h b/hal/parallel_bus.h index 7ab5537..1424a40 100644 --- a/hal/parallel_bus.h +++ b/hal/parallel_bus.h @@ -1,61 +1,61 @@ -/* - * parallel_bus.h - * - * Created on: Nov 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_PARALLEL_BUS_H_ -#define HAL_PARALLEL_BUS_H_ - -#include -#include - -void ParallelBus_Init(void); - -void ParallelBus_SetAddress(uint32_t address); -void ParallelBus_SetData(uint32_t data); -void ParallelBus_SetCS(bool high); -void ParallelBus_SetOE(bool high); -void ParallelBus_SetWE(bool high); - -void ParallelBus_SetAddressDir(uint32_t outputs); -void ParallelBus_SetDataDir(uint32_t outputs); -void ParallelBus_SetCSDir(bool output); -void ParallelBus_SetOEDir(bool output); -void ParallelBus_SetWEDir(bool output); - -void ParallelBus_SetAddressPullups(uint32_t pullups); -void ParallelBus_SetDataPullups(uint32_t pullups); -void ParallelBus_SetCSPullup(bool pullup); -void ParallelBus_SetOEPullup(bool pullup); -void ParallelBus_SetWEPullup(bool pullup); - -uint32_t ParallelBus_ReadAddress(void); -uint32_t ParallelBus_ReadData(void); -bool ParallelBus_ReadCS(void); -bool ParallelBus_ReadOE(void); -bool ParallelBus_ReadWE(void); - -void ParallelBus_WriteCycle(uint32_t address, uint32_t data); -uint32_t ParallelBus_ReadCycle(uint32_t address); -void ParallelBus_Read(uint32_t startAddress, uint32_t *buf, uint16_t len); - -#endif /* HAL_PARALLEL_BUS_H_ */ +/* + * parallel_bus.h + * + * Created on: Nov 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_PARALLEL_BUS_H_ +#define HAL_PARALLEL_BUS_H_ + +#include +#include + +void ParallelBus_Init(void); + +void ParallelBus_SetAddress(uint32_t address); +void ParallelBus_SetData(uint32_t data); +void ParallelBus_SetCS(bool high); +void ParallelBus_SetOE(bool high); +void ParallelBus_SetWE(bool high); + +void ParallelBus_SetAddressDir(uint32_t outputs); +void ParallelBus_SetDataDir(uint32_t outputs); +void ParallelBus_SetCSDir(bool output); +void ParallelBus_SetOEDir(bool output); +void ParallelBus_SetWEDir(bool output); + +void ParallelBus_SetAddressPullups(uint32_t pullups); +void ParallelBus_SetDataPullups(uint32_t pullups); +void ParallelBus_SetCSPullup(bool pullup); +void ParallelBus_SetOEPullup(bool pullup); +void ParallelBus_SetWEPullup(bool pullup); + +uint32_t ParallelBus_ReadAddress(void); +uint32_t ParallelBus_ReadData(void); +bool ParallelBus_ReadCS(void); +bool ParallelBus_ReadOE(void); +bool ParallelBus_ReadWE(void); + +void ParallelBus_WriteCycle(uint32_t address, uint32_t data); +uint32_t ParallelBus_ReadCycle(uint32_t address); +void ParallelBus_Read(uint32_t startAddress, uint32_t *buf, uint16_t len); + +#endif /* HAL_PARALLEL_BUS_H_ */ diff --git a/hal/spi.h b/hal/spi.h index 5768cb2..c37ead7 100644 --- a/hal/spi.h +++ b/hal/spi.h @@ -1,75 +1,75 @@ -/* - * spi.h - * - * Created on: Nov 14, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_SPI_H_ -#define HAL_SPI_H_ - -#include "gpio.h" -#include "spi_private.h" - -/// CPHA bit in the SPI mode parameter of SPI_InitDevice -#define SPI_CPHA (1 << 0) -/// CPOL bit in the SPI mode parameter of SPI_InitDevice -#define SPI_CPOL (1 << 1) - -/// Friendly names for modes 0-3 when dealing with CPHA/CPOL in SPI_InitDevice -#define SPI_MODE_0 (0 | 0) -#define SPI_MODE_1 (0 | SPI_CPHA) -#define SPI_MODE_2 (SPI_CPOL | 0) -#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA) - -/// SPI controller -typedef struct SPIController -{ - /// The serial clock pin - GPIOPin sckPin; - /// The master out/slave in pin - GPIOPin mosiPin; - /// The master in/slave out pin - GPIOPin misoPin; -} SPIController; - -/// SPI device -typedef struct SPIDevice -{ - // These two members should be filled in the struct by hand - /// The GPIO pin used for chip select - GPIOPin csPin; - /// The SPI controller this device belongs to - SPIController *controller; - - // Everything below here is private - SPIDevicePrivate private; -} SPIDevice; - -SPIController *SPI_Controller(uint8_t index); -void SPI_InitController(SPIController *c); -bool SPI_InitDevice(SPIDevice *spi, uint32_t maxClock, uint8_t mode); -void SPI_RequestBus(SPIDevice *spi); -void SPI_ReleaseBus(SPIDevice *spi); -void SPI_Assert(SPIDevice *spi); -void SPI_Deassert(SPIDevice *spi); -uint8_t SPI_RWByte(SPIDevice *spi, uint8_t b); - -#endif /* HAL_SPI_H_ */ +/* + * spi.h + * + * Created on: Nov 14, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_SPI_H_ +#define HAL_SPI_H_ + +#include "gpio.h" +#include "spi_private.h" + +/// CPHA bit in the SPI mode parameter of SPI_InitDevice +#define SPI_CPHA (1 << 0) +/// CPOL bit in the SPI mode parameter of SPI_InitDevice +#define SPI_CPOL (1 << 1) + +/// Friendly names for modes 0-3 when dealing with CPHA/CPOL in SPI_InitDevice +#define SPI_MODE_0 (0 | 0) +#define SPI_MODE_1 (0 | SPI_CPHA) +#define SPI_MODE_2 (SPI_CPOL | 0) +#define SPI_MODE_3 (SPI_CPOL | SPI_CPHA) + +/// SPI controller +typedef struct SPIController +{ + /// The serial clock pin + GPIOPin sckPin; + /// The master out/slave in pin + GPIOPin mosiPin; + /// The master in/slave out pin + GPIOPin misoPin; +} SPIController; + +/// SPI device +typedef struct SPIDevice +{ + // These two members should be filled in the struct by hand + /// The GPIO pin used for chip select + GPIOPin csPin; + /// The SPI controller this device belongs to + SPIController *controller; + + // Everything below here is private + SPIDevicePrivate private; +} SPIDevice; + +SPIController *SPI_Controller(uint8_t index); +void SPI_InitController(SPIController *c); +bool SPI_InitDevice(SPIDevice *spi, uint32_t maxClock, uint8_t mode); +void SPI_RequestBus(SPIDevice *spi); +void SPI_ReleaseBus(SPIDevice *spi); +void SPI_Assert(SPIDevice *spi); +void SPI_Deassert(SPIDevice *spi); +uint8_t SPI_RWByte(SPIDevice *spi, uint8_t b); + +#endif /* HAL_SPI_H_ */ diff --git a/hal/usbcdc.h b/hal/usbcdc.h index 5af0e36..9c96a7d 100644 --- a/hal/usbcdc.h +++ b/hal/usbcdc.h @@ -1,42 +1,42 @@ -/* - * usbcdc.h - * - * Created on: Nov 22, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef HAL_USBCDC_H_ -#define HAL_USBCDC_H_ - -#include -#include "usbcdc_hw.h" - -// Note: Functions commented out should be implemented as static inline -// functions in the board-specific header file for efficiency. -void USBCDC_Init(void); -void USBCDC_Disable(void); -void USBCDC_Check(void); -//void USBCDC_SendByte(uint8_t byte); -//bool USBCDC_SendData(uint8_t const *data, uint16_t len); -//int16_t USBCDC_ReadByte(void); -//uint8_t USBCDC_ReadByteBlocking(void); -//void USBCDC_Flush(void) - -#endif /* HAL_USBCDC_H_ */ +/* + * usbcdc.h + * + * Created on: Nov 22, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef HAL_USBCDC_H_ +#define HAL_USBCDC_H_ + +#include +#include "usbcdc_hw.h" + +// Note: Functions commented out should be implemented as static inline +// functions in the board-specific header file for efficiency. +void USBCDC_Init(void); +void USBCDC_Disable(void); +void USBCDC_Check(void); +//void USBCDC_SendByte(uint8_t byte); +//bool USBCDC_SendData(uint8_t const *data, uint16_t len); +//int16_t USBCDC_ReadByte(void); +//uint8_t USBCDC_ReadByteBlocking(void); +//void USBCDC_Flush(void) + +#endif /* HAL_USBCDC_H_ */ diff --git a/led.h b/led.h index 61225ca..0720f6d 100644 --- a/led.h +++ b/led.h @@ -1,65 +1,65 @@ -/* - * led.h - * - * Created on: May 27, 2012 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef LED_H_ -#define LED_H_ - -#include "hal/board.h" -#include "hal/gpio.h" - -/** Initializes the LED and turns it off - * - */ -static inline void LED_Init(void) -{ - GPIOPin ledPin = Board_LEDPin(); - GPIO_SetDirection(ledPin, true); - GPIO_SetOff(ledPin); -} - -/** Turns the LED on - * - */ -static inline void LED_On(void) -{ - GPIO_SetOn(Board_LEDPin()); -} - -/** Turns the LED off - * - */ -static inline void LED_Off(void) -{ - GPIO_SetOff(Board_LEDPin()); -} - -/** Toggles the LED - * - */ -static inline void LED_Toggle(void) -{ - GPIO_Toggle(Board_LEDPin()); -} - -#endif /* LED_H_ */ +/* + * led.h + * + * Created on: May 27, 2012 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef LED_H_ +#define LED_H_ + +#include "hal/board.h" +#include "hal/gpio.h" + +/** Initializes the LED and turns it off + * + */ +static inline void LED_Init(void) +{ + GPIOPin ledPin = Board_LEDPin(); + GPIO_SetDirection(ledPin, true); + GPIO_SetOff(ledPin); +} + +/** Turns the LED on + * + */ +static inline void LED_On(void) +{ + GPIO_SetOn(Board_LEDPin()); +} + +/** Turns the LED off + * + */ +static inline void LED_Off(void) +{ + GPIO_SetOff(Board_LEDPin()); +} + +/** Toggles the LED + * + */ +static inline void LED_Toggle(void) +{ + GPIO_Toggle(Board_LEDPin()); +} + +#endif /* LED_H_ */ diff --git a/main.c b/main.c index dc85acc..751c7c5 100644 --- a/main.c +++ b/main.c @@ -1,71 +1,71 @@ -/* - * main.c - * - * Created on: Nov 25, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * ----------------------------------------------------------------------------- - * - * TODO: Add smarter short detection? Automatically run an electrical test at - * startup and leave everything in input mode if shorts are detected? - * I'm especially thinking about the case of SIMM control pins shorted - * together, like CS and OE, which will default to opposite output values. - * Is this even worth implementing? It's probably only useful when testing - * newly-built SIMMs. We would need to implement a protocol for this so - * the programmer software can be alerted that a short was detected. - */ - -#include "hal/board.h" -#include "hardware.h" -#include "hal/parallel_bus.h" -#include "tests/simm_electrical_test.h" -#include "simm_programmer.h" -#include "led.h" - -/** Main function - * - * @return Never; the main loop is an infinite loop. - */ -int main(void) -{ - DisableInterrupts(); - Board_Init(); - LED_Init(); - - // If there was a brownout detected, turn on the LED momentarily - if (Board_BrownoutDetected()) - { - LED_On(); - DelayMS(500); - LED_Off(); - } - - // Initialize everything and turn on interrupts - ParallelBus_Init(); - SIMMProgrammer_Init(); - EnableInterrupts(); - - // Main loop - while (1) - { - SIMMProgrammer_Check(); - } - - return 0; -} +/* + * main.c + * + * Created on: Nov 25, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ----------------------------------------------------------------------------- + * + * TODO: Add smarter short detection? Automatically run an electrical test at + * startup and leave everything in input mode if shorts are detected? + * I'm especially thinking about the case of SIMM control pins shorted + * together, like CS and OE, which will default to opposite output values. + * Is this even worth implementing? It's probably only useful when testing + * newly-built SIMMs. We would need to implement a protocol for this so + * the programmer software can be alerted that a short was detected. + */ + +#include "hal/board.h" +#include "hardware.h" +#include "hal/parallel_bus.h" +#include "tests/simm_electrical_test.h" +#include "simm_programmer.h" +#include "led.h" + +/** Main function + * + * @return Never; the main loop is an infinite loop. + */ +int main(void) +{ + DisableInterrupts(); + Board_Init(); + LED_Init(); + + // If there was a brownout detected, turn on the LED momentarily + if (Board_BrownoutDetected()) + { + LED_On(); + DelayMS(500); + LED_Off(); + } + + // Initialize everything and turn on interrupts + ParallelBus_Init(); + SIMMProgrammer_Init(); + EnableInterrupts(); + + // Main loop + while (1) + { + SIMMProgrammer_Check(); + } + + return 0; +} diff --git a/programmer_protocol.h b/programmer_protocol.h index f507161..4ccdc6d 100644 --- a/programmer_protocol.h +++ b/programmer_protocol.h @@ -1,188 +1,188 @@ -/* - * programmer_protocol.h - * - * Created on: Dec 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef PROGRAMMER_PROTOCOL_H_ -#define PROGRAMMER_PROTOCOL_H_ - -/// When the programmer is in "waiting for command" mode, -/// you send it one of the bytes below to do something (or begin to do something) -typedef enum ProgrammerCommand -{ - EnterWaitingMode = 0, - DoElectricalTest, - IdentifyChips, - ReadByte, - ReadChips, - EraseChips, - WriteChips, - GetBootloaderState, - EnterBootloader, - EnterProgrammer, - BootloaderEraseAndWriteProgram, - SetSIMMTypePLCC32_2MB, - SetSIMMTypeLarger, - SetVerifyWhileWriting, - SetNoVerifyWhileWriting, - ErasePortion, - WriteChipsAt, - ReadChipsAt, - SetChipsMask -} ProgrammerCommand; - -// After a command is sent, the programmer will always respond with -// one of the replies below. (Depending on the command, it may reply with other -// stuff after that, too) -typedef enum ProgrammerReply -{ - CommandReplyOK = 0, - CommandReplyError, - CommandReplyInvalid -} ProgrammerReply; - -// ------------------------- ELECTRICAL TEST PROTOCOL ------------------------- -// After CommandReplyOK, any failures are reported by the programmer. -// It will send ProgrammerElectricalTestFail followed by two more bytes -- each -// representing an index of the failure location. Any more electrical test failures -// will result in another 3-byte sequence as described above. -// When it's totally finished, it will send ProgrammerElectricalTestDone. -// So a pass would be indicated by no ProgrammerElectricalTestFail sequences being -// sent. -typedef enum ProgrammerElectricalTestReply -{ - ProgrammerElectricalTestFail = 0, - ProgrammerElectricalTestDone -} ProgrammerElectricalTestReply; - -// ------------------------- IDENTIFY CHIPS PROTOCOL ------------------------- -// After CommandReplyOK, it will send the manufacturer ID and device ID of each -// of the 4 chips: -// M1, D1, M2, D2, M3, D3, M4, D4 -// followed by ProgrammerIdentifyDone. -typedef enum ProgrammerIdentifyReply -{ - ProgrammerIdentifyDone = 0 -} ProgrammerIdentifyReply; - -// ------------------------- READ PROTOCOL ------------------------- -// After CommandReplyOK, the requester will send a 4-byte value containing -// the number of bytes requested to read (should be a multiple of the read -// chunk size of 1024 bytes, though). The programmer will reply with OK or -// error, and if OK, also send a chunk of data. -// The computer will send a reply (see the enum below this one) -// The programmer will then reply to *that* reply (see this enum) -typedef enum ProgrammerReadReply -{ - ProgrammerReadOK = 0, - ProgrammerReadError, - ProgrammerReadMoreData, - ProgrammerReadFinished, - ProgrammerReadConfirmCancel -} ProgrammerReadReply; - -// When the computer is confirming reception of a block of data from the device, -// it should reply with either OK that it received the data OK, or cancel -// to tell the device that the user canceled the read. -typedef enum ComputerReadReply -{ - ComputerReadOK = 0, - ComputerReadCancel -} ComputerReadReply; - -// ------------------------- ERASE PROTOCOL ------------------------- -// There is none -- a reply of CommandReplyOK will indicate that the erase -// completed successfully. - -// ------------------------- WRITE PROTOCOL ------------------------- -// After CommandReplyOK, the computer should send one of the commands below. -// The programmer will reply with one of the replies seen in the enum below -// this one, and then the computer can send a 1024-byte chunk of data. -// The programmer will reply with ProgrammerWriteOK, and then the cycle can -// continue (the computer sends another request in this enum) -// -// If the programmer was asked to verify while writing and a verification error -// occurs, it will respond with ProgrammerWriteVerificationError ORed with a bit -// mask of chips that are acting up (so it could be 0x81 if IC1 is acting up, -// for example) -typedef enum ComputerWriteRequest -{ - ComputerWriteMore = 0, - ComputerWriteFinish, - ComputerWriteCancel -} ComputerWriteRequest; - -typedef enum ProgrammerWriteReply -{ - ProgrammerWriteOK = 0, - ProgrammerWriteError, - ProgrammerWriteConfirmCancel, - ProgrammerWriteVerificationError = 0x80 /* high bit signifies verify error, low bits signify which chips are bad */ -} ProgrammerWriteReply; - -// ------------------------- BOOTLOADER STATE PROTOCOL ------------------------- -// If the command is GetBootloaderState, it will reply with CommandReplyOK followed -// by one of the two replies below to tell the control program which mode -// the device is currently in. -typedef enum BootloaderStateReply -{ - BootloaderStateInBootloader = 0, - BootloaderStateInProgrammer -} BootloaderStateReply; - -// ------------------------- BOOTLOADER ERASE/WRITE PROTOCOL ------------------------- -// If the command is BootloaderEraseAndWriteProgram, it will reply with CommandReplyOK -// followed by either BootloaderEraseOK or BootloaderEraseError. At this point -// the program can ask to write more data or finish or cancel, and then the appropriate -// reply will be sent back to it. Works very similar to the write protocol. -typedef enum ProgrammerBootloaderEraseWriteReply -{ - BootloaderWriteOK, - BootloaderWriteError, - BootloaderWriteConfirmCancel -} ProgrammerBootloaderEraseWriteReply; - -typedef enum ComputerBootloaderEraseWriteRequest -{ - ComputerBootloaderWriteMore = 0, - ComputerBootloaderFinish, - ComputerBootloaderCancel -} ComputerBootloaderEraseWriteRequest; - -// ------------------------- ERASE PORTION OF CHIP PROTOCOL ------------------------- -// If the command is ErasePortion, the programmer will reply CommandReplyOK. -// Next, the program will send the beginning position to erase as a 4-byte little -// endian integer, followed by the length to erase as a 4-byte little endian -// integer. The programmer will reply with ProgrammerErasePortionOK to signify -// that the erase is beginning, followed by ProgrammerErasePortionFinished when -// everything is done. -// The length and position to erase must be on 256 KB boundaries and shouldn't -// go past the end of the selected type of chip. If any error occurs, it will -// reply with ProgrammerErasePortionError instead. -typedef enum ProgrammerErasePortionOfChipReply -{ - ProgrammerErasePortionOK = 0, - ProgrammerErasePortionError, +/* + * programmer_protocol.h + * + * Created on: Dec 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef PROGRAMMER_PROTOCOL_H_ +#define PROGRAMMER_PROTOCOL_H_ + +/// When the programmer is in "waiting for command" mode, +/// you send it one of the bytes below to do something (or begin to do something) +typedef enum ProgrammerCommand +{ + EnterWaitingMode = 0, + DoElectricalTest, + IdentifyChips, + ReadByte, + ReadChips, + EraseChips, + WriteChips, + GetBootloaderState, + EnterBootloader, + EnterProgrammer, + BootloaderEraseAndWriteProgram, + SetSIMMTypePLCC32_2MB, + SetSIMMTypeLarger, + SetVerifyWhileWriting, + SetNoVerifyWhileWriting, + ErasePortion, + WriteChipsAt, + ReadChipsAt, + SetChipsMask +} ProgrammerCommand; + +// After a command is sent, the programmer will always respond with +// one of the replies below. (Depending on the command, it may reply with other +// stuff after that, too) +typedef enum ProgrammerReply +{ + CommandReplyOK = 0, + CommandReplyError, + CommandReplyInvalid +} ProgrammerReply; + +// ------------------------- ELECTRICAL TEST PROTOCOL ------------------------- +// After CommandReplyOK, any failures are reported by the programmer. +// It will send ProgrammerElectricalTestFail followed by two more bytes -- each +// representing an index of the failure location. Any more electrical test failures +// will result in another 3-byte sequence as described above. +// When it's totally finished, it will send ProgrammerElectricalTestDone. +// So a pass would be indicated by no ProgrammerElectricalTestFail sequences being +// sent. +typedef enum ProgrammerElectricalTestReply +{ + ProgrammerElectricalTestFail = 0, + ProgrammerElectricalTestDone +} ProgrammerElectricalTestReply; + +// ------------------------- IDENTIFY CHIPS PROTOCOL ------------------------- +// After CommandReplyOK, it will send the manufacturer ID and device ID of each +// of the 4 chips: +// M1, D1, M2, D2, M3, D3, M4, D4 +// followed by ProgrammerIdentifyDone. +typedef enum ProgrammerIdentifyReply +{ + ProgrammerIdentifyDone = 0 +} ProgrammerIdentifyReply; + +// ------------------------- READ PROTOCOL ------------------------- +// After CommandReplyOK, the requester will send a 4-byte value containing +// the number of bytes requested to read (should be a multiple of the read +// chunk size of 1024 bytes, though). The programmer will reply with OK or +// error, and if OK, also send a chunk of data. +// The computer will send a reply (see the enum below this one) +// The programmer will then reply to *that* reply (see this enum) +typedef enum ProgrammerReadReply +{ + ProgrammerReadOK = 0, + ProgrammerReadError, + ProgrammerReadMoreData, + ProgrammerReadFinished, + ProgrammerReadConfirmCancel +} ProgrammerReadReply; + +// When the computer is confirming reception of a block of data from the device, +// it should reply with either OK that it received the data OK, or cancel +// to tell the device that the user canceled the read. +typedef enum ComputerReadReply +{ + ComputerReadOK = 0, + ComputerReadCancel +} ComputerReadReply; + +// ------------------------- ERASE PROTOCOL ------------------------- +// There is none -- a reply of CommandReplyOK will indicate that the erase +// completed successfully. + +// ------------------------- WRITE PROTOCOL ------------------------- +// After CommandReplyOK, the computer should send one of the commands below. +// The programmer will reply with one of the replies seen in the enum below +// this one, and then the computer can send a 1024-byte chunk of data. +// The programmer will reply with ProgrammerWriteOK, and then the cycle can +// continue (the computer sends another request in this enum) +// +// If the programmer was asked to verify while writing and a verification error +// occurs, it will respond with ProgrammerWriteVerificationError ORed with a bit +// mask of chips that are acting up (so it could be 0x81 if IC1 is acting up, +// for example) +typedef enum ComputerWriteRequest +{ + ComputerWriteMore = 0, + ComputerWriteFinish, + ComputerWriteCancel +} ComputerWriteRequest; + +typedef enum ProgrammerWriteReply +{ + ProgrammerWriteOK = 0, + ProgrammerWriteError, + ProgrammerWriteConfirmCancel, + ProgrammerWriteVerificationError = 0x80 /* high bit signifies verify error, low bits signify which chips are bad */ +} ProgrammerWriteReply; + +// ------------------------- BOOTLOADER STATE PROTOCOL ------------------------- +// If the command is GetBootloaderState, it will reply with CommandReplyOK followed +// by one of the two replies below to tell the control program which mode +// the device is currently in. +typedef enum BootloaderStateReply +{ + BootloaderStateInBootloader = 0, + BootloaderStateInProgrammer +} BootloaderStateReply; + +// ------------------------- BOOTLOADER ERASE/WRITE PROTOCOL ------------------------- +// If the command is BootloaderEraseAndWriteProgram, it will reply with CommandReplyOK +// followed by either BootloaderEraseOK or BootloaderEraseError. At this point +// the program can ask to write more data or finish or cancel, and then the appropriate +// reply will be sent back to it. Works very similar to the write protocol. +typedef enum ProgrammerBootloaderEraseWriteReply +{ + BootloaderWriteOK, + BootloaderWriteError, + BootloaderWriteConfirmCancel +} ProgrammerBootloaderEraseWriteReply; + +typedef enum ComputerBootloaderEraseWriteRequest +{ + ComputerBootloaderWriteMore = 0, + ComputerBootloaderFinish, + ComputerBootloaderCancel +} ComputerBootloaderEraseWriteRequest; + +// ------------------------- ERASE PORTION OF CHIP PROTOCOL ------------------------- +// If the command is ErasePortion, the programmer will reply CommandReplyOK. +// Next, the program will send the beginning position to erase as a 4-byte little +// endian integer, followed by the length to erase as a 4-byte little endian +// integer. The programmer will reply with ProgrammerErasePortionOK to signify +// that the erase is beginning, followed by ProgrammerErasePortionFinished when +// everything is done. +// The length and position to erase must be on 256 KB boundaries and shouldn't +// go past the end of the selected type of chip. If any error occurs, it will +// reply with ProgrammerErasePortionError instead. +typedef enum ProgrammerErasePortionOfChipReply +{ + ProgrammerErasePortionOK = 0, + ProgrammerErasePortionError, ProgrammerErasePortionFinished } ProgrammerErasePortionOfChipReply; - -#endif /* PROGRAMMER_PROTOCOL_H_ */ + +#endif /* PROGRAMMER_PROTOCOL_H_ */ diff --git a/simm_programmer.c b/simm_programmer.c index 1738d78..06600af 100644 --- a/simm_programmer.c +++ b/simm_programmer.c @@ -1,663 +1,663 @@ -/* - * simm_programmer.c - * - * Created on: Dec 9, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "simm_programmer.h" -#include "hal/usbcdc.h" -#include "drivers/parallel_flash.h" -#include "tests/simm_electrical_test.h" -#include "programmer_protocol.h" -#include "led.h" -#include "hardware.h" -#include - -/// Maximum size of an individual chip on a SIMM we read -#define MAX_CHIP_SIZE (2UL * 1024UL * 1024UL) -/// Number of bytes we read/write at once -#define READ_WRITE_CHUNK_SIZE_BYTES 1024UL -/// Make sure the chunk size is a multiple of 4 bytes, since there are 4 chips -#if ((READ_WRITE_CHUNK_SIZE_BYTES % 4) != 0) -#error Read/write chunk size should be a multiple of 4 bytes -#endif -/// The smallest granularity for sector erase that we support -#define ERASE_SECTOR_SIZE_BYTES (256UL * 1024UL) - -/// Internal state so we know how to interpret the next-received byte -typedef enum ProgrammerCommandState -{ - WaitingForCommand = 0, //!< No active commands - ReadingChipsReadLength, //!< Reading the length for reading data from the SIMM - ReadingChips, //!< Reading data from the SIMM - WritingChips, //!< Writing data to the SIMM - ErasePortionReadingPosLength,//!< Reading the length of SIMM data to erase - ReadingChipsReadStartPos, //!< Reading the start position for reading data from the SIMM - WritingChipsReadingStartPos, //!< Reading the start position for writing data to the SIMM - ReadingChipsMask, //!< Reading the bitmask of which chips should be programmed -} ProgrammerCommandState; -static ProgrammerCommandState curCommandState = WaitingForCommand; - -// State info for reading/writing -static uint16_t curReadIndex; -static uint32_t readLength; -static uint8_t readLengthByteIndex; -static int16_t writePosInChunk = -1; -static uint16_t curWriteIndex = 0; -static bool verifyDuringWrite = false; -static uint32_t erasePosition; -static uint32_t eraseLength; -static uint8_t chipsMask = ALL_CHIPS; - -/// Buffers we use to store incoming/outgoing data. -static union -{ - uint32_t words[READ_WRITE_CHUNK_SIZE_BYTES / PARALLEL_FLASH_NUM_CHIPS]; - uint8_t bytes[READ_WRITE_CHUNK_SIZE_BYTES]; -} writeChunks, readChunks; - -// Private functions -static void SIMMProgrammer_HandleWaitingForCommandByte(uint8_t byte); -static void SIMMProgrammer_HandleReadingChipsByte(uint8_t byte); -static void SIMMProgrammer_HandleReadingChipsReadLengthByte(uint8_t byte); -static void SIMMProgrammer_SendReadDataChunk(void); -static void SIMMProgrammer_HandleWritingChipsByte(uint8_t byte); -static void SIMMProgrammer_ElectricalTest_Fail_Handler(uint8_t index1, uint8_t index2); -static void SIMMProgrammer_HandleErasePortionReadPosLengthByte(uint8_t byte); -static void SIMMProgrammer_HandleReadingChipsReadStartPosByte(uint8_t byte); -static void SIMMProgrammer_HandleWritingChipsReadingStartPosByte(uint8_t byte); -static void SIMMProgrammer_HandleReadingChipsMaskByte(uint8_t byte); - -/** Initializes the SIMM programmer and prepares it for USB communication. - * - */ -void SIMMProgrammer_Init(void) -{ - USBCDC_Init(); -} - -/** Allows the SIMM programmer to do its thing. Main loop handler. - * - * Call this function during every main loop iteration. - */ -void SIMMProgrammer_Check(void) -{ - // Read as many bytes as we can and process them - int16_t result; - while ((result = USBCDC_ReadByte()) >= 0) - { - uint8_t recvByte = (uint8_t)result; - - // Hand it off to the correct handler function based on the current state - switch (curCommandState) - { - case WaitingForCommand: - SIMMProgrammer_HandleWaitingForCommandByte(recvByte); - break; - case ReadingChipsReadLength: - SIMMProgrammer_HandleReadingChipsReadLengthByte(recvByte); - break; - case ReadingChips: - SIMMProgrammer_HandleReadingChipsByte(recvByte); - break; - case WritingChips: - SIMMProgrammer_HandleWritingChipsByte(recvByte); - break; - case ErasePortionReadingPosLength: - SIMMProgrammer_HandleErasePortionReadPosLengthByte(recvByte); - break; - case ReadingChipsReadStartPos: - SIMMProgrammer_HandleReadingChipsReadStartPosByte(recvByte); - break; - case WritingChipsReadingStartPos: - SIMMProgrammer_HandleWritingChipsReadingStartPosByte(recvByte); - break; - case ReadingChipsMask: - SIMMProgrammer_HandleReadingChipsMaskByte(recvByte); - break; - } - } - - // And do any periodic USB CDC tasks - USBCDC_Check(); -} - -/** Handles a received byte when we are waiting for a command - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleWaitingForCommandByte(uint8_t byte) -{ - switch (byte) - { - // Asked to enter waiting mode -- we're already there, so say OK. - case EnterWaitingMode: - USBCDC_SendByte(CommandReplyOK); - curCommandState = WaitingForCommand; - break; - // Asked to do the electrical test. Reply OK, and then do the test, - // sending whatever replies necessary - case DoElectricalTest: - USBCDC_SendByte(CommandReplyOK); - // Flush out the initial "OK" reply immediately in this case so the - // caller gets immediate feedback that the test has started - USBCDC_Flush(); - SIMMElectricalTest_Run(SIMMProgrammer_ElectricalTest_Fail_Handler); - USBCDC_SendByte(ProgrammerElectricalTestDone); - curCommandState = WaitingForCommand; - break; - // Asked to identify the chips in the SIMM. Identify them and send reply. - case IdentifyChips: - { - struct ParallelFlashChipID chips[PARALLEL_FLASH_NUM_CHIPS]; - USBCDC_SendByte(CommandReplyOK); - ParallelFlash_IdentifyChips(chips); - for (int i = 0; i < PARALLEL_FLASH_NUM_CHIPS; i++) - { - USBCDC_SendByte(chips[i].manufacturer); - USBCDC_SendByte(chips[i].device); - } - USBCDC_SendByte(ProgrammerIdentifyDone); - break; - } - // Asked to read a single byte from each SIMM. Change the state and reply. - case ReadByte: - USBCDC_SendByte(CommandReplyInvalid); // not implemented yet - break; - // Asked to read all four chips. Set the state, reply with the first chunk. - // This will read from the BEGINNING of the SIMM every time. Use - // ReadChipsAt to specify a start position - case ReadChips: - curCommandState = ReadingChipsReadLength; - curReadIndex = 0; - readLengthByteIndex = 0; - readLength = 0; - USBCDC_SendByte(CommandReplyOK); - break; - case ReadChipsAt: - curCommandState = ReadingChipsReadStartPos; - curReadIndex = 0; - readLengthByteIndex = 0; - readLength = 0; - USBCDC_SendByte(CommandReplyOK); - break; - // Erase the chips and reply OK. (TODO: Sometimes erase might fail) - case EraseChips: - ParallelFlash_EraseChips(chipsMask); - USBCDC_SendByte(CommandReplyOK); - break; - // Begin writing the chips. Change the state, reply, wait for chunk of data - case WriteChips: - curCommandState = WritingChips; - curWriteIndex = 0; - writePosInChunk = -1; - USBCDC_SendByte(CommandReplyOK); - break; - case WriteChipsAt: - curCommandState = WritingChipsReadingStartPos; - curWriteIndex = 0; - readLengthByteIndex = 0; - writePosInChunk = -1; - USBCDC_SendByte(CommandReplyOK); - break; - // Asked for the current bootloader state. We are in the program right now, - // so reply accordingly. - case GetBootloaderState: - USBCDC_SendByte(CommandReplyOK); - USBCDC_SendByte(BootloaderStateInProgrammer); - break; - // Enter the bootloader. Wait a bit, then jump to the bootloader location. - case EnterBootloader: - USBCDC_SendByte(CommandReplyOK); - // Force this to be sent immediately so the programmer software knows. - USBCDC_Flush(); - - // Insert a small delay to ensure that it arrives before rebooting. - DelayMS(1000); - - // Done with the USB interface -- the bootloader will re-initialize it. - USBCDC_Disable(); - - // Disable interrupts so nothing weird happens... - cli(); - - // Wait a little bit to let everything settle and let the program - // close the port after the USB disconnect - DelayMS(2000); - - // And, of course, go into the bootloader. - __asm__ __volatile__ ( "jmp 0xE000" ); - break; - // Enter the programmer. We're already there, so reply OK. - case EnterProgrammer: - // Already in the programmer - USBCDC_SendByte(CommandReplyOK); - break; - // Set the SIMM type to the older, smaller chip size (2MB and below) - case SetSIMMTypePLCC32_2MB: - ParallelFlash_SetChipType(ParallelFlash_SST39SF040_x4); - USBCDC_SendByte(CommandReplyOK); - break; - case SetSIMMTypeLarger: - ParallelFlash_SetChipType(ParallelFlash_M29F160FB5AN6E2_x4); - USBCDC_SendByte(CommandReplyOK); - break; - case SetVerifyWhileWriting: - verifyDuringWrite = true; - USBCDC_SendByte(CommandReplyOK); - break; - case SetNoVerifyWhileWriting: - verifyDuringWrite = false; - USBCDC_SendByte(CommandReplyOK); - break; - case ErasePortion: - readLengthByteIndex = 0; - eraseLength = 0; - erasePosition = 0; - curCommandState = ErasePortionReadingPosLength; - USBCDC_SendByte(CommandReplyOK); - break; - case SetChipsMask: - curCommandState = ReadingChipsMask; - USBCDC_SendByte(CommandReplyOK); - break; - // We don't know what this command is, so reply that it was invalid. - default: - USBCDC_SendByte(CommandReplyInvalid); - break; - } -} - -/** Handles a received byte when we are reading from chips - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleReadingChipsByte(uint8_t byte) -{ - // The byte should be a reply from the computer. It should be either: - // 1) ComputerReadOK -- meaning it got the chunk we just sent - // or - // 2) ComputerReadCancel -- meaning the user canceled the read - switch (byte) - { - case ComputerReadOK: - // If they have confirmed the final data chunk, let them know - // that they have finished, and enter command state. - if (curReadIndex >= readLength) - { - LED_Off(); - USBCDC_SendByte(ProgrammerReadFinished); - curCommandState = WaitingForCommand; - } - else // There's more data left to read, so read it and send it to them! - { - LED_Toggle(); - USBCDC_SendByte(ProgrammerReadMoreData); - SIMMProgrammer_SendReadDataChunk(); - } - break; - case ComputerReadCancel: - // If they've canceled, let them know we got their request and go back - // to "waiting for command" state - USBCDC_SendByte(ProgrammerReadConfirmCancel); - curCommandState = WaitingForCommand; - break; - } -} - -/** Handles a received byte when we are reading the length of data requested to be read - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleReadingChipsReadLengthByte(uint8_t byte) -{ - // There will be four bytes, so count up until we know the length. If they - // have sent all four bytes, send the first read chunk. - readLength |= (((uint32_t)byte) << (8*readLengthByteIndex)); - if (++readLengthByteIndex >= 4) - { - // Ensure it's within limits and a multiple of 1024 - if ((curReadIndex + readLength > PARALLEL_FLASH_NUM_CHIPS * MAX_CHIP_SIZE) || - (readLength % READ_WRITE_CHUNK_SIZE_BYTES) || - (curReadIndex % READ_WRITE_CHUNK_SIZE_BYTES) || - (readLength == 0))// Ensure it's within limits and a multiple of 1024 - { - USBCDC_SendByte(ProgrammerReadError); - curCommandState = WaitingForCommand; - } - else - { - // Convert the length/pos into the number of chunks we need to send - readLength /= READ_WRITE_CHUNK_SIZE_BYTES; - curReadIndex /= READ_WRITE_CHUNK_SIZE_BYTES; - curCommandState = ReadingChips; - USBCDC_SendByte(ProgrammerReadOK); - SIMMProgrammer_SendReadDataChunk(); - } - } -} - -/** Reads a chunk of data from the SIMM and sends it over the USB CDC serial port. - * - */ -static void SIMMProgrammer_SendReadDataChunk(void) -{ - // Read the next chunk of data, send it over USB, and make sure - // we sent it correctly. - ParallelFlash_Read(curReadIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), - readChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS); - bool retVal = USBCDC_SendData(readChunks.bytes, READ_WRITE_CHUNK_SIZE_BYTES); - - // If for some reason there was an error, mark it as such. Otherwise, - // increment our pointer so we know the next chunk of data to send. - if (!retVal) - { - //curCommandState = ReadingChipsUnableSendError; // TODO: not implemented - curCommandState = WaitingForCommand; - } - else - { - curReadIndex++; - } -} - -/** Handles a received byte when we are in the "writing chips" state - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleWritingChipsByte(uint8_t byte) -{ - // This means we have just started the entire process or just finished - // a chunk, so see what the computer has decided for us to do. - if (writePosInChunk == -1) - { - switch (byte) - { - // The computer asked to write more data to the SIMM. - case ComputerWriteMore: - writePosInChunk = 0; - // Make sure we don't write past the capacity of the chips. - if (curWriteIndex < MAX_CHIP_SIZE / (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS)) - { - USBCDC_SendByte(ProgrammerWriteOK); - } - else - { - LED_Off(); - USBCDC_SendByte(ProgrammerWriteError); - curCommandState = WaitingForCommand; - } - break; - // The computer said that it's done writing. - case ComputerWriteFinish: - LED_Off(); - USBCDC_SendByte(ProgrammerWriteOK); - curCommandState = WaitingForCommand; - break; - // The computer asked to cancel. - case ComputerWriteCancel: - LED_Off(); - USBCDC_SendByte(ProgrammerWriteConfirmCancel); - curCommandState = WaitingForCommand; - break; - } - } - else // Interpret the incoming byte as data to write to the SIMM. - { - // Save the byte. Then, block until we receive the rest of the data. - writeChunks.bytes[writePosInChunk++] = byte; - while (writePosInChunk < READ_WRITE_CHUNK_SIZE_BYTES) - { - writeChunks.bytes[writePosInChunk++] = USBCDC_ReadByteBlocking(); - } - - // We filled up the chunk, write it out and confirm it, then wait - // for the next command from the computer! - if (chipsMask == ALL_CHIPS) - { - ParallelFlash_WriteAllChips(curWriteIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), - writeChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS); - } - else - { - ParallelFlash_WriteSomeChips(curWriteIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), - writeChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS, chipsMask); - } - - // Verify if we were asked to. - uint8_t badVerifyChipsMask = 0; - if (verifyDuringWrite) - { - // Read back a chunk - ParallelFlash_Read(curWriteIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), - readChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS); - - // Compare the readback to what we attempted to flash. - // Look at each chip - for (uint8_t chip = 0; chip < PARALLEL_FLASH_NUM_CHIPS; chip++) - { - uint16_t bytePos = chip; - uint8_t thisChipMask = 1 << chip; - // Loop over all bytes that are on this chip - for (uint16_t i = 0; i < READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS; i++) - { - if (writeChunks.bytes[bytePos] != readChunks.bytes[bytePos]) - { - badVerifyChipsMask |= thisChipMask; - } - bytePos += PARALLEL_FLASH_NUM_CHIPS; - } - } - - // Filter out chips we didn't care about - badVerifyChipsMask &= chipsMask; - } - - // Bail if verification failed - if (badVerifyChipsMask != 0) - { - // Verification failed. The mask we calculated is actually - // backwards. We need to reverse it when we transmit the IC - // status back to the programmer software. This is kind of silly - // but it's too late to update the protocol. - uint8_t actualBadMask = 0; - for (uint8_t i = 0; i < PARALLEL_FLASH_NUM_CHIPS; i++) - { - if (badVerifyChipsMask & (1 << i)) - { - actualBadMask |= 0x80; - } - actualBadMask >>= 1; - } - - // Uh oh -- verification failure. - LED_Off(); - // Send the fail bit along with a mask of failed chips. - USBCDC_SendByte(ProgrammerWriteVerificationError | badVerifyChipsMask); - curCommandState = WaitingForCommand; - } - else - { - USBCDC_SendByte(ProgrammerWriteOK); - curWriteIndex++; - writePosInChunk = -1; - LED_Toggle(); - } - } -} - -/** Handler called during an electrical test when a short is detected - * - * @param index1 The index of the first shorted pin - * @param index2 The index of the second shorted pin - * - * The two pins at index1 and index2 have been detected as shorted together. - * The numbering is internal to the SIMM electrical test, and the programmer - * software knows how to interpret it. - */ -static void SIMMProgrammer_ElectricalTest_Fail_Handler(uint8_t index1, uint8_t index2) -{ - USBCDC_SendByte(ProgrammerElectricalTestFail); - USBCDC_SendByte(index1); - USBCDC_SendByte(index2); -} - -/** Handles a received byte when we are determining what part of the chip to erase - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleErasePortionReadPosLengthByte(uint8_t byte) -{ - // Read in the position and length to erase - if (readLengthByteIndex < 4) - { - erasePosition |= (((uint32_t)byte) << (8*readLengthByteIndex)); - } - else - { - eraseLength |= (((uint32_t)byte) << (8*(readLengthByteIndex - 4))); - } - - if (++readLengthByteIndex >= 8) - { - ParallelFlashChipType chipType = ParallelFlash_ChipType(); - bool eraseSuccess = false; - - // Ensure they are both within limits of sector size erasure - if (((erasePosition % ERASE_SECTOR_SIZE_BYTES) == 0) && - ((eraseLength % ERASE_SECTOR_SIZE_BYTES) == 0)) - { - uint32_t boundary = eraseLength + erasePosition; - - // Ensure they are within the limits of the chip size too - if (chipType == ParallelFlash_SST39SF040_x4) - { - if (boundary <= (2 * 1024UL * 1024UL)) - { - // OK! We're erasing certain sectors of a 2 MB SIMM. - USBCDC_SendByte(ProgrammerErasePortionOK); - // Send the response immediately, it could take a while. - USBCDC_Flush(); - if (ParallelFlash_EraseSectors(erasePosition/PARALLEL_FLASH_NUM_CHIPS, - eraseLength/PARALLEL_FLASH_NUM_CHIPS, chipsMask)) - { - eraseSuccess = true; - } - } - } - else if (chipType == ParallelFlash_M29F160FB5AN6E2_x4) - { - if (boundary <= (8 * 1024UL * 1024UL)) - { - // OK! We're erasing certain sectors of an 8 MB SIMM. - USBCDC_SendByte(ProgrammerErasePortionOK); - // Send the response immediately, it could take a while. - USBCDC_Flush(); - if (ParallelFlash_EraseSectors(erasePosition/PARALLEL_FLASH_NUM_CHIPS, - eraseLength/PARALLEL_FLASH_NUM_CHIPS, chipsMask)) - { - eraseSuccess = true; - } - } - } - } - - if (eraseSuccess) - { - // Not on a sector boundary for erase position and/or length - USBCDC_SendByte(ProgrammerErasePortionFinished); - curCommandState = WaitingForCommand; - } - else - { - // Not on a sector boundary for erase position and/or length - USBCDC_SendByte(ProgrammerErasePortionError); - curCommandState = WaitingForCommand; - } - } -} - -/** Handles a received byte when we are determining where to start reading from the SIMM - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleReadingChipsReadStartPosByte(uint8_t byte) -{ - // There will be four bytes, so count up until we know the position. If they - // have sent all four bytes, then start reading the length - curReadIndex |= (((uint32_t)byte) << (8*readLengthByteIndex)); - if (++readLengthByteIndex >= 4) - { - readLengthByteIndex = 0; - curCommandState = ReadingChipsReadLength; - } -} - -/** Handles a received byte when we are determining where to start writing to the SIMM - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleWritingChipsReadingStartPosByte(uint8_t byte) -{ - // There will be four bytes, so count up until we know the position. If they - // have sent all four bytes, then confirm the write and begin - curWriteIndex |= (((uint32_t)byte) << (8*readLengthByteIndex)); - if (++readLengthByteIndex >= 4) - { - // Got it...now, is it valid? If so, allow the write to begin - if ((curWriteIndex % READ_WRITE_CHUNK_SIZE_BYTES) || - (curWriteIndex >= PARALLEL_FLASH_NUM_CHIPS * MAX_CHIP_SIZE)) - { - USBCDC_SendByte(ProgrammerWriteError); - curCommandState = WaitingForCommand; - } - else - { - // Convert write size into an index appropriate for rest of code - curWriteIndex /= READ_WRITE_CHUNK_SIZE_BYTES; - USBCDC_SendByte(ProgrammerWriteOK); - curCommandState = WritingChips; - } - } -} - -/** Handles a received byte when we are determining the mask of which chips to write to - * - * @param byte The received byte - */ -static void SIMMProgrammer_HandleReadingChipsMaskByte(uint8_t byte) -{ - // Single byte follows containing mask of chips we're programming - if (byte <= 0x0F) - { - // Mask has to be less than or equal to 0x0F because there are only - // four valid mask bits. - chipsMask = byte; - USBCDC_SendByte(CommandReplyOK); - } - else - { - USBCDC_SendByte(CommandReplyError); - } - - // Done either way; now we're waiting for a command to arrive - curCommandState = WaitingForCommand; -} +/* + * simm_programmer.c + * + * Created on: Dec 9, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "simm_programmer.h" +#include "hal/usbcdc.h" +#include "drivers/parallel_flash.h" +#include "tests/simm_electrical_test.h" +#include "programmer_protocol.h" +#include "led.h" +#include "hardware.h" +#include + +/// Maximum size of an individual chip on a SIMM we read +#define MAX_CHIP_SIZE (2UL * 1024UL * 1024UL) +/// Number of bytes we read/write at once +#define READ_WRITE_CHUNK_SIZE_BYTES 1024UL +/// Make sure the chunk size is a multiple of 4 bytes, since there are 4 chips +#if ((READ_WRITE_CHUNK_SIZE_BYTES % 4) != 0) +#error Read/write chunk size should be a multiple of 4 bytes +#endif +/// The smallest granularity for sector erase that we support +#define ERASE_SECTOR_SIZE_BYTES (256UL * 1024UL) + +/// Internal state so we know how to interpret the next-received byte +typedef enum ProgrammerCommandState +{ + WaitingForCommand = 0, //!< No active commands + ReadingChipsReadLength, //!< Reading the length for reading data from the SIMM + ReadingChips, //!< Reading data from the SIMM + WritingChips, //!< Writing data to the SIMM + ErasePortionReadingPosLength,//!< Reading the length of SIMM data to erase + ReadingChipsReadStartPos, //!< Reading the start position for reading data from the SIMM + WritingChipsReadingStartPos, //!< Reading the start position for writing data to the SIMM + ReadingChipsMask, //!< Reading the bitmask of which chips should be programmed +} ProgrammerCommandState; +static ProgrammerCommandState curCommandState = WaitingForCommand; + +// State info for reading/writing +static uint16_t curReadIndex; +static uint32_t readLength; +static uint8_t readLengthByteIndex; +static int16_t writePosInChunk = -1; +static uint16_t curWriteIndex = 0; +static bool verifyDuringWrite = false; +static uint32_t erasePosition; +static uint32_t eraseLength; +static uint8_t chipsMask = ALL_CHIPS; + +/// Buffers we use to store incoming/outgoing data. +static union +{ + uint32_t words[READ_WRITE_CHUNK_SIZE_BYTES / PARALLEL_FLASH_NUM_CHIPS]; + uint8_t bytes[READ_WRITE_CHUNK_SIZE_BYTES]; +} writeChunks, readChunks; + +// Private functions +static void SIMMProgrammer_HandleWaitingForCommandByte(uint8_t byte); +static void SIMMProgrammer_HandleReadingChipsByte(uint8_t byte); +static void SIMMProgrammer_HandleReadingChipsReadLengthByte(uint8_t byte); +static void SIMMProgrammer_SendReadDataChunk(void); +static void SIMMProgrammer_HandleWritingChipsByte(uint8_t byte); +static void SIMMProgrammer_ElectricalTest_Fail_Handler(uint8_t index1, uint8_t index2); +static void SIMMProgrammer_HandleErasePortionReadPosLengthByte(uint8_t byte); +static void SIMMProgrammer_HandleReadingChipsReadStartPosByte(uint8_t byte); +static void SIMMProgrammer_HandleWritingChipsReadingStartPosByte(uint8_t byte); +static void SIMMProgrammer_HandleReadingChipsMaskByte(uint8_t byte); + +/** Initializes the SIMM programmer and prepares it for USB communication. + * + */ +void SIMMProgrammer_Init(void) +{ + USBCDC_Init(); +} + +/** Allows the SIMM programmer to do its thing. Main loop handler. + * + * Call this function during every main loop iteration. + */ +void SIMMProgrammer_Check(void) +{ + // Read as many bytes as we can and process them + int16_t result; + while ((result = USBCDC_ReadByte()) >= 0) + { + uint8_t recvByte = (uint8_t)result; + + // Hand it off to the correct handler function based on the current state + switch (curCommandState) + { + case WaitingForCommand: + SIMMProgrammer_HandleWaitingForCommandByte(recvByte); + break; + case ReadingChipsReadLength: + SIMMProgrammer_HandleReadingChipsReadLengthByte(recvByte); + break; + case ReadingChips: + SIMMProgrammer_HandleReadingChipsByte(recvByte); + break; + case WritingChips: + SIMMProgrammer_HandleWritingChipsByte(recvByte); + break; + case ErasePortionReadingPosLength: + SIMMProgrammer_HandleErasePortionReadPosLengthByte(recvByte); + break; + case ReadingChipsReadStartPos: + SIMMProgrammer_HandleReadingChipsReadStartPosByte(recvByte); + break; + case WritingChipsReadingStartPos: + SIMMProgrammer_HandleWritingChipsReadingStartPosByte(recvByte); + break; + case ReadingChipsMask: + SIMMProgrammer_HandleReadingChipsMaskByte(recvByte); + break; + } + } + + // And do any periodic USB CDC tasks + USBCDC_Check(); +} + +/** Handles a received byte when we are waiting for a command + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleWaitingForCommandByte(uint8_t byte) +{ + switch (byte) + { + // Asked to enter waiting mode -- we're already there, so say OK. + case EnterWaitingMode: + USBCDC_SendByte(CommandReplyOK); + curCommandState = WaitingForCommand; + break; + // Asked to do the electrical test. Reply OK, and then do the test, + // sending whatever replies necessary + case DoElectricalTest: + USBCDC_SendByte(CommandReplyOK); + // Flush out the initial "OK" reply immediately in this case so the + // caller gets immediate feedback that the test has started + USBCDC_Flush(); + SIMMElectricalTest_Run(SIMMProgrammer_ElectricalTest_Fail_Handler); + USBCDC_SendByte(ProgrammerElectricalTestDone); + curCommandState = WaitingForCommand; + break; + // Asked to identify the chips in the SIMM. Identify them and send reply. + case IdentifyChips: + { + struct ParallelFlashChipID chips[PARALLEL_FLASH_NUM_CHIPS]; + USBCDC_SendByte(CommandReplyOK); + ParallelFlash_IdentifyChips(chips); + for (int i = 0; i < PARALLEL_FLASH_NUM_CHIPS; i++) + { + USBCDC_SendByte(chips[i].manufacturer); + USBCDC_SendByte(chips[i].device); + } + USBCDC_SendByte(ProgrammerIdentifyDone); + break; + } + // Asked to read a single byte from each SIMM. Change the state and reply. + case ReadByte: + USBCDC_SendByte(CommandReplyInvalid); // not implemented yet + break; + // Asked to read all four chips. Set the state, reply with the first chunk. + // This will read from the BEGINNING of the SIMM every time. Use + // ReadChipsAt to specify a start position + case ReadChips: + curCommandState = ReadingChipsReadLength; + curReadIndex = 0; + readLengthByteIndex = 0; + readLength = 0; + USBCDC_SendByte(CommandReplyOK); + break; + case ReadChipsAt: + curCommandState = ReadingChipsReadStartPos; + curReadIndex = 0; + readLengthByteIndex = 0; + readLength = 0; + USBCDC_SendByte(CommandReplyOK); + break; + // Erase the chips and reply OK. (TODO: Sometimes erase might fail) + case EraseChips: + ParallelFlash_EraseChips(chipsMask); + USBCDC_SendByte(CommandReplyOK); + break; + // Begin writing the chips. Change the state, reply, wait for chunk of data + case WriteChips: + curCommandState = WritingChips; + curWriteIndex = 0; + writePosInChunk = -1; + USBCDC_SendByte(CommandReplyOK); + break; + case WriteChipsAt: + curCommandState = WritingChipsReadingStartPos; + curWriteIndex = 0; + readLengthByteIndex = 0; + writePosInChunk = -1; + USBCDC_SendByte(CommandReplyOK); + break; + // Asked for the current bootloader state. We are in the program right now, + // so reply accordingly. + case GetBootloaderState: + USBCDC_SendByte(CommandReplyOK); + USBCDC_SendByte(BootloaderStateInProgrammer); + break; + // Enter the bootloader. Wait a bit, then jump to the bootloader location. + case EnterBootloader: + USBCDC_SendByte(CommandReplyOK); + // Force this to be sent immediately so the programmer software knows. + USBCDC_Flush(); + + // Insert a small delay to ensure that it arrives before rebooting. + DelayMS(1000); + + // Done with the USB interface -- the bootloader will re-initialize it. + USBCDC_Disable(); + + // Disable interrupts so nothing weird happens... + cli(); + + // Wait a little bit to let everything settle and let the program + // close the port after the USB disconnect + DelayMS(2000); + + // And, of course, go into the bootloader. + __asm__ __volatile__ ( "jmp 0xE000" ); + break; + // Enter the programmer. We're already there, so reply OK. + case EnterProgrammer: + // Already in the programmer + USBCDC_SendByte(CommandReplyOK); + break; + // Set the SIMM type to the older, smaller chip size (2MB and below) + case SetSIMMTypePLCC32_2MB: + ParallelFlash_SetChipType(ParallelFlash_SST39SF040_x4); + USBCDC_SendByte(CommandReplyOK); + break; + case SetSIMMTypeLarger: + ParallelFlash_SetChipType(ParallelFlash_M29F160FB5AN6E2_x4); + USBCDC_SendByte(CommandReplyOK); + break; + case SetVerifyWhileWriting: + verifyDuringWrite = true; + USBCDC_SendByte(CommandReplyOK); + break; + case SetNoVerifyWhileWriting: + verifyDuringWrite = false; + USBCDC_SendByte(CommandReplyOK); + break; + case ErasePortion: + readLengthByteIndex = 0; + eraseLength = 0; + erasePosition = 0; + curCommandState = ErasePortionReadingPosLength; + USBCDC_SendByte(CommandReplyOK); + break; + case SetChipsMask: + curCommandState = ReadingChipsMask; + USBCDC_SendByte(CommandReplyOK); + break; + // We don't know what this command is, so reply that it was invalid. + default: + USBCDC_SendByte(CommandReplyInvalid); + break; + } +} + +/** Handles a received byte when we are reading from chips + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleReadingChipsByte(uint8_t byte) +{ + // The byte should be a reply from the computer. It should be either: + // 1) ComputerReadOK -- meaning it got the chunk we just sent + // or + // 2) ComputerReadCancel -- meaning the user canceled the read + switch (byte) + { + case ComputerReadOK: + // If they have confirmed the final data chunk, let them know + // that they have finished, and enter command state. + if (curReadIndex >= readLength) + { + LED_Off(); + USBCDC_SendByte(ProgrammerReadFinished); + curCommandState = WaitingForCommand; + } + else // There's more data left to read, so read it and send it to them! + { + LED_Toggle(); + USBCDC_SendByte(ProgrammerReadMoreData); + SIMMProgrammer_SendReadDataChunk(); + } + break; + case ComputerReadCancel: + // If they've canceled, let them know we got their request and go back + // to "waiting for command" state + USBCDC_SendByte(ProgrammerReadConfirmCancel); + curCommandState = WaitingForCommand; + break; + } +} + +/** Handles a received byte when we are reading the length of data requested to be read + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleReadingChipsReadLengthByte(uint8_t byte) +{ + // There will be four bytes, so count up until we know the length. If they + // have sent all four bytes, send the first read chunk. + readLength |= (((uint32_t)byte) << (8*readLengthByteIndex)); + if (++readLengthByteIndex >= 4) + { + // Ensure it's within limits and a multiple of 1024 + if ((curReadIndex + readLength > PARALLEL_FLASH_NUM_CHIPS * MAX_CHIP_SIZE) || + (readLength % READ_WRITE_CHUNK_SIZE_BYTES) || + (curReadIndex % READ_WRITE_CHUNK_SIZE_BYTES) || + (readLength == 0))// Ensure it's within limits and a multiple of 1024 + { + USBCDC_SendByte(ProgrammerReadError); + curCommandState = WaitingForCommand; + } + else + { + // Convert the length/pos into the number of chunks we need to send + readLength /= READ_WRITE_CHUNK_SIZE_BYTES; + curReadIndex /= READ_WRITE_CHUNK_SIZE_BYTES; + curCommandState = ReadingChips; + USBCDC_SendByte(ProgrammerReadOK); + SIMMProgrammer_SendReadDataChunk(); + } + } +} + +/** Reads a chunk of data from the SIMM and sends it over the USB CDC serial port. + * + */ +static void SIMMProgrammer_SendReadDataChunk(void) +{ + // Read the next chunk of data, send it over USB, and make sure + // we sent it correctly. + ParallelFlash_Read(curReadIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), + readChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS); + bool retVal = USBCDC_SendData(readChunks.bytes, READ_WRITE_CHUNK_SIZE_BYTES); + + // If for some reason there was an error, mark it as such. Otherwise, + // increment our pointer so we know the next chunk of data to send. + if (!retVal) + { + //curCommandState = ReadingChipsUnableSendError; // TODO: not implemented + curCommandState = WaitingForCommand; + } + else + { + curReadIndex++; + } +} + +/** Handles a received byte when we are in the "writing chips" state + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleWritingChipsByte(uint8_t byte) +{ + // This means we have just started the entire process or just finished + // a chunk, so see what the computer has decided for us to do. + if (writePosInChunk == -1) + { + switch (byte) + { + // The computer asked to write more data to the SIMM. + case ComputerWriteMore: + writePosInChunk = 0; + // Make sure we don't write past the capacity of the chips. + if (curWriteIndex < MAX_CHIP_SIZE / (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS)) + { + USBCDC_SendByte(ProgrammerWriteOK); + } + else + { + LED_Off(); + USBCDC_SendByte(ProgrammerWriteError); + curCommandState = WaitingForCommand; + } + break; + // The computer said that it's done writing. + case ComputerWriteFinish: + LED_Off(); + USBCDC_SendByte(ProgrammerWriteOK); + curCommandState = WaitingForCommand; + break; + // The computer asked to cancel. + case ComputerWriteCancel: + LED_Off(); + USBCDC_SendByte(ProgrammerWriteConfirmCancel); + curCommandState = WaitingForCommand; + break; + } + } + else // Interpret the incoming byte as data to write to the SIMM. + { + // Save the byte. Then, block until we receive the rest of the data. + writeChunks.bytes[writePosInChunk++] = byte; + while (writePosInChunk < READ_WRITE_CHUNK_SIZE_BYTES) + { + writeChunks.bytes[writePosInChunk++] = USBCDC_ReadByteBlocking(); + } + + // We filled up the chunk, write it out and confirm it, then wait + // for the next command from the computer! + if (chipsMask == ALL_CHIPS) + { + ParallelFlash_WriteAllChips(curWriteIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), + writeChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS); + } + else + { + ParallelFlash_WriteSomeChips(curWriteIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), + writeChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS, chipsMask); + } + + // Verify if we were asked to. + uint8_t badVerifyChipsMask = 0; + if (verifyDuringWrite) + { + // Read back a chunk + ParallelFlash_Read(curWriteIndex * (READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS), + readChunks.words, READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS); + + // Compare the readback to what we attempted to flash. + // Look at each chip + for (uint8_t chip = 0; chip < PARALLEL_FLASH_NUM_CHIPS; chip++) + { + uint16_t bytePos = chip; + uint8_t thisChipMask = 1 << chip; + // Loop over all bytes that are on this chip + for (uint16_t i = 0; i < READ_WRITE_CHUNK_SIZE_BYTES/PARALLEL_FLASH_NUM_CHIPS; i++) + { + if (writeChunks.bytes[bytePos] != readChunks.bytes[bytePos]) + { + badVerifyChipsMask |= thisChipMask; + } + bytePos += PARALLEL_FLASH_NUM_CHIPS; + } + } + + // Filter out chips we didn't care about + badVerifyChipsMask &= chipsMask; + } + + // Bail if verification failed + if (badVerifyChipsMask != 0) + { + // Verification failed. The mask we calculated is actually + // backwards. We need to reverse it when we transmit the IC + // status back to the programmer software. This is kind of silly + // but it's too late to update the protocol. + uint8_t actualBadMask = 0; + for (uint8_t i = 0; i < PARALLEL_FLASH_NUM_CHIPS; i++) + { + if (badVerifyChipsMask & (1 << i)) + { + actualBadMask |= 0x80; + } + actualBadMask >>= 1; + } + + // Uh oh -- verification failure. + LED_Off(); + // Send the fail bit along with a mask of failed chips. + USBCDC_SendByte(ProgrammerWriteVerificationError | badVerifyChipsMask); + curCommandState = WaitingForCommand; + } + else + { + USBCDC_SendByte(ProgrammerWriteOK); + curWriteIndex++; + writePosInChunk = -1; + LED_Toggle(); + } + } +} + +/** Handler called during an electrical test when a short is detected + * + * @param index1 The index of the first shorted pin + * @param index2 The index of the second shorted pin + * + * The two pins at index1 and index2 have been detected as shorted together. + * The numbering is internal to the SIMM electrical test, and the programmer + * software knows how to interpret it. + */ +static void SIMMProgrammer_ElectricalTest_Fail_Handler(uint8_t index1, uint8_t index2) +{ + USBCDC_SendByte(ProgrammerElectricalTestFail); + USBCDC_SendByte(index1); + USBCDC_SendByte(index2); +} + +/** Handles a received byte when we are determining what part of the chip to erase + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleErasePortionReadPosLengthByte(uint8_t byte) +{ + // Read in the position and length to erase + if (readLengthByteIndex < 4) + { + erasePosition |= (((uint32_t)byte) << (8*readLengthByteIndex)); + } + else + { + eraseLength |= (((uint32_t)byte) << (8*(readLengthByteIndex - 4))); + } + + if (++readLengthByteIndex >= 8) + { + ParallelFlashChipType chipType = ParallelFlash_ChipType(); + bool eraseSuccess = false; + + // Ensure they are both within limits of sector size erasure + if (((erasePosition % ERASE_SECTOR_SIZE_BYTES) == 0) && + ((eraseLength % ERASE_SECTOR_SIZE_BYTES) == 0)) + { + uint32_t boundary = eraseLength + erasePosition; + + // Ensure they are within the limits of the chip size too + if (chipType == ParallelFlash_SST39SF040_x4) + { + if (boundary <= (2 * 1024UL * 1024UL)) + { + // OK! We're erasing certain sectors of a 2 MB SIMM. + USBCDC_SendByte(ProgrammerErasePortionOK); + // Send the response immediately, it could take a while. + USBCDC_Flush(); + if (ParallelFlash_EraseSectors(erasePosition/PARALLEL_FLASH_NUM_CHIPS, + eraseLength/PARALLEL_FLASH_NUM_CHIPS, chipsMask)) + { + eraseSuccess = true; + } + } + } + else if (chipType == ParallelFlash_M29F160FB5AN6E2_x4) + { + if (boundary <= (8 * 1024UL * 1024UL)) + { + // OK! We're erasing certain sectors of an 8 MB SIMM. + USBCDC_SendByte(ProgrammerErasePortionOK); + // Send the response immediately, it could take a while. + USBCDC_Flush(); + if (ParallelFlash_EraseSectors(erasePosition/PARALLEL_FLASH_NUM_CHIPS, + eraseLength/PARALLEL_FLASH_NUM_CHIPS, chipsMask)) + { + eraseSuccess = true; + } + } + } + } + + if (eraseSuccess) + { + // Not on a sector boundary for erase position and/or length + USBCDC_SendByte(ProgrammerErasePortionFinished); + curCommandState = WaitingForCommand; + } + else + { + // Not on a sector boundary for erase position and/or length + USBCDC_SendByte(ProgrammerErasePortionError); + curCommandState = WaitingForCommand; + } + } +} + +/** Handles a received byte when we are determining where to start reading from the SIMM + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleReadingChipsReadStartPosByte(uint8_t byte) +{ + // There will be four bytes, so count up until we know the position. If they + // have sent all four bytes, then start reading the length + curReadIndex |= (((uint32_t)byte) << (8*readLengthByteIndex)); + if (++readLengthByteIndex >= 4) + { + readLengthByteIndex = 0; + curCommandState = ReadingChipsReadLength; + } +} + +/** Handles a received byte when we are determining where to start writing to the SIMM + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleWritingChipsReadingStartPosByte(uint8_t byte) +{ + // There will be four bytes, so count up until we know the position. If they + // have sent all four bytes, then confirm the write and begin + curWriteIndex |= (((uint32_t)byte) << (8*readLengthByteIndex)); + if (++readLengthByteIndex >= 4) + { + // Got it...now, is it valid? If so, allow the write to begin + if ((curWriteIndex % READ_WRITE_CHUNK_SIZE_BYTES) || + (curWriteIndex >= PARALLEL_FLASH_NUM_CHIPS * MAX_CHIP_SIZE)) + { + USBCDC_SendByte(ProgrammerWriteError); + curCommandState = WaitingForCommand; + } + else + { + // Convert write size into an index appropriate for rest of code + curWriteIndex /= READ_WRITE_CHUNK_SIZE_BYTES; + USBCDC_SendByte(ProgrammerWriteOK); + curCommandState = WritingChips; + } + } +} + +/** Handles a received byte when we are determining the mask of which chips to write to + * + * @param byte The received byte + */ +static void SIMMProgrammer_HandleReadingChipsMaskByte(uint8_t byte) +{ + // Single byte follows containing mask of chips we're programming + if (byte <= 0x0F) + { + // Mask has to be less than or equal to 0x0F because there are only + // four valid mask bits. + chipsMask = byte; + USBCDC_SendByte(CommandReplyOK); + } + else + { + USBCDC_SendByte(CommandReplyError); + } + + // Done either way; now we're waiting for a command to arrive + curCommandState = WaitingForCommand; +} diff --git a/simm_programmer.h b/simm_programmer.h index d66e881..1f95211 100644 --- a/simm_programmer.h +++ b/simm_programmer.h @@ -1,31 +1,31 @@ -/* - * simm_programmer.h - * - * Created on: Dec 9, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SIMM_PROGRAMMER_H_ -#define SIMM_PROGRAMMER_H_ - -void SIMMProgrammer_Init(void); -void SIMMProgrammer_Check(void); - -#endif /* SIMM_PROGRAMMER_H_ */ +/* + * simm_programmer.h + * + * Created on: Dec 9, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SIMM_PROGRAMMER_H_ +#define SIMM_PROGRAMMER_H_ + +void SIMMProgrammer_Init(void); +void SIMMProgrammer_Check(void); + +#endif /* SIMM_PROGRAMMER_H_ */ diff --git a/tests/simm_electrical_test.c b/tests/simm_electrical_test.c index 5aef975..4453e54 100644 --- a/tests/simm_electrical_test.c +++ b/tests/simm_electrical_test.c @@ -1,473 +1,473 @@ -/* - * simm_electrical_test.c - * - * Created on: Nov 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "simm_electrical_test.h" -#include "../hal/parallel_bus.h" -#include "hardware.h" - -/// The index of the highest SIMM address pin -#define SIMM_HIGHEST_ADDRESS_LINE 20 -/// Mask that represents every SIMM address pin -#define SIMM_ADDRESS_PINS_MASK ((1UL << (SIMM_HIGHEST_ADDRESS_LINE + 1)) - 1) - -/// The index of the highest SIMM data pin -#define SIMM_HIGHEST_DATA_LINE 31 -/// Mask that represents every SIMM data pin -#define SIMM_DATA_PINS_MASK 0xFFFFFFFFUL - -/// Milliseconds to wait before testing for shorts -#define DELAY_SETTLE_TIME_MS 20 - -/// The index reported as a short when it's a ground short -#define GROUND_FAIL_INDEX 0xFF -/// The index reported when A0 is shorted -#define FIRST_ADDRESS_LINE_FAIL_INDEX 0 -/// The index reported when A20 is shorted -#define LAST_ADDRESS_LINE_FAIL_INDEX (FIRST_ADDRESS_LINE_FAIL_INDEX + SIMM_HIGHEST_ADDRESS_LINE) -/// The index reported when D0 is shorted -#define FIRST_DATA_LINE_FAIL_INDEX (LAST_ADDRESS_LINE_FAIL_INDEX + 1) -/// The index reported when D31 is shorted -#define LAST_DATA_LINE_FAIL_INDEX (FIRST_DATA_LINE_FAIL_INDEX + SIMM_HIGHEST_DATA_LINE) -/// The index reported when CS is shorted -#define CS_FAIL_INDEX (LAST_DATA_LINE_FAIL_INDEX + 1) -/// The index reported when OE is shorted -#define OE_FAIL_INDEX (CS_FAIL_INDEX + 1) -/// The index reported when WE is shorted -#define WE_FAIL_INDEX (OE_FAIL_INDEX + 1) - -/// Enum representing the step we're on during the electrical test -typedef enum ElectricalTestStage -{ - TestingAddressLines,//!< We are testing an address pin - TestingDataLines, //!< We are testing a data pin - TestingCS, //!< We are testing the CS pin - TestingOE, //!< We are testing the OE pin - TestingWE, //!< We are testing the WE pin - DoneTesting //!< We completed the test -} ElectricalTestStage; - -static void SIMMElectricalTest_ResetGroundShorts(void); -static void SIMMElectricalTest_AddGroundShort(uint8_t index); -static bool SIMMElectricalTest_IsGroundShort(uint8_t index); - -/// Pin indexes that were detected as shorted to ground. They have to be saved, -/// because they end up being detected as a short against every other pin, -/// so we have to be able to filter them out when testing non-ground shorts. -static uint32_t groundShorts[2]; - -/** Runs the electrical test - * - * @param errorHandler Pointer to function to call when a short is detected. - * @return The number of errors we found - * - * The two parameters to errorHandler are the two indexes that are shorted. - * (See the _FAIL_INDEX defines at the top of this file) - */ -int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t)) -{ - // Returns number of errors found - int numErrors = 0; - - // Reset the pins we have determined that are shorted to ground - // (We have to ignore them during the second phase of the test) - SIMMElectricalTest_ResetGroundShorts(); - - // First check for anything shorted to ground. Set all lines as inputs with - // a weak pull-up resistor. Then read the values back and check for any - // zeros. This would indicate a short to ground. - ParallelBus_SetAddressDir(0); - ParallelBus_SetDataDir(0); - ParallelBus_SetCSDir(false); - ParallelBus_SetOEDir(false); - ParallelBus_SetWEDir(false); - ParallelBus_SetAddressPullups(SIMM_ADDRESS_PINS_MASK); - ParallelBus_SetDataPullups(SIMM_DATA_PINS_MASK); - ParallelBus_SetCSPullup(true); - ParallelBus_SetOEPullup(true); - ParallelBus_SetWEPullup(true); - - // Wait a brief moment... - DelayMS(DELAY_SETTLE_TIME_MS); - - // Now loop through every pin and check it. - uint8_t curPin = 0; - uint8_t i; - - // Read the address pins back first - uint32_t readback = ParallelBus_ReadAddress(); - // Check each bit for a LOW which would indicate a short to ground - for (i = 0; i <= SIMM_HIGHEST_ADDRESS_LINE; i++) - { - // Did we find a low bit? - if (!(readback & 1)) - { - // That means this pin is shorted to ground. - // So notify the caller that we have a ground short on this pin - if (errorHandler) - { - errorHandler(curPin, GROUND_FAIL_INDEX); - } - - // Add it to our internal list of ground shorts also. - SIMMElectricalTest_AddGroundShort(curPin); - - // And of course increment the error counter. - numErrors++; - } - - // No matter what, though, move on to the next bit and pin. - readback >>= 1; - curPin++; - } - - // Repeat the exact same process for the data pins - readback = ParallelBus_ReadData(); - for (i = 0; i <= SIMM_HIGHEST_DATA_LINE; i++) - { - if (!(readback & 1)) - { - if (errorHandler) - { - errorHandler(curPin, GROUND_FAIL_INDEX); - } - SIMMElectricalTest_AddGroundShort(curPin); - numErrors++; - } - - readback >>= 1; - curPin++; - } - - // Check chip select in the same way... - if (!ParallelBus_ReadCS()) - { - if (errorHandler) - { - errorHandler(curPin, GROUND_FAIL_INDEX); - } - SIMMElectricalTest_AddGroundShort(curPin); - numErrors++; - } - curPin++; - - // Output enable... - if (!ParallelBus_ReadOE()) - { - if (errorHandler) - { - errorHandler(curPin, GROUND_FAIL_INDEX); - } - SIMMElectricalTest_AddGroundShort(curPin); - numErrors++; - } - curPin++; - - // Write enable... - if (!ParallelBus_ReadWE()) - { - if (errorHandler) - { - errorHandler(curPin, GROUND_FAIL_INDEX); - } - SIMMElectricalTest_AddGroundShort(curPin); - numErrors++; - } - curPin++; // Doesn't need to be here, but for consistency I'm leaving it. - - // OK, now we know which lines are shorted to ground. We need to keep that - // in mind, because those lines will now show as shorted to ALL other - // lines...ignore them during tests to find other independent shorts - - // Now, check each individual line vs. all other lines on the SIMM for any - // shorts between them - ElectricalTestStage curStage = TestingAddressLines; - // Counter of what address or data pin we're on. Not used for control lines. - uint8_t addrDataPin = 0; - // What pin we are currently testing all other pins against. - uint8_t testPin = 0; - // More explanation: addrDataPin is only a counter inside the address or - // data pins. testPin is a total counter of ALL pins. - while (curStage != DoneTesting) - { - // Set one pin to output a 0. - // Set all other pins as inputs with pull-ups. - // Then read back all the other pins. If any of them read back as 0, - // it means they are shorted to the pin we set as an output. - - // If we're testing address lines right now, set the current address - // line as an output (and make it output a LOW). Set all other address - // lines as inputs with pullups. - if (curStage == TestingAddressLines) - { - // Mask of the address pin we're testing - uint32_t addressLineMask = (1UL << addrDataPin); - - // Set it as an output and all other address pins as inputs. - ParallelBus_SetAddressDir(addressLineMask); - ParallelBus_SetAddress(0); - ParallelBus_SetAddressPullups(~addressLineMask); - } - else - { - // If not testing an address line, set all address pins as inputs - // with pullups. All the other stages follow the same pattern so I - // won't bother commenting them. - ParallelBus_SetAddressDir(0); - ParallelBus_SetAddressPullups(SIMM_ADDRESS_PINS_MASK); - } - - // Do the same thing for data lines... - if (curStage == TestingDataLines) - { - uint32_t dataLineMask = (1UL << addrDataPin); - ParallelBus_SetDataDir(dataLineMask); - ParallelBus_SetData(0); - ParallelBus_SetDataPullups(~dataLineMask); - } - else - { - ParallelBus_SetDataDir(0); - ParallelBus_SetDataPullups(SIMM_DATA_PINS_MASK); - } - - // Chip select... - if (curStage == TestingCS) - { - ParallelBus_SetCSDir(true); - ParallelBus_SetCS(false); - } - else - { - ParallelBus_SetCSDir(false); - ParallelBus_SetCSPullup(true); - } - - // Output enable... - if (curStage == TestingOE) - { - ParallelBus_SetOEDir(true); - ParallelBus_SetOE(false); - } - else - { - ParallelBus_SetOEDir(false); - ParallelBus_SetOEPullup(true); - } - - // And write enable. - if (curStage == TestingWE) - { - ParallelBus_SetWEDir(true); - ParallelBus_SetWE(false); - } - else - { - ParallelBus_SetWEDir(false); - ParallelBus_SetWEPullup(true); - } - - // OK, so now we have set up all lines as needed. Exactly one pin is - // outputting a 0, and all other pins are inputs with pull-ups enabled. - // Read back all the lines, and if any pin reads back as 0, it means - // that pin is shorted to the pin we are testing (overpowering its - // pullup). However, because we test each pin against every other pin, - // any short would appear twice. Once as "pin 1 is shorted to pin 2" - // and once as "pin 2 is shorted to pin 1". To avoid that annoyance, I - // only check each combination of two pins once. You'll see below how I - // do this by testing to ensure curPin > testPin. - - // Allow everything to settle - DelayMS(DELAY_SETTLE_TIME_MS); - - // Now keep a count of how many pins we have actually checked during - // THIS test iteration. This is the "fail index" of the current pin. - curPin = 0; - - // Read back the address data to see if any shorts were found - readback = ParallelBus_ReadAddress(); - - // Count any shorted pins - for (i = 0; i <= SIMM_HIGHEST_ADDRESS_LINE; i++) - { - // Failure here? - if ((curPin > testPin) && // We haven't already checked this combination of pins (don't test pin against itself either) - !(readback & 1) && // It's showing as low (which indicates a short) - !SIMMElectricalTest_IsGroundShort(curPin)) // And it's not recorded as a short to ground - { - // Send it out as an error notification and increase error counter - if (errorHandler) - { - errorHandler(testPin, curPin); - } - numErrors++; - } - - // No matter what, move on to the next bit and pin - readback >>= 1; - curPin++; - } - - // Same thing for data pins - readback = ParallelBus_ReadData(); - - // Count any shorted pins - for (i = 0; i <= SIMM_HIGHEST_DATA_LINE; i++) - { - // Failure here? - if ((curPin > testPin) && // We haven't already checked this combination of pins (don't test pin against itself either) - !(readback & 1) && // It's showing as low (which indicates a short) - !SIMMElectricalTest_IsGroundShort(curPin)) // And it's not recorded as a short to ground - { - if (errorHandler) - { - errorHandler(testPin, curPin); - } - numErrors++; - } - - readback >>= 1; - curPin++; - } - - // And chip select... - if ((curPin > testPin) && - !ParallelBus_ReadCS() && - !SIMMElectricalTest_IsGroundShort(curPin)) - { - if (errorHandler) - { - errorHandler(testPin, curPin); - } - numErrors++; - } - curPin++; - - // Output enable... - if ((curPin > testPin) && - !ParallelBus_ReadOE() && - !SIMMElectricalTest_IsGroundShort(curPin)) - { - if (errorHandler) - { - errorHandler(testPin, curPin); - } - numErrors++; - } - curPin++; - - // And write enable - if ((curPin > testPin) && - !ParallelBus_ReadWE() && - !SIMMElectricalTest_IsGroundShort(curPin)) - { - if (errorHandler) - { - errorHandler(testPin, curPin); - } - numErrors++; - } - curPin++; // Not needed, kept for consistency - - // Finally, move on to the next stage if needed. - if (curStage == TestingAddressLines) - { - // If we've exhausted all address lines, move on to the next stage - // (and reset the pin counter to 0) - if (++addrDataPin > SIMM_HIGHEST_ADDRESS_LINE) - { - curStage++; - addrDataPin = 0; - } - } - else if (curStage == TestingDataLines) - { - // If we've exhausted all data lines, move on to the next stage - // (don't bother resetting the pin counter -- the other stages don't use it) - if (++addrDataPin > SIMM_HIGHEST_DATA_LINE) - { - curStage++; - } - } - else - { - curStage++; - } - - // Move on to test the next pin - testPin++; - } - - // Restore to a normal state by calling ParallelBus_Init again. - ParallelBus_Init(); - - // Now that the final state is restored, return the number of errors found - return numErrors; -} - -/** Resets our list of pins that are shorted to ground - * - */ -static void SIMMElectricalTest_ResetGroundShorts(void) -{ - groundShorts[0] = 0; - groundShorts[1] = 0; -} - -/** Adds a pin to the list of ground shorts - * - * @param index The index of the pin in the electrical test - */ -static void SIMMElectricalTest_AddGroundShort(uint8_t index) -{ - if (index < 32) - { - groundShorts[0] |= (1UL << index); - } - else if (index < 64) - { - groundShorts[1] |= (1UL << (index - 32)); - } - // None are >= 64, no further handling needed -} - -/** Determines if a pin has already been saved as a ground short - * - * @param index The index of the pin in the electrical test - * @return True if this pin has been determined as a short to GND, false if not - */ -static bool SIMMElectricalTest_IsGroundShort(uint8_t index) -{ - if (index < 32) - { - return ((groundShorts[0] & (1UL << index)) != 0); - } - else if (index < 64) - { - return ((groundShorts[1] & (1UL << (index - 32))) != 0); - } - else - { - return false; - } -} +/* + * simm_electrical_test.c + * + * Created on: Nov 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "simm_electrical_test.h" +#include "../hal/parallel_bus.h" +#include "hardware.h" + +/// The index of the highest SIMM address pin +#define SIMM_HIGHEST_ADDRESS_LINE 20 +/// Mask that represents every SIMM address pin +#define SIMM_ADDRESS_PINS_MASK ((1UL << (SIMM_HIGHEST_ADDRESS_LINE + 1)) - 1) + +/// The index of the highest SIMM data pin +#define SIMM_HIGHEST_DATA_LINE 31 +/// Mask that represents every SIMM data pin +#define SIMM_DATA_PINS_MASK 0xFFFFFFFFUL + +/// Milliseconds to wait before testing for shorts +#define DELAY_SETTLE_TIME_MS 20 + +/// The index reported as a short when it's a ground short +#define GROUND_FAIL_INDEX 0xFF +/// The index reported when A0 is shorted +#define FIRST_ADDRESS_LINE_FAIL_INDEX 0 +/// The index reported when A20 is shorted +#define LAST_ADDRESS_LINE_FAIL_INDEX (FIRST_ADDRESS_LINE_FAIL_INDEX + SIMM_HIGHEST_ADDRESS_LINE) +/// The index reported when D0 is shorted +#define FIRST_DATA_LINE_FAIL_INDEX (LAST_ADDRESS_LINE_FAIL_INDEX + 1) +/// The index reported when D31 is shorted +#define LAST_DATA_LINE_FAIL_INDEX (FIRST_DATA_LINE_FAIL_INDEX + SIMM_HIGHEST_DATA_LINE) +/// The index reported when CS is shorted +#define CS_FAIL_INDEX (LAST_DATA_LINE_FAIL_INDEX + 1) +/// The index reported when OE is shorted +#define OE_FAIL_INDEX (CS_FAIL_INDEX + 1) +/// The index reported when WE is shorted +#define WE_FAIL_INDEX (OE_FAIL_INDEX + 1) + +/// Enum representing the step we're on during the electrical test +typedef enum ElectricalTestStage +{ + TestingAddressLines,//!< We are testing an address pin + TestingDataLines, //!< We are testing a data pin + TestingCS, //!< We are testing the CS pin + TestingOE, //!< We are testing the OE pin + TestingWE, //!< We are testing the WE pin + DoneTesting //!< We completed the test +} ElectricalTestStage; + +static void SIMMElectricalTest_ResetGroundShorts(void); +static void SIMMElectricalTest_AddGroundShort(uint8_t index); +static bool SIMMElectricalTest_IsGroundShort(uint8_t index); + +/// Pin indexes that were detected as shorted to ground. They have to be saved, +/// because they end up being detected as a short against every other pin, +/// so we have to be able to filter them out when testing non-ground shorts. +static uint32_t groundShorts[2]; + +/** Runs the electrical test + * + * @param errorHandler Pointer to function to call when a short is detected. + * @return The number of errors we found + * + * The two parameters to errorHandler are the two indexes that are shorted. + * (See the _FAIL_INDEX defines at the top of this file) + */ +int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t)) +{ + // Returns number of errors found + int numErrors = 0; + + // Reset the pins we have determined that are shorted to ground + // (We have to ignore them during the second phase of the test) + SIMMElectricalTest_ResetGroundShorts(); + + // First check for anything shorted to ground. Set all lines as inputs with + // a weak pull-up resistor. Then read the values back and check for any + // zeros. This would indicate a short to ground. + ParallelBus_SetAddressDir(0); + ParallelBus_SetDataDir(0); + ParallelBus_SetCSDir(false); + ParallelBus_SetOEDir(false); + ParallelBus_SetWEDir(false); + ParallelBus_SetAddressPullups(SIMM_ADDRESS_PINS_MASK); + ParallelBus_SetDataPullups(SIMM_DATA_PINS_MASK); + ParallelBus_SetCSPullup(true); + ParallelBus_SetOEPullup(true); + ParallelBus_SetWEPullup(true); + + // Wait a brief moment... + DelayMS(DELAY_SETTLE_TIME_MS); + + // Now loop through every pin and check it. + uint8_t curPin = 0; + uint8_t i; + + // Read the address pins back first + uint32_t readback = ParallelBus_ReadAddress(); + // Check each bit for a LOW which would indicate a short to ground + for (i = 0; i <= SIMM_HIGHEST_ADDRESS_LINE; i++) + { + // Did we find a low bit? + if (!(readback & 1)) + { + // That means this pin is shorted to ground. + // So notify the caller that we have a ground short on this pin + if (errorHandler) + { + errorHandler(curPin, GROUND_FAIL_INDEX); + } + + // Add it to our internal list of ground shorts also. + SIMMElectricalTest_AddGroundShort(curPin); + + // And of course increment the error counter. + numErrors++; + } + + // No matter what, though, move on to the next bit and pin. + readback >>= 1; + curPin++; + } + + // Repeat the exact same process for the data pins + readback = ParallelBus_ReadData(); + for (i = 0; i <= SIMM_HIGHEST_DATA_LINE; i++) + { + if (!(readback & 1)) + { + if (errorHandler) + { + errorHandler(curPin, GROUND_FAIL_INDEX); + } + SIMMElectricalTest_AddGroundShort(curPin); + numErrors++; + } + + readback >>= 1; + curPin++; + } + + // Check chip select in the same way... + if (!ParallelBus_ReadCS()) + { + if (errorHandler) + { + errorHandler(curPin, GROUND_FAIL_INDEX); + } + SIMMElectricalTest_AddGroundShort(curPin); + numErrors++; + } + curPin++; + + // Output enable... + if (!ParallelBus_ReadOE()) + { + if (errorHandler) + { + errorHandler(curPin, GROUND_FAIL_INDEX); + } + SIMMElectricalTest_AddGroundShort(curPin); + numErrors++; + } + curPin++; + + // Write enable... + if (!ParallelBus_ReadWE()) + { + if (errorHandler) + { + errorHandler(curPin, GROUND_FAIL_INDEX); + } + SIMMElectricalTest_AddGroundShort(curPin); + numErrors++; + } + curPin++; // Doesn't need to be here, but for consistency I'm leaving it. + + // OK, now we know which lines are shorted to ground. We need to keep that + // in mind, because those lines will now show as shorted to ALL other + // lines...ignore them during tests to find other independent shorts + + // Now, check each individual line vs. all other lines on the SIMM for any + // shorts between them + ElectricalTestStage curStage = TestingAddressLines; + // Counter of what address or data pin we're on. Not used for control lines. + uint8_t addrDataPin = 0; + // What pin we are currently testing all other pins against. + uint8_t testPin = 0; + // More explanation: addrDataPin is only a counter inside the address or + // data pins. testPin is a total counter of ALL pins. + while (curStage != DoneTesting) + { + // Set one pin to output a 0. + // Set all other pins as inputs with pull-ups. + // Then read back all the other pins. If any of them read back as 0, + // it means they are shorted to the pin we set as an output. + + // If we're testing address lines right now, set the current address + // line as an output (and make it output a LOW). Set all other address + // lines as inputs with pullups. + if (curStage == TestingAddressLines) + { + // Mask of the address pin we're testing + uint32_t addressLineMask = (1UL << addrDataPin); + + // Set it as an output and all other address pins as inputs. + ParallelBus_SetAddressDir(addressLineMask); + ParallelBus_SetAddress(0); + ParallelBus_SetAddressPullups(~addressLineMask); + } + else + { + // If not testing an address line, set all address pins as inputs + // with pullups. All the other stages follow the same pattern so I + // won't bother commenting them. + ParallelBus_SetAddressDir(0); + ParallelBus_SetAddressPullups(SIMM_ADDRESS_PINS_MASK); + } + + // Do the same thing for data lines... + if (curStage == TestingDataLines) + { + uint32_t dataLineMask = (1UL << addrDataPin); + ParallelBus_SetDataDir(dataLineMask); + ParallelBus_SetData(0); + ParallelBus_SetDataPullups(~dataLineMask); + } + else + { + ParallelBus_SetDataDir(0); + ParallelBus_SetDataPullups(SIMM_DATA_PINS_MASK); + } + + // Chip select... + if (curStage == TestingCS) + { + ParallelBus_SetCSDir(true); + ParallelBus_SetCS(false); + } + else + { + ParallelBus_SetCSDir(false); + ParallelBus_SetCSPullup(true); + } + + // Output enable... + if (curStage == TestingOE) + { + ParallelBus_SetOEDir(true); + ParallelBus_SetOE(false); + } + else + { + ParallelBus_SetOEDir(false); + ParallelBus_SetOEPullup(true); + } + + // And write enable. + if (curStage == TestingWE) + { + ParallelBus_SetWEDir(true); + ParallelBus_SetWE(false); + } + else + { + ParallelBus_SetWEDir(false); + ParallelBus_SetWEPullup(true); + } + + // OK, so now we have set up all lines as needed. Exactly one pin is + // outputting a 0, and all other pins are inputs with pull-ups enabled. + // Read back all the lines, and if any pin reads back as 0, it means + // that pin is shorted to the pin we are testing (overpowering its + // pullup). However, because we test each pin against every other pin, + // any short would appear twice. Once as "pin 1 is shorted to pin 2" + // and once as "pin 2 is shorted to pin 1". To avoid that annoyance, I + // only check each combination of two pins once. You'll see below how I + // do this by testing to ensure curPin > testPin. + + // Allow everything to settle + DelayMS(DELAY_SETTLE_TIME_MS); + + // Now keep a count of how many pins we have actually checked during + // THIS test iteration. This is the "fail index" of the current pin. + curPin = 0; + + // Read back the address data to see if any shorts were found + readback = ParallelBus_ReadAddress(); + + // Count any shorted pins + for (i = 0; i <= SIMM_HIGHEST_ADDRESS_LINE; i++) + { + // Failure here? + if ((curPin > testPin) && // We haven't already checked this combination of pins (don't test pin against itself either) + !(readback & 1) && // It's showing as low (which indicates a short) + !SIMMElectricalTest_IsGroundShort(curPin)) // And it's not recorded as a short to ground + { + // Send it out as an error notification and increase error counter + if (errorHandler) + { + errorHandler(testPin, curPin); + } + numErrors++; + } + + // No matter what, move on to the next bit and pin + readback >>= 1; + curPin++; + } + + // Same thing for data pins + readback = ParallelBus_ReadData(); + + // Count any shorted pins + for (i = 0; i <= SIMM_HIGHEST_DATA_LINE; i++) + { + // Failure here? + if ((curPin > testPin) && // We haven't already checked this combination of pins (don't test pin against itself either) + !(readback & 1) && // It's showing as low (which indicates a short) + !SIMMElectricalTest_IsGroundShort(curPin)) // And it's not recorded as a short to ground + { + if (errorHandler) + { + errorHandler(testPin, curPin); + } + numErrors++; + } + + readback >>= 1; + curPin++; + } + + // And chip select... + if ((curPin > testPin) && + !ParallelBus_ReadCS() && + !SIMMElectricalTest_IsGroundShort(curPin)) + { + if (errorHandler) + { + errorHandler(testPin, curPin); + } + numErrors++; + } + curPin++; + + // Output enable... + if ((curPin > testPin) && + !ParallelBus_ReadOE() && + !SIMMElectricalTest_IsGroundShort(curPin)) + { + if (errorHandler) + { + errorHandler(testPin, curPin); + } + numErrors++; + } + curPin++; + + // And write enable + if ((curPin > testPin) && + !ParallelBus_ReadWE() && + !SIMMElectricalTest_IsGroundShort(curPin)) + { + if (errorHandler) + { + errorHandler(testPin, curPin); + } + numErrors++; + } + curPin++; // Not needed, kept for consistency + + // Finally, move on to the next stage if needed. + if (curStage == TestingAddressLines) + { + // If we've exhausted all address lines, move on to the next stage + // (and reset the pin counter to 0) + if (++addrDataPin > SIMM_HIGHEST_ADDRESS_LINE) + { + curStage++; + addrDataPin = 0; + } + } + else if (curStage == TestingDataLines) + { + // If we've exhausted all data lines, move on to the next stage + // (don't bother resetting the pin counter -- the other stages don't use it) + if (++addrDataPin > SIMM_HIGHEST_DATA_LINE) + { + curStage++; + } + } + else + { + curStage++; + } + + // Move on to test the next pin + testPin++; + } + + // Restore to a normal state by calling ParallelBus_Init again. + ParallelBus_Init(); + + // Now that the final state is restored, return the number of errors found + return numErrors; +} + +/** Resets our list of pins that are shorted to ground + * + */ +static void SIMMElectricalTest_ResetGroundShorts(void) +{ + groundShorts[0] = 0; + groundShorts[1] = 0; +} + +/** Adds a pin to the list of ground shorts + * + * @param index The index of the pin in the electrical test + */ +static void SIMMElectricalTest_AddGroundShort(uint8_t index) +{ + if (index < 32) + { + groundShorts[0] |= (1UL << index); + } + else if (index < 64) + { + groundShorts[1] |= (1UL << (index - 32)); + } + // None are >= 64, no further handling needed +} + +/** Determines if a pin has already been saved as a ground short + * + * @param index The index of the pin in the electrical test + * @return True if this pin has been determined as a short to GND, false if not + */ +static bool SIMMElectricalTest_IsGroundShort(uint8_t index) +{ + if (index < 32) + { + return ((groundShorts[0] & (1UL << index)) != 0); + } + else if (index < 64) + { + return ((groundShorts[1] & (1UL << (index - 32))) != 0); + } + else + { + return false; + } +} diff --git a/tests/simm_electrical_test.h b/tests/simm_electrical_test.h index 27676a3..78d25b1 100644 --- a/tests/simm_electrical_test.h +++ b/tests/simm_electrical_test.h @@ -1,32 +1,32 @@ -/* - * simm_electrical_test.h - * - * Created on: Nov 26, 2011 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef SIMM_ELECTRICAL_TEST_H_ -#define SIMM_ELECTRICAL_TEST_H_ - -#include - -int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t)); - -#endif /* SIMM_ELECTRICAL_TEST_H_ */ +/* + * simm_electrical_test.h + * + * Created on: Nov 26, 2011 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SIMM_ELECTRICAL_TEST_H_ +#define SIMM_ELECTRICAL_TEST_H_ + +#include + +int SIMMElectricalTest_Run(void (*errorHandler)(uint8_t, uint8_t)); + +#endif /* SIMM_ELECTRICAL_TEST_H_ */ diff --git a/util.h b/util.h index 4e646f6..3cfbab1 100644 --- a/util.h +++ b/util.h @@ -1,31 +1,31 @@ -/* - * util.h - * - * Created on: Nov 25, 2020 - * Author: Doug - * - * Copyright (C) 2011-2020 Doug Brown - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef UTIL_H_ -#define UTIL_H_ - -/// Macro so we don't have to repeat this monstrosity multiple times -#define ALWAYS_INLINE __attribute__ ((__always_inline__)) inline - -#endif /* UTIL_H_ */ +/* + * util.h + * + * Created on: Nov 25, 2020 + * Author: Doug + * + * Copyright (C) 2011-2020 Doug Brown + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef UTIL_H_ +#define UTIL_H_ + +/// Macro so we don't have to repeat this monstrosity multiple times +#define ALWAYS_INLINE __attribute__ ((__always_inline__)) inline + +#endif /* UTIL_H_ */