From 0c0436f47c296513dace43d3ba20e3cc36f8f527 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 25 Mar 2012 17:46:26 +0200 Subject: Board, rev A. --- firmware/LUFA/CodeTemplates/DriverStubs/Buttons.h | 86 + .../LUFA/CodeTemplates/DriverStubs/Dataflash.h | 186 ++ firmware/LUFA/CodeTemplates/DriverStubs/Joystick.h | 98 + firmware/LUFA/CodeTemplates/DriverStubs/LEDs.h | 125 + firmware/LUFA/CodeTemplates/makefile_template | 707 +++++ firmware/LUFA/Common/Attributes.h | 139 + firmware/LUFA/Common/BoardTypes.h | 151 + firmware/LUFA/Common/Common.h | 253 ++ firmware/LUFA/Doxygen.conf | 1564 ++++++++++ firmware/LUFA/Drivers/Board/ADAFRUITU4/LEDs.h | 129 + firmware/LUFA/Drivers/Board/ATAVRUSBRF01/Buttons.h | 98 + firmware/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h | 141 + firmware/LUFA/Drivers/Board/BENITO/Buttons.h | 98 + firmware/LUFA/Drivers/Board/BENITO/LEDs.h | 130 + firmware/LUFA/Drivers/Board/BLACKCAT/LEDs.h | 131 + firmware/LUFA/Drivers/Board/BUI/LEDs.h | 132 + firmware/LUFA/Drivers/Board/BUMBLEB/Buttons.h | 103 + firmware/LUFA/Drivers/Board/BUMBLEB/Joystick.h | 120 + firmware/LUFA/Drivers/Board/BUMBLEB/LEDs.h | 143 + firmware/LUFA/Drivers/Board/Buttons.h | 135 + firmware/LUFA/Drivers/Board/CULV3/Buttons.h | 98 + firmware/LUFA/Drivers/Board/CULV3/LEDs.h | 129 + firmware/LUFA/Drivers/Board/Dataflash.h | 212 ++ firmware/LUFA/Drivers/Board/EVK527/AT45DB321C.h | 105 + firmware/LUFA/Drivers/Board/EVK527/Buttons.h | 104 + firmware/LUFA/Drivers/Board/EVK527/Dataflash.h | 184 ++ firmware/LUFA/Drivers/Board/EVK527/Joystick.h | 119 + firmware/LUFA/Drivers/Board/EVK527/LEDs.h | 135 + firmware/LUFA/Drivers/Board/JMDBU2/Buttons.h | 98 + firmware/LUFA/Drivers/Board/JMDBU2/LEDs.h | 129 + firmware/LUFA/Drivers/Board/Joystick.h | 114 + firmware/LUFA/Drivers/Board/LEDs.h | 212 ++ firmware/LUFA/Drivers/Board/MAXIMUS/LEDs.h | 131 + firmware/LUFA/Drivers/Board/MICROSIN162/Buttons.h | 98 + firmware/LUFA/Drivers/Board/MICROSIN162/LEDs.h | 129 + firmware/LUFA/Drivers/Board/MINIMUS/Buttons.h | 97 + firmware/LUFA/Drivers/Board/MINIMUS/LEDs.h | 131 + firmware/LUFA/Drivers/Board/OLIMEX162/Buttons.h | 98 + firmware/LUFA/Drivers/Board/OLIMEX162/LEDs.h | 129 + firmware/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h | 163 + firmware/LUFA/Drivers/Board/STK525/AT45DB321C.h | 105 + firmware/LUFA/Drivers/Board/STK525/Buttons.h | 104 + firmware/LUFA/Drivers/Board/STK525/Dataflash.h | 184 ++ firmware/LUFA/Drivers/Board/STK525/Joystick.h | 119 + firmware/LUFA/Drivers/Board/STK525/LEDs.h | 138 + firmware/LUFA/Drivers/Board/STK526/AT45DB642D.h | 115 + firmware/LUFA/Drivers/Board/STK526/Buttons.h | 104 + firmware/LUFA/Drivers/Board/STK526/Dataflash.h | 184 ++ firmware/LUFA/Drivers/Board/STK526/Joystick.h | 116 + firmware/LUFA/Drivers/Board/STK526/LEDs.h | 138 + firmware/LUFA/Drivers/Board/TEENSY/LEDs.h | 129 + firmware/LUFA/Drivers/Board/Temperature.c | 61 + firmware/LUFA/Drivers/Board/Temperature.h | 125 + firmware/LUFA/Drivers/Board/UDIP/Buttons.h | 98 + firmware/LUFA/Drivers/Board/UDIP/LEDs.h | 154 + firmware/LUFA/Drivers/Board/UNO/LEDs.h | 130 + firmware/LUFA/Drivers/Board/USBFOO/Buttons.h | 98 + firmware/LUFA/Drivers/Board/USBFOO/LEDS.h | 129 + firmware/LUFA/Drivers/Board/USBKEY/AT45DB642D.h | 115 + firmware/LUFA/Drivers/Board/USBKEY/Buttons.h | 98 + firmware/LUFA/Drivers/Board/USBKEY/Dataflash.h | 192 ++ firmware/LUFA/Drivers/Board/USBKEY/Joystick.h | 119 + firmware/LUFA/Drivers/Board/USBKEY/LEDs.h | 137 + firmware/LUFA/Drivers/Board/USBTINYMKII/Buttons.h | 98 + firmware/LUFA/Drivers/Board/USBTINYMKII/LEDs.h | 133 + firmware/LUFA/Drivers/Board/XPLAIN/AT45DB642D.h | 115 + firmware/LUFA/Drivers/Board/XPLAIN/Dataflash.h | 190 ++ firmware/LUFA/Drivers/Board/XPLAIN/LEDs.h | 129 + firmware/LUFA/Drivers/Misc/TerminalCodes.h | 224 ++ firmware/LUFA/Drivers/Peripheral/ADC.h | 72 + firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/ADC.h | 411 +++ firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h | 155 + firmware/LUFA/Drivers/Peripheral/SPI.h | 208 ++ firmware/LUFA/Drivers/Peripheral/Serial.c | 54 + firmware/LUFA/Drivers/Peripheral/Serial.h | 167 + firmware/LUFA/Drivers/Peripheral/SerialStream.c | 54 + firmware/LUFA/Drivers/Peripheral/SerialStream.h | 116 + firmware/LUFA/Drivers/Peripheral/TWI.c | 75 + firmware/LUFA/Drivers/Peripheral/TWI.h | 72 + firmware/LUFA/Drivers/USB/Class/Audio.h | 75 + firmware/LUFA/Drivers/USB/Class/CDC.h | 80 + firmware/LUFA/Drivers/USB/Class/Common/Audio.h | 701 +++++ firmware/LUFA/Drivers/USB/Class/Common/CDC.h | 372 +++ firmware/LUFA/Drivers/USB/Class/Common/HID.h | 451 +++ firmware/LUFA/Drivers/USB/Class/Common/MIDI.h | 293 ++ .../LUFA/Drivers/USB/Class/Common/MassStorage.h | 362 +++ firmware/LUFA/Drivers/USB/Class/Common/Printer.h | 121 + firmware/LUFA/Drivers/USB/Class/Common/RNDIS.h | 399 +++ .../LUFA/Drivers/USB/Class/Common/StillImage.h | 161 + firmware/LUFA/Drivers/USB/Class/Device/Audio.c | 98 + firmware/LUFA/Drivers/USB/Class/Device/Audio.h | 336 +++ firmware/LUFA/Drivers/USB/Class/Device/Audio.lst | 184 ++ firmware/LUFA/Drivers/USB/Class/Device/Audio.o | Bin 0 -> 7724 bytes firmware/LUFA/Drivers/USB/Class/Device/CDC.c | 332 ++ firmware/LUFA/Drivers/USB/Class/Device/CDC.h | 342 +++ firmware/LUFA/Drivers/USB/Class/Device/CDC.lst | 1059 +++++++ firmware/LUFA/Drivers/USB/Class/Device/CDC.o | Bin 0 -> 25224 bytes firmware/LUFA/Drivers/USB/Class/Device/HID.c | 190 ++ firmware/LUFA/Drivers/USB/Class/Device/HID.h | 222 ++ firmware/LUFA/Drivers/USB/Class/Device/HID.lst | 769 +++++ firmware/LUFA/Drivers/USB/Class/Device/HID.o | Bin 0 -> 13920 bytes firmware/LUFA/Drivers/USB/Class/Device/MIDI.c | 148 + firmware/LUFA/Drivers/USB/Class/Device/MIDI.h | 189 ++ firmware/LUFA/Drivers/USB/Class/Device/MIDI.lst | 346 +++ firmware/LUFA/Drivers/USB/Class/Device/MIDI.o | Bin 0 -> 12248 bytes .../LUFA/Drivers/USB/Class/Device/MassStorage.c | 247 ++ .../LUFA/Drivers/USB/Class/Device/MassStorage.h | 177 ++ .../LUFA/Drivers/USB/Class/Device/MassStorage.lst | 643 ++++ .../LUFA/Drivers/USB/Class/Device/MassStorage.o | Bin 0 -> 15196 bytes firmware/LUFA/Drivers/USB/Class/Device/RNDIS.c | 496 +++ firmware/LUFA/Drivers/USB/Class/Device/RNDIS.h | 186 ++ firmware/LUFA/Drivers/USB/Class/Device/RNDIS.lst | 1519 ++++++++++ firmware/LUFA/Drivers/USB/Class/Device/RNDIS.o | Bin 0 -> 23344 bytes firmware/LUFA/Drivers/USB/Class/HID.h | 81 + firmware/LUFA/Drivers/USB/Class/Host/CDC.c | 465 +++ firmware/LUFA/Drivers/USB/Class/Host/CDC.h | 334 ++ firmware/LUFA/Drivers/USB/Class/Host/CDC.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/CDC.o | Bin 0 -> 920 bytes firmware/LUFA/Drivers/USB/Class/Host/HID.c | 387 +++ firmware/LUFA/Drivers/USB/Class/Host/HID.h | 316 ++ firmware/LUFA/Drivers/USB/Class/Host/HID.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/HID.o | Bin 0 -> 920 bytes firmware/LUFA/Drivers/USB/Class/Host/HIDParser.c | 361 +++ firmware/LUFA/Drivers/USB/Class/Host/HIDParser.h | 356 +++ firmware/LUFA/Drivers/USB/Class/Host/HIDParser.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/HIDParser.o | Bin 0 -> 928 bytes .../LUFA/Drivers/USB/Class/Host/HIDReportData.h | 142 + firmware/LUFA/Drivers/USB/Class/Host/MIDI.c | 215 ++ firmware/LUFA/Drivers/USB/Class/Host/MIDI.h | 201 ++ firmware/LUFA/Drivers/USB/Class/Host/MIDI.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/MIDI.o | Bin 0 -> 920 bytes firmware/LUFA/Drivers/USB/Class/Host/MassStorage.c | 629 ++++ firmware/LUFA/Drivers/USB/Class/Host/MassStorage.h | 344 +++ .../LUFA/Drivers/USB/Class/Host/MassStorage.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/MassStorage.o | Bin 0 -> 928 bytes firmware/LUFA/Drivers/USB/Class/Host/Printer.c | 392 +++ firmware/LUFA/Drivers/USB/Class/Host/Printer.h | 282 ++ firmware/LUFA/Drivers/USB/Class/Host/Printer.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/Printer.o | Bin 0 -> 924 bytes firmware/LUFA/Drivers/USB/Class/Host/RNDIS.c | 480 +++ firmware/LUFA/Drivers/USB/Class/Host/RNDIS.h | 290 ++ firmware/LUFA/Drivers/USB/Class/Host/RNDIS.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/RNDIS.o | Bin 0 -> 924 bytes firmware/LUFA/Drivers/USB/Class/Host/StillImage.c | 443 +++ firmware/LUFA/Drivers/USB/Class/Host/StillImage.h | 331 ++ .../LUFA/Drivers/USB/Class/Host/StillImage.lst | 19 + firmware/LUFA/Drivers/USB/Class/Host/StillImage.o | Bin 0 -> 928 bytes firmware/LUFA/Drivers/USB/Class/MIDI.h | 83 + firmware/LUFA/Drivers/USB/Class/MassStorage.h | 80 + firmware/LUFA/Drivers/USB/Class/Printer.h | 77 + firmware/LUFA/Drivers/USB/Class/RNDIS.h | 80 + firmware/LUFA/Drivers/USB/Class/StillImage.h | 75 + .../LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c | 142 + .../LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h | 287 ++ .../Drivers/USB/HighLevel/ConfigDescriptor.lst | 306 ++ .../LUFA/Drivers/USB/HighLevel/ConfigDescriptor.o | Bin 0 -> 8920 bytes .../LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c | 382 +++ .../LUFA/Drivers/USB/HighLevel/DeviceStandardReq.h | 165 + .../Drivers/USB/HighLevel/DeviceStandardReq.lst | 569 ++++ .../LUFA/Drivers/USB/HighLevel/DeviceStandardReq.o | Bin 0 -> 13764 bytes .../LUFA/Drivers/USB/HighLevel/EndpointStream.c | 233 ++ .../LUFA/Drivers/USB/HighLevel/EndpointStream.h | 524 ++++ .../LUFA/Drivers/USB/HighLevel/EndpointStream.lst | 3174 ++++++++++++++++++++ .../LUFA/Drivers/USB/HighLevel/EndpointStream.o | Bin 0 -> 56848 bytes firmware/LUFA/Drivers/USB/HighLevel/Events.c | 39 + firmware/LUFA/Drivers/USB/HighLevel/Events.h | 375 +++ firmware/LUFA/Drivers/USB/HighLevel/Events.lst | 55 + firmware/LUFA/Drivers/USB/HighLevel/Events.o | Bin 0 -> 2904 bytes .../LUFA/Drivers/USB/HighLevel/HostStandardReq.c | 180 ++ .../LUFA/Drivers/USB/HighLevel/HostStandardReq.h | 118 + .../LUFA/Drivers/USB/HighLevel/HostStandardReq.lst | 19 + .../LUFA/Drivers/USB/HighLevel/HostStandardReq.o | Bin 0 -> 932 bytes firmware/LUFA/Drivers/USB/HighLevel/PipeStream.c | 196 ++ firmware/LUFA/Drivers/USB/HighLevel/PipeStream.h | 298 ++ firmware/LUFA/Drivers/USB/HighLevel/PipeStream.lst | 19 + firmware/LUFA/Drivers/USB/HighLevel/PipeStream.o | Bin 0 -> 928 bytes .../LUFA/Drivers/USB/HighLevel/StdDescriptors.h | 692 +++++ .../LUFA/Drivers/USB/HighLevel/StdRequestType.h | 247 ++ .../LUFA/Drivers/USB/HighLevel/StreamCallbacks.h | 87 + .../Template/Template_Endpoint_Control_R.c | 48 + .../Template/Template_Endpoint_Control_W.c | 56 + .../USB/HighLevel/Template/Template_Endpoint_RW.c | 79 + .../USB/HighLevel/Template/Template_Pipe_RW.c | 83 + firmware/LUFA/Drivers/USB/HighLevel/USBMode.h | 138 + firmware/LUFA/Drivers/USB/HighLevel/USBTask.c | 89 + firmware/LUFA/Drivers/USB/HighLevel/USBTask.h | 206 ++ firmware/LUFA/Drivers/USB/HighLevel/USBTask.lst | 88 + firmware/LUFA/Drivers/USB/HighLevel/USBTask.o | Bin 0 -> 5036 bytes firmware/LUFA/Drivers/USB/LowLevel/Device.c | 53 + firmware/LUFA/Drivers/USB/LowLevel/Device.h | 247 ++ firmware/LUFA/Drivers/USB/LowLevel/Device.lst | 64 + firmware/LUFA/Drivers/USB/LowLevel/Device.o | Bin 0 -> 3152 bytes firmware/LUFA/Drivers/USB/LowLevel/Endpoint.c | 141 + firmware/LUFA/Drivers/USB/LowLevel/Endpoint.h | 892 ++++++ firmware/LUFA/Drivers/USB/LowLevel/Endpoint.lst | 283 ++ firmware/LUFA/Drivers/USB/LowLevel/Endpoint.o | Bin 0 -> 9016 bytes firmware/LUFA/Drivers/USB/LowLevel/Host.c | 355 +++ firmware/LUFA/Drivers/USB/LowLevel/Host.h | 527 ++++ firmware/LUFA/Drivers/USB/LowLevel/Host.lst | 19 + firmware/LUFA/Drivers/USB/LowLevel/Host.o | Bin 0 -> 920 bytes firmware/LUFA/Drivers/USB/LowLevel/OTG.h | 155 + firmware/LUFA/Drivers/USB/LowLevel/Pipe.c | 140 + firmware/LUFA/Drivers/USB/LowLevel/Pipe.h | 941 ++++++ firmware/LUFA/Drivers/USB/LowLevel/Pipe.lst | 19 + firmware/LUFA/Drivers/USB/LowLevel/Pipe.o | Bin 0 -> 920 bytes firmware/LUFA/Drivers/USB/LowLevel/USBController.c | 232 ++ firmware/LUFA/Drivers/USB/LowLevel/USBController.h | 471 +++ .../LUFA/Drivers/USB/LowLevel/USBController.lst | 204 ++ firmware/LUFA/Drivers/USB/LowLevel/USBController.o | Bin 0 -> 7632 bytes firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.c | 269 ++ firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.h | 106 + .../LUFA/Drivers/USB/LowLevel/USBInterrupt.lst | 261 ++ firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.o | Bin 0 -> 6936 bytes firmware/LUFA/Drivers/USB/USB.h | 408 +++ firmware/LUFA/License.txt | 18 + firmware/LUFA/ManPages/AboutLUFA.txt | 20 + firmware/LUFA/ManPages/AlternativeStacks.txt | 69 + firmware/LUFA/ManPages/Author.jpg | Bin 0 -> 28410 bytes .../LUFA/ManPages/BuildingLinkableLibraries.txt | 23 + firmware/LUFA/ManPages/ChangeLog.txt | 1099 +++++++ firmware/LUFA/ManPages/CompileTimeTokens.txt | 212 ++ firmware/LUFA/ManPages/CompilingApps.txt | 30 + firmware/LUFA/ManPages/ConfiguringApps.txt | 89 + firmware/LUFA/ManPages/DevelopingWithLUFA.txt | 21 + firmware/LUFA/ManPages/DeviceSupport.txt | 51 + firmware/LUFA/ManPages/DirectorySummaries.txt | 192 ++ firmware/LUFA/ManPages/Donating.txt | 24 + firmware/LUFA/ManPages/FutureChanges.txt | 42 + firmware/LUFA/ManPages/GettingStarted.txt | 27 + firmware/LUFA/ManPages/Groups.txt | 21 + firmware/LUFA/ManPages/LUFA.png | Bin 0 -> 10296 bytes firmware/LUFA/ManPages/LUFAPoweredProjects.txt | 95 + firmware/LUFA/ManPages/LUFAvsAtmelStack.txt | 46 + firmware/LUFA/ManPages/LibraryApps.txt | 116 + firmware/LUFA/ManPages/LibraryResources.txt | 32 + firmware/LUFA/ManPages/LicenseInfo.txt | 22 + firmware/LUFA/ManPages/MainPage.txt | 48 + firmware/LUFA/ManPages/MigrationInformation.txt | 564 ++++ firmware/LUFA/ManPages/ProgrammingApps.txt | 27 + firmware/LUFA/ManPages/SoftwareBootloaderJump.txt | 69 + firmware/LUFA/ManPages/VIDAndPIDValues.txt | 424 +++ firmware/LUFA/ManPages/WhyUseLUFA.txt | 46 + firmware/LUFA/ManPages/WritingBoardDrivers.txt | 27 + firmware/LUFA/Scheduler/Scheduler.c | 99 + firmware/LUFA/Scheduler/Scheduler.h | 313 ++ firmware/LUFA/Version.h | 52 + firmware/LUFA/makefile | 77 + 247 files changed, 48219 insertions(+) create mode 100644 firmware/LUFA/CodeTemplates/DriverStubs/Buttons.h create mode 100644 firmware/LUFA/CodeTemplates/DriverStubs/Dataflash.h create mode 100644 firmware/LUFA/CodeTemplates/DriverStubs/Joystick.h create mode 100644 firmware/LUFA/CodeTemplates/DriverStubs/LEDs.h create mode 100644 firmware/LUFA/CodeTemplates/makefile_template create mode 100644 firmware/LUFA/Common/Attributes.h create mode 100644 firmware/LUFA/Common/BoardTypes.h create mode 100644 firmware/LUFA/Common/Common.h create mode 100644 firmware/LUFA/Doxygen.conf create mode 100644 firmware/LUFA/Drivers/Board/ADAFRUITU4/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/ATAVRUSBRF01/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/BENITO/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/BENITO/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/BLACKCAT/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/BUI/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/BUMBLEB/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/BUMBLEB/Joystick.h create mode 100644 firmware/LUFA/Drivers/Board/BUMBLEB/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/CULV3/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/CULV3/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/Dataflash.h create mode 100644 firmware/LUFA/Drivers/Board/EVK527/AT45DB321C.h create mode 100644 firmware/LUFA/Drivers/Board/EVK527/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/EVK527/Dataflash.h create mode 100644 firmware/LUFA/Drivers/Board/EVK527/Joystick.h create mode 100644 firmware/LUFA/Drivers/Board/EVK527/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/JMDBU2/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/JMDBU2/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/Joystick.h create mode 100644 firmware/LUFA/Drivers/Board/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/MAXIMUS/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/MICROSIN162/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/MICROSIN162/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/MINIMUS/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/MINIMUS/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/OLIMEX162/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/OLIMEX162/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/STK525/AT45DB321C.h create mode 100644 firmware/LUFA/Drivers/Board/STK525/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/STK525/Dataflash.h create mode 100644 firmware/LUFA/Drivers/Board/STK525/Joystick.h create mode 100644 firmware/LUFA/Drivers/Board/STK525/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/STK526/AT45DB642D.h create mode 100644 firmware/LUFA/Drivers/Board/STK526/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/STK526/Dataflash.h create mode 100644 firmware/LUFA/Drivers/Board/STK526/Joystick.h create mode 100644 firmware/LUFA/Drivers/Board/STK526/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/TEENSY/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/Temperature.c create mode 100644 firmware/LUFA/Drivers/Board/Temperature.h create mode 100644 firmware/LUFA/Drivers/Board/UDIP/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/UDIP/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/UNO/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/USBFOO/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/USBFOO/LEDS.h create mode 100644 firmware/LUFA/Drivers/Board/USBKEY/AT45DB642D.h create mode 100644 firmware/LUFA/Drivers/Board/USBKEY/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/USBKEY/Dataflash.h create mode 100644 firmware/LUFA/Drivers/Board/USBKEY/Joystick.h create mode 100644 firmware/LUFA/Drivers/Board/USBKEY/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/USBTINYMKII/Buttons.h create mode 100644 firmware/LUFA/Drivers/Board/USBTINYMKII/LEDs.h create mode 100644 firmware/LUFA/Drivers/Board/XPLAIN/AT45DB642D.h create mode 100644 firmware/LUFA/Drivers/Board/XPLAIN/Dataflash.h create mode 100644 firmware/LUFA/Drivers/Board/XPLAIN/LEDs.h create mode 100644 firmware/LUFA/Drivers/Misc/TerminalCodes.h create mode 100644 firmware/LUFA/Drivers/Peripheral/ADC.h create mode 100644 firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/ADC.h create mode 100644 firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h create mode 100644 firmware/LUFA/Drivers/Peripheral/SPI.h create mode 100644 firmware/LUFA/Drivers/Peripheral/Serial.c create mode 100644 firmware/LUFA/Drivers/Peripheral/Serial.h create mode 100644 firmware/LUFA/Drivers/Peripheral/SerialStream.c create mode 100644 firmware/LUFA/Drivers/Peripheral/SerialStream.h create mode 100644 firmware/LUFA/Drivers/Peripheral/TWI.c create mode 100644 firmware/LUFA/Drivers/Peripheral/TWI.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Audio.h create mode 100644 firmware/LUFA/Drivers/USB/Class/CDC.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/Audio.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/CDC.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/HID.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/MIDI.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/MassStorage.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/Printer.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/RNDIS.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Common/StillImage.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/Audio.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/Audio.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/Audio.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/Audio.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/CDC.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/CDC.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/CDC.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/CDC.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/HID.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/HID.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/HID.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/HID.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MIDI.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MIDI.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MIDI.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MIDI.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MassStorage.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MassStorage.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MassStorage.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/MassStorage.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/RNDIS.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/RNDIS.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/RNDIS.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Device/RNDIS.o create mode 100644 firmware/LUFA/Drivers/USB/Class/HID.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/CDC.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/CDC.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/CDC.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/CDC.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HID.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HID.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HID.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HID.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HIDParser.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HIDParser.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HIDParser.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HIDParser.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/HIDReportData.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MIDI.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MIDI.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MIDI.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MIDI.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MassStorage.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MassStorage.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MassStorage.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/MassStorage.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/Printer.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/Printer.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/Printer.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/Printer.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/RNDIS.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/RNDIS.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/RNDIS.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/RNDIS.o create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/StillImage.c create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/StillImage.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/StillImage.lst create mode 100644 firmware/LUFA/Drivers/USB/Class/Host/StillImage.o create mode 100644 firmware/LUFA/Drivers/USB/Class/MIDI.h create mode 100644 firmware/LUFA/Drivers/USB/Class/MassStorage.h create mode 100644 firmware/LUFA/Drivers/USB/Class/Printer.h create mode 100644 firmware/LUFA/Drivers/USB/Class/RNDIS.h create mode 100644 firmware/LUFA/Drivers/USB/Class/StillImage.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.o create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.o create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.o create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Events.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Events.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Events.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Events.o create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.o create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/PipeStream.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/PipeStream.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/PipeStream.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/PipeStream.o create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/StdDescriptors.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/StdRequestType.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_R.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_W.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_RW.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Pipe_RW.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/USBMode.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/USBTask.c create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/USBTask.h create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/USBTask.lst create mode 100644 firmware/LUFA/Drivers/USB/HighLevel/USBTask.o create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Device.c create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Device.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Device.lst create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Device.o create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Endpoint.c create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Endpoint.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Endpoint.lst create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Endpoint.o create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Host.c create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Host.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Host.lst create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Host.o create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/OTG.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Pipe.c create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Pipe.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Pipe.lst create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/Pipe.o create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBController.c create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBController.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBController.lst create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBController.o create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.c create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.h create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.lst create mode 100644 firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.o create mode 100644 firmware/LUFA/Drivers/USB/USB.h create mode 100644 firmware/LUFA/License.txt create mode 100644 firmware/LUFA/ManPages/AboutLUFA.txt create mode 100644 firmware/LUFA/ManPages/AlternativeStacks.txt create mode 100644 firmware/LUFA/ManPages/Author.jpg create mode 100644 firmware/LUFA/ManPages/BuildingLinkableLibraries.txt create mode 100644 firmware/LUFA/ManPages/ChangeLog.txt create mode 100644 firmware/LUFA/ManPages/CompileTimeTokens.txt create mode 100644 firmware/LUFA/ManPages/CompilingApps.txt create mode 100644 firmware/LUFA/ManPages/ConfiguringApps.txt create mode 100644 firmware/LUFA/ManPages/DevelopingWithLUFA.txt create mode 100644 firmware/LUFA/ManPages/DeviceSupport.txt create mode 100644 firmware/LUFA/ManPages/DirectorySummaries.txt create mode 100644 firmware/LUFA/ManPages/Donating.txt create mode 100644 firmware/LUFA/ManPages/FutureChanges.txt create mode 100644 firmware/LUFA/ManPages/GettingStarted.txt create mode 100644 firmware/LUFA/ManPages/Groups.txt create mode 100644 firmware/LUFA/ManPages/LUFA.png create mode 100644 firmware/LUFA/ManPages/LUFAPoweredProjects.txt create mode 100644 firmware/LUFA/ManPages/LUFAvsAtmelStack.txt create mode 100644 firmware/LUFA/ManPages/LibraryApps.txt create mode 100644 firmware/LUFA/ManPages/LibraryResources.txt create mode 100644 firmware/LUFA/ManPages/LicenseInfo.txt create mode 100644 firmware/LUFA/ManPages/MainPage.txt create mode 100644 firmware/LUFA/ManPages/MigrationInformation.txt create mode 100644 firmware/LUFA/ManPages/ProgrammingApps.txt create mode 100644 firmware/LUFA/ManPages/SoftwareBootloaderJump.txt create mode 100644 firmware/LUFA/ManPages/VIDAndPIDValues.txt create mode 100644 firmware/LUFA/ManPages/WhyUseLUFA.txt create mode 100644 firmware/LUFA/ManPages/WritingBoardDrivers.txt create mode 100644 firmware/LUFA/Scheduler/Scheduler.c create mode 100644 firmware/LUFA/Scheduler/Scheduler.h create mode 100644 firmware/LUFA/Version.h create mode 100644 firmware/LUFA/makefile (limited to 'firmware/LUFA') diff --git a/firmware/LUFA/CodeTemplates/DriverStubs/Buttons.h b/firmware/LUFA/CodeTemplates/DriverStubs/Buttons.h new file mode 100644 index 0000000..33f963f --- /dev/null +++ b/firmware/LUFA/CodeTemplates/DriverStubs/Buttons.h @@ -0,0 +1,86 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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: */ + #include + #include + + // 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 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/firmware/LUFA/CodeTemplates/DriverStubs/Dataflash.h b/firmware/LUFA/CodeTemplates/DriverStubs/Dataflash.h new file mode 100644 index 0000000..e07117f --- /dev/null +++ b/firmware/LUFA/CodeTemplates/DriverStubs/Dataflash.h @@ -0,0 +1,186 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR'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; + } + + /** 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 + * ((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-byte 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/firmware/LUFA/CodeTemplates/DriverStubs/Joystick.h b/firmware/LUFA/CodeTemplates/DriverStubs/Joystick.h new file mode 100644 index 0000000..f542fa3 --- /dev/null +++ b/firmware/LUFA/CodeTemplates/DriverStubs/Joystick.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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, a small surface mount four-way (plus button) digital joystick + on most USB AVR boards. +*/ + +#ifndef __JOYSTICK_USER_H__ +#define __JOYSTICK_USER_H__ + + /* Includes: */ + #include + + // 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 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/firmware/LUFA/CodeTemplates/DriverStubs/LEDs.h b/firmware/LUFA/CodeTemplates/DriverStubs/LEDs.h new file mode 100644 index 0000000..46309a1 --- /dev/null +++ b/firmware/LUFA/CodeTemplates/DriverStubs/LEDs.h @@ -0,0 +1,125 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 USB AVR boards. +*/ + +#ifndef __LEDS_USER_H__ +#define __LEDS_USER_H__ + + /* Includes: */ + #include + + // 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_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/firmware/LUFA/CodeTemplates/makefile_template b/firmware/LUFA/CodeTemplates/makefile_template new file mode 100644 index 0000000..33b47e0 --- /dev/null +++ b/firmware/LUFA/CodeTemplates/makefile_template @@ -0,0 +1,707 @@ +# 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 ### + + +# 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_CLOCK, 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_CLOCK = ### INSERT RAW INPUT CLOCK SPEED 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 TOKES 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 + + +# 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 + + +# 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=c99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += -DF_CLOCK=$(F_CLOCK)UL +CDEFS += -DBOARD=BOARD_$(BOARD) +CDEFS += $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += -DF_CLOCK=$(F_CLOCK)UL +ADEFS += -DBOARD=BOARD_$(BOARD) +ADEFS += $(LUFA_OPTS) + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL +CPPDEFS += -DBOARD=BOARD_$(BOARD) +CPPDEFS += $(LUFA_OPTS) +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS + + + +#---------------- 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 += -mshort-calls +#CFLAGS += -fno-unit-at-a-time +#CFLAGS += -Wundef +#CFLAGS += -Wunreachable-code +#CFLAGS += -Wsign-compare +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 += -fno-exceptions +CPPFLAGS += -Wall +CPPFLAGS += -Wundef +#CPPFLAGS += -mshort-calls +#CPPFLAGS += -fno-unit-at-a-time +#CPPFLAGS += -Wstrict-prototypes +#CPPFLAGS += -Wunreachable-code +#CPPFLAGS += -Wsign-compare +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 $< $@ + +%.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... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +# 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 diff --git a/firmware/LUFA/Common/Attributes.h b/firmware/LUFA/Common/Attributes.h new file mode 100644 index 0000000..053a9b8 --- /dev/null +++ b/firmware/LUFA/Common/Attributes.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 AVR-GCC special function/variable attribute macros. + * + * This file contains macros for applying GCC specific attributes to functions and variables to control various + * optimiser 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 compiler error when used. + * + * \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_GCCAttr Function/Variable Attributes + * + * Macros for easy access GCC function and variable attributes, which can be applied to function prototypes or + * variable attributes. + * + * @{ + */ + +#ifndef __FUNCATTR_H__ +#define __FUNCATTR_H__ + + /* Preprocessor Checks: */ + #if !defined(__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 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 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 inlining. When applied, the given + * function will not be inlined under any circumstances. + */ + #define ATTR_NO_INLINE __attribute__ ((noinline)) + + /** Forces the compiler to inline the specified function. When applied, the given function will be + * inlined 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)) + + /** 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"))) + #endif + + /** 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__ ((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 ))) +#endif + +/** @} */ + diff --git a/firmware/LUFA/Common/BoardTypes.h b/firmware/LUFA/Common/BoardTypes.h new file mode 100644 index 0000000..7a9bb59 --- /dev/null +++ b/firmware/LUFA/Common/BoardTypes.h @@ -0,0 +1,151 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 board hardware defines. + * + * This file contains constants which can be passed to the compiler (via setting the macro BOARD) in the + * user project makefile using the -D option to configure the library board-specific drivers. + * + * \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 + * + * Macros for indicating the chosen physical board hardware to the library. These macros should be used when + * defining the BOARD token to the chosen hardware via the -D switch in the project makefile. + * + * @{ + */ + +#ifndef __BOARDTYPES_H__ +#define __BOARDTYPES_H__ + + /* Preprocessor Checks: */ + #if !defined(__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 USBKEY specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_USBKEY 0 + + /** Selects the STK525 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_STK525 1 + + /** Selects the STK526 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_STK526 2 + + /** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */ + #define BOARD_RZUSBSTICK 3 + + /** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */ + #define BOARD_ATAVRUSBRF01 4 + + /** Selects the user-defined board drivers, which should be placed in the user project's folder + * under a directory named /Board/. Each board driver should be named identically to the LUFA + * master board driver (i.e., driver in the LUFA/Drivers/Board director) so that the library + * can correctly identify it. + */ + #define BOARD_USER 5 + + /** Selects the BUMBLEB specific board drivers, using the officially recommended peripheral layout. */ + #define BOARD_BUMBLEB 6 + + /** Selects the XPLAIN (Revision 2 or newer) specific board drivers, including LED and Dataflash driver. */ + #define BOARD_XPLAIN 7 + + /** Selects the XPLAIN (Revision 1) specific board drivers, including LED and Dataflash driver. */ + #define BOARD_XPLAIN_REV1 8 + + /** Selects the EVK527 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_EVK527 9 + + /** 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 10 + + /** Selects the Teensy (all versions) 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 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 + + #if !defined(__DOXYGEN__) + #define BOARD_ BOARD_NONE + + #if !defined(BOARD) + #define BOARD BOARD_NONE + #endif + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Common/Common.h b/firmware/LUFA/Common/Common.h new file mode 100644 index 0000000..3c3fd0d --- /dev/null +++ b/firmware/LUFA/Common/Common.h @@ -0,0 +1,253 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 macros and functions. + * + * This file contains macros which are common to all library elements, and which may be useful in user code. It + * also includes other common headers, such as Atomic.h, Attributes.h and BoardTypes.h. + */ + +/** @defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h + * + * Common utility headers containing macros, functions, enums and types which are common to all + * aspects of the library. + * + * @{ + */ + +/** @defgroup Group_Debugging Debugging Macros + * + * Macros for debugging use. + */ + +/** @defgroup Group_BitManip Endian and Bit Macros + * + * Functions for swapping endianness and reversing bit orders. + */ + +#ifndef __COMMON_H__ +#define __COMMON_H__ + + /* Includes: */ + #include + #include + + #include "Attributes.h" + #include "BoardTypes.h" + + /* 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 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 IF statements). + */ + #define MACROE while (0) + + /** Defines a volatile 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 optimiser + * removes/reorders code to the point where break points cannot reliably be set. + * + * \ingroup Group_Debugging + */ + #define JTAG_DEBUG_POINT() __asm__ volatile ("NOP" ::) + + /** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statement. When + * a JTAG is used, this causes the program execution to halt when reached until manually resumed. + * + * \ingroup Group_Debugging + */ + #define JTAG_DEBUG_BREAK() __asm__ volatile ("BREAK" ::) + + /** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false. + * + * \ingroup Group_Debugging + */ + #define JTAG_DEBUG_ASSERT(x) MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE + + /** Macro for testing condition "x" and writing debug data to the stdout stream if false. The stdout stream + * must be pre-initialized before this macro is run and linked to an output device, such as the AVR's USART + * peripheral. + * + * The output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion {x} failed." + * + * \ingroup Group_Debugging + */ + #define STDOUT_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \ + "Assertion \"%s\" failed.\r\n"), \ + __FILE__, __func__, __LINE__, #x); } }MACROE + + #if !defined(pgm_read_ptr) || defined(__DOXYGEN__) + /** Reads a pointer out of PROGMEM space. This is currently a wrapper for the avr-libc pgm_read_ptr() + * macro with a 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. + * + * \param[in] Addr Address of the pointer to read. + * + * \return Pointer retrieved from PROGMEM space. + */ + #define pgm_read_ptr(Addr) (void*)pgm_read_word(Addr) + #endif + + /** 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. + * + * \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) ((((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. + * + * \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) ((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \ + (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL)) + + /* 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. + * + * \ingroup Group_BitManip + * + * \param[in] Byte Byte of data whose bits are to be reversed. + */ + 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 reverse the byte ordering of the individual bytes in a 16 bit number. + * + * \ingroup Group_BitManip + * + * \param[in] Word Word of data whose bytes are to be swapped. + */ + 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) + { + 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 number. + * + * \ingroup Group_BitManip + * + * \param[in] DWord Double word of data whose bytes are to be swapped. + */ + 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) + { + 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 number. + * + * \ingroup Group_BitManip + * + * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed. + * \param[in] Bytes Length of the data in bytes. + */ + static inline void SwapEndian_n(void* Data, + uint8_t Bytes) ATTR_NON_NULL_PTR_ARG(1); + static inline void SwapEndian_n(void* Data, + uint8_t Bytes) + { + uint8_t* CurrDataPos = (uint8_t*)Data; + + while (Bytes > 1) + { + uint8_t Temp = *CurrDataPos; + *CurrDataPos = *(CurrDataPos + Bytes - 1); + *(CurrDataPos + Bytes - 1) = Temp; + + CurrDataPos++; + Bytes -= 2; + } + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Doxygen.conf b/firmware/LUFA/Doxygen.conf new file mode 100644 index 0000000..933e3c1 --- /dev/null +++ b/firmware/LUFA/Doxygen.conf @@ -0,0 +1,1564 @@ +# Doxyfile 1.6.2 + +# 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 (Formerly MyUSB) 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 + +# 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-Cyrilic, 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 is your file systems +# 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, C#, 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 make 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 to 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 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 penality. +# 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 rougly 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 = 1 + +#--------------------------------------------------------------------------- +# 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 namespace 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 + +# 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 define 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 defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# 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 + +# This WARN_NO_PARAMDOC option can be abled 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++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +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 filesystem 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, INPUT_FILTER +# is applied to all files. + +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 + +#--------------------------------------------------------------------------- +# 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. + +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 = + +# 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 = + +# 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 + +# 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 + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +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 = NO + +# 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 + +# 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 + +# 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 disadvances is 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, a4wide, 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 = + +# 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 +# in the INCLUDE_PATH (see below) will be search if 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 + +# 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. + +EXPAND_AS_DEFINED = __CALLBACK_PARAM + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and 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 is superseded by the HAVE_DOT option below. This is only a +# fallback. 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 + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need 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 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 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 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/firmware/LUFA/Drivers/Board/ADAFRUITU4/LEDs.h b/firmware/LUFA/Drivers/Board/ADAFRUITU4/LEDs.h new file mode 100644 index 0000000..39b6256 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/ADAFRUITU4/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Adafruit U4 Breakout board. + * + * Board specific LED driver header for the Adafruit U4 Breakout board (http://ladyada.net/products/atmega32u4breakout). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_ADAFRUITU4 ADAFRUITU4 + * + * Board specific LED driver header for the Adafruit U4 Breakout board (http://ladyada.net/products/atmega32u4breakout). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_ADAFRUITU4_H__ +#define __LEDS_ADAFRUITU4_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 6) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for the none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRE |= LEDS_ALL_LEDS; + PORTE &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTE |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTE &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTE = ((PORTE & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTE = ((PORTE & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTE = (PORTE ^ (LEDMask & LEDS_ALL_LEDS)); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTE & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/ATAVRUSBRF01/Buttons.h b/firmware/LUFA/Drivers/Board/ATAVRUSBRF01/Buttons.h new file mode 100644 index 0000000..80063bd --- /dev/null +++ b/firmware/LUFA/Drivers/Board/ATAVRUSBRF01/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Atmel ATAVRUSBRF01. + * + * Board specific Buttons driver header for the Atmel ATAVRUSBRF01. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_ATAVRUSBRF01 ATAVRUSBRF01 + * + * Board specific Buttons driver header for the Atmel ATAVRUSBRF01. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_ATAVRUSBRF01_H__ +#define __BUTTONS_ATAVRUSBRF01_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h b/firmware/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h new file mode 100644 index 0000000..f52df99 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/ATAVRUSBRF01/LEDs.h @@ -0,0 +1,141 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel ATAVRUSBRF01. + * + * Board specific LED driver header for the Atmel ATAVRUSBRF01. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_ATAVRUSBRF01 ATAVRUSBRF01 + * + * Board specific LED driver header for the Atmel ATAVRUSBRF01. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_ATAVRUSBRF01_H__ +#define __LEDS_ATAVRUSBRF01_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2) + #define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4) + + #define LEDS_PORTE_MASK_SHIFT 4 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 0) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 1) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= (LEDMask & LEDS_ALL_LEDS); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~(LEDMask & LEDS_ALL_LEDS); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = (PORTD & ~LEDS_ALL_LEDS) | (LEDMask & LEDS_ALL_LEDS); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/BENITO/Buttons.h b/firmware/LUFA/Drivers/Board/BENITO/Buttons.h new file mode 100644 index 0000000..d47e017 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BENITO/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Tempusdictum Benito. + * + * Board specific Buttons driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_BENITO BENITO + * + * Board specific Buttons driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_BENITO_H__ +#define __BUTTONS_BENITO_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/BENITO/LEDs.h b/firmware/LUFA/Drivers/Board/BENITO/LEDs.h new file mode 100644 index 0000000..72c0d24 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BENITO/LEDs.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Tempusdictum Benito. + * + * Board specific LED driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_BENITO BENITO + * + * Board specific LED driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_BENITO_H__ +#define __LEDS_BENITO_H__ + + /* Includes: */ + #include + + /* 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 (1 << 7) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 6) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRC |= LEDS_ALL_LEDS; + PORTC |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTC &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTC |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTC = ((PORTC | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTC = ((PORTC | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTC ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTC & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/BLACKCAT/LEDs.h b/firmware/LUFA/Drivers/Board/BLACKCAT/LEDs.h new file mode 100644 index 0000000..8ca1b95 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BLACKCAT/LEDs.h @@ -0,0 +1,131 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the BLACKCAT USB JTAG. + * + * Board specific LED driver header for the TCNISO Blackcat USB JTAG (http://www.embeddedcomputers.net/products/BlackcatUSB/. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_BLACKCAT BLACKCAT + * + * Board specific LED driver header for the TCNISO Blackcat USB JTAG (http://www.embeddedcomputers.net/products/BlackcatUSB/. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_BLACKCAT_H__ +#define __LEDS_BLACKCAT_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 6) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 3) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/firmware/LUFA/Drivers/Board/BUI/LEDs.h b/firmware/LUFA/Drivers/Board/BUI/LEDs.h new file mode 100644 index 0000000..b1e3a99 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BUI/LEDs.h @@ -0,0 +1,132 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Busware BUI. + * + * Board specific LED driver header for the Busware BUI (http://www.busware.de/tiki-index.php?page=BUI). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_BUI BUI + * + * Board specific LED driver header for the Busware BUI (http://www.busware.de/tiki-index.php?page=BUI). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_BUI_H__ +#define __LEDS_BUI_H__ + + /* Includes: */ + #include + +/* 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 (1 << 2) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 3) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRC |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTC |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTC &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTC = (PORTC & ~LEDS_ALL_LEDS) | LEDMask; + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTC = (PORTC & ~LEDMask) | ActiveMask; + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTC ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTC & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/BUMBLEB/Buttons.h b/firmware/LUFA/Drivers/Board/BUMBLEB/Buttons.h new file mode 100644 index 0000000..b4c1f80 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BUMBLEB/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Fletchtronics BUMBLEB. + * + * Board specific Buttons driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). + * + * The BUMBLEB third-party board does not include any on-board peripherals, but does have an officially recommended + * external peripheral layout for buttons, LEDs and a Joystick. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_BUMBLEB BUMBLEB + * + * Board specific buttons driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB + * third-party board does not include any on-board peripherals, but does have an officially recommended external peripheral + * layout for buttons, LEDs and a Joystick. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_BUMBLEB_H__ +#define __BUTTONS_BUMBLEB_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/BUMBLEB/Joystick.h b/firmware/LUFA/Drivers/Board/BUMBLEB/Joystick.h new file mode 100644 index 0000000..7197726 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BUMBLEB/Joystick.h @@ -0,0 +1,120 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific joystick driver header for the Fletchtronics BUMLEB. + * + * Board specific joystick driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). + * + * The BUMBLEB third-party board does not include any on-board peripherals, but does have an officially recommended + * external peripheral layout for buttons, LEDs and a Joystick. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + */ + +/** \ingroup Group_Joystick + * @defgroup Group_Joystick_BUMBLEB BUMBLEB + * + * Board specific joystick driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB + * third-party board does not include any on-board peripherals, but does have an officially recommended external peripheral + * layout for buttons, LEDs and a Joystick. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + * + * @{ + */ + +#ifndef __JOYSTICK_BUMBLEB_H__ +#define __JOYSTICK_BUMBLEB_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define JOY_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1 << 2) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1 << 3) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT (1 << 0) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN (1 << 1) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1 << 4) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + DDRD &= ~JOY_MASK; + PORTD |= JOY_MASK; + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + return (uint8_t)(~PIND & JOY_MASK); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/BUMBLEB/LEDs.h b/firmware/LUFA/Drivers/Board/BUMBLEB/LEDs.h new file mode 100644 index 0000000..839f188 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/BUMBLEB/LEDs.h @@ -0,0 +1,143 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Fletchtronics BUMBLEB. + * + * Board specific LED driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). + * + * The BUMBLEB third-party board does not include any on-board peripherals, but does have an officially recommended + * external peripheral layout for buttons, LEDs and a Joystick. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_BUMBLEB BUMBLEB + * + * Board specific LED driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB + * third-party board does not include any on-board peripherals, but does have an officially recommended external + * peripheral layout for buttons, LEDs and a Joystick. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_BUMBLEB_H__ +#define __LEDS_BUMBLEB_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 5) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 6) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1 << 7) + + /** 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) + { + DDRB |= LEDS_ALL_LEDS; + PORTB &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LedMask) + { + PORTB |= LedMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LedMask) + { + PORTB &= ~LedMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LedMask) + { + PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LedMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LedMask, + const uint8_t ActiveMask) + { + PORTB = ((PORTB & ~LedMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTB ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTB & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/Buttons.h b/firmware/LUFA/Drivers/Board/Buttons.h new file mode 100644 index 0000000..57fcc63 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/Buttons.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 board digital button driver. + * + * This file is the master dispatch header file for the board-specific Buttons driver, for boards containing + * physical pushbuttons connected to the AVR's GPIO pins. + * + * User code should include this file, which will in turn include the correct Button driver header file for the + * currently selected board. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Buttons.h file in the user project + * directory. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * @defgroup Group_Buttons Buttons Driver - LUFA/Drivers/Board/Buttons.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Hardware buttons driver. This provides an easy to use driver for the hardware buttons present on many boards. + * It provides a way to easily configure and check the status of all the buttons on the board so that appropriate + * actions can be taken. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + * + * @{ + */ + +#ifndef __BUTTONS_H__ +#define __BUTTONS_H__ + + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_BUTTONS_H + #define INCLUDE_FROM_BUTTONS_H + #endif + + /* Includes: */ + #include "../../Common/Common.h" + + #if (BOARD == BOARD_NONE) + #error The Board Buttons driver cannot be used if the makefile BOARD option is not set. + #elif (BOARD == BOARD_USBKEY) + #include "USBKEY/Buttons.h" + #elif (BOARD == BOARD_STK525) + #include "STK525/Buttons.h" + #elif (BOARD == BOARD_STK526) + #include "STK526/Buttons.h" + #elif (BOARD == BOARD_ATAVRUSBRF01) + #include "ATAVRUSBRF01/Buttons.h" + #elif (BOARD == BOARD_BUMBLEB) + #include "BUMBLEB/Buttons.h" + #elif (BOARD == BOARD_EVK527) + #include "EVK527/Buttons.h" + #elif (BOARD == BOARD_USBTINYMKII) + #include "USBTINYMKII/Buttons.h" + #elif (BOARD == BOARD_BENITO) + #include "BENITO/Buttons.h" + #elif (BOARD == BOARD_JMDBU2) + #include "JMDBU2/Buttons.h" + #elif (BOARD == BOARD_OLIMEX162) + #include "OLIMEX162/Buttons.h" + #elif (BOARD == BOARD_USBFOO) + #include "USBFOO/Buttons.h" + #elif (BOARD == BOARD_UDIP) + #include "UDIP/Buttons.h" + #elif (BOARD == BOARD_CULV3) + #include "CULV3/Buttons.h" + #elif (BOARD == BOARD_MINIMUS) + #include "MINIMUS/Buttons.h" + #elif (BOARD == BOARD_MICROSIN162) + #include "MICROSIN162/Buttons.h" + #elif (BOARD == BOARD_USER) + #include "Board/Buttons.h" + #else + #error The selected board does not contain any GPIO buttons. + #endif + + /* Pseudo-Functions for Doxygen: */ + #if defined(__DOXYGEN__) + /** Initialises the BUTTONS driver, so that the current button position can be read. This sets the appropriate + * I/O pins to an inputs with pull-ups enabled. + * + * This must be called before any Button driver functions are used. + */ + static inline void Buttons_Init(void); + + /** Returns a mask indicating which board buttons are currently pressed. + * + * \return Mask indicating which board buttons are currently pressed. + */ + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/CULV3/Buttons.h b/firmware/LUFA/Drivers/Board/CULV3/Buttons.h new file mode 100644 index 0000000..088559a --- /dev/null +++ b/firmware/LUFA/Drivers/Board/CULV3/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Busware CULV3. + * + * Board specific LED driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_CULV3 CULV3 + * + * Board specific LED driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __BUTTONS_CULV3_H__ +#define __BUTTONS_CULV3_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 2) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRE &= ~BUTTONS_BUTTON1; + PORTE |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/CULV3/LEDs.h b/firmware/LUFA/Drivers/Board/CULV3/LEDs.h new file mode 100644 index 0000000..52fd337 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/CULV3/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Busware CUL V3. + * + * Board specific LED driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_CULV3 CULV3 + * + * Board specific LED driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_CULV3_H__ +#define __LEDS_CULV3_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 6) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for the none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRE |= LEDS_ALL_LEDS; + PORTE &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTE |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTE &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTE = ((PORTE & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTE = ((PORTE & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTE = (PORTE ^ (LEDMask & LEDS_ALL_LEDS)); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTE & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/Dataflash.h b/firmware/LUFA/Drivers/Board/Dataflash.h new file mode 100644 index 0000000..9c6bb8b --- /dev/null +++ b/firmware/LUFA/Drivers/Board/Dataflash.h @@ -0,0 +1,212 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 board dataflash IC driver. + * + * This file is the master dispatch header file for the board-specific dataflash driver, for boards containing + * dataflash ICs for external non-volatile storage. + * + * User code should include this file, which will in turn include the correct dataflash driver header file for + * the currently selected board. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project + * directory. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * @defgroup Group_Dataflash Dataflash Driver - LUFA/Drivers/Board/Dataflash.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Dataflash driver. This module provides an easy to use interface for the Dataflash ICs located on many boards, + * for the storage of large amounts of data into the Dataflash's non-volatile memory. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + * + * @{ + */ + +#ifndef __DATAFLASH_H__ +#define __DATAFLASH_H__ + + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_DATAFLASH_H + #define INCLUDE_FROM_DATAFLASH_H + #endif + + /* Includes: */ + #include "../Peripheral/SPI.h" + #include "../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __GET_DATAFLASH_MASK2(x, y) x ## y + #define __GET_DATAFLASH_MASK(x) __GET_DATAFLASH_MASK2(DATAFLASH_CHIP,x) + #endif + + /** Retrieves the Dataflash chip select mask for the given Dataflash chip index. + * + * \param[in] index Index of the dataflash chip mask to retrieve + * + * \return Mask for the given Dataflash chip's /CS pin + */ + #define DATAFLASH_CHIP_MASK(index) __GET_DATAFLASH_MASK(index) + + /* Inline Functions: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void); + + /** 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; + + /** 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; + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + + /** 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 + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress); + + /** 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); + + /** 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); + + /** 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-byte 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); + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] 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) + { + return SPI_TransferByte(Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] 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) + { + SPI_SendByte(Byte); + } + + /** 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) + { + return SPI_ReceiveByte(); + } + + /* Includes: */ + #if (BOARD == BOARD_NONE) + #error The Board Buttons driver cannot be used if the makefile BOARD option is not set. + #elif (BOARD == BOARD_USBKEY) + #include "USBKEY/Dataflash.h" + #elif (BOARD == BOARD_STK525) + #include "STK525/Dataflash.h" + #elif (BOARD == BOARD_STK526) + #include "STK526/Dataflash.h" + #elif (BOARD == BOARD_XPLAIN) + #include "XPLAIN/Dataflash.h" + #elif (BOARD == BOARD_XPLAIN_REV1) + #include "XPLAIN/Dataflash.h" + #elif (BOARD == BOARD_EVK527) + #include "EVK527/Dataflash.h" + #elif (BOARD == BOARD_USER) + #include "Board/Dataflash.h" + #else + #error The selected board does not contain a dataflash IC. + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/EVK527/AT45DB321C.h b/firmware/LUFA/Drivers/Board/EVK527/AT45DB321C.h new file mode 100644 index 0000000..9bcf510 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/EVK527/AT45DB321C.h @@ -0,0 +1,105 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash commands header for the AT45DB321C as mounted on the Atmel EVK527. + * + * Board specific Dataflash commands header for the AT45DB321C as mounted on the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash_EVK527 + * @defgroup Group_Dataflash_EVK527_AT45DB321C AT45DB321C + * + * Board specific Dataflash commands header for the AT45DB321C as mounted on the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_CMDS_H__ +#define __DATAFLASH_CMDS_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Dataflash Status Values */ + //@{ + #define DF_STATUS_READY (1 << 7) + #define DF_STATUS_COMPMISMATCH (1 << 6) + #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) + //@} + + #define DF_MANUFACTURER_ATMEL 0x1F + + /** \name Dataflash Commands */ + //@{ + #define DF_CMD_GETSTATUS 0xD7 + + #define DF_CMD_MAINMEMTOBUFF1 0x53 + #define DF_CMD_MAINMEMTOBUFF2 0x55 + #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 + #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 + #define DF_CMD_AUTOREWRITEBUFF1 0x58 + #define DF_CMD_AUTOREWRITEBUFF2 0x59 + + #define DF_CMD_MAINMEMPAGEREAD 0xD2 + #define DF_CMD_CONTARRAYREAD_LF 0xE8 + #define DF_CMD_BUFF1READ_LF 0xD4 + #define DF_CMD_BUFF2READ_LF 0xD6 + + #define DF_CMD_BUFF1WRITE 0x84 + #define DF_CMD_BUFF2WRITE 0x87 + #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 + #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 + #define DF_CMD_BUFF1TOMAINMEM 0x88 + #define DF_CMD_BUFF2TOMAINMEM 0x89 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 + + #define DF_CMD_PAGEERASE 0x81 + #define DF_CMD_BLOCKERASE 0x50 + + #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF}) + #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D + #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A + #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F + #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF + + #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F + //@} + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/EVK527/Buttons.h b/firmware/LUFA/Drivers/Board/EVK527/Buttons.h new file mode 100644 index 0000000..4f6b536 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/EVK527/Buttons.h @@ -0,0 +1,104 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Atmel EVK527. + * + * Board specific Buttons driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_EVK527 EVK527 + * + * Board specific Buttons driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_EVK527_H__ +#define __BUTTONS_EVK527_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 2) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRE &= ~BUTTONS_BUTTON1; + PORTE |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/EVK527/Dataflash.h b/firmware/LUFA/Drivers/Board/EVK527/Dataflash.h new file mode 100644 index 0000000..9f6c6d8 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/EVK527/Dataflash.h @@ -0,0 +1,184 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash driver header for the Atmel EVK527. + * + * Board specific Dataflash driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash + * @defgroup Group_Dataflash_EVK527 EVK527 + * + * Board specific Dataflash driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_EVK527_H__ +#define __DATAFLASH_EVK527_H__ + + /* Includes: */ + #include "AT45DB321C.h" + + /* 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 (1 << 6) + #define DATAFLASH_CHIPCS_DDR DDRE + #define DATAFLASH_CHIPCS_PORT PORTE + #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 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 0 + + /** Internal main memory page size for the board's dataflash IC. */ + #define DATAFLASH_PAGE_SIZE 512 + + /** Total number of pages inside the board's dataflash IC. */ + #define DATAFLASH_PAGES 8192 + + /* Inline Functions: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR'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; + } + + /** 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 + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + return; + + Dataflash_SelectChip(DATAFLASH_CHIP1); + } + + /** 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-byte 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) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/EVK527/Joystick.h b/firmware/LUFA/Drivers/Board/EVK527/Joystick.h new file mode 100644 index 0000000..06c14fe --- /dev/null +++ b/firmware/LUFA/Drivers/Board/EVK527/Joystick.h @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific joystick driver header for the Atmel EVK527. + * + * Board specific joystick driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + */ + +/** \ingroup Group_Joystick + * @defgroup Group_Joystick_EVK527 EVK527 + * + * Board specific joystick driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + * + * @{ + */ + +#ifndef __JOYSTICK_EVK527_H__ +#define __JOYSTICK_EVK527_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define JOY_FMASK ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7)) + #define JOY_CMASK (1 << 6)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1 << 4) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT (1 << 7) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1 << 5) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN ((1 << 6) >> 3) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1 << 6) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + DDRF &= ~(JOY_FMASK); + DDRC &= ~(JOY_CMASK); + + PORTF |= JOY_FMASK; + PORTC |= JOY_CMASK; + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + return (((uint8_t)~PINF & JOY_FMASK) | (((uint8_t)~PINC & JOY_CMASK) >> 3)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/EVK527/LEDs.h b/firmware/LUFA/Drivers/Board/EVK527/LEDs.h new file mode 100644 index 0000000..0ac7a53 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/EVK527/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel EVK527. + * + * Board specific LED driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_EVK527 EVK527 + * + * Board specific LED driver header for the Atmel EVK527. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_EVK527_H__ +#define __LEDS_EVK527_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 5) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 6) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 7) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/JMDBU2/Buttons.h b/firmware/LUFA/Drivers/Board/JMDBU2/Buttons.h new file mode 100644 index 0000000..eacece7 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/JMDBU2/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Mattairtech JM-DB-U2. + * + * Board specific Buttons driver header for the Mattairtech JM-DB-U2 (http://u2.mattair.net/index.html). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_JMDBU2 JMDBU2 + * + * Board specific Buttons driver header for the Mattairtech JM-DB-U2 (http://u2.mattair.net/index.html). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_JMDBU2_H__ +#define __BUTTONS_JMDBU2_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/JMDBU2/LEDs.h b/firmware/LUFA/Drivers/Board/JMDBU2/LEDs.h new file mode 100644 index 0000000..46ac849 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/JMDBU2/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Mattairtech JM-DB-U2. + * + * Board specific LED driver header for the Mattairtech JM-DB-U2 (http://u2.mattair.net/index.html). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_JMDBU2 JMDBU2 + * + * Board specific LED driver header for the Mattairtech JM-DB-U2 (http://u2.mattair.net/index.html). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_JMDBU2_H__ +#define __LEDS_JMDBU2_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/Joystick.h b/firmware/LUFA/Drivers/Board/Joystick.h new file mode 100644 index 0000000..e43110a --- /dev/null +++ b/firmware/LUFA/Drivers/Board/Joystick.h @@ -0,0 +1,114 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 board digital joystick driver. + * + * This file is the master dispatch header file for the board-specific Joystick driver, for boards containing a + * 5-way joystick. + * + * User code should include this file, which will in turn include the correct joystick driver header file for the + * currently selected board. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Joystick.h file in the user project + * directory. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * @defgroup Group_Joystick Joystick Driver - LUFA/Drivers/Board/Joystick.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Hardware Joystick driver. This module provides an easy to use interface to control the hardware digital Joystick + * located on many boards. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + * + * @{ + */ + +#ifndef __JOYSTICK_H__ +#define __JOYSTICK_H__ + + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_JOYSTICK_H + #define INCLUDE_FROM_JOYSTICK_H + #endif + + /* Includes: */ + #include "../../Common/Common.h" + + #if (BOARD == BOARD_NONE) + #error The Board Joystick driver cannot be used if the makefile BOARD option is not set. + #elif (BOARD == BOARD_USBKEY) + #include "USBKEY/Joystick.h" + #elif (BOARD == BOARD_STK525) + #include "STK525/Joystick.h" + #elif (BOARD == BOARD_STK526) + #include "STK526/Joystick.h" + #elif (BOARD == BOARD_BUMBLEB) + #include "BUMBLEB/Joystick.h" + #elif (BOARD == BOARD_EVK527) + #include "EVK527/Joystick.h" + #elif (BOARD == BOARD_USER) + #include "Board/Joystick.h" + #else + #error The selected board does not contain a joystick. + #endif + + /* Pseudo-Functions for Doxygen: */ + #if defined(__DOXYGEN__) + /** Initialises the joystick driver so that the joystick position can be read. This sets the appropriate + * I/O pins to inputs with their pull-ups enabled. + */ + static inline void Joystick_Init(void); + + /** Returns the current status of the joystick, as a mask indicating the direction the joystick is + * currently facing in (multiple bits can be set). + * + * \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file + * for direction masks. + */ + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/LEDs.h b/firmware/LUFA/Drivers/Board/LEDs.h new file mode 100644 index 0000000..72ed729 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/LEDs.h @@ -0,0 +1,212 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 board LEDs driver. + * + * This file is the master dispatch header file for the board-specific LED driver, for boards containing user + * controllable LEDs. + * + * User code should include this file, which will in turn include the correct LED driver header file for the + * currently selected board. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/LEDs.h file in the user project + * directory. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * @defgroup Group_LEDs LEDs Driver - LUFA/Drivers/Board/LEDs.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Hardware LEDs driver. This provides an easy to use driver for the hardware LEDs present on many boards. It + * provides an interface to configure, test and change the status of all the board LEDs. + * + * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. If the BOARD value + * is set to BOARD_NONE, this driver is silently disabled. + * + * For possible BOARD makefile values, see \ref Group_BoardTypes. + * + * \note To make code as compatible as possible, it is assumed that all boards carry a minimum of four LEDs. If + * a board contains less than four LEDs, the remaining LED masks are defined to 0 so as to have no effect. + * If other behaviour is desired, either alias the remaining LED masks to existing LED masks via the -D + * switch in the project makefile, or alias them to nothing in the makefile to cause compilation errors when + * a non-existing LED is referenced in application code. Note that this means that it is possible to make + * compatible code for a board with no LEDs by making a board LED driver (see \ref Page_WritingBoardDrivers) + * which contains only stub functions and defines no LEDs. + * + * @{ + */ + +#ifndef __LEDS_H__ +#define __LEDS_H__ + + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_LEDS_H + #define INCLUDE_FROM_LEDS_H + #endif + + /* Includes: */ + #include "../../Common/Common.h" + + #if (BOARD == BOARD_NONE) + static inline void LEDs_Init(void) {}; + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) {}; + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) {}; + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) {}; + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) {}; + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) {}; + static inline uint8_t LEDs_GetLEDs(void) { return 0; } + #elif (BOARD == BOARD_USBKEY) + #include "USBKEY/LEDs.h" + #elif (BOARD == BOARD_STK525) + #include "STK525/LEDs.h" + #elif (BOARD == BOARD_STK526) + #include "STK526/LEDs.h" + #elif (BOARD == BOARD_RZUSBSTICK) + #include "RZUSBSTICK/LEDs.h" + #elif (BOARD == BOARD_ATAVRUSBRF01) + #include "ATAVRUSBRF01/LEDs.h" + #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) + #include "XPLAIN/LEDs.h" + #elif (BOARD == BOARD_BUMBLEB) + #include "BUMBLEB/LEDs.h" + #elif (BOARD == BOARD_EVK527) + #include "EVK527/LEDs.h" + #elif (BOARD == BOARD_TEENSY) + #include "TEENSY/LEDs.h" + #elif (BOARD == BOARD_USBTINYMKII) + #include "USBTINYMKII/LEDs.h" + #elif (BOARD == BOARD_BENITO) + #include "BENITO/LEDs.h" + #elif (BOARD == BOARD_JMDBU2) + #include "JMDBU2/LEDs.h" + #elif (BOARD == BOARD_OLIMEX162) + #include "OLIMEX162/LEDs.h" + #elif (BOARD == BOARD_USBFOO) + #include "USBFOO/LEDs.h" + #elif (BOARD == BOARD_UDIP) + #include "UDIP/LEDs.h" + #elif (BOARD == BOARD_BUI) + #include "BUI/LEDs.h" + #elif (BOARD == BOARD_UNO) + #include "UNO/LEDs.h" + #elif (BOARD == BOARD_CULV3) + #include "CULV3/LEDs.h" + #elif (BOARD == BOARD_BLACKCAT) + #include "BLACKCAT/LEDs.h" + #elif (BOARD == BOARD_MAXIMUS) + #include "MAXIMUS/LEDs.h" + #elif (BOARD == BOARD_MINIMUS) + #include "MINIMUS/LEDs.h" + #elif (BOARD == BOARD_ADAFRUITU4) + #include "ADAFRUITU4/LEDs.h" + #elif (BOARD == BOARD_MICROSIN162) + #include "MICROSIN162/LEDs.h" + #elif (BOARD == BOARD_USER) + #include "Board/LEDs.h" + #endif + + #if !defined(LEDS_LED1) + #define LEDS_LED1 0 + #endif + + #if !defined(LEDS_LED2) + #define LEDS_LED2 0 + #endif + + #if !defined(LEDS_LED3) + #define LEDS_LED3 0 + #endif + + #if !defined(LEDS_LED4) + #define LEDS_LED4 0 + #endif + + /* Pseudo-Functions for Doxygen: */ + #if defined(__DOXYGEN__) + /** Initialises the board LED driver so that the LEDs can be controlled. This sets the appropriate port + * I/O pins as outputs, and sets the LEDs to default to off. + */ + static inline void LEDs_Init(void); + + /** Turns on the LEDs specified in the given LED mask. + * + * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file). + */ + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask); + + /** Turns off the LEDs specified in the given LED mask. + * + * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file). + */ + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask); + + /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED + * mask. + * + * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file). + */ + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask); + + /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs + * specified in both the LED and active masks. + * + * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file). + * \param[in] ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off. + */ + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask); + + /** Toggles all LEDs in the LED mask, leaving all others in their current states. + * + * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file). + */ + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask); + + /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the + * corresponding LED is on. + * + * \return Mask of the board LEDs which are currently turned on. + */ + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/MAXIMUS/LEDs.h b/firmware/LUFA/Drivers/Board/MAXIMUS/LEDs.h new file mode 100644 index 0000000..d540d32 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/MAXIMUS/LEDs.h @@ -0,0 +1,131 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Maximus. + * + * Board specific LED driver header for the Maximus (http://www.avrusb.com/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_MAXIMUS MAXIMUS + * + * Board specific LED driver header for the Maximus (http://www.avrusb.com/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_MAXIMUS_H__ +#define __LEDS_MAXIMUS_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 6) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 7) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRB |= LEDS_ALL_LEDS; + PORTB &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTB |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTB &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTB = ((PORTB & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTB = (PORTB ^ (LEDMask & LEDS_ALL_LEDS)); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTB & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/firmware/LUFA/Drivers/Board/MICROSIN162/Buttons.h b/firmware/LUFA/Drivers/Board/MICROSIN162/Buttons.h new file mode 100644 index 0000000..78f9c1e --- /dev/null +++ b/firmware/LUFA/Drivers/Board/MICROSIN162/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Microsin AVR-USB162 board. + * + * Board specific Buttons driver header for the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_MICROSIN162 MICROSIN162 + * + * Board specific Buttons driver header for the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_MICROSIN162_H__ +#define __BUTTONS_MICROSIN162_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/MICROSIN162/LEDs.h b/firmware/LUFA/Drivers/Board/MICROSIN162/LEDs.h new file mode 100644 index 0000000..1ac0eea --- /dev/null +++ b/firmware/LUFA/Drivers/Board/MICROSIN162/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Microsin AVR-USB162 board. + * + * Board specific LED driver header for the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_MICROSIN162 MICROSIN162 + * + * Board specific LED driver header for the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_MICROSIN162_H__ +#define __LEDS_MICROSIN162_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (~PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/MINIMUS/Buttons.h b/firmware/LUFA/Drivers/Board/MINIMUS/Buttons.h new file mode 100644 index 0000000..c38c9c3 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/MINIMUS/Buttons.h @@ -0,0 +1,97 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the MINIMUS. + * + * Board specific Buttons driver header for the MINIMUS. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_MINIMUS MINIMUS + * + * Board specific Buttons driver header for the MINIMUS. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_MINIMUS_H__ +#define __BUTTONS_MINIMUS_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 8) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/firmware/LUFA/Drivers/Board/MINIMUS/LEDs.h b/firmware/LUFA/Drivers/Board/MINIMUS/LEDs.h new file mode 100644 index 0000000..96db6ee --- /dev/null +++ b/firmware/LUFA/Drivers/Board/MINIMUS/LEDs.h @@ -0,0 +1,131 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the MINIMUS. + * + * Board specific LED driver header for the Minimus USB (http://www.minimususb.com/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_MINIMUS MINIMUS + * + * Board specific LED driver header for the Minimus USB (http://www.minimususb.com/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_MINIMUS_H__ +#define __LEDS_MINIMUS_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 5) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 6) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for the none of the board LEDs. */ + #define LEDS_NO_LEDS 1 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS)); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/firmware/LUFA/Drivers/Board/OLIMEX162/Buttons.h b/firmware/LUFA/Drivers/Board/OLIMEX162/Buttons.h new file mode 100644 index 0000000..9632f7a --- /dev/null +++ b/firmware/LUFA/Drivers/Board/OLIMEX162/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board. + * + * Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board (http://www.olimex.com/dev/avr-usb-162.html). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_OLIMEX162 OLIMEX162 + * + * Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board (http://www.olimex.com/dev/avr-usb-162.html). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_OLIMEX162_H__ +#define __BUTTONS_OLIMEX162_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/OLIMEX162/LEDs.h b/firmware/LUFA/Drivers/Board/OLIMEX162/LEDs.h new file mode 100644 index 0000000..d90f079 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/OLIMEX162/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Olimex AVR-USB-162. + * + * Board specific LED driver header for the Olimex AVR-USB-162 (http://www.olimex.com/dev/avr-usb-162.html). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_OLIMEX162 OLIMEX162 + * + * Board specific LED driver header for the Olimex AVR-USB-162 (http://www.olimex.com/dev/avr-usb-162.html). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_OLIMEX162_H__ +#define __LEDS_OLIMEX162_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (~PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h b/firmware/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h new file mode 100644 index 0000000..d8949bd --- /dev/null +++ b/firmware/LUFA/Drivers/Board/RZUSBSTICK/LEDs.h @@ -0,0 +1,163 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel RZUSBSTICK. + * + * Board specific LED driver header for the Atmel RZUSBSTICK. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_RZUSBSTICK RZUSBSTICK + * + * Board specific LED driver header for the Atmel RZUSBSTICK. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_RZUSBSTICK_H__ +#define __LEDS_RZUSBSTICK_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2) + #define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4) + + #define LEDS_PORTE_MASK_SHIFT 4 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 7) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 5) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 ((1 << 6) >> LEDS_PORTE_MASK_SHIFT) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 ((1 << 7) >> LEDS_PORTE_MASK_SHIFT) + + /** 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) + { + DDRD |= LEDS_PORTD_LEDS; + PORTD &= ~LEDS_LED1; + PORTD |= LEDS_LED2; + + DDRE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + PORTE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= (LEDMask & LEDS_LED1); + PORTD &= ~(LEDMask & LEDS_LED2); + PORTE &= ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~(LEDMask & LEDS_LED1); + PORTD |= (LEDMask & LEDS_LED2); + PORTE |= ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = (((PORTD & ~LEDS_LED1) | (LEDMask & LEDS_LED1)) | + ((PORTD | LEDS_LED2) & ~(LEDMask & LEDS_LED2))); + PORTE = ((PORTE | (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) & + ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = (((PORTD & ~(LEDMask & LEDS_LED1)) | (ActiveMask & LEDS_LED1)) | + ((PORTD | (LEDMask & LEDS_LED2)) & ~(ActiveMask & LEDS_LED2))); + PORTE = ((PORTE | ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)) & + ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD = (PORTD ^ (LEDMask & LEDS_PORTD_LEDS)); + PORTE = (PORTE ^ ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (((PORTD & LEDS_LED1) | (~PORTD & LEDS_LED2)) | + ((~PORTE & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) >> LEDS_PORTE_MASK_SHIFT)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK525/AT45DB321C.h b/firmware/LUFA/Drivers/Board/STK525/AT45DB321C.h new file mode 100644 index 0000000..8599d0f --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK525/AT45DB321C.h @@ -0,0 +1,105 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash commands header for the AT45DB321C as mounted on the Atmel STK525. + * + * Board specific Dataflash commands header for the AT45DB321C as mounted on the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash_STK525 + * @defgroup Group_Dataflash_STK525_AT45DB321C AT45DB321C + * + * Board specific Dataflash commands header for the AT45DB321C as mounted on the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_CMDS_H__ +#define __DATAFLASH_CMDS_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Dataflash Status Values */ + //@{ + #define DF_STATUS_READY (1 << 7) + #define DF_STATUS_COMPMISMATCH (1 << 6) + #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) + //@} + + #define DF_MANUFACTURER_ATMEL 0x1F + + /** \name Dataflash Commands */ + //@{ + #define DF_CMD_GETSTATUS 0xD7 + + #define DF_CMD_MAINMEMTOBUFF1 0x53 + #define DF_CMD_MAINMEMTOBUFF2 0x55 + #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 + #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 + #define DF_CMD_AUTOREWRITEBUFF1 0x58 + #define DF_CMD_AUTOREWRITEBUFF2 0x59 + + #define DF_CMD_MAINMEMPAGEREAD 0xD2 + #define DF_CMD_CONTARRAYREAD_LF 0xE8 + #define DF_CMD_BUFF1READ_LF 0xD4 + #define DF_CMD_BUFF2READ_LF 0xD6 + + #define DF_CMD_BUFF1WRITE 0x84 + #define DF_CMD_BUFF2WRITE 0x87 + #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 + #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 + #define DF_CMD_BUFF1TOMAINMEM 0x88 + #define DF_CMD_BUFF2TOMAINMEM 0x89 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 + + #define DF_CMD_PAGEERASE 0x81 + #define DF_CMD_BLOCKERASE 0x50 + + #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF}) + #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D + #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A + #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F + #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF + + #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F + //@} + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK525/Buttons.h b/firmware/LUFA/Drivers/Board/STK525/Buttons.h new file mode 100644 index 0000000..73ef3aa --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK525/Buttons.h @@ -0,0 +1,104 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Atmel STK525. + * + * Board specific Buttons driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_STK525 STK525 + * + * Board specific Buttons driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_STK525_H__ +#define __BUTTONS_STK525_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 2) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRE &= ~BUTTONS_BUTTON1; + PORTE |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK525/Dataflash.h b/firmware/LUFA/Drivers/Board/STK525/Dataflash.h new file mode 100644 index 0000000..10054d1 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK525/Dataflash.h @@ -0,0 +1,184 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash driver header for the Atmel STK525. + * + * Board specific Dataflash driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash + * @defgroup Group_Dataflash_STK525 STK525 + * + * Board specific Dataflash driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_STK525_H__ +#define __DATAFLASH_STK525_H__ + + /* Includes: */ + #include "AT45DB321C.h" + + /* 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 (1 << 4) + #define DATAFLASH_CHIPCS_DDR DDRB + #define DATAFLASH_CHIPCS_PORT PORTB + #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 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 0 + + /** Internal main memory page size for the board's dataflash IC. */ + #define DATAFLASH_PAGE_SIZE 512 + + /** Total number of pages inside the board's dataflash IC. */ + #define DATAFLASH_PAGES 8192 + + /* Inline Functions: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR'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; + } + + /** 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 + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + return; + + Dataflash_SelectChip(DATAFLASH_CHIP1); + } + + /** 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-byte 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) + { + Dataflash_SendByte(PageAddress >> 6); + Dataflash_SendByte((PageAddress << 2) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK525/Joystick.h b/firmware/LUFA/Drivers/Board/STK525/Joystick.h new file mode 100644 index 0000000..0535558 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK525/Joystick.h @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific joystick driver header for the Atmel STK525. + * + * Board specific joystick driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + */ + +/** \ingroup Group_Joystick + * @defgroup Group_Joystick_STK525 STK525 + * + * Board specific joystick driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + * + * @{ + */ + +#ifndef __JOYSTICK_STK525_H__ +#define __JOYSTICK_STK525_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7)) + #define JOY_EMASK ((1 << 4) | (1 << 5)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1 << 6) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT ((1 << 4) >> 1) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1 << 7) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN ((1 << 5) >> 1) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1 << 5) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + DDRB &= ~(JOY_BMASK); + DDRE &= ~(JOY_EMASK); + + PORTB |= JOY_BMASK; + PORTE |= JOY_EMASK; + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK525/LEDs.h b/firmware/LUFA/Drivers/Board/STK525/LEDs.h new file mode 100644 index 0000000..edfc2bf --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK525/LEDs.h @@ -0,0 +1,138 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel STK525. + * + * Board specific LED driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_STK525 STK525 + * + * Board specific LED driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_STK525_H__ +#define __LEDS_STK525_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 5) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 7) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1 << 6) + + /** 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) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK526/AT45DB642D.h b/firmware/LUFA/Drivers/Board/STK526/AT45DB642D.h new file mode 100644 index 0000000..c273083 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK526/AT45DB642D.h @@ -0,0 +1,115 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel STK526. + * + * Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash_STK526 + * @defgroup Group_Dataflash_STK526_AT45DB642D AT45DB642D + * + * Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_CMDS_H__ +#define __DATAFLASH_CMDS_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Dataflash Status Values */ + //@{ + #define DF_STATUS_READY (1 << 7) + #define DF_STATUS_COMPMISMATCH (1 << 6) + #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) + #define DF_STATUS_BINARYPAGESIZE_ON (1 << 0) + //@} + + #define DF_MANUFACTURER_ATMEL 0x1F + + /** \name Dataflash Commands */ + //@{ + #define DF_CMD_GETSTATUS 0xD7 + #define DF_CMD_POWERDOWN 0xB9 + #define DF_CMD_WAKEUP 0xAB + + #define DF_CMD_MAINMEMTOBUFF1 0x53 + #define DF_CMD_MAINMEMTOBUFF2 0x55 + #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 + #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 + #define DF_CMD_AUTOREWRITEBUFF1 0x58 + #define DF_CMD_AUTOREWRITEBUFF2 0x59 + + #define DF_CMD_MAINMEMPAGEREAD 0xD2 + #define DF_CMD_CONTARRAYREAD_LF 0x03 + #define DF_CMD_BUFF1READ_LF 0xD1 + #define DF_CMD_BUFF2READ_LF 0xD3 + + #define DF_CMD_BUFF1WRITE 0x84 + #define DF_CMD_BUFF2WRITE 0x87 + #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 + #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 + #define DF_CMD_BUFF1TOMAINMEM 0x88 + #define DF_CMD_BUFF2TOMAINMEM 0x89 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 + + #define DF_CMD_PAGEERASE 0x81 + #define DF_CMD_BLOCKERASE 0x50 + #define DF_CMD_SECTORERASE 0x7C + + #define DF_CMD_CHIPERASE ((char[]){0xC7, 0x94, 0x80, 0x9A}) + #define DF_CMD_CHIPERASE_BYTE1 0xC7 + #define DF_CMD_CHIPERASE_BYTE2 0x94 + #define DF_CMD_CHIPERASE_BYTE3 0x80 + #define DF_CMD_CHIPERASE_BYTE4 0x9A + + #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0x9A}) + #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D + #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A + #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F + #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0x9A + + #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F + //@} + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK526/Buttons.h b/firmware/LUFA/Drivers/Board/STK526/Buttons.h new file mode 100644 index 0000000..cc07054 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK526/Buttons.h @@ -0,0 +1,104 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Atmel STK526. + * + * Board specific Buttons driver header for the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_STK526 STK526 + * + * Board specific Buttons driver header for the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_STK526_H__ +#define __BUTTONS_STK526_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK526/Dataflash.h b/firmware/LUFA/Drivers/Board/STK526/Dataflash.h new file mode 100644 index 0000000..087bfd2 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK526/Dataflash.h @@ -0,0 +1,184 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash driver header for the Atmel STK525. + * + * Board specific Dataflash driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash + * @defgroup Group_Dataflash_STK526 STK526 + * + * Board specific Dataflash driver header for the Atmel STK525. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_STK526_H__ +#define __DATAFLASH_STK526_H__ + + /* Includes: */ + #include "AT45DB642D.h" + + /* 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 (1 << 2) + #define DATAFLASH_CHIPCS_DDR DDRC + #define DATAFLASH_CHIPCS_PORT PORTC + #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 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 0 + + /** Internal main memory page size for the board's dataflash IC. */ + #define DATAFLASH_PAGE_SIZE 1024 + + /** Total number of pages inside the board's dataflash IC. */ + #define DATAFLASH_PAGES 8192 + + /* Inline Functions: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR'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; + } + + /** 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 + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + return; + + Dataflash_SelectChip(DATAFLASH_CHIP1); + } + + /** 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-byte 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) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK526/Joystick.h b/firmware/LUFA/Drivers/Board/STK526/Joystick.h new file mode 100644 index 0000000..7309963 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK526/Joystick.h @@ -0,0 +1,116 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific joystick driver header for the Atmel STK526. + * + * Board specific joystick driver header for the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + */ + +/** \ingroup Group_Joystick + * @defgroup Group_Joystick_STK526 STK526 + * + * Board specific joystick driver header for the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + * + * @{ + */ + +#ifndef __JOYSTICK_STK526_H__ +#define __JOYSTICK_STK526_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define JOY_BMASK ((1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1 << 4) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT (1 << 6) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1 << 5) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN (1 << 7) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1 << 0) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + DDRB &= ~JOY_BMASK; + + PORTB |= JOY_BMASK; + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + return ((uint8_t)~PINB & JOY_BMASK); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/STK526/LEDs.h b/firmware/LUFA/Drivers/Board/STK526/LEDs.h new file mode 100644 index 0000000..b407d44 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/STK526/LEDs.h @@ -0,0 +1,138 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel STK526. + * + * Board specific LED driver header for the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_STK526 STK526 + * + * Board specific LED driver header for the Atmel STK526. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_STK526_H__ +#define __LEDS_STK526_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 1) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 0) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 5) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1 << 4) + + /** 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) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/TEENSY/LEDs.h b/firmware/LUFA/Drivers/Board/TEENSY/LEDs.h new file mode 100644 index 0000000..29ed008 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/TEENSY/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the PJRC Teensy boards. + * + * Board specific LED driver header for the PJRC Teensy boards (http://www.pjrc.com/teensy/index.html). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_TEENSY TEENSY + * + * Board specific LED driver header for the PJRC Teensy boards (http://www.pjrc.com/teensy/index.html). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_TEENSY_H__ +#define __LEDS_TEENSY_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 6) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (~PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/Temperature.c b/firmware/LUFA/Drivers/Board/Temperature.c new file mode 100644 index 0000000..719dfe1 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/Temperature.c @@ -0,0 +1,61 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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. +*/ + +#include "Temperature.h" + +static const uint16_t PROGMEM Temperature_Lookup[] = { + 0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373, + 0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307, + 0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C, + 0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7, + 0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161, + 0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7, + 0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA, + 0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074, + 0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050, + 0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038 + }; + +int8_t Temperature_GetTemperature(void) +{ + uint16_t Temp_ADC = ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | TEMP_ADC_CHANNEL_MASK); + + if (Temp_ADC > pgm_read_word(&Temperature_Lookup[0])) + return TEMP_MIN_TEMP; + + for (uint16_t Index = 0; Index < TEMP_TABLE_SIZE; Index++) + { + if (Temp_ADC > pgm_read_word(&Temperature_Lookup[Index])) + return (Index + TEMP_TABLE_OFFSET); + } + + return TEMP_MAX_TEMP; +} + diff --git a/firmware/LUFA/Drivers/Board/Temperature.h b/firmware/LUFA/Drivers/Board/Temperature.h new file mode 100644 index 0000000..e34a141 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/Temperature.h @@ -0,0 +1,125 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 board temperature sensor driver. + * + * Master include file for the board temperature sensor driver, for the USB boards which contain a temperature sensor. + */ + +/** \ingroup Group_BoardDrivers + * @defgroup Group_Temperature Temperature Sensor Driver - LUFA/Drivers/Board/Temperature.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/Board/Temperature.c (Makefile source module name: LUFA_SRC_TEMPERATURE) + * + * \section Module Description + * Temperature sensor driver. This provides an easy to use interface for the hardware temperature sensor located + * on many boards. It provides an interface to configure the sensor and appropriate ADC channel, plus read out the + * current temperature in degrees C. It is designed for and will only work with the temperature sensor located on the + * official Atmel USB AVR boards, as each sensor has different characteristics. + * + * @{ + */ + +#ifndef __TEMPERATURE_H__ +#define __TEMPERATURE_H__ + + /* Includes: */ + #include + + #include "../../Common/Common.h" + #include "../Peripheral/ADC.h" + + #if (BOARD == BOARD_NONE) + #error The Board Temperature Sensor driver cannot be used if the makefile BOARD option is not set. + #elif ((BOARD != BOARD_USBKEY) && (BOARD != BOARD_STK525) && \ + (BOARD != BOARD_STK526) && (BOARD != BOARD_USER) && \ + (BOARD != BOARD_EVK527)) + #error The selected board does not contain a temperature sensor. + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** ADC channel number for the temperature sensor. */ + #define TEMP_ADC_CHANNEL 0 + + /** ADC channel MUX mask for the temperature sensor. */ + #define TEMP_ADC_CHANNEL_MASK ADC_CHANNEL0 + + /** Minimum returnable temperature from the \ref Temperature_GetTemperature() function. */ + #define TEMP_MIN_TEMP TEMP_TABLE_OFFSET + + /** Maximum returnable temperature from the \ref Temperature_GetTemperature() function. */ + #define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET) + + /* Inline Functions: */ + /** Initialises the temperature sensor driver, including setting up the appropriate ADC channel. + * This must be called before any other temperature sensor routines. + * + * \pre The ADC itself (not the ADC channel) must be configured separately before calling the + * temperature sensor functions. + */ + static inline void Temperature_Init(void) ATTR_ALWAYS_INLINE; + static inline void Temperature_Init(void) + { + ADC_SetupChannel(TEMP_ADC_CHANNEL); + } + + /* Function Prototypes: */ + /** Performs a complete ADC on the temperature sensor channel, and converts the result into a + * valid temperature between \ref TEMP_MIN_TEMP and \ref TEMP_MAX_TEMP in degrees Celsius. + * + * \return Signed temperature value in degrees Celsius. + */ + int8_t Temperature_GetTemperature(void) ATTR_WARN_UNUSED_RESULT; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define TEMP_TABLE_SIZE (sizeof(Temperature_Lookup) / sizeof(Temperature_Lookup[0])) + #define TEMP_TABLE_OFFSET -21 + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/UDIP/Buttons.h b/firmware/LUFA/Drivers/Board/UDIP/Buttons.h new file mode 100644 index 0000000..42646f8 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/UDIP/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the UDIP. + * + * Board specific Buttons driver header for the Linnix UDIP (http://linnix.com/udip/). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_UDIP UDIP + * + * Board specific Buttons driver header for the Linnix UDIP (http://linnix.com/udip/). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_UDIP_H__ +#define __BUTTONS_UDIP_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/UDIP/LEDs.h b/firmware/LUFA/Drivers/Board/UDIP/LEDs.h new file mode 100644 index 0000000..e0060b5 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/UDIP/LEDs.h @@ -0,0 +1,154 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Linnix UDIP. + * + * Board specific LED driver header for the Linnix UDIP (http://linnix.com/udip/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_UDIP UDIP + * + * Board specific LED driver header for the Linnix UDIP (http://linnix.com/udip/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_UDIP_H__ +#define __LEDS_UDIP_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define LEDS_PORTB_LEDS (LEDS_LED1 | LEDS_LED2) + #define LEDS_PORTD_LEDS (LEDS_LED3 | LEDS_LED4) + + #define LEDS_PORTD_MASK_SHIFT 1 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1 << 6) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 5) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 ((1 << 5) >> LEDS_PORTD_MASK_SHIFT) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 ((1 << 4) >> LEDS_PORTD_MASK_SHIFT) + + /** 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) + { + DDRB |= LEDS_PORTB_LEDS; + DDRD |= (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT); + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTB |= (LEDMask & LEDS_PORTB_LEDS); + PORTD |= ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTB &= ~(LEDMask & LEDS_PORTB_LEDS); + PORTD &= ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTB = (PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS); + PORTD = (PORTD & ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT)) | + ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTB = (PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS); + PORTD = (PORTD & ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT)) | + ((ActiveMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTB ^= (LEDMask & LEDS_PORTB_LEDS); + PORTD ^= ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return ((PORTB & LEDS_PORTB_LEDS) | ((PORTD & LEDS_PORTD_LEDS) >> LEDS_PORTD_MASK_SHIFT)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/UNO/LEDs.h b/firmware/LUFA/Drivers/Board/UNO/LEDs.h new file mode 100644 index 0000000..dc16cd1 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/UNO/LEDs.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Arduino Uno. + * + * Board specific LED driver header for the Arduino Uno (http://arduino.cc/en/Main/ArduinoBoardUno). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_UNO UNO + * + * Board specific LED driver header for the Arduino Uno (http://arduino.cc/en/Main/ArduinoBoardUno). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_BENITO_H__ +#define __LEDS_BENITO_H__ + + /* Includes: */ + #include + + /* 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 (1 << 4) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 5) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBFOO/Buttons.h b/firmware/LUFA/Drivers/Board/USBFOO/Buttons.h new file mode 100644 index 0000000..bb3f7e6 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBFOO/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Kernel Concepts USBFOO. + * + * Board specific Buttons driver header for the Kernel Concepts USBFOO (http://shop.kernelconcepts.de/product_info.php?products_id=102). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_USBFOO USBFOO + * + * Board specific Buttons driver header for the Kernel Concepts USBFOO (http://shop.kernelconcepts.de/product_info.php?products_id=102). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_USBFOO_H__ +#define __BUTTONS_USBFOO_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBFOO/LEDS.h b/firmware/LUFA/Drivers/Board/USBFOO/LEDS.h new file mode 100644 index 0000000..e9dd196 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBFOO/LEDS.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Kernel Concepts USBFOO. + * + * Board specific LED driver header for the Kernel Concepts USBFOO (http://shop.kernelconcepts.de/product_info.php?products_id=102). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_USBFOO USBFOO + * + * Board specific LED driver header for the Kernel Concepts USBFOO (http://shop.kernelconcepts.de/product_info.php?products_id=102). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_USBFOO_H__ +#define __LEDS_USBFOO_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRD |= LEDS_ALL_LEDS; + PORTD |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (~PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBKEY/AT45DB642D.h b/firmware/LUFA/Drivers/Board/USBKEY/AT45DB642D.h new file mode 100644 index 0000000..9f2a429 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBKEY/AT45DB642D.h @@ -0,0 +1,115 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel USBKEY. + * + * Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash_USBKEY + * @defgroup Group_Dataflash_USBKEY_AT45DB642D AT45DB642D + * + * Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_CMDS_H__ +#define __DATAFLASH_CMDS_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Dataflash Status Values */ + //@{ + #define DF_STATUS_READY (1 << 7) + #define DF_STATUS_COMPMISMATCH (1 << 6) + #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) + #define DF_STATUS_BINARYPAGESIZE_ON (1 << 0) + //@} + + #define DF_MANUFACTURER_ATMEL 0x1F + + /** \name Dataflash Commands */ + //@{ + #define DF_CMD_GETSTATUS 0xD7 + #define DF_CMD_POWERDOWN 0xB9 + #define DF_CMD_WAKEUP 0xAB + + #define DF_CMD_MAINMEMTOBUFF1 0x53 + #define DF_CMD_MAINMEMTOBUFF2 0x55 + #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 + #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 + #define DF_CMD_AUTOREWRITEBUFF1 0x58 + #define DF_CMD_AUTOREWRITEBUFF2 0x59 + + #define DF_CMD_MAINMEMPAGEREAD 0xD2 + #define DF_CMD_CONTARRAYREAD_LF 0x03 + #define DF_CMD_BUFF1READ_LF 0xD1 + #define DF_CMD_BUFF2READ_LF 0xD3 + + #define DF_CMD_BUFF1WRITE 0x84 + #define DF_CMD_BUFF2WRITE 0x87 + #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 + #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 + #define DF_CMD_BUFF1TOMAINMEM 0x88 + #define DF_CMD_BUFF2TOMAINMEM 0x89 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 + + #define DF_CMD_PAGEERASE 0x81 + #define DF_CMD_BLOCKERASE 0x50 + #define DF_CMD_SECTORERASE 0x7C + + #define DF_CMD_CHIPERASE ((char[]){0xC7, 0x94, 0x80, 0x9A}) + #define DF_CMD_CHIPERASE_BYTE1 0xC7 + #define DF_CMD_CHIPERASE_BYTE2 0x94 + #define DF_CMD_CHIPERASE_BYTE3 0x80 + #define DF_CMD_CHIPERASE_BYTE4 0x9A + + #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0x9A}) + #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D + #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A + #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F + #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0x9A + + #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F + //@} + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBKEY/Buttons.h b/firmware/LUFA/Drivers/Board/USBKEY/Buttons.h new file mode 100644 index 0000000..d59e0a5 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBKEY/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for the Atmel USBKEY. + * + * Board specific Buttons driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_USBKEY USBKEY + * + * Board specific Buttons driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_USBKEY_H__ +#define __BUTTONS_USBKEY_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 2) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRE &= ~BUTTONS_BUTTON1; + PORTE |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBKEY/Dataflash.h b/firmware/LUFA/Drivers/Board/USBKEY/Dataflash.h new file mode 100644 index 0000000..843928e --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBKEY/Dataflash.h @@ -0,0 +1,192 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash driver header for the Atmel USBKEY. + * + * Board specific Dataflash driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash + * @defgroup Group_Dataflash_USBKEY USBKEY + * + * Board specific Dataflash driver header for the Atmel USBKEY board. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_USBKEY_H__ +#define __DATAFLASH_USBKEY_H__ + + /* Includes: */ + #include "AT45DB642D.h" + + /* 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 ((1 << 1) | (1 << 0)) + #define DATAFLASH_CHIPCS_DDR DDRE + #define DATAFLASH_CHIPCS_PORT PORTE + #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 2 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 (1 << 1) + + /** Mask for the second dataflash chip selected. */ + #define DATAFLASH_CHIP2 (1 << 0) + + /** Internal main memory page size for the board's dataflash ICs. */ + #define DATAFLASH_PAGE_SIZE 1024 + + /** Total number of pages inside each of the board's dataflash ICs. */ + #define DATAFLASH_PAGES 8192 + + /* Inline Functions: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR'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; + } + + /** 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 + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) + return; + + if (PageAddress & 0x01) + Dataflash_SelectChip(DATAFLASH_CHIP2); + else + Dataflash_SelectChip(DATAFLASH_CHIP1); + } + + /** 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-byte 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) + { + PageAddress >>= 1; + + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBKEY/Joystick.h b/firmware/LUFA/Drivers/Board/USBKEY/Joystick.h new file mode 100644 index 0000000..65d2b53 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBKEY/Joystick.h @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific joystick driver header for the Atmel USBKEY. + * + * Board specific joystick driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + */ + +/** \ingroup Group_Joystick + * @defgroup Group_Joystick_USBKEY USBKEY + * + * Board specific joystick driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the joystick driver + * dispatch header located in LUFA/Drivers/Board/Joystick.h. + * + * @{ + */ + +#ifndef __JOYSTICK_USBKEY_H__ +#define __JOYSTICK_USBKEY_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7)) + #define JOY_EMASK ((1 << 4) | (1 << 5)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1 << 6) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT ((1 << 4) >> 1) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1 << 7) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN ((1 << 5) >> 1) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1 << 5) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + DDRB &= ~(JOY_BMASK); + DDRE &= ~(JOY_EMASK); + + PORTB |= JOY_BMASK; + PORTE |= JOY_EMASK; + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBKEY/LEDs.h b/firmware/LUFA/Drivers/Board/USBKEY/LEDs.h new file mode 100644 index 0000000..9362b78 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBKEY/LEDs.h @@ -0,0 +1,137 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel USBKEY. + * + * Board specific LED driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_USBKEY USBKEY + * + * Board specific LED driver header for the Atmel USBKEY. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_USBKEY_H__ +#define __LEDS_USBKEY_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 4) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 5) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 7) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1 << 6) + + /** 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) + { + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTD ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTD & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/firmware/LUFA/Drivers/Board/USBTINYMKII/Buttons.h b/firmware/LUFA/Drivers/Board/USBTINYMKII/Buttons.h new file mode 100644 index 0000000..059016e --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBTINYMKII/Buttons.h @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Buttons driver header for Tom's USBTINY MKII. + * + * Board specific Buttons driver header for Tom's USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + */ + +/** \ingroup Group_Buttons + * @defgroup Group_Buttons_USBTINYMKII USBTINYMKII + * + * Board specific Buttons driver header for Tom's USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/). + * + * \note This file should not be included directly. It is automatically included as needed by the Buttons driver + * dispatch header located in LUFA/Drivers/Board/Buttons.h. + * + * @{ + */ + +#ifndef __BUTTONS_USBTINYMKII_H__ +#define __BUTTONS_USBTINYMKII_H__ + + /* Includes: */ + #include + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 7) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + DDRD &= ~BUTTONS_BUTTON1; + PORTD |= BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/USBTINYMKII/LEDs.h b/firmware/LUFA/Drivers/Board/USBTINYMKII/LEDs.h new file mode 100644 index 0000000..cd33a2a --- /dev/null +++ b/firmware/LUFA/Drivers/Board/USBTINYMKII/LEDs.h @@ -0,0 +1,133 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for Tom's USBTINY MKII. + * + * Board specific LED driver header for Tom's USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_USBTINYMKII USBTINYMKII + * + * Board specific LED driver header for Tom's USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/). + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_USBTINYMKII_H__ +#define __LEDS_USBTINYMKII_H__ + + /* Includes: */ + #include + + /* 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 (1 << 6) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1 << 7) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 5) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRB |= LEDS_ALL_LEDS; + PORTB &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LedMask) + { + PORTB |= LedMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LedMask) + { + PORTB &= ~LedMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LedMask) + { + PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LedMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LedMask, + const uint8_t ActiveMask) + { + PORTB = ((PORTB & ~LedMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTB ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTB & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/XPLAIN/AT45DB642D.h b/firmware/LUFA/Drivers/Board/XPLAIN/AT45DB642D.h new file mode 100644 index 0000000..b02d338 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/XPLAIN/AT45DB642D.h @@ -0,0 +1,115 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel XPLAIN. + * + * Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel XPLAIN. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash_XPLAIN + * @defgroup Group_Dataflash_XPLAIN_AT45DB642D AT45DB642D + * + * Board specific Dataflash commands header for the AT45DB642D as mounted on the Atmel XPLAIN. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_CMDS_H__ +#define __DATAFLASH_CMDS_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Dataflash Status Values */ + //@{ + #define DF_STATUS_READY (1 << 7) + #define DF_STATUS_COMPMISMATCH (1 << 6) + #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) + #define DF_STATUS_BINARYPAGESIZE_ON (1 << 0) + //@} + + #define DF_MANUFACTURER_ATMEL 0x1F + + /** \name Dataflash Commands */ + //@{ + #define DF_CMD_GETSTATUS 0xD7 + #define DF_CMD_POWERDOWN 0xB9 + #define DF_CMD_WAKEUP 0xAB + + #define DF_CMD_MAINMEMTOBUFF1 0x53 + #define DF_CMD_MAINMEMTOBUFF2 0x55 + #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 + #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 + #define DF_CMD_AUTOREWRITEBUFF1 0x58 + #define DF_CMD_AUTOREWRITEBUFF2 0x59 + + #define DF_CMD_MAINMEMPAGEREAD 0xD2 + #define DF_CMD_CONTARRAYREAD_LF 0x03 + #define DF_CMD_BUFF1READ_LF 0xD1 + #define DF_CMD_BUFF2READ_LF 0xD3 + + #define DF_CMD_BUFF1WRITE 0x84 + #define DF_CMD_BUFF2WRITE 0x87 + #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 + #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 + #define DF_CMD_BUFF1TOMAINMEM 0x88 + #define DF_CMD_BUFF2TOMAINMEM 0x89 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 + #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 + + #define DF_CMD_PAGEERASE 0x81 + #define DF_CMD_BLOCKERASE 0x50 + #define DF_CMD_SECTORERASE 0x7C + + #define DF_CMD_CHIPERASE ((char[]){0xC7, 0x94, 0x80, 0x9A}) + #define DF_CMD_CHIPERASE_BYTE1 0xC7 + #define DF_CMD_CHIPERASE_BYTE2 0x94 + #define DF_CMD_CHIPERASE_BYTE3 0x80 + #define DF_CMD_CHIPERASE_BYTE4 0x9A + + #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0x9A}) + #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D + #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A + #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F + #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0x9A + + #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F + //@} + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/XPLAIN/Dataflash.h b/firmware/LUFA/Drivers/Board/XPLAIN/Dataflash.h new file mode 100644 index 0000000..0779b05 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/XPLAIN/Dataflash.h @@ -0,0 +1,190 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific Dataflash driver header for the Atmel XPLAIN. + * + * Board specific Dataflash driver header for the Atmel XPLAIN. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + */ + +/** \ingroup Group_Dataflash + * @defgroup Group_Dataflash_XPLAIN XPLAIN + * + * Board specific Dataflash driver header for the Atmel XPLAIN. + * + * \note This file should not be included directly. It is automatically included as needed by the dataflash driver + * dispatch header located in LUFA/Drivers/Board/Dataflash.h. + * + * @{ + */ + +#ifndef __DATAFLASH_XPLAIN_H__ +#define __DATAFLASH_XPLAIN_H__ + + /* Includes: */ + #include "AT45DB642D.h" + + /* 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 (1 << 5) + #define DATAFLASH_CHIPCS_DDR DDRB + #define DATAFLASH_CHIPCS_PORT PORTB + #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 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 0 + + #if (BOARD == BOARD_XPLAIN_REV1) + #define DATAFLASH_PAGE_SIZE 256 + + #define DATAFLASH_PAGES 2048 + #else + /** Internal main memory page size for the board's dataflash ICs. */ + #define DATAFLASH_PAGE_SIZE 1024 + + /** Total number of pages inside each of the board's dataflash ICs. */ + #define DATAFLASH_PAGES 8192 + #endif + + /* Inline Functions: */ + /** Initialises the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The AVR'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; + } + + /** 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 + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + return; + + Dataflash_SelectChip(DATAFLASH_CHIP1); + } + + /** 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-byte 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) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Board/XPLAIN/LEDs.h b/firmware/LUFA/Drivers/Board/XPLAIN/LEDs.h new file mode 100644 index 0000000..a6b2fd2 --- /dev/null +++ b/firmware/LUFA/Drivers/Board/XPLAIN/LEDs.h @@ -0,0 +1,129 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Board specific LED driver header for the Atmel XPLAIN. + * + * Board specific LED driver header for the Atmel XPLAIN. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + */ + +/** \ingroup Group_LEDs + * @defgroup Group_LEDs_XPLAIN XPLAIN + * + * Board specific LED driver header for the Atmel XPLAIN. + * + * \note This file should not be included directly. It is automatically included as needed by the LEDs driver + * dispatch header located in LUFA/Drivers/Board/LEDs.h. + * + * @{ + */ + +#ifndef __LEDS_XPLAIN_H__ +#define __LEDS_XPLAIN_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + + /* 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 (1 << 6) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS LEDS_LED1 + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + DDRB |= LEDS_ALL_LEDS; + PORTB |= LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTB &= ~LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTB |= LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTB = ((PORTB | LEDS_ALL_LEDS) & ~LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTB = ((PORTB | LEDMask) & ~ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTB ^= LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (~PORTB & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Misc/TerminalCodes.h b/firmware/LUFA/Drivers/Misc/TerminalCodes.h new file mode 100644 index 0000000..b1bb8b8 --- /dev/null +++ b/firmware/LUFA/Drivers/Misc/TerminalCodes.h @@ -0,0 +1,224 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 ANSI terminal special escape code macros. + * + * ANSI terminal compatible escape sequences. These escape sequences are designed to be concatenated with existing + * strings to modify their display on a compatible terminal application. + */ + +/** \ingroup Group_MiscDrivers + * @defgroup Group_Terminal ANSI Terminal Escape Codes - LUFA/Drivers/Misc/TerminalCodes.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Escape code macros for ANSI compliant text terminals. + * + * \note If desired, the macro DISABLE_TERMINAL_CODES can be defined in the project makefile and passed to the GCC + * compiler via the -D switch to disable the terminal codes without modifying the source, for use with non + * compatible terminals (any terminal codes then equate to empty strings). + * + * Example Usage: + * \code + * printf("Some String, " ESC_BOLD_ON " Some bold string"); + * \endcode + * + * @{ + */ + +#ifndef __TERMINALCODES_H__ +#define __TERMINALCODES_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if !defined(DISABLE_TERMINAL_CODES) + /** Creates an ANSI escape sequence with the specified payload. + * + * \param[in] EscapeSeq Payload to encode as an ANSI escape sequence, a ESC_* mask. + */ + #define ANSI_ESCAPE_SEQUENCE(EscapeSeq) "\33[" EscapeSeq + #else + #define ANSI_ESCAPE_SEQUENCE(EscapeSeq) + #endif + + /** \name Text Display Modifier Escape Sequences */ + //@{ + /** Turns on bold so that any following text is printed to the terminal in bold. */ + #define ESC_BOLD_ON ANSI_ESCAPE_SEQUENCE("1m") + + /** Turns on italics so that any following text is printed to the terminal in italics. */ + #define ESC_ITALICS_ON ANSI_ESCAPE_SEQUENCE("3m") + + /** Turns on underline so that any following text is printed to the terminal underlined. */ + #define ESC_UNDERLINE_ON ANSI_ESCAPE_SEQUENCE("4m") + + /** Turns on inverse so that any following text is printed to the terminal in inverted colours. */ + #define ESC_INVERSE_ON ANSI_ESCAPE_SEQUENCE("7m") + + /** Turns on strikethrough so that any following text is printed to the terminal with a line through the + * center. + */ + #define ESC_STRIKETHROUGH_ON ANSI_ESCAPE_SEQUENCE("9m") + + /** Turns off bold so that any following text is printed to the terminal in non bold. */ + #define ESC_BOLD_OFF ANSI_ESCAPE_SEQUENCE("22m") + + /** Turns off italics so that any following text is printed to the terminal in non italics. */ + #define ESC_ITALICS_OFF ANSI_ESCAPE_SEQUENCE("23m") + + /** Turns off underline so that any following text is printed to the terminal non underlined. */ + #define ESC_UNDERLINE_OFF ANSI_ESCAPE_SEQUENCE("24m") + + /** Turns off inverse so that any following text is printed to the terminal in non inverted colours. */ + #define ESC_INVERSE_OFF ANSI_ESCAPE_SEQUENCE("27m") + + /** Turns off strikethrough so that any following text is printed to the terminal without a line through + * the center. + */ + #define ESC_STRIKETHROUGH_OFF ANSI_ESCAPE_SEQUENCE("29m") + //@} + + /** \name Text Colour Control Sequences */ + //@{ + /** Sets the foreground (text) colour to black. */ + #define ESC_FG_BLACK ANSI_ESCAPE_SEQUENCE("30m") + + /** Sets the foreground (text) colour to red. */ + #define ESC_FG_RED ANSI_ESCAPE_SEQUENCE("31m") + + /** Sets the foreground (text) colour to green. */ + #define ESC_FG_GREEN ANSI_ESCAPE_SEQUENCE("32m") + + /** Sets the foreground (text) colour to yellow. */ + #define ESC_FG_YELLOW ANSI_ESCAPE_SEQUENCE("33m") + + /** Sets the foreground (text) colour to blue. */ + #define ESC_FG_BLUE ANSI_ESCAPE_SEQUENCE("34m") + + /** Sets the foreground (text) colour to magenta. */ + #define ESC_FG_MAGENTA ANSI_ESCAPE_SEQUENCE("35m") + + /** Sets the foreground (text) colour to cyan. */ + #define ESC_FG_CYAN ANSI_ESCAPE_SEQUENCE("36m") + + /** Sets the foreground (text) colour to white. */ + #define ESC_FG_WHITE ANSI_ESCAPE_SEQUENCE("37m") + + /** Sets the foreground (text) colour to the terminal's default. */ + #define ESC_FG_DEFAULT ANSI_ESCAPE_SEQUENCE("39m") + + /** Sets the text background colour to black. */ + #define ESC_BG_BLACK ANSI_ESCAPE_SEQUENCE("40m") + + /** Sets the text background colour to red. */ + #define ESC_BG_RED ANSI_ESCAPE_SEQUENCE("41m") + + /** Sets the text background colour to green. */ + #define ESC_BG_GREEN ANSI_ESCAPE_SEQUENCE("42m") + + /** Sets the text background colour to yellow. */ + #define ESC_BG_YELLOW ANSI_ESCAPE_SEQUENCE("43m") + + /** Sets the text background colour to blue. */ + #define ESC_BG_BLUE ANSI_ESCAPE_SEQUENCE("44m") + + /** Sets the text background colour to magenta. */ + #define ESC_BG_MAGENTA ANSI_ESCAPE_SEQUENCE("45m") + + /** Sets the text background colour to cyan. */ + #define ESC_BG_CYAN ANSI_ESCAPE_SEQUENCE("46m") + + /** Sets the text background colour to white. */ + #define ESC_BG_WHITE ANSI_ESCAPE_SEQUENCE("47m") + + /** Sets the text background colour to the terminal's default. */ + #define ESC_BG_DEFAULT ANSI_ESCAPE_SEQUENCE("49m") + //@} + + /** \name Cursor Positioning Control Sequences */ + //@{ + /** Saves the current cursor position so that it may be restored with \ref ESC_CURSOR_POS_RESTORE. */ + #define ESC_CURSOR_POS_SAVE ANSI_ESCAPE_SEQUENCE("s") + + /** Restores the cursor position to the last position saved with \ref ESC_CURSOR_POS_SAVE. */ + #define ESC_CURSOR_POS_RESTORE ANSI_ESCAPE_SEQUENCE("u") + + /** Sets the cursor position to the given line and column. + * + * \param[in] Line Line number to position the cursor at + * \param[in] Column Column number to position the cursor at + */ + #define ESC_CURSOR_POS(Line, Column) ANSI_ESCAPE_SEQUENCE(#Line ";" #Column "H") + + /** Moves the cursor up the given number of lines. + * + * \param[in] Lines Number of lines to move the cursor position + */ + #define ESC_CURSOR_UP(Lines) ANSI_ESCAPE_SEQUENCE(#Lines "A") + + /** Moves the cursor down the given number of lines. + * + * \param[in] Lines Number of lines to move the cursor position + */ + #define ESC_CURSOR_DOWN(Lines) ANSI_ESCAPE_SEQUENCE(#Lines "B") + + /** Moves the cursor to the right the given number of columns. + * + * \param[in] Columns Number of columns to move the cursor position + */ + #define ESC_CURSOR_FORWARD(Columns) ANSI_ESCAPE_SEQUENCE(#Columns "C") + + /** Moves the cursor to the left the given number of columns. + * + * \param[in] Columns Number of columns to move the cursor position + */ + #define ESC_CURSOR_BACKWARD(Columns) ANSI_ESCAPE_SEQUENCE(#Columns "D") + //@} + + /** \name Miscellaneous Control Sequences */ + //@{ + /** Resets any escape sequence modifiers back to their defaults. */ + #define ESC_RESET ANSI_ESCAPE_SEQUENCE("0m") + + /** Erases the entire display, returning the cursor to the top left. */ + #define ESC_ERASE_DISPLAY ANSI_ESCAPE_SEQUENCE("2J") + + /** Erases the current line, returning the cursor to the far left. */ + #define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K") + //@} + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Peripheral/ADC.h b/firmware/LUFA/Drivers/Peripheral/ADC.h new file mode 100644 index 0000000..d172584 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/ADC.h @@ -0,0 +1,72 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 ADC peripheral driver. + * + * This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC. + * + * User code should include this file, which will in turn include the correct ADC driver header file for the + * currently selected AVR model. + */ + +/** \ingroup Group_PeripheralDrivers + * @defgroup Group_ADC ADC Driver - LUFA/Drivers/Peripheral/ADC.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Hardware ADC driver. This module provides an easy to use driver for the hardware + * ADC present on many AVR models, for the conversion of analogue signals into the + * digital domain. + */ + +#ifndef __ADC_H__ +#define __ADC_H__ + + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_ADC_H + #endif + + /* Includes: */ + #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ + defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ + defined(__AVR_ATmega32U6__)) + #include "AVRU4U6U7/ADC.h" + #else + #error "ADC is not available for the currently selected AVR model." + #endif + +#endif + diff --git a/firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/ADC.h b/firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/ADC.h new file mode 100644 index 0000000..9a72cd2 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/ADC.h @@ -0,0 +1,411 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 ADC peripheral driver for the U7, U6 and U4 USB AVRs. + * + * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC + * peripheral internally. + * + * \note This file should not be included directly. It is automatically included as needed by the ADC driver + * dispatch header located in LUFA/Drivers/Peripheral/ADC.h. + */ + +/** \ingroup Group_ADC + * @defgroup Group_ADC_AVRU4U6U7 Series U4, U6 and U7 Model ADC Driver + * + * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC + * peripheral internally. + * + * \note This file should not be included directly. It is automatically included as needed by the ADC driver + * dispatch header located in LUFA/Drivers/Peripheral/ADC.h. + * + * @{ + */ + +#ifndef __ADC_AVRU4U6U7_H__ +#define __ADC_AVRU4U6U7_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + #include + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_ADC_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/ADC.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name ADC Reference Configuration Masks */ + //@{ + /** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */ + #define ADC_REFERENCE_AREF 0 + + /** Reference mask, for using the voltage present at the AVR's AVCC pin for the ADC reference. */ + #define ADC_REFERENCE_AVCC (1 << REFS0) + + /** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */ + #define ADC_REFERENCE_INT2560MV ((1 << REFS1) | (1 << REFS0)) + //@} + + /** \name ADC Result Adjustment Configuration Masks */ + //@{ + /** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the + * ADC_GetResult() macro contain the 8 most significant bits of the result. + */ + #define ADC_LEFT_ADJUSTED (1 << ADLAR) + + /** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the + * ADC_GetResult() macro contain the 8 least significant bits of the result. + */ + #define ADC_RIGHT_ADJUSTED (0 << ADLAR) + //@} + + /** \name ADC Mode Configuration Masks */ + //@{ + /** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC + * is capable of at the given input clock speed. + */ + #define ADC_FREE_RUNNING (1 << ADATE) + + /** Sets the ADC mode to single conversion, so that only a single conversion will take place before + * the ADC returns to idle. + */ + #define ADC_SINGLE_CONVERSION (0 << ADATE) + //@} + + /** \name ADC Prescaler Configuration Masks */ + //@{ + /** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */ + #define ADC_PRESCALE_2 (1 << ADPS0) + + /** Sets the ADC input clock to prescale by a factor of 4 the AVR's system clock. */ + #define ADC_PRESCALE_4 (1 << ADPS1) + + /** Sets the ADC input clock to prescale by a factor of 8 the AVR's system clock. */ + #define ADC_PRESCALE_8 ((1 << ADPS0) | (1 << ADPS1)) + + /** Sets the ADC input clock to prescale by a factor of 16 the AVR's system clock. */ + #define ADC_PRESCALE_16 (1 << ADPS2) + + /** Sets the ADC input clock to prescale by a factor of 32 the AVR's system clock. */ + #define ADC_PRESCALE_32 ((1 << ADPS2) | (1 << ADPS0)) + + /** Sets the ADC input clock to prescale by a factor of 64 the AVR's system clock. */ + #define ADC_PRESCALE_64 ((1 << ADPS2) | (1 << ADPS1)) + + /** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */ + #define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0)) + //@} + + /** \name ADC MUX Masks */ + //@{ + /** MUX mask define for the ADC0 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_CHANNEL0 (0x00 << MUX0) + + /** MUX mask define for the ADC1 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_CHANNEL1 (0x01 << MUX0) + + #if !(defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__)) + /** MUX mask define for the ADC2 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL2 (0x02 << MUX0) + + /** MUX mask define for the ADC3 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL3 (0x03 << MUX0) + #endif + + /** MUX mask define for the ADC4 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_CHANNEL4 (0x04 << MUX0) + + /** MUX mask define for the ADC5 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_CHANNEL5 (0x05 << MUX0) + + /** MUX mask define for the ADC6 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_CHANNEL6 (0x06 << MUX0) + + /** MUX mask define for the ADC7 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_CHANNEL7 (0x07 << MUX0) + + /** MUX mask define for the internal 1.1V bandgap channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */ + #define ADC_1100MV_BANDGAP (0x1E << MUX0) + + #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__)) + /** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL8 ((1 << 8) | (0x00 << MUX0)) + + /** MUX mask define for the ADC9 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL9 ((1 << 8) | (0x01 << MUX0)) + + /** MUX mask define for the ADC10 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL10 ((1 << 8) | (0x02 << MUX0)) + + /** MUX mask define for the ADC11 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL11 ((1 << 8) | (0x03 << MUX0)) + + /** MUX mask define for the ADC12 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL12 ((1 << 8) | (0x04 << MUX0)) + + /** MUX mask define for the ADC13 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_CHANNEL13 ((1 << 8) | (0x05 << MUX0)) + + /** MUX mask define for the internal temperature sensor channel of the ADC. See \ref ADC_StartReading and + * \ref ADC_GetChannelReading. + * + * \note Not available on all AVR models. + */ + #define ADC_INT_TEMP_SENS ((1 << 8) | (0x07 << MUX0)) + #endif + //@} + + /* Inline Functions: */ + /** Configures the given ADC channel, ready for ADC conversions. This function sets the + * associated port pin as an input and disables the digital portion of the I/O to reduce + * power consumption. + * + * \note This must only be called for ADC channels with are connected to a physical port + * pin of the AVR, denoted by its special alternative function ADCx. + * \n\n + * + * \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask. + * + * \param[in] ChannelIndex ADC channel number to set up for conversions. + */ + static inline void ADC_SetupChannel(const uint8_t ChannelIndex) + { + #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ + defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_ATmega32U6__)) + DDRF &= ~(1 << ChannelIndex); + DIDR0 |= (1 << ChannelIndex); + #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) + if (ChannelIndex < 8) + { + DDRF &= ~(1 << ChannelIndex); + DIDR0 |= (1 << ChannelIndex); + } + else if (ChannelIndex == 8) + { + DDRD &= ~(1 << 4); + DIDR2 |= (1 << 0); + } + else if (ChannelIndex < 11) + { + DDRD &= ~(1 << (ChannelIndex - 3)); + DIDR2 |= (1 << (ChannelIndex - 8)); + } + else + { + DDRB &= ~(1 << (ChannelIndex - 7)); + DIDR2 |= (1 << (ChannelIndex - 8)); + } + #endif + } + + /** De-configures the given ADC channel, re-enabling digital I/O mode instead of analog. This + * function sets the associated port pin as an input and re-enabled the digital portion of + * the I/O. + * + * \note This must only be called for ADC channels with are connected to a physical port + * pin of the AVR, denoted by its special alternative function ADCx. + * \n\n + * + * \note The channel number must be specified as an integer, and NOT a ADC_CHANNELx mask. + * + * \param[in] ChannelIndex ADC channel number to set up for conversions. + */ + static inline void ADC_DisableChannel(const uint8_t ChannelIndex) + { + #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ + defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_ATmega32U6__)) + DDRF &= ~(1 << ChannelIndex); + DIDR0 &= ~(1 << ChannelIndex); + #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) + if (ChannelIndex < 8) + { + DDRF &= ~(1 << ChannelIndex); + DIDR0 &= ~(1 << ChannelIndex); + } + else if (ChannelIndex == 8) + { + DDRD &= ~(1 << 4); + DIDR2 &= ~(1 << 0); + } + else if (ChannelIndex < 11) + { + DDRD &= ~(1 << (ChannelIndex - 3)); + DIDR2 &= ~(1 << (ChannelIndex - 8)); + } + else + { + DDRB &= ~(1 << (ChannelIndex - 7)); + DIDR2 &= ~(1 << (ChannelIndex - 8)); + } + #endif + } + + /** Starts the reading of the given channel, but does not wait until the conversion has completed. + * Once executed, the conversion status can be determined via the \ref ADC_IsReadingComplete() macro and + * the result read via the \ref ADC_GetResult() macro. + * + * If the ADC has been initialized in free running mode, calling this function once will begin the repeated + * conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed), + * this function must be called each time a conversion is to take place. + * + * \param[in] MUXMask ADC channel mask, reference mask and adjustment mask. + */ + static inline void ADC_StartReading(const uint16_t MUXMask) + { + ADMUX = MUXMask; + + #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__)) + if (MUXMask & (1 << 8)) + ADCSRB |= (1 << MUX5); + else + ADCSRB &= ~(1 << MUX5); + #endif + + ADCSRA |= (1 << ADSC); + } + + /** Indicates if the current ADC conversion is completed, or still in progress. + * + * \return Boolean false if the reading is still taking place, or true if the conversion is + * complete and ready to be read out with \ref ADC_GetResult(). + */ + static inline bool ADC_IsReadingComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool ADC_IsReadingComplete(void) + { + return ((ADCSRA & (1 << ADIF)) ? true : false); + } + + /** Retrieves the conversion value of the last completed ADC conversion and clears the reading + * completion flag. + * + * \return The result of the last ADC conversion as an unsigned value. + */ + static inline uint16_t ADC_GetResult(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t ADC_GetResult(void) + { + ADCSRA |= (1 << ADIF); + return ADC; + } + + /** Performs a complete single reading from channel, including a polling spin-loop to wait for the + * conversion to complete, and the returning of the converted value. + * + * \note For free running mode, the automated conversions should be initialized with a single call + * to \ref ADC_StartReading() to select the channel and begin the automated conversions, and + * the results read directly from the \ref ADC_GetResult() instead to reduce overhead. + * + * \param[in] MUXMask Mask comprising of an ADC channel mask, reference mask and adjustment mask. + */ + static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask) ATTR_WARN_UNUSED_RESULT; + static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask) + { + ADC_StartReading(MUXMask); + + while (!(ADC_IsReadingComplete())); + + return ADC_GetResult(); + } + + /** Initialises the ADC, ready for conversions. This must be called before any other ADC operations. + * The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and + * prescaler masks. + * + * \param[in] Mode Mask of ADC prescale and mode settings. + */ + static inline void ADC_Init(uint8_t Mode) ATTR_ALWAYS_INLINE; + static inline void ADC_Init(uint8_t Mode) + { + ADCSRA = ((1 << ADEN) | Mode); + } + + /** Turns off the ADC. If this is called, any further ADC operations will require a call to + * \ref ADC_Init() before the ADC can be used again. + */ + static inline void ADC_ShutDown(void) ATTR_ALWAYS_INLINE; + static inline void ADC_ShutDown(void) + { + ADCSRA = 0; + } + + /** Indicates if the ADC is currently enabled. + * + * \return Boolean true if the ADC subsystem is currently enabled, false otherwise. + */ + static inline bool ADC_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool ADC_GetStatus(void) + { + return ((ADCSRA & (1 << ADEN)) ? true : false); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h b/firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h new file mode 100644 index 0000000..a797990 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/AVRU4U6U7/TWI.h @@ -0,0 +1,155 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 TWI peripheral driver for the U7, U6 and U4 USB AVRs. + * + * Master mode TWI driver for the AT90USB1287, AT90USB1286, AT90USB647, AT90USB646, ATMEGA16U4 and ATMEGA32U4 AVRs. + * + * \note This file should not be included directly. It is automatically included as needed by the TWI driver + * dispatch header located in LUFA/Drivers/Peripheral/TWI.h. + */ + +/** \ingroup Group_TWI + * @defgroup Group_TWI_AVRU4U6U7 Series U4, U6 and U7 Model TWI Driver + * + * Master mode TWI driver for the AT90USB1287, AT90USB1286, AT90USB647, AT90USB646, ATMEGA16U4 and ATMEGA32U4 AVRs. + * + * \note This file should not be included directly. It is automatically included as needed by the TWI driver + * dispatch header located in LUFA/Drivers/Peripheral/TWI.h. + * + * @{ + */ + +#ifndef __TWI_AVRU4U6U7_H__ +#define __TWI_AVRU4U6U7_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + #include + #include + #include + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_TWI_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/TWI.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Inline Functions: */ + /** Initialises the TWI hardware into master mode, ready for data transmission and reception. This must be + * before any other TWI operations. + */ + static inline void TWI_Init(void) ATTR_ALWAYS_INLINE; + static inline void TWI_Init(void) + { + TWCR |= (1 << TWEN); + } + + /** Turns off the TWI driver hardware. If this is called, any further TWI operations will require a call to + * \ref TWI_Init() before the TWI can be used again. + */ + static inline void TWI_ShutDown(void) ATTR_ALWAYS_INLINE; + static inline void TWI_ShutDown(void) + { + TWCR &= ~(1 << TWEN); + } + + /** Sends a TWI STOP onto the TWI bus, terminating communication with the currently addressed device. */ + static inline void TWI_StopTransmission(void) ATTR_ALWAYS_INLINE; + static inline void TWI_StopTransmission(void) + { + TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN)); + } + + /** Sends a byte to the currently addressed device on the TWI bus. + * + * \param[in] Byte Byte to send to the currently addressed device + * + * \return Boolean true if the recipient ACKed the byte, false otherwise + */ + static inline bool TWI_SendByte(const uint8_t Byte) + { + TWDR = Byte; + TWCR = ((1 << TWINT) | (1 << TWEN)); + while (!(TWCR & (1 << TWINT))); + + return ((TWSR & TW_STATUS_MASK) == TW_MT_DATA_ACK); + } + + /** Receives a byte from the currently addressed device on the TWI bus. + * + * \param[in] Byte Location where the read byte is to be stored + * \param[in] LastByte Indicates if the byte should be ACKed if false, NAKed if true + * + * \return Boolean true if the byte reception successfully completed, false otherwise + */ + static inline bool TWI_ReceiveByte(uint8_t* const Byte, + const bool LastByte) + { + uint8_t TWCRMask = ((1 << TWINT) | (1 << TWEN)); + + if (!(LastByte)) + TWCRMask |= (1 << TWEA); + + TWCR = TWCRMask; + while (!(TWCR & (1 << TWINT))); + *Byte = TWDR; + + return ((TWSR & TW_STATUS_MASK) == TW_MR_DATA_ACK); + } + + /* Function Prototypes: */ + /** Begins a master mode TWI bus communication with the given slave device address. + * + * \param[in] SlaveAddress Address of the slave TWI device to communicate with + * \param[in] TimeoutMS Timeout period within which the slave must respond, in milliseconds + * + * \return Boolean true if the device is ready for data, false otherwise + */ + bool TWI_StartTransmission(const uint8_t SlaveAddress, + const uint8_t TimeoutMS); + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Peripheral/SPI.h b/firmware/LUFA/Drivers/Peripheral/SPI.h new file mode 100644 index 0000000..957325e --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/SPI.h @@ -0,0 +1,208 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 SPI peripheral driver. + * + * Hardware SPI subsystem driver for the supported USB AVRs models. + */ + +/** \ingroup Group_PeripheralDrivers + * @defgroup Group_SPI SPI Driver - LUFA/Drivers/Peripheral/SPI.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Module Description + * Driver for the hardware SPI port available on most AVR models. This module provides + * an easy to use driver for the setup of and transfer of data over the AVR's SPI port. + * + * @{ + */ + +#ifndef __SPI_H__ +#define __SPI_H__ + + /* Includes: */ + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define SPI_USE_DOUBLESPEED (1 << SPE) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name SPI Prescaler Configuration Masks */ + //@{ + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 2. */ + #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED + + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 4. */ + #define SPI_SPEED_FCPU_DIV_4 0 + + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 8. */ + #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPR0)) + + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 16. */ + #define SPI_SPEED_FCPU_DIV_16 (1 << SPR0) + + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 32. */ + #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (1 << SPR1)) + + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 64. */ + #define SPI_SPEED_FCPU_DIV_64 (SPI_USE_DOUBLESPEED | (1 << SPR1) | (1 << SPR0)) + + /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 128. */ + #define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 << SPR0)) + //@} + + /** \name SPI SCK Polarity Configuration Masks */ + //@{ + /** SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the rising edge. */ + #define SPI_SCK_LEAD_RISING (0 << CPOL) + + /** SPI clock polarity mask for SPI_Init(). Indicates that the SCK should lead on the falling edge. */ + #define SPI_SCK_LEAD_FALLING (1 << CPOL) + //@} + + /** \name SPI Sample Edge Configuration Masks */ + //@{ + /** SPI data sample mode mask for SPI_Init(). Indicates that the data should sampled on the leading edge. */ + #define SPI_SAMPLE_LEADING (0 << CPHA) + + /** SPI data sample mode mask for SPI_Init(). Indicates that the data should be sampled on the trailing edge. */ + #define SPI_SAMPLE_TRAILING (1 << CPHA) + //@} + + /** \name SPI Data Ordering Configuration Masks */ + //@{ + /** SPI data order mask for SPI_Init(). Indicates that data should be shifted out MSB first. */ + #define SPI_ORDER_MSB_FIRST (0 << DORD) + + /** SPI data order mask for SPI_Init(). Indicates that data should be shifted out MSB first. */ + #define SPI_ORDER_LSB_FIRST (1 << DORD) + //@} + + /** \name SPI Mode Configuration Masks */ + //@{ + /** SPI mode mask for SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */ + #define SPI_MODE_SLAVE (0 << MSTR) + + /** SPI mode mask for SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */ + #define SPI_MODE_MASTER (1 << MSTR) + //@} + + /* Inline Functions: */ + /** Initialises the SPI subsystem, ready for transfers. Must be called before calling any other + * SPI routines. + * + * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the SPI_SPEED_*, + * SPI_SCK_*, SPI_SAMPLE_*, SPI_ORDER_* and SPI_MODE_* masks. + */ + static inline void SPI_Init(const uint8_t SPIOptions) + { + DDRB |= ((1 << 1) | (1 << 2)); + DDRB &= ~((1 << 0) | (1 << 3)); + PORTB |= ((1 << 0) | (1 << 3)); + + SPCR = ((1 << SPE) | SPIOptions); + + if (SPIOptions & SPI_USE_DOUBLESPEED) + SPSR |= (1 << SPI2X); + else + SPSR &= ~(1 << SPI2X); + } + + /** Turns off the SPI driver, disabling and returning used hardware to their default configuration. */ + static inline void SPI_ShutDown(void) + { + DDRB &= ~((1 << 1) | (1 << 2)); + PORTB &= ~((1 << 0) | (1 << 3)); + + SPCR = 0; + SPSR = 0; + } + + /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete. + * + * \param[in] Byte Byte to send through the SPI interface. + * + * \return Response byte from the attached SPI device. + */ + static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t SPI_TransferByte(const uint8_t Byte) + { + SPDR = Byte; + while (!(SPSR & (1 << SPIF))); + return SPDR; + } + + /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response + * byte sent to from the attached SPI device is ignored. + * + * \param[in] Byte Byte to send through the SPI interface. + */ + static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void SPI_SendByte(const uint8_t Byte) + { + SPDR = Byte; + while (!(SPSR & (1 << SPIF))); + } + + /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response + * byte from the attached SPI device is returned. + * + * \return The response byte from the attached SPI device. + */ + static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t SPI_ReceiveByte(void) + { + SPDR = 0x00; + while (!(SPSR & (1 << SPIF))); + return SPDR; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Peripheral/Serial.c b/firmware/LUFA/Drivers/Peripheral/Serial.c new file mode 100644 index 0000000..fe41b20 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/Serial.c @@ -0,0 +1,54 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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. +*/ + +#include "Serial.h" + +void Serial_TxString_P(const char* FlashStringPtr) +{ + uint8_t CurrByte; + + while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00) + { + Serial_TxByte(CurrByte); + FlashStringPtr++; + } +} + +void Serial_TxString(const char* StringPtr) +{ + uint8_t CurrByte; + + while ((CurrByte = *StringPtr) != 0x00) + { + Serial_TxByte(CurrByte); + StringPtr++; + } +} + diff --git a/firmware/LUFA/Drivers/Peripheral/Serial.h b/firmware/LUFA/Drivers/Peripheral/Serial.h new file mode 100644 index 0000000..9f42df6 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/Serial.h @@ -0,0 +1,167 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 USART peripheral driver. + * + * Driver for the USART subsystem on supported USB AVRs. + */ + +/** \ingroup Group_PeripheralDrivers + * @defgroup Group_Serial Serial USART Driver - LUFA/Drivers/Peripheral/Serial.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/Peripheral/Serial.c (Makefile source module name: LUFA_SRC_SERIAL) + * + * \section Module Description + * Hardware serial USART driver. This module provides an easy to use driver for + * the setup of and transfer of data over the AVR's USART port. + * + * @{ + */ + +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + + /* Includes: */ + #include + #include + #include + + #include "../../Common/Common.h" + #include "../Misc/TerminalCodes.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is + * not set. + */ + #define SERIAL_UBBRVAL(baud) ((((F_CPU / 16) + (baud / 2)) / (baud)) - 1) + + /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is + * set. + */ + #define SERIAL_2X_UBBRVAL(baud) ((((F_CPU / 8) + (baud / 2)) / (baud)) - 1) + + /* Function Prototypes: */ + /** Transmits a given string located in program space (FLASH) through the USART. + * + * \param[in] FlashStringPtr Pointer to a string located in program space. + */ + void Serial_TxString_P(const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1); + + /** Transmits a given string located in SRAM memory through the USART. + * + * \param[in] StringPtr Pointer to a string located in SRAM space. + */ + void Serial_TxString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1); + + /* Inline Functions: */ + /** Initializes the USART, ready for serial data transmission and reception. This initializes the interface to + * standard 8-bit, no parity, 1 stop bit settings suitable for most applications. + * + * \param[in] BaudRate Serial baud rate, in bits per second. + * \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate. + */ + static inline void Serial_Init(const uint32_t BaudRate, + const bool DoubleSpeed) + { + UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate)); + + UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10)); + UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0); + UCSR1B = ((1 << TXEN1) | (1 << RXEN1)); + + DDRD |= (1 << 3); + PORTD |= (1 << 2); + } + + /** Turns off the USART driver, disabling and returning used hardware to their default configuration. */ + static inline void Serial_ShutDown(void) + { + UCSR1B = 0; + UCSR1A = 0; + UCSR1C = 0; + + UBRR1 = 0; + + DDRD &= ~(1 << 3); + PORTD &= ~(1 << 2); + } + + /** Indicates whether a character has been received through the USART. + * + * \return Boolean true if a character has been received, false otherwise. + */ + static inline bool Serial_IsCharReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Serial_IsCharReceived(void) + { + return ((UCSR1A & (1 << RXC1)) ? true : false); + } + + /** Transmits a given byte through the USART. + * + * \param[in] DataByte Byte to transmit through the USART. + */ + static inline void Serial_TxByte(const char DataByte) ATTR_ALWAYS_INLINE; + static inline void Serial_TxByte(const char DataByte) + { + while (!(UCSR1A & (1 << UDRE1))); + UDR1 = DataByte; + } + + /** Receives a byte from the USART. This function blocks until a byte has been + * received; if non-blocking behaviour is required, test for a received character + * beforehand with \ref Serial_IsCharReceived(). + * + * \return Byte received from the USART. + */ + static inline char Serial_RxByte(void) ATTR_ALWAYS_INLINE; + static inline char Serial_RxByte(void) + { + while (!(UCSR1A & (1 << RXC1))); + return UDR1; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Peripheral/SerialStream.c b/firmware/LUFA/Drivers/Peripheral/SerialStream.c new file mode 100644 index 0000000..30aa5a4 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/SerialStream.c @@ -0,0 +1,54 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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_SERIALSTREAM_C +#include "SerialStream.h" + +FILE USARTStream = FDEV_SETUP_STREAM(SerialStream_TxByte, SerialStream_RxByte, _FDEV_SETUP_RW); + +static int SerialStream_TxByte(char DataByte, + FILE *Stream) +{ + (void)Stream; + + Serial_TxByte(DataByte); + return 0; +} + +static int SerialStream_RxByte(FILE *Stream) +{ + (void)Stream; + + if (!(Serial_IsCharReceived())) + return _FDEV_EOF; + + return Serial_RxByte(); +} + diff --git a/firmware/LUFA/Drivers/Peripheral/SerialStream.h b/firmware/LUFA/Drivers/Peripheral/SerialStream.h new file mode 100644 index 0000000..3e37667 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/SerialStream.h @@ -0,0 +1,116 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Standard avr-libc character stream driver for the USART. + * + * Serial stream driver for the USART subsystem on supported USB AVRs. This makes use of the functions in the + * regular USART driver (see \ref Group_Serial), but allows the avr-libc standard stream functions (printf, + * puts, etc.) to work with the + * USART. + */ + +/** \ingroup Group_PeripheralDrivers + * @defgroup Group_SerialStream Serial Stream Driver - LUFA/Drivers/Peripheral/SerialStream.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/Peripheral/SerialStream.c (Makefile source module name: LUFA_SRC_SERIALSTREAM) + * + * \section Module Description + * Serial stream driver for the USART subsystem on supported USB AVRs. This makes use of the functions in the + * regular USART driver (see \ref Group_Serial), but allows the avr-libc standard stream functions (printf, + * puts, etc.) to work with the + * USART. + * + * @{ + */ + +#ifndef __SERIAL_STREAM_H__ +#define __SERIAL_STREAM_H__ + + /* Includes: */ + #include + #include + + #include "Serial.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* External Variables: */ + extern FILE USARTStream; + + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_SERIALSTREAM_C) + static int SerialStream_TxByte(char DataByte, + FILE *Stream) ATTR_NON_NULL_PTR_ARG(2); + static int SerialStream_RxByte(FILE *Stream) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Public Interface - May be used in end-application: */ + /* Inline Functions: */ + /** Initialises the serial stream (and regular USART driver) so that both the stream and regular + * USART driver functions can be used. Must be called before any stream or regular USART functions. + * + * \param[in] BaudRate Baud rate to configure the USART to. + * \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate. + */ + static inline void SerialStream_Init(const uint32_t BaudRate, + const bool DoubleSpeed) + { + Serial_Init(BaudRate, DoubleSpeed); + + stdout = &USARTStream; + stdin = &USARTStream; + } + + /** Turns off the serial stream (and regular USART driver), disabling and returning used hardware to + * their default configuration. + */ + static inline void SerialStream_ShutDown(void) + { + Serial_ShutDown(); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/Peripheral/TWI.c b/firmware/LUFA/Drivers/Peripheral/TWI.c new file mode 100644 index 0000000..4694b0b --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/TWI.c @@ -0,0 +1,75 @@ +/* + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +#include "TWI.h" + +bool TWI_StartTransmission(const uint8_t SlaveAddress, + const uint8_t TimeoutMS) +{ + for (;;) + { + bool BusCaptured = false; + uint16_t TimeoutRemaining; + + TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN)); + + TimeoutRemaining = (TimeoutMS * 100); + while (TimeoutRemaining-- && !(BusCaptured)) + { + if (TWCR & (1 << TWINT)) + { + switch (TWSR & TW_STATUS_MASK) + { + case TW_START: + case TW_REP_START: + BusCaptured = true; + break; + case TW_MT_ARB_LOST: + TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN)); + continue; + default: + TWCR = (1 << TWEN); + return false; + } + } + + _delay_us(10); + } + + if (!(BusCaptured)) + { + TWCR = (1 << TWEN); + return false; + } + + TWDR = SlaveAddress; + TWCR = ((1 << TWINT) | (1 << TWEN)); + + TimeoutRemaining = (TimeoutMS * 100); + while (TimeoutRemaining--) + { + if (TWCR & (1 << TWINT)) + break; + + _delay_us(10); + } + + if (!(TimeoutRemaining)) + return false; + + switch (TWSR & TW_STATUS_MASK) + { + case TW_MT_SLA_ACK: + case TW_MR_SLA_ACK: + return true; + default: + TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN)); + return false; + } + } +} + diff --git a/firmware/LUFA/Drivers/Peripheral/TWI.h b/firmware/LUFA/Drivers/Peripheral/TWI.h new file mode 100644 index 0000000..ae918c3 --- /dev/null +++ b/firmware/LUFA/Drivers/Peripheral/TWI.h @@ -0,0 +1,72 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 TWI peripheral driver. + * + * This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC. + * + * User code should include this file, which will in turn include the correct ADC driver header file for the + * currently selected AVR model. + */ + +/** \ingroup Group_PeripheralDrivers + * @defgroup Group_TWI TWI Driver - LUFA/Drivers/Peripheral/TWI.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/Peripheral/TWI.c (Makefile source module name: LUFA_SRC_TWI) + * + * + * \section Module Description + * Master Mode Hardware TWI driver. This module provides an easy to use driver for the hardware + * TWI present on many AVR models, for the transmission and reception of data on a TWI bus. + */ + +#ifndef __TWI_H__ +#define __TWI_H__ + + /* Macros: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_TWI_H + #endif + + /* Includes: */ + #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ + defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ + defined(__AVR_ATmega32U6__)) + #include "AVRU4U6U7/TWI.h" + #else + #error "TWI is not available for the currently selected AVR model." + #endif + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Audio.h b/firmware/LUFA/Drivers/USB/Class/Audio.h new file mode 100644 index 0000000..70ababe --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Audio.h @@ -0,0 +1,75 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Audio Class driver. + * + * Master include file for the library USB Audio 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_USBClassAudio Audio 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/Audio.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Audio Class Driver module. This module contains an internal implementation of the USB Audio 1.0 Class, for Device + * USB mode only. User applications can use this class driver instead of implementing the Audio 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 Audio Class. + * + * @{ + */ + +#ifndef _AUDIO_CLASS_H_ +#define _AUDIO_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_AUDIO_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/Audio.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/CDC.h b/firmware/LUFA/Drivers/USB/Class/CDC.h new file mode 100644 index 0000000..d8b7b58 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/CDC.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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/CDC.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/CDC.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section 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 "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/CDC.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/CDC.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/Audio.h b/firmware/LUFA/Drivers/USB/Class/Common/Audio.h new file mode 100644 index 0000000..a635947 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/Audio.h @@ -0,0 +1,701 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Audio 1.0 Class driver. + * + * Common definitions and declarations for the library USB Audio 1.0 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_USBClassAudio + * @defgroup Group_USBClassAudioCommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * Audio 1.0 Class. + * + * @{ + */ + +#ifndef _AUDIO_CLASS_COMMON_H_ +#define _AUDIO_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_AUDIO_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + #if !defined(AUDIO_TOTAL_SAMPLE_RATES) || defined(__DOXYGEN__) + /** Total number of discrete audio sample rates supported by the device. This value can be overridden by defining this + * token in the project makefile to the desired value, and passing it to the compiler via the -D switch. + */ + #define AUDIO_TOTAL_SAMPLE_RATES 1 + #endif + + /** \name Audio Channel Masks */ + //@{ + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_LEFT_FRONT (1 << 0) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_RIGHT_FRONT (1 << 1) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_CENTER_FRONT (1 << 2) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_LOW_FREQ_ENHANCE (1 << 3) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_LEFT_SURROUND (1 << 4) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_RIGHT_SURROUND (1 << 5) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_LEFT_OF_CENTER (1 << 6) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_RIGHT_OF_CENTER (1 << 7) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_SURROUND (1 << 8) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_SIDE_LEFT (1 << 9) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_SIDE_RIGHT (1 << 10) + + /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_CHANNEL_TOP (1 << 11) + //@} + + /** \name Audio Feature Masks */ + //@{ + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_MUTE (1 << 0) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_VOLUME (1 << 1) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_BASS (1 << 2) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_MID (1 << 3) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_TREBLE (1 << 4) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_GRAPHIC_EQUALIZER (1 << 5) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_AUTOMATIC_GAIN (1 << 6) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_DELAY (1 << 7) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_BASS_BOOST (1 << 8) + + /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */ + #define AUDIO_FEATURE_BASS_LOUDNESS (1 << 9) + //@} + + /** \name Audio Terminal Types */ + //@{ + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_UNDEFINED 0x0100 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_STREAMING 0x0101 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_VENDOR 0x01FF + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_UNDEFINED 0x0200 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_MIC 0x0201 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_DESKTOP_MIC 0x0202 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_PERSONAL_MIC 0x0203 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_OMNIDIR_MIC 0x0204 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_MIC_ARRAY 0x0205 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_PROCESSING_MIC 0x0206 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_IN_OUT_UNDEFINED 0x0300 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_SPEAKER 0x0301 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_HEADPHONES 0x0302 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_HEAD_MOUNTED 0x0303 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_DESKTOP 0x0304 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_ROOM 0x0305 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_COMMUNICATION 0x0306 + + /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */ + #define AUDIO_TERMINAL_OUT_LOWFREQ 0x0307 + //@} + + /** Convenience macro to fill a 24-bit \ref USB_Audio_SampleFreq_t structure with the given sample rate as a 24-bit number. + * + * \param[in] freq Required audio sampling frequency in HZ + */ + #define AUDIO_SAMPLE_FREQ(freq) {((uint32_t)freq & 0x00FFFF), (((uint32_t)freq >> 16) & 0x0000FF)} + + /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint + * accepts only filled endpoint packets of audio samples. + */ + #define AUDIO_EP_FULL_PACKETS_ONLY (1 << 7) + + /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint + * will accept partially filled endpoint packets of audio samples. + */ + #define AUDIO_EP_ACCEPTS_SMALL_PACKETS (0 << 7) + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Audio + * device class. + */ + enum Audio_Descriptor_ClassSubclassProtocol_t + { + AUDIO_CSCP_AudioClass = 0x01, /**< Descriptor Class value indicating that the device or + * interface belongs to the USB Audio 1.0 class. + */ + AUDIO_CSCP_ControlSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or + * interface belongs to the Audio Control subclass. + */ + AUDIO_CSCP_ControlProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or + * interface belongs to the Audio Control protocol. + */ + AUDIO_CSCP_AudioStreamingSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or + * interface belongs to the MIDI Streaming subclass. + */ + AUDIO_CSCP_MIDIStreamingSubclass = 0x03, /**< Descriptor Subclass value indicating that the device or + * interface belongs to the Audio streaming subclass. + */ + AUDIO_CSCP_StreamingProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or + * interface belongs to the Streaming Audio protocol. + */ + }; + + /** Audio class specific interface description subtypes, for the Audio Control interface. */ + enum Audio_CSInterface_AC_SubTypes_t + { + AUDIO_DSUBTYPE_CSInterface_Header = 0x01, /**< Audio class specific control interface header. */ + AUDIO_DSUBTYPE_CSInterface_InputTerminal = 0x02, /**< Audio class specific control interface Input Terminal. */ + AUDIO_DSUBTYPE_CSInterface_OutputTerminal = 0x03, /**< Audio class specific control interface Output Terminal. */ + AUDIO_DSUBTYPE_CSInterface_Mixer = 0x04, /**< Audio class specific control interface Mixer Unit. */ + AUDIO_DSUBTYPE_CSInterface_Selector = 0x05, /**< Audio class specific control interface Selector Unit. */ + AUDIO_DSUBTYPE_CSInterface_Feature = 0x06, /**< Audio class specific control interface Feature Unit. */ + AUDIO_DSUBTYPE_CSInterface_Processing = 0x07, /**< Audio class specific control interface Processing Unit. */ + AUDIO_DSUBTYPE_CSInterface_Extension = 0x08, /**< Audio class specific control interface Extension Unit. */ + }; + + /** Audio class specific interface description subtypes, for the Audio Streaming interface. */ + enum Audio_CSInterface_AS_SubTypes_t + { + AUDIO_DSUBTYPE_CSInterface_General = 0x01, /**< Audio class specific streaming interface general descriptor. */ + AUDIO_DSUBTYPE_CSInterface_FormatType = 0x02, /**< Audio class specific streaming interface format type descriptor. */ + AUDIO_DSUBTYPE_CSInterface_FormatSpecific = 0x03, /**< Audio class specific streaming interface format information descriptor. */ + }; + + /** Audio class specific endpoint description subtypes, for the Audio Streaming interface. */ + enum Audio_CSEndpoint_SubTypes_t + { + AUDIO_DSUBTYPE_CSEndpoint_General = 0x01, /**< Audio class specific endpoint general descriptor. */ + }; + + /* Type Defines: */ + /** \brief Audio class-specific Input Terminal Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device + * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example, + * a USB endpoint). See the USB Audio specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_InputTerminal_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal. + */ + + uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ + uint16_t TerminalType; /**< Type of terminal, a TERMINAL_* mask. */ + uint8_t AssociatedOutputTerminal; /**< ID of associated output terminal, for physically grouped terminals + * such as the speaker and microphone of a phone handset. + */ + uint8_t TotalChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */ + uint16_t ChannelConfig; /**< CHANNEL_* masks indicating what channel layout is supported by this terminal. */ + + uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device. */ + uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_Audio_Descriptor_InputTerminal_t; + + /** \brief Audio class-specific Input Terminal Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device + * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example, + * a USB endpoint). See the USB Audio specification for more details. + * + * \see \ref USB_Audio_Descriptor_InputTerminal_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal. + */ + uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ + uint16_t wTerminalType; /**< Type of terminal, a TERMINAL_* mask. */ + uint8_t bAssocTerminal; /**< ID of associated output terminal, for physically grouped terminals + * such as the speaker and microphone of a phone handset. + */ + uint8_t bNrChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */ + uint16_t wChannelConfig; /**< CHANNEL_* masks indicating what channel layout is supported by this terminal. */ + + uint8_t iChannelNames; /**< Index of a string descriptor describing this channel within the device. */ + uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_Audio_StdDescriptor_InputTerminal_t; + + /** \brief Audio class-specific Output Terminal Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device + * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example, + * a USB endpoint). See the USB Audio specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_OutputTerminal_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal. + */ + + uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ + uint16_t TerminalType; /**< Type of terminal, a TERMINAL_* mask. */ + uint8_t AssociatedInputTerminal; /**< ID of associated input terminal, for physically grouped terminals + * such as the speaker and microphone of a phone handset. + */ + uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from. */ + + uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_Audio_Descriptor_OutputTerminal_t; + + /** \brief Audio class-specific Output Terminal Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device + * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example, + * a USB endpoint). See the USB Audio specification for more details. + * + * \see \ref USB_Audio_Descriptor_OutputTerminal_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; /**< Sub type value used to distinguish between audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, + * a value from the \ref Audio_CSInterface_AC_SubTypes_t enum. + */ + uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */ + uint16_t wTerminalType; /**< Type of terminal, a TERMINAL_* mask. */ + uint8_t bAssocTerminal; /**< ID of associated input terminal, for physically grouped terminals + * such as the speaker and microphone of a phone handset. + */ + uint8_t bSourceID; /**< ID value of the unit this terminal's audio is sourced from. */ + + uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_Audio_StdDescriptor_OutputTerminal_t; + + /** \brief Audio class-specific Interface Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to + * supply extra information about the audio device's layout to the host. See the USB Audio specification for more + * details. + * + * \see \ref USB_Audio_StdDescriptor_Interface_AC_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. + */ + + uint16_t ACSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version. */ + uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ + + uint8_t InCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */ + uint8_t InterfaceNumber; /**< Interface number of the associated Audio Streaming interface. */ + } USB_Audio_Descriptor_Interface_AC_t; + + /** \brief Audio class-specific Interface Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to + * supply extra information about the audio device's layout to the host. See the USB Audio specification for more + * details. + * + * \see \ref USB_Audio_Descriptor_Interface_AC_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. + */ + + uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors, + * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. + */ + + uint16_t bcdADC; /**< Binary coded decimal value, indicating the supported Audio Class specification version. */ + uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ + + uint8_t bInCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */ + uint8_t bInterfaceNumbers; /**< Interface number of the associated Audio Streaming interface. */ + } USB_Audio_StdDescriptor_Interface_AC_t; + + /** \brief Audio class-specific Feature Unit Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features + * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio + * specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_FeatureUnit_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature. + */ + + uint8_t UnitID; /**< ID value of this feature unit - must be a unique value within the device. */ + uint8_t SourceID; /**< Source ID value of the audio source input into this feature unit. */ + + uint8_t ControlSize; /**< Size of each element in the ChanelControlls array. */ + uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */ + + uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_Audio_Descriptor_FeatureUnit_t; + + /** \brief Audio class-specific Feature Unit Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features + * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio + * specification for more details. + * + * \see \ref USB_Audio_Descriptor_FeatureUnit_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature. + */ + + uint8_t bUnitID; /**< ID value of this feature unit - must be a unique value within the device. */ + uint8_t bSourceID; /**< Source ID value of the audio source input into this feature unit. */ + + uint8_t bControlSize; /**< Size of each element in the ChanelControlls array. */ + uint8_t bmaControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */ + + uint8_t iFeature; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_Audio_StdDescriptor_FeatureUnit_t; + + /** \brief Audio class-specific Streaming Audio Interface Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host + * how audio streams within the device are formatted. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_Interface_AS_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. + */ + + uint8_t TerminalLink; /**< ID value of the output terminal this descriptor is describing. */ + + uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */ + uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification. */ + } USB_Audio_Descriptor_Interface_AS_t; + + /** \brief Audio class-specific Streaming Audio Interface Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host + * how audio streams within the device are formatted. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_Descriptor_Interface_AS_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, + * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. + */ + + uint8_t bTerminalLink; /**< ID value of the output terminal this descriptor is describing. */ + + uint8_t bDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */ + uint16_t wFormatTag; /**< Format of the audio stream, see Audio Device Formats specification. */ + } USB_Audio_StdDescriptor_Interface_AS_t; + + /** \brief 24-Bit Audio Frequency Structure. + * + * Type define for a 24bit audio sample frequency structure. GCC does not contain a built in 24bit datatype, + * this this structure is used to build up the value instead. Fill this structure with the \ref AUDIO_SAMPLE_FREQ() macro. + */ + typedef struct + { + uint16_t LowWord; /**< Low 16 bits of the 24-bit value. */ + uint8_t HighByte; /**< Upper 8 bits of the 24-bit value. */ + } USB_Audio_SampleFreq_t; + + /** \brief Audio class-specific Format Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details + * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used + * in the device's audio streams. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_Format_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType. + */ + + uint8_t FormatType; /**< Format of the audio stream, see Audio Device Formats specification. */ + uint8_t Channels; /**< Total number of discrete channels in the stream. */ + + uint8_t SubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */ + uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream. */ + + uint8_t SampleFrequencyType; /**< Total number of sample frequencies supported by the device. */ + USB_Audio_SampleFreq_t SampleFrequencies[AUDIO_TOTAL_SAMPLE_RATES]; /**< Sample frequencies supported by the device (must be 24-bit). */ + } USB_Audio_Descriptor_Format_t; + + /** \brief Audio class-specific Format Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details + * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used + * in the device's audio streams. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_Descriptor_Format_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; /**< Sub type value used to distinguish between audio class-specific descriptors, + * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType. + */ + + uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors, + * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum. + */ + + uint8_t bFormatType; /**< Format of the audio stream, see Audio Device Formats specification. */ + uint8_t bNrChannels; /**< Total number of discrete channels in the stream. */ + + uint8_t bSubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */ + uint8_t bBitResolution; /**< Bits of resolution of each channel's samples in the stream. */ + + uint8_t bSampleFrequencyType; /**< Total number of sample frequencies supported by the device. */ + uint8_t SampleFrequencies[AUDIO_TOTAL_SAMPLE_RATES * 3]; /**< Sample frequencies supported by the device (must be 24-bit). */ + } USB_Audio_StdDescriptor_Format_t; + + /** \brief Audio class-specific Streaming Endpoint Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint + * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Std_t for the version of this type with standard element names. + */ + typedef struct + { + USB_Descriptor_Endpoint_t Endpoint; /**< Standard endpoint descriptor describing the audio endpoint. */ + + uint8_t Refresh; /**< Always set to zero for Audio class devices. */ + uint8_t SyncEndpointNumber; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */ + } USB_Audio_Descriptor_StreamEndpoint_Std_t; + + /** \brief Audio class-specific Streaming Endpoint Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint + * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_Descriptor_StreamEndpoint_Std_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. + */ + 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. + */ + + uint8_t bRefresh; /**< Always set to zero for Audio class devices. */ + uint8_t bSynchAddress; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */ + } USB_Audio_StdDescriptor_StreamEndpoint_Std_t; + + /** \brief Audio class-specific Extended Endpoint Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information + * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio + * class-specific extended endpoint descriptor. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Spc_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors, + * a value from the \ref Audio_CSEndpoint_SubTypes_t enum. + */ + + uint8_t Attributes; /**< Audio class-specific endpoint attributes, such as ACCEPTS_SMALL_PACKETS. */ + + uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */ + uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */ + } USB_Audio_Descriptor_StreamEndpoint_Spc_t; + + /** \brief Audio class-specific Extended Endpoint Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information + * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio + * class-specific extended endpoint descriptor. See the USB Audio specification for more details. + * + * \see \ref USB_Audio_Descriptor_StreamEndpoint_Spc_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors, + * a value from the \ref Audio_CSEndpoint_SubTypes_t enum. + */ + + uint8_t bmAttributes; /**< Audio class-specific endpoint attributes, such as ACCEPTS_SMALL_PACKETS. */ + + uint8_t bLockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */ + uint16_t wLockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */ + } USB_Audio_StdDescriptor_StreamEndpoint_Spc_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/CDC.h b/firmware/LUFA/Drivers/USB/Class/Common/CDC.h new file mode 100644 index 0000000..dabe438 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/CDC.h @@ -0,0 +1,372 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 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 "../../HighLevel/StdDescriptors.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 + + /* 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 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 Class value indicating that the device or interface + * belongs to no specific protocol of the CDC class. + */ + CDC_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Class 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 Managment 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. + */ + 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. + */ + } 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. + */ + 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. */ + } 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. + */ + 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 capabiltiies, refer + * to the CDC ACM specification. + */ + } 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. + */ + 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 capabiltiies, refer + * to the CDC ACM specification. + */ + } 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. + */ + 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. */ + } 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. + */ + 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. */ + } USB_CDC_StdDescriptor_FunctionalUnion_t; + + /** Type define for a CDC Line Encoding structure, used to hold the various encoding parameters for a virtual + * serial port. + */ + 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. */ + } CDC_LineEncoding_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/HID.h b/firmware/LUFA/Drivers/USB/Class/Common/HID.h new file mode 100644 index 0000000..ca2212e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/HID.h @@ -0,0 +1,451 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 HID Class driver. + * + * Common definitions and declarations for the library USB HID 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_USBClassHID + * @defgroup Group_USBClassHIDCommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * HID Class. + * + * @{ + */ + +#ifndef _HID_CLASS_COMMON_H_ +#define _HID_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + + #include + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_HID_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** \name Keyboard Standard Report Modifier Masks */ + //@{ + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_LEFTCTRL (1 << 0) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_LEFTSHIFT (1 << 1) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_LEFTALT (1 << 2) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_LEFTGUI (1 << 3) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_RIGHTCTRL (1 << 4) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_RIGHTALT (1 << 6) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ + #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7) + //@} + + /** \name Keyboard Standard Report LED Masks */ + //@{ + /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */ + #define HID_KEYBOARD_LED_NUMLOCK (1 << 0) + + /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */ + #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1) + + /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */ + #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2) + + /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */ + #define HID_KEYBOARD_LED_KATANA (1 << 3) + //@} + + /** \name Keyboard Standard Report Key Scancodes */ + //@{ + #define HID_KEYBOARD_SC_ERROR_ROLLOVER 0x01 + #define HID_KEYBOARD_SC_POST_FAIL 0x02 + #define HID_KEYBOARD_SC_ERROR_UNDEFINED 0x03 + #define HID_KEYBOARD_SC_A 0x04 + #define HID_KEYBOARD_SC_B 0x05 + #define HID_KEYBOARD_SC_C 0x06 + #define HID_KEYBOARD_SC_D 0x04 + #define HID_KEYBOARD_SC_E 0x08 + #define HID_KEYBOARD_SC_F 0x09 + #define HID_KEYBOARD_SC_G 0x0A + #define HID_KEYBOARD_SC_H 0x0B + #define HID_KEYBOARD_SC_I 0x0C + #define HID_KEYBOARD_SC_J 0x0D + #define HID_KEYBOARD_SC_K 0x0E + #define HID_KEYBOARD_SC_L 0x0F + #define HID_KEYBOARD_SC_M 0x10 + #define HID_KEYBOARD_SC_N 0x11 + #define HID_KEYBOARD_SC_O 0x12 + #define HID_KEYBOARD_SC_P 0x13 + #define HID_KEYBOARD_SC_Q 0x14 + #define HID_KEYBOARD_SC_R 0x15 + #define HID_KEYBOARD_SC_S 0x16 + #define HID_KEYBOARD_SC_T 0x17 + #define HID_KEYBOARD_SC_U 0x18 + #define HID_KEYBOARD_SC_V 0x19 + #define HID_KEYBOARD_SC_W 0x1A + #define HID_KEYBOARD_SC_X 0x1B + #define HID_KEYBOARD_SC_Y 0x1C + #define HID_KEYBOARD_SC_Z 0x1D + #define HID_KEYBOARD_SC_1_AND_EXCLAMATION 0x1E + #define HID_KEYBOARD_SC_2_AND_AT 0x1F + #define HID_KEYBOARD_SC_3_AND_HASHMARK 0x20 + #define HID_KEYBOARD_SC_4_AND_DOLLAR 0x21 + #define HID_KEYBOARD_SC_5_AND_PERCENTAGE 0x22 + #define HID_KEYBOARD_SC_6_AND_CARET 0x23 + #define HID_KEYBOARD_SC_7_AND_AND_AMPERSAND 0x24 + #define HID_KEYBOARD_SC_8_AND_ASTERISK 0x25 + #define HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS 0x26 + #define HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS 0x27 + #define HID_KEYBOARD_SC_ENTER 0x28 + #define HID_KEYBOARD_SC_ESCAPE 0x29 + #define HID_KEYBOARD_SC_BACKSPACE 0x2A + #define HID_KEYBOARD_SC_TAB 0x2B + #define HID_KEYBOARD_SC_SPACE 0x2C + #define HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE 0x2D + #define HID_KEYBOARD_SC_EQUAL_AND_PLUS 0x2E + #define HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE 0x2F + #define HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE 0x30 + #define HID_KEYBOARD_SC_BACKSLASH_AND_PIPE 0x31 + #define HID_KEYBOARD_SC_NON_US_HASHMARK_AND_TILDE 0x32 + #define HID_KEYBOARD_SC_SEMICOLON_AND_COLON 0x33 + #define HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE 0x34 + #define HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE 0x35 + #define HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN 0x36 + #define HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN 0x37 + #define HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK 0x38 + #define HID_KEYBOARD_SC_CAPS_LOCK 0x39 + #define HID_KEYBOARD_SC_F1 0x3A + #define HID_KEYBOARD_SC_F2 0x3B + #define HID_KEYBOARD_SC_F3 0x3C + #define HID_KEYBOARD_SC_F4 0x3D + #define HID_KEYBOARD_SC_F5 0x3E + #define HID_KEYBOARD_SC_F6 0x3F + #define HID_KEYBOARD_SC_F7 0x40 + #define HID_KEYBOARD_SC_F8 0x41 + #define HID_KEYBOARD_SC_F9 0x42 + #define HID_KEYBOARD_SC_F10 0x43 + #define HID_KEYBOARD_SC_F11 0x44 + #define HID_KEYBOARD_SC_F12 0x45 + #define HID_KEYBOARD_SC_PRINT_SCREEN 0x46 + #define HID_KEYBOARD_SC_SCROLL_LOCK 0x47 + #define HID_KEYBOARD_SC_PAUSE 0x48 + #define HID_KEYBOARD_SC_INSERT 0x49 + #define HID_KEYBOARD_SC_HOME 0x4A + #define HID_KEYBOARD_SC_PAGE_UP 0x4B + #define HID_KEYBOARD_SC_DELETE 0x4C + #define HID_KEYBOARD_SC_END 0x4D + #define HID_KEYBOARD_SC_PAGE_DOWN 0x4E + #define HID_KEYBOARD_SC_RIGHT_ARROW 0xEF + #define HID_KEYBOARD_SC_LEFT_ARROW 0x50 + #define HID_KEYBOARD_SC_DOWN_ARROW 0x51 + #define HID_KEYBOARD_SC_UP_ARROW 0x52 + #define HID_KEYBOARD_SC_NUM_LOCK 0x53 + #define HID_KEYBOARD_SC_KEYPAD_SLASH 0x54 + #define HID_KEYBOARD_SC_KEYPAD_ASTERISK 0x55 + #define HID_KEYBOARD_SC_KEYPAD_MINUS 0x56 + #define HID_KEYBOARD_SC_KEYPAD_PLUS 0x57 + #define HID_KEYBOARD_SC_KEYPAD_ENTER 0x58 + #define HID_KEYBOARD_SC_KEYPAD_1_AND_END 0x59 + #define HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW 0x5A + #define HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN 0x5B + #define HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW 0x5C + #define HID_KEYBOARD_SC_KEYPAD_5 0x5D + #define HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW 0x5E + #define HID_KEYBOARD_SC_KEYPAD_7_AND_HOME 0x5F + #define HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW 0x60 + #define HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP 0x61 + #define HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT 0x62 + #define HID_KEYBOARD_SC_KEYPAD_DOT_AND_DELETE 0x63 + #define HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE 0x64 + #define HID_KEYBOARD_SC_EQUAL_SIGN 0x67 + #define HID_KEYBOARD_SC_F13 0x68 + #define HID_KEYBOARD_SC_F14 0x69 + #define HID_KEYBOARD_SC_F15 0x6A + #define HID_KEYBOARD_SC_F16 0x6B + #define HID_KEYBOARD_SC_F17 0x6C + #define HID_KEYBOARD_SC_F18 0x6D + #define HID_KEYBOARD_SC_F19 0x6E + #define HID_KEYBOARD_SC_F20 0x6F + #define HID_KEYBOARD_SC_F21 0x70 + #define HID_KEYBOARD_SC_F22 0x71 + #define HID_KEYBOARD_SC_F23 0x72 + #define HID_KEYBOARD_SC_F24 0x73 + #define HID_KEYBOARD_SC_EXECUTE 0x74 + #define HID_KEYBOARD_SC_HELP 0x75 + #define HID_KEYBOARD_SC_MANU 0x76 + #define HID_KEYBOARD_SC_SELECT 0x77 + #define HID_KEYBOARD_SC_STOP 0x78 + #define HID_KEYBOARD_SC_AGAIN 0x79 + #define HID_KEYBOARD_SC_UNDO 0x7A + #define HID_KEYBOARD_SC_CUT 0x7B + #define HID_KEYBOARD_SC_COPY 0x7C + #define HID_KEYBOARD_SC_PASTE 0x7D + #define HID_KEYBOARD_SC_FIND 0x7E + #define HID_KEYBOARD_SC_MUTE 0x7F + #define HID_KEYBOARD_SC_VOLUME_UP 0x80 + #define HID_KEYBOARD_SC_VOLUME_DOWN 0x81 + #define HID_KEYBOARD_SC_LOCKING_CAPS_LOCK 0x82 + #define HID_KEYBOARD_SC_LOCKING_NUM_LOCK 0x83 + #define HID_KEYBOARD_SC_LOCKING_SCROLL_LOCK 0x84 + #define HID_KEYBOARD_SC_KEYPAD_COMMA 0x85 + #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN 0x86 + #define HID_KEYBOARD_SC_INTERNATIONAL1 0x87 + #define HID_KEYBOARD_SC_INTERNATIONAL2 0x88 + #define HID_KEYBOARD_SC_INTERNATIONAL3 0x8A + #define HID_KEYBOARD_SC_INTERNATIONAL5 0x8B + #define HID_KEYBOARD_SC_INTERNATIONAL6 0x8C + #define HID_KEYBOARD_SC_INTERNATIONAL7 0x8D + #define HID_KEYBOARD_SC_INTERNATIONAL8 0x8E + #define HID_KEYBOARD_SC_INTERNATIONAL9 0x8F + #define HID_KEYBOARD_SC_LANG1 0x90 + #define HID_KEYBOARD_SC_LANG2 0x91 + #define HID_KEYBOARD_SC_LANG3 0x92 + #define HID_KEYBOARD_SC_LANG4 0x93 + #define HID_KEYBOARD_SC_LANG5 0x94 + #define HID_KEYBOARD_SC_LANG6 0x95 + #define HID_KEYBOARD_SC_LANG7 0x96 + #define HID_KEYBOARD_SC_LANG8 0x97 + #define HID_KEYBOARD_SC_LANG9 0x98 + #define HID_KEYBOARD_SC_ALTERNATE_ERASE 0x99 + #define HID_KEYBOARD_SC_SISREQ 0x9A + #define HID_KEYBOARD_SC_CANCEL 0x9B + #define HID_KEYBOARD_SC_CLEAR 0x9C + #define HID_KEYBOARD_SC_PRIOR 0x9D + #define HID_KEYBOARD_SC_RETURN 0x9E + #define HID_KEYBOARD_SC_SEPARATOR 0x9F + #define HID_KEYBOARD_SC_OUT 0xA0 + #define HID_KEYBOARD_SC_OPER 0xA1 + #define HID_KEYBOARD_SC_CLEAR_AND_AGAIN 0xA2 + #define HID_KEYBOARD_SC_CRSEL_ANDPROPS 0xA3 + #define HID_KEYBOARD_SC_EXSEL 0xA4 + #define HID_KEYBOARD_SC_KEYPAD_00 0xB0 + #define HID_KEYBOARD_SC_KEYPAD_000 0xB1 + #define HID_KEYBOARD_SC_THOUSANDS_SEPARATOR 0xB2 + #define HID_KEYBOARD_SC_DECIMAL_SEPARATOR 0xB3 + #define HID_KEYBOARD_SC_CURRENCY_UNIT 0xB4 + #define HID_KEYBOARD_SC_CURRENCY_SUB_UNIT 0xB5 + #define HID_KEYBOARD_SC_KEYPAD_OPENING_PARENTHESIS 0xB6 + #define HID_KEYBOARD_SC_KEYPAD_CLOSING_PARENTHESIS 0xB7 + #define HID_KEYBOARD_SC_KEYPAD_OPENING_BRACE 0xB8 + #define HID_KEYBOARD_SC_KEYPAD_CLOSING_BRACE 0xB9 + #define HID_KEYBOARD_SC_KEYPAD_TAB 0xBA + #define HID_KEYBOARD_SC_KEYPAD_BACKSPACE 0xBB + #define HID_KEYBOARD_SC_KEYPAD_A 0xBC + #define HID_KEYBOARD_SC_KEYPAD_B 0xBD + #define HID_KEYBOARD_SC_KEYPAD_C 0xBE + #define HID_KEYBOARD_SC_KEYPAD_D 0xBF + #define HID_KEYBOARD_SC_KEYPAD_E 0xC0 + #define HID_KEYBOARD_SC_KEYPAD_F 0xC1 + #define HID_KEYBOARD_SC_KEYPAD_XOR 0xC2 + #define HID_KEYBOARD_SC_KEYPAD_CARET 0xC3 + #define HID_KEYBOARD_SC_KEYPAD_PERCENTAGE 0xC4 + #define HID_KEYBOARD_SC_KEYPAD_LESS_THAN_SIGN 0xC5 + #define HID_KEYBOARD_SC_KEYPAD_GREATER_THAN_SIGN 0xC6 + #define HID_KEYBOARD_SC_KEYPAD_AMP 0xC7 + #define HID_KEYBOARD_SC_KEYPAD_AMP_AMP 0xC8 + #define HID_KEYBOARD_SC_KEYPAD_PIPE 0xC9 + #define HID_KEYBOARD_SC_KEYPAD_PIPE_PIPE 0xCA + #define HID_KEYBOARD_SC_KEYPAD_COLON 0xCB + #define HID_KEYBOARD_SC_KEYPAD_HASHMARK 0xCC + #define HID_KEYBOARD_SC_KEYPAD_SPACE 0xCD + #define HID_KEYBOARD_SC_KEYPAD_AT 0xCE + #define HID_KEYBOARD_SC_KEYPAD_EXCLAMATION_SIGN 0xCF + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_STORE 0xD0 + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_RECALL 0xD1 + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_CLEAR 0xD2 + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_ADD 0xD3 + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_SUBTRACT 0xD4 + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_MULTIPLY 0xD5 + #define HID_KEYBOARD_SC_KEYPAD_MEMORY_DIVIDE 0xD6 + #define HID_KEYBOARD_SC_KEYPAD_PLUS_AND_MINUS 0xD7 + #define HID_KEYBOARD_SC_KEYPAD_CLEAR 0xD8 + #define HID_KEYBOARD_SC_KEYPAD_CLEAR_ENTRY 0xD9 + #define HID_KEYBOARD_SC_KEYPAD_BINARY 0xDA + #define HID_KEYBOARD_SC_KEYPAD_OCTAL 0xDB + #define HID_KEYBOARD_SC_KEYPAD_DECIMAL 0xDC + #define HID_KEYBOARD_SC_KEYPAD_HEXADECIMAL 0xDD + #define HID_KEYBOARD_SC_LEFT_CONTROL 0xE0 + #define HID_KEYBOARD_SC_LEFT_SHIFT 0xE1 + #define HID_KEYBOARD_SC_LEFT_ALT 0xE2 + #define HID_KEYBOARD_SC_LEFT_GUI 0xE3 + #define HID_KEYBOARD_SC_RIGHT_CONTROL 0xE4 + #define HID_KEYBOARD_SC_RIGHT_SHIFT 0xE5 + #define HID_KEYBOARD_SC_RIGHT_ALT 0xE6 + #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7 + //@} + + /* Type Defines: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the HID + * device class. + */ + enum HID_Descriptor_ClassSubclassProtocol_t + { + HID_CSCP_HIDClass = 0x03, /**< Descriptor Class value indicating that the device or interface + * belongs to the HID class. + */ + HID_CSCP_NonBootSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface + * does not implement a HID boot protocol. + */ + HID_CSCP_BootSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface + * implements a HID boot protocol. + */ + HID_CSCP_NonBootProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface + * does not belong to a HID boot protocol. + */ + HID_CSCP_KeyboardBootProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the Keyboard HID boot protocol. + */ + HID_CSCP_MouseBootProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the Mouse HID boot protocol. + */ + }; + + /** Enum for the HID class specific control requests that can be issued by the USB bus host. */ + enum HID_ClassRequests_t + { + HID_REQ_GetReport = 0x01, /**< HID class-specific Request to get the current HID report from the device. */ + HID_REQ_GetIdle = 0x02, /**< HID class-specific Request to get the current device idle count. */ + HID_REQ_GetProtocol = 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */ + HID_REQ_SetReport = 0x09, /**< HID class-specific Request to set the current HID report to the device. */ + HID_REQ_SetIdle = 0x0A, /**< HID class-specific Request to set the device's idle count. */ + HID_REQ_SetProtocol = 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */ + }; + + /** Enum for the HID class specific descriptor types. */ + enum HID_DescriptorTypes_t + { + HID_DTYPE_HID = 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */ + HID_DTYPE_Report = 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */ + }; + + /** Enum for the different types of HID reports. */ + enum HID_ReportItemTypes_t + { + HID_REPORT_ITEM_In = 0, /**< Indicates that the item is an IN report type. */ + HID_REPORT_ITEM_Out = 1, /**< Indicates that the item is an OUT report type. */ + HID_REPORT_ITEM_Feature = 2, /**< Indicates that the item is a FEATURE report type. */ + }; + + /** \brief HID class-specific HID Descriptor (LUFA naming conventions). + * + * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID + * specification for details on the structure elements. + * + * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + + uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to. */ + uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */ + + uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */ + + uint8_t HIDReportType; /**< Type of HID report, set to \ref HID_DTYPE_Report. */ + uint16_t HIDReportLength; /**< Length of the associated HID report descriptor, in bytes. */ + } USB_HID_Descriptor_HID_t; + + /** \brief HID class-specific HID Descriptor (USB-IF naming conventions). + * + * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID + * specification for details on the structure elements. + * + * \see \ref USB_HID_Descriptor_HID_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 bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. */ + uint8_t bCountryCode; /**< Country code of the localized device, or zero if universal. */ + + uint8_t bNumDescriptors; /**< Total number of HID report descriptors for the interface. */ + + uint8_t bDescriptorType2; /**< Type of HID report, set to \ref HID_DTYPE_Report. */ + uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */ + } USB_HID_StdDescriptor_HID_t; + + /** \brief Standard HID Boot Protocol Mouse Report. + * + * Type define for a standard Boot Protocol Mouse report + */ + typedef struct + { + uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */ + int8_t X; /**< Current delta X movement of the mouse. */ + int8_t Y; /**< Current delta Y movement on the mouse. */ + } USB_MouseReport_Data_t; + + /** \brief Standard HID Boot Protocol Keyboard Report. + * + * Type define for a standard Boot Protocol Keyboard report + */ + typedef struct + { + uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of + * HID_KEYBOARD_MODIFER_* masks). + */ + uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */ + uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */ + } USB_KeyboardReport_Data_t; + + /** Type define for the data type used to store HID report descriptor elements. */ + typedef uint8_t USB_Descriptor_HIDReport_Datatype_t; + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/MIDI.h b/firmware/LUFA/Drivers/USB/Class/Common/MIDI.h new file mode 100644 index 0000000..4a3be81 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/MIDI.h @@ -0,0 +1,293 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 MIDI Class driver. + * + * Common definitions and declarations for the library USB MIDI 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_USBClassMIDI + * @defgroup Group_USBClassMIDICommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * MIDI Class. + * + * @{ + */ + +#ifndef _MIDI_CLASS_COMMON_H_ +#define _MIDI_CLASS_COMMON_H_ + + /* Macros: */ + #define __INCLUDE_FROM_AUDIO_DRIVER + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + #include "Audio.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_MIDI_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** \name MIDI Command Values */ + //@{ + /** MIDI command for a note on (activation) event. */ + #define MIDI_COMMAND_NOTE_ON 0x90 + + /** MIDI command for a note off (deactivation) event. */ + #define MIDI_COMMAND_NOTE_OFF 0x80 + //@} + + /** Standard key press velocity value used for all note events. */ + #define MIDI_STANDARD_VELOCITY 64 + + /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel + * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address. + * + * \param[in] channel MIDI channel number to address. + */ + #define MIDI_CHANNEL(channel) ((channel) - 1) + + /* Enums: */ + /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */ + enum MIDI_JackTypes_t + { + MIDI_JACKTYPE_Embedded = 0x01, /**< MIDI class descriptor jack type value for an embedded (logical) MIDI input or output jack. */ + MIDI_JACKTYPE_External = 0x02, /**< MIDI class descriptor jack type value for an external (physical) MIDI input or output jack. */ + }; + + /* Type Defines: */ + /** \brief MIDI class-specific Streaming Interface Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host + * how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors. + * See the USB Audio specification for more details. + * + * \see \ref USB_MIDI_StdDescriptor_AudioInterface_AS_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors. */ + + uint16_t AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class + * specification version. + */ + uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ + } USB_MIDI_Descriptor_AudioInterface_AS_t; + + /** \brief MIDI class-specific Streaming Interface Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host + * how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors. + * See the USB Audio specification for more details. + * + * \see \ref USB_MIDI_Descriptor_AudioInterface_AS_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version. */ + uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */ + } USB_MIDI_StdDescriptor_AudioInterface_AS_t; + + /** \brief MIDI class-specific Input Jack Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either + * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint). + * + * \see \ref USB_MIDI_StdDescriptor_InputJack_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors. */ + + uint8_t JackType; /**< Type of jack, one of the JACKTYPE_* mask values. */ + uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */ + + uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_MIDI_Descriptor_InputJack_t; + + /** \brief MIDI class-specific Input Jack Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either + * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint). + * + * \see \ref USB_MIDI_Descriptor_InputJack_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t bJackType; /**< Type of jack, one of the JACKTYPE_* mask values. */ + uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */ + + uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_MIDI_StdDescriptor_InputJack_t; + + /** \brief MIDI class-specific Output Jack Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either + * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint). + * + * \see \ref USB_MIDI_StdDescriptor_OutputJack_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors. */ + + uint8_t JackType; /**< Type of jack, one of the JACKTYPE_* mask values. */ + uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */ + + uint8_t NumberOfPins; /**< Number of output channels within the jack, either physical or logical. */ + uint8_t SourceJackID[1]; /**< ID of each output pin's source data jack. */ + uint8_t SourcePinID[1]; /**< Pin number in the input jack of each output pin's source data. */ + + uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_MIDI_Descriptor_OutputJack_t; + + /** \brief MIDI class-specific Output Jack Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either + * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint). + * + * \see \ref USB_MIDI_Descriptor_OutputJack_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t bJackType; /**< Type of jack, one of the JACKTYPE_* mask values. */ + uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */ + + uint8_t bNrInputPins; /**< Number of output channels within the jack, either physical or logical. */ + uint8_t baSourceID[1]; /**< ID of each output pin's source data jack. */ + uint8_t baSourcePin[1]; /**< Pin number in the input jack of each output pin's source data. */ + + uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */ + } USB_MIDI_StdDescriptor_OutputJack_t; + + /** \brief Audio class-specific Jack Endpoint Descriptor (LUFA naming conventions). + * + * Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information + * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio + * class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details. + * + * \see \ref USB_MIDI_StdDescriptor_Jack_Endpoint_t for the version of this type with standard element names. + */ + 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 audio class-specific descriptors. */ + + uint8_t TotalEmbeddedJacks; /**< Total number of jacks inside this endpoint. */ + uint8_t AssociatedJackID[1]; /**< IDs of each jack inside the endpoint. */ + } USB_MIDI_Descriptor_Jack_Endpoint_t; + + /** \brief Audio class-specific Jack Endpoint Descriptor (USB-IF naming conventions). + * + * Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information + * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio + * class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details. + * + * \see \ref USB_MIDI_Descriptor_Jack_Endpoint_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. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t bNumEmbMIDIJack; /**< Total number of jacks inside this endpoint. */ + uint8_t bAssocJackID[1]; /**< IDs of each jack inside the endpoint. */ + } USB_MIDI_StdDescriptor_Jack_Endpoint_t; + + /** \brief MIDI Class Driver Event Packet. + * + * Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface. + */ + typedef struct + { + unsigned char Command : 4; /**< Upper nibble of the MIDI command being sent or received in the event packet. */ + unsigned char CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface. */ + + uint8_t Data1; /**< First byte of data in the MIDI event. */ + uint8_t Data2; /**< Second byte of data in the MIDI event. */ + uint8_t Data3; /**< Third byte of data in the MIDI event. */ + } MIDI_EventPacket_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/MassStorage.h b/firmware/LUFA/Drivers/USB/Class/Common/MassStorage.h new file mode 100644 index 0000000..fd24056 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/MassStorage.h @@ -0,0 +1,362 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Mass Storage Class driver. + * + * Common definitions and declarations for the library USB Mass Storage 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_USBClassMS + * @defgroup Group_USBClassMSCommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * Mass Storage Class. + * + * @{ + */ + +#ifndef _MS_CLASS_COMMON_H_ +#define _MS_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_MS_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */ + #define MS_CBW_SIGNATURE 0x43425355UL + + /** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */ + #define MS_CSW_SIGNATURE 0x53425355UL + + /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */ + #define MS_COMMAND_DIR_DATA_OUT (0 << 7) + + /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */ + #define MS_COMMAND_DIR_DATA_IN (1 << 7) + + /** \name SCSI Commands*/ + //@{ + /** SCSI Command Code for an INQUIRY command. */ + #define SCSI_CMD_INQUIRY 0x12 + + /** SCSI Command Code for a REQUEST SENSE command. */ + #define SCSI_CMD_REQUEST_SENSE 0x03 + + /** SCSI Command Code for a TEST UNIT READY command. */ + #define SCSI_CMD_TEST_UNIT_READY 0x00 + + /** SCSI Command Code for a READ CAPACITY (10) command. */ + #define SCSI_CMD_READ_CAPACITY_10 0x25 + + /** SCSI Command Code for a SEND DIAGNOSTIC command. */ + #define SCSI_CMD_SEND_DIAGNOSTIC 0x1D + + /** SCSI Command Code for a PREVENT ALLOW MEDIUM REMOVAL command. */ + #define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E + + /** SCSI Command Code for a WRITE (10) command. */ + #define SCSI_CMD_WRITE_10 0x2A + + /** SCSI Command Code for a READ (10) command. */ + #define SCSI_CMD_READ_10 0x28 + + /** SCSI Command Code for a WRITE (6) command. */ + #define SCSI_CMD_WRITE_6 0x0A + + /** SCSI Command Code for a READ (6) command. */ + #define SCSI_CMD_READ_6 0x08 + + /** SCSI Command Code for a VERIFY (10) command. */ + #define SCSI_CMD_VERIFY_10 0x2F + + /** SCSI Command Code for a MODE SENSE (6) command. */ + #define SCSI_CMD_MODE_SENSE_6 0x1A + + /** SCSI Command Code for a MODE SENSE (10) command. */ + #define SCSI_CMD_MODE_SENSE_10 0x5A + //@} + + /** \name SCSI Sense Key Values */ + //@{ + /** SCSI Sense Code to indicate no error has occurred. */ + #define SCSI_SENSE_KEY_GOOD 0x00 + + /** SCSI Sense Code to indicate that the device has recovered from an error. */ + #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01 + + /** SCSI Sense Code to indicate that the device is not ready for a new command. */ + #define SCSI_SENSE_KEY_NOT_READY 0x02 + + /** SCSI Sense Code to indicate an error whilst accessing the medium. */ + #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03 + + /** SCSI Sense Code to indicate a hardware has occurred. */ + #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04 + + /** SCSI Sense Code to indicate that an illegal request has been issued. */ + #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05 + + /** SCSI Sense Code to indicate that the unit requires attention from the host to indicate + * a reset event, medium removal or other condition. + */ + #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06 + + /** SCSI Sense Code to indicate that a write attempt on a protected block has been made. */ + #define SCSI_SENSE_KEY_DATA_PROTECT 0x07 + + /** SCSI Sense Code to indicate an error while trying to write to a write-once medium. */ + #define SCSI_SENSE_KEY_BLANK_CHECK 0x08 + + /** SCSI Sense Code to indicate a vendor specific error has occurred. */ + #define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09 + + /** SCSI Sense Code to indicate that an EXTENDED COPY command has aborted due to an error. */ + #define SCSI_SENSE_KEY_COPY_ABORTED 0x0A + + /** SCSI Sense Code to indicate that the device has aborted the issued command. */ + #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B + + /** SCSI Sense Code to indicate an attempt to write past the end of a partition has been made. */ + #define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D + + /** SCSI Sense Code to indicate that the source data did not match the data read from the medium. */ + #define SCSI_SENSE_KEY_MISCOMPARE 0x0E + //@} + + /** \name SCSI Additional Sense Codes */ + //@{ + /** SCSI Additional Sense Code to indicate no additional sense information is available. */ + #define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION 0x00 + + /** SCSI Additional Sense Code to indicate that the logical unit (LUN) addressed is not ready. */ + #define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY 0x04 + + /** SCSI Additional Sense Code to indicate an invalid field was encountered while processing the issued command. */ + #define SCSI_ASENSE_INVALID_FIELD_IN_CDB 0x24 + + /** SCSI Additional Sense Code to indicate that a medium that was previously indicated as not ready has now + * become ready for use. + */ + #define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE 0x28 + + /** SCSI Additional Sense Code to indicate that an attempt to write to a protected area was made. */ + #define SCSI_ASENSE_WRITE_PROTECTED 0x27 + + /** SCSI Additional Sense Code to indicate an error whilst formatting the device medium. */ + #define SCSI_ASENSE_FORMAT_ERROR 0x31 + + /** SCSI Additional Sense Code to indicate an invalid command was issued. */ + #define SCSI_ASENSE_INVALID_COMMAND 0x20 + + /** SCSI Additional Sense Code to indicate a write to a block out outside of the medium's range was issued. */ + #define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21 + + /** SCSI Additional Sense Code to indicate that no removable medium is inserted into the device. */ + #define SCSI_ASENSE_MEDIUM_NOT_PRESENT 0x3A + //@} + + /** \name SCSI Additional Sense Key Code Qualifiers */ + //@{ + /** SCSI Additional Sense Qualifier Code to indicate no additional sense qualifier information is available. */ + #define SCSI_ASENSEQ_NO_QUALIFIER 0x00 + + /** SCSI Additional Sense Qualifier Code to indicate that a medium format command failed to complete. */ + #define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED 0x01 + + /** SCSI Additional Sense Qualifier Code to indicate that an initializing command must be issued before the issued + * command can be executed. + */ + #define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED 0x02 + + /** SCSI Additional Sense Qualifier Code to indicate that an operation is currently in progress. */ + #define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07 + //@} + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Mass + * Storage device class. + */ + enum MS_Descriptor_ClassSubclassProtocol_t + { + MS_CSCP_MassStorageClass = 0x08, /**< Descriptor Class value indicating that the device or interface + * belongs to the Mass Storage class. + */ + MS_CSCP_SCSITransparentSubclass = 0x06, /**< Descriptor Subclass value indicating that the device or interface + * belongs to the SCSI Transparent Command Set subclass of the Mass + * storage class. + */ + MS_CSCP_BulkOnlyTransportProtocol = 0x50, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the Bulk Only Transport protocol of the Mass Storage class. + */ + }; + + /** Enum for the Mass Storage class specific control requests that can be issued by the USB bus host. */ + enum MS_ClassRequests_t + { + MS_REQ_GetMaxLUN = 0xFE, /**< Mass Storage class-specific request to retrieve the total number of Logical + * Units (drives) in the SCSI device. + */ + MS_REQ_MassStorageReset = 0xFF, /**< Mass Storage class-specific request to reset the Mass Storage interface, + * ready for the next command. + */ + }; + + /** Enum for the possible command status wrapper return status codes. */ + enum MS_CommandStatusCodes_t + { + MS_SCSI_COMMAND_Pass = 0, /**< Command completed with no error */ + MS_SCSI_COMMAND_Fail = 1, /**< Command failed to complete - host may check the exact error via a + * SCSI REQUEST SENSE command. + */ + MS_SCSI_COMMAND_PhaseError = 2, /**< Command failed due to being invalid in the current phase. */ + }; + + /* Type Defines: */ + /** \brief Mass Storage Class Command Block Wrapper. + * + * Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol. */ + typedef struct + { + uint32_t Signature; /**< Command block signature, must be CBW_SIGNATURE to indicate a valid Command Block. */ + uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */ + uint32_t DataTransferLength; /**< Length of the optional data portion of the issued command, in bytes. */ + uint8_t Flags; /**< Command block flags, indicating command data direction. */ + uint8_t LUN; /**< Logical Unit number this command is issued to. */ + uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array. */ + uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block. */ + } MS_CommandBlockWrapper_t; + + /** \brief Mass Storage Class Command Status Wrapper. + * + * Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol. + */ + typedef struct + { + uint32_t Signature; /**< Status block signature, must be CSW_SIGNATURE to indicate a valid Command Status. */ + uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */ + uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command. */ + uint8_t Status; /**< Status code of the issued command - a value from the \ref MS_CommandStatusCodes_t enum. */ + } MS_CommandStatusWrapper_t; + + /** \brief Mass Storage Class SCSI Sense Structure + * + * Type define for a SCSI Sense structure. Structures of this type are filled out by the + * device via the \ref MS_Host_RequestSense() function, indicating the current sense data of the + * device (giving explicit error codes for the last issued command). For details of the + * structure contents, refer to the SCSI specifications. + */ + typedef struct + { + uint8_t ResponseCode; + + uint8_t SegmentNumber; + + unsigned char SenseKey : 4; + unsigned char Reserved : 1; + unsigned char ILI : 1; + unsigned char EOM : 1; + unsigned char FileMark : 1; + + uint8_t Information[4]; + uint8_t AdditionalLength; + uint8_t CmdSpecificInformation[4]; + uint8_t AdditionalSenseCode; + uint8_t AdditionalSenseQualifier; + uint8_t FieldReplaceableUnitCode; + uint8_t SenseKeySpecific[3]; + } SCSI_Request_Sense_Response_t; + + /** \brief Mass Storage Class SCSI Inquiry Structure. + * + * Type define for a SCSI Inquiry structure. Structures of this type are filled out by the + * device via the \ref MS_Host_GetInquiryData() function, retrieving the attached device's + * information. + * + * For details of the structure contents, refer to the SCSI specifications. + */ + typedef struct + { + unsigned char DeviceType : 5; + unsigned char PeripheralQualifier : 3; + + unsigned char Reserved : 7; + unsigned char Removable : 1; + + uint8_t Version; + + unsigned char ResponseDataFormat : 4; + unsigned char Reserved2 : 1; + unsigned char NormACA : 1; + unsigned char TrmTsk : 1; + unsigned char AERC : 1; + + uint8_t AdditionalLength; + uint8_t Reserved3[2]; + + unsigned char SoftReset : 1; + unsigned char CmdQue : 1; + unsigned char Reserved4 : 1; + unsigned char Linked : 1; + unsigned char Sync : 1; + unsigned char WideBus16Bit : 1; + unsigned char WideBus32Bit : 1; + unsigned char RelAddr : 1; + + uint8_t VendorID[8]; + uint8_t ProductID[16]; + uint8_t RevisionID[4]; + } SCSI_Inquiry_Response_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/Printer.h b/firmware/LUFA/Drivers/USB/Class/Common/Printer.h new file mode 100644 index 0000000..47a7909 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/Printer.h @@ -0,0 +1,121 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Printer Class driver. + * + * Common definitions and declarations for the library USB Printer 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_USBClassPrinter + * @defgroup Group_USBClassPrinterCommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * Printer Class. + * + * @{ + */ + +#ifndef _PRINTER_CLASS_COMMON_H_ +#define _PRINTER_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_PRINTER_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** \name Virtual Printer Status Line Masks */ + //@{ + /** Port status mask for a printer device, indicating that an error has *not* occurred. */ + #define PRNT_PORTSTATUS_NOTERROR (1 << 3) + + /** Port status mask for a printer device, indicating that the device is currently selected. */ + #define PRNT_PORTSTATUS_SELECT (1 << 4) + + /** Port status mask for a printer device, indicating that the device is currently out of paper. */ + #define PRNT_PORTSTATUS_PAPEREMPTY (1 << 5) + //@} + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Printer + * device class. + */ + enum PRNT_Descriptor_ClassSubclassProtocol_t + { + PRNT_CSCP_PrinterClass = 0x07, /**< Descriptor Class value indicating that the device or interface + * belongs to the Printer class. + */ + PRNT_CSCP_PrinterSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface + * belongs to the Printer subclass. + */ + PRNT_CSCP_BidirectionalProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the Bidirectional protocol of the Printer class. + */ + }; + + /** Enum for the Printer class specific control requests that can be issued by the USB bus host. */ + enum PRNT_ClassRequests_t + { + PRNT_REQ_GetDeviceID = 0x00, /**< Printer class-specific request to retrieve the Unicode ID + * string of the device, containing the device's name, manufacturer + * and supported printer languages. + */ + PRNT_REQ_GetPortStatus = 0x01, /**< Printer class-specific request to get the current status of the + * virtual printer port, for device selection and ready states. + */ + PRNT_REQ_SoftReset = 0x02, /**< Printer class-specific request to reset the device, ready for new + * printer commands. + */ + }; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/RNDIS.h b/firmware/LUFA/Drivers/USB/Class/Common/RNDIS.h new file mode 100644 index 0000000..b4fb114 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/RNDIS.h @@ -0,0 +1,399 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 RNDIS Class driver. + * + * Common definitions and declarations for the library USB RNDIS 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_USBClassRNDIS + * @defgroup Group_USBClassRNDISCommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * RNDIS Class. + * + * @{ + */ + +#ifndef _RNDIS_CLASS_COMMON_H_ +#define _RNDIS_CLASS_COMMON_H_ + + /* Macros: */ + #define __INCLUDE_FROM_CDC_DRIVER + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + #include "CDC.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_RNDIS_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** Implemented RNDIS Version Major. */ + #define REMOTE_NDIS_VERSION_MAJOR 0x01 + + /** Implemented RNDIS Version Minor. */ + #define REMOTE_NDIS_VERSION_MINOR 0x00 + + /** \name RNDIS Message Values */ + //@{ + #define REMOTE_NDIS_PACKET_MSG 0x00000001UL + #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002UL + #define REMOTE_NDIS_HALT_MSG 0x00000003UL + #define REMOTE_NDIS_QUERY_MSG 0x00000004UL + #define REMOTE_NDIS_SET_MSG 0x00000005UL + #define REMOTE_NDIS_RESET_MSG 0x00000006UL + #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007UL + #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008UL + //@} + + /** \name RNDIS Response Values */ + //@{ + #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002UL + #define REMOTE_NDIS_QUERY_CMPLT 0x80000004UL + #define REMOTE_NDIS_SET_CMPLT 0x80000005UL + #define REMOTE_NDIS_RESET_CMPLT 0x80000006UL + #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL + //@} + + /** \name RNDIS Status Values */ + //@{ + #define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL + #define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL + #define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL + #define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL + #define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL + #define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL + //@} + + /** \name RNDIS Media States */ + //@{ + #define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL + #define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL + //@} + + #define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL + + /** \name RNDIS Connection Types */ + //@{ + #define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL + #define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL + //@} + + /** \name RNDIS Packet Types */ + //@{ + #define REMOTE_NDIS_PACKET_DIRECTED 0x00000001UL + #define REMOTE_NDIS_PACKET_MULTICAST 0x00000002UL + #define REMOTE_NDIS_PACKET_ALL_MULTICAST 0x00000004UL + #define REMOTE_NDIS_PACKET_BROADCAST 0x00000008UL + #define REMOTE_NDIS_PACKET_SOURCE_ROUTING 0x00000010UL + #define REMOTE_NDIS_PACKET_PROMISCUOUS 0x00000020UL + #define REMOTE_NDIS_PACKET_SMT 0x00000040UL + #define REMOTE_NDIS_PACKET_ALL_LOCAL 0x00000080UL + #define REMOTE_NDIS_PACKET_GROUP 0x00001000UL + #define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL + #define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL + #define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL + //@} + + /** \name RNDIS OID Values */ + //@{ + #define OID_GEN_SUPPORTED_LIST 0x00010101UL + #define OID_GEN_HARDWARE_STATUS 0x00010102UL + #define OID_GEN_MEDIA_SUPPORTED 0x00010103UL + #define OID_GEN_MEDIA_IN_USE 0x00010104UL + #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106UL + #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL + #define OID_GEN_LINK_SPEED 0x00010107UL + #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010AUL + #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010BUL + #define OID_GEN_VENDOR_ID 0x0001010CUL + #define OID_GEN_VENDOR_DESCRIPTION 0x0001010DUL + #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010EUL + #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL + #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL + #define OID_GEN_PHYSICAL_MEDIUM 0x00010202UL + #define OID_GEN_XMIT_OK 0x00020101UL + #define OID_GEN_RCV_OK 0x00020102UL + #define OID_GEN_XMIT_ERROR 0x00020103UL + #define OID_GEN_RCV_ERROR 0x00020104UL + #define OID_GEN_RCV_NO_BUFFER 0x00020105UL + #define OID_802_3_PERMANENT_ADDRESS 0x01010101UL + #define OID_802_3_CURRENT_ADDRESS 0x01010102UL + #define OID_802_3_MULTICAST_LIST 0x01010103UL + #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104UL + #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101UL + #define OID_802_3_XMIT_ONE_COLLISION 0x01020102UL + #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL + //@} + + /** Maximum size in bytes of a RNDIS control message which can be sent or received. */ + #define RNDIS_MESSAGE_BUFFER_SIZE 128 + + /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */ + #define ETHERNET_FRAME_SIZE_MAX 1500 + + /* Enums: */ + /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */ + enum RNDIS_ClassRequests_t + { + RNDIS_REQ_SendEncapsulatedCommand = 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */ + RNDIS_REQ_GetEncapsulatedResponse = 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */ + }; + + /** Enum for the possible NDIS adapter states. */ + enum RNDIS_States_t + { + RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized. */ + RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers. */ + RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers. */ + }; + + /** Enum for the RNDIS class specific notification requests that can be issued by a RNDIS device to a host. */ + enum RNDIS_ClassNotifications_t + { + RNDIS_NOTIF_ResponseAvailable = 0x01, /**< Notification request value for a RNDIS Response Available notification. */ + }; + + /** Enum for the NDIS hardware states. */ + enum NDIS_Hardware_Status_t + { + NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host. */ + NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing. */ + NDIS_HardwareStatus_Reset, /**< Hardware reset. */ + NDIS_HardwareStatus_Closing, /**< Hardware currently closing. */ + NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host. */ + }; + + /* Type Defines: */ + /** \brief MAC Address Structure. + * + * Type define for a physical MAC address of a device on a network. + */ + typedef struct + { + uint8_t Octets[6]; /**< Individual bytes of a MAC address */ + } MAC_Address_t; + + /** \brief RNDIS Ethernet Frame Packet Information Structure. + * + * Type define for an Ethernet frame buffer data and information structure. + */ + typedef struct + { + uint8_t FrameData[ETHERNET_FRAME_SIZE_MAX]; /**< Ethernet frame contents. */ + uint16_t FrameLength; /**< Length in bytes of the Ethernet frame stored in the buffer. */ + bool FrameInBuffer; /**< Indicates if a frame is currently stored in the buffer. */ + } Ethernet_Frame_Info_t; + + /** \brief RNDIS Common Message Header Structure. + * + * Type define for a RNDIS message header, sent before RNDIS messages. + */ + typedef struct + { + uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ + uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */ + } RNDIS_Message_Header_t; + + /** \brief RNDIS Message Structure. + * + * Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t DataOffset; + uint32_t DataLength; + uint32_t OOBDataOffset; + uint32_t OOBDataLength; + uint32_t NumOOBDataElements; + uint32_t PerPacketInfoOffset; + uint32_t PerPacketInfoLength; + uint32_t VcHandle; + uint32_t Reserved; + } RNDIS_Packet_Message_t; + + /** \brief RNDIS Initialization Message Structure. + * + * Type define for a RNDIS Initialize command message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + + uint32_t MajorVersion; + uint32_t MinorVersion; + uint32_t MaxTransferSize; + } RNDIS_Initialize_Message_t; + + /** \brief RNDIS Initialize Complete Message Structure. + * + * Type define for a RNDIS Initialize Complete response message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + + uint32_t MajorVersion; + uint32_t MinorVersion; + uint32_t DeviceFlags; + uint32_t Medium; + uint32_t MaxPacketsPerTransfer; + uint32_t MaxTransferSize; + uint32_t PacketAlignmentFactor; + uint32_t AFListOffset; + uint32_t AFListSize; + } RNDIS_Initialize_Complete_t; + + /** \brief RNDIS Keep Alive Message Structure. + * + * Type define for a RNDIS Keep Alive command message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + } RNDIS_KeepAlive_Message_t; + + /** \brief RNDIS Keep Alive Complete Message Structure. + * + * Type define for a RNDIS Keep Alive Complete response message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + } RNDIS_KeepAlive_Complete_t; + + /** \brief RNDIS Reset Complete Message Structure. + * + * Type define for a RNDIS Reset Complete response message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t Status; + + uint32_t AddressingReset; + } RNDIS_Reset_Complete_t; + + /** \brief RNDIS OID Property Set Message Structure. + * + * Type define for a RNDIS OID Property Set command message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + + uint32_t Oid; + uint32_t InformationBufferLength; + uint32_t InformationBufferOffset; + uint32_t DeviceVcHandle; + } RNDIS_Set_Message_t; + + /** \brief RNDIS OID Property Set Complete Message Structure. + * + * Type define for a RNDIS OID Property Set Complete response message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + } RNDIS_Set_Complete_t; + + /** \brief RNDIS OID Property Query Message Structure. + * + * Type define for a RNDIS OID Property Query command message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + + uint32_t Oid; + uint32_t InformationBufferLength; + uint32_t InformationBufferOffset; + uint32_t DeviceVcHandle; + } RNDIS_Query_Message_t; + + /** \brief RNDIS OID Property Query Complete Message Structure. + * + * Type define for a RNDIS OID Property Query Complete response message. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + + uint32_t InformationBufferLength; + uint32_t InformationBufferOffset; + } RNDIS_Query_Complete_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Common/StillImage.h b/firmware/LUFA/Drivers/USB/Class/Common/StillImage.h new file mode 100644 index 0000000..6347d59 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Common/StillImage.h @@ -0,0 +1,161 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Still Image Class driver. + * + * Common definitions and declarations for the library USB Still Image 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_USBClassSI + * @defgroup Group_USBClassSICommon Common Class Definitions + * + * \section Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * Still Image Class. + * + * @{ + */ + +#ifndef _SI_CLASS_COMMON_H_ +#define _SI_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../HighLevel/StdDescriptors.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SI_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** Length in bytes of a given Unicode string's character length. + * + * \param[in] Chars Total number of Unicode characters in the string. + * + * \return Number of bytes of the given unicode string. + */ + #define UNICODE_STRING_LENGTH(Chars) ((Chars) << 1) + + /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for + * a command container. + * + * \param[in] Params Number of parameters which are to be sent in the Param field of the container. + */ + #define PIMA_COMMAND_SIZE(Params) ((sizeof(PIMA_Container_t) - 12) + ((Params) * sizeof(uint32_t))) + + /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for + * a data container. + * + * \param[in] DataLen Length in bytes of the data in the container. + */ + #define PIMA_DATA_SIZE(DataLen) ((sizeof(PIMA_Container_t) - 12) + (DataLen)) + + /* Enums: */ + /** Enum for the possible PIMA contains types. */ + enum PIMA_Container_Types_t + { + PIMA_CONTAINER_Undefined = 0, /**< Undefined container type. */ + PIMA_CONTAINER_CommandBlock = 1, /**< Command Block container type. */ + PIMA_CONTAINER_DataBlock = 2, /**< Data Block container type. */ + PIMA_CONTAINER_ResponseBlock = 3, /**< Response container type. */ + PIMA_CONTAINER_EventBlock = 4, /**< Event Block container type. */ + }; + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the + * Still Image device class. + */ + enum SI_Descriptor_ClassSubclassProtocol_t + { + SI_CSCP_StillImageClass = 0x06, /**< Descriptor Class value indicating that the device or interface + * belongs to the Still Image class. + */ + SI_CSCP_StillImageSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface + * belongs to the Still Image subclass. + */ + SI_CSCP_BulkOnlyProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the Bulk Only Transport protocol of the Still Image class. + */ + }; + + /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */ + enum PIMA_ResponseCodes_t + { + PIMA_RESPONSE_OK = 1, /**< Response code indicating no error in the issued command. */ + PIMA_RESPONSE_GeneralError = 2, /**< Response code indicating a general error while processing the + * issued command. + */ + PIMA_RESPONSE_SessionNotOpen = 3, /**< Response code indicating that the sent command requires an open + * session before being issued. + */ + PIMA_RESPONSE_InvalidTransaction = 4, /**< Response code indicating an invalid transaction occurred. */ + PIMA_RESPONSE_OperationNotSupported = 5, /**< Response code indicating that the issued command is not supported + * by the attached device. + */ + PIMA_RESPONSE_ParameterNotSupported = 6, /**< Response code indicating that one or more of the issued command's + * parameters are not supported by the device. + */ + }; + + /* Type Defines: */ + /** \brief PIMA Still Image Device Command/Response Container. + * + * Type define for a PIMA container, use to send commands and receive responses to and from an + * attached Still Image device. + */ + typedef struct + { + uint32_t DataLength; /**< Length of the container and data, in bytes. */ + uint16_t Type; /**< Container type, a value from the \ref PIMA_Container_Types_t enum. */ + uint16_t Code; /**< Command, event or response code of the container. */ + uint32_t TransactionID; /**< Unique container ID to link blocks together. */ + uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only). */ + } PIMA_Container_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/Audio.c b/firmware/LUFA/Drivers/USB/Class/Device/Audio.c new file mode 100644 index 0000000..cc847e5 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/Audio.c @@ -0,0 +1,98 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_AUDIO_DRIVER +#define __INCLUDE_FROM_AUDIO_DEVICE_C +#include "Audio.h" + +void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if (USB_ControlRequest.wIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber) + return; + + switch (USB_ControlRequest.bRequest) + { + case REQ_SetInterface: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + AudioInterfaceInfo->State.InterfaceEnabled = ((USB_ControlRequest.wValue & 0xFF) != 0); + } + + break; + } +} + +bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) +{ + memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State)); + + for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) + { + uint16_t Size; + uint8_t Type; + uint8_t Direction; + + if (EndpointNum == AudioInterfaceInfo->Config.DataINEndpointNumber) + { + Size = AudioInterfaceInfo->Config.DataINEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_ISOCHRONOUS; + } + else if (EndpointNum == AudioInterfaceInfo->Config.DataOUTEndpointNumber) + { + Size = AudioInterfaceInfo->Config.DataOUTEndpointSize; + Direction = ENDPOINT_DIR_OUT; + Type = EP_TYPE_ISOCHRONOUS; + } + else + { + continue; + } + + if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, ENDPOINT_BANK_DOUBLE))) + { + return false; + } + } + + return true; +} + +#endif diff --git a/firmware/LUFA/Drivers/USB/Class/Device/Audio.h b/firmware/LUFA/Drivers/USB/Class/Device/Audio.h new file mode 100644 index 0000000..5ba688a --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/Audio.h @@ -0,0 +1,336 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Audio 1.0 Class driver. + * + * Device mode driver for the library USB Audio 1.0 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_USBClassAudio + * @defgroup Group_USBClassAudioDevice Audio 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/Audio.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Device Mode USB Class driver framework interface, for the Audio 1.0 USB Class driver. + * + * @{ + */ + +#ifndef _AUDIO_CLASS_DEVICE_H_ +#define _AUDIO_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/Audio.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_AUDIO_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_AUDIO_DEVICE_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief Audio Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each Audio interface + * within the user application, and passed to each of the Audio class driver functions as the + * AudioInterfaceInfo parameter. This stores each Audio interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this + * structure controls. + */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the incoming Audio Streaming data, if available + * (zero if unused). + */ + uint16_t DataINEndpointSize; /**< Size in bytes of the incoming Audio Streaming data endpoint, if available + * (zero if unused). + */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing Audio Streaming data, if available + * (zero if unused). + */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing Audio Streaming data endpoint, if available + * (zero if unused). + */ + } 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 + { + bool InterfaceEnabled; /**< Set and cleared by the class driver to indicate if the host has enabled the streaming endpoints + * of the Audio Streaming interface. + */ + } 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_Audio_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given Audio 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 Audio interface is selected. + * + * \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the endpoints were successfully configured, false otherwise. + */ + bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Processes incoming control requests from the host, that are directed to the given Audio class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + */ + void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /* Inline Functions: */ + /** General management task for a given Audio 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] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + */ + static inline void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + (void)AudioInterfaceInfo; + } + + /** Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming + * OUT endpoint ready for reading. + * + * \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] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the given Audio interface has a sample to be read, false otherwise. + */ + static inline bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled)) + return false; + + Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber); + return Endpoint_IsOUTReceived(); + } + + /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects + * the streaming IN endpoint ready for writing. + * + * \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] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean true if the given Audio interface is ready to accept the next sample, false otherwise. + */ + static inline bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled)) + return false; + + Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber); + return Endpoint_IsINReady(); + } + + /** Reads the next 8-bit audio sample from the current audio interface. + * + * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsSampleReceived() function to ensure + * ensure the correct endpoint is selected and ready for data. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Signed 8-bit audio sample from the audio interface. + */ + static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + int8_t Sample; + + (void)AudioInterfaceInfo; + + Sample = Endpoint_Read_Byte(); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + + return Sample; + } + + /** Reads the next 16-bit audio sample from the current audio interface. + * + * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsSampleReceived() function to ensure + * that the correct endpoint is selected and ready for data. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Signed 16-bit audio sample from the audio interface. + */ + static inline int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + int16_t Sample; + + (void)AudioInterfaceInfo; + + Sample = (int16_t)Endpoint_Read_Word_LE(); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + + return Sample; + } + + /** Reads the next 24-bit audio sample from the current audio interface. + * + * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsSampleReceived() function to ensure + * that the correct endpoint is selected and ready for data. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Signed 24-bit audio sample from the audio interface. + */ + static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + { + int32_t Sample; + + (void)AudioInterfaceInfo; + + Sample = (((uint32_t)Endpoint_Read_Byte() << 16) | Endpoint_Read_Word_LE()); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + + return Sample; + } + + /** Writes the next 8-bit audio sample to the current audio interface. + * + * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsReadyForNextSample() function to + * ensure that the correct endpoint is selected and ready for data. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * \param[in] Sample Signed 8-bit audio sample. + */ + static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int8_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int8_t Sample) + { + Endpoint_Write_Byte(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + Endpoint_ClearIN(); + } + + /** Writes the next 16-bit audio sample to the current audio interface. + * + * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsReadyForNextSample() function to + * ensure that the correct endpoint is selected and ready for data. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * \param[in] Sample Signed 16-bit audio sample. + */ + static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int16_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int16_t Sample) + { + Endpoint_Write_Word_LE(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + Endpoint_ClearIN(); + } + + /** Writes the next 24-bit audio sample to the current audio interface. + * + * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsReadyForNextSample() function to + * ensure that the correct endpoint is selected and ready for data. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * \param[in] Sample Signed 24-bit audio sample. + */ + static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int32_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const int32_t Sample) + { + Endpoint_Write_Byte(Sample >> 16); + Endpoint_Write_Word_LE(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpointSize) + Endpoint_ClearIN(); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/Audio.lst b/firmware/LUFA/Drivers/USB/Class/Device/Audio.lst new file mode 100644 index 0000000..711e651 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/Audio.lst @@ -0,0 +1,184 @@ + 1 .file "Audio.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.Audio_Device_ConfigureEndpoints,"ax",@progbits + 17 .global Audio_Device_ConfigureEndpoints + 19 Audio_Device_ConfigureEndpoints: + 20 .LFB82: + 21 .LSM0: + 22 .LVL0: + 23 0000 1F93 push r17 + 24 0002 CF93 push r28 + 25 0004 DF93 push r29 + 26 /* prologue: function */ + 27 /* frame size = 0 */ + 28 0006 EC01 movw r28,r24 + 29 .LSM1: + 30 0008 1F82 std Y+7,__zero_reg__ + 31 000a 11E0 ldi r17,lo8(1) + 32 .LVL1: + 33 .L8: + 34 .LBB14: + 35 .LBB15: + 36 .LSM2: + 37 000c 8981 ldd r24,Y+1 + 38 000e 1817 cp r17,r24 + 39 0010 01F4 brne .L2 + 40 .LSM3: + 41 0012 2A81 ldd r18,Y+2 + 42 0014 3B81 ldd r19,Y+3 + 43 .LVL2: + 44 0016 61E0 ldi r22,lo8(1) + 45 .LVL3: + 46 0018 00C0 rjmp .L3 + 47 .LVL4: + 48 .L2: + 49 .LSM4: + 50 001a 8C81 ldd r24,Y+4 + 51 001c 1817 cp r17,r24 + 52 001e 01F4 brne .L4 + 53 .LSM5: + 54 0020 2D81 ldd r18,Y+5 + 55 0022 3E81 ldd r19,Y+6 + 56 .LVL5: + 57 0024 60E0 ldi r22,lo8(0) + 58 .LVL6: + 59 .L3: + 60 0026 40E0 ldi r20,lo8(0) + 61 .LVL7: + 62 0028 88E0 ldi r24,lo8(8) + 63 002a 90E0 ldi r25,hi8(8) + 64 .LVL8: + 65 002c 00C0 rjmp .L5 + 66 .L6: + 67 .LBB16: + 68 .LBB17: + 69 .LBB18: + 70 .LBB19: + 71 .LSM6: + 72 002e 4F5F subi r20,lo8(-(1)) + 73 .LSM7: + 74 0030 880F lsl r24 + 75 0032 991F rol r25 + 76 .L5: + 77 .LSM8: + 78 0034 8217 cp r24,r18 + 79 0036 9307 cpc r25,r19 + 80 0038 00F0 brlo .L6 + 81 .LBE19: + 82 .LBE18: + 83 .LBE17: + 84 .LSM9: + 85 003a 6064 ori r22,lo8(64) + 86 003c 4295 swap r20 + 87 003e 407F andi r20,lo8(-16) + 88 0040 4660 ori r20,lo8(6) + 89 0042 812F mov r24,r17 + 90 .LVL9: + 91 0044 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 92 .LVL10: + 93 .LBE16: + 94 .LSM10: + 95 0048 8823 tst r24 + 96 004a 01F0 breq .L7 + 97 .L4: + 98 .LBE15: + 99 .LSM11: + 100 004c 1F5F subi r17,lo8(-(1)) + 101 004e 1530 cpi r17,lo8(5) + 102 0050 01F4 brne .L8 + 103 0052 81E0 ldi r24,lo8(1) + 104 .L7: + 105 /* epilogue start */ + 106 .LBE14: + 107 .LSM12: + 108 0054 DF91 pop r29 + 109 0056 CF91 pop r28 + 110 .LVL11: + 111 0058 1F91 pop r17 + 112 .LVL12: + 113 005a 0895 ret + 114 .LFE82: + 116 .section .text.Audio_Device_ProcessControlRequest,"ax",@progbits + 117 .global Audio_Device_ProcessControlRequest + 119 Audio_Device_ProcessControlRequest: + 120 .LFB81: + 121 .LSM13: + 122 .LVL13: + 123 0000 CF93 push r28 + 124 0002 DF93 push r29 + 125 /* prologue: function */ + 126 /* frame size = 0 */ + 127 0004 EC01 movw r28,r24 + 128 .LBB20: + 129 .LBB21: + 130 .LSM14: + 131 0006 8091 E800 lds r24,232 + 132 .LVL14: + 133 .LBE21: + 134 .LBE20: + 135 .LSM15: + 136 000a 83FF sbrs r24,3 + 137 000c 00C0 rjmp .L15 + 138 .LSM16: + 139 000e 8881 ld r24,Y + 140 0010 90E0 ldi r25,lo8(0) + 141 0012 2091 0000 lds r18,USB_ControlRequest+4 + 142 0016 3091 0000 lds r19,(USB_ControlRequest+4)+1 + 143 001a 2817 cp r18,r24 + 144 001c 3907 cpc r19,r25 + 145 001e 01F4 brne .L15 + 146 .LSM17: + 147 0020 8091 0000 lds r24,USB_ControlRequest+1 + 148 0024 8B30 cpi r24,lo8(11) + 149 0026 01F4 brne .L15 + 150 .LSM18: + 151 0028 8091 0000 lds r24,USB_ControlRequest + 152 002c 8130 cpi r24,lo8(1) + 153 002e 01F4 brne .L15 + 154 .LBB22: + 155 .LBB23: + 156 .LSM19: + 157 0030 8091 E800 lds r24,232 + 158 0034 877F andi r24,lo8(-9) + 159 0036 8093 E800 sts 232,r24 + 160 .LBE23: + 161 .LBE22: + 162 .LSM20: + 163 003a 0E94 0000 call Endpoint_ClearStatusStage + 164 .LSM21: + 165 003e 90E0 ldi r25,lo8(0) + 166 0040 8091 0000 lds r24,USB_ControlRequest+2 + 167 0044 8111 cpse r24,__zero_reg__ + 168 0046 91E0 ldi r25,lo8(1) + 169 .L14: + 170 0048 9F83 std Y+7,r25 + 171 .L15: + 172 /* epilogue start */ + 173 .LSM22: + 174 004a DF91 pop r29 + 175 004c CF91 pop r28 + 176 .LVL15: + 177 004e 0895 ret + 178 .LFE81: + 212 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Audio.c + /tmp/ccVOq125.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccVOq125.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccVOq125.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccVOq125.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccVOq125.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccVOq125.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccVOq125.s:19 .text.Audio_Device_ConfigureEndpoints:0000000000000000 Audio_Device_ConfigureEndpoints + /tmp/ccVOq125.s:119 .text.Audio_Device_ProcessControlRequest:0000000000000000 Audio_Device_ProcessControlRequest + +UNDEFINED SYMBOLS +Endpoint_ConfigureEndpoint_Prv +USB_ControlRequest +Endpoint_ClearStatusStage diff --git a/firmware/LUFA/Drivers/USB/Class/Device/Audio.o b/firmware/LUFA/Drivers/USB/Class/Device/Audio.o new file mode 100644 index 0000000..6658370 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Device/Audio.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Device/CDC.c b/firmware/LUFA/Drivers/USB/Class/Device/CDC.c new file mode 100644 index 0000000..0da5cc6 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/CDC.c @@ -0,0 +1,332 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_CDC_DRIVER +#define __INCLUDE_FROM_CDC_DEVICE_C +#include "CDC.h" + +void CDC_Device_Event_Stub(void) +{ + +} + +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(); + Endpoint_Write_Control_Stream_LE(&CDCInterfaceInfo->State.LineEncoding, sizeof(CDCInterfaceInfo->State.LineEncoding)); + Endpoint_ClearOUT(); + } + + break; + case CDC_REQ_SetLineEncoding: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_Read_Control_Stream_LE(&CDCInterfaceInfo->State.LineEncoding, sizeof(CDCInterfaceInfo->State.LineEncoding)); + Endpoint_ClearIN(); + + 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 Data, + 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(Data, Length, NO_STREAM_CALLBACK); +} + +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_Byte(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_Byte(); + + 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 = 0, + .wIndex = 0, + .wLength = sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), + }; + + Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost, + sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), + NO_STREAM_CALLBACK); + Endpoint_ClearIN(); +} + +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 + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/CDC.h b/firmware/LUFA/Drivers/USB/Class/Device/CDC.h new file mode 100644 index 0000000..4fa823a --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/CDC.h @@ -0,0 +1,342 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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/CDC.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section 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/CDC.h" + + #include + #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 + + #if defined(__INCLUDE_FROM_CDC_DEVICE_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #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 + { + const 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 + { + uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_* + * masks. This value is updated each time \ref CDC_Device_USBTask() is called. + */ + uint8_t DeviceToHost; /**< Control line states from the device to host, as a set of 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. + * + * \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Boolean true if the endpoints were successfully configured, 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 ControlLineStates.HostToDevice value inside the CDC interface structure passed as a parameter, set as + * a mask of 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 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] Data Pointer to the string to send to the host. + * \param[in] Length Size in bytes of the 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 Data, + const uint16_t Length) 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 + * 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 avr-libc library that accept a FILE stream as a destination (e.g. 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 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. + * + * \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 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. + * + * \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) + 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); + + void CDC_Device_Event_Stub(void); + 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/firmware/LUFA/Drivers/USB/Class/Device/CDC.lst b/firmware/LUFA/Drivers/USB/Class/Device/CDC.lst new file mode 100644 index 0000000..ceb9593 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/CDC.lst @@ -0,0 +1,1059 @@ + 1 .file "CDC.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.CDC_Device_Event_Stub,"ax",@progbits + 17 .global CDC_Device_Event_Stub + 19 CDC_Device_Event_Stub: + 20 .LFB81: + 21 .LSM0: + 22 /* prologue: function */ + 23 /* frame size = 0 */ + 24 /* epilogue start */ + 25 .LSM1: + 26 0000 0895 ret + 27 .LFE81: + 29 .section .text.CDC_Device_BytesReceived,"ax",@progbits + 30 .global CDC_Device_BytesReceived + 32 CDC_Device_BytesReceived: + 33 .LFB88: + 34 .LSM2: + 35 .LVL0: + 36 /* prologue: function */ + 37 /* frame size = 0 */ + 38 0000 FC01 movw r30,r24 + 39 .LSM3: + 40 0002 8091 0000 lds r24,USB_DeviceState + 41 .LVL1: + 42 0006 8430 cpi r24,lo8(4) + 43 0008 01F4 brne .L4 + 44 000a 8785 ldd r24,Z+15 + 45 000c 9089 ldd r25,Z+16 + 46 000e A189 ldd r26,Z+17 + 47 0010 B289 ldd r27,Z+18 + 48 0012 0097 sbiw r24,0 + 49 0014 A105 cpc r26,__zero_reg__ + 50 0016 B105 cpc r27,__zero_reg__ + 51 0018 01F0 breq .L4 + 52 .LSM4: + 53 001a 8581 ldd r24,Z+5 + 54 .LBB71: + 55 .LBB72: + 56 .LSM5: + 57 001c 8093 E900 sts 233,r24 + 58 .LBE72: + 59 .LBE71: + 60 .LBB73: + 61 .LBB74: + 62 .LSM6: + 63 0020 8091 E800 lds r24,232 + 64 .LBE74: + 65 .LBE73: + 66 .LSM7: + 67 0024 82FF sbrs r24,2 + 68 0026 00C0 rjmp .L4 + 69 .LBB75: + 70 .LBB76: + 71 .LSM8: + 72 0028 8091 F200 lds r24,242 + 73 .LBE76: + 74 .LBE75: + 75 .LSM9: + 76 002c 8823 tst r24 + 77 002e 01F4 brne .L5 + 78 .LBB77: + 79 .LBB78: + 80 .LSM10: + 81 0030 8091 E800 lds r24,232 + 82 0034 8B77 andi r24,lo8(123) + 83 0036 8093 E800 sts 232,r24 + 84 003a 00C0 rjmp .L4 + 85 .L5: + 86 .LBE78: + 87 .LBE77: + 88 .LBB79: + 89 .LBB80: + 90 .LSM11: + 91 003c 8091 F200 lds r24,242 + 92 0040 282F mov r18,r24 + 93 0042 30E0 ldi r19,lo8(0) + 94 0044 00C0 rjmp .L6 + 95 .L4: + 96 .LSM12: + 97 0046 20E0 ldi r18,lo8(0) + 98 0048 30E0 ldi r19,hi8(0) + 99 .L6: + 100 .LBE80: + 101 .LBE79: + 102 .LSM13: + 103 004a C901 movw r24,r18 + 104 /* epilogue start */ + 105 004c 0895 ret + 106 .LFE88: + 108 .section .text.CDC_Device_ReceiveByte,"ax",@progbits + 109 .global CDC_Device_ReceiveByte + 111 CDC_Device_ReceiveByte: + 112 .LFB89: + 113 .LSM14: + 114 .LVL2: + 115 /* prologue: function */ + 116 /* frame size = 0 */ + 117 0000 FC01 movw r30,r24 + 118 .LSM15: + 119 0002 8091 0000 lds r24,USB_DeviceState + 120 .LVL3: + 121 0006 8430 cpi r24,lo8(4) + 122 0008 01F4 brne .L9 + 123 000a 8785 ldd r24,Z+15 + 124 000c 9089 ldd r25,Z+16 + 125 000e A189 ldd r26,Z+17 + 126 0010 B289 ldd r27,Z+18 + 127 0012 0097 sbiw r24,0 + 128 0014 A105 cpc r26,__zero_reg__ + 129 0016 B105 cpc r27,__zero_reg__ + 130 0018 01F0 breq .L9 + 131 .LSM16: + 132 001a 8581 ldd r24,Z+5 + 133 .LBB81: + 134 .LBB82: + 135 .LSM17: + 136 001c 8093 E900 sts 233,r24 + 137 .LBE82: + 138 .LBE81: + 139 .LBB83: + 140 .LBB84: + 141 .LSM18: + 142 0020 8091 E800 lds r24,232 + 143 .LBE84: + 144 .LBE83: + 145 .LSM19: + 146 0024 82FF sbrs r24,2 + 147 0026 00C0 rjmp .L9 + 148 .L10: + 149 .LBB85: + 150 .LBB86: + 151 .LSM20: + 152 0028 8091 F200 lds r24,242 + 153 .LBE86: + 154 .LBE85: + 155 .LSM21: + 156 002c 8823 tst r24 + 157 002e 01F4 brne .L12 + 158 0030 2FEF ldi r18,lo8(-1) + 159 0032 3FEF ldi r19,hi8(-1) + 160 .LVL4: + 161 0034 00C0 rjmp .L13 + 162 .LVL5: + 163 .L12: + 164 .LBB87: + 165 .LBB88: + 166 .LSM22: + 167 0036 8091 F100 lds r24,241 + 168 .LBE88: + 169 .LBE87: + 170 .LSM23: + 171 003a 282F mov r18,r24 + 172 .LVL6: + 173 003c 30E0 ldi r19,lo8(0) + 174 .LVL7: + 175 .L13: + 176 .LBB89: + 177 .LBB90: + 178 .LSM24: + 179 003e 8091 F200 lds r24,242 + 180 .LBE90: + 181 .LBE89: + 182 .LSM25: + 183 0042 8823 tst r24 + 184 0044 01F4 brne .L11 + 185 .LBB91: + 186 .LBB92: + 187 .LSM26: + 188 0046 8091 E800 lds r24,232 + 189 004a 8B77 andi r24,lo8(123) + 190 004c 8093 E800 sts 232,r24 + 191 0050 00C0 rjmp .L11 + 192 .LVL8: + 193 .L9: + 194 0052 2FEF ldi r18,lo8(-1) + 195 0054 3FEF ldi r19,hi8(-1) + 196 .LVL9: + 197 .L11: + 198 .LBE92: + 199 .LBE91: + 200 .LSM27: + 201 0056 C901 movw r24,r18 + 202 .LVL10: + 203 /* epilogue start */ + 204 0058 0895 ret + 205 .LFE89: + 207 .section .text.CDC_Device_CreateStream,"ax",@progbits + 208 .global CDC_Device_CreateStream + 210 CDC_Device_CreateStream: + 211 .LFB91: + 212 .LSM28: + 213 .LVL11: + 214 /* prologue: function */ + 215 /* frame size = 0 */ + 216 0000 FB01 movw r30,r22 + 217 .LSM29: + 218 0002 2EE0 ldi r18,lo8(14) + 219 0004 DB01 movw r26,r22 + 220 0006 1D92 st X+,__zero_reg__ + 221 0008 2A95 dec r18 + 222 000a 01F4 brne .-6 + 223 000c 23E0 ldi r18,lo8(3) + 224 000e 2383 std Z+3,r18 + 225 0010 20E0 ldi r18,lo8(gs(CDC_Device_putchar)) + 226 0012 30E0 ldi r19,hi8(gs(CDC_Device_putchar)) + 227 0014 3187 std Z+9,r19 + 228 0016 2087 std Z+8,r18 + 229 0018 20E0 ldi r18,lo8(gs(CDC_Device_getchar)) + 230 001a 30E0 ldi r19,hi8(gs(CDC_Device_getchar)) + 231 001c 3387 std Z+11,r19 + 232 001e 2287 std Z+10,r18 + 233 .LSM30: + 234 0020 9587 std Z+13,r25 + 235 0022 8487 std Z+12,r24 + 236 /* epilogue start */ + 237 .LSM31: + 238 0024 0895 ret + 239 .LFE91: + 241 .section .text.CDC_Device_CreateBlockingStream,"ax",@progbits + 242 .global CDC_Device_CreateBlockingStream + 244 CDC_Device_CreateBlockingStream: + 245 .LFB92: + 246 .LSM32: + 247 .LVL12: + 248 /* prologue: function */ + 249 /* frame size = 0 */ + 250 0000 FB01 movw r30,r22 + 251 .LSM33: + 252 0002 2EE0 ldi r18,lo8(14) + 253 0004 DB01 movw r26,r22 + 254 0006 1D92 st X+,__zero_reg__ + 255 0008 2A95 dec r18 + 256 000a 01F4 brne .-6 + 257 000c 23E0 ldi r18,lo8(3) + 258 000e 2383 std Z+3,r18 + 259 0010 20E0 ldi r18,lo8(gs(CDC_Device_putchar)) + 260 0012 30E0 ldi r19,hi8(gs(CDC_Device_putchar)) + 261 0014 3187 std Z+9,r19 + 262 0016 2087 std Z+8,r18 + 263 0018 20E0 ldi r18,lo8(gs(CDC_Device_getchar_Blocking)) + 264 001a 30E0 ldi r19,hi8(gs(CDC_Device_getchar_Blocking)) + 265 001c 3387 std Z+11,r19 + 266 001e 2287 std Z+10,r18 + 267 .LSM34: + 268 0020 9587 std Z+13,r25 + 269 0022 8487 std Z+12,r24 + 270 /* epilogue start */ + 271 .LSM35: + 272 0024 0895 ret + 273 .LFE92: + 275 .section .text.CDC_Device_getchar,"ax",@progbits + 277 CDC_Device_getchar: + 278 .LFB94: + 279 .LSM36: + 280 .LVL13: + 281 /* prologue: function */ + 282 /* frame size = 0 */ + 283 .LSM37: + 284 0000 FC01 movw r30,r24 + 285 0002 8485 ldd r24,Z+12 + 286 0004 9585 ldd r25,Z+13 + 287 .LVL14: + 288 0006 0E94 0000 call CDC_Device_ReceiveByte + 289 000a 9C01 movw r18,r24 + 290 .LVL15: + 291 .LSM38: + 292 000c 97FF sbrs r25,7 + 293 000e 00C0 rjmp .L20 + 294 .LVL16: + 295 0010 2EEF ldi r18,lo8(-2) + 296 0012 3FEF ldi r19,hi8(-2) + 297 .LVL17: + 298 .L20: + 299 .LSM39: + 300 0014 C901 movw r24,r18 + 301 .LVL18: + 302 /* epilogue start */ + 303 0016 0895 ret + 304 .LFE94: + 306 .section .text.CDC_Device_SendControlLineStateChange,"ax",@progbits + 307 .global CDC_Device_SendControlLineStateChange + 309 CDC_Device_SendControlLineStateChange: + 310 .LFB90: + 311 .LSM40: + 312 .LVL19: + 313 0000 0F93 push r16 + 314 0002 1F93 push r17 + 315 0004 DF93 push r29 + 316 0006 CF93 push r28 + 317 0008 CDB7 in r28,__SP_L__ + 318 000a DEB7 in r29,__SP_H__ + 319 000c 2897 sbiw r28,8 + 320 000e 0FB6 in __tmp_reg__,__SREG__ + 321 0010 F894 cli + 322 0012 DEBF out __SP_H__,r29 + 323 0014 0FBE out __SREG__,__tmp_reg__ + 324 0016 CDBF out __SP_L__,r28 + 325 /* prologue: function */ + 326 /* frame size = 8 */ + 327 0018 8C01 movw r16,r24 + 328 .LSM41: + 329 001a 8091 0000 lds r24,USB_DeviceState + 330 .LVL20: + 331 001e 8430 cpi r24,lo8(4) + 332 0020 01F4 brne .L25 + 333 0022 F801 movw r30,r16 + 334 0024 8785 ldd r24,Z+15 + 335 0026 9089 ldd r25,Z+16 + 336 0028 A189 ldd r26,Z+17 + 337 002a B289 ldd r27,Z+18 + 338 002c 0097 sbiw r24,0 + 339 002e A105 cpc r26,__zero_reg__ + 340 0030 B105 cpc r27,__zero_reg__ + 341 0032 01F0 breq .L25 + 342 .LSM42: + 343 0034 8185 ldd r24,Z+9 + 344 .LBB93: + 345 .LBB94: + 346 .LSM43: + 347 0036 8093 E900 sts 233,r24 + 348 .LBE94: + 349 .LBE93: + 350 .LSM44: + 351 003a DE01 movw r26,r28 + 352 003c 1196 adiw r26,1 + 353 003e E0E0 ldi r30,lo8(C.17.3562) + 354 0040 F0E0 ldi r31,hi8(C.17.3562) + 355 0042 88E0 ldi r24,lo8(8) + 356 .L24: + 357 0044 0190 ld r0,Z+ + 358 0046 0D92 st X+,r0 + 359 0048 8150 subi r24,lo8(-(-1)) + 360 004a 01F4 brne .L24 + 361 .LSM45: + 362 004c CE01 movw r24,r28 + 363 004e 0196 adiw r24,1 + 364 0050 68E0 ldi r22,lo8(8) + 365 0052 70E0 ldi r23,hi8(8) + 366 0054 40E0 ldi r20,lo8(0) + 367 0056 50E0 ldi r21,hi8(0) + 368 0058 0E94 0000 call Endpoint_Write_Stream_LE + 369 .LSM46: + 370 005c C801 movw r24,r16 + 371 005e 0E96 adiw r24,14 + 372 0060 61E0 ldi r22,lo8(1) + 373 0062 70E0 ldi r23,hi8(1) + 374 0064 40E0 ldi r20,lo8(0) + 375 0066 50E0 ldi r21,hi8(0) + 376 0068 0E94 0000 call Endpoint_Write_Stream_LE + 377 .LBB95: + 378 .LBB96: + 379 .LSM47: + 380 006c 8091 E800 lds r24,232 + 381 0070 8E77 andi r24,lo8(126) + 382 0072 8093 E800 sts 232,r24 + 383 .L25: + 384 /* epilogue start */ + 385 .LBE96: + 386 .LBE95: + 387 .LSM48: + 388 0076 2896 adiw r28,8 + 389 0078 0FB6 in __tmp_reg__,__SREG__ + 390 007a F894 cli + 391 007c DEBF out __SP_H__,r29 + 392 007e 0FBE out __SREG__,__tmp_reg__ + 393 0080 CDBF out __SP_L__,r28 + 394 0082 CF91 pop r28 + 395 0084 DF91 pop r29 + 396 0086 1F91 pop r17 + 397 0088 0F91 pop r16 + 398 .LVL21: + 399 008a 0895 ret + 400 .LFE90: + 402 .section .text.CDC_Device_SendString,"ax",@progbits + 403 .global CDC_Device_SendString + 405 CDC_Device_SendString: + 406 .LFB85: + 407 .LSM49: + 408 .LVL22: + 409 /* prologue: function */ + 410 /* frame size = 0 */ + 411 0000 FC01 movw r30,r24 + 412 .LSM50: + 413 0002 8091 0000 lds r24,USB_DeviceState + 414 .LVL23: + 415 0006 8430 cpi r24,lo8(4) + 416 0008 01F4 brne .L28 + 417 000a 8785 ldd r24,Z+15 + 418 000c 9089 ldd r25,Z+16 + 419 000e A189 ldd r26,Z+17 + 420 0010 B289 ldd r27,Z+18 + 421 0012 0097 sbiw r24,0 + 422 0014 A105 cpc r26,__zero_reg__ + 423 0016 B105 cpc r27,__zero_reg__ + 424 0018 01F0 breq .L28 + 425 .LSM51: + 426 001a 8181 ldd r24,Z+1 + 427 .LBB97: + 428 .LBB98: + 429 .LSM52: + 430 001c 8093 E900 sts 233,r24 + 431 .LBE98: + 432 .LBE97: + 433 .LSM53: + 434 0020 CB01 movw r24,r22 + 435 0022 BA01 movw r22,r20 + 436 .LVL24: + 437 0024 40E0 ldi r20,lo8(0) + 438 0026 50E0 ldi r21,hi8(0) + 439 .LVL25: + 440 0028 0E94 0000 call Endpoint_Write_Stream_LE + 441 .LVL26: + 442 002c 0895 ret + 443 .LVL27: + 444 .L28: + 445 002e 82E0 ldi r24,lo8(2) + 446 .LSM54: + 447 0030 0895 ret + 448 .LFE85: + 450 .section .text.CDC_Device_Flush,"ax",@progbits + 451 .global CDC_Device_Flush + 453 CDC_Device_Flush: + 454 .LFB87: + 455 .LSM55: + 456 .LVL28: + 457 /* prologue: function */ + 458 /* frame size = 0 */ + 459 0000 FC01 movw r30,r24 + 460 .LSM56: + 461 0002 8091 0000 lds r24,USB_DeviceState + 462 .LVL29: + 463 0006 8430 cpi r24,lo8(4) + 464 0008 01F4 brne .L32 + 465 000a 8785 ldd r24,Z+15 + 466 000c 9089 ldd r25,Z+16 + 467 000e A189 ldd r26,Z+17 + 468 0010 B289 ldd r27,Z+18 + 469 0012 0097 sbiw r24,0 + 470 0014 A105 cpc r26,__zero_reg__ + 471 0016 B105 cpc r27,__zero_reg__ + 472 0018 01F0 breq .L32 + 473 .LSM57: + 474 001a 8181 ldd r24,Z+1 + 475 .LBB99: + 476 .LBB100: + 477 .LSM58: + 478 001c 8093 E900 sts 233,r24 + 479 .LBE100: + 480 .LBE99: + 481 .LBB101: + 482 .LBB102: + 483 .LSM59: + 484 0020 8091 F200 lds r24,242 + 485 .LBE102: + 486 .LBE101: + 487 .LSM60: + 488 0024 8823 tst r24 + 489 0026 01F0 breq .L33 + 490 .LBB103: + 491 .LBB104: + 492 .LSM61: + 493 0028 9091 E800 lds r25,232 + 494 .LBE104: + 495 .LBE103: + 496 .LBB105: + 497 .LBB106: + 498 .LSM62: + 499 002c 8091 E800 lds r24,232 + 500 0030 8E77 andi r24,lo8(126) + 501 0032 8093 E800 sts 232,r24 + 502 .LBE106: + 503 .LBE105: + 504 .LSM63: + 505 0036 95FD sbrc r25,5 + 506 0038 00C0 rjmp .L33 + 507 .LSM64: + 508 003a 0E94 0000 call Endpoint_WaitUntilReady + 509 .LVL30: + 510 003e 982F mov r25,r24 + 511 .LVL31: + 512 0040 8823 tst r24 + 513 0042 01F4 brne .L34 + 514 .LVL32: + 515 .LBB107: + 516 .LBB108: + 517 .LSM65: + 518 0044 8091 E800 lds r24,232 + 519 .LVL33: + 520 0048 8E77 andi r24,lo8(126) + 521 004a 8093 E800 sts 232,r24 + 522 004e 00C0 rjmp .L34 + 523 .LVL34: + 524 .L32: + 525 0050 92E0 ldi r25,lo8(2) + 526 .LVL35: + 527 0052 00C0 rjmp .L34 + 528 .LVL36: + 529 .L33: + 530 0054 90E0 ldi r25,lo8(0) + 531 .LVL37: + 532 .L34: + 533 .LBE108: + 534 .LBE107: + 535 .LSM66: + 536 0056 892F mov r24,r25 + 537 /* epilogue start */ + 538 0058 0895 ret + 539 .LFE87: + 541 .section .text.CDC_Device_USBTask,"ax",@progbits + 542 .global CDC_Device_USBTask + 544 CDC_Device_USBTask: + 545 .LFB84: + 546 .LSM67: + 547 .LVL38: + 548 /* prologue: function */ + 549 /* frame size = 0 */ + 550 0000 FC01 movw r30,r24 + 551 .LSM68: + 552 0002 8091 0000 lds r24,USB_DeviceState + 553 .LVL39: + 554 0006 8430 cpi r24,lo8(4) + 555 0008 01F4 brne .L38 + 556 000a 8785 ldd r24,Z+15 + 557 000c 9089 ldd r25,Z+16 + 558 000e A189 ldd r26,Z+17 + 559 0010 B289 ldd r27,Z+18 + 560 0012 0097 sbiw r24,0 + 561 0014 A105 cpc r26,__zero_reg__ + 562 0016 B105 cpc r27,__zero_reg__ + 563 0018 01F0 breq .L38 + 564 .LSM69: + 565 001a CF01 movw r24,r30 + 566 001c 0E94 0000 call CDC_Device_Flush + 567 .LVL40: + 568 .L38: + 569 0020 0895 ret + 570 .LFE84: + 572 .section .text.CDC_Device_getchar_Blocking,"ax",@progbits + 574 CDC_Device_getchar_Blocking: + 575 .LFB95: + 576 .LSM70: + 577 .LVL41: + 578 0000 CF93 push r28 + 579 0002 DF93 push r29 + 580 /* prologue: function */ + 581 /* frame size = 0 */ + 582 0004 EC01 movw r28,r24 + 583 0006 00C0 rjmp .L40 + 584 .LVL42: + 585 .L43: + 586 .LSM71: + 587 0008 8091 0000 lds r24,USB_DeviceState + 588 .LVL43: + 589 000c 8823 tst r24 + 590 000e 01F4 brne .L41 + 591 0010 2EEF ldi r18,lo8(-2) + 592 0012 3FEF ldi r19,hi8(-2) + 593 0014 00C0 rjmp .L42 + 594 .L41: + 595 .LSM72: + 596 0016 8C85 ldd r24,Y+12 + 597 0018 9D85 ldd r25,Y+13 + 598 001a 0E94 0000 call CDC_Device_USBTask + 599 .LVL44: + 600 .LSM73: + 601 001e 0E94 0000 call USB_USBTask + 602 .LVL45: + 603 .L40: + 604 .LSM74: + 605 0022 8C85 ldd r24,Y+12 + 606 0024 9D85 ldd r25,Y+13 + 607 0026 0E94 0000 call CDC_Device_ReceiveByte + 608 002a 9C01 movw r18,r24 + 609 .LVL46: + 610 002c 97FD sbrc r25,7 + 611 002e 00C0 rjmp .L43 + 612 .L42: + 613 .LSM75: + 614 0030 C901 movw r24,r18 + 615 .LVL47: + 616 /* epilogue start */ + 617 0032 DF91 pop r29 + 618 0034 CF91 pop r28 + 619 .LVL48: + 620 0036 0895 ret + 621 .LFE95: + 623 .section .text.CDC_Device_SendByte,"ax",@progbits + 624 .global CDC_Device_SendByte + 626 CDC_Device_SendByte: + 627 .LFB86: + 628 .LSM76: + 629 .LVL49: + 630 0000 1F93 push r17 + 631 /* prologue: function */ + 632 /* frame size = 0 */ + 633 0002 FC01 movw r30,r24 + 634 0004 162F mov r17,r22 + 635 .LSM77: + 636 0006 8091 0000 lds r24,USB_DeviceState + 637 .LVL50: + 638 000a 8430 cpi r24,lo8(4) + 639 000c 01F4 brne .L46 + 640 .LVL51: + 641 000e 8785 ldd r24,Z+15 + 642 0010 9089 ldd r25,Z+16 + 643 0012 A189 ldd r26,Z+17 + 644 0014 B289 ldd r27,Z+18 + 645 0016 0097 sbiw r24,0 + 646 0018 A105 cpc r26,__zero_reg__ + 647 001a B105 cpc r27,__zero_reg__ + 648 001c 01F0 breq .L46 + 649 .LSM78: + 650 001e 8181 ldd r24,Z+1 + 651 .LBB109: + 652 .LBB110: + 653 .LSM79: + 654 0020 8093 E900 sts 233,r24 + 655 .LBE110: + 656 .LBE109: + 657 .LBB111: + 658 .LBB112: + 659 .LSM80: + 660 0024 8091 E800 lds r24,232 + 661 .LBE112: + 662 .LBE111: + 663 .LSM81: + 664 0028 85FD sbrc r24,5 + 665 002a 00C0 rjmp .L47 + 666 .LBB113: + 667 .LBB114: + 668 .LBB115: + 669 .LSM82: + 670 002c 8091 E800 lds r24,232 + 671 0030 8E77 andi r24,lo8(126) + 672 0032 8093 E800 sts 232,r24 + 673 .LBE115: + 674 .LBE114: + 675 .LSM83: + 676 0036 0E94 0000 call Endpoint_WaitUntilReady + 677 .LVL52: + 678 003a 8823 tst r24 + 679 .LVL53: + 680 003c 01F4 brne .L48 + 681 .LVL54: + 682 .L47: + 683 .LBE113: + 684 .LBB116: + 685 .LBB117: + 686 .LSM84: + 687 003e 1093 F100 sts 241,r17 + 688 0042 80E0 ldi r24,lo8(0) + 689 0044 00C0 rjmp .L48 + 690 .LVL55: + 691 .L46: + 692 .LSM85: + 693 0046 82E0 ldi r24,lo8(2) + 694 .LVL56: + 695 .L48: + 696 .LVL57: + 697 /* epilogue start */ + 698 .LBE117: + 699 .LBE116: + 700 .LSM86: + 701 0048 1F91 pop r17 + 702 .LVL58: + 703 004a 0895 ret + 704 .LFE86: + 706 .section .text.CDC_Device_putchar,"ax",@progbits + 708 CDC_Device_putchar: + 709 .LFB93: + 710 .LSM87: + 711 .LVL59: + 712 /* prologue: function */ + 713 /* frame size = 0 */ + 714 0000 282F mov r18,r24 + 715 0002 FB01 movw r30,r22 + 716 .LSM88: + 717 0004 8485 ldd r24,Z+12 + 718 0006 9585 ldd r25,Z+13 + 719 .LVL60: + 720 0008 622F mov r22,r18 + 721 .LVL61: + 722 000a 0E94 0000 call CDC_Device_SendByte + 723 .LVL62: + 724 000e 8823 tst r24 + 725 0010 01F4 brne .L51 + 726 0012 20E0 ldi r18,lo8(0) + 727 0014 30E0 ldi r19,hi8(0) + 728 0016 00C0 rjmp .L52 + 729 .L51: + 730 0018 2FEF ldi r18,lo8(-1) + 731 001a 3FEF ldi r19,hi8(-1) + 732 .L52: + 733 .LSM89: + 734 001c C901 movw r24,r18 + 735 /* epilogue start */ + 736 001e 0895 ret + 737 .LFE93: + 739 .section .text.CDC_Device_ConfigureEndpoints,"ax",@progbits + 740 .global CDC_Device_ConfigureEndpoints + 742 CDC_Device_ConfigureEndpoints: + 743 .LFB83: + 744 .LSM90: + 745 .LVL63: + 746 0000 1F93 push r17 + 747 0002 CF93 push r28 + 748 0004 DF93 push r29 + 749 /* prologue: function */ + 750 /* frame size = 0 */ + 751 0006 EC01 movw r28,r24 + 752 .LSM91: + 753 0008 0D96 adiw r24,13 + 754 .LVL64: + 755 000a FC01 movw r30,r24 + 756 000c 89E0 ldi r24,lo8(9) + 757 000e DF01 movw r26,r30 + 758 0010 1D92 st X+,__zero_reg__ + 759 0012 8A95 dec r24 + 760 0014 01F4 brne .-6 + 761 0016 11E0 ldi r17,lo8(1) + 762 .LVL65: + 763 .L64: + 764 .LBB118: + 765 .LBB119: + 766 .LSM92: + 767 0018 8981 ldd r24,Y+1 + 768 001a 1817 cp r17,r24 + 769 001c 01F4 brne .L55 + 770 .LSM93: + 771 001e EA81 ldd r30,Y+2 + 772 0020 FB81 ldd r31,Y+3 + 773 .LVL66: + 774 .LSM94: + 775 0022 8C81 ldd r24,Y+4 + 776 .LVL67: + 777 0024 62E0 ldi r22,lo8(2) + 778 .LVL68: + 779 0026 00C0 rjmp .L67 + 780 .LVL69: + 781 .L55: + 782 .LSM95: + 783 0028 8D81 ldd r24,Y+5 + 784 002a 1817 cp r17,r24 + 785 002c 01F4 brne .L57 + 786 .LSM96: + 787 002e EE81 ldd r30,Y+6 + 788 0030 FF81 ldd r31,Y+7 + 789 .LVL70: + 790 .LSM97: + 791 0032 8885 ldd r24,Y+8 + 792 .LVL71: + 793 0034 62E0 ldi r22,lo8(2) + 794 .LVL72: + 795 0036 30E0 ldi r19,lo8(0) + 796 .LVL73: + 797 0038 00C0 rjmp .L56 + 798 .LVL74: + 799 .L57: + 800 .LSM98: + 801 003a 8985 ldd r24,Y+9 + 802 003c 1817 cp r17,r24 + 803 003e 01F4 brne .L58 + 804 .LSM99: + 805 0040 EA85 ldd r30,Y+10 + 806 0042 FB85 ldd r31,Y+11 + 807 .LVL75: + 808 .LSM100: + 809 0044 8C85 ldd r24,Y+12 + 810 .LVL76: + 811 0046 63E0 ldi r22,lo8(3) + 812 .LVL77: + 813 .L67: + 814 0048 31E0 ldi r19,lo8(1) + 815 .LVL78: + 816 .L56: + 817 .LSM101: + 818 004a 8823 tst r24 + 819 004c 01F4 brne .L59 + 820 004e 40E0 ldi r20,lo8(0) + 821 0050 00C0 rjmp .L60 + 822 .L59: + 823 0052 44E0 ldi r20,lo8(4) + 824 .L60: + 825 0054 20E0 ldi r18,lo8(0) + 826 .LVL79: + 827 0056 88E0 ldi r24,lo8(8) + 828 0058 90E0 ldi r25,hi8(8) + 829 .LVL80: + 830 005a 00C0 rjmp .L61 + 831 .L62: + 832 .LBB120: + 833 .LBB121: + 834 .LBB122: + 835 .LBB123: + 836 .LSM102: + 837 005c 2F5F subi r18,lo8(-(1)) + 838 .LSM103: + 839 005e 880F lsl r24 + 840 0060 991F rol r25 + 841 .L61: + 842 .LSM104: + 843 0062 8E17 cp r24,r30 + 844 0064 9F07 cpc r25,r31 + 845 0066 00F0 brlo .L62 + 846 .LBE123: + 847 .LBE122: + 848 .LBE121: + 849 .LSM105: + 850 0068 6295 swap r22 + 851 006a 660F lsl r22 + 852 006c 660F lsl r22 + 853 006e 607C andi r22,lo8(-64) + 854 0070 632B or r22,r19 + 855 0072 4260 ori r20,lo8(2) + 856 0074 2295 swap r18 + 857 0076 207F andi r18,lo8(-16) + 858 0078 422B or r20,r18 + 859 007a 812F mov r24,r17 + 860 .LVL81: + 861 007c 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 862 .LVL82: + 863 .LBE120: + 864 .LSM106: + 865 0080 8823 tst r24 + 866 0082 01F0 breq .L63 + 867 .L58: + 868 .LBE119: + 869 .LSM107: + 870 0084 1F5F subi r17,lo8(-(1)) + 871 0086 1530 cpi r17,lo8(5) + 872 0088 01F4 brne .L64 + 873 008a 81E0 ldi r24,lo8(1) + 874 .L63: + 875 /* epilogue start */ + 876 .LBE118: + 877 .LSM108: + 878 008c DF91 pop r29 + 879 008e CF91 pop r28 + 880 .LVL83: + 881 0090 1F91 pop r17 + 882 .LVL84: + 883 0092 0895 ret + 884 .LFE83: + 886 .section .text.CDC_Device_ProcessControlRequest,"ax",@progbits + 887 .global CDC_Device_ProcessControlRequest + 889 CDC_Device_ProcessControlRequest: + 890 .LFB82: + 891 .LSM109: + 892 .LVL85: + 893 0000 CF93 push r28 + 894 0002 DF93 push r29 + 895 /* prologue: function */ + 896 /* frame size = 0 */ + 897 0004 EC01 movw r28,r24 + 898 .LBB124: + 899 .LBB125: + 900 .LSM110: + 901 0006 8091 E800 lds r24,232 + 902 .LVL86: + 903 .LBE125: + 904 .LBE124: + 905 .LSM111: + 906 000a 83FF sbrs r24,3 + 907 000c 00C0 rjmp .L75 + 908 .LSM112: + 909 000e 8881 ld r24,Y + 910 0010 90E0 ldi r25,lo8(0) + 911 0012 2091 0000 lds r18,USB_ControlRequest+4 + 912 0016 3091 0000 lds r19,(USB_ControlRequest+4)+1 + 913 001a 2817 cp r18,r24 + 914 001c 3907 cpc r19,r25 + 915 001e 01F0 breq .+2 + 916 0020 00C0 rjmp .L75 + 917 .LSM113: + 918 0022 8091 0000 lds r24,USB_ControlRequest+1 + 919 0026 8132 cpi r24,lo8(33) + 920 0028 01F0 breq .L71 + 921 002a 8232 cpi r24,lo8(34) + 922 002c 00F4 brsh .L74 + 923 002e 8032 cpi r24,lo8(32) + 924 0030 01F0 breq .+2 + 925 0032 00C0 rjmp .L75 + 926 0034 00C0 rjmp .L76 + 927 .L74: + 928 0036 8232 cpi r24,lo8(34) + 929 0038 01F0 breq .L72 + 930 003a 8332 cpi r24,lo8(35) + 931 003c 01F0 breq .+2 + 932 003e 00C0 rjmp .L75 + 933 0040 00C0 rjmp .L77 + 934 .L71: + 935 .LSM114: + 936 0042 8091 0000 lds r24,USB_ControlRequest + 937 0046 813A cpi r24,lo8(-95) + 938 0048 01F0 breq .+2 + 939 004a 00C0 rjmp .L75 + 940 .LBB126: + 941 .LBB127: + 942 .LSM115: + 943 004c 8091 E800 lds r24,232 + 944 0050 877F andi r24,lo8(-9) + 945 0052 8093 E800 sts 232,r24 + 946 .LBE127: + 947 .LBE126: + 948 .LSM116: + 949 0056 CE01 movw r24,r28 + 950 0058 0F96 adiw r24,15 + 951 005a 67E0 ldi r22,lo8(7) + 952 005c 70E0 ldi r23,hi8(7) + 953 005e 0E94 0000 call Endpoint_Write_Control_Stream_LE + 954 .LBB128: + 955 .LBB129: + 956 .LSM117: + 957 0062 8091 E800 lds r24,232 + 958 0066 8B77 andi r24,lo8(123) + 959 0068 8093 E800 sts 232,r24 + 960 006c 00C0 rjmp .L75 + 961 .L76: + 962 .LBE129: + 963 .LBE128: + 964 .LSM118: + 965 006e 8091 0000 lds r24,USB_ControlRequest + 966 0072 8132 cpi r24,lo8(33) + 967 0074 01F4 brne .L75 + 968 .LBB130: + 969 .LBB131: + 970 .LSM119: + 971 0076 8091 E800 lds r24,232 + 972 007a 877F andi r24,lo8(-9) + 973 007c 8093 E800 sts 232,r24 + 974 .LBE131: + 975 .LBE130: + 976 .LSM120: + 977 0080 CE01 movw r24,r28 + 978 0082 0F96 adiw r24,15 + 979 0084 67E0 ldi r22,lo8(7) + 980 0086 70E0 ldi r23,hi8(7) + 981 0088 0E94 0000 call Endpoint_Read_Control_Stream_LE + 982 .LBB132: + 983 .LBB133: + 984 .LSM121: + 985 008c 8091 E800 lds r24,232 + 986 0090 8E77 andi r24,lo8(126) + 987 0092 8093 E800 sts 232,r24 + 988 .LBE133: + 989 .LBE132: + 990 .LSM122: + 991 0096 CE01 movw r24,r28 + 992 0098 0E94 0000 call EVENT_CDC_Device_LineEncodingChanged + 993 009c 00C0 rjmp .L75 + 994 .L72: + 995 .LSM123: + 996 009e 8091 0000 lds r24,USB_ControlRequest + 997 00a2 8132 cpi r24,lo8(33) + 998 00a4 01F4 brne .L75 + 999 .LBB134: + 1000 .LBB135: + 1001 .LSM124: + 1002 00a6 8091 E800 lds r24,232 + 1003 00aa 877F andi r24,lo8(-9) + 1004 00ac 8093 E800 sts 232,r24 + 1005 .LBE135: + 1006 .LBE134: + 1007 .LSM125: + 1008 00b0 0E94 0000 call Endpoint_ClearStatusStage + 1009 .LSM126: + 1010 00b4 8091 0000 lds r24,USB_ControlRequest+2 + 1011 00b8 8D87 std Y+13,r24 + 1012 .LSM127: + 1013 00ba CE01 movw r24,r28 + 1014 00bc 0E94 0000 call EVENT_CDC_Device_ControLineStateChanged + 1015 00c0 00C0 rjmp .L75 + 1016 .L77: + 1017 .LSM128: + 1018 00c2 8091 0000 lds r24,USB_ControlRequest + 1019 00c6 8132 cpi r24,lo8(33) + 1020 00c8 01F4 brne .L75 + 1021 .LBB136: + 1022 .LBB137: + 1023 .LSM129: + 1024 00ca 8091 E800 lds r24,232 + 1025 00ce 877F andi r24,lo8(-9) + 1026 00d0 8093 E800 sts 232,r24 + 1027 .LBE137: + 1028 .LBE136: + 1029 .LSM130: + 1030 00d4 0E94 0000 call Endpoint_ClearStatusStage + 1031 .LSM131: + 1032 00d8 CE01 movw r24,r28 + 1033 00da 6091 0000 lds r22,USB_ControlRequest+2 + 1034 00de 0E94 0000 call EVENT_CDC_Device_BreakSent + 1035 .L75: + 1036 /* epilogue start */ + 1037 .LSM132: + 1038 00e2 DF91 pop r29 + 1039 00e4 CF91 pop r28 + 1040 .LVL87: + 1041 00e6 0895 ret + 1042 .LFE82: + 1044 .data + 1047 C.17.3562: + 1048 0000 A1 .byte -95 + 1049 0001 20 .byte 32 + 1050 0002 0000 .word 0 + 1051 0004 0000 .word 0 + 1052 0006 0100 .word 1 + 1053 .weak EVENT_CDC_Device_LineEncodingChanged + 1054 .set EVENT_CDC_Device_LineEncodingChanged,CDC_Device_Event_Stub + 1055 .weak EVENT_CDC_Device_ControLineStateChanged + 1056 .set EVENT_CDC_Device_ControLineStateChanged,CDC_Device_Event_Stub + 1057 .weak EVENT_CDC_Device_BreakSent + 1058 .set EVENT_CDC_Device_BreakSent,CDC_Device_Event_Stub + 1195 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 CDC.c + /tmp/cc6wpRq4.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cc6wpRq4.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cc6wpRq4.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cc6wpRq4.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cc6wpRq4.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cc6wpRq4.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/cc6wpRq4.s:19 .text.CDC_Device_Event_Stub:0000000000000000 CDC_Device_Event_Stub + /tmp/cc6wpRq4.s:32 .text.CDC_Device_BytesReceived:0000000000000000 CDC_Device_BytesReceived + /tmp/cc6wpRq4.s:111 .text.CDC_Device_ReceiveByte:0000000000000000 CDC_Device_ReceiveByte + /tmp/cc6wpRq4.s:210 .text.CDC_Device_CreateStream:0000000000000000 CDC_Device_CreateStream + /tmp/cc6wpRq4.s:708 .text.CDC_Device_putchar:0000000000000000 CDC_Device_putchar + /tmp/cc6wpRq4.s:277 .text.CDC_Device_getchar:0000000000000000 CDC_Device_getchar + /tmp/cc6wpRq4.s:244 .text.CDC_Device_CreateBlockingStream:0000000000000000 CDC_Device_CreateBlockingStream + /tmp/cc6wpRq4.s:574 .text.CDC_Device_getchar_Blocking:0000000000000000 CDC_Device_getchar_Blocking + /tmp/cc6wpRq4.s:309 .text.CDC_Device_SendControlLineStateChange:0000000000000000 CDC_Device_SendControlLineStateChange + /tmp/cc6wpRq4.s:1047 .data:0000000000000000 C.17.3562 + /tmp/cc6wpRq4.s:405 .text.CDC_Device_SendString:0000000000000000 CDC_Device_SendString + /tmp/cc6wpRq4.s:453 .text.CDC_Device_Flush:0000000000000000 CDC_Device_Flush + /tmp/cc6wpRq4.s:544 .text.CDC_Device_USBTask:0000000000000000 CDC_Device_USBTask + /tmp/cc6wpRq4.s:626 .text.CDC_Device_SendByte:0000000000000000 CDC_Device_SendByte + /tmp/cc6wpRq4.s:742 .text.CDC_Device_ConfigureEndpoints:0000000000000000 CDC_Device_ConfigureEndpoints + /tmp/cc6wpRq4.s:889 .text.CDC_Device_ProcessControlRequest:0000000000000000 CDC_Device_ProcessControlRequest + /tmp/cc6wpRq4.s:19 .text.CDC_Device_Event_Stub:0000000000000000 EVENT_CDC_Device_LineEncodingChanged + /tmp/cc6wpRq4.s:19 .text.CDC_Device_Event_Stub:0000000000000000 EVENT_CDC_Device_ControLineStateChanged + /tmp/cc6wpRq4.s:19 .text.CDC_Device_Event_Stub:0000000000000000 EVENT_CDC_Device_BreakSent + +UNDEFINED SYMBOLS +USB_DeviceState +Endpoint_Write_Stream_LE +Endpoint_WaitUntilReady +USB_USBTask +Endpoint_ConfigureEndpoint_Prv +USB_ControlRequest +Endpoint_Write_Control_Stream_LE +Endpoint_Read_Control_Stream_LE +Endpoint_ClearStatusStage +__do_copy_data diff --git a/firmware/LUFA/Drivers/USB/Class/Device/CDC.o b/firmware/LUFA/Drivers/USB/Class/Device/CDC.o new file mode 100644 index 0000000..4e47b49 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Device/CDC.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Device/HID.c b/firmware/LUFA/Drivers/USB/Class/Device/HID.c new file mode 100644 index 0000000..f538610 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/HID.c @@ -0,0 +1,190 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_HID_DRIVER +#define __INCLUDE_FROM_HID_DEVICE_C +#include "HID.h" + +void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if (USB_ControlRequest.wIndex != HIDInterfaceInfo->Config.InterfaceNumber) + return; + + switch (USB_ControlRequest.bRequest) + { + case HID_REQ_GetReport: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + uint16_t ReportSize = 0; + uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); + uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; + uint8_t ReportData[HIDInterfaceInfo->Config.PrevReportINBufferSize]; + + memset(ReportData, 0, sizeof(ReportData)); + + CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, ReportData, &ReportSize); + + if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) + memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData, HIDInterfaceInfo->Config.PrevReportINBufferSize); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); + Endpoint_ClearOUT(); + } + + break; + case HID_REQ_SetReport: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + uint16_t ReportSize = USB_ControlRequest.wLength; + uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF); + uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1; + uint8_t ReportData[ReportSize]; + + Endpoint_ClearSETUP(); + Endpoint_Read_Control_Stream_LE(ReportData, ReportSize); + Endpoint_ClearIN(); + + CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType, ReportData, ReportSize); + } + + break; + case HID_REQ_GetProtocol: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_Write_Byte(HIDInterfaceInfo->State.UsingReportProtocol); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + + break; + case HID_REQ_SetProtocol: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); + } + + break; + case HID_REQ_SetIdle: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); + } + + break; + case HID_REQ_GetIdle: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_Write_Byte(HIDInterfaceInfo->State.IdleCount >> 2); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + + break; + } +} + +bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) +{ + memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State)); + HIDInterfaceInfo->State.UsingReportProtocol = true; + HIDInterfaceInfo->State.IdleCount = 500; + + if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber, EP_TYPE_INTERRUPT, + ENDPOINT_DIR_IN, HIDInterfaceInfo->Config.ReportINEndpointSize, + HIDInterfaceInfo->Config.ReportINEndpointDoubleBank ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) + { + return false; + } + + return true; +} + +void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber); + + if (Endpoint_IsReadWriteAllowed()) + { + uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize]; + uint8_t ReportID = 0; + uint16_t ReportINSize = 0; + + memset(ReportINData, 0, sizeof(ReportINData)); + + bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, HID_REPORT_ITEM_In, + ReportINData, &ReportINSize); + bool StatesChanged = false; + bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining)); + + if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL) + { + StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0); + memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize); + } + + if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed)) + { + HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount; + + Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber); + + if (ReportID) + Endpoint_Write_Byte(ReportID); + + Endpoint_Write_Stream_LE(ReportINData, ReportINSize, NO_STREAM_CALLBACK); + + Endpoint_ClearIN(); + } + } +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/HID.h b/firmware/LUFA/Drivers/USB/Class/Device/HID.h new file mode 100644 index 0000000..49358f5 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/HID.h @@ -0,0 +1,222 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 HID Class driver. + * + * Device mode driver for the library USB HID 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_USBClassHID + * @defgroup Group_USBClassHIDDevice HID 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/HID.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Device Mode USB Class driver framework interface, for the HID USB Class driver. + * + * @{ + */ + +#ifndef _HID_CLASS_DEVICE_H_ +#define _HID_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/HID.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_HID_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_HID_DEVICE_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief HID Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each HID interface + * within the user application, and passed to each of the HID class driver functions as the + * HIDInterfaceInfo parameter. This stores each HID interface's configuration and state information. + * + * \note Due to technical limitations, the HID device class driver does not utilize a separate OUT + * endpoint for host->device communications. Instead, the host->device data (if any) is sent to + * the device via the control endpoint. + */ + typedef struct + { + const struct + { + uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device. */ + + uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint. */ + uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint. */ + bool ReportINEndpointDoubleBank; /**< Indicates if the HID interface's IN report endpoint should use double banking. */ + + void* PrevReportINBuffer; /**< Pointer to a buffer where the previously created HID input report can be + * stored by the driver, for comparison purposes to detect report changes that + * must be sent immediately to the host. This should point to a buffer big enough + * to hold the largest HID input report sent from the HID interface. If this is set + * to NULL, it is up to the user to force transfers when needed in the + * \ref CALLBACK_HID_Device_CreateHIDReport() callback function. + * + * \note Due to the single buffer, the internal driver can only correctly compare + * subsequent reports with identical report IDs. In multiple report devices, + * this buffer should be set to NULL and the decision to send reports made + * by the user application instead. + */ + uint8_t PrevReportINBufferSize; /**< Size in bytes of the given input report buffer. This is used to create a + * second buffer of the same size within the driver so that subsequent reports + * can be compared. If the user app is to determine when reports are to be sent + * exclusively (i.e. \ref PrevReportINBuffer is NULL) this value must still be + * set to the size of the largest report the device can issue to the host. + */ + } 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 + { + bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode. */ + uint16_t IdleCount; /**< Report idle period, in milliseconds, set by the host. */ + uint16_t IdleMSRemaining; /**< Total number of milliseconds remaining before the idle period elapsed - this + * should be decremented by the user application if non-zero each millisecond. */ + } 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_HID_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given HID 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 HID interface is selected. + * + * \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * + * \return Boolean true if the endpoints were successfully configured, false otherwise. + */ + bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Processes incoming control requests from the host, that are directed to the given HID class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + */ + void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** General management task for a given HID 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] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + */ + void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** HID class driver callback for the user creation of a HID IN report. This callback may fire in response to either + * HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the + * user is responsible for the creation of the next HID input report to be sent to the host. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * \param[in,out] ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero, + * this should be set to the report ID of the generated HID input report (if any). If multiple + * reports are not sent via the given HID interface, this parameter should be ignored. + * \param[in] ReportType Type of HID report to generate, either \ref HID_REPORT_ITEM_In or \ref HID_REPORT_ITEM_Feature. + * \param[out] ReportData Pointer to a buffer where the generated HID report should be stored. + * \param[out] ReportSize Number of bytes in the generated input report, or zero if no report is to be sent. + * + * \return Boolean true to force the sending of the report even if it is identical to the previous report and still within + * the idle period (useful for devices which report relative movement), false otherwise. + */ + bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, + uint8_t* const ReportID, + const uint8_t ReportType, + void* ReportData, + uint16_t* const ReportSize) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(4) ATTR_NON_NULL_PTR_ARG(5); + + /** HID class driver callback for the user processing of a received HID OUT report. This callback may fire in response to + * either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback + * the user is responsible for the processing of the received HID output report from the host. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * \param[in] ReportID Report ID of the received output report. If multiple reports are not received via the given HID + * interface, this parameter should be ignored. + * \param[in] ReportType Type of received HID report, either \ref HID_REPORT_ITEM_Out or \ref HID_REPORT_ITEM_Feature. + * \param[in] ReportData Pointer to a buffer where the received HID report is stored. + * \param[in] ReportSize Size in bytes of the received report from the host. + */ + void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, + const uint8_t ReportID, + const uint8_t ReportType, + const void* ReportData, + const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(4); + + /* Inline Functions: */ + /** Indicates that a millisecond of idle time has elapsed on the given HID interface, and the interface's idle count should be + * decremented. This should be called once per millisecond so that hardware key-repeats function correctly. It is recommended + * that this be called by the \ref EVENT_USB_Device_StartOfFrame() event, once SOF events have been enabled via + * \ref USB_Device_EnableSOFEvents(). + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + */ + static inline void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_ALWAYS_INLINE ATTR_NON_NULL_PTR_ARG(1); + static inline void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) + { + if (HIDInterfaceInfo->State.IdleMSRemaining) + HIDInterfaceInfo->State.IdleMSRemaining--; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/HID.lst b/firmware/LUFA/Drivers/USB/Class/Device/HID.lst new file mode 100644 index 0000000..46fb481 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/HID.lst @@ -0,0 +1,769 @@ + 1 .file "HID.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.HID_Device_USBTask,"ax",@progbits + 17 .global HID_Device_USBTask + 19 HID_Device_USBTask: + 20 .LFB83: + 21 .LSM0: + 22 .LVL0: + 23 0000 4F92 push r4 + 24 0002 5F92 push r5 + 25 0004 6F92 push r6 + 26 0006 7F92 push r7 + 27 0008 8F92 push r8 + 28 000a 9F92 push r9 + 29 000c AF92 push r10 + 30 000e BF92 push r11 + 31 0010 CF92 push r12 + 32 0012 DF92 push r13 + 33 0014 EF92 push r14 + 34 0016 FF92 push r15 + 35 0018 0F93 push r16 + 36 001a 1F93 push r17 + 37 001c DF93 push r29 + 38 001e CF93 push r28 + 39 0020 00D0 rcall . + 40 0022 0F92 push __tmp_reg__ + 41 0024 CDB7 in r28,__SP_L__ + 42 0026 DEB7 in r29,__SP_H__ + 43 /* prologue: function */ + 44 /* frame size = 3 */ + 45 0028 7C01 movw r14,r24 + 46 .LSM1: + 47 002a 6DB6 in r6,__SP_L__ + 48 002c 7EB6 in r7,__SP_H__ + 49 .LSM2: + 50 002e 8091 0000 lds r24,USB_DeviceState + 51 .LVL1: + 52 0032 8430 cpi r24,lo8(4) + 53 0034 01F0 breq .+2 + 54 0036 00C0 rjmp .L13 + 55 .LSM3: + 56 0038 F701 movw r30,r14 + 57 003a 8181 ldd r24,Z+1 + 58 .LBB49: + 59 .LBB50: + 60 .LSM4: + 61 003c 8093 E900 sts 233,r24 + 62 .LBE50: + 63 .LBE49: + 64 .LBB51: + 65 .LBB52: + 66 .LSM5: + 67 0040 8091 E800 lds r24,232 + 68 .LBE52: + 69 .LBE51: + 70 .LSM6: + 71 0044 85FF sbrs r24,5 + 72 0046 00C0 rjmp .L13 + 73 0048 5DB6 in r5,__SP_L__ + 74 004a 4EB6 in r4,__SP_H__ + 75 .LBB53: + 76 .LSM7: + 77 004c 4781 ldd r20,Z+7 + 78 004e 8DB7 in r24,__SP_L__ + 79 0050 9EB7 in r25,__SP_H__ + 80 0052 841B sub r24,r20 + 81 0054 9109 sbc r25,__zero_reg__ + 82 0056 0FB6 in __tmp_reg__,__SREG__ + 83 0058 F894 cli + 84 005a 9EBF out __SP_H__,r25 + 85 005c 0FBE out __SREG__,__tmp_reg__ + 86 005e 8DBF out __SP_L__,r24 + 87 0060 0DB7 in r16,__SP_L__ + 88 0062 1EB7 in r17,__SP_H__ + 89 0064 0F5F subi r16,lo8(-(1)) + 90 0066 1F4F sbci r17,hi8(-(1)) + 91 .LSM8: + 92 0068 1982 std Y+1,__zero_reg__ + 93 .LVL2: + 94 .LSM9: + 95 006a 1B82 std Y+3,__zero_reg__ + 96 006c 1A82 std Y+2,__zero_reg__ + 97 .LVL3: + 98 .LSM10: + 99 006e C02E mov r12,r16 + 100 0070 912E mov r9,r17 + 101 0072 C801 movw r24,r16 + 102 0074 60E0 ldi r22,lo8(0) + 103 0076 70E0 ldi r23,hi8(0) + 104 0078 50E0 ldi r21,lo8(0) + 105 007a 0E94 0000 call memset + 106 .LSM11: + 107 007e C701 movw r24,r14 + 108 0080 BE01 movw r22,r28 + 109 0082 6F5F subi r22,lo8(-(1)) + 110 0084 7F4F sbci r23,hi8(-(1)) + 111 0086 40E0 ldi r20,lo8(0) + 112 0088 9801 movw r18,r16 + 113 008a 8E01 movw r16,r28 + 114 008c 0E5F subi r16,lo8(-(2)) + 115 008e 1F4F sbci r17,hi8(-(2)) + 116 0090 0E94 0000 call CALLBACK_HID_Device_CreateHIDReport + 117 0094 882E mov r8,r24 + 118 .LVL4: + 119 .LSM12: + 120 0096 F701 movw r30,r14 + 121 0098 8185 ldd r24,Z+9 + 122 009a 9285 ldd r25,Z+10 + 123 009c 892B or r24,r25 + 124 009e 01F4 brne .L3 + 125 00a0 AA24 clr r10 + 126 00a2 BB24 clr r11 + 127 00a4 00C0 rjmp .L4 + 128 .L3: + 129 00a6 20E0 ldi r18,lo8(0) + 130 00a8 F701 movw r30,r14 + 131 00aa 8385 ldd r24,Z+11 + 132 00ac 9485 ldd r25,Z+12 + 133 00ae 892B or r24,r25 + 134 00b0 01F0 breq .L5 + 135 00b2 21E0 ldi r18,lo8(1) + 136 .L5: + 137 00b4 81E0 ldi r24,lo8(1) + 138 00b6 2827 eor r18,r24 + 139 00b8 A22E mov r10,r18 + 140 00ba BB24 clr r11 + 141 .L4: + 142 .LSM13: + 143 00bc F701 movw r30,r14 + 144 00be 0581 ldd r16,Z+5 + 145 00c0 1681 ldd r17,Z+6 + 146 00c2 0115 cp r16,__zero_reg__ + 147 00c4 1105 cpc r17,__zero_reg__ + 148 00c6 01F4 brne .L6 + 149 00c8 DD24 clr r13 + 150 .LVL5: + 151 00ca 00C0 rjmp .L7 + 152 .LVL6: + 153 .L6: + 154 .LSM14: + 155 00cc 4A81 ldd r20,Y+2 + 156 00ce 5B81 ldd r21,Y+3 + 157 00d0 8C2D mov r24,r12 + 158 00d2 992D mov r25,r9 + 159 00d4 B801 movw r22,r16 + 160 00d6 0E94 0000 call memcmp + 161 00da DD24 clr r13 + 162 .LVL7: + 163 00dc 0097 sbiw r24,0 + 164 00de 01F0 breq .L8 + 165 00e0 DD24 clr r13 + 166 00e2 D394 inc r13 + 167 .L8: + 168 .LSM15: + 169 00e4 F701 movw r30,r14 + 170 00e6 4781 ldd r20,Z+7 + 171 00e8 C801 movw r24,r16 + 172 00ea 6C2D mov r22,r12 + 173 00ec 792D mov r23,r9 + 174 00ee 50E0 ldi r21,lo8(0) + 175 00f0 0E94 0000 call memcpy + 176 .L7: + 177 .LSM16: + 178 00f4 8A81 ldd r24,Y+2 + 179 00f6 9B81 ldd r25,Y+3 + 180 00f8 892B or r24,r25 + 181 00fa 01F0 breq .L10 + 182 .LVL8: + 183 00fc 8820 tst r8 + 184 00fe 01F4 brne .L11 + 185 0100 DD20 tst r13 + 186 0102 01F4 brne .L11 + 187 0104 AB28 or r10,r11 + 188 0106 01F0 breq .L10 + 189 .L11: + 190 .LSM17: + 191 0108 F701 movw r30,r14 + 192 010a 8185 ldd r24,Z+9 + 193 010c 9285 ldd r25,Z+10 + 194 .LVL9: + 195 010e 9487 std Z+12,r25 + 196 0110 8387 std Z+11,r24 + 197 .LSM18: + 198 0112 8181 ldd r24,Z+1 + 199 .LBB54: + 200 .LBB55: + 201 .LSM19: + 202 0114 8093 E900 sts 233,r24 + 203 .LBE55: + 204 .LBE54: + 205 .LSM20: + 206 0118 8981 ldd r24,Y+1 + 207 011a 8823 tst r24 + 208 011c 01F0 breq .L12 + 209 .LBB56: + 210 .LBB57: + 211 .LSM21: + 212 011e 8093 F100 sts 241,r24 + 213 .L12: + 214 .LBE57: + 215 .LBE56: + 216 .LSM22: + 217 0122 6A81 ldd r22,Y+2 + 218 0124 7B81 ldd r23,Y+3 + 219 0126 8C2D mov r24,r12 + 220 0128 992D mov r25,r9 + 221 012a 40E0 ldi r20,lo8(0) + 222 012c 50E0 ldi r21,hi8(0) + 223 012e 0E94 0000 call Endpoint_Write_Stream_LE + 224 .LBB58: + 225 .LBB59: + 226 .LSM23: + 227 0132 8091 E800 lds r24,232 + 228 0136 8E77 andi r24,lo8(126) + 229 0138 8093 E800 sts 232,r24 + 230 .LVL10: + 231 .L10: + 232 013c 852D mov r24,r5 + 233 013e 942D mov r25,r4 + 234 0140 9C01 movw r18,r24 + 235 0142 0FB6 in __tmp_reg__,__SREG__ + 236 0144 F894 cli + 237 0146 3EBF out __SP_H__,r19 + 238 0148 0FBE out __SREG__,__tmp_reg__ + 239 014a 2DBF out __SP_L__,r18 + 240 .L13: + 241 .LBE59: + 242 .LBE58: + 243 .LBE53: + 244 .LSM24: + 245 014c 0FB6 in __tmp_reg__,__SREG__ + 246 014e F894 cli + 247 0150 7EBE out __SP_H__,r7 + 248 0152 0FBE out __SREG__,__tmp_reg__ + 249 0154 6DBE out __SP_L__,r6 + 250 /* epilogue start */ + 251 0156 0F90 pop __tmp_reg__ + 252 0158 0F90 pop __tmp_reg__ + 253 015a 0F90 pop __tmp_reg__ + 254 015c CF91 pop r28 + 255 015e DF91 pop r29 + 256 0160 1F91 pop r17 + 257 0162 0F91 pop r16 + 258 0164 FF90 pop r15 + 259 0166 EF90 pop r14 + 260 .LVL11: + 261 0168 DF90 pop r13 + 262 .LVL12: + 263 016a CF90 pop r12 + 264 016c BF90 pop r11 + 265 016e AF90 pop r10 + 266 0170 9F90 pop r9 + 267 0172 8F90 pop r8 + 268 .LVL13: + 269 0174 7F90 pop r7 + 270 0176 6F90 pop r6 + 271 0178 5F90 pop r5 + 272 017a 4F90 pop r4 + 273 017c 0895 ret + 274 .LFE83: + 276 .section .text.HID_Device_ConfigureEndpoints,"ax",@progbits + 277 .global HID_Device_ConfigureEndpoints + 279 HID_Device_ConfigureEndpoints: + 280 .LFB82: + 281 .LSM25: + 282 .LVL14: + 283 0000 CF93 push r28 + 284 0002 DF93 push r29 + 285 /* prologue: function */ + 286 /* frame size = 0 */ + 287 0004 DC01 movw r26,r24 + 288 .LSM26: + 289 0006 0896 adiw r24,8 + 290 .LVL15: + 291 0008 FC01 movw r30,r24 + 292 000a 85E0 ldi r24,lo8(5) + 293 000c EF01 movw r28,r30 + 294 000e 1992 st Y+,__zero_reg__ + 295 0010 8A95 dec r24 + 296 0012 01F4 brne .-6 + 297 .LSM27: + 298 0014 81E0 ldi r24,lo8(1) + 299 0016 1896 adiw r26,8 + 300 0018 8C93 st X,r24 + 301 001a 1897 sbiw r26,8 + 302 .LSM28: + 303 001c 84EF ldi r24,lo8(500) + 304 001e 91E0 ldi r25,hi8(500) + 305 0020 1A96 adiw r26,9+1 + 306 0022 9C93 st X,r25 + 307 0024 8E93 st -X,r24 + 308 0026 1997 sbiw r26,9 + 309 .LSM29: + 310 0028 1196 adiw r26,1 + 311 002a 3C91 ld r19,X + 312 002c 1197 sbiw r26,1 + 313 002e 1296 adiw r26,2 + 314 0030 6D91 ld r22,X+ + 315 0032 7C91 ld r23,X + 316 0034 1397 sbiw r26,2+1 + 317 0036 1496 adiw r26,4 + 318 0038 8C91 ld r24,X + 319 003a 8823 tst r24 + 320 003c 01F4 brne .L15 + 321 003e 40E0 ldi r20,lo8(0) + 322 0040 00C0 rjmp .L16 + 323 .L15: + 324 0042 44E0 ldi r20,lo8(4) + 325 .L16: + 326 0044 20E0 ldi r18,lo8(0) + 327 .LVL16: + 328 0046 88E0 ldi r24,lo8(8) + 329 0048 90E0 ldi r25,hi8(8) + 330 .LVL17: + 331 004a 00C0 rjmp .L17 + 332 .L18: + 333 .LBB60: + 334 .LBB61: + 335 .LBB62: + 336 .LBB63: + 337 .LSM30: + 338 004c 2F5F subi r18,lo8(-(1)) + 339 .LSM31: + 340 004e 880F lsl r24 + 341 0050 991F rol r25 + 342 .L17: + 343 .LSM32: + 344 0052 8617 cp r24,r22 + 345 0054 9707 cpc r25,r23 + 346 0056 00F0 brlo .L18 + 347 .LBE63: + 348 .LBE62: + 349 .LBE61: + 350 .LSM33: + 351 0058 4260 ori r20,lo8(2) + 352 005a 2295 swap r18 + 353 005c 207F andi r18,lo8(-16) + 354 005e 422B or r20,r18 + 355 0060 832F mov r24,r19 + 356 .LVL18: + 357 0062 61EC ldi r22,lo8(-63) + 358 0064 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 359 .LVL19: + 360 0068 8111 cpse r24,__zero_reg__ + 361 006a 81E0 ldi r24,lo8(1) + 362 .L19: + 363 /* epilogue start */ + 364 .LBE60: + 365 .LSM34: + 366 006c DF91 pop r29 + 367 006e CF91 pop r28 + 368 0070 0895 ret + 369 .LFE82: + 371 .section .text.HID_Device_ProcessControlRequest,"ax",@progbits + 372 .global HID_Device_ProcessControlRequest + 374 HID_Device_ProcessControlRequest: + 375 .LFB81: + 376 .LSM35: + 377 .LVL20: + 378 0000 6F92 push r6 + 379 0002 7F92 push r7 + 380 0004 8F92 push r8 + 381 0006 9F92 push r9 + 382 0008 AF92 push r10 + 383 000a BF92 push r11 + 384 000c CF92 push r12 + 385 000e DF92 push r13 + 386 0010 EF92 push r14 + 387 0012 FF92 push r15 + 388 0014 0F93 push r16 + 389 0016 1F93 push r17 + 390 0018 DF93 push r29 + 391 001a CF93 push r28 + 392 001c 00D0 rcall . + 393 001e 0F92 push __tmp_reg__ + 394 0020 CDB7 in r28,__SP_L__ + 395 0022 DEB7 in r29,__SP_H__ + 396 /* prologue: function */ + 397 /* frame size = 3 */ + 398 0024 4C01 movw r8,r24 + 399 .LSM36: + 400 0026 6DB6 in r6,__SP_L__ + 401 0028 7EB6 in r7,__SP_H__ + 402 .LBB64: + 403 .LBB65: + 404 .LSM37: + 405 002a 8091 E800 lds r24,232 + 406 .LVL21: + 407 .LBE65: + 408 .LBE64: + 409 .LSM38: + 410 002e 83FF sbrs r24,3 + 411 0030 00C0 rjmp .L33 + 412 .LSM39: + 413 0032 F401 movw r30,r8 + 414 0034 8081 ld r24,Z + 415 0036 90E0 ldi r25,lo8(0) + 416 0038 2091 0000 lds r18,USB_ControlRequest+4 + 417 003c 3091 0000 lds r19,(USB_ControlRequest+4)+1 + 418 0040 2817 cp r18,r24 + 419 0042 3907 cpc r19,r25 + 420 0044 01F0 breq .+2 + 421 0046 00C0 rjmp .L33 + 422 .LSM40: + 423 0048 8091 0000 lds r24,USB_ControlRequest+1 + 424 004c 8330 cpi r24,lo8(3) + 425 004e 01F4 brne .+2 + 426 0050 00C0 rjmp .L25 + 427 0052 8430 cpi r24,lo8(4) + 428 0054 00F4 brsh .L29 + 429 0056 8130 cpi r24,lo8(1) + 430 0058 01F0 breq .L23 + 431 005a 8230 cpi r24,lo8(2) + 432 005c 01F0 breq .+2 + 433 005e 00C0 rjmp .L33 + 434 0060 00C0 rjmp .L36 + 435 .L29: + 436 0062 8A30 cpi r24,lo8(10) + 437 0064 01F4 brne .+2 + 438 0066 00C0 rjmp .L27 + 439 0068 8B30 cpi r24,lo8(11) + 440 006a 01F4 brne .+2 + 441 006c 00C0 rjmp .L28 + 442 006e 8930 cpi r24,lo8(9) + 443 0070 01F0 breq .+2 + 444 0072 00C0 rjmp .L33 + 445 0074 00C0 rjmp .L37 + 446 .L23: + 447 .LSM41: + 448 0076 8091 0000 lds r24,USB_ControlRequest + 449 007a 813A cpi r24,lo8(-95) + 450 007c 01F0 breq .+2 + 451 007e 00C0 rjmp .L33 + 452 0080 ADB6 in r10,__SP_L__ + 453 0082 FEB6 in r15,__SP_H__ + 454 .LBB66: + 455 .LSM42: + 456 0084 1B82 std Y+3,__zero_reg__ + 457 0086 1A82 std Y+2,__zero_reg__ + 458 .LVL22: + 459 .LSM43: + 460 0088 8091 0000 lds r24,USB_ControlRequest+2 + 461 008c 1091 0000 lds r17,USB_ControlRequest+3 + 462 0090 8983 std Y+1,r24 + 463 .LVL23: + 464 .LSM44: + 465 0092 F401 movw r30,r8 + 466 0094 4781 ldd r20,Z+7 + 467 0096 8DB7 in r24,__SP_L__ + 468 0098 9EB7 in r25,__SP_H__ + 469 009a 841B sub r24,r20 + 470 009c 9109 sbc r25,__zero_reg__ + 471 009e 0FB6 in __tmp_reg__,__SREG__ + 472 00a0 F894 cli + 473 00a2 9EBF out __SP_H__,r25 + 474 00a4 0FBE out __SREG__,__tmp_reg__ + 475 00a6 8DBF out __SP_L__,r24 + 476 00a8 CDB6 in r12,__SP_L__ + 477 00aa DEB6 in r13,__SP_H__ + 478 00ac 0894 sec + 479 00ae C11C adc r12,__zero_reg__ + 480 00b0 D11C adc r13,__zero_reg__ + 481 .LSM45: + 482 00b2 EC2C mov r14,r12 + 483 00b4 BD2C mov r11,r13 + 484 00b6 C601 movw r24,r12 + 485 00b8 60E0 ldi r22,lo8(0) + 486 00ba 70E0 ldi r23,hi8(0) + 487 00bc 50E0 ldi r21,lo8(0) + 488 00be 0E94 0000 call memset + 489 .LSM46: + 490 00c2 1150 subi r17,lo8(-(-1)) + 491 00c4 C401 movw r24,r8 + 492 00c6 BE01 movw r22,r28 + 493 00c8 6F5F subi r22,lo8(-(1)) + 494 00ca 7F4F sbci r23,hi8(-(1)) + 495 00cc 412F mov r20,r17 + 496 00ce 9601 movw r18,r12 + 497 00d0 8E01 movw r16,r28 + 498 00d2 0E5F subi r16,lo8(-(2)) + 499 00d4 1F4F sbci r17,hi8(-(2)) + 500 00d6 0E94 0000 call CALLBACK_HID_Device_CreateHIDReport + 501 .LSM47: + 502 00da F401 movw r30,r8 + 503 00dc 2581 ldd r18,Z+5 + 504 00de 3681 ldd r19,Z+6 + 505 00e0 2115 cp r18,__zero_reg__ + 506 00e2 3105 cpc r19,__zero_reg__ + 507 00e4 01F0 breq .L30 + 508 .LSM48: + 509 00e6 4781 ldd r20,Z+7 + 510 00e8 C901 movw r24,r18 + 511 00ea B601 movw r22,r12 + 512 00ec 50E0 ldi r21,lo8(0) + 513 00ee 0E94 0000 call memcpy + 514 .L30: + 515 .LBB67: + 516 .LBB68: + 517 .LSM49: + 518 00f2 1092 E900 sts 233,__zero_reg__ + 519 .LBE68: + 520 .LBE67: + 521 .LBB69: + 522 .LBB70: + 523 .LSM50: + 524 00f6 8091 E800 lds r24,232 + 525 00fa 877F andi r24,lo8(-9) + 526 00fc 8093 E800 sts 232,r24 + 527 .LBE70: + 528 .LBE69: + 529 .LSM51: + 530 0100 6A81 ldd r22,Y+2 + 531 0102 7B81 ldd r23,Y+3 + 532 0104 8E2D mov r24,r14 + 533 0106 9B2D mov r25,r11 + 534 0108 0E94 0000 call Endpoint_Write_Control_Stream_LE + 535 .LBB71: + 536 .LBB72: + 537 .LSM52: + 538 010c 8091 E800 lds r24,232 + 539 0110 8B77 andi r24,lo8(123) + 540 0112 8093 E800 sts 232,r24 + 541 0116 2A2D mov r18,r10 + 542 0118 3F2D mov r19,r15 + 543 011a 00C0 rjmp .L34 + 544 .LVL24: + 545 .L37: + 546 .LBE72: + 547 .LBE71: + 548 .LBE66: + 549 .LSM53: + 550 011c 8091 0000 lds r24,USB_ControlRequest + 551 0120 8132 cpi r24,lo8(33) + 552 0122 01F0 breq .+2 + 553 0124 00C0 rjmp .L33 + 554 0126 AEB6 in r10,__SP_H__ + 555 .LBB73: + 556 .LSM54: + 557 0128 0091 0000 lds r16,USB_ControlRequest+6 + 558 012c 1091 0000 lds r17,(USB_ControlRequest+6)+1 + 559 .LVL25: + 560 .LSM55: + 561 0130 C090 0000 lds r12,USB_ControlRequest+2 + 562 0134 D090 0000 lds r13,USB_ControlRequest+3 + 563 .LSM56: + 564 0138 8DB7 in r24,__SP_L__ + 565 013a 9EB7 in r25,__SP_H__ + 566 013c 801B sub r24,r16 + 567 013e 910B sbc r25,r17 + 568 0140 0FB6 in __tmp_reg__,__SREG__ + 569 0142 F894 cli + 570 0144 9EBF out __SP_H__,r25 + 571 0146 0FBE out __SREG__,__tmp_reg__ + 572 0148 8DBF out __SP_L__,r24 + 573 014a EDB6 in r14,__SP_L__ + 574 014c FEB6 in r15,__SP_H__ + 575 014e 0894 sec + 576 0150 E11C adc r14,__zero_reg__ + 577 0152 F11C adc r15,__zero_reg__ + 578 .LBB74: + 579 .LBB75: + 580 .LSM57: + 581 0154 8091 E800 lds r24,232 + 582 0158 877F andi r24,lo8(-9) + 583 015a 8093 E800 sts 232,r24 + 584 .LBE75: + 585 .LBE74: + 586 .LSM58: + 587 015e C701 movw r24,r14 + 588 0160 B801 movw r22,r16 + 589 0162 0E94 0000 call Endpoint_Read_Control_Stream_LE + 590 .LBB76: + 591 .LBB77: + 592 .LSM59: + 593 0166 8091 E800 lds r24,232 + 594 016a 8E77 andi r24,lo8(126) + 595 016c 8093 E800 sts 232,r24 + 596 .LBE77: + 597 .LBE76: + 598 .LSM60: + 599 0170 DA94 dec r13 + 600 0172 C401 movw r24,r8 + 601 0174 6C2D mov r22,r12 + 602 0176 4D2D mov r20,r13 + 603 0178 9701 movw r18,r14 + 604 017a 0E94 0000 call CALLBACK_HID_Device_ProcessHIDReport + 605 017e 262D mov r18,r6 + 606 0180 3A2D mov r19,r10 + 607 .LVL26: + 608 .L34: + 609 0182 0FB6 in __tmp_reg__,__SREG__ + 610 0184 F894 cli + 611 0186 3EBF out __SP_H__,r19 + 612 0188 0FBE out __SREG__,__tmp_reg__ + 613 018a 2DBF out __SP_L__,r18 + 614 018c 00C0 rjmp .L33 + 615 .LVL27: + 616 .L25: + 617 .LBE73: + 618 .LSM61: + 619 018e 8091 0000 lds r24,USB_ControlRequest + 620 0192 813A cpi r24,lo8(-95) + 621 0194 01F0 breq .+2 + 622 0196 00C0 rjmp .L33 + 623 .LBB78: + 624 .LBB79: + 625 .LSM62: + 626 0198 8091 E800 lds r24,232 + 627 019c 877F andi r24,lo8(-9) + 628 019e 8093 E800 sts 232,r24 + 629 .LBE79: + 630 .LBE78: + 631 .LSM63: + 632 01a2 F401 movw r30,r8 + 633 01a4 8085 ldd r24,Z+8 + 634 01a6 00C0 rjmp .L35 + 635 .L28: + 636 .LSM64: + 637 01a8 8091 0000 lds r24,USB_ControlRequest + 638 01ac 8132 cpi r24,lo8(33) + 639 01ae 01F0 breq .+2 + 640 01b0 00C0 rjmp .L33 + 641 .LBB80: + 642 .LBB81: + 643 .LSM65: + 644 01b2 8091 E800 lds r24,232 + 645 01b6 877F andi r24,lo8(-9) + 646 01b8 8093 E800 sts 232,r24 + 647 .LBE81: + 648 .LBE80: + 649 .LSM66: + 650 01bc 0E94 0000 call Endpoint_ClearStatusStage + 651 .LSM67: + 652 01c0 90E0 ldi r25,lo8(0) + 653 01c2 8091 0000 lds r24,USB_ControlRequest+2 + 654 01c6 8111 cpse r24,__zero_reg__ + 655 01c8 91E0 ldi r25,lo8(1) + 656 .L32: + 657 01ca F401 movw r30,r8 + 658 01cc 9087 std Z+8,r25 + 659 01ce 00C0 rjmp .L33 + 660 .L27: + 661 .LSM68: + 662 01d0 8091 0000 lds r24,USB_ControlRequest + 663 01d4 8132 cpi r24,lo8(33) + 664 01d6 01F4 brne .L33 + 665 .LBB82: + 666 .LBB83: + 667 .LSM69: + 668 01d8 8091 E800 lds r24,232 + 669 01dc 877F andi r24,lo8(-9) + 670 01de 8093 E800 sts 232,r24 + 671 .LBE83: + 672 .LBE82: + 673 .LSM70: + 674 01e2 0E94 0000 call Endpoint_ClearStatusStage + 675 .LSM71: + 676 01e6 8091 0000 lds r24,USB_ControlRequest+2 + 677 01ea 9091 0000 lds r25,(USB_ControlRequest+2)+1 + 678 01ee 8070 andi r24,lo8(-256) + 679 01f0 76E0 ldi r23,6 + 680 01f2 9695 1: lsr r25 + 681 01f4 8795 ror r24 + 682 01f6 7A95 dec r23 + 683 01f8 01F4 brne 1b + 684 01fa F401 movw r30,r8 + 685 01fc 9287 std Z+10,r25 + 686 01fe 8187 std Z+9,r24 + 687 0200 00C0 rjmp .L33 + 688 .L36: + 689 .LSM72: + 690 0202 8091 0000 lds r24,USB_ControlRequest + 691 0206 813A cpi r24,lo8(-95) + 692 0208 01F4 brne .L33 + 693 .LBB84: + 694 .LBB85: + 695 .LSM73: + 696 020a 8091 E800 lds r24,232 + 697 020e 877F andi r24,lo8(-9) + 698 0210 8093 E800 sts 232,r24 + 699 .LBE85: + 700 .LBE84: + 701 .LSM74: + 702 0214 F401 movw r30,r8 + 703 0216 8185 ldd r24,Z+9 + 704 0218 9285 ldd r25,Z+10 + 705 021a 9695 lsr r25 + 706 021c 8795 ror r24 + 707 021e 9695 lsr r25 + 708 0220 8795 ror r24 + 709 .L35: + 710 .LBB86: + 711 .LBB87: + 712 .LSM75: + 713 0222 8093 F100 sts 241,r24 + 714 .LBE87: + 715 .LBE86: + 716 .LBB88: + 717 .LBB89: + 718 .LSM76: + 719 0226 8091 E800 lds r24,232 + 720 022a 8E77 andi r24,lo8(126) + 721 022c 8093 E800 sts 232,r24 + 722 .LBE89: + 723 .LBE88: + 724 .LSM77: + 725 0230 0E94 0000 call Endpoint_ClearStatusStage + 726 .LVL28: + 727 .L33: + 728 .LSM78: + 729 0234 0FB6 in __tmp_reg__,__SREG__ + 730 0236 F894 cli + 731 0238 7EBE out __SP_H__,r7 + 732 023a 0FBE out __SREG__,__tmp_reg__ + 733 023c 6DBE out __SP_L__,r6 + 734 /* epilogue start */ + 735 023e 0F90 pop __tmp_reg__ + 736 0240 0F90 pop __tmp_reg__ + 737 0242 0F90 pop __tmp_reg__ + 738 0244 CF91 pop r28 + 739 0246 DF91 pop r29 + 740 0248 1F91 pop r17 + 741 024a 0F91 pop r16 + 742 .LVL29: + 743 024c FF90 pop r15 + 744 024e EF90 pop r14 + 745 0250 DF90 pop r13 + 746 0252 CF90 pop r12 + 747 0254 BF90 pop r11 + 748 0256 AF90 pop r10 + 749 0258 9F90 pop r9 + 750 025a 8F90 pop r8 + 751 .LVL30: + 752 025c 7F90 pop r7 + 753 025e 6F90 pop r6 + 754 0260 0895 ret + 755 .LFE81: + 797 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 HID.c + /tmp/ccYdlTY9.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccYdlTY9.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccYdlTY9.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccYdlTY9.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccYdlTY9.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccYdlTY9.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccYdlTY9.s:19 .text.HID_Device_USBTask:0000000000000000 HID_Device_USBTask + /tmp/ccYdlTY9.s:279 .text.HID_Device_ConfigureEndpoints:0000000000000000 HID_Device_ConfigureEndpoints + /tmp/ccYdlTY9.s:374 .text.HID_Device_ProcessControlRequest:0000000000000000 HID_Device_ProcessControlRequest + +UNDEFINED SYMBOLS +USB_DeviceState +memset +CALLBACK_HID_Device_CreateHIDReport +memcmp +memcpy +Endpoint_Write_Stream_LE +Endpoint_ConfigureEndpoint_Prv +USB_ControlRequest +Endpoint_Write_Control_Stream_LE +Endpoint_Read_Control_Stream_LE +CALLBACK_HID_Device_ProcessHIDReport +Endpoint_ClearStatusStage diff --git a/firmware/LUFA/Drivers/USB/Class/Device/HID.o b/firmware/LUFA/Drivers/USB/Class/Device/HID.o new file mode 100644 index 0000000..d3f9f75 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Device/HID.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MIDI.c b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.c new file mode 100644 index 0000000..9d2a1a8 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.c @@ -0,0 +1,148 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_MIDI_DRIVER +#define __INCLUDE_FROM_MIDI_DEVICE_C +#include "MIDI.h" + +bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) +{ + memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State)); + + for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) + { + uint16_t Size; + uint8_t Type; + uint8_t Direction; + bool DoubleBanked; + + if (EndpointNum == MIDIInterfaceInfo->Config.DataINEndpointNumber) + { + Size = MIDIInterfaceInfo->Config.DataINEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_BULK; + DoubleBanked = MIDIInterfaceInfo->Config.DataINEndpointDoubleBank; + } + else if (EndpointNum == MIDIInterfaceInfo->Config.DataOUTEndpointNumber) + { + Size = MIDIInterfaceInfo->Config.DataOUTEndpointSize; + Direction = ENDPOINT_DIR_OUT; + Type = EP_TYPE_BULK; + DoubleBanked = MIDIInterfaceInfo->Config.DataOUTEndpointDoubleBank; + } + else + { + continue; + } + + if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, + DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) + { + return false; + } + } + + return true; +} + +void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + MIDI_Device_Flush(MIDIInterfaceInfo); + #endif +} + +uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, + const MIDI_EventPacket_t* const Event) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber); + + if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK)) != ENDPOINT_RWSTREAM_NoError) + return ErrorCode; + + if (!(Endpoint_IsReadWriteAllowed())) + Endpoint_ClearIN(); + + return ENDPOINT_RWSTREAM_NoError; +} + +uint8_t MIDI_Device_Flush(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpointNumber); + + if (Endpoint_BytesInEndpoint()) + { + Endpoint_ClearIN(); + + if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) + return ErrorCode; + } + + return ENDPOINT_READYWAIT_NoError; +} + +bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, + MIDI_EventPacket_t* const Event) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return false; + + Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpointNumber); + + if (!(Endpoint_IsReadWriteAllowed())) + return false; + + Endpoint_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK); + + if (!(Endpoint_IsReadWriteAllowed())) + Endpoint_ClearOUT(); + + return true; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MIDI.h b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.h new file mode 100644 index 0000000..8ac7146 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.h @@ -0,0 +1,189 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 MIDI Class driver. + * + * Device mode driver for the library USB MIDI 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_USBClassMIDI + * @defgroup Group_USBClassMIDIDevice MIDI 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/MIDI.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Device Mode USB Class driver framework interface, for the MIDI USB Class driver. + * + * @{ + */ + +#ifndef _MIDI_CLASS_DEVICE_H_ +#define _MIDI_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/MIDI.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_MIDI_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_MIDI_DEVICE_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Define: */ + /** \brief MIDI Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each MIDI interface + * within the user application, and passed to each of the MIDI class driver functions as the + * MIDIInterfaceInfo parameter. This stores each MIDI interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls. */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the incoming MIDI data, if available (zero if unused). */ + uint16_t DataINEndpointSize; /**< Size in bytes of the incoming MIDI data endpoint, if available (zero if unused). */ + bool DataINEndpointDoubleBank; /**< Indicates if the MIDI interface's IN data endpoint should use double banking. */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the outgoing MIDI data, if available (zero if unused). */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the outgoing MIDI data endpoint, if available (zero if unused). */ + bool DataOUTEndpointDoubleBank; /**< Indicates if the MIDI interface's IN data 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 + { + // No state information for this class + } 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_MIDI_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given MIDI 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 MIDI interface is selected. + * + * \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * + * \return Boolean true if the endpoints were successfully configured, false otherwise. + */ + bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** General management task for a given MIDI 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] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + */ + void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. Events are queued into the + * endpoint bank until either the endpoint bank is full, or \ref MIDI_Device_Flush() is called. This allows for multiple + * MIDI events to be packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * \param[in] Event Pointer to a populated \ref MIDI_EventPacket_t structure containing the MIDI event to send. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, + const MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + + /** Flushes the MIDI send buffer, sending any queued MIDI events to the host. This should be called to override the + * \ref MIDI_Device_SendEventPacket() function's packing behaviour, to flush queued events. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t MIDI_Device_Flush(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Receives a MIDI event packet from the host. Events are unpacked from the endpoint, thus if the endpoint bank contains + * multiple MIDI events from the host in the one packet, multiple calls to this function will return each individual event. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * \param[out] Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed. + * + * \return Boolean true if a MIDI event packet was received, false otherwise. + */ + bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo, + MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /* Inline Functions: */ + /** Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + */ + static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) + { + (void)MIDIInterfaceInfo; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MIDI.lst b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.lst new file mode 100644 index 0000000..cb878a0 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.lst @@ -0,0 +1,346 @@ + 1 .file "MIDI.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.MIDI_Device_ReceiveEventPacket,"ax",@progbits + 17 .global MIDI_Device_ReceiveEventPacket + 19 MIDI_Device_ReceiveEventPacket: + 20 .LFB85: + 21 .LSM0: + 22 .LVL0: + 23 /* prologue: function */ + 24 /* frame size = 0 */ + 25 0000 FC01 movw r30,r24 + 26 .LSM1: + 27 0002 8091 0000 lds r24,USB_DeviceState + 28 .LVL1: + 29 0006 8430 cpi r24,lo8(4) + 30 0008 01F4 brne .L2 + 31 .LSM2: + 32 000a 8581 ldd r24,Z+5 + 33 .LBB30: + 34 .LBB31: + 35 .LSM3: + 36 000c 8093 E900 sts 233,r24 + 37 .LBE31: + 38 .LBE30: + 39 .LBB32: + 40 .LBB33: + 41 .LSM4: + 42 0010 8091 E800 lds r24,232 + 43 .LBE33: + 44 .LBE32: + 45 .LSM5: + 46 0014 85FF sbrs r24,5 + 47 0016 00C0 rjmp .L2 + 48 .LSM6: + 49 0018 CB01 movw r24,r22 + 50 001a 64E0 ldi r22,lo8(4) + 51 001c 70E0 ldi r23,hi8(4) + 52 .LVL2: + 53 001e 40E0 ldi r20,lo8(0) + 54 0020 50E0 ldi r21,hi8(0) + 55 0022 0E94 0000 call Endpoint_Read_Stream_LE + 56 .LVL3: + 57 .LBB34: + 58 .LBB35: + 59 .LSM7: + 60 0026 8091 E800 lds r24,232 + 61 .LBE35: + 62 .LBE34: + 63 .LSM8: + 64 002a 85FD sbrc r24,5 + 65 002c 00C0 rjmp .L6 + 66 .L3: + 67 .LBB36: + 68 .LBB37: + 69 .LSM9: + 70 002e 8091 E800 lds r24,232 + 71 0032 8B77 andi r24,lo8(123) + 72 0034 8093 E800 sts 232,r24 + 73 .L6: + 74 0038 81E0 ldi r24,lo8(1) + 75 003a 0895 ret + 76 .LVL4: + 77 .L2: + 78 003c 80E0 ldi r24,lo8(0) + 79 .LBE37: + 80 .LBE36: + 81 .LSM10: + 82 003e 0895 ret + 83 .LFE85: + 85 .section .text.MIDI_Device_Flush,"ax",@progbits + 86 .global MIDI_Device_Flush + 88 MIDI_Device_Flush: + 89 .LFB84: + 90 .LSM11: + 91 .LVL5: + 92 /* prologue: function */ + 93 /* frame size = 0 */ + 94 0000 FC01 movw r30,r24 + 95 .LSM12: + 96 0002 8091 0000 lds r24,USB_DeviceState + 97 .LVL6: + 98 0006 8430 cpi r24,lo8(4) + 99 0008 01F0 breq .L8 + 100 000a 82E0 ldi r24,lo8(2) + 101 .LVL7: + 102 000c 0895 ret + 103 .LVL8: + 104 .L8: + 105 .LSM13: + 106 000e 8181 ldd r24,Z+1 + 107 .LBB38: + 108 .LBB39: + 109 .LSM14: + 110 0010 8093 E900 sts 233,r24 + 111 .LBE39: + 112 .LBE38: + 113 .LBB40: + 114 .LBB41: + 115 .LSM15: + 116 0014 8091 F200 lds r24,242 + 117 .LBE41: + 118 .LBE40: + 119 .LSM16: + 120 0018 8823 tst r24 + 121 001a 01F0 breq .L9 + 122 .LBB42: + 123 .LBB43: + 124 .LSM17: + 125 001c 8091 E800 lds r24,232 + 126 0020 8E77 andi r24,lo8(126) + 127 0022 8093 E800 sts 232,r24 + 128 .LBE43: + 129 .LBE42: + 130 .LSM18: + 131 0026 0E94 0000 call Endpoint_WaitUntilReady + 132 .LVL9: + 133 .L9: + 134 .LSM19: + 135 002a 0895 ret + 136 .LFE84: + 138 .section .text.MIDI_Device_USBTask,"ax",@progbits + 139 .global MIDI_Device_USBTask + 141 MIDI_Device_USBTask: + 142 .LFB82: + 143 .LSM20: + 144 .LVL10: + 145 /* prologue: function */ + 146 /* frame size = 0 */ + 147 0000 9C01 movw r18,r24 + 148 .LSM21: + 149 0002 8091 0000 lds r24,USB_DeviceState + 150 .LVL11: + 151 0006 8430 cpi r24,lo8(4) + 152 0008 01F4 brne .L14 + 153 .LSM22: + 154 000a C901 movw r24,r18 + 155 000c 0E94 0000 call MIDI_Device_Flush + 156 .LVL12: + 157 .L14: + 158 0010 0895 ret + 159 .LFE82: + 161 .section .text.MIDI_Device_SendEventPacket,"ax",@progbits + 162 .global MIDI_Device_SendEventPacket + 164 MIDI_Device_SendEventPacket: + 165 .LFB83: + 166 .LSM23: + 167 .LVL13: + 168 /* prologue: function */ + 169 /* frame size = 0 */ + 170 0000 FC01 movw r30,r24 + 171 .LSM24: + 172 0002 8091 0000 lds r24,USB_DeviceState + 173 .LVL14: + 174 0006 8430 cpi r24,lo8(4) + 175 0008 01F0 breq .L16 + 176 000a 92E0 ldi r25,lo8(2) + 177 .LVL15: + 178 000c 00C0 rjmp .L17 + 179 .LVL16: + 180 .L16: + 181 .LSM25: + 182 000e 8181 ldd r24,Z+1 + 183 .LBB44: + 184 .LBB45: + 185 .LSM26: + 186 0010 8093 E900 sts 233,r24 + 187 .LBE45: + 188 .LBE44: + 189 .LSM27: + 190 0014 CB01 movw r24,r22 + 191 0016 64E0 ldi r22,lo8(4) + 192 0018 70E0 ldi r23,hi8(4) + 193 .LVL17: + 194 001a 40E0 ldi r20,lo8(0) + 195 001c 50E0 ldi r21,hi8(0) + 196 001e 0E94 0000 call Endpoint_Write_Stream_LE + 197 .LVL18: + 198 0022 982F mov r25,r24 + 199 .LVL19: + 200 0024 8823 tst r24 + 201 0026 01F4 brne .L17 + 202 .LVL20: + 203 .LBB46: + 204 .LBB47: + 205 .LSM28: + 206 0028 8091 E800 lds r24,232 + 207 .LVL21: + 208 .LBE47: + 209 .LBE46: + 210 .LSM29: + 211 002c 85FD sbrc r24,5 + 212 002e 00C0 rjmp .L17 + 213 .LBB48: + 214 .LBB49: + 215 .LSM30: + 216 0030 8091 E800 lds r24,232 + 217 0034 8E77 andi r24,lo8(126) + 218 0036 8093 E800 sts 232,r24 + 219 .LVL22: + 220 .L17: + 221 .LBE49: + 222 .LBE48: + 223 .LSM31: + 224 003a 892F mov r24,r25 + 225 /* epilogue start */ + 226 003c 0895 ret + 227 .LFE83: + 229 .section .text.MIDI_Device_ConfigureEndpoints,"ax",@progbits + 230 .global MIDI_Device_ConfigureEndpoints + 232 MIDI_Device_ConfigureEndpoints: + 233 .LFB81: + 234 .LSM32: + 235 .LVL23: + 236 0000 1F93 push r17 + 237 0002 CF93 push r28 + 238 0004 DF93 push r29 + 239 /* prologue: function */ + 240 /* frame size = 0 */ + 241 0006 EC01 movw r28,r24 + 242 .LSM33: + 243 0008 11E0 ldi r17,lo8(1) + 244 .LVL24: + 245 .L28: + 246 .LBB50: + 247 .LBB51: + 248 .LSM34: + 249 000a 8981 ldd r24,Y+1 + 250 000c 1817 cp r17,r24 + 251 000e 01F4 brne .L20 + 252 .LSM35: + 253 0010 EA81 ldd r30,Y+2 + 254 0012 FB81 ldd r31,Y+3 + 255 .LVL25: + 256 .LSM36: + 257 0014 8C81 ldd r24,Y+4 + 258 .LVL26: + 259 0016 61E0 ldi r22,lo8(1) + 260 .LVL27: + 261 0018 00C0 rjmp .L21 + 262 .LVL28: + 263 .L20: + 264 .LSM37: + 265 001a 8D81 ldd r24,Y+5 + 266 001c 1817 cp r17,r24 + 267 001e 01F4 brne .L22 + 268 .LSM38: + 269 0020 EE81 ldd r30,Y+6 + 270 0022 FF81 ldd r31,Y+7 + 271 .LVL29: + 272 .LSM39: + 273 0024 8885 ldd r24,Y+8 + 274 .LVL30: + 275 0026 60E0 ldi r22,lo8(0) + 276 .LVL31: + 277 .L21: + 278 .LSM40: + 279 0028 8823 tst r24 + 280 002a 01F4 brne .L23 + 281 002c 40E0 ldi r20,lo8(0) + 282 002e 00C0 rjmp .L24 + 283 .L23: + 284 0030 44E0 ldi r20,lo8(4) + 285 .L24: + 286 0032 20E0 ldi r18,lo8(0) + 287 .LVL32: + 288 0034 88E0 ldi r24,lo8(8) + 289 0036 90E0 ldi r25,hi8(8) + 290 .LVL33: + 291 0038 00C0 rjmp .L25 + 292 .L26: + 293 .LBB52: + 294 .LBB53: + 295 .LBB54: + 296 .LBB55: + 297 .LSM41: + 298 003a 2F5F subi r18,lo8(-(1)) + 299 .LSM42: + 300 003c 880F lsl r24 + 301 003e 991F rol r25 + 302 .L25: + 303 .LSM43: + 304 0040 8E17 cp r24,r30 + 305 0042 9F07 cpc r25,r31 + 306 0044 00F0 brlo .L26 + 307 .LBE55: + 308 .LBE54: + 309 .LBE53: + 310 .LSM44: + 311 0046 6068 ori r22,lo8(-128) + 312 0048 4260 ori r20,lo8(2) + 313 004a 2295 swap r18 + 314 004c 207F andi r18,lo8(-16) + 315 004e 422B or r20,r18 + 316 0050 812F mov r24,r17 + 317 .LVL34: + 318 0052 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 319 .LVL35: + 320 .LBE52: + 321 .LSM45: + 322 0056 8823 tst r24 + 323 0058 01F0 breq .L27 + 324 .L22: + 325 .LBE51: + 326 .LSM46: + 327 005a 1F5F subi r17,lo8(-(1)) + 328 005c 1530 cpi r17,lo8(5) + 329 005e 01F4 brne .L28 + 330 0060 81E0 ldi r24,lo8(1) + 331 .L27: + 332 /* epilogue start */ + 333 .LBE50: + 334 .LSM47: + 335 0062 DF91 pop r29 + 336 0064 CF91 pop r28 + 337 .LVL36: + 338 0066 1F91 pop r17 + 339 .LVL37: + 340 0068 0895 ret + 341 .LFE81: + 399 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 MIDI.c + /tmp/cc3Ze3Jq.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cc3Ze3Jq.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cc3Ze3Jq.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cc3Ze3Jq.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cc3Ze3Jq.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cc3Ze3Jq.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/cc3Ze3Jq.s:19 .text.MIDI_Device_ReceiveEventPacket:0000000000000000 MIDI_Device_ReceiveEventPacket + /tmp/cc3Ze3Jq.s:88 .text.MIDI_Device_Flush:0000000000000000 MIDI_Device_Flush + /tmp/cc3Ze3Jq.s:141 .text.MIDI_Device_USBTask:0000000000000000 MIDI_Device_USBTask + /tmp/cc3Ze3Jq.s:164 .text.MIDI_Device_SendEventPacket:0000000000000000 MIDI_Device_SendEventPacket + /tmp/cc3Ze3Jq.s:232 .text.MIDI_Device_ConfigureEndpoints:0000000000000000 MIDI_Device_ConfigureEndpoints + +UNDEFINED SYMBOLS +USB_DeviceState +Endpoint_Read_Stream_LE +Endpoint_WaitUntilReady +Endpoint_Write_Stream_LE +Endpoint_ConfigureEndpoint_Prv diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MIDI.o b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.o new file mode 100644 index 0000000..80100ad Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Device/MIDI.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.c b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.c new file mode 100644 index 0000000..64d61df --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.c @@ -0,0 +1,247 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_MS_DRIVER +#define __INCLUDE_FROM_MASSSTORAGE_DEVICE_C +#include "MassStorage.h" + +static volatile bool* CallbackIsResetSource; + +void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if (USB_ControlRequest.wIndex != MSInterfaceInfo->Config.InterfaceNumber) + return; + + switch (USB_ControlRequest.bRequest) + { + case MS_REQ_MassStorageReset: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + MSInterfaceInfo->State.IsMassStoreReset = true; + } + + break; + case MS_REQ_GetMaxLUN: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_Write_Byte(MSInterfaceInfo->Config.TotalLUNs - 1); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + + break; + } +} + +bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + memset(&MSInterfaceInfo->State, 0x00, sizeof(MSInterfaceInfo->State)); + + for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) + { + uint16_t Size; + uint8_t Type; + uint8_t Direction; + bool DoubleBanked; + + if (EndpointNum == MSInterfaceInfo->Config.DataINEndpointNumber) + { + Size = MSInterfaceInfo->Config.DataINEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_BULK; + DoubleBanked = MSInterfaceInfo->Config.DataINEndpointDoubleBank; + } + else if (EndpointNum == MSInterfaceInfo->Config.DataOUTEndpointNumber) + { + Size = MSInterfaceInfo->Config.DataOUTEndpointSize; + Direction = ENDPOINT_DIR_OUT; + Type = EP_TYPE_BULK; + DoubleBanked = MSInterfaceInfo->Config.DataOUTEndpointDoubleBank; + } + else + { + continue; + } + + if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, + DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) + { + return false; + } + } + + return true; +} + +void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + + if (Endpoint_IsReadWriteAllowed()) + { + if (MS_Device_ReadInCommandBlock(MSInterfaceInfo)) + { + if (MSInterfaceInfo->State.CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN) + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + + MSInterfaceInfo->State.CommandStatus.Status = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo) ? + MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail; + MSInterfaceInfo->State.CommandStatus.Signature = MS_CSW_SIGNATURE; + MSInterfaceInfo->State.CommandStatus.Tag = MSInterfaceInfo->State.CommandBlock.Tag; + MSInterfaceInfo->State.CommandStatus.DataTransferResidue = MSInterfaceInfo->State.CommandBlock.DataTransferLength; + + if ((MSInterfaceInfo->State.CommandStatus.Status == MS_SCSI_COMMAND_Fail) && + (MSInterfaceInfo->State.CommandStatus.DataTransferResidue)) + { + Endpoint_StallTransaction(); + } + + MS_Device_ReturnCommandStatus(MSInterfaceInfo); + } + } + + if (MSInterfaceInfo->State.IsMassStoreReset) + { + Endpoint_ResetFIFO(MSInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_ResetFIFO(MSInterfaceInfo->Config.DataINEndpointNumber); + + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + Endpoint_ClearStall(); + Endpoint_ResetDataToggle(); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_ClearStall(); + Endpoint_ResetDataToggle(); + + MSInterfaceInfo->State.IsMassStoreReset = false; + } +} + +static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + + CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset; + if (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock, + (sizeof(MS_CommandBlockWrapper_t) - 16), + StreamCallback_MS_Device_AbortOnMassStoreReset)) + { + return false; + } + + if ((MSInterfaceInfo->State.CommandBlock.Signature != MS_CBW_SIGNATURE) || + (MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) || + (MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) || + (MSInterfaceInfo->State.CommandBlock.SCSICommandLength == 0) || + (MSInterfaceInfo->State.CommandBlock.SCSICommandLength > 16)) + { + Endpoint_StallTransaction(); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + Endpoint_StallTransaction(); + + return false; + } + + CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset; + if (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock.SCSICommandData, + MSInterfaceInfo->State.CommandBlock.SCSICommandLength, + StreamCallback_MS_Device_AbortOnMassStoreReset)) + { + return false; + } + + Endpoint_ClearOUT(); + + return true; +} + +static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpointNumber); + + while (Endpoint_IsStalled()) + { + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (MSInterfaceInfo->State.IsMassStoreReset) + return; + } + + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpointNumber); + + while (Endpoint_IsStalled()) + { + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (MSInterfaceInfo->State.IsMassStoreReset) + return; + } + + CallbackIsResetSource = &MSInterfaceInfo->State.IsMassStoreReset; + if (Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, sizeof(MS_CommandStatusWrapper_t), + StreamCallback_MS_Device_AbortOnMassStoreReset)) + { + return; + } + + Endpoint_ClearIN(); +} + +static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void) +{ + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (*CallbackIsResetSource) + return STREAMCALLBACK_Abort; + else + return STREAMCALLBACK_Continue; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.h b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.h new file mode 100644 index 0000000..31d3ba9 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.h @@ -0,0 +1,177 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Mass Storage Class driver. + * + * Device mode driver for the library USB Mass Storage 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_USBClassMS + * @defgroup Group_USBClassMSDevice Mass Storage 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/MassStorage.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Device Mode USB Class driver framework interface, for the Mass Storage USB Class driver. + * + * @{ + */ + +#ifndef _MS_CLASS_DEVICE_H_ +#define _MS_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/MassStorage.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_MS_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_MASSSTORAGE_DEVICE_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief Mass Storage Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each Mass Storage interface + * within the user application, and passed to each of the Mass Storage class driver functions as the + * MSInterfaceInfo parameter. This stores each Mass Storage interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device. */ + + uint8_t DataINEndpointNumber; /**< Endpoint number of the Mass Storage interface's IN data endpoint. */ + uint16_t DataINEndpointSize; /**< Size in bytes of the Mass Storage interface's IN data endpoint. */ + bool DataINEndpointDoubleBank; /**< Indicates if the Mass Storage interface's IN data endpoint should use double banking. */ + + uint8_t DataOUTEndpointNumber; /**< Endpoint number of the Mass Storage interface's OUT data endpoint. */ + uint16_t DataOUTEndpointSize; /**< Size in bytes of the Mass Storage interface's OUT data endpoint. */ + bool DataOUTEndpointDoubleBank; /**< Indicates if the Mass Storage interface's OUT data endpoint should use double banking. */ + + uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface. */ + } 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 + { + MS_CommandBlockWrapper_t CommandBlock; /**< Mass Storage class command block structure, stores the received SCSI + * command from the host which is to be processed. + */ + MS_CommandStatusWrapper_t CommandStatus; /**< Mass Storage class command status structure, set elements to indicate + * the issued command's success or failure to the host. + */ + volatile bool IsMassStoreReset; /**< Flag indicating that the host has requested that the Mass Storage interface be reset + * and that all current Mass Storage operations should immediately abort. + */ + } 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_MS_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given Mass Storage 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 Mass Storage interface is selected. + * + * \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + * + * \return Boolean true if the endpoints were successfully configured, false otherwise. + */ + bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Processes incoming control requests from the host, that are directed to the given Mass Storage class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + */ + void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** General management task for a given Mass Storage 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] MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state. + */ + void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the + * host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible + * for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure + * inside the Mass Storage class state structure passed as a parameter to the callback function. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + * + * \return Boolean true if the SCSI command was successfully processed, false otherwise. + */ + bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_MASSSTORAGE_DEVICE_C) + static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void); + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.lst b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.lst new file mode 100644 index 0000000..12dc787 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.lst @@ -0,0 +1,643 @@ + 1 .file "MassStorage.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.StreamCallback_MS_Device_AbortOnMassStoreReset,"ax",@progbits + 18 StreamCallback_MS_Device_AbortOnMassStoreReset: + 19 .LFB86: + 20 .LSM0: + 21 /* prologue: function */ + 22 /* frame size = 0 */ + 23 .LSM1: + 24 0000 0E94 0000 call USB_USBTask + 25 .LSM2: + 26 0004 E091 0000 lds r30,CallbackIsResetSource + 27 0008 F091 0000 lds r31,(CallbackIsResetSource)+1 + 28 000c 8081 ld r24,Z + 29 /* epilogue start */ + 30 .LSM3: + 31 000e 0895 ret + 32 .LFE86: + 34 .section .text.MS_Device_USBTask,"ax",@progbits + 35 .global MS_Device_USBTask + 37 MS_Device_USBTask: + 38 .LFB83: + 39 .LSM4: + 40 .LVL0: + 41 0000 0F93 push r16 + 42 0002 1F93 push r17 + 43 0004 CF93 push r28 + 44 0006 DF93 push r29 + 45 /* prologue: function */ + 46 /* frame size = 0 */ + 47 0008 EC01 movw r28,r24 + 48 .LSM5: + 49 000a 8091 0000 lds r24,USB_DeviceState + 50 .LVL1: + 51 000e 8430 cpi r24,lo8(4) + 52 0010 01F0 breq .+2 + 53 0012 00C0 rjmp .L14 + 54 .LSM6: + 55 0014 9D81 ldd r25,Y+5 + 56 .LBB112: + 57 .LBB113: + 58 .LSM7: + 59 0016 9093 E900 sts 233,r25 + 60 .LBE113: + 61 .LBE112: + 62 .LBB114: + 63 .LBB115: + 64 .LSM8: + 65 001a 8091 E800 lds r24,232 + 66 .LBE115: + 67 .LBE114: + 68 .LSM9: + 69 001e 85FF sbrs r24,5 + 70 0020 00C0 rjmp .L5 + 71 .LBB116: + 72 .LBB117: + 73 .LBB124: + 74 .LBB125: + 75 .LSM10: + 76 0022 9093 E900 sts 233,r25 + 77 .LBE125: + 78 .LBE124: + 79 .LSM11: + 80 0026 8E01 movw r16,r28 + 81 0028 0A5C subi r16,lo8(-(54)) + 82 002a 1F4F sbci r17,hi8(-(54)) + 83 002c 1093 0000 sts (CallbackIsResetSource)+1,r17 + 84 0030 0093 0000 sts CallbackIsResetSource,r16 + 85 .LBE117: + 86 .LSM12: + 87 0034 CE01 movw r24,r28 + 88 0036 0A96 adiw r24,10 + 89 0038 6FE0 ldi r22,lo8(15) + 90 003a 70E0 ldi r23,hi8(15) + 91 003c 40E0 ldi r20,lo8(gs(StreamCallback_MS_Device_AbortOnMassStoreReset)) + 92 003e 50E0 ldi r21,hi8(gs(StreamCallback_MS_Device_AbortOnMassStoreReset)) + 93 0040 0E94 0000 call Endpoint_Read_Stream_LE + 94 .LBB128: + 95 0044 8823 tst r24 + 96 0046 01F0 breq .+2 + 97 0048 00C0 rjmp .L5 + 98 .LSM13: + 99 004a 8A85 ldd r24,Y+10 + 100 004c 9B85 ldd r25,Y+11 + 101 004e AC85 ldd r26,Y+12 + 102 0050 BD85 ldd r27,Y+13 + 103 0052 8555 subi r24,lo8(1128420181) + 104 0054 9345 sbci r25,hi8(1128420181) + 105 0056 A244 sbci r26,hlo8(1128420181) + 106 0058 B344 sbci r27,hhi8(1128420181) + 107 005a 01F4 brne .L6 + 108 005c 9F89 ldd r25,Y+23 + 109 005e 8985 ldd r24,Y+9 + 110 0060 9817 cp r25,r24 + 111 0062 00F4 brsh .L6 + 112 0064 8E89 ldd r24,Y+22 + 113 0066 90E0 ldi r25,lo8(0) + 114 0068 8F71 andi r24,lo8(31) + 115 006a 9070 andi r25,hi8(31) + 116 006c 892B or r24,r25 + 117 006e 01F4 brne .L6 + 118 0070 688D ldd r22,Y+24 + 119 0072 6623 tst r22 + 120 0074 01F0 breq .L6 + 121 0076 6131 cpi r22,lo8(17) + 122 0078 00F0 brlo .L7 + 123 .L6: + 124 .LBB122: + 125 .LBB123: + 126 .LSM14: + 127 007a 8091 EB00 lds r24,235 + 128 007e 8062 ori r24,lo8(32) + 129 0080 8093 EB00 sts 235,r24 + 130 .LBE123: + 131 .LBE122: + 132 .LSM15: + 133 0084 8981 ldd r24,Y+1 + 134 .LBB120: + 135 .LBB121: + 136 .LSM16: + 137 0086 8093 E900 sts 233,r24 + 138 .LBE121: + 139 .LBE120: + 140 .LBB118: + 141 .LBB119: + 142 .LSM17: + 143 008a 8091 EB00 lds r24,235 + 144 008e 8062 ori r24,lo8(32) + 145 0090 8093 EB00 sts 235,r24 + 146 0094 00C0 rjmp .L5 + 147 .L7: + 148 .LBE119: + 149 .LBE118: + 150 .LSM18: + 151 0096 1093 0000 sts (CallbackIsResetSource)+1,r17 + 152 009a 0093 0000 sts CallbackIsResetSource,r16 + 153 .LBE128: + 154 .LSM19: + 155 009e CE01 movw r24,r28 + 156 00a0 4996 adiw r24,25 + 157 00a2 70E0 ldi r23,lo8(0) + 158 00a4 40E0 ldi r20,lo8(gs(StreamCallback_MS_Device_AbortOnMassStoreReset)) + 159 00a6 50E0 ldi r21,hi8(gs(StreamCallback_MS_Device_AbortOnMassStoreReset)) + 160 00a8 0E94 0000 call Endpoint_Read_Stream_LE + 161 .LBB129: + 162 00ac 8823 tst r24 + 163 00ae 01F0 breq .+2 + 164 00b0 00C0 rjmp .L5 + 165 .LBB126: + 166 .LBB127: + 167 .LSM20: + 168 00b2 8091 E800 lds r24,232 + 169 00b6 8B77 andi r24,lo8(123) + 170 00b8 8093 E800 sts 232,r24 + 171 .LBE127: + 172 .LBE126: + 173 .LBE129: + 174 .LBE116: + 175 .LSM21: + 176 00bc 8E89 ldd r24,Y+22 + 177 00be 87FF sbrs r24,7 + 178 00c0 00C0 rjmp .L8 + 179 .LSM22: + 180 00c2 8981 ldd r24,Y+1 + 181 .LBB130: + 182 .LBB131: + 183 .LSM23: + 184 00c4 8093 E900 sts 233,r24 + 185 .L8: + 186 .LBE131: + 187 .LBE130: + 188 .LSM24: + 189 00c8 CE01 movw r24,r28 + 190 00ca 0E94 0000 call CALLBACK_MS_Device_SCSICommandReceived + 191 00ce 91E0 ldi r25,lo8(1) + 192 00d0 9827 eor r25,r24 + 193 00d2 9DAB std Y+53,r25 + 194 .LSM25: + 195 00d4 25E5 ldi r18,lo8(1396855637) + 196 00d6 33E5 ldi r19,hi8(1396855637) + 197 00d8 42E4 ldi r20,hlo8(1396855637) + 198 00da 53E5 ldi r21,hhi8(1396855637) + 199 00dc 29A7 std Y+41,r18 + 200 00de 3AA7 std Y+42,r19 + 201 00e0 4BA7 std Y+43,r20 + 202 00e2 5CA7 std Y+44,r21 + 203 .LSM26: + 204 00e4 2E85 ldd r18,Y+14 + 205 00e6 3F85 ldd r19,Y+15 + 206 00e8 4889 ldd r20,Y+16 + 207 00ea 5989 ldd r21,Y+17 + 208 00ec 2DA7 std Y+45,r18 + 209 00ee 3EA7 std Y+46,r19 + 210 00f0 4FA7 std Y+47,r20 + 211 00f2 58AB std Y+48,r21 + 212 .LSM27: + 213 00f4 2A89 ldd r18,Y+18 + 214 00f6 3B89 ldd r19,Y+19 + 215 00f8 4C89 ldd r20,Y+20 + 216 00fa 5D89 ldd r21,Y+21 + 217 00fc 29AB std Y+49,r18 + 218 00fe 3AAB std Y+50,r19 + 219 0100 4BAB std Y+51,r20 + 220 0102 5CAB std Y+52,r21 + 221 .LSM28: + 222 0104 9130 cpi r25,lo8(1) + 223 0106 01F4 brne .L9 + 224 0108 2115 cp r18,__zero_reg__ + 225 010a 3105 cpc r19,__zero_reg__ + 226 010c 4105 cpc r20,__zero_reg__ + 227 010e 5105 cpc r21,__zero_reg__ + 228 0110 01F0 breq .L9 + 229 .LBB132: + 230 .LBB133: + 231 .LSM29: + 232 0112 8091 EB00 lds r24,235 + 233 0116 8062 ori r24,lo8(32) + 234 0118 8093 EB00 sts 235,r24 + 235 .L9: + 236 .LBE133: + 237 .LBE132: + 238 .LBB134: + 239 .LBB135: + 240 .LSM30: + 241 011c 8D81 ldd r24,Y+5 + 242 .LBB142: + 243 .LBB143: + 244 .LSM31: + 245 011e 8093 E900 sts 233,r24 + 246 0122 00C0 rjmp .L10 + 247 .L11: + 248 .LBE143: + 249 .LBE142: + 250 .LSM32: + 251 0124 0E94 0000 call USB_USBTask + 252 .LSM33: + 253 0128 8EA9 ldd r24,Y+54 + 254 012a 8823 tst r24 + 255 012c 01F4 brne .L5 + 256 .L10: + 257 .LBB140: + 258 .LBB141: + 259 .LSM34: + 260 012e 8091 EB00 lds r24,235 + 261 .LBE141: + 262 .LBE140: + 263 .LSM35: + 264 0132 85FD sbrc r24,5 + 265 0134 00C0 rjmp .L11 + 266 .LSM36: + 267 0136 8981 ldd r24,Y+1 + 268 .LBB138: + 269 .LBB139: + 270 .LSM37: + 271 0138 8093 E900 sts 233,r24 + 272 013c 00C0 rjmp .L12 + 273 .L13: + 274 .LBE139: + 275 .LBE138: + 276 .LSM38: + 277 013e 0E94 0000 call USB_USBTask + 278 .LSM39: + 279 0142 8EA9 ldd r24,Y+54 + 280 0144 8823 tst r24 + 281 0146 01F4 brne .L5 + 282 .L12: + 283 .LBB136: + 284 .LBB137: + 285 .LSM40: + 286 0148 8091 EB00 lds r24,235 + 287 .LBE137: + 288 .LBE136: + 289 .LSM41: + 290 014c 85FD sbrc r24,5 + 291 014e 00C0 rjmp .L13 + 292 .LSM42: + 293 0150 E696 adiw r28,54 + 294 0152 D093 0000 sts (CallbackIsResetSource)+1,r29 + 295 0156 C093 0000 sts CallbackIsResetSource,r28 + 296 015a E697 sbiw r28,54 + 297 .LBE135: + 298 .LSM43: + 299 015c CE01 movw r24,r28 + 300 015e 8996 adiw r24,41 + 301 0160 6DE0 ldi r22,lo8(13) + 302 0162 70E0 ldi r23,hi8(13) + 303 0164 40E0 ldi r20,lo8(gs(StreamCallback_MS_Device_AbortOnMassStoreReset)) + 304 0166 50E0 ldi r21,hi8(gs(StreamCallback_MS_Device_AbortOnMassStoreReset)) + 305 0168 0E94 0000 call Endpoint_Write_Stream_LE + 306 .LBB146: + 307 016c 8823 tst r24 + 308 016e 01F4 brne .L5 + 309 .LBB144: + 310 .LBB145: + 311 .LSM44: + 312 0170 8091 E800 lds r24,232 + 313 0174 8E77 andi r24,lo8(126) + 314 0176 8093 E800 sts 232,r24 + 315 .L5: + 316 .LBE145: + 317 .LBE144: + 318 .LBE146: + 319 .LBE134: + 320 .LSM45: + 321 017a 8EA9 ldd r24,Y+54 + 322 017c 8823 tst r24 + 323 017e 01F0 breq .L14 + 324 .LSM46: + 325 0180 4D81 ldd r20,Y+5 + 326 .LBB147: + 327 .LBB148: + 328 .LSM47: + 329 0182 21E0 ldi r18,lo8(1) + 330 0184 30E0 ldi r19,hi8(1) + 331 0186 C901 movw r24,r18 + 332 0188 042E mov r0,r20 + 333 018a 00C0 rjmp 2f + 334 018c 880F 1: lsl r24 + 335 018e 991F rol r25 + 336 0190 0A94 2: dec r0 + 337 0192 02F4 brpl 1b + 338 0194 8093 EA00 sts 234,r24 + 339 .LSM48: + 340 0198 1092 EA00 sts 234,__zero_reg__ + 341 .LBE148: + 342 .LBE147: + 343 .LSM49: + 344 019c 9981 ldd r25,Y+1 + 345 .LBB149: + 346 .LBB150: + 347 .LSM50: + 348 019e 092E mov r0,r25 + 349 01a0 00C0 rjmp 2f + 350 01a2 220F 1: lsl r18 + 351 01a4 331F rol r19 + 352 01a6 0A94 2: dec r0 + 353 01a8 02F4 brpl 1b + 354 01aa 2093 EA00 sts 234,r18 + 355 .LSM51: + 356 01ae 1092 EA00 sts 234,__zero_reg__ + 357 .LBE150: + 358 .LBE149: + 359 .LBB151: + 360 .LBB152: + 361 .LSM52: + 362 01b2 4093 E900 sts 233,r20 + 363 .LBE152: + 364 .LBE151: + 365 .LBB153: + 366 .LBB154: + 367 .LSM53: + 368 01b6 8091 EB00 lds r24,235 + 369 01ba 8061 ori r24,lo8(16) + 370 01bc 8093 EB00 sts 235,r24 + 371 .LBE154: + 372 .LBE153: + 373 .LBB155: + 374 .LBB156: + 375 .LSM54: + 376 01c0 8091 EB00 lds r24,235 + 377 01c4 8860 ori r24,lo8(8) + 378 01c6 8093 EB00 sts 235,r24 + 379 .LBE156: + 380 .LBE155: + 381 .LBB157: + 382 .LBB158: + 383 .LSM55: + 384 01ca 9093 E900 sts 233,r25 + 385 .LBE158: + 386 .LBE157: + 387 .LBB159: + 388 .LBB160: + 389 .LSM56: + 390 01ce 8091 EB00 lds r24,235 + 391 01d2 8061 ori r24,lo8(16) + 392 01d4 8093 EB00 sts 235,r24 + 393 .LBE160: + 394 .LBE159: + 395 .LBB161: + 396 .LBB162: + 397 .LSM57: + 398 01d8 8091 EB00 lds r24,235 + 399 01dc 8860 ori r24,lo8(8) + 400 01de 8093 EB00 sts 235,r24 + 401 .LBE162: + 402 .LBE161: + 403 .LSM58: + 404 01e2 1EAA std Y+54,__zero_reg__ + 405 .L14: + 406 /* epilogue start */ + 407 .LSM59: + 408 01e4 DF91 pop r29 + 409 01e6 CF91 pop r28 + 410 .LVL2: + 411 01e8 1F91 pop r17 + 412 01ea 0F91 pop r16 + 413 01ec 0895 ret + 414 .LFE83: + 416 .section .text.MS_Device_ConfigureEndpoints,"ax",@progbits + 417 .global MS_Device_ConfigureEndpoints + 419 MS_Device_ConfigureEndpoints: + 420 .LFB82: + 421 .LSM60: + 422 .LVL3: + 423 0000 1F93 push r17 + 424 0002 CF93 push r28 + 425 0004 DF93 push r29 + 426 /* prologue: function */ + 427 /* frame size = 0 */ + 428 0006 EC01 movw r28,r24 + 429 .LSM61: + 430 0008 0A96 adiw r24,10 + 431 .LVL4: + 432 000a FC01 movw r30,r24 + 433 000c 8DE2 ldi r24,lo8(45) + 434 000e DF01 movw r26,r30 + 435 0010 1D92 st X+,__zero_reg__ + 436 0012 8A95 dec r24 + 437 0014 01F4 brne .-6 + 438 0016 11E0 ldi r17,lo8(1) + 439 .LVL5: + 440 .L24: + 441 .LBB163: + 442 .LBB164: + 443 .LSM62: + 444 0018 8981 ldd r24,Y+1 + 445 001a 1817 cp r17,r24 + 446 001c 01F4 brne .L16 + 447 .LSM63: + 448 001e EA81 ldd r30,Y+2 + 449 0020 FB81 ldd r31,Y+3 + 450 .LVL6: + 451 .LSM64: + 452 0022 8C81 ldd r24,Y+4 + 453 .LVL7: + 454 0024 61E0 ldi r22,lo8(1) + 455 .LVL8: + 456 0026 00C0 rjmp .L17 + 457 .LVL9: + 458 .L16: + 459 .LSM65: + 460 0028 8D81 ldd r24,Y+5 + 461 002a 1817 cp r17,r24 + 462 002c 01F4 brne .L18 + 463 .LSM66: + 464 002e EE81 ldd r30,Y+6 + 465 0030 FF81 ldd r31,Y+7 + 466 .LVL10: + 467 .LSM67: + 468 0032 8885 ldd r24,Y+8 + 469 .LVL11: + 470 0034 60E0 ldi r22,lo8(0) + 471 .LVL12: + 472 .L17: + 473 .LSM68: + 474 0036 8823 tst r24 + 475 0038 01F4 brne .L19 + 476 003a 40E0 ldi r20,lo8(0) + 477 003c 00C0 rjmp .L20 + 478 .L19: + 479 003e 44E0 ldi r20,lo8(4) + 480 .L20: + 481 0040 20E0 ldi r18,lo8(0) + 482 .LVL13: + 483 0042 88E0 ldi r24,lo8(8) + 484 0044 90E0 ldi r25,hi8(8) + 485 .LVL14: + 486 0046 00C0 rjmp .L21 + 487 .L22: + 488 .LBB165: + 489 .LBB166: + 490 .LBB167: + 491 .LBB168: + 492 .LSM69: + 493 0048 2F5F subi r18,lo8(-(1)) + 494 .LSM70: + 495 004a 880F lsl r24 + 496 004c 991F rol r25 + 497 .L21: + 498 .LSM71: + 499 004e 8E17 cp r24,r30 + 500 0050 9F07 cpc r25,r31 + 501 0052 00F0 brlo .L22 + 502 .LBE168: + 503 .LBE167: + 504 .LBE166: + 505 .LSM72: + 506 0054 6068 ori r22,lo8(-128) + 507 0056 4260 ori r20,lo8(2) + 508 0058 2295 swap r18 + 509 005a 207F andi r18,lo8(-16) + 510 005c 422B or r20,r18 + 511 005e 812F mov r24,r17 + 512 .LVL15: + 513 0060 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 514 .LVL16: + 515 .LBE165: + 516 .LSM73: + 517 0064 8823 tst r24 + 518 0066 01F0 breq .L23 + 519 .L18: + 520 .LBE164: + 521 .LSM74: + 522 0068 1F5F subi r17,lo8(-(1)) + 523 006a 1530 cpi r17,lo8(5) + 524 006c 01F4 brne .L24 + 525 006e 81E0 ldi r24,lo8(1) + 526 .L23: + 527 /* epilogue start */ + 528 .LBE163: + 529 .LSM75: + 530 0070 DF91 pop r29 + 531 0072 CF91 pop r28 + 532 .LVL17: + 533 0074 1F91 pop r17 + 534 .LVL18: + 535 0076 0895 ret + 536 .LFE82: + 538 .section .text.MS_Device_ProcessControlRequest,"ax",@progbits + 539 .global MS_Device_ProcessControlRequest + 541 MS_Device_ProcessControlRequest: + 542 .LFB81: + 543 .LSM76: + 544 .LVL19: + 545 0000 CF93 push r28 + 546 0002 DF93 push r29 + 547 /* prologue: function */ + 548 /* frame size = 0 */ + 549 0004 EC01 movw r28,r24 + 550 .LBB169: + 551 .LBB170: + 552 .LSM77: + 553 0006 8091 E800 lds r24,232 + 554 .LVL20: + 555 .LBE170: + 556 .LBE169: + 557 .LSM78: + 558 000a 83FF sbrs r24,3 + 559 000c 00C0 rjmp .L31 + 560 .LSM79: + 561 000e 8881 ld r24,Y + 562 0010 90E0 ldi r25,lo8(0) + 563 0012 2091 0000 lds r18,USB_ControlRequest+4 + 564 0016 3091 0000 lds r19,(USB_ControlRequest+4)+1 + 565 001a 2817 cp r18,r24 + 566 001c 3907 cpc r19,r25 + 567 001e 01F4 brne .L31 + 568 .LSM80: + 569 0020 8091 0000 lds r24,USB_ControlRequest+1 + 570 0024 8E3F cpi r24,lo8(-2) + 571 0026 01F0 breq .L29 + 572 0028 8F3F cpi r24,lo8(-1) + 573 002a 01F4 brne .L31 + 574 .LSM81: + 575 002c 8091 0000 lds r24,USB_ControlRequest + 576 0030 8132 cpi r24,lo8(33) + 577 0032 01F4 brne .L31 + 578 .LBB171: + 579 .LBB172: + 580 .LSM82: + 581 0034 8091 E800 lds r24,232 + 582 0038 877F andi r24,lo8(-9) + 583 003a 8093 E800 sts 232,r24 + 584 .LBE172: + 585 .LBE171: + 586 .LSM83: + 587 003e 0E94 0000 call Endpoint_ClearStatusStage + 588 .LSM84: + 589 0042 81E0 ldi r24,lo8(1) + 590 0044 8EAB std Y+54,r24 + 591 0046 00C0 rjmp .L31 + 592 .L29: + 593 .LSM85: + 594 0048 8091 0000 lds r24,USB_ControlRequest + 595 004c 813A cpi r24,lo8(-95) + 596 004e 01F4 brne .L31 + 597 .LBB173: + 598 .LBB174: + 599 .LSM86: + 600 0050 8091 E800 lds r24,232 + 601 0054 877F andi r24,lo8(-9) + 602 0056 8093 E800 sts 232,r24 + 603 .LBE174: + 604 .LBE173: + 605 .LSM87: + 606 005a 8985 ldd r24,Y+9 + 607 005c 8150 subi r24,lo8(-(-1)) + 608 .LBB175: + 609 .LBB176: + 610 .LSM88: + 611 005e 8093 F100 sts 241,r24 + 612 .LBE176: + 613 .LBE175: + 614 .LBB177: + 615 .LBB178: + 616 .LSM89: + 617 0062 8091 E800 lds r24,232 + 618 0066 8E77 andi r24,lo8(126) + 619 0068 8093 E800 sts 232,r24 + 620 .LBE178: + 621 .LBE177: + 622 .LSM90: + 623 006c 0E94 0000 call Endpoint_ClearStatusStage + 624 .L31: + 625 /* epilogue start */ + 626 .LSM91: + 627 0070 DF91 pop r29 + 628 0072 CF91 pop r28 + 629 .LVL21: + 630 0074 0895 ret + 631 .LFE81: + 633 .lcomm CallbackIsResetSource,2 + 682 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 MassStorage.c + /tmp/ccHFx5pp.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccHFx5pp.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccHFx5pp.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccHFx5pp.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccHFx5pp.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccHFx5pp.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccHFx5pp.s:18 .text.StreamCallback_MS_Device_AbortOnMassStoreReset:0000000000000000 StreamCallback_MS_Device_AbortOnMassStoreReset + .bss:0000000000000000 CallbackIsResetSource + /tmp/ccHFx5pp.s:37 .text.MS_Device_USBTask:0000000000000000 MS_Device_USBTask + /tmp/ccHFx5pp.s:419 .text.MS_Device_ConfigureEndpoints:0000000000000000 MS_Device_ConfigureEndpoints + /tmp/ccHFx5pp.s:541 .text.MS_Device_ProcessControlRequest:0000000000000000 MS_Device_ProcessControlRequest + +UNDEFINED SYMBOLS +USB_USBTask +USB_DeviceState +Endpoint_Read_Stream_LE +CALLBACK_MS_Device_SCSICommandReceived +Endpoint_Write_Stream_LE +Endpoint_ConfigureEndpoint_Prv +USB_ControlRequest +Endpoint_ClearStatusStage +__do_clear_bss diff --git a/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.o b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.o new file mode 100644 index 0000000..2dbf5cd Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Device/MassStorage.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.c b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.c new file mode 100644 index 0000000..c6de9e5 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.c @@ -0,0 +1,496 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_RNDIS_DRIVER +#define __INCLUDE_FROM_RNDIS_DEVICE_C +#include "RNDIS.h" + +static const uint32_t PROGMEM AdapterSupportedOIDList[] = + { + OID_GEN_SUPPORTED_LIST, + OID_GEN_PHYSICAL_MEDIUM, + OID_GEN_HARDWARE_STATUS, + OID_GEN_MEDIA_SUPPORTED, + OID_GEN_MEDIA_IN_USE, + OID_GEN_MAXIMUM_FRAME_SIZE, + OID_GEN_MAXIMUM_TOTAL_SIZE, + OID_GEN_LINK_SPEED, + OID_GEN_TRANSMIT_BLOCK_SIZE, + OID_GEN_RECEIVE_BLOCK_SIZE, + OID_GEN_VENDOR_ID, + OID_GEN_VENDOR_DESCRIPTION, + OID_GEN_CURRENT_PACKET_FILTER, + OID_GEN_MAXIMUM_TOTAL_SIZE, + OID_GEN_MEDIA_CONNECT_STATUS, + OID_GEN_XMIT_OK, + OID_GEN_RCV_OK, + OID_GEN_XMIT_ERROR, + OID_GEN_RCV_ERROR, + OID_GEN_RCV_NO_BUFFER, + OID_802_3_PERMANENT_ADDRESS, + OID_802_3_CURRENT_ADDRESS, + OID_802_3_MULTICAST_LIST, + OID_802_3_MAXIMUM_LIST_SIZE, + OID_802_3_RCV_ERROR_ALIGNMENT, + OID_802_3_XMIT_ONE_COLLISION, + OID_802_3_XMIT_MORE_COLLISIONS, + }; + +void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if (USB_ControlRequest.wIndex != RNDISInterfaceInfo->Config.ControlInterfaceNumber) + return; + + switch (USB_ControlRequest.bRequest) + { + case RNDIS_REQ_SendEncapsulatedCommand: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_Read_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, USB_ControlRequest.wLength); + Endpoint_ClearIN(); + + RNDIS_Device_ProcessRNDISControlMessage(RNDISInterfaceInfo); + } + + break; + case RNDIS_REQ_GetEncapsulatedResponse: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + + if (!(MessageHeader->MessageLength)) + { + RNDISInterfaceInfo->State.RNDISMessageBuffer[0] = 0; + MessageHeader->MessageLength = 1; + } + + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, MessageHeader->MessageLength); + Endpoint_ClearOUT(); + + MessageHeader->MessageLength = 0; + } + + break; + } +} + +bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State)); + + for (uint8_t EndpointNum = 1; EndpointNum < ENDPOINT_TOTAL_ENDPOINTS; EndpointNum++) + { + uint16_t Size; + uint8_t Type; + uint8_t Direction; + bool DoubleBanked; + + if (EndpointNum == RNDISInterfaceInfo->Config.DataINEndpointNumber) + { + Size = RNDISInterfaceInfo->Config.DataINEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_BULK; + DoubleBanked = RNDISInterfaceInfo->Config.DataINEndpointDoubleBank; + } + else if (EndpointNum == RNDISInterfaceInfo->Config.DataOUTEndpointNumber) + { + Size = RNDISInterfaceInfo->Config.DataOUTEndpointSize; + Direction = ENDPOINT_DIR_OUT; + Type = EP_TYPE_BULK; + DoubleBanked = RNDISInterfaceInfo->Config.DataOUTEndpointDoubleBank; + } + else if (EndpointNum == RNDISInterfaceInfo->Config.NotificationEndpointNumber) + { + Size = RNDISInterfaceInfo->Config.NotificationEndpointSize; + Direction = ENDPOINT_DIR_IN; + Type = EP_TYPE_INTERRUPT; + DoubleBanked = RNDISInterfaceInfo->Config.NotificationEndpointDoubleBank; + } + else + { + continue; + } + + if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, + DoubleBanked ? ENDPOINT_BANK_DOUBLE : ENDPOINT_BANK_SINGLE))) + { + return false; + } + } + + return true; +} + +void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpointNumber); + + if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.ResponseReady) + { + USB_Request_Header_t Notification = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = RNDIS_NOTIF_ResponseAvailable, + .wValue = 0, + .wIndex = 0, + .wLength = 0, + }; + + Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NO_STREAM_CALLBACK); + + Endpoint_ClearIN(); + + RNDISInterfaceInfo->State.ResponseReady = false; + } + + if ((RNDISInterfaceInfo->State.CurrRNDISState == RNDIS_Data_Initialized) && !(MessageHeader->MessageLength)) + { + RNDIS_Packet_Message_t RNDISPacketHeader; + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpointNumber); + + if (Endpoint_IsOUTReceived() && !(RNDISInterfaceInfo->State.FrameIN.FrameInBuffer)) + { + Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NO_STREAM_CALLBACK); + + if (RNDISPacketHeader.DataLength > ETHERNET_FRAME_SIZE_MAX) + { + Endpoint_StallTransaction(); + return; + } + + Endpoint_Read_Stream_LE(RNDISInterfaceInfo->State.FrameIN.FrameData, RNDISPacketHeader.DataLength, NO_STREAM_CALLBACK); + + Endpoint_ClearOUT(); + + RNDISInterfaceInfo->State.FrameIN.FrameLength = RNDISPacketHeader.DataLength; + + RNDISInterfaceInfo->State.FrameIN.FrameInBuffer = true; + } + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpointNumber); + + if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer) + { + memset(&RNDISPacketHeader, 0, sizeof(RNDIS_Packet_Message_t)); + + RNDISPacketHeader.MessageType = REMOTE_NDIS_PACKET_MSG; + RNDISPacketHeader.MessageLength = (sizeof(RNDIS_Packet_Message_t) + RNDISInterfaceInfo->State.FrameOUT.FrameLength); + RNDISPacketHeader.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)); + RNDISPacketHeader.DataLength = RNDISInterfaceInfo->State.FrameOUT.FrameLength; + + Endpoint_Write_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_LE(RNDISInterfaceInfo->State.FrameOUT.FrameData, RNDISPacketHeader.DataLength, NO_STREAM_CALLBACK); + Endpoint_ClearIN(); + + RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer = false; + } + } +} + +void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + /* Note: Only a single buffer is used for both the received message and its response to save SRAM. Because of + this, response bytes should be filled in order so that they do not clobber unread data in the buffer. */ + + RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + + switch (MessageHeader->MessageType) + { + case REMOTE_NDIS_INITIALIZE_MSG: + RNDISInterfaceInfo->State.ResponseReady = true; + + RNDIS_Initialize_Message_t* INITIALIZE_Message = + (RNDIS_Initialize_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Initialize_Complete_t* INITIALIZE_Response = + (RNDIS_Initialize_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + + INITIALIZE_Response->MessageType = REMOTE_NDIS_INITIALIZE_CMPLT; + INITIALIZE_Response->MessageLength = sizeof(RNDIS_Initialize_Complete_t); + INITIALIZE_Response->RequestId = INITIALIZE_Message->RequestId; + INITIALIZE_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; + + INITIALIZE_Response->MajorVersion = REMOTE_NDIS_VERSION_MAJOR; + INITIALIZE_Response->MinorVersion = REMOTE_NDIS_VERSION_MINOR; + INITIALIZE_Response->DeviceFlags = REMOTE_NDIS_DF_CONNECTIONLESS; + INITIALIZE_Response->Medium = REMOTE_NDIS_MEDIUM_802_3; + INITIALIZE_Response->MaxPacketsPerTransfer = 1; + INITIALIZE_Response->MaxTransferSize = (sizeof(RNDIS_Packet_Message_t) + ETHERNET_FRAME_SIZE_MAX); + INITIALIZE_Response->PacketAlignmentFactor = 0; + INITIALIZE_Response->AFListOffset = 0; + INITIALIZE_Response->AFListSize = 0; + + RNDISInterfaceInfo->State.CurrRNDISState = RNDIS_Initialized; + + break; + case REMOTE_NDIS_HALT_MSG: + RNDISInterfaceInfo->State.ResponseReady = false; + MessageHeader->MessageLength = 0; + + RNDISInterfaceInfo->State.CurrRNDISState = RNDIS_Uninitialized; + + break; + case REMOTE_NDIS_QUERY_MSG: + RNDISInterfaceInfo->State.ResponseReady = true; + + RNDIS_Query_Message_t* QUERY_Message = (RNDIS_Query_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Query_Complete_t* QUERY_Response = (RNDIS_Query_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + uint32_t Query_Oid = QUERY_Message->Oid; + + void* QueryData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + + QUERY_Message->InformationBufferOffset]; + void* ResponseData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)]; + uint16_t ResponseSize; + + QUERY_Response->MessageType = REMOTE_NDIS_QUERY_CMPLT; + QUERY_Response->MessageLength = sizeof(RNDIS_Query_Complete_t); + + if (RNDIS_Device_ProcessNDISQuery(RNDISInterfaceInfo, Query_Oid, QueryData, QUERY_Message->InformationBufferLength, + ResponseData, &ResponseSize)) + { + QUERY_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; + QUERY_Response->MessageLength += ResponseSize; + + QUERY_Response->InformationBufferLength = ResponseSize; + QUERY_Response->InformationBufferOffset = (sizeof(RNDIS_Query_Complete_t) - sizeof(RNDIS_Message_Header_t)); + } + else + { + QUERY_Response->Status = REMOTE_NDIS_STATUS_NOT_SUPPORTED; + + QUERY_Response->InformationBufferLength = 0; + QUERY_Response->InformationBufferOffset = 0; + } + + break; + case REMOTE_NDIS_SET_MSG: + RNDISInterfaceInfo->State.ResponseReady = true; + + RNDIS_Set_Message_t* SET_Message = (RNDIS_Set_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_Set_Complete_t* SET_Response = (RNDIS_Set_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + uint32_t SET_Oid = SET_Message->Oid; + + SET_Response->MessageType = REMOTE_NDIS_SET_CMPLT; + SET_Response->MessageLength = sizeof(RNDIS_Set_Complete_t); + SET_Response->RequestId = SET_Message->RequestId; + + void* SetData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + + SET_Message->InformationBufferOffset]; + + SET_Response->Status = RNDIS_Device_ProcessNDISSet(RNDISInterfaceInfo, SET_Oid, SetData, + SET_Message->InformationBufferLength) ? + REMOTE_NDIS_STATUS_SUCCESS : REMOTE_NDIS_STATUS_NOT_SUPPORTED; + break; + case REMOTE_NDIS_RESET_MSG: + RNDISInterfaceInfo->State.ResponseReady = true; + + RNDIS_Reset_Complete_t* RESET_Response = (RNDIS_Reset_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + + RESET_Response->MessageType = REMOTE_NDIS_RESET_CMPLT; + RESET_Response->MessageLength = sizeof(RNDIS_Reset_Complete_t); + RESET_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; + RESET_Response->AddressingReset = 0; + + break; + case REMOTE_NDIS_KEEPALIVE_MSG: + RNDISInterfaceInfo->State.ResponseReady = true; + + RNDIS_KeepAlive_Message_t* KEEPALIVE_Message = + (RNDIS_KeepAlive_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + RNDIS_KeepAlive_Complete_t* KEEPALIVE_Response = + (RNDIS_KeepAlive_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer; + + KEEPALIVE_Response->MessageType = REMOTE_NDIS_KEEPALIVE_CMPLT; + KEEPALIVE_Response->MessageLength = sizeof(RNDIS_KeepAlive_Complete_t); + KEEPALIVE_Response->RequestId = KEEPALIVE_Message->RequestId; + KEEPALIVE_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; + + break; + } +} + +static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + const uint32_t OId, + void* const QueryData, + const uint16_t QuerySize, + void* ResponseData, + uint16_t* const ResponseSize) +{ + (void)QueryData; + (void)QuerySize; + + switch (OId) + { + case OID_GEN_SUPPORTED_LIST: + *ResponseSize = sizeof(AdapterSupportedOIDList); + + memcpy_P(ResponseData, AdapterSupportedOIDList, sizeof(AdapterSupportedOIDList)); + + return true; + case OID_GEN_PHYSICAL_MEDIUM: + *ResponseSize = sizeof(uint32_t); + + /* Indicate that the device is a true ethernet link */ + *((uint32_t*)ResponseData) = 0; + + return true; + case OID_GEN_HARDWARE_STATUS: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = NDIS_HardwareStatus_Ready; + + return true; + case OID_GEN_MEDIA_SUPPORTED: + case OID_GEN_MEDIA_IN_USE: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = REMOTE_NDIS_MEDIUM_802_3; + + return true; + case OID_GEN_VENDOR_ID: + *ResponseSize = sizeof(uint32_t); + + /* Vendor ID 0x0xFFFFFF is reserved for vendors who have not purchased a NDIS VID */ + *((uint32_t*)ResponseData) = 0x00FFFFFF; + + return true; + case OID_GEN_MAXIMUM_FRAME_SIZE: + case OID_GEN_TRANSMIT_BLOCK_SIZE: + case OID_GEN_RECEIVE_BLOCK_SIZE: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = ETHERNET_FRAME_SIZE_MAX; + + return true; + case OID_GEN_VENDOR_DESCRIPTION: + *ResponseSize = (strlen(RNDISInterfaceInfo->Config.AdapterVendorDescription) + 1); + + memcpy(ResponseData, RNDISInterfaceInfo->Config.AdapterVendorDescription, *ResponseSize); + + return true; + case OID_GEN_MEDIA_CONNECT_STATUS: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = REMOTE_NDIS_MEDIA_STATE_CONNECTED; + + return true; + case OID_GEN_LINK_SPEED: + *ResponseSize = sizeof(uint32_t); + + /* Indicate 10Mb/s link speed */ + *((uint32_t*)ResponseData) = 100000; + + return true; + case OID_802_3_PERMANENT_ADDRESS: + case OID_802_3_CURRENT_ADDRESS: + *ResponseSize = sizeof(MAC_Address_t); + + memcpy(ResponseData, &RNDISInterfaceInfo->Config.AdapterMACAddress, sizeof(MAC_Address_t)); + + return true; + case OID_802_3_MAXIMUM_LIST_SIZE: + *ResponseSize = sizeof(uint32_t); + + /* Indicate only one multicast address supported */ + *((uint32_t*)ResponseData) = 1; + + return true; + case OID_GEN_CURRENT_PACKET_FILTER: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = RNDISInterfaceInfo->State.CurrPacketFilter; + + return true; + case OID_GEN_XMIT_OK: + case OID_GEN_RCV_OK: + case OID_GEN_XMIT_ERROR: + case OID_GEN_RCV_ERROR: + case OID_GEN_RCV_NO_BUFFER: + case OID_802_3_RCV_ERROR_ALIGNMENT: + case OID_802_3_XMIT_ONE_COLLISION: + case OID_802_3_XMIT_MORE_COLLISIONS: + *ResponseSize = sizeof(uint32_t); + + /* Unused statistic OIDs - always return 0 for each */ + *((uint32_t*)ResponseData) = 0; + + return true; + case OID_GEN_MAXIMUM_TOTAL_SIZE: + *ResponseSize = sizeof(uint32_t); + + /* Indicate maximum overall buffer (Ethernet frame and RNDIS header) the adapter can handle */ + *((uint32_t*)ResponseData) = (RNDIS_MESSAGE_BUFFER_SIZE + ETHERNET_FRAME_SIZE_MAX); + + return true; + default: + return false; + } +} + +static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + const uint32_t OId, + const void* SetData, + const uint16_t SetSize) +{ + (void)SetSize; + + switch (OId) + { + case OID_GEN_CURRENT_PACKET_FILTER: + RNDISInterfaceInfo->State.CurrPacketFilter = *((uint32_t*)SetData); + RNDISInterfaceInfo->State.CurrRNDISState = ((RNDISInterfaceInfo->State.CurrPacketFilter) ? + RNDIS_Data_Initialized : RNDIS_Data_Initialized); + + return true; + case OID_802_3_MULTICAST_LIST: + /* Do nothing - throw away the value from the host as it is unused */ + + return true; + default: + return false; + } +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.h b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.h new file mode 100644 index 0000000..9f24f29 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.h @@ -0,0 +1,186 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 RNDIS Class driver. + * + * Device mode driver for the library USB RNDIS 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_USBClassRNDIS + * @defgroup Group_USBClassRNDISDevice RNDIS 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/RNDIS.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Device Mode USB Class driver framework interface, for the RNDIS USB Class driver. + * + * @{ + */ + +#ifndef _RNDIS_CLASS_DEVICE_H_ +#define _RNDIS_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/RNDIS.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_RNDIS_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_RNDIS_DEVICE_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief RNDIS Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each RNDIS interface + * within the user application, and passed to each of the RNDIS class driver functions as the + * RNDISInterfaceInfo parameter. This stores each RNDIS interface's configuration and state information. + */ + typedef struct + { + const 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 RNDIS 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 RNDIS 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 RNDIS interface's notification endpoint should use double banking. */ + + char* AdapterVendorDescription; /**< String description of the adapter vendor. */ + MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter. */ + } 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 + { + uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host, + * managed by the class driver. + */ + bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host. */ + uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the \ref RNDIS_States_t enum. */ + uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver. */ + Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user + * processing. + */ + Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the + * user application. + */ + } 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_RNDIS_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given RNDIS 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 HID interface is selected. + * + * \note The endpoint index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or endpoint bank corruption will occur. Gaps in the allocated endpoint numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved endpoint indexes. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + * + * \return Boolean true if the endpoints were successfully configured, false otherwise. + */ + bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Processes incoming control requests from the host, that are directed to the given RNDIS class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + */ + void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** General management task for a given HID 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] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + */ + void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_RNDIS_DEVICE_C) + static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1); + static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + const uint32_t OId, + void* const QueryData, + const uint16_t QuerySize, + void* ResponseData, + uint16_t* const ResponseSize) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(5) ATTR_NON_NULL_PTR_ARG(6); + static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + const uint32_t OId, + const void* SetData, + const uint16_t SetSize) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(3); + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.lst b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.lst new file mode 100644 index 0000000..3ae93a2 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.lst @@ -0,0 +1,1519 @@ + 1 .file "RNDIS.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.RNDIS_Device_USBTask,"ax",@progbits + 17 .global RNDIS_Device_USBTask + 19 RNDIS_Device_USBTask: + 20 .LFB83: + 21 .LSM0: + 22 .LVL0: + 23 0000 EF92 push r14 + 24 0002 FF92 push r15 + 25 0004 0F93 push r16 + 26 0006 1F93 push r17 + 27 0008 DF93 push r29 + 28 000a CF93 push r28 + 29 000c CDB7 in r28,__SP_L__ + 30 000e DEB7 in r29,__SP_H__ + 31 0010 AC97 sbiw r28,44 + 32 0012 0FB6 in __tmp_reg__,__SREG__ + 33 0014 F894 cli + 34 0016 DEBF out __SP_H__,r29 + 35 0018 0FBE out __SREG__,__tmp_reg__ + 36 001a CDBF out __SP_L__,r28 + 37 /* prologue: function */ + 38 /* frame size = 44 */ + 39 001c 8C01 movw r16,r24 + 40 .LSM1: + 41 001e 8091 0000 lds r24,USB_DeviceState + 42 .LVL1: + 43 0022 8430 cpi r24,lo8(4) + 44 0024 01F0 breq .+2 + 45 0026 00C0 rjmp .L7 + 46 .LSM2: + 47 0028 D801 movw r26,r16 + 48 002a 1996 adiw r26,9 + 49 002c 8C91 ld r24,X + 50 .LBB43: + 51 .LBB44: + 52 .LSM3: + 53 002e 8093 E900 sts 233,r24 + 54 .LBE44: + 55 .LBE43: + 56 .LBB45: + 57 .LBB46: + 58 .LSM4: + 59 0032 8091 E800 lds r24,232 + 60 .LBE46: + 61 .LBE45: + 62 .LSM5: + 63 0036 80FF sbrs r24,0 + 64 0038 00C0 rjmp .L3 + 65 003a 0B56 subi r16,lo8(-(149)) + 66 003c 1F4F sbci r17,hi8(-(149)) + 67 003e F801 movw r30,r16 + 68 0040 8081 ld r24,Z + 69 0042 0559 subi r16,lo8(-(-149)) + 70 0044 1040 sbci r17,hi8(-(-149)) + 71 0046 8823 tst r24 + 72 0048 01F0 breq .L3 + 73 .LBB47: + 74 .LSM6: + 75 004a DE01 movw r26,r28 + 76 004c 1196 adiw r26,1 + 77 004e E0E0 ldi r30,lo8(C.9.3485) + 78 0050 F0E0 ldi r31,hi8(C.9.3485) + 79 0052 88E0 ldi r24,lo8(8) + 80 .L4: + 81 0054 0190 ld r0,Z+ + 82 0056 0D92 st X+,r0 + 83 0058 8150 subi r24,lo8(-(-1)) + 84 005a 01F4 brne .L4 + 85 .LSM7: + 86 005c CE01 movw r24,r28 + 87 005e 0196 adiw r24,1 + 88 0060 68E0 ldi r22,lo8(8) + 89 0062 70E0 ldi r23,hi8(8) + 90 0064 40E0 ldi r20,lo8(0) + 91 0066 50E0 ldi r21,hi8(0) + 92 0068 0E94 0000 call Endpoint_Write_Stream_LE + 93 .LBB48: + 94 .LBB49: + 95 .LSM8: + 96 006c 8091 E800 lds r24,232 + 97 0070 8E77 andi r24,lo8(126) + 98 0072 8093 E800 sts 232,r24 + 99 .LBE49: + 100 .LBE48: + 101 .LSM9: + 102 0076 0B56 subi r16,lo8(-(149)) + 103 0078 1F4F sbci r17,hi8(-(149)) + 104 007a D801 movw r26,r16 + 105 007c 1C92 st X,__zero_reg__ + 106 007e 0559 subi r16,lo8(-(-149)) + 107 0080 1040 sbci r17,hi8(-(-149)) + 108 .L3: + 109 .LBE47: + 110 .LSM10: + 111 0082 0A56 subi r16,lo8(-(150)) + 112 0084 1F4F sbci r17,hi8(-(150)) + 113 0086 F801 movw r30,r16 + 114 0088 8081 ld r24,Z + 115 008a 0659 subi r16,lo8(-(-150)) + 116 008c 1040 sbci r17,hi8(-(-150)) + 117 008e 8230 cpi r24,lo8(2) + 118 0090 01F0 breq .+2 + 119 0092 00C0 rjmp .L7 + 120 0094 F801 movw r30,r16 + 121 0096 818D ldd r24,Z+25 + 122 0098 928D ldd r25,Z+26 + 123 009a A38D ldd r26,Z+27 + 124 009c B48D ldd r27,Z+28 + 125 009e 0097 sbiw r24,0 + 126 00a0 A105 cpc r26,__zero_reg__ + 127 00a2 B105 cpc r27,__zero_reg__ + 128 00a4 01F0 breq .+2 + 129 00a6 00C0 rjmp .L7 + 130 .LBB50: + 131 .LSM11: + 132 00a8 8581 ldd r24,Z+5 + 133 .LBB51: + 134 .LBB52: + 135 .LSM12: + 136 00aa 8093 E900 sts 233,r24 + 137 .LBE52: + 138 .LBE51: + 139 .LBB53: + 140 .LBB54: + 141 .LSM13: + 142 00ae 8091 E800 lds r24,232 + 143 .LBE54: + 144 .LBE53: + 145 .LSM14: + 146 00b2 82FF sbrs r24,2 + 147 00b4 00C0 rjmp .L5 + 148 00b6 99E7 ldi r25,lo8(1657) + 149 00b8 E92E mov r14,r25 + 150 00ba 96E0 ldi r25,hi8(1657) + 151 00bc F92E mov r15,r25 + 152 00be E00E add r14,r16 + 153 00c0 F11E adc r15,r17 + 154 00c2 D701 movw r26,r14 + 155 00c4 8C91 ld r24,X + 156 00c6 8823 tst r24 + 157 00c8 01F4 brne .L5 + 158 .LSM15: + 159 00ca CE01 movw r24,r28 + 160 00cc 0196 adiw r24,1 + 161 00ce 6CE2 ldi r22,lo8(44) + 162 00d0 70E0 ldi r23,hi8(44) + 163 00d2 40E0 ldi r20,lo8(0) + 164 00d4 50E0 ldi r21,hi8(0) + 165 00d6 0E94 0000 call Endpoint_Read_Stream_LE + 166 .LSM16: + 167 00da 2D85 ldd r18,Y+13 + 168 00dc 3E85 ldd r19,Y+14 + 169 00de 4F85 ldd r20,Y+15 + 170 00e0 5889 ldd r21,Y+16 + 171 00e2 2D3D cpi r18,lo8(1501) + 172 00e4 B5E0 ldi r27,hi8(1501) + 173 00e6 3B07 cpc r19,r27 + 174 00e8 B0E0 ldi r27,hlo8(1501) + 175 00ea 4B07 cpc r20,r27 + 176 00ec B0E0 ldi r27,hhi8(1501) + 177 00ee 5B07 cpc r21,r27 + 178 00f0 00F0 brlo .L6 + 179 .LBB55: + 180 .LBB56: + 181 .LSM17: + 182 00f2 8091 EB00 lds r24,235 + 183 00f6 8062 ori r24,lo8(32) + 184 00f8 8093 EB00 sts 235,r24 + 185 00fc 00C0 rjmp .L7 + 186 .L6: + 187 .LBE56: + 188 .LBE55: + 189 .LSM18: + 190 00fe C801 movw r24,r16 + 191 0100 8556 subi r24,lo8(-(155)) + 192 0102 9F4F sbci r25,hi8(-(155)) + 193 0104 B901 movw r22,r18 + 194 0106 40E0 ldi r20,lo8(0) + 195 0108 50E0 ldi r21,hi8(0) + 196 010a 0E94 0000 call Endpoint_Read_Stream_LE + 197 .LBB57: + 198 .LBB58: + 199 .LSM19: + 200 010e 8091 E800 lds r24,232 + 201 0112 8B77 andi r24,lo8(123) + 202 0114 8093 E800 sts 232,r24 + 203 .LBE58: + 204 .LBE57: + 205 .LSM20: + 206 0118 0958 subi r16,lo8(-(1655)) + 207 011a 194F sbci r17,hi8(-(1655)) + 208 011c 8D85 ldd r24,Y+13 + 209 011e 9E85 ldd r25,Y+14 + 210 0120 F801 movw r30,r16 + 211 0122 9183 std Z+1,r25 + 212 0124 8083 st Z,r24 + 213 0126 0757 subi r16,lo8(-(-1655)) + 214 0128 1640 sbci r17,hi8(-(-1655)) + 215 .LSM21: + 216 012a 81E0 ldi r24,lo8(1) + 217 012c D701 movw r26,r14 + 218 012e 8C93 st X,r24 + 219 .L5: + 220 .LSM22: + 221 0130 F801 movw r30,r16 + 222 0132 8181 ldd r24,Z+1 + 223 .LBB59: + 224 .LBB60: + 225 .LSM23: + 226 0134 8093 E900 sts 233,r24 + 227 .LBE60: + 228 .LBE59: + 229 .LBB61: + 230 .LBB62: + 231 .LSM24: + 232 0138 8091 E800 lds r24,232 + 233 .LBE62: + 234 .LBE61: + 235 .LSM25: + 236 013c 80FF sbrs r24,0 + 237 013e 00C0 rjmp .L7 + 238 0140 88E5 ldi r24,lo8(3160) + 239 0142 E82E mov r14,r24 + 240 0144 8CE0 ldi r24,hi8(3160) + 241 0146 F82E mov r15,r24 + 242 0148 E00E add r14,r16 + 243 014a F11E adc r15,r17 + 244 014c D701 movw r26,r14 + 245 014e 8C91 ld r24,X + 246 0150 8823 tst r24 + 247 0152 01F4 brne .+2 + 248 0154 00C0 rjmp .L7 + 249 .LSM26: + 250 0156 FE01 movw r30,r28 + 251 0158 3196 adiw r30,1 + 252 015a 8CE2 ldi r24,lo8(44) + 253 015c DF01 movw r26,r30 + 254 015e 1D92 st X+,__zero_reg__ + 255 0160 8A95 dec r24 + 256 0162 01F4 brne .-6 + 257 .LSM27: + 258 0164 81E0 ldi r24,lo8(1) + 259 0166 90E0 ldi r25,hi8(1) + 260 0168 A0E0 ldi r26,hlo8(1) + 261 016a B0E0 ldi r27,hhi8(1) + 262 016c 8983 std Y+1,r24 + 263 016e 9A83 std Y+2,r25 + 264 0170 AB83 std Y+3,r26 + 265 0172 BC83 std Y+4,r27 + 266 .LSM28: + 267 0174 0A5A subi r16,lo8(-(3158)) + 268 0176 134F sbci r17,hi8(-(3158)) + 269 0178 D801 movw r26,r16 + 270 017a 8D91 ld r24,X+ + 271 017c 9C91 ld r25,X + 272 017e 8C96 adiw r24,44 + 273 0180 9C01 movw r18,r24 + 274 0182 40E0 ldi r20,lo8(0) + 275 0184 50E0 ldi r21,hi8(0) + 276 0186 8C97 sbiw r24,44 + 277 0188 2D83 std Y+5,r18 + 278 018a 3E83 std Y+6,r19 + 279 018c 4F83 std Y+7,r20 + 280 018e 5887 std Y+8,r21 + 281 .LSM29: + 282 0190 24E2 ldi r18,lo8(36) + 283 0192 30E0 ldi r19,hi8(36) + 284 0194 40E0 ldi r20,hlo8(36) + 285 0196 50E0 ldi r21,hhi8(36) + 286 0198 2987 std Y+9,r18 + 287 019a 3A87 std Y+10,r19 + 288 019c 4B87 std Y+11,r20 + 289 019e 5C87 std Y+12,r21 + 290 .LSM30: + 291 01a0 A0E0 ldi r26,lo8(0) + 292 01a2 B0E0 ldi r27,hi8(0) + 293 01a4 8D87 std Y+13,r24 + 294 01a6 9E87 std Y+14,r25 + 295 01a8 AF87 std Y+15,r26 + 296 01aa B88B std Y+16,r27 + 297 .LSM31: + 298 01ac CF01 movw r24,r30 + 299 01ae 6CE2 ldi r22,lo8(44) + 300 01b0 70E0 ldi r23,hi8(44) + 301 01b2 40E0 ldi r20,lo8(0) + 302 01b4 50E0 ldi r21,hi8(0) + 303 01b6 0E94 0000 call Endpoint_Write_Stream_LE + 304 .LSM32: + 305 01ba 6D85 ldd r22,Y+13 + 306 01bc 7E85 ldd r23,Y+14 + 307 01be C801 movw r24,r16 + 308 01c0 8C5D subi r24,lo8(-(-1500)) + 309 01c2 9540 sbci r25,hi8(-(-1500)) + 310 01c4 40E0 ldi r20,lo8(0) + 311 01c6 50E0 ldi r21,hi8(0) + 312 01c8 0E94 0000 call Endpoint_Write_Stream_LE + 313 .LBB63: + 314 .LBB64: + 315 .LSM33: + 316 01cc 8091 E800 lds r24,232 + 317 01d0 8E77 andi r24,lo8(126) + 318 01d2 8093 E800 sts 232,r24 + 319 .LBE64: + 320 .LBE63: + 321 .LSM34: + 322 01d6 F701 movw r30,r14 + 323 01d8 1082 st Z,__zero_reg__ + 324 .L7: + 325 /* epilogue start */ + 326 .LBE50: + 327 .LSM35: + 328 01da AC96 adiw r28,44 + 329 01dc 0FB6 in __tmp_reg__,__SREG__ + 330 01de F894 cli + 331 01e0 DEBF out __SP_H__,r29 + 332 01e2 0FBE out __SREG__,__tmp_reg__ + 333 01e4 CDBF out __SP_L__,r28 + 334 01e6 CF91 pop r28 + 335 01e8 DF91 pop r29 + 336 01ea 1F91 pop r17 + 337 01ec 0F91 pop r16 + 338 .LVL2: + 339 01ee FF90 pop r15 + 340 01f0 EF90 pop r14 + 341 01f2 0895 ret + 342 .LFE83: + 344 .section .text.RNDIS_Device_ConfigureEndpoints,"ax",@progbits + 345 .global RNDIS_Device_ConfigureEndpoints + 347 RNDIS_Device_ConfigureEndpoints: + 348 .LFB82: + 349 .LSM36: + 350 .LVL3: + 351 0000 1F93 push r17 + 352 0002 CF93 push r28 + 353 0004 DF93 push r29 + 354 /* prologue: function */ + 355 /* frame size = 0 */ + 356 0006 EC01 movw r28,r24 + 357 .LSM37: + 358 0008 4596 adiw r24,21 + 359 .LVL4: + 360 000a FC01 movw r30,r24 + 361 000c 84E4 ldi r24,lo8(3140) + 362 000e 9CE0 ldi r25,hi8(3140) + 363 0010 DF01 movw r26,r30 + 364 0012 9C01 movw r18,r24 + 365 0014 1D92 st X+,__zero_reg__ + 366 0016 2150 subi r18,1 + 367 0018 3040 sbci r19,0 + 368 001a 01F4 brne .-8 + 369 001c 11E0 ldi r17,lo8(1) + 370 .LVL5: + 371 .L19: + 372 .LBB65: + 373 .LBB66: + 374 .LSM38: + 375 001e 8981 ldd r24,Y+1 + 376 0020 1817 cp r17,r24 + 377 0022 01F4 brne .L10 + 378 .LSM39: + 379 0024 EA81 ldd r30,Y+2 + 380 0026 FB81 ldd r31,Y+3 + 381 .LVL6: + 382 .LSM40: + 383 0028 8C81 ldd r24,Y+4 + 384 .LVL7: + 385 002a 62E0 ldi r22,lo8(2) + 386 .LVL8: + 387 002c 00C0 rjmp .L22 + 388 .LVL9: + 389 .L10: + 390 .LSM41: + 391 002e 8D81 ldd r24,Y+5 + 392 0030 1817 cp r17,r24 + 393 0032 01F4 brne .L12 + 394 .LSM42: + 395 0034 EE81 ldd r30,Y+6 + 396 0036 FF81 ldd r31,Y+7 + 397 .LVL10: + 398 .LSM43: + 399 0038 8885 ldd r24,Y+8 + 400 .LVL11: + 401 003a 62E0 ldi r22,lo8(2) + 402 .LVL12: + 403 003c 30E0 ldi r19,lo8(0) + 404 .LVL13: + 405 003e 00C0 rjmp .L11 + 406 .LVL14: + 407 .L12: + 408 .LSM44: + 409 0040 8985 ldd r24,Y+9 + 410 0042 1817 cp r17,r24 + 411 0044 01F4 brne .L13 + 412 .LSM45: + 413 0046 EA85 ldd r30,Y+10 + 414 0048 FB85 ldd r31,Y+11 + 415 .LVL15: + 416 .LSM46: + 417 004a 8C85 ldd r24,Y+12 + 418 .LVL16: + 419 004c 63E0 ldi r22,lo8(3) + 420 .LVL17: + 421 .L22: + 422 004e 31E0 ldi r19,lo8(1) + 423 .LVL18: + 424 .L11: + 425 .LSM47: + 426 0050 8823 tst r24 + 427 0052 01F4 brne .L14 + 428 0054 40E0 ldi r20,lo8(0) + 429 0056 00C0 rjmp .L15 + 430 .L14: + 431 0058 44E0 ldi r20,lo8(4) + 432 .L15: + 433 005a 20E0 ldi r18,lo8(0) + 434 .LVL19: + 435 005c 88E0 ldi r24,lo8(8) + 436 005e 90E0 ldi r25,hi8(8) + 437 .LVL20: + 438 0060 00C0 rjmp .L16 + 439 .L17: + 440 .LBB67: + 441 .LBB68: + 442 .LBB69: + 443 .LBB70: + 444 .LSM48: + 445 0062 2F5F subi r18,lo8(-(1)) + 446 .LSM49: + 447 0064 880F lsl r24 + 448 0066 991F rol r25 + 449 .L16: + 450 .LSM50: + 451 0068 8E17 cp r24,r30 + 452 006a 9F07 cpc r25,r31 + 453 006c 00F0 brlo .L17 + 454 .LBE70: + 455 .LBE69: + 456 .LBE68: + 457 .LSM51: + 458 006e 6295 swap r22 + 459 0070 660F lsl r22 + 460 0072 660F lsl r22 + 461 0074 607C andi r22,lo8(-64) + 462 0076 632B or r22,r19 + 463 0078 4260 ori r20,lo8(2) + 464 007a 2295 swap r18 + 465 007c 207F andi r18,lo8(-16) + 466 007e 422B or r20,r18 + 467 0080 812F mov r24,r17 + 468 .LVL21: + 469 0082 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 470 .LVL22: + 471 .LBE67: + 472 .LSM52: + 473 0086 8823 tst r24 + 474 0088 01F0 breq .L18 + 475 .L13: + 476 .LBE66: + 477 .LSM53: + 478 008a 1F5F subi r17,lo8(-(1)) + 479 008c 1530 cpi r17,lo8(5) + 480 008e 01F4 brne .L19 + 481 0090 81E0 ldi r24,lo8(1) + 482 .L18: + 483 /* epilogue start */ + 484 .LBE65: + 485 .LSM54: + 486 0092 DF91 pop r29 + 487 0094 CF91 pop r28 + 488 .LVL23: + 489 0096 1F91 pop r17 + 490 .LVL24: + 491 0098 0895 ret + 492 .LFE82: + 494 .section .text.RNDIS_Device_ProcessControlRequest,"ax",@progbits + 495 .global RNDIS_Device_ProcessControlRequest + 497 RNDIS_Device_ProcessControlRequest: + 498 .LFB81: + 499 .LSM55: + 500 .LVL25: + 501 0000 EF92 push r14 + 502 0002 FF92 push r15 + 503 0004 0F93 push r16 + 504 0006 1F93 push r17 + 505 0008 CF93 push r28 + 506 000a DF93 push r29 + 507 /* prologue: function */ + 508 /* frame size = 0 */ + 509 000c EC01 movw r28,r24 + 510 .LBB89: + 511 .LBB90: + 512 .LSM56: + 513 000e 8091 E800 lds r24,232 + 514 .LVL26: + 515 .LBE90: + 516 .LBE89: + 517 .LSM57: + 518 0012 83FF sbrs r24,3 + 519 0014 00C0 rjmp .L63 + 520 .LSM58: + 521 0016 8881 ld r24,Y + 522 0018 90E0 ldi r25,lo8(0) + 523 001a 2091 0000 lds r18,USB_ControlRequest+4 + 524 001e 3091 0000 lds r19,(USB_ControlRequest+4)+1 + 525 0022 2817 cp r18,r24 + 526 0024 3907 cpc r19,r25 + 527 0026 01F0 breq .+2 + 528 0028 00C0 rjmp .L63 + 529 .LSM59: + 530 002a 8091 0000 lds r24,USB_ControlRequest+1 + 531 002e 8823 tst r24 + 532 0030 01F0 breq .L25 + 533 0032 8130 cpi r24,lo8(1) + 534 0034 01F0 breq .+2 + 535 0036 00C0 rjmp .L63 + 536 0038 00C0 rjmp .L71 + 537 .L25: + 538 .LSM60: + 539 003a 8091 0000 lds r24,USB_ControlRequest + 540 003e 8132 cpi r24,lo8(33) + 541 0040 01F0 breq .+2 + 542 0042 00C0 rjmp .L63 + 543 .LBB91: + 544 .LBB92: + 545 .LSM61: + 546 0044 8091 E800 lds r24,232 + 547 0048 877F andi r24,lo8(-9) + 548 004a 8093 E800 sts 232,r24 + 549 .LBE92: + 550 .LBE91: + 551 .LSM62: + 552 004e 8E01 movw r16,r28 + 553 0050 0B5E subi r16,lo8(-(21)) + 554 0052 1F4F sbci r17,hi8(-(21)) + 555 0054 6091 0000 lds r22,USB_ControlRequest+6 + 556 0058 7091 0000 lds r23,(USB_ControlRequest+6)+1 + 557 005c C801 movw r24,r16 + 558 005e 0E94 0000 call Endpoint_Read_Control_Stream_LE + 559 .LBB93: + 560 .LBB94: + 561 .LSM63: + 562 0062 8091 E800 lds r24,232 + 563 0066 8E77 andi r24,lo8(126) + 564 0068 8093 E800 sts 232,r24 + 565 .LBE94: + 566 .LBE93: + 567 .LBB95: + 568 .LBB96: + 569 .LSM64: + 570 006c 8D89 ldd r24,Y+21 + 571 006e 9E89 ldd r25,Y+22 + 572 0070 AF89 ldd r26,Y+23 + 573 0072 B88D ldd r27,Y+24 + 574 0074 8430 cpi r24,lo8(4) + 575 0076 9105 cpc r25,__zero_reg__ + 576 0078 A105 cpc r26,__zero_reg__ + 577 007a B105 cpc r27,__zero_reg__ + 578 007c 01F4 brne .+2 + 579 007e 00C0 rjmp .L29 + 580 0080 8530 cpi r24,lo8(5) + 581 0082 9105 cpc r25,__zero_reg__ + 582 0084 A105 cpc r26,__zero_reg__ + 583 0086 B105 cpc r27,__zero_reg__ + 584 0088 00F4 brsh .L33 + 585 008a 8230 cpi r24,lo8(2) + 586 008c 9105 cpc r25,__zero_reg__ + 587 008e A105 cpc r26,__zero_reg__ + 588 0090 B105 cpc r27,__zero_reg__ + 589 0092 01F0 breq .L27 + 590 0094 0397 sbiw r24,3 + 591 0096 A105 cpc r26,__zero_reg__ + 592 0098 B105 cpc r27,__zero_reg__ + 593 009a 01F0 breq .+2 + 594 009c 00C0 rjmp .L63 + 595 009e 00C0 rjmp .L72 + 596 .L33: + 597 00a0 8630 cpi r24,lo8(6) + 598 00a2 9105 cpc r25,__zero_reg__ + 599 00a4 A105 cpc r26,__zero_reg__ + 600 00a6 B105 cpc r27,__zero_reg__ + 601 00a8 01F4 brne .+2 + 602 00aa 00C0 rjmp .L31 + 603 00ac 8630 cpi r24,lo8(6) + 604 00ae 9105 cpc r25,__zero_reg__ + 605 00b0 A105 cpc r26,__zero_reg__ + 606 00b2 B105 cpc r27,__zero_reg__ + 607 00b4 00F4 brsh .+2 + 608 00b6 00C0 rjmp .L30 + 609 00b8 0897 sbiw r24,8 + 610 00ba A105 cpc r26,__zero_reg__ + 611 00bc B105 cpc r27,__zero_reg__ + 612 00be 01F0 breq .+2 + 613 00c0 00C0 rjmp .L63 + 614 00c2 00C0 rjmp .L73 + 615 .L27: + 616 .LBB97: + 617 .LSM65: + 618 00c4 CB56 subi r28,lo8(-(149)) + 619 00c6 DF4F sbci r29,hi8(-(149)) + 620 00c8 21E0 ldi r18,lo8(1) + 621 00ca 2883 st Y,r18 + 622 00cc C559 subi r28,lo8(-(-149)) + 623 00ce D040 sbci r29,hi8(-(-149)) + 624 .LSM66: + 625 00d0 82E0 ldi r24,lo8(-2147483646) + 626 00d2 90E0 ldi r25,hi8(-2147483646) + 627 00d4 A0E0 ldi r26,hlo8(-2147483646) + 628 00d6 B0E8 ldi r27,hhi8(-2147483646) + 629 00d8 8D8B std Y+21,r24 + 630 00da 9E8B std Y+22,r25 + 631 00dc AF8B std Y+23,r26 + 632 00de B88F std Y+24,r27 + 633 .LSM67: + 634 00e0 84E3 ldi r24,lo8(52) + 635 00e2 90E0 ldi r25,hi8(52) + 636 00e4 A0E0 ldi r26,hlo8(52) + 637 00e6 B0E0 ldi r27,hhi8(52) + 638 00e8 F801 movw r30,r16 + 639 00ea 8483 std Z+4,r24 + 640 00ec 9583 std Z+5,r25 + 641 00ee A683 std Z+6,r26 + 642 00f0 B783 std Z+7,r27 + 643 .LSM68: + 644 00f2 1486 std Z+12,__zero_reg__ + 645 00f4 1586 std Z+13,__zero_reg__ + 646 00f6 1686 std Z+14,__zero_reg__ + 647 00f8 1786 std Z+15,__zero_reg__ + 648 .LSM69: + 649 00fa 81E0 ldi r24,lo8(1) + 650 00fc 90E0 ldi r25,hi8(1) + 651 00fe A0E0 ldi r26,hlo8(1) + 652 0100 B0E0 ldi r27,hhi8(1) + 653 0102 808B std Z+16,r24 + 654 0104 918B std Z+17,r25 + 655 0106 A28B std Z+18,r26 + 656 0108 B38B std Z+19,r27 + 657 .LSM70: + 658 010a 148A std Z+20,__zero_reg__ + 659 010c 158A std Z+21,__zero_reg__ + 660 010e 168A std Z+22,__zero_reg__ + 661 0110 178A std Z+23,__zero_reg__ + 662 .LSM71: + 663 0112 808F std Z+24,r24 + 664 0114 918F std Z+25,r25 + 665 0116 A28F std Z+26,r26 + 666 0118 B38F std Z+27,r27 + 667 .LSM72: + 668 011a 148E std Z+28,__zero_reg__ + 669 011c 158E std Z+29,__zero_reg__ + 670 011e 168E std Z+30,__zero_reg__ + 671 0120 178E std Z+31,__zero_reg__ + 672 .LSM73: + 673 0122 80A3 std Z+32,r24 + 674 0124 91A3 std Z+33,r25 + 675 0126 A2A3 std Z+34,r26 + 676 0128 B3A3 std Z+35,r27 + 677 .LSM74: + 678 012a 88E0 ldi r24,lo8(1544) + 679 012c 96E0 ldi r25,hi8(1544) + 680 012e A0E0 ldi r26,hlo8(1544) + 681 0130 B0E0 ldi r27,hhi8(1544) + 682 0132 84A3 std Z+36,r24 + 683 0134 95A3 std Z+37,r25 + 684 0136 A6A3 std Z+38,r26 + 685 0138 B7A3 std Z+39,r27 + 686 .LSM75: + 687 013a 10A6 std Z+40,__zero_reg__ + 688 013c 11A6 std Z+41,__zero_reg__ + 689 013e 12A6 std Z+42,__zero_reg__ + 690 0140 13A6 std Z+43,__zero_reg__ + 691 .LSM76: + 692 0142 14A6 std Z+44,__zero_reg__ + 693 0144 15A6 std Z+45,__zero_reg__ + 694 0146 16A6 std Z+46,__zero_reg__ + 695 0148 17A6 std Z+47,__zero_reg__ + 696 .LSM77: + 697 014a 10AA std Z+48,__zero_reg__ + 698 014c 11AA std Z+49,__zero_reg__ + 699 014e 12AA std Z+50,__zero_reg__ + 700 0150 13AA std Z+51,__zero_reg__ + 701 .LSM78: + 702 0152 CA56 subi r28,lo8(-(150)) + 703 0154 DF4F sbci r29,hi8(-(150)) + 704 0156 2883 st Y,r18 + 705 0158 00C0 rjmp .L63 + 706 .L72: + 707 .LSM79: + 708 015a CB56 subi r28,lo8(-(149)) + 709 015c DF4F sbci r29,hi8(-(149)) + 710 015e 1992 st Y+,__zero_reg__ + 711 .LSM80: + 712 0160 F801 movw r30,r16 + 713 0162 1482 std Z+4,__zero_reg__ + 714 0164 1582 std Z+5,__zero_reg__ + 715 0166 1682 std Z+6,__zero_reg__ + 716 0168 1782 std Z+7,__zero_reg__ + 717 .LSM81: + 718 016a 1882 st Y,__zero_reg__ + 719 .LVL27: + 720 016c 00C0 rjmp .L63 + 721 .LVL28: + 722 .L29: + 723 .LSM82: + 724 016e CB56 subi r28,lo8(-(149)) + 725 0170 DF4F sbci r29,hi8(-(149)) + 726 0172 81E0 ldi r24,lo8(1) + 727 0174 8883 st Y,r24 + 728 0176 C559 subi r28,lo8(-(-149)) + 729 0178 D040 sbci r29,hi8(-(-149)) + 730 .LSM83: + 731 017a F801 movw r30,r16 + 732 017c 2485 ldd r18,Z+12 + 733 017e 3585 ldd r19,Z+13 + 734 0180 4685 ldd r20,Z+14 + 735 0182 5785 ldd r21,Z+15 + 736 .LVL29: + 737 .LSM84: + 738 0184 6DE2 ldi r22,lo8(45) + 739 0186 E62E mov r14,r22 + 740 0188 F12C mov r15,__zero_reg__ + 741 .LVL30: + 742 018a EC0E add r14,r28 + 743 018c FD1E adc r15,r29 + 744 .LSM85: + 745 018e 84E0 ldi r24,lo8(-2147483644) + 746 0190 90E0 ldi r25,hi8(-2147483644) + 747 0192 A0E0 ldi r26,hlo8(-2147483644) + 748 0194 B0E8 ldi r27,hhi8(-2147483644) + 749 0196 8D8B std Y+21,r24 + 750 0198 9E8B std Y+22,r25 + 751 019a AF8B std Y+23,r26 + 752 019c B88F std Y+24,r27 + 753 .LSM86: + 754 019e 88E1 ldi r24,lo8(24) + 755 01a0 90E0 ldi r25,hi8(24) + 756 01a2 A0E0 ldi r26,hlo8(24) + 757 01a4 B0E0 ldi r27,hhi8(24) + 758 01a6 8483 std Z+4,r24 + 759 01a8 9583 std Z+5,r25 + 760 01aa A683 std Z+6,r26 + 761 01ac B783 std Z+7,r27 + 762 .LBB100: + 763 .LBB101: + 764 .LSM87: + 765 01ae 2E30 cpi r18,lo8(65806) + 766 01b0 F1E0 ldi r31,hi8(65806) + 767 01b2 3F07 cpc r19,r31 + 768 01b4 F1E0 ldi r31,hlo8(65806) + 769 01b6 4F07 cpc r20,r31 + 770 01b8 F0E0 ldi r31,hhi8(65806) + 771 01ba 5F07 cpc r21,r31 + 772 01bc 01F4 brne .+2 + 773 01be 00C0 rjmp .L42 + 774 01c0 2F30 cpi r18,lo8(65807) + 775 01c2 61E0 ldi r22,hi8(65807) + 776 01c4 3607 cpc r19,r22 + 777 01c6 61E0 ldi r22,hlo8(65807) + 778 01c8 4607 cpc r20,r22 + 779 01ca 60E0 ldi r22,hhi8(65807) + 780 01cc 5607 cpc r21,r22 + 781 01ce 00F0 brlo .+2 + 782 01d0 00C0 rjmp .L49 + 783 01d2 2630 cpi r18,lo8(65798) + 784 01d4 81E0 ldi r24,hi8(65798) + 785 01d6 3807 cpc r19,r24 + 786 01d8 81E0 ldi r24,hlo8(65798) + 787 01da 4807 cpc r20,r24 + 788 01dc 80E0 ldi r24,hhi8(65798) + 789 01de 5807 cpc r21,r24 + 790 01e0 01F4 brne .+2 + 791 01e2 00C0 rjmp .L38 + 792 01e4 2730 cpi r18,lo8(65799) + 793 01e6 E1E0 ldi r30,hi8(65799) + 794 01e8 3E07 cpc r19,r30 + 795 01ea E1E0 ldi r30,hlo8(65799) + 796 01ec 4E07 cpc r20,r30 + 797 01ee E0E0 ldi r30,hhi8(65799) + 798 01f0 5E07 cpc r21,r30 + 799 01f2 00F4 brsh .L50 + 800 01f4 2230 cpi r18,lo8(65794) + 801 01f6 F1E0 ldi r31,hi8(65794) + 802 01f8 3F07 cpc r19,r31 + 803 01fa F1E0 ldi r31,hlo8(65794) + 804 01fc 4F07 cpc r20,r31 + 805 01fe F0E0 ldi r31,hhi8(65794) + 806 0200 5F07 cpc r21,r31 + 807 0202 01F4 brne .+2 + 808 0204 00C0 rjmp .L46 + 809 0206 2330 cpi r18,lo8(65795) + 810 0208 61E0 ldi r22,hi8(65795) + 811 020a 3607 cpc r19,r22 + 812 020c 61E0 ldi r22,hlo8(65795) + 813 020e 4607 cpc r20,r22 + 814 0210 60E0 ldi r22,hhi8(65795) + 815 0212 5607 cpc r21,r22 + 816 0214 00F4 brsh .L51 + 817 0216 2150 subi r18,lo8(65793) + 818 0218 3140 sbci r19,hi8(65793) + 819 021a 4140 sbci r20,hlo8(65793) + 820 021c 5040 sbci r21,hhi8(65793) + 821 021e 01F0 breq .+2 + 822 0220 00C0 rjmp .L34 + 823 0222 00C0 rjmp .L74 + 824 .L51: + 825 0224 2550 subi r18,lo8(65797) + 826 0226 3140 sbci r19,hi8(65797) + 827 0228 4140 sbci r20,hlo8(65797) + 828 022a 5040 sbci r21,hhi8(65797) + 829 022c 00F0 brlo .+2 + 830 022e 00C0 rjmp .L34 + 831 0230 00C0 rjmp .L46 + 832 .L50: + 833 0232 2C30 cpi r18,lo8(65804) + 834 0234 F1E0 ldi r31,hi8(65804) + 835 0236 3F07 cpc r19,r31 + 836 0238 F1E0 ldi r31,hlo8(65804) + 837 023a 4F07 cpc r20,r31 + 838 023c F0E0 ldi r31,hhi8(65804) + 839 023e 5F07 cpc r21,r31 + 840 0240 00F4 brsh .L52 + 841 0242 2A30 cpi r18,lo8(65802) + 842 0244 61E0 ldi r22,hi8(65802) + 843 0246 3607 cpc r19,r22 + 844 0248 61E0 ldi r22,hlo8(65802) + 845 024a 4607 cpc r20,r22 + 846 024c 60E0 ldi r22,hhi8(65802) + 847 024e 5607 cpc r21,r22 + 848 0250 00F0 brlo .+2 + 849 0252 00C0 rjmp .L38 + 850 0254 2750 subi r18,lo8(65799) + 851 0256 3140 sbci r19,hi8(65799) + 852 0258 4140 sbci r20,hlo8(65799) + 853 025a 5040 sbci r21,hhi8(65799) + 854 025c 01F0 breq .+2 + 855 025e 00C0 rjmp .L34 + 856 0260 00C0 rjmp .L75 + 857 .L52: + 858 0262 2C30 cpi r18,lo8(65804) + 859 0264 E1E0 ldi r30,hi8(65804) + 860 0266 3E07 cpc r19,r30 + 861 0268 E1E0 ldi r30,hlo8(65804) + 862 026a 4E07 cpc r20,r30 + 863 026c E0E0 ldi r30,hhi8(65804) + 864 026e 5E07 cpc r21,r30 + 865 0270 01F4 brne .+2 + 866 0272 00C0 rjmp .L40 + 867 0274 2D50 subi r18,lo8(65805) + 868 0276 3140 sbci r19,hi8(65805) + 869 0278 4140 sbci r20,hlo8(65805) + 870 027a 5040 sbci r21,hhi8(65805) + 871 027c 01F0 breq .+2 + 872 027e 00C0 rjmp .L34 + 873 0280 00C0 rjmp .L76 + 874 .L49: + 875 0282 2630 cpi r18,lo8(131334) + 876 0284 61E0 ldi r22,hi8(131334) + 877 0286 3607 cpc r19,r22 + 878 0288 62E0 ldi r22,hlo8(131334) + 879 028a 4607 cpc r20,r22 + 880 028c 60E0 ldi r22,hhi8(131334) + 881 028e 5607 cpc r21,r22 + 882 0290 00F4 brsh .L53 + 883 0292 2130 cpi r18,lo8(131329) + 884 0294 81E0 ldi r24,hi8(131329) + 885 0296 3807 cpc r19,r24 + 886 0298 82E0 ldi r24,hlo8(131329) + 887 029a 4807 cpc r20,r24 + 888 029c 80E0 ldi r24,hhi8(131329) + 889 029e 5807 cpc r21,r24 + 890 02a0 00F0 brlo .+2 + 891 02a2 00C0 rjmp .L46 + 892 02a4 2431 cpi r18,lo8(65812) + 893 02a6 E1E0 ldi r30,hi8(65812) + 894 02a8 3E07 cpc r19,r30 + 895 02aa E1E0 ldi r30,hlo8(65812) + 896 02ac 4E07 cpc r20,r30 + 897 02ae E0E0 ldi r30,hhi8(65812) + 898 02b0 5E07 cpc r21,r30 + 899 02b2 01F4 brne .+2 + 900 02b4 00C0 rjmp .L46 + 901 02b6 2230 cpi r18,lo8(66050) + 902 02b8 F2E0 ldi r31,hi8(66050) + 903 02ba 3F07 cpc r19,r31 + 904 02bc F1E0 ldi r31,hlo8(66050) + 905 02be 4F07 cpc r20,r31 + 906 02c0 F0E0 ldi r31,hhi8(66050) + 907 02c2 5F07 cpc r21,r31 + 908 02c4 01F4 brne .+2 + 909 02c6 00C0 rjmp .L46 + 910 02c8 2151 subi r18,lo8(65809) + 911 02ca 3140 sbci r19,hi8(65809) + 912 02cc 4140 sbci r20,hlo8(65809) + 913 02ce 5040 sbci r21,hhi8(65809) + 914 02d0 01F0 breq .+2 + 915 02d2 00C0 rjmp .L34 + 916 02d4 00C0 rjmp .L77 + 917 .L53: + 918 02d6 2430 cpi r18,lo8(16843012) + 919 02d8 81E0 ldi r24,hi8(16843012) + 920 02da 3807 cpc r19,r24 + 921 02dc 81E0 ldi r24,hlo8(16843012) + 922 02de 4807 cpc r20,r24 + 923 02e0 81E0 ldi r24,hhi8(16843012) + 924 02e2 5807 cpc r21,r24 + 925 02e4 01F4 brne .+2 + 926 02e6 00C0 rjmp .L48 + 927 02e8 2530 cpi r18,lo8(16843013) + 928 02ea E1E0 ldi r30,hi8(16843013) + 929 02ec 3E07 cpc r19,r30 + 930 02ee E1E0 ldi r30,hlo8(16843013) + 931 02f0 4E07 cpc r20,r30 + 932 02f2 E1E0 ldi r30,hhi8(16843013) + 933 02f4 5E07 cpc r21,r30 + 934 02f6 00F4 brsh .L54 + 935 02f8 2150 subi r18,lo8(-(-16843009)) + 936 02fa 3140 sbci r19,hi8(-(-16843009)) + 937 02fc 4140 sbci r20,hlo8(-(-16843009)) + 938 02fe 5140 sbci r21,hhi8(-(-16843009)) + 939 0300 2230 cpi r18,lo8(2) + 940 0302 3105 cpc r19,__zero_reg__ + 941 0304 4105 cpc r20,__zero_reg__ + 942 0306 5105 cpc r21,__zero_reg__ + 943 0308 00F0 brlo .+2 + 944 030a 00C0 rjmp .L34 + 945 030c 00C0 rjmp .L78 + 946 .L54: + 947 030e 2150 subi r18,lo8(-(-16908545)) + 948 0310 3140 sbci r19,hi8(-(-16908545)) + 949 0312 4240 sbci r20,hlo8(-(-16908545)) + 950 0314 5140 sbci r21,hhi8(-(-16908545)) + 951 0316 2330 cpi r18,lo8(3) + 952 0318 3105 cpc r19,__zero_reg__ + 953 031a 4105 cpc r20,__zero_reg__ + 954 031c 5105 cpc r21,__zero_reg__ + 955 031e 00F0 brlo .+2 + 956 0320 00C0 rjmp .L34 + 957 0322 00C0 rjmp .L46 + 958 .L74: + 959 .LSM88: + 960 0324 C701 movw r24,r14 + 961 0326 60E0 ldi r22,lo8(AdapterSupportedOIDList) + 962 0328 70E0 ldi r23,hi8(AdapterSupportedOIDList) + 963 032a 4CE6 ldi r20,lo8(108) + 964 032c 50E0 ldi r21,hi8(108) + 965 032e 0E94 0000 call memcpy_P + 966 .LVL31: + 967 0332 CCE6 ldi r28,lo8(108) + 968 0334 D0E0 ldi r29,hi8(108) + 969 .LVL32: + 970 0336 00C0 rjmp .L55 + 971 .LVL33: + 972 .L40: + 973 .LSM89: + 974 0338 8FEF ldi r24,lo8(16777215) + 975 033a 9FEF ldi r25,hi8(16777215) + 976 033c AFEF ldi r26,hlo8(16777215) + 977 033e B0E0 ldi r27,hhi8(16777215) + 978 0340 00C0 rjmp .L70 + 979 .L38: + 980 .LSM90: + 981 0342 8CED ldi r24,lo8(1500) + 982 0344 95E0 ldi r25,hi8(1500) + 983 0346 A0E0 ldi r26,hlo8(1500) + 984 0348 B0E0 ldi r27,hhi8(1500) + 985 034a 00C0 rjmp .L70 + 986 .L76: + 987 .LSM91: + 988 034c 6D85 ldd r22,Y+13 + 989 034e 7E85 ldd r23,Y+14 + 990 .LBE101: + 991 0350 FB01 movw r30,r22 + 992 0352 EF01 movw r28,r30 + 993 .LVL34: + 994 0354 0990 ld __tmp_reg__,Y+ + 995 0356 0020 tst __tmp_reg__ + 996 0358 01F4 brne .-6 + 997 .LBB102: + 998 035a CE1B sub r28,r30 + 999 035c DF0B sbc r29,r31 + 1000 .LSM92: + 1001 035e C701 movw r24,r14 + 1002 .LVL35: + 1003 0360 AE01 movw r20,r28 + 1004 .LVL36: + 1005 0362 0E94 0000 call memcpy + 1006 .LVL37: + 1007 0366 00C0 rjmp .L55 + 1008 .LVL38: + 1009 .L75: + 1010 .LSM93: + 1011 0368 80EA ldi r24,lo8(100000) + 1012 036a 96E8 ldi r25,hi8(100000) + 1013 036c A1E0 ldi r26,hlo8(100000) + 1014 036e B0E0 ldi r27,hhi8(100000) + 1015 0370 00C0 rjmp .L70 + 1016 .L78: + 1017 .LSM94: + 1018 0372 D701 movw r26,r14 + 1019 0374 FE01 movw r30,r28 + 1020 0376 3F96 adiw r30,15 + 1021 0378 86E0 ldi r24,lo8(6) + 1022 .LVL39: + 1023 .L57: + 1024 037a 0190 ld r0,Z+ + 1025 037c 0D92 st X+,r0 + 1026 037e 8150 subi r24,lo8(-(-1)) + 1027 0380 01F4 brne .L57 + 1028 0382 C6E0 ldi r28,lo8(6) + 1029 0384 D0E0 ldi r29,hi8(6) + 1030 .LVL40: + 1031 0386 00C0 rjmp .L55 + 1032 .LVL41: + 1033 .L48: + 1034 .LSM95: + 1035 0388 81E0 ldi r24,lo8(1) + 1036 038a 90E0 ldi r25,hi8(1) + 1037 038c A0E0 ldi r26,hlo8(1) + 1038 038e B0E0 ldi r27,hhi8(1) + 1039 0390 00C0 rjmp .L70 + 1040 .L42: + 1041 .LSM96: + 1042 0392 C956 subi r28,lo8(-(151)) + 1043 0394 DF4F sbci r29,hi8(-(151)) + 1044 0396 8881 ld r24,Y + 1045 0398 9981 ldd r25,Y+1 + 1046 039a AA81 ldd r26,Y+2 + 1047 039c BB81 ldd r27,Y+3 + 1048 039e C759 subi r28,lo8(-(-151)) + 1049 03a0 D040 sbci r29,hi8(-(-151)) + 1050 03a2 00C0 rjmp .L70 + 1051 .L46: + 1052 .LSM97: + 1053 03a4 1DA6 std Y+45,__zero_reg__ + 1054 03a6 1EA6 std Y+46,__zero_reg__ + 1055 03a8 1FA6 std Y+47,__zero_reg__ + 1056 03aa 18AA std Y+48,__zero_reg__ + 1057 03ac 00C0 rjmp .L68 + 1058 .L77: + 1059 .LSM98: + 1060 03ae 8CE5 ldi r24,lo8(1628) + 1061 03b0 96E0 ldi r25,hi8(1628) + 1062 03b2 A0E0 ldi r26,hlo8(1628) + 1063 03b4 B0E0 ldi r27,hhi8(1628) + 1064 .L70: + 1065 03b6 8DA7 std Y+45,r24 + 1066 03b8 9EA7 std Y+46,r25 + 1067 03ba AFA7 std Y+47,r26 + 1068 03bc B8AB std Y+48,r27 + 1069 .L68: + 1070 03be C4E0 ldi r28,lo8(4) + 1071 03c0 D0E0 ldi r29,hi8(4) + 1072 .LVL42: + 1073 03c2 00C0 rjmp .L55 + 1074 .LVL43: + 1075 .L34: + 1076 .LBE102: + 1077 .LBE100: + 1078 .LSM99: + 1079 03c4 8BEB ldi r24,lo8(-1073741637) + 1080 03c6 90E0 ldi r25,hi8(-1073741637) + 1081 03c8 A0E0 ldi r26,hlo8(-1073741637) + 1082 03ca B0EC ldi r27,hhi8(-1073741637) + 1083 03cc F801 movw r30,r16 + 1084 03ce 8487 std Z+12,r24 + 1085 03d0 9587 std Z+13,r25 + 1086 03d2 A687 std Z+14,r26 + 1087 03d4 B787 std Z+15,r27 + 1088 .LSM100: + 1089 03d6 108A std Z+16,__zero_reg__ + 1090 03d8 118A std Z+17,__zero_reg__ + 1091 03da 128A std Z+18,__zero_reg__ + 1092 03dc 138A std Z+19,__zero_reg__ + 1093 .LSM101: + 1094 03de 148A std Z+20,__zero_reg__ + 1095 03e0 158A std Z+21,__zero_reg__ + 1096 03e2 168A std Z+22,__zero_reg__ + 1097 03e4 178A std Z+23,__zero_reg__ + 1098 03e6 00C0 rjmp .L63 + 1099 .LVL44: + 1100 .L30: + 1101 .LSM102: + 1102 03e8 CB56 subi r28,lo8(-(149)) + 1103 03ea DF4F sbci r29,hi8(-(149)) + 1104 03ec 81E0 ldi r24,lo8(1) + 1105 03ee 8883 st Y,r24 + 1106 03f0 C559 subi r28,lo8(-(-149)) + 1107 03f2 D040 sbci r29,hi8(-(-149)) + 1108 .LSM103: + 1109 03f4 F801 movw r30,r16 + 1110 03f6 2485 ldd r18,Z+12 + 1111 03f8 3585 ldd r19,Z+13 + 1112 03fa 4685 ldd r20,Z+14 + 1113 03fc 5785 ldd r21,Z+15 + 1114 .LVL45: + 1115 .LSM104: + 1116 03fe 85E0 ldi r24,lo8(-2147483643) + 1117 0400 90E0 ldi r25,hi8(-2147483643) + 1118 0402 A0E0 ldi r26,hlo8(-2147483643) + 1119 0404 B0E8 ldi r27,hhi8(-2147483643) + 1120 0406 8D8B std Y+21,r24 + 1121 0408 9E8B std Y+22,r25 + 1122 040a AF8B std Y+23,r26 + 1123 040c B88F std Y+24,r27 + 1124 .LSM105: + 1125 040e 80E1 ldi r24,lo8(16) + 1126 0410 90E0 ldi r25,hi8(16) + 1127 0412 A0E0 ldi r26,hlo8(16) + 1128 0414 B0E0 ldi r27,hhi8(16) + 1129 0416 8483 std Z+4,r24 + 1130 0418 9583 std Z+5,r25 + 1131 041a A683 std Z+6,r26 + 1132 041c B783 std Z+7,r27 + 1133 .LSM106: + 1134 041e 8489 ldd r24,Z+20 + 1135 0420 9589 ldd r25,Z+21 + 1136 0422 A689 ldd r26,Z+22 + 1137 0424 B789 ldd r27,Z+23 + 1138 .LBB98: + 1139 .LBB99: + 1140 .LSM107: + 1141 0426 2E30 cpi r18,lo8(65806) + 1142 0428 F1E0 ldi r31,hi8(65806) + 1143 042a 3F07 cpc r19,r31 + 1144 042c F1E0 ldi r31,hlo8(65806) + 1145 042e 4F07 cpc r20,r31 + 1146 0430 F0E0 ldi r31,hhi8(65806) + 1147 0432 5F07 cpc r21,r31 + 1148 0434 01F0 breq .L59 + 1149 0436 2350 subi r18,lo8(16843011) + 1150 0438 3140 sbci r19,hi8(16843011) + 1151 043a 4140 sbci r20,hlo8(16843011) + 1152 043c 5140 sbci r21,hhi8(16843011) + 1153 043e 01F0 breq .L67 + 1154 0440 8BEB ldi r24,lo8(-1073741637) + 1155 0442 90E0 ldi r25,hi8(-1073741637) + 1156 0444 A0E0 ldi r26,hlo8(-1073741637) + 1157 0446 B0EC ldi r27,hhi8(-1073741637) + 1158 0448 00C0 rjmp .L61 + 1159 .L59: + 1160 .LSM108: + 1161 044a FE01 movw r30,r28 + 1162 044c E80F add r30,r24 + 1163 044e F91F adc r31,r25 + 1164 0450 858D ldd r24,Z+29 + 1165 0452 968D ldd r25,Z+30 + 1166 0454 A78D ldd r26,Z+31 + 1167 0456 B0A1 ldd r27,Z+32 + 1168 0458 C956 subi r28,lo8(-(151)) + 1169 045a DF4F sbci r29,hi8(-(151)) + 1170 045c 8883 st Y,r24 + 1171 045e 9983 std Y+1,r25 + 1172 0460 AA83 std Y+2,r26 + 1173 0462 BB83 std Y+3,r27 + 1174 .LSM109: + 1175 0464 FE01 movw r30,r28 + 1176 0466 82E0 ldi r24,lo8(2) + 1177 0468 8293 st -Z,r24 + 1178 .L67: + 1179 046a 80E0 ldi r24,lo8(0) + 1180 046c 90E0 ldi r25,hi8(0) + 1181 046e A0E0 ldi r26,hlo8(0) + 1182 0470 B0E0 ldi r27,hhi8(0) + 1183 .L61: + 1184 .LBE99: + 1185 .LBE98: + 1186 .LSM110: + 1187 0472 F801 movw r30,r16 + 1188 0474 8487 std Z+12,r24 + 1189 0476 9587 std Z+13,r25 + 1190 0478 A687 std Z+14,r26 + 1191 047a B787 std Z+15,r27 + 1192 047c 00C0 rjmp .L63 + 1193 .LVL46: + 1194 .L31: + 1195 .LSM111: + 1196 047e CB56 subi r28,lo8(-(149)) + 1197 0480 DF4F sbci r29,hi8(-(149)) + 1198 0482 81E0 ldi r24,lo8(1) + 1199 0484 8883 st Y,r24 + 1200 0486 C559 subi r28,lo8(-(-149)) + 1201 0488 D040 sbci r29,hi8(-(-149)) + 1202 .LSM112: + 1203 048a 86E0 ldi r24,lo8(-2147483642) + 1204 048c 90E0 ldi r25,hi8(-2147483642) + 1205 048e A0E0 ldi r26,hlo8(-2147483642) + 1206 0490 B0E8 ldi r27,hhi8(-2147483642) + 1207 0492 8D8B std Y+21,r24 + 1208 0494 9E8B std Y+22,r25 + 1209 0496 AF8B std Y+23,r26 + 1210 0498 B88F std Y+24,r27 + 1211 .LSM113: + 1212 049a 80E1 ldi r24,lo8(16) + 1213 049c 90E0 ldi r25,hi8(16) + 1214 049e A0E0 ldi r26,hlo8(16) + 1215 04a0 B0E0 ldi r27,hhi8(16) + 1216 04a2 F801 movw r30,r16 + 1217 04a4 8483 std Z+4,r24 + 1218 04a6 9583 std Z+5,r25 + 1219 04a8 A683 std Z+6,r26 + 1220 04aa B783 std Z+7,r27 + 1221 .LSM114: + 1222 04ac 1086 std Z+8,__zero_reg__ + 1223 04ae 1186 std Z+9,__zero_reg__ + 1224 04b0 1286 std Z+10,__zero_reg__ + 1225 04b2 1386 std Z+11,__zero_reg__ + 1226 04b4 00C0 rjmp .L69 + 1227 .L73: + 1228 .LSM115: + 1229 04b6 CB56 subi r28,lo8(-(149)) + 1230 04b8 DF4F sbci r29,hi8(-(149)) + 1231 04ba 81E0 ldi r24,lo8(1) + 1232 04bc 8883 st Y,r24 + 1233 04be C559 subi r28,lo8(-(-149)) + 1234 04c0 D040 sbci r29,hi8(-(-149)) + 1235 .LSM116: + 1236 04c2 88E0 ldi r24,lo8(-2147483640) + 1237 04c4 90E0 ldi r25,hi8(-2147483640) + 1238 04c6 A0E0 ldi r26,hlo8(-2147483640) + 1239 04c8 B0E8 ldi r27,hhi8(-2147483640) + 1240 04ca 8D8B std Y+21,r24 + 1241 04cc 9E8B std Y+22,r25 + 1242 04ce AF8B std Y+23,r26 + 1243 04d0 B88F std Y+24,r27 + 1244 .LSM117: + 1245 04d2 80E1 ldi r24,lo8(16) + 1246 04d4 90E0 ldi r25,hi8(16) + 1247 04d6 A0E0 ldi r26,hlo8(16) + 1248 04d8 B0E0 ldi r27,hhi8(16) + 1249 04da F801 movw r30,r16 + 1250 04dc 8483 std Z+4,r24 + 1251 04de 9583 std Z+5,r25 + 1252 04e0 A683 std Z+6,r26 + 1253 04e2 B783 std Z+7,r27 + 1254 .L69: + 1255 .LSM118: + 1256 04e4 1486 std Z+12,__zero_reg__ + 1257 04e6 1586 std Z+13,__zero_reg__ + 1258 04e8 1686 std Z+14,__zero_reg__ + 1259 04ea 1786 std Z+15,__zero_reg__ + 1260 04ec 00C0 rjmp .L63 + 1261 .L71: + 1262 .LBE97: + 1263 .LBE96: + 1264 .LBE95: + 1265 .LSM119: + 1266 04ee 8091 0000 lds r24,USB_ControlRequest + 1267 04f2 813A cpi r24,lo8(-95) + 1268 04f4 01F0 breq .+2 + 1269 04f6 00C0 rjmp .L63 + 1270 .LBB105: + 1271 .LSM120: + 1272 04f8 8E01 movw r16,r28 + 1273 .LVL47: + 1274 04fa 0B5E subi r16,lo8(-(21)) + 1275 04fc 1F4F sbci r17,hi8(-(21)) + 1276 .LSM121: + 1277 04fe F801 movw r30,r16 + 1278 0500 8481 ldd r24,Z+4 + 1279 0502 9581 ldd r25,Z+5 + 1280 0504 A681 ldd r26,Z+6 + 1281 0506 B781 ldd r27,Z+7 + 1282 0508 0097 sbiw r24,0 + 1283 050a A105 cpc r26,__zero_reg__ + 1284 050c B105 cpc r27,__zero_reg__ + 1285 050e 01F4 brne .L62 + 1286 .LSM122: + 1287 0510 1D8A std Y+21,__zero_reg__ + 1288 .LSM123: + 1289 0512 81E0 ldi r24,lo8(1) + 1290 0514 90E0 ldi r25,hi8(1) + 1291 0516 A0E0 ldi r26,hlo8(1) + 1292 0518 B0E0 ldi r27,hhi8(1) + 1293 051a 8483 std Z+4,r24 + 1294 051c 9583 std Z+5,r25 + 1295 051e A683 std Z+6,r26 + 1296 0520 B783 std Z+7,r27 + 1297 .L62: + 1298 .LBB106: + 1299 .LBB107: + 1300 .LSM124: + 1301 0522 8091 E800 lds r24,232 + 1302 0526 877F andi r24,lo8(-9) + 1303 0528 8093 E800 sts 232,r24 + 1304 .LBE107: + 1305 .LBE106: + 1306 .LSM125: + 1307 052c F801 movw r30,r16 + 1308 052e 6481 ldd r22,Z+4 + 1309 0530 7581 ldd r23,Z+5 + 1310 0532 CE01 movw r24,r28 + 1311 0534 4596 adiw r24,21 + 1312 0536 0E94 0000 call Endpoint_Write_Control_Stream_LE + 1313 .LBB108: + 1314 .LBB109: + 1315 .LSM126: + 1316 053a 8091 E800 lds r24,232 + 1317 053e 8B77 andi r24,lo8(123) + 1318 0540 8093 E800 sts 232,r24 + 1319 .LBE109: + 1320 .LBE108: + 1321 .LSM127: + 1322 0544 F801 movw r30,r16 + 1323 0546 1482 std Z+4,__zero_reg__ + 1324 0548 1582 std Z+5,__zero_reg__ + 1325 054a 1682 std Z+6,__zero_reg__ + 1326 054c 1782 std Z+7,__zero_reg__ + 1327 054e 00C0 rjmp .L63 + 1328 .LVL48: + 1329 .L55: + 1330 .LBE105: + 1331 .LBB110: + 1332 .LBB104: + 1333 .LBB103: + 1334 .LSM128: + 1335 0550 F801 movw r30,r16 + 1336 0552 1486 std Z+12,__zero_reg__ + 1337 0554 1586 std Z+13,__zero_reg__ + 1338 0556 1686 std Z+14,__zero_reg__ + 1339 0558 1786 std Z+15,__zero_reg__ + 1340 .LSM129: + 1341 055a CE01 movw r24,r28 + 1342 055c A0E0 ldi r26,lo8(0) + 1343 055e B0E0 ldi r27,hi8(0) + 1344 0560 2481 ldd r18,Z+4 + 1345 0562 3581 ldd r19,Z+5 + 1346 0564 4681 ldd r20,Z+6 + 1347 0566 5781 ldd r21,Z+7 + 1348 .LVL49: + 1349 0568 280F add r18,r24 + 1350 056a 391F adc r19,r25 + 1351 056c 4A1F adc r20,r26 + 1352 056e 5B1F adc r21,r27 + 1353 0570 2483 std Z+4,r18 + 1354 0572 3583 std Z+5,r19 + 1355 0574 4683 std Z+6,r20 + 1356 0576 5783 std Z+7,r21 + 1357 .LSM130: + 1358 0578 808B std Z+16,r24 + 1359 057a 918B std Z+17,r25 + 1360 057c A28B std Z+18,r26 + 1361 057e B38B std Z+19,r27 + 1362 .LSM131: + 1363 0580 80E1 ldi r24,lo8(16) + 1364 0582 90E0 ldi r25,hi8(16) + 1365 0584 A0E0 ldi r26,hlo8(16) + 1366 0586 B0E0 ldi r27,hhi8(16) + 1367 0588 848B std Z+20,r24 + 1368 058a 958B std Z+21,r25 + 1369 058c A68B std Z+22,r26 + 1370 058e B78B std Z+23,r27 + 1371 .LVL50: + 1372 .L63: + 1373 /* epilogue start */ + 1374 .LBE103: + 1375 .LBE104: + 1376 .LBE110: + 1377 .LSM132: + 1378 0590 DF91 pop r29 + 1379 0592 CF91 pop r28 + 1380 .LVL51: + 1381 0594 1F91 pop r17 + 1382 0596 0F91 pop r16 + 1383 .LVL52: + 1384 0598 FF90 pop r15 + 1385 059a EF90 pop r14 + 1386 .LVL53: + 1387 059c 0895 ret + 1388 .LFE81: + 1390 .data + 1393 C.9.3485: + 1394 0000 A1 .byte -95 + 1395 0001 01 .byte 1 + 1396 0002 0000 .word 0 + 1397 0004 0000 .word 0 + 1398 0006 0000 .word 0 + 1399 .section .progmem.data,"a",@progbits + 1402 AdapterSupportedOIDList: + 1403 0000 01 .byte 1 + 1404 0001 01 .byte 1 + 1405 0002 01 .byte 1 + 1406 0003 00 .byte 0 + 1407 0004 02 .byte 2 + 1408 0005 02 .byte 2 + 1409 0006 01 .byte 1 + 1410 0007 00 .byte 0 + 1411 0008 02 .byte 2 + 1412 0009 01 .byte 1 + 1413 000a 01 .byte 1 + 1414 000b 00 .byte 0 + 1415 000c 03 .byte 3 + 1416 000d 01 .byte 1 + 1417 000e 01 .byte 1 + 1418 000f 00 .byte 0 + 1419 0010 04 .byte 4 + 1420 0011 01 .byte 1 + 1421 0012 01 .byte 1 + 1422 0013 00 .byte 0 + 1423 0014 06 .byte 6 + 1424 0015 01 .byte 1 + 1425 0016 01 .byte 1 + 1426 0017 00 .byte 0 + 1427 0018 11 .byte 17 + 1428 0019 01 .byte 1 + 1429 001a 01 .byte 1 + 1430 001b 00 .byte 0 + 1431 001c 07 .byte 7 + 1432 001d 01 .byte 1 + 1433 001e 01 .byte 1 + 1434 001f 00 .byte 0 + 1435 0020 0A .byte 10 + 1436 0021 01 .byte 1 + 1437 0022 01 .byte 1 + 1438 0023 00 .byte 0 + 1439 0024 0B .byte 11 + 1440 0025 01 .byte 1 + 1441 0026 01 .byte 1 + 1442 0027 00 .byte 0 + 1443 0028 0C .byte 12 + 1444 0029 01 .byte 1 + 1445 002a 01 .byte 1 + 1446 002b 00 .byte 0 + 1447 002c 0D .byte 13 + 1448 002d 01 .byte 1 + 1449 002e 01 .byte 1 + 1450 002f 00 .byte 0 + 1451 0030 0E .byte 14 + 1452 0031 01 .byte 1 + 1453 0032 01 .byte 1 + 1454 0033 00 .byte 0 + 1455 0034 11 .byte 17 + 1456 0035 01 .byte 1 + 1457 0036 01 .byte 1 + 1458 0037 00 .byte 0 + 1459 0038 14 .byte 20 + 1460 0039 01 .byte 1 + 1461 003a 01 .byte 1 + 1462 003b 00 .byte 0 + 1463 003c 01 .byte 1 + 1464 003d 01 .byte 1 + 1465 003e 02 .byte 2 + 1466 003f 00 .byte 0 + 1467 0040 02 .byte 2 + 1468 0041 01 .byte 1 + 1469 0042 02 .byte 2 + 1470 0043 00 .byte 0 + 1471 0044 03 .byte 3 + 1472 0045 01 .byte 1 + 1473 0046 02 .byte 2 + 1474 0047 00 .byte 0 + 1475 0048 04 .byte 4 + 1476 0049 01 .byte 1 + 1477 004a 02 .byte 2 + 1478 004b 00 .byte 0 + 1479 004c 05 .byte 5 + 1480 004d 01 .byte 1 + 1481 004e 02 .byte 2 + 1482 004f 00 .byte 0 + 1483 0050 01 .byte 1 + 1484 0051 01 .byte 1 + 1485 0052 01 .byte 1 + 1486 0053 01 .byte 1 + 1487 0054 02 .byte 2 + 1488 0055 01 .byte 1 + 1489 0056 01 .byte 1 + 1490 0057 01 .byte 1 + 1491 0058 03 .byte 3 + 1492 0059 01 .byte 1 + 1493 005a 01 .byte 1 + 1494 005b 01 .byte 1 + 1495 005c 04 .byte 4 + 1496 005d 01 .byte 1 + 1497 005e 01 .byte 1 + 1498 005f 01 .byte 1 + 1499 0060 01 .byte 1 + 1500 0061 01 .byte 1 + 1501 0062 02 .byte 2 + 1502 0063 01 .byte 1 + 1503 0064 02 .byte 2 + 1504 0065 01 .byte 1 + 1505 0066 02 .byte 2 + 1506 0067 01 .byte 1 + 1507 0068 03 .byte 3 + 1508 0069 01 .byte 1 + 1509 006a 02 .byte 2 + 1510 006b 01 .byte 1 + 1551 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 RNDIS.c + /tmp/ccEJ1rts.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccEJ1rts.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccEJ1rts.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccEJ1rts.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccEJ1rts.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccEJ1rts.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccEJ1rts.s:19 .text.RNDIS_Device_USBTask:0000000000000000 RNDIS_Device_USBTask + /tmp/ccEJ1rts.s:1393 .data:0000000000000000 C.9.3485 + /tmp/ccEJ1rts.s:347 .text.RNDIS_Device_ConfigureEndpoints:0000000000000000 RNDIS_Device_ConfigureEndpoints + /tmp/ccEJ1rts.s:497 .text.RNDIS_Device_ProcessControlRequest:0000000000000000 RNDIS_Device_ProcessControlRequest + /tmp/ccEJ1rts.s:1402 .progmem.data:0000000000000000 AdapterSupportedOIDList + +UNDEFINED SYMBOLS +USB_DeviceState +Endpoint_Write_Stream_LE +Endpoint_Read_Stream_LE +Endpoint_ConfigureEndpoint_Prv +USB_ControlRequest +Endpoint_Read_Control_Stream_LE +memcpy_P +memcpy +Endpoint_Write_Control_Stream_LE +__do_copy_data diff --git a/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.o b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.o new file mode 100644 index 0000000..f525cda Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Device/RNDIS.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/HID.h b/firmware/LUFA/Drivers/USB/Class/HID.h new file mode 100644 index 0000000..7748f44 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/HID.h @@ -0,0 +1,81 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 HID Class driver. + * + * Master include file for the library USB HID 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_USBClassHID HID 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/HID.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/HID.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/HIDParser.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Module Description + * HID Class Driver module. This module contains an internal implementation of the USB HID Class, for both Device + * and Host USB modes. User applications can use this class driver instead of implementing the HID 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 HID Class. + * + * @{ + */ + +#ifndef _HID_CLASS_H_ +#define _HID_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_HID_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/HID.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/HID.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/CDC.c b/firmware/LUFA/Drivers/USB/Class/Host/CDC.c new file mode 100644 index 0000000..afa4629 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/CDC.c @@ -0,0 +1,465 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_CDC_DRIVER +#define __INCLUDE_FROM_CDC_HOST_C +#include "CDC.h" + +uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Endpoint_t* NotificationEndpoint = NULL; + USB_Descriptor_Interface_t* CDCControlInterface = NULL; + + memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return CDC_ENUMERROR_InvalidConfigDescriptor; + + while (!(DataINEndpoint) || !(DataOUTEndpoint) || !(NotificationEndpoint)) + { + if (!(CDCControlInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_CDC_Host_NextCDCInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (NotificationEndpoint) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return CDC_ENUMERROR_NoCompatibleInterfaceFound; + } + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + } + else + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return CDC_ENUMERROR_NoCompatibleInterfaceFound; + } + + CDCControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + NotificationEndpoint = NULL; + } + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + { + if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) + NotificationEndpoint = EndpointData; + else + DataINEndpoint = EndpointData; + } + else + { + DataOUTEndpoint = EndpointData; + } + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + CDCInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + CDCInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + } + else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, + NotificationEndpoint->EndpointAddress, NotificationEndpoint->EndpointSize, + CDCInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + Pipe_SetInterruptPeriod(NotificationEndpoint->PollingIntervalMS); + + CDCInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize; + } + } + + CDCInterfaceInfo->State.ControlInterfaceNumber = CDCControlInterface->InterfaceNumber; + CDCInterfaceInfo->State.ControlLineStates.HostToDevice = (CDC_CONTROL_LINE_OUT_RTS | CDC_CONTROL_LINE_OUT_DTR); + CDCInterfaceInfo->State.ControlLineStates.DeviceToHost = (CDC_CONTROL_LINE_IN_DCD | CDC_CONTROL_LINE_IN_DSR); + CDCInterfaceInfo->State.IsActive = true; + + return CDC_ENUMERROR_NoError; +} + +static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == CDC_CSCP_CDCClass) && + (Interface->SubClass == CDC_CSCP_ACMSubclass) && + (Interface->Protocol == CDC_CSCP_ATCommandProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == CDC_CSCP_CDCDataClass) && + (Interface->SubClass == CDC_CSCP_NoDataSubclass) && + (Interface->Protocol == CDC_CSCP_NoDataProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK); + + if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) && + !(Pipe_IsEndpointBound(Endpoint->EndpointAddress))) + { + return DESCRIPTOR_SEARCH_Found; + } + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + USB_Request_Header_t Notification; + Pipe_Read_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NO_STREAM_CALLBACK); + + if ((Notification.bRequest == CDC_NOTIF_SerialState) && + (Notification.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))) + { + Pipe_Read_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost, + sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), + NO_STREAM_CALLBACK); + + Pipe_ClearIN(); + + EVENT_CDC_Host_ControLineStateChanged(CDCInterfaceInfo); + } + else + { + Pipe_ClearIN(); + } + } + + Pipe_Freeze(); + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + CDC_Host_Flush(CDCInterfaceInfo); + #endif +} + +uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = CDC_REQ_SetLineEncoding, + .wValue = 0, + .wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber, + .wLength = sizeof(CDCInterfaceInfo->State.LineEncoding), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(&CDCInterfaceInfo->State.LineEncoding); +} + +uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = CDC_REQ_SetControlLineState, + .wValue = CDCInterfaceInfo->State.ControlLineStates.HostToDevice, + .wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const uint8_t Duration) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = CDC_REQ_SendBreak, + .wValue = Duration, + .wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const char* const Data, + const uint16_t Length) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + + Pipe_Unfreeze(); + ErrorCode = Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK); + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const uint8_t Data) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + } + + Pipe_Write_Byte(Data); + Pipe_Freeze(); + + return PIPE_READYWAIT_NoError; +} + +uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return 0; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (!(Pipe_BytesInPipe())) + { + Pipe_ClearIN(); + Pipe_Freeze(); + return 0; + } + else + { + Pipe_Freeze(); + return Pipe_BytesInPipe(); + } + } + else + { + Pipe_Freeze(); + + return 0; + } +} + +int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return -1; + + int16_t ReceivedByte = -1; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + ReceivedByte = Pipe_Read_Byte(); + + if (!(Pipe_BytesInPipe())) + Pipe_ClearIN(); + } + + Pipe_Freeze(); + + return ReceivedByte; +} + +uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (!(Pipe_BytesInPipe())) + return PIPE_READYWAIT_NoError; + + bool BankFull = !(Pipe_IsReadWriteAllowed()); + + Pipe_ClearOUT(); + + if (BankFull) + { + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + } + + Pipe_Freeze(); + + return PIPE_READYWAIT_NoError; +} + +void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Host_putchar, CDC_Host_getchar, _FDEV_SETUP_RW); + fdev_set_udata(Stream, CDCInterfaceInfo); +} + +void CDC_Host_CreateBlockingStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Host_putchar, CDC_Host_getchar_Blocking, _FDEV_SETUP_RW); + fdev_set_udata(Stream, CDCInterfaceInfo); +} + +static int CDC_Host_putchar(char c, + FILE* Stream) +{ + return CDC_Host_SendByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0; +} + +static int CDC_Host_getchar(FILE* Stream) +{ + int16_t ReceivedByte = CDC_Host_ReceiveByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream)); + + if (ReceivedByte < 0) + return _FDEV_EOF; + + return ReceivedByte; +} + +static int CDC_Host_getchar_Blocking(FILE* Stream) +{ + int16_t ReceivedByte; + + while ((ReceivedByte = CDC_Host_ReceiveByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream))) < 0) + { + if (USB_HostState == HOST_STATE_Unattached) + return _FDEV_EOF; + + CDC_Host_USBTask((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream)); + USB_USBTask(); + } + + return ReceivedByte; +} + +void CDC_Host_Event_Stub(void) +{ + +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/CDC.h b/firmware/LUFA/Drivers/USB/Class/Host/CDC.h new file mode 100644 index 0000000..4128fe1 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/CDC.h @@ -0,0 +1,334 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB CDC Class driver. + * + * Host 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_USBClassCDCHost CDC Class Host 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/Host/CDC.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the CDC USB Class driver. + * + * @{ + */ + +#ifndef __CDC_CLASS_HOST_H__ +#define __CDC_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/CDC.h" + + #include + #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 + + #if defined(__INCLUDE_FROM_CDC_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief CDC Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made 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 + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the CDC interface's IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the CDC interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the CDC interface's OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the CDC interface's OUT data pipe should use double banking. */ + + uint8_t NotificationPipeNumber; /**< Pipe number of the CDC interface's IN notification endpoint, if used. */ + bool NotificationPipeDoubleBank; /**< Indicates if the CDC interface's notification pipe 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref CDC_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the CDC interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe. */ + uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification pipe, if used. */ + + struct + { + uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_* + * masks - to notify the device of changes to these values, call the + * \ref CDC_Host_SendControlLineStateChange() function. + */ + uint8_t DeviceToHost; /**< Control line states from the device to host, as a set of CDC_CONTROL_LINE_IN_* + * masks. This value is updated each time \ref CDC_Host_USBTask() is called. + */ + } 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. When set by the host application, the + * \ref CDC_Host_SetLineEncoding() function must be called to push the changes + * to the device. + */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_CDC_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref CDC_Host_ConfigurePipes() function. */ + enum CDC_Host_EnumerationFailure_ErrorCodes_t + { + CDC_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + CDC_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + CDC_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */ + }; + + /* Function Prototypes: */ + /** General management task for a given CDC host 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 an CDC Class host configuration and state. + */ + void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Host interface configuration routine, to configure a given CDC host interface instance using the Configuration + * Descriptor read from an attached USB device. This function automatically updates the given CDC Host instance's + * state values and configures the pipes required to communicate with the interface if it is found within the device. + * This should be called once after the stack has enumerated the attached device, while the host state machine is in + * the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref CDC_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Sets the line encoding for the attached device's virtual serial port. This should be called when the LineEncoding + * values of the interface have been changed to push the new settings to the USB device. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a Serial Control Line State Change notification to the device. This should be called when the virtual serial + * control lines (DTR, RTS, etc.) have changed states. Line states persist until they are cleared via a second + * notification. This should be called each time the CDC class driver's ControlLineStates.HostToDevice value is updated + * to push the new states to the USB device. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a Send Break request to the device. This is generally used to separate data data or to indicate a special condition + * to the receiving device. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * \param[in] Duration Duration of the break, in milliseconds. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a given string to the attached USB device, if connected. If a device is not connected when the function is called, the + * string is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the + * \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single pipe packet, increasing data throughput. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * \param[in] Data Pointer to the string to send to the device. + * \param[in] Length Size in bytes of the string to send to the device. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const char* const Data, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the + * byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the + * \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single pipe packet, increasing data throughput. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * \param[in] Data Byte of data to send to the device. + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_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 device, waiting to be read. This indicates the number + * of bytes in the IN pipe bank only, and thus the number of calls to \ref CDC_Host_ReceiveByte() which are guaranteed to succeed + * immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be + * released back to the USB controller until all bytes are read. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * + * \return Total number of buffered bytes received from the device. + */ + uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function + * returns a negative value. The \ref CDC_Host_BytesReceived() function may be queried in advance to determine how many bytes + * are currently buffered in the CDC interface's data receive pipe. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * + * \return Next received byte from the device, or a negative value if no data received. + */ + int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_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 Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_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 avr-libc library that accept a FILE stream as a destination (e.g. fprintf). The created + * stream is bidirectional and can be used for both input and output functions. + * + * \note The created stream can be given as stdout if desired to direct the standard output from all functions + * to the given CDC interface. + * + * \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_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + FILE* const Stream); + + /** Identical to CDC_Host_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. + * + * \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_Host_CreateBlockingStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + FILE* const Stream); + + /** CDC class driver event for a control line state change on a CDC host interface. This event fires each time the device notifies + * the host of a control line state change (containing the virtual serial control line states, such as DCD) 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 ControlLineStates.DeviceToHost value inside the CDC host interface structure passed as a parameter, set as + * a mask of CDC_CONTROL_LINE_IN_* masks. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state. + */ + void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_CDC_HOST_C) + static int CDC_Host_putchar(char c, + FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); + static int CDC_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + static int CDC_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + + void CDC_Host_Event_Stub(void); + void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) + ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Host_Event_Stub); + + static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/CDC.lst b/firmware/LUFA/Drivers/USB/Class/Host/CDC.lst new file mode 100644 index 0000000..5243ec9 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/CDC.lst @@ -0,0 +1,19 @@ + 1 .file "CDC.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 CDC.c + /tmp/cck4n38w.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cck4n38w.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cck4n38w.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cck4n38w.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cck4n38w.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cck4n38w.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/CDC.o b/firmware/LUFA/Drivers/USB/Class/Host/CDC.o new file mode 100644 index 0000000..c1333af Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/CDC.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HID.c b/firmware/LUFA/Drivers/USB/Class/Host/HID.c new file mode 100644 index 0000000..7343631 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HID.c @@ -0,0 +1,387 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HID_DRIVER +#define __INCLUDE_FROM_HID_HOST_C +#include "HID.h" + +uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Interface_t* HIDInterface = NULL; + USB_HID_Descriptor_HID_t* HIDDescriptor = NULL; + + memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return HID_ENUMERROR_InvalidConfigDescriptor; + + while (!(DataINEndpoint) || !(DataOUTEndpoint)) + { + if (!(HIDInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (DataINEndpoint || DataOUTEndpoint) + break; + + do + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return HID_ENUMERROR_NoCompatibleInterfaceFound; + } + + HIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + } while (HIDInterfaceInfo->Config.HIDInterfaceProtocol && + (HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol)); + + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_HID_Host_NextHID) != DESCRIPTOR_SEARCH_COMP_Found) + { + return HID_ENUMERROR_NoCompatibleInterfaceFound; + } + + HIDDescriptor = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_HID_Descriptor_HID_t); + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + HIDInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS); + + HIDInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == HIDInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + HIDInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + Pipe_SetInterruptPeriod(DataOUTEndpoint->PollingIntervalMS); + + HIDInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + HIDInterfaceInfo->State.DeviceUsesOUTPipe = true; + } + } + + HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber; + HIDInterfaceInfo->State.HIDReportSize = HIDDescriptor->HIDReportLength; + HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol); + HIDInterfaceInfo->State.LargestReportSize = 8; + HIDInterfaceInfo->State.IsActive = true; + + return HID_ENUMERROR_NoError; +} + +static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if (Interface->Class == HID_CSCP_HIDClass) + return DESCRIPTOR_SEARCH_Found; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == HID_DTYPE_HID) + return DESCRIPTOR_SEARCH_Found; + else if (Header->Type == DTYPE_Interface) + return DESCRIPTOR_SEARCH_Fail; + else + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + if (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))) + return DESCRIPTOR_SEARCH_Found; + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) +uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + const uint8_t ReportID, + void* Buffer) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = HID_REQ_SetReport, + .wValue = ((HID_REPORT_ITEM_In + 1) << 8) | ReportID, + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Buffer); +} +#endif + +uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + void* Buffer) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + uint16_t ReportSize; + uint8_t* BufferPos = Buffer; + +#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + if (!(HIDInterfaceInfo->State.UsingBootProtocol)) + { + uint8_t ReportID = 0; + + if (HIDInterfaceInfo->Config.HIDParserData->UsingReportIDs) + { + ReportID = Pipe_Read_Byte(); + *(BufferPos++) = ReportID; + } + + ReportSize = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In); + } + else +#endif + { + ReportSize = Pipe_BytesInPipe(); + } + + if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearIN(); + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, +#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + const uint8_t ReportID, +#endif + const uint8_t ReportType, + void* Buffer, + const uint16_t ReportSize) +{ +#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) + return false; + + if (HIDInterfaceInfo->State.DeviceUsesOUTPipe && (ReportType == HID_REPORT_ITEM_Out)) + { + uint8_t ErrorCode; + + Pipe_SelectPipe(HIDInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (ReportID) + Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NO_STREAM_CALLBACK); + + if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; + } + else +#endif + { + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = HID_REQ_SetReport, +#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + .wValue = ((ReportType + 1) << 8) | ReportID, +#else + .wValue = ((ReportType + 1) << 8), +#endif + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = ReportSize, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Buffer); + } +} + +bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive)) + return false; + + bool ReportReceived; + + Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + ReportReceived = Pipe_IsINReceived(); + + Pipe_Freeze(); + + return ReportReceived; +} + +uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) +{ + uint8_t ErrorCode; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = HID_REQ_SetProtocol, + .wValue = 0, + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if (!(HIDInterfaceInfo->State.SupportsBootProtocol)) + return HID_ERROR_LOGICAL; + + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + HIDInterfaceInfo->State.LargestReportSize = 8; + HIDInterfaceInfo->State.UsingBootProtocol = true; + + return HOST_SENDCONTROL_Successful; +} + +#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) +uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) +{ + uint8_t ErrorCode; + + uint8_t HIDReportData[HIDInterfaceInfo->State.HIDReportSize]; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_GetDescriptor, + .wValue = (HID_DTYPE_Report << 8), + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = HIDInterfaceInfo->State.HIDReportSize, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(HIDReportData)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + if (HIDInterfaceInfo->State.UsingBootProtocol) + { + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = HID_REQ_SetProtocol, + .wValue = 1, + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + HIDInterfaceInfo->State.UsingBootProtocol = false; + } + + if (HIDInterfaceInfo->Config.HIDParserData == NULL) + return HID_ERROR_LOGICAL; + + if ((ErrorCode = USB_ProcessHIDReport(HIDReportData, HIDInterfaceInfo->State.HIDReportSize, + HIDInterfaceInfo->Config.HIDParserData)) != HID_PARSE_Successful) + { + return HID_ERROR_LOGICAL | ErrorCode; + } + + uint8_t LargestReportSizeBits = HIDInterfaceInfo->Config.HIDParserData->LargestReportSizeBits; + HIDInterfaceInfo->State.LargestReportSize = (LargestReportSizeBits >> 3) + ((LargestReportSizeBits & 0x07) != 0); + + return 0; +} +#endif + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HID.h b/firmware/LUFA/Drivers/USB/Class/Host/HID.h new file mode 100644 index 0000000..2d6fd9e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HID.h @@ -0,0 +1,316 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB HID Class driver. + * + * Host mode driver for the library USB HID 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_USBClassHID + * @defgroup Group_USBClassHIDHost HID Class Host 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/Host/HID.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/HIDParser.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the HID USB Class driver. + * + * @{ + */ + +#ifndef __HID_CLASS_HOST_H__ +#define __HID_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/HID.h" + #include "HIDParser.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_HID_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_HID_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Error code for some HID Host functions, indicating a logical (and not hardware) error. */ + #define HID_ERROR_LOGICAL 0x80 + + /* Type Defines: */ + /** \brief HID Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made within the user application, + * and passed to each of the HID class driver functions as the HIDInterfaceInfo parameter. This + * stores each HID interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the HID interface's IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the HID interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the HID interface's OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the HID interface's OUT data pipe should use double banking. */ + + uint8_t HIDInterfaceProtocol; /**< HID interface protocol value to match against if a specific + * boot subclass protocol is required, a protocol value from the + * \ref HID_Descriptor_ClassSubclassProtocol_t enum. + */ + #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + HID_ReportInfo_t* HIDParserData; /**< HID parser data to store the parsed HID report data, when boot protocol + * is not used. + * + * \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, + * this method is unavailable. + */ + #endif + } 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the HID interface's OUT data pipe. */ + + bool SupportsBootProtocol; /**< Indicates if the current interface instance supports the HID Boot + * Protocol when enabled via \ref HID_Host_SetBootProtocol(). + */ + bool DeviceUsesOUTPipe; /**< Indicates if the current interface instance uses a separate OUT data pipe for + * OUT reports, or if OUT reports are sent via the control pipe instead. + */ + bool UsingBootProtocol; /**< Indicates that the interface is currently initialized in Boot Protocol mode */ + uint16_t HIDReportSize; /**< Size in bytes of the HID report descriptor in the device. */ + + uint8_t LargestReportSize; /**< Largest report the device will send, in bytes. */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_HID_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref HID_Host_ConfigurePipes() function. */ + enum HID_Host_EnumerationFailure_ErrorCodes_t + { + HID_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + HID_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + HID_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor. */ + }; + + /* Function Prototypes: */ + /** Host interface configuration routine, to configure a given HID host interface instance using the Configuration + * Descriptor read from an attached USB device. This function automatically updates the given HID Host instance's + * state values and configures the pipes required to communicate with the interface if it is found within the + * device. This should be called once after the stack has enumerated the attached device, while the host state + * machine is in the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * \n\n + * + * \note Once the device pipes are configured, the HID device's reporting protocol must be set via a call + * to either the \ref HID_Host_SetBootProtocol() or \ref HID_Host_SetReportProtocol() function. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref HID_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + + /** Receives a HID IN report from the attached HID device, when a report has been received on the HID IN Data pipe. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \note The destination buffer should be large enough to accommodate the largest report that the attached device + * can generate. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * \param[in] Buffer Buffer to store the received report into. + * + * \return An error code from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + void* Buffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + /** Receives a HID IN report from the attached device, by the report ID. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * \param[in] ReportID Report ID of the received report if ControlRequest is false, set by the to the Report ID to fetch. + * \param[in] Buffer Buffer to store the received report into. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + const uint8_t ReportID, + void* Buffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + #endif + + /** Sends an OUT or FEATURE report to the currently attached HID device, using the device's OUT pipe if available, + * or the device's Control pipe if not. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, the ReportID parameter is removed + * from the parameter list of this function. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * \param[in] ReportID Report ID of the report to send to the device, or 0 if the device does not use report IDs. + * \param[in] ReportType Type of report to issue to the device, either \ref HID_REPORT_ITEM_Out or \ref HID_REPORT_ITEM_Feature. + * \param[in] Buffer Buffer containing the report to send to the attached device. + * \param[in] ReportSize Report size in bytes to send to the attached device. + * + * \return An error code from the \ref USB_Host_SendControlErrorCodes_t enum if the DeviceUsesOUTPipe flag is set in + * the interface's state structure, a value from the \ref Pipe_Stream_RW_ErrorCodes_t enum otherwise. + */ + uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + const uint8_t ReportID, + #endif + const uint8_t ReportType, + void* Buffer, + const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1) + #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + ATTR_NON_NULL_PTR_ARG(4); + #else + ATTR_NON_NULL_PTR_ARG(3); + #endif + + /** Determines if a HID IN report has been received from the attached device on the data IN pipe. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * + * \return Boolean true if a report has been received, false otherwise. + */ + bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Switches the attached HID device's reporting protocol over to the Boot Report protocol mode, on supported devices. + * + * \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method must still be called + * to explicitly place the attached device into boot protocol mode before use. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * + * \return \ref HID_ERROR_LOGICAL if the device does not support Boot Protocol mode, a value from the + * \ref USB_Host_SendControlErrorCodes_t enum otherwise. + */ + uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY) + /** Switches the attached HID device's reporting protocol over to the standard Report protocol mode. This also retrieves + * and parses the device's HID report descriptor, so that the size of each report can be determined in advance. + * + * \note Whether this function is used or not, the \ref CALLBACK_HIDParser_FilterHIDReportItem() callback from the HID + * Report Parser this function references must be implemented in the user code. + * \n\n + * + * \note When the HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum if an error occurs while retrieving the HID + * Report descriptor or the setting of the Report protocol, \ref HID_ERROR_LOGICAL if the HID interface does + * not have a valid \ref HID_ReportInfo_t structure set in its configuration, a mask of \ref HID_ERROR_LOGICAL + * and a value from the \ref HID_Parse_ErrorCodes_t otherwise. + */ + uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + #endif + + /* Inline Functions: */ + /** General management task for a given Human Interface Class host 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] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + */ + static inline void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo); + static inline void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) + { + (void)HIDInterfaceInfo; + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_HID_HOST_C) + static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_HID_Host_NextHID(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HID.lst b/firmware/LUFA/Drivers/USB/Class/Host/HID.lst new file mode 100644 index 0000000..ac15d24 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HID.lst @@ -0,0 +1,19 @@ + 1 .file "HID.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 HID.c + /tmp/ccOMFwTz.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccOMFwTz.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccOMFwTz.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccOMFwTz.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccOMFwTz.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccOMFwTz.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HID.o b/firmware/LUFA/Drivers/USB/Class/Host/HID.o new file mode 100644 index 0000000..ab0765d Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/HID.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.c b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.c new file mode 100644 index 0000000..f0e7db8 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.c @@ -0,0 +1,361 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HID_DRIVER +#include "HIDParser.h" + +uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, + uint16_t ReportSize, + HID_ReportInfo_t* const ParserData) +{ + HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH]; + HID_StateTable_t* CurrStateTable = &StateTable[0]; + HID_CollectionPath_t* CurrCollectionPath = NULL; + HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0]; + uint16_t UsageList[HID_USAGE_STACK_DEPTH]; + uint8_t UsageListSize = 0; + HID_MinMax_t UsageMinMax = {0, 0}; + + memset(ParserData, 0x00, sizeof(HID_ReportInfo_t)); + memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t)); + memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t)); + + ParserData->TotalDeviceReports = 1; + + while (ReportSize) + { + uint8_t HIDReportItem = *ReportData; + uint32_t ReportItemData = 0; + + ReportData++; + ReportSize--; + + switch (HIDReportItem & DATA_SIZE_MASK) + { + case DATA_SIZE_4: + ReportItemData = *((uint32_t*)ReportData); + ReportSize -= 4; + ReportData += 4; + break; + case DATA_SIZE_2: + ReportItemData = *((uint16_t*)ReportData); + ReportSize -= 2; + ReportData += 2; + break; + case DATA_SIZE_1: + ReportItemData = *((uint8_t*)ReportData); + ReportSize -= 1; + ReportData += 1; + break; + } + + switch (HIDReportItem & (TYPE_MASK | TAG_MASK)) + { + case (TYPE_GLOBAL | TAG_GLOBAL_PUSH): + if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1]) + return HID_PARSE_HIDStackOverflow; + + memcpy((CurrStateTable + 1), + CurrStateTable, + sizeof(HID_ReportItem_t)); + + CurrStateTable++; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_POP): + if (CurrStateTable == &StateTable[0]) + return HID_PARSE_HIDStackUnderflow; + + CurrStateTable--; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE): + CurrStateTable->Attributes.Usage.Page = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN): + CurrStateTable->Attributes.Logical.Minimum = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX): + CurrStateTable->Attributes.Logical.Maximum = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN): + CurrStateTable->Attributes.Physical.Minimum = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX): + CurrStateTable->Attributes.Physical.Maximum = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP): + CurrStateTable->Attributes.Unit.Exponent = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_UNIT): + CurrStateTable->Attributes.Unit.Type = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE): + CurrStateTable->Attributes.BitSize = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT): + CurrStateTable->ReportCount = ReportItemData; + break; + case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID): + CurrStateTable->ReportID = ReportItemData; + + if (ParserData->UsingReportIDs) + { + CurrReportIDInfo = NULL; + + for (uint8_t i = 0; i < ParserData->TotalDeviceReports; i++) + { + if (ParserData->ReportIDSizes[i].ReportID == CurrStateTable->ReportID) + { + CurrReportIDInfo = &ParserData->ReportIDSizes[i]; + break; + } + } + + if (CurrReportIDInfo == NULL) + { + if (ParserData->TotalDeviceReports == HID_MAX_REPORT_IDS) + return HID_PARSE_InsufficientReportIDItems; + + CurrReportIDInfo = &ParserData->ReportIDSizes[ParserData->TotalDeviceReports++]; + memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t)); + } + } + + ParserData->UsingReportIDs = true; + + CurrReportIDInfo->ReportID = CurrStateTable->ReportID; + break; + case (TYPE_LOCAL | TAG_LOCAL_USAGE): + if (UsageListSize == HID_USAGE_STACK_DEPTH) + return HID_PARSE_UsageListOverflow; + + UsageList[UsageListSize++] = ReportItemData; + break; + case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN): + UsageMinMax.Minimum = ReportItemData; + break; + case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX): + UsageMinMax.Maximum = ReportItemData; + break; + case (TYPE_MAIN | TAG_MAIN_COLLECTION): + if (CurrCollectionPath == NULL) + { + CurrCollectionPath = &ParserData->CollectionPaths[0]; + } + else + { + HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath; + + CurrCollectionPath = &ParserData->CollectionPaths[1]; + + while (CurrCollectionPath->Parent != NULL) + { + if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1]) + return HID_PARSE_InsufficientCollectionPaths; + + CurrCollectionPath++; + } + + CurrCollectionPath->Parent = ParentCollectionPath; + } + + CurrCollectionPath->Type = ReportItemData; + CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page; + + if (UsageListSize) + { + CurrCollectionPath->Usage.Usage = UsageList[0]; + + for (uint8_t i = 0; i < UsageListSize; i++) + UsageList[i] = UsageList[i + 1]; + + UsageListSize--; + } + else if (UsageMinMax.Minimum <= UsageMinMax.Maximum) + { + CurrCollectionPath->Usage.Usage = UsageMinMax.Minimum++; + } + + break; + case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION): + if (CurrCollectionPath == NULL) + return HID_PARSE_UnexpectedEndCollection; + + CurrCollectionPath = CurrCollectionPath->Parent; + break; + case (TYPE_MAIN | TAG_MAIN_INPUT): + case (TYPE_MAIN | TAG_MAIN_OUTPUT): + case (TYPE_MAIN | TAG_MAIN_FEATURE): + for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++) + { + HID_ReportItem_t NewReportItem; + + memcpy(&NewReportItem.Attributes, + &CurrStateTable->Attributes, + sizeof(HID_ReportItem_Attributes_t)); + + NewReportItem.ItemFlags = ReportItemData; + NewReportItem.CollectionPath = CurrCollectionPath; + NewReportItem.ReportID = CurrStateTable->ReportID; + + if (UsageListSize) + { + NewReportItem.Attributes.Usage.Usage = UsageList[0]; + + for (uint8_t i = 0; i < UsageListSize; i++) + UsageList[i] = UsageList[i + 1]; + + UsageListSize--; + } + else if (UsageMinMax.Minimum <= UsageMinMax.Maximum) + { + NewReportItem.Attributes.Usage.Usage = UsageMinMax.Minimum++; + } + + uint8_t ItemTag = (HIDReportItem & TAG_MASK); + + if (ItemTag == TAG_MAIN_INPUT) + NewReportItem.ItemType = HID_REPORT_ITEM_In; + else if (ItemTag == TAG_MAIN_OUTPUT) + NewReportItem.ItemType = HID_REPORT_ITEM_Out; + else + NewReportItem.ItemType = HID_REPORT_ITEM_Feature; + + NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]; + + CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize; + + if (ParserData->LargestReportSizeBits < NewReportItem.BitOffset) + ParserData->LargestReportSizeBits = NewReportItem.BitOffset; + + if (!(ReportItemData & IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) + { + if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) + return HID_PARSE_InsufficientReportItems; + + memcpy(&ParserData->ReportItems[ParserData->TotalReportItems], + &NewReportItem, sizeof(HID_ReportItem_t)); + + ParserData->TotalReportItems++; + } + } + + break; + } + + if ((HIDReportItem & TYPE_MASK) == TYPE_MAIN) + { + UsageMinMax.Minimum = 0; + UsageMinMax.Maximum = 0; + UsageListSize = 0; + } + } + + if (!(ParserData->TotalReportItems)) + return HID_PARSE_NoUnfilteredReportItems; + + return HID_PARSE_Successful; +} + +bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, + HID_ReportItem_t* const ReportItem) +{ + uint16_t DataBitsRem = ReportItem->Attributes.BitSize; + uint16_t CurrentBit = ReportItem->BitOffset; + uint32_t BitMask = (1 << 0); + + if (ReportItem->ReportID) + { + if (ReportItem->ReportID != ReportData[0]) + return false; + + ReportData++; + } + + ReportItem->PreviousValue = ReportItem->Value; + ReportItem->Value = 0; + + while (DataBitsRem--) + { + if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8))) + ReportItem->Value |= BitMask; + + CurrentBit++; + BitMask <<= 1; + } + + return true; +} + +void USB_SetHIDReportItemInfo(uint8_t* ReportData, + HID_ReportItem_t* const ReportItem) +{ + uint16_t DataBitsRem = ReportItem->Attributes.BitSize; + uint16_t CurrentBit = ReportItem->BitOffset; + uint32_t BitMask = (1 << 0); + + if (ReportItem->ReportID) + { + ReportData[0] = ReportItem->ReportID; + ReportData++; + } + + ReportItem->PreviousValue = ReportItem->Value; + + while (DataBitsRem--) + { + if (ReportItem->Value & (1 << (CurrentBit % 8))) + ReportData[CurrentBit / 8] |= BitMask; + + CurrentBit++; + BitMask <<= 1; + } +} + +uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, + const uint8_t ReportID, + const uint8_t ReportType) +{ + for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++) + { + uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType]; + + if (ParserData->ReportIDSizes[i].ReportID == ReportID) + return ((ReportSizeBits >> 3) + ((ReportSizeBits & 0x07) ? 1 : 0)); + } + + return 0; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.h b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.h new file mode 100644 index 0000000..cb3b98f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.h @@ -0,0 +1,356 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Human Interface Device (HID) Class report descriptor parser. + * + * This file allows for the easy parsing of complex HID report descriptors, which describes the data that + * a HID device transmits to the host. It also provides an easy API for extracting and processing the data + * elements inside a HID report sent from an attached HID device. + */ + +/** \ingroup Group_USB + * @defgroup Group_HIDParser HID Report Parser + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Class/Host/HIDParser.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Module Description + * Functions, macros, variables, enums and types related to the parsing of HID class device report descriptors. + * + * The processed HID report is presented back to the user application as a flat structure containing each report + * item's IN, OUT and FEATURE items along with each item's attributes. + * + * This library portion also allows for easy setting and retrieval of data from a HID report, including devices + * with multiple reports on the one HID interface. + * + * @{ + */ + +#ifndef __HIDPARSER_H__ +#define __HIDPARSER_H__ + + /* Includes: */ + #include + #include + + #include "HIDReportData.h" + #include "../Common/HID.h" + + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Macros: */ + #if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__) + /** Constant indicating the maximum stack depth of the state table. A larger state table + * allows for more PUSH/POP report items to be nested, but consumes more memory. By default + * this is set to 2 levels (allowing non-nested PUSH items) but this can be overridden by + * defining HID_STATETABLE_STACK_DEPTH to another value in the user project makefile, passing the + * define to the compiler using the -D compiler switch. + */ + #define HID_STATETABLE_STACK_DEPTH 2 + #endif + + #if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__) + /** Constant indicating the maximum stack depth of the usage table. A larger usage table + * allows for more USAGE items to be indicated sequentially for REPORT COUNT entries of more than + * one, but requires more stack space. By default this is set to 8 levels (allowing for a report + * item with a count of 8) but this can be overridden by defining HID_USAGE_STACK_DEPTH to another + * value in the user project makefile, passing the define to the compiler using the -D compiler + * switch. + */ + #define HID_USAGE_STACK_DEPTH 8 + #endif + + #if !defined(HID_MAX_COLLECTIONS) || defined(__DOXYGEN__) + /** Constant indicating the maximum number of COLLECTION items (nested or unnested) that can be + * processed in the report item descriptor. A large value allows for more COLLECTION items to be + * processed, but consumes more memory. By default this is set to 10 collections, but this can be + * overridden by defining HID_MAX_COLLECTIONS to another value in the user project makefile, passing + * the define to the compiler using the -D compiler switch. + */ + #define HID_MAX_COLLECTIONS 10 + #endif + + #if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__) + /** Constant indicating the maximum number of report items (IN, OUT or FEATURE) that can be processed + * in the report item descriptor and stored in the user HID Report Info structure. A large value allows + * for more report items to be stored, but consumes more memory. By default this is set to 20 items, + * but this can be overridden by defining HID_MAX_REPORTITEMS to another value in the user project + * makefile, and passing the define to the compiler using the -D compiler switch. + */ + #define HID_MAX_REPORTITEMS 20 + #endif + + #if !defined(HID_MAX_REPORT_IDS) || defined(__DOXYGEN__) + /** Constant indicating the maximum number of unique report IDs that can be processed in the report item + * descriptor for the report size information array in the user HID Report Info structure. A large value + * allows for more report ID report sizes to be stored, but consumes more memory. By default this is set + * to 10 items, but this can be overridden by defining HID_MAX_REPORT_IDS to another value in the user project + * makefile, and passing the define to the compiler using the -D compiler switch. Note that IN, OUT and FEATURE + * items sharing the same report ID consume only one size item in the array. + */ + #define HID_MAX_REPORT_IDS 10 + #endif + + /** Returns the value a given HID report item (once its value has been fetched via \ref USB_GetHIDReportItemInfo()) + * left-aligned to the given data type. This allows for signed data to be interpreted correctly, by shifting the data + * leftwards until the data's sign bit is in the correct position. + * + * \param[in] ReportItem HID Report Item whose retrieved value is to be aligned. + * \param[in] Type Data type to align the HID report item's value to. + * + * \return Left-aligned data of the given report item's pre-retrieved value for the given datatype. + */ + #define HID_ALIGN_DATA(ReportItem, Type) ((Type)(ReportItem->Value << ((8 * sizeof(Type)) - ReportItem->Attributes.BitSize))) + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the possible error codes in the return value of the \ref USB_ProcessHIDReport() function. */ + enum HID_Parse_ErrorCodes_t + { + HID_PARSE_Successful = 0, /**< Successful parse of the HID report descriptor, no error. */ + HID_PARSE_HIDStackOverflow = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */ + HID_PARSE_HIDStackUnderflow = 2, /**< A POP was found when the state table stack was empty. */ + HID_PARSE_InsufficientReportItems = 3, /**< More than \ref HID_MAX_REPORTITEMS report items in the report. */ + HID_PARSE_UnexpectedEndCollection = 4, /**< An END COLLECTION item found without matching COLLECTION item. */ + HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */ + HID_PARSE_UsageListOverflow = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */ + HID_PARSE_InsufficientReportIDItems = 7, /**< More than \ref HID_MAX_REPORT_IDS report IDs in the device. */ + HID_PARSE_NoUnfilteredReportItems = 8, /**< All report items from the device were filtered by the filtering callback routine. */ + }; + + /* Type Defines: */ + /** \brief HID Parser Report Item Min/Max Structure. + * + * Type define for an attribute with both minimum and maximum values (e.g. Logical Min/Max). + */ + typedef struct + { + uint32_t Minimum; /**< Minimum value for the attribute. */ + uint32_t Maximum; /**< Maximum value for the attribute. */ + } HID_MinMax_t; + + /** \brief HID Parser Report Item Unit Structure. + * + * Type define for the Unit attributes of a report item. + */ + typedef struct + { + uint32_t Type; /**< Unit type (refer to HID specifications for details). */ + uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */ + } HID_Unit_t; + + /** \brief HID Parser Report Item Usage Structure. + * + * Type define for the Usage attributes of a report item. + */ + typedef struct + { + uint16_t Page; /**< Usage page of the report item. */ + uint16_t Usage; /**< Usage of the report item. */ + } HID_Usage_t; + + /** \brief HID Parser Report Item Collection Path Structure. + * + * Type define for a COLLECTION object. Contains the collection attributes and a reference to the + * parent collection if any. + */ + typedef struct CollectionPath + { + uint8_t Type; /**< Collection type (e.g. "Generic Desktop"). */ + HID_Usage_t Usage; /**< Collection usage. */ + struct CollectionPath* Parent; /**< Reference to parent collection, or NULL if root collection. */ + } HID_CollectionPath_t; + + /** \brief HID Parser Report Item Attributes Structure. + * + * Type define for all the data attributes of a report item, except flags. + */ + typedef struct + { + uint8_t BitSize; /**< Size in bits of the report item's data. */ + + HID_Usage_t Usage; /**< Usage of the report item. */ + HID_Unit_t Unit; /**< Unit type and exponent of the report item. */ + HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */ + HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */ + } HID_ReportItem_Attributes_t; + + /** \brief HID Parser Report Item Details Structure. + * + * Type define for a report item (IN, OUT or FEATURE) layout attributes and other details. + */ + typedef struct + { + uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */ + uint8_t ItemType; /**< Report item type, a value in HID_ReportItemTypes_t. */ + uint16_t ItemFlags; /**< Item data flags, such as constant/variable, etc. */ + uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */ + HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */ + + HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */ + + uint32_t Value; /**< Current value of the report item - use \ref HID_ALIGN_DATA() when processing + * a retrieved value so that it is aligned to a specific type. + */ + uint32_t PreviousValue; /**< Previous value of the report item. */ + } HID_ReportItem_t; + + /** \brief HID Parser Report Size Structure. + * + * Type define for a report item size information structure, to retain the size of a device's reports by ID. + */ + typedef struct + { + uint8_t ReportID; /**< Report ID of the report within the HID interface. */ + uint16_t ReportSizeBits[3]; /**< Total number of bits in each report type for the given Report ID, + * indexed by the \ref HID_ReportItemTypes_t enum. + */ + } HID_ReportSizeInfo_t; + + /** \brief HID Parser State Structure. + * + * Type define for a complete processed HID report, including all report item data and collections. + */ + typedef struct + { + uint8_t TotalReportItems; /**< Total number of report items stored in the + * ReportItems array. + */ + HID_ReportItem_t ReportItems[HID_MAX_REPORTITEMS]; /**< Report items array, including + * all IN, OUT and FEATURE items. + */ + HID_CollectionPath_t CollectionPaths[HID_MAX_COLLECTIONS]; /**< All collection items, referenced + * by the report items. + */ + uint8_t TotalDeviceReports; /**< Number of reports within the HID interface */ + HID_ReportSizeInfo_t ReportIDSizes[HID_MAX_REPORT_IDS]; /**< Report sizes for each report in the interface */ + uint16_t LargestReportSizeBits; /**< Largest report that the attached device will generate, in bits */ + bool UsingReportIDs; /**< Indicates if the device has at least one REPORT ID + * element in its HID report descriptor. + */ + } HID_ReportInfo_t; + + /* Function Prototypes: */ + /** Function to process a given HID report returned from an attached device, and store it into a given + * \ref HID_ReportInfo_t structure. + * + * \param[in] ReportData Buffer containing the device's HID report table. + * \param[in] ReportSize Size in bytes of the HID report table. + * \param[out] ParserData Pointer to a \ref HID_ReportInfo_t instance for the parser output. + * + * \return A value in the \ref HID_Parse_ErrorCodes_t enum. + */ + uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, + uint16_t ReportSize, + HID_ReportInfo_t* const ParserData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Extracts the given report item's value out of the given HID report and places it into the Value + * member of the report item's \ref HID_ReportItem_t structure. + * + * When called on a report with an item that exists in that report, this copies the report item's Value + * to it's PreviousValue element for easy checking to see if an item's value has changed before processing + * a report. If the given item does not exist in the report, the function does not modify the report item's + * data. + * + * \param[in] ReportData Buffer containing an IN or FEATURE report from an attached device. + * \param[in,out] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array. + * + * \returns Boolean true if the item to retrieve was located in the given report, false otherwise. + */ + bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, + HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Retrieves the given report item's value out of the Value member of the report item's + * \ref HID_ReportItem_t structure and places it into the correct position in the HID report + * buffer. The report buffer is assumed to have the appropriate bits cleared before calling + * this function (i.e., the buffer should be explicitly cleared before report values are added). + * + * When called, this copies the report item's Value element to it's PreviousValue element for easy + * checking to see if an item's value has changed before sending a report. + * + * If the device has multiple HID reports, the first byte in the report is set to the report ID of the given item. + * + * \param[out] ReportData Buffer holding the current OUT or FEATURE report data. + * \param[in] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array. + */ + void USB_SetHIDReportItemInfo(uint8_t* ReportData, + HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Retrieves the size of a given HID report in bytes from it's Report ID. + * + * \param[in] ParserData Pointer to a \ref HID_ReportInfo_t instance containing the parser output. + * \param[in] ReportID Report ID of the report whose size is to be retrieved. + * \param[in] ReportType Type of the report whose size is to be determined, a valued from the + * \ref HID_ReportItemTypes_t enum. + * + * \return Size of the report in bytes, or 0 if the report does not exist. + */ + uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData, + const uint8_t ReportID, + const uint8_t ReportType) ATTR_CONST ATTR_NON_NULL_PTR_ARG(1); + + /** Callback routine for the HID Report Parser. This callback must be implemented by the user code when + * the parser is used, to determine what report IN, OUT and FEATURE item's information is stored into the user + * HID_ReportInfo_t structure. This can be used to filter only those items the application will be using, so that + * no RAM is wasted storing the attributes for report items which will never be referenced by the application. + * + * \param[in] CurrentItem Pointer to the current report item for user checking. + * + * \return Boolean true if the item should be stored into the HID_ReportInfo_t structure, false if it should be ignored. + */ + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Type Defines: */ + typedef struct + { + HID_ReportItem_Attributes_t Attributes; + uint8_t ReportCount; + uint8_t ReportID; + } HID_StateTable_t; + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.lst b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.lst new file mode 100644 index 0000000..79add07 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.lst @@ -0,0 +1,19 @@ + 1 .file "HIDParser.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 HIDParser.c + /tmp/ccpm8Lt2.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccpm8Lt2.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccpm8Lt2.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccpm8Lt2.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccpm8Lt2.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccpm8Lt2.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.o b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.o new file mode 100644 index 0000000..da84c79 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/HIDParser.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/HIDReportData.h b/firmware/LUFA/Drivers/USB/Class/Host/HIDReportData.h new file mode 100644 index 0000000..6ce6b8a --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/HIDReportData.h @@ -0,0 +1,142 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Constants for HID report item attributes. + * + * HID report item constants for report item attributes. Refer to the HID specification for + * details on each flag's meaning when applied to an IN, OUT or FEATURE item. + */ + +/** \ingroup Group_HIDParser + * @defgroup Group_HIDIOFConst Input/Output/Feature Masks + * + * Masks indicating the type of Input, Output of Feature HID report item. + * + * @{ + */ + +#ifndef __HIDREPORTDATA_H__ +#define __HIDREPORTDATA_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \ref HID_ReportItem_t.ItemFlags flag for constant data. */ + #define IOF_CONSTANT (1 << 0) + + /** \ref HID_ReportItem_t.ItemFlags flag for data. */ + #define IOF_DATA (0 << 0) + + /** \ref HID_ReportItem_t.ItemFlags flag for variable data. */ + #define IOF_VARIABLE (1 << 1) + + /** \ref HID_ReportItem_t.ItemFlags flag for array data. */ + #define IOF_ARRAY (0 << 1) + + /** \ref HID_ReportItem_t.ItemFlags flag for relative data. */ + #define IOF_RELATIVE (1 << 2) + + /** \ref HID_ReportItem_t.ItemFlags flag for absolute data. */ + #define IOF_ABSOLUTE (0 << 2) + + /** \ref HID_ReportItem_t.ItemFlags flag for wrapped value data. */ + #define IOF_WRAP (1 << 3) + + /** \ref HID_ReportItem_t.ItemFlags flag for non-wrapped value data. */ + #define IOF_NOWRAP (0 << 3) + + /** \ref HID_ReportItem_t.ItemFlags flag for non linear data. */ + #define IOF_NONLINEAR (1 << 4) + + /** \ref HID_ReportItem_t.ItemFlags flag for linear data. */ + #define IOF_LINEAR (0 << 4) + + /** \ref HID_ReportItem_t.ItemFlags flag for no preferred state. */ + #define IOF_NOPREFERRED (1 << 5) + + /** \ref HID_ReportItem_t.ItemFlags flag for preferred state items. */ + #define IOF_PREFERREDSTATE (0 << 5) + + /** \ref HID_ReportItem_t.ItemFlags flag for null state items. */ + #define IOF_NULLSTATE (1 << 6) + + /** \ref HID_ReportItem_t.ItemFlags flag for no null position data. */ + #define IOF_NONULLPOSITION (0 << 6) + + /** \ref HID_ReportItem_t.ItemFlags flag for buffered bytes. */ + #define IOF_BUFFEREDBYTES (1 << 8) + + /** \ref HID_ReportItem_t.ItemFlags flag for bit field data. */ + #define IOF_BITFIELD (0 << 8) + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define DATA_SIZE_MASK 0x03 + #define TYPE_MASK 0x0C + #define TAG_MASK 0xF0 + + #define DATA_SIZE_0 0x00 + #define DATA_SIZE_1 0x01 + #define DATA_SIZE_2 0x02 + #define DATA_SIZE_4 0x03 + + #define TYPE_MAIN 0x00 + #define TYPE_GLOBAL 0x04 + #define TYPE_LOCAL 0x08 + + #define TAG_MAIN_INPUT 0x80 + #define TAG_MAIN_OUTPUT 0x90 + #define TAG_MAIN_COLLECTION 0xA0 + #define TAG_MAIN_FEATURE 0xB0 + #define TAG_MAIN_ENDCOLLECTION 0xC0 + + #define TAG_GLOBAL_USAGEPAGE 0x00 + #define TAG_GLOBAL_LOGICALMIN 0x10 + #define TAG_GLOBAL_LOGICALMAX 0x20 + #define TAG_GLOBAL_PHYSMIN 0x30 + #define TAG_GLOBAL_PHYSMAX 0x40 + #define TAG_GLOBAL_UNITEXP 0x50 + #define TAG_GLOBAL_UNIT 0x60 + #define TAG_GLOBAL_REPORTSIZE 0x70 + #define TAG_GLOBAL_REPORTID 0x80 + #define TAG_GLOBAL_REPORTCOUNT 0x90 + #define TAG_GLOBAL_PUSH 0xA0 + #define TAG_GLOBAL_POP 0xB0 + + #define TAG_LOCAL_USAGE 0x00 + #define TAG_LOCAL_USAGEMIN 0x10 + #define TAG_LOCAL_USAGEMAX 0x20 + #endif + +/** @} */ + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MIDI.c b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.c new file mode 100644 index 0000000..4877dbe --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.c @@ -0,0 +1,215 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_MIDI_DRIVER +#define __INCLUDE_FROM_MIDI_HOST_C +#include "MIDI.h" + +uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Interface_t* MIDIInterface = NULL; + + memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return MIDI_ENUMERROR_InvalidConfigDescriptor; + + while (!(DataINEndpoint) || !(DataOUTEndpoint)) + { + if (!(MIDIInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_MIDI_Host_NextMIDIStreamingInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return MIDI_ENUMERROR_NoCompatibleInterfaceFound; + } + + MIDIInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + MIDIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + MIDIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + MIDIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + MIDIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + } + } + + MIDIInterfaceInfo->State.InterfaceNumber = MIDIInterface->InterfaceNumber; + MIDIInterfaceInfo->State.IsActive = true; + + return MIDI_ENUMERROR_NoError; +} + +static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == AUDIO_CSCP_AudioClass) && + (Interface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) && + (Interface->Protocol == AUDIO_CSCP_StreamingProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK); + + if ((EndpointType == EP_TYPE_BULK) && !(Pipe_IsEndpointBound(Endpoint->EndpointAddress))) + return DESCRIPTOR_SEARCH_Found; + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +void MIDI_Host_USBTask(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive)) + return; + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + MIDI_Host_Flush(MIDIInterfaceInfo); + #endif +} + +uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber); + + if (Pipe_BytesInPipe()) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + } + + return PIPE_READYWAIT_NoError; +} + +uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, + MIDI_EventPacket_t* const Event) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipeNumber); + + if ((ErrorCode = Pipe_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if (!(Pipe_IsReadWriteAllowed())) + Pipe_ClearOUT(); + + return PIPE_RWSTREAM_NoError; +} + +bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, + MIDI_EventPacket_t* const Event) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataINPipeNumber); + + if (!(Pipe_IsReadWriteAllowed())) + return false; + + Pipe_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NO_STREAM_CALLBACK); + + if (!(Pipe_IsReadWriteAllowed())) + Pipe_ClearIN(); + + return true; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MIDI.h b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.h new file mode 100644 index 0000000..0cb778f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.h @@ -0,0 +1,201 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB MIDI Class driver. + * + * Host mode driver for the library USB MIDI 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_USBClassMIDI + * @defgroup Group_USBClassMIDIHost MIDI Class Host 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/Host/MIDI.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the MIDI USB Class driver. + * + * @{ + */ + +#ifndef __MIDI_CLASS_HOST_H__ +#define __MIDI_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/MIDI.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_MIDI_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_MIDI_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief MIDI Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made within the user application, + * and passed to each of the MIDI class driver functions as the MIDIInterfaceInfo parameter. This + * stores each MIDI interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the MIDI interface's streaming IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the MIDI interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the MIDI interface's streaming OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the MIDI interface's OUT data pipe 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref MIDI_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t InterfaceNumber; /**< Interface index of the MIDI interface within the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the MIDI Streaming Data interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the MIDI Streaming Data interface's OUT data pipe. */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_MIDI_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref MIDI_Host_ConfigurePipes() function. */ + enum MIDI_Host_EnumerationFailure_ErrorCodes_t + { + MIDI_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + MIDI_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + MIDI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible MIDI interface was not found in the device's Configuration Descriptor. */ + }; + + /* Function Prototypes: */ + /** Host interface configuration routine, to configure a given MIDI host interface instance using the Configuration + * Descriptor read from an attached USB device. This function automatically updates the given MIDI Host instance's + * state values and configures the pipes required to communicate with the interface if it is found within the device. + * This should be called once after the stack has enumerated the attached device, while the host state machine is in + * the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing an MIDI Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref MIDI_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** General management task for a given MIDI host 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] MIDIInterfaceInfo Pointer to a structure containing an MIDI Class host configuration and state. + */ + void MIDI_Host_USBTask(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, + MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Flushes the MIDI send buffer, sending any queued MIDI events to the device. This should be called to override the + * \ref MIDI_Host_SendEventPacket() function's packing behaviour, to flush queued events. Events are queued into the + * pipe bank until either the pipe bank is full, or \ref MIDI_Host_Flush() is called. This allows for multiple MIDI + * events to be packed into a single pipe packet, increasing data throughput. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Receives a MIDI event packet from the device. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * \param[out] Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed. + * + * \return Boolean true if a MIDI event packet was received, false otherwise. + */ + bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo, + MIDI_EventPacket_t* const Event) 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_MIDI_HOST_C) + static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MIDI.lst b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.lst new file mode 100644 index 0000000..eb26be7 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.lst @@ -0,0 +1,19 @@ + 1 .file "MIDI.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 MIDI.c + /tmp/cc5LIYAF.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cc5LIYAF.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cc5LIYAF.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cc5LIYAF.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cc5LIYAF.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cc5LIYAF.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MIDI.o b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.o new file mode 100644 index 0000000..bb3defc Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/MIDI.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.c b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.c new file mode 100644 index 0000000..0ecaca9 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -0,0 +1,629 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_MS_DRIVER +#define __INCLUDE_FROM_MASSSTORAGE_HOST_C +#include "MassStorage.h" + +uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Interface_t* MassStorageInterface = NULL; + + memset(&MSInterfaceInfo->State, 0x00, sizeof(MSInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return MS_ENUMERROR_InvalidConfigDescriptor; + + while (!(DataINEndpoint) || !(DataOUTEndpoint)) + { + if (!(MassStorageInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_MS_Host_NextMSInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_MS_Host_NextMSInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return MS_ENUMERROR_NoCompatibleInterfaceFound; + } + + MassStorageInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + MSInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + MSInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + MSInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + MSInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + } + } + + MSInterfaceInfo->State.InterfaceNumber = MassStorageInterface->InterfaceNumber; + MSInterfaceInfo->State.IsActive = true; + + return MS_ENUMERROR_NoError; +} + +static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == MS_CSCP_MassStorageClass) && + (Interface->SubClass == MS_CSCP_SCSITransparentSubclass) && + (Interface->Protocol == MS_CSCP_BulkOnlyTransportProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK); + + if ((EndpointType == EP_TYPE_BULK) && (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))) + { + return DESCRIPTOR_SEARCH_Found; + } + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandBlockWrapper_t* const SCSICommandBlock, + const void* const BufferPtr) +{ + uint8_t ErrorCode = PIPE_RWSTREAM_NoError; + + SCSICommandBlock->Signature = MS_CBW_SIGNATURE; + SCSICommandBlock->Tag = ++MSInterfaceInfo->State.TransactionTag; + + if (MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF) + MSInterfaceInfo->State.TransactionTag = 1; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(SCSICommandBlock, sizeof(MS_CommandBlockWrapper_t), + NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + + Pipe_Freeze(); + + if ((BufferPtr != NULL) && + ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, SCSICommandBlock, (void*)BufferPtr)) != PIPE_RWSTREAM_NoError)) + { + Pipe_Freeze(); + return ErrorCode; + } + + return ErrorCode; +} + +static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) +{ + uint16_t TimeoutMSRem = MS_COMMAND_DATA_TIMEOUT_MS; + uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber(); + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + while (!(Pipe_IsINReceived())) + { + uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return PIPE_RWSTREAM_Timeout; + } + + Pipe_Freeze(); + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearPipeStall(MSInterfaceInfo->Config.DataOUTPipeNumber); + + return PIPE_RWSTREAM_PipeStalled; + } + + Pipe_Freeze(); + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearPipeStall(MSInterfaceInfo->Config.DataINPipeNumber); + + return PIPE_RWSTREAM_PipeStalled; + } + + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + }; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber); + Pipe_Freeze(); + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandBlockWrapper_t* const SCSICommandBlock, + void* BufferPtr) +{ + uint8_t ErrorCode = PIPE_RWSTREAM_NoError; + uint16_t BytesRem = SCSICommandBlock->DataTransferLength; + + if (SCSICommandBlock->Flags & MS_COMMAND_DIR_DATA_IN) + { + if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError) + { + Pipe_Freeze(); + return ErrorCode; + } + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearIN(); + } + else + { + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + + while (!(Pipe_IsOUTReady())) + { + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + } + } + + Pipe_Freeze(); + + return ErrorCode; +} + +static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandStatusWrapper_t* const SCSICommandStatus) +{ + uint8_t ErrorCode = PIPE_RWSTREAM_NoError; + + if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(MS_CommandStatusWrapper_t), + NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + { + return ErrorCode; + } + + Pipe_ClearIN(); + Pipe_Freeze(); + + if (SCSICommandStatus->Status != MS_SCSI_COMMAND_Pass) + ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED; + + return ErrorCode; +} + +uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = MS_REQ_MassStorageReset, + .wValue = 0, + .wIndex = MSInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + uint8_t* const MaxLUNIndex) +{ + uint8_t ErrorCode = HOST_SENDCONTROL_Successful; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = MS_REQ_GetMaxLUN, + .wValue = 0, + .wIndex = MSInterfaceInfo->State.InterfaceNumber, + .wLength = 1, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) != HOST_SENDCONTROL_Successful) + { + *MaxLUNIndex = 0; + ErrorCode = HOST_SENDCONTROL_Successful; + } + + return ErrorCode; +} + +uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + SCSI_Inquiry_Response_t* const InquiryData) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = sizeof(SCSI_Inquiry_Response_t), + .Flags = MS_COMMAND_DIR_DATA_IN, + .LUN = LUNIndex, + .SCSICommandLength = 6, + .SCSICommandData = + { + SCSI_CMD_INQUIRY, + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + sizeof(SCSI_Inquiry_Response_t), // Allocation Length + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = 0, + .Flags = MS_COMMAND_DIR_DATA_IN, + .LUN = LUNIndex, + .SCSICommandLength = 6, + .SCSICommandData = + { + SCSI_CMD_TEST_UNIT_READY, + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + SCSI_Capacity_t* const DeviceCapacity) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = sizeof(SCSI_Capacity_t), + .Flags = MS_COMMAND_DIR_DATA_IN, + .LUN = LUNIndex, + .SCSICommandLength = 10, + .SCSICommandData = + { + SCSI_CMD_READ_CAPACITY_10, + 0x00, // Reserved + 0x00, // MSB of Logical block address + 0x00, + 0x00, + 0x00, // LSB of Logical block address + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Partial Medium Indicator + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + SwapEndian_n(&DeviceCapacity->Blocks, sizeof(DeviceCapacity->Blocks)); + SwapEndian_n(&DeviceCapacity->BlockSize, sizeof(DeviceCapacity->BlockSize)); + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + SCSI_Request_Sense_Response_t* const SenseData) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = sizeof(SCSI_Request_Sense_Response_t), + .Flags = MS_COMMAND_DIR_DATA_IN, + .LUN = LUNIndex, + .SCSICommandLength = 6, + .SCSICommandData = + { + SCSI_CMD_REQUEST_SENSE, + 0x00, // Reserved + 0x00, // Reserved + 0x00, // Reserved + sizeof(SCSI_Request_Sense_Response_t), // Allocation Length + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + const bool PreventRemoval) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = 0, + .Flags = MS_COMMAND_DIR_DATA_OUT, + .LUN = LUNIndex, + .SCSICommandLength = 6, + .SCSICommandData = + { + SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL, + 0x00, // Reserved + 0x00, // Reserved + PreventRemoval, // Prevent flag + 0x00, // Reserved + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + const uint32_t BlockAddress, + const uint8_t Blocks, + const uint16_t BlockSize, + void* BlockBuffer) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = ((uint32_t)Blocks * BlockSize), + .Flags = MS_COMMAND_DIR_DATA_IN, + .LUN = LUNIndex, + .SCSICommandLength = 10, + .SCSICommandData = + { + SCSI_CMD_READ_10, + 0x00, // Unused (control bits, all off) + (BlockAddress >> 24), // MSB of Block Address + (BlockAddress >> 16), + (BlockAddress >> 8), + (BlockAddress & 0xFF), // LSB of Block Address + 0x00, // Reserved + 0x00, // MSB of Total Blocks to Read + Blocks, // LSB of Total Blocks to Read + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + const uint32_t BlockAddress, + const uint8_t Blocks, + const uint16_t BlockSize, + const void* BlockBuffer) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = ((uint32_t)Blocks * BlockSize), + .Flags = MS_COMMAND_DIR_DATA_OUT, + .LUN = LUNIndex, + .SCSICommandLength = 10, + .SCSICommandData = + { + SCSI_CMD_WRITE_10, + 0x00, // Unused (control bits, all off) + (BlockAddress >> 24), // MSB of Block Address + (BlockAddress >> 16), + (BlockAddress >> 8), + (BlockAddress & 0xFF), // LSB of Block Address + 0x00, // Reserved + 0x00, // MSB of Total Blocks to Write + Blocks, // LSB of Total Blocks to Write + 0x00 // Unused (control) + } + }; + + MS_CommandStatusWrapper_t SCSICommandStatus; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.h b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.h new file mode 100644 index 0000000..ad4286d --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -0,0 +1,344 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB Mass Storage Class driver. + * + * Host mode driver for the library USB Mass Storage 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_USBClassMS + * @defgroup Group_USBClassMassStorageHost Mass Storage Class Host 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/Host/MassStorage.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the Mass Storage USB Class driver. + * + * @{ + */ + +#ifndef __MS_CLASS_HOST_H__ +#define __MS_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/MassStorage.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_MS_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_MASSSTORAGE_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Error code for some Mass Storage Host functions, indicating a logical (and not hardware) error. */ + #define MS_ERROR_LOGICAL_CMD_FAILED 0x80 + + /* Type Defines: */ + /** \brief Mass Storage Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made within the user application, + * and passed to each of the Mass Storage class driver functions as the MSInterfaceInfo parameter. This + * stores each Mass Storage interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the Mass Storage interface's IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the Mass Storage interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the Mass Storage interface's OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the Mass Storage interface's OUT data pipe 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref MS_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t InterfaceNumber; /**< Interface index of the Mass Storage interface within the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the Mass Storage interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the Mass Storage interface's OUT data pipe. */ + + uint32_t TransactionTag; /**< Current transaction tag for data synchronizing of packets. */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_MS_Host_t; + + /** \brief SCSI Device LUN Capacity Structure. + * + * SCSI capacity structure, to hold the total capacity of the device in both the number + * of blocks in the current LUN, and the size of each block. This structure is filled by + * the device when the \ref MS_Host_ReadDeviceCapacity() function is called. + */ + typedef struct + { + uint32_t Blocks; /**< Number of blocks in the addressed LUN of the device. */ + uint32_t BlockSize; /**< Number of bytes in each block in the addressed LUN. */ + } SCSI_Capacity_t; + + /* Enums: */ + enum MS_Host_EnumerationFailure_ErrorCodes_t + { + MS_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + MS_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + MS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Mass Storage interface was not found in the device's Configuration Descriptor. */ + }; + + /* Function Prototypes: */ + /** Host interface configuration routine, to configure a given Mass Storage host interface instance using the + * Configuration Descriptor read from an attached USB device. This function automatically updates the given Mass + * Storage Host instance's state values and configures the pipes required to communicate with the interface if it + * is found within the device. This should be called once after the stack has enumerated the attached device, while + * the host state machine is in the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing an MS Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref MS_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Sends a MASS STORAGE RESET control request to the attached device, resetting the Mass Storage Interface + * and readying it for the next Mass Storage command. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a GET MAX LUN control request to the attached device, retrieving the index of the highest LUN (Logical + * UNit, a logical drive) in the device. This value can then be used in the other functions of the Mass Storage + * Host mode Class driver to address a specific LUN within the device. + * + * \note Some devices do not support this request, and will STALL it when issued. To get around this, + * on unsupported devices the max LUN index will be reported as zero and no error will be returned + * if the device STALLs the request. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[out] MaxLUNIndex Pointer to a location where the highest LUN index value should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + uint8_t* const MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Retrieves the Mass Storage device's inquiry data for the specified LUN, indicating the device characteristics and + * properties. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * \param[out] InquiryData Location where the read inquiry data should be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED. + */ + uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + SCSI_Inquiry_Response_t* const InquiryData) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(3); + + /** Sends a TEST UNIT READY command to the device, to determine if it is ready to accept other SCSI commands. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready. + */ + uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex) ATTR_NON_NULL_PTR_ARG(1); + + /** Retrieves the total capacity of the attached USB Mass Storage device, in blocks, and block size. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * \param[out] DeviceCapacity Pointer to the location where the capacity information should be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready. + */ + uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + SCSI_Capacity_t* const DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(3); + + /** Retrieves the device sense data, indicating the current device state and error codes for the previously + * issued command. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * \param[out] SenseData Pointer to the location where the sense information should be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready. + */ + uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + SCSI_Request_Sense_Response_t* const SenseData) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(3); + + /** Issues a PREVENT MEDIUM REMOVAL command, to logically (or, depending on the type of device, physically) lock + * the device from removal so that blocks of data on the medium can be read or altered. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * \param[in] PreventRemoval Boolean true if the device should be locked from removal, false otherwise. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready. + */ + uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + const bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads blocks of data from the attached Mass Storage device's medium. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * \param[in] BlockAddress Starting block address within the device to read from. + * \param[in] Blocks Total number of blocks to read. + * \param[in] BlockSize Size in bytes of each block within the device. + * \param[out] BlockBuffer Pointer to where the read data from the device should be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready. + */ + uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + const uint32_t BlockAddress, + const uint8_t Blocks, + const uint16_t BlockSize, + void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6); + + /** Writes blocks of data to the attached Mass Storage device's medium. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state. + * \param[in] LUNIndex LUN index within the device the command is being issued to. + * \param[in] BlockAddress Starting block address within the device to write to. + * \param[in] Blocks Total number of blocks to read. + * \param[in] BlockSize Size in bytes of each block within the device. + * \param[in] BlockBuffer Pointer to where the data to write should be sourced from. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready. + */ + uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + const uint8_t LUNIndex, + const uint32_t BlockAddress, + const uint8_t Blocks, + const uint16_t BlockSize, + const void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6); + + /* Inline Functions: */ + /** General management task for a given Mass Storage host 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] MSInterfaceInfo Pointer to a structure containing an Mass Storage Class host configuration and state. + */ + static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo); + static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) + { + (void)MSInterfaceInfo; + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define MS_COMMAND_DATA_TIMEOUT_MS 10000 + + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_MASSSTORAGE_HOST_C) + static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + + static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandBlockWrapper_t* const SCSICommandBlock, + const void* const BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandBlockWrapper_t* const SCSICommandBlock, + void* BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + MS_CommandStatusWrapper_t* const SCSICommandStatus) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.lst b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.lst new file mode 100644 index 0000000..41f6f0e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.lst @@ -0,0 +1,19 @@ + 1 .file "MassStorage.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 MassStorage.c + /tmp/ccgRRIOC.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccgRRIOC.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccgRRIOC.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccgRRIOC.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccgRRIOC.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccgRRIOC.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.o b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.o new file mode 100644 index 0000000..8a2b34b Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/MassStorage.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/Printer.c b/firmware/LUFA/Drivers/USB/Class/Host/Printer.c new file mode 100644 index 0000000..ddcece8 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/Printer.c @@ -0,0 +1,392 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_PRINTER_DRIVER +#define __INCLUDE_FROM_PRINTER_HOST_C +#include "Printer.h" + +uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Interface_t* PrinterInterface = NULL; + + memset(&PRNTInterfaceInfo->State, 0x00, sizeof(PRNTInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return PRNT_ENUMERROR_InvalidConfigDescriptor; + + while (!(DataINEndpoint) || !(DataOUTEndpoint)) + { + if (!(PrinterInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_PRNT_Host_NextPRNTInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return PRNT_ENUMERROR_NoCompatibleInterfaceFound; + } + + PrinterInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + PRNTInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + PRNTInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + PRNTInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + PRNTInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + } + } + + PRNTInterfaceInfo->State.InterfaceNumber = PrinterInterface->InterfaceNumber; + PRNTInterfaceInfo->State.AlternateSetting = PrinterInterface->AlternateSetting; + PRNTInterfaceInfo->State.IsActive = true; + + return PRNT_ENUMERROR_NoError; +} + +static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == PRNT_CSCP_PrinterClass) && + (Interface->SubClass == PRNT_CSCP_PrinterSubclass) && + (Interface->Protocol == PRNT_CSCP_BidirectionalProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK); + + if (EndpointType == EP_TYPE_BULK) + return DESCRIPTOR_SEARCH_Found; + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +void PRNT_Host_USBTask(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return; + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + PRNT_Host_Flush(PRNTInterfaceInfo); + #endif +} + +uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) +{ + if (PRNTInterfaceInfo->State.AlternateSetting) + { + uint8_t ErrorCode; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_SetInterface, + .wValue = PRNTInterfaceInfo->State.AlternateSetting, + .wIndex = PRNTInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + } + + return HOST_SENDCONTROL_Successful; +} + +uint8_t PRNT_Host_GetPortStatus(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + uint8_t* const PortStatus) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = PRNT_REQ_GetPortStatus, + .wValue = 0, + .wIndex = PRNTInterfaceInfo->State.InterfaceNumber, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(PortStatus); +} + +uint8_t PRNT_Host_SoftReset(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = PRNT_REQ_SoftReset, + .wValue = 0, + .wIndex = PRNTInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t PRNT_Host_Flush(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (!(Pipe_BytesInPipe())) + return PIPE_READYWAIT_NoError; + + bool BankFull = !(Pipe_IsReadWriteAllowed()); + + Pipe_ClearOUT(); + + if (BankFull) + { + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + } + + Pipe_Freeze(); + + return PIPE_READYWAIT_NoError; +} + +uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + const uint8_t Data) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + } + + Pipe_Write_Byte(Data); + Pipe_Freeze(); + + return PIPE_READYWAIT_NoError; +} + +uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + void* Buffer, + const uint16_t Length) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + + ErrorCode = Pipe_WaitUntilReady(); + + Pipe_Freeze(); + + return ErrorCode; +} + +uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return 0; + + Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (!(Pipe_BytesInPipe())) + { + Pipe_ClearIN(); + Pipe_Freeze(); + return 0; + } + else + { + Pipe_Freeze(); + return Pipe_BytesInPipe(); + } + } + else + { + Pipe_Freeze(); + + return 0; + } +} + +int16_t PRNT_Host_ReceiveByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + int16_t ReceivedByte = -1; + + Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + ReceivedByte = Pipe_Read_Byte(); + + if (!(Pipe_BytesInPipe())) + Pipe_ClearIN(); + } + + Pipe_Freeze(); + + return ReceivedByte; +} + +uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + char* const DeviceIDString, + const uint16_t BufferSize) +{ + uint8_t ErrorCode = HOST_SENDCONTROL_Successful; + uint16_t DeviceIDStringLength = 0; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = PRNT_REQ_GetDeviceID, + .wValue = 0, + .wIndex = PRNTInterfaceInfo->State.InterfaceNumber, + .wLength = sizeof(DeviceIDStringLength), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + if (!(DeviceIDStringLength)) + { + DeviceIDString[0] = 0x00; + return HOST_SENDCONTROL_Successful; + } + + DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength); + + if (DeviceIDStringLength > BufferSize) + DeviceIDStringLength = BufferSize; + + USB_ControlRequest.wLength = DeviceIDStringLength; + + if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2); + + DeviceIDString[DeviceIDStringLength - 2] = 0x00; + + return HOST_SENDCONTROL_Successful; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/Printer.h b/firmware/LUFA/Drivers/USB/Class/Host/Printer.h new file mode 100644 index 0000000..cc77e96 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/Printer.h @@ -0,0 +1,282 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB Printer Class driver. + * + * Host mode driver for the library USB Printer 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_USBClassPrinter + * @defgroup Group_USBClassPrinterHost Printer Class Host 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/Host/Printer.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the Printer USB Class driver. + * + * @{ + */ + +#ifndef __PRINTER_CLASS_HOST_H__ +#define __PRINTER_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/Printer.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_PRINTER_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_PRINTER_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief Printer Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made within the user application, + * and passed to each of the Printer class driver functions as the PRNTInterfaceInfo parameter. This + * stores each Printer interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the Printer interface's IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the Printer interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the Printer interface's OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the Printer interface's OUT data pipe 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref PRNT_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t InterfaceNumber; /**< Interface index of the Printer interface within the attached device. */ + uint8_t AlternateSetting; /**< Alternate setting within the Printer Interface in the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the Printer interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the Printer interface's OUT data pipe. */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_PRNT_Host_t; + + /* Enums: */ + enum PRNT_Host_EnumerationFailure_ErrorCodes_t + { + PRNT_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + PRNT_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + PRNT_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Printer interface was not found in the device's Configuration Descriptor. */ + }; + + /* Function Prototypes: */ + /** General management task for a given Printer host 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] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + */ + void PRNT_Host_USBTask(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Host interface configuration routine, to configure a given Printer host interface instance using the + * Configuration Descriptor read from an attached USB device. This function automatically updates the given Printer + * instance's state values and configures the pipes required to communicate with the interface if it is found within + * the device. This should be called once after the stack has enumerated the attached device, while the host state + * machine is in the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref PRNT_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Configures the printer to enable Bidirectional mode, if it is not already in this mode. This should be called + * once the connected device's configuration has been set, to ensure the printer is ready to accept commands. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Retrieves the status of the virtual Printer port's inbound status lines. The result can then be masked against the + * PRNT_PORTSTATUS_* macros to determine the printer port's status. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * \param[out] PortStatus Location where the retrieved port status should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t PRNT_Host_GetPortStatus(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + uint8_t* const PortStatus) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Soft-resets the attached printer, readying it for new commands. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t PRNT_Host_SoftReset(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) 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 Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t PRNT_Host_Flush(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends the given raw data stream to the attached printer's input endpoint. This should contain commands that the + * printer is able to understand - for example, PCL data. Not all printers accept all printer languages; see + * \ref PRNT_Host_GetDeviceID() for details on determining acceptable languages for an attached printer. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * \param[in] Buffer Pointer to a buffer containing the raw command stream to send to the printer. + * \param[in] Length Size in bytes of the command stream to be sent. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + void* Buffer, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the + * byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the + * \ref PRNT_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single pipe packet, increasing data throughput. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * \param[in] Data Byte of data to send to the device. + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); + + /** Determines the number of bytes received by the printer interface from the device, waiting to be read. This indicates the number + * of bytes in the IN pipe bank only, and thus the number of calls to \ref PRNT_Host_ReceiveByte() which are guaranteed to succeed + * immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be + * released back to the USB controller until all bytes are read. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * + * \return Total number of buffered bytes received from the device. + */ + uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo); + + /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function + * returns a negative value. The \ref PRNT_Host_BytesReceived() function may be queried in advance to determine how many bytes + * are currently buffered in the Printer interface's data receive pipe. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * + * \return Next received byte from the device, or a negative value if no data received. + */ + int16_t PRNT_Host_ReceiveByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo); + + /** Retrieves the attached printer device's ID string, formatted according to IEEE 1284. This string is sent as a + * Unicode string from the device and is automatically converted to an ASCII encoded C string by this function, thus + * the maximum reportable string length is two less than the size given (to accommodate the Unicode string length + * bytes which are removed). + * + * This string, when supported, contains the model, manufacturer and acceptable printer languages for the attached device. + * + * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state. + * \param[out] DeviceIDString Pointer to a buffer where the Device ID string should be stored, in ASCII format. + * \param[in] BufferSize Size in bytes of the buffer allocated for the Device ID string. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + char* const DeviceIDString, + const uint16_t BufferSize) 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_PRINTER_HOST_C) + static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/Printer.lst b/firmware/LUFA/Drivers/USB/Class/Host/Printer.lst new file mode 100644 index 0000000..6e74140 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/Printer.lst @@ -0,0 +1,19 @@ + 1 .file "Printer.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Printer.c + /tmp/cchSsxeH.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cchSsxeH.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cchSsxeH.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cchSsxeH.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cchSsxeH.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cchSsxeH.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/Printer.o b/firmware/LUFA/Drivers/USB/Class/Host/Printer.o new file mode 100644 index 0000000..400656d Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/Printer.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.c b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.c new file mode 100644 index 0000000..11f7d9e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.c @@ -0,0 +1,480 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_RNDIS_DRIVER +#define __INCLUDE_FROM_RNDIS_HOST_C +#include "RNDIS.h" + +uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Endpoint_t* NotificationEndpoint = NULL; + USB_Descriptor_Interface_t* RNDISControlInterface = NULL; + + memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return RNDIS_ENUMERROR_InvalidConfigDescriptor; + + RNDISControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + while (!(DataINEndpoint) || !(DataOUTEndpoint) || !(NotificationEndpoint)) + { + if (!(RNDISControlInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (NotificationEndpoint) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_RNDIS_Host_NextRNDISDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return RNDIS_ENUMERROR_NoCompatibleInterfaceFound; + } + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + } + else + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_RNDIS_Host_NextRNDISControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return RNDIS_ENUMERROR_NoCompatibleInterfaceFound; + } + + RNDISControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + NotificationEndpoint = NULL; + } + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + { + if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) + NotificationEndpoint = EndpointData; + else + DataINEndpoint = EndpointData; + } + else + { + DataOUTEndpoint = EndpointData; + } + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + RNDISInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == RNDISInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + RNDISInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + } + else if (PipeNum == RNDISInterfaceInfo->Config.NotificationPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, + NotificationEndpoint->EndpointAddress, NotificationEndpoint->EndpointSize, + RNDISInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + Pipe_SetInterruptPeriod(NotificationEndpoint->PollingIntervalMS); + + RNDISInterfaceInfo->State.NotificationPipeSize = NotificationEndpoint->EndpointSize; + } + } + + RNDISInterfaceInfo->State.ControlInterfaceNumber = RNDISControlInterface->InterfaceNumber; + RNDISInterfaceInfo->State.IsActive = true; + + return RNDIS_ENUMERROR_NoError; +} + +static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == CDC_CSCP_CDCClass) && + (Interface->SubClass == CDC_CSCP_ACMSubclass) && + (Interface->Protocol == CDC_CSCP_VendorSpecificProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, + USB_Descriptor_Interface_t); + + if ((Interface->Class == CDC_CSCP_CDCDataClass) && + (Interface->SubClass == CDC_CSCP_NoDataSubclass) && + (Interface->Protocol == CDC_CSCP_NoDataProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK); + + if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) && + !(Pipe_IsEndpointBound(Endpoint->EndpointAddress))) + { + return DESCRIPTOR_SEARCH_Found; + } + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t Length) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = RNDIS_REQ_SendEncapsulatedCommand, + .wValue = 0, + .wIndex = RNDISInterfaceInfo->State.ControlInterfaceNumber, + .wLength = Length, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(Buffer); +} + +static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t Length) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = RNDIS_REQ_GetEncapsulatedResponse, + .wValue = 0, + .wIndex = RNDISInterfaceInfo->State.ControlInterfaceNumber, + .wLength = Length, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(Buffer); +} + +uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) +{ + uint8_t ErrorCode; + + RNDIS_KeepAlive_Message_t KeepAliveMessage; + RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse; + + KeepAliveMessage.MessageType = REMOTE_NDIS_KEEPALIVE_MSG; + KeepAliveMessage.MessageLength = sizeof(RNDIS_KeepAlive_Message_t); + KeepAliveMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; + + if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &KeepAliveMessage, + sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &KeepAliveMessageResponse, + sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + return HOST_SENDCONTROL_Successful; +} + +uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) +{ + uint8_t ErrorCode; + + RNDIS_Initialize_Message_t InitMessage; + RNDIS_Initialize_Complete_t InitMessageResponse; + + InitMessage.MessageType = REMOTE_NDIS_INITIALIZE_MSG; + InitMessage.MessageLength = sizeof(RNDIS_Initialize_Message_t); + InitMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; + + InitMessage.MajorVersion = REMOTE_NDIS_VERSION_MAJOR; + InitMessage.MinorVersion = REMOTE_NDIS_VERSION_MINOR; + InitMessage.MaxTransferSize = RNDISInterfaceInfo->Config.HostMaxPacketSize; + + if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &InitMessage, + sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &InitMessageResponse, + sizeof(RNDIS_Initialize_Complete_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if (InitMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) + return RNDIS_COMMAND_FAILED; + + RNDISInterfaceInfo->State.DeviceMaxPacketSize = InitMessageResponse.MaxTransferSize; + + return HOST_SENDCONTROL_Successful; +} + +uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + const uint32_t Oid, + void* Buffer, + const uint16_t Length) +{ + uint8_t ErrorCode; + + struct + { + RNDIS_Set_Message_t SetMessage; + uint8_t ContiguousBuffer[Length]; + } SetMessageData; + + RNDIS_Set_Complete_t SetMessageResponse; + + SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG; + SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length; + SetMessageData.SetMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; + + SetMessageData.SetMessage.Oid = Oid; + SetMessageData.SetMessage.InformationBufferLength = Length; + SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t)); + SetMessageData.SetMessage.DeviceVcHandle = 0; + + memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length); + + if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &SetMessageData, + SetMessageData.SetMessage.MessageLength)) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &SetMessageResponse, + sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if (SetMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) + return RNDIS_COMMAND_FAILED; + + return HOST_SENDCONTROL_Successful; +} + +uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + const uint32_t Oid, + void* Buffer, + const uint16_t MaxLength) +{ + uint8_t ErrorCode; + + RNDIS_Query_Message_t QueryMessage; + + struct + { + RNDIS_Query_Complete_t QueryMessageResponse; + uint8_t ContiguousBuffer[MaxLength]; + } QueryMessageResponseData; + + QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG; + QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t); + QueryMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; + + QueryMessage.Oid = Oid; + QueryMessage.InformationBufferLength = 0; + QueryMessage.InformationBufferOffset = 0; + QueryMessage.DeviceVcHandle = 0; + + if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &QueryMessage, + sizeof(RNDIS_Query_Message_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &QueryMessageResponseData, + sizeof(QueryMessageResponseData))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if (QueryMessageResponseData.QueryMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) + return RNDIS_COMMAND_FAILED; + + memcpy(Buffer, &QueryMessageResponseData.ContiguousBuffer, MaxLength); + + return HOST_SENDCONTROL_Successful; +} + +bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) +{ + bool PacketWaiting; + + if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive)) + return false; + + Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber); + + Pipe_Unfreeze(); + PacketWaiting = Pipe_IsINReceived(); + Pipe_Freeze(); + + return PacketWaiting; +} + +uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + uint16_t* const PacketLength) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (!(Pipe_IsReadWriteAllowed())) + { + if (Pipe_IsINReceived()) + Pipe_ClearIN(); + + *PacketLength = 0; + Pipe_Freeze(); + return PIPE_RWSTREAM_NoError; + } + + RNDIS_Packet_Message_t DeviceMessage; + + if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t), + NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + { + return ErrorCode; + } + + *PacketLength = (uint16_t)DeviceMessage.DataLength; + + Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)), + NO_STREAM_CALLBACK); + + Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK); + + if (!(Pipe_BytesInPipe())) + Pipe_ClearIN(); + + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t PacketLength) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + RNDIS_Packet_Message_t DeviceMessage; + + memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t)); + DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG; + DeviceMessage.MessageLength = (sizeof(RNDIS_Packet_Message_t) + PacketLength); + DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)); + DeviceMessage.DataLength = PacketLength; + + Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t), + NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + { + return ErrorCode; + } + + Pipe_Write_Stream_LE(Buffer, PacketLength, NO_STREAM_CALLBACK); + Pipe_ClearOUT(); + + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.h b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.h new file mode 100644 index 0000000..611e59e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.h @@ -0,0 +1,290 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB RNDIS Class driver. + * + * Host mode driver for the library USB RNDIS 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_USBClassRNDIS + * @defgroup Group_USBClassRNDISHost RNDIS Class Host 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/Host/RNDIS.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the Microsoft RNDIS Ethernet + * USB Class driver. + * + * @{ + */ + +#ifndef __RNDIS_CLASS_HOST_H__ +#define __RNDIS_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/RNDIS.h" + + #include + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_RNDIS_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_RNDIS_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief RNDIS Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made within the user application, + * and passed to each of the RNDIS class driver functions as the RNDISInterfaceInfo parameter. This + * stores each RNDIS interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the RNDIS interface's IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the RNDIS interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the RNDIS interface's OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the RNDIS interface's OUT data pipe should use double banking. */ + + uint8_t NotificationPipeNumber; /**< Pipe number of the RNDIS interface's IN notification endpoint, if used. */ + bool NotificationPipeDoubleBank; /**< Indicates if the RNDIS interface's notification pipe should use double banking. */ + + uint32_t HostMaxPacketSize; /**< Maximum size of a packet which can be buffered by the host. */ + } 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref RNDIS_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t ControlInterfaceNumber; /**< Interface index of the RNDIS control interface within the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the RNDIS interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the RNDIS interface's OUT data pipe. */ + uint16_t NotificationPipeSize; /**< Size in bytes of the RNDIS interface's IN notification pipe, if used. */ + + uint32_t DeviceMaxPacketSize; /**< Maximum size of a packet which can be buffered by the attached RNDIS device. */ + + uint32_t RequestID; /**< Request ID counter to give a unique ID for each command/response pair. */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_RNDIS_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref RNDIS_Host_ConfigurePipes() function. */ + enum RNDIS_Host_EnumerationFailure_ErrorCodes_t + { + RNDIS_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + RNDIS_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + RNDIS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible RNDIS interface was not found in the device's Configuration Descriptor. */ + }; + + /* Macros: */ + /** Additional error code for RNDIS functions when a device returns a logical command failure. */ + #define RNDIS_COMMAND_FAILED 0xC0 + + /* Function Prototypes: */ + /** Host interface configuration routine, to configure a given RNDIS host interface instance using the Configuration + * Descriptor read from an attached USB device. This function automatically updates the given RNDIS Host instance's + * state values and configures the pipes required to communicate with the interface if it is found within the device. + * This should be called once after the stack has enumerated the attached device, while the host state machine is in + * the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref RNDIS_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Sends a RNDIS KEEPALIVE command to the device, to ensure that it does not enter standby mode after periods + * of long inactivity. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_COMMAND_FAILED if the device returned a + * logical command failure. + */ + uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Initialises the attached RNDIS device's RNDIS interface. This should be called after the device's pipes have been + * configured via the call to \ref RNDIS_Host_ConfigurePipes(). + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_COMMAND_FAILED if the device returned a + * logical command failure. + */ + uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sets a given RNDIS property of an attached RNDIS device. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * \param[in] Oid OID number of the parameter to set. + * \param[in] Buffer Pointer to where the property data is to be sourced from. + * \param[in] Length Length in bytes of the property data to sent to the device. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_COMMAND_FAILED if the device returned a + * logical command failure. + */ + uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + const uint32_t Oid, + void* Buffer, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Gets a given RNDIS property of an attached RNDIS device. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * \param[in] Oid OID number of the parameter to get. + * \param[in] Buffer Pointer to where the property data is to be written to. + * \param[in] MaxLength Length in bytes of the destination buffer size. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_COMMAND_FAILED if the device returned a + * logical command failure. + */ + uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + const uint32_t Oid, + void* Buffer, + const uint16_t MaxLength) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Determines if a packet is currently waiting for the host to read in and process. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * + * \return Boolean true if a packet is waiting to be read in by the host, false otherwise. + */ + bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Retrieves the next pending packet from the device, discarding the remainder of the RNDIS packet header to leave + * only the packet contents for processing by the host in the nominated buffer. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * \param[out] Buffer Pointer to a buffer where the packer data is to be written to. + * \param[out] PacketLength Pointer to where the length in bytes of the read packet is to be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + uint16_t* const PacketLength) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2) + ATTR_NON_NULL_PTR_ARG(3); + + /** Sends the given packet to the attached RNDIS device, after adding a RNDIS packet message header. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + * \param[in] Buffer Pointer to a buffer where the packer data is to be read from. + * \param[in] PacketLength Length in bytes of the packet to send. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t PacketLength) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /* Inline Functions: */ + /** General management task for a given RNDIS host 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] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state. + */ + static inline void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) + { + (void)RNDISInterfaceInfo; + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_RNDIS_HOST_C) + static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(2); + static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(2); + + static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.lst b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.lst new file mode 100644 index 0000000..9dfa2cb --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.lst @@ -0,0 +1,19 @@ + 1 .file "RNDIS.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 RNDIS.c + /tmp/ccQYGsRG.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccQYGsRG.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccQYGsRG.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccQYGsRG.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccQYGsRG.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccQYGsRG.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.o b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.o new file mode 100644 index 0000000..63b9e84 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/RNDIS.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/Host/StillImage.c b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.c new file mode 100644 index 0000000..7b31e10 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.c @@ -0,0 +1,443 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_SI_DRIVER +#define __INCLUDE_FROM_STILLIMAGE_HOST_C +#include "StillImage.h" + +uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Endpoint_t* EventsEndpoint = NULL; + USB_Descriptor_Interface_t* StillImageInterface = NULL; + + memset(&SIInterfaceInfo->State, 0x00, sizeof(SIInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return SI_ENUMERROR_InvalidConfigDescriptor; + + while (!(DataINEndpoint) || !(DataOUTEndpoint)) + { + if (!(StillImageInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_SI_Host_NextSIInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_SI_Host_NextSIInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return SI_ENUMERROR_NoCompatibleInterfaceFound; + } + + StillImageInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + DataINEndpoint = NULL; + DataOUTEndpoint = NULL; + EventsEndpoint = NULL; + + continue; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) + { + if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) + EventsEndpoint = EndpointData; + else + DataINEndpoint = EndpointData; + } + else + { + DataOUTEndpoint = EndpointData; + } + } + + for (uint8_t PipeNum = 1; PipeNum < PIPE_TOTAL_PIPES; PipeNum++) + { + if (PipeNum == SIInterfaceInfo->Config.DataINPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_IN, + DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, + SIInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + SIInterfaceInfo->State.DataINPipeSize = DataINEndpoint->EndpointSize; + } + else if (PipeNum == SIInterfaceInfo->Config.DataOUTPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_BULK, PIPE_TOKEN_OUT, + DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, + SIInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + + SIInterfaceInfo->State.DataOUTPipeSize = DataOUTEndpoint->EndpointSize; + } + else if (PipeNum == SIInterfaceInfo->Config.EventsPipeNumber) + { + Pipe_ConfigurePipe(PipeNum, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, + EventsEndpoint->EndpointAddress, EventsEndpoint->EndpointSize, + SIInterfaceInfo->Config.EventsPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE); + Pipe_SetInterruptPeriod(EventsEndpoint->PollingIntervalMS); + + SIInterfaceInfo->State.EventsPipeSize = EventsEndpoint->EndpointSize; + } + } + + SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber; + SIInterfaceInfo->State.IsActive = true; + + return SI_ENUMERROR_NoError; +} + +uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Interface) + { + USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t); + + if ((Interface->Class == SI_CSCP_StillImageClass) && + (Interface->SubClass == SI_CSCP_StillImageSubclass) && + (Interface->Protocol == SI_CSCP_BulkOnlyProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor) +{ + USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t); + + if (Header->Type == DTYPE_Endpoint) + { + USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t); + + uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK); + + if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) && + (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))) + { + return DESCRIPTOR_SEARCH_Found; + } + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + PIMA_Container_t* const PIMAHeader) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + if (SIInterfaceInfo->State.IsSessionOpen) + PIMAHeader->TransactionID = SIInterfaceInfo->State.TransactionID++; + + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0)); + + if (ParamBytes) + { + if ((ErrorCode = Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + } + + Pipe_ClearOUT(); + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + PIMA_Container_t* const PIMAHeader) +{ + uint16_t TimeoutMSRem = SI_COMMAND_DATA_TIMEOUT_MS; + uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber(); + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + while (!(Pipe_IsINReceived())) + { + uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return PIPE_RWSTREAM_Timeout; + } + + Pipe_Freeze(); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearPipeStall(SIInterfaceInfo->Config.DataOUTPipeNumber); + return PIPE_RWSTREAM_PipeStalled; + } + + Pipe_Freeze(); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearPipeStall(SIInterfaceInfo->Config.DataINPipeNumber); + return PIPE_RWSTREAM_PipeStalled; + } + + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + } + + Pipe_Read_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NO_STREAM_CALLBACK); + + if (PIMAHeader->Type == PIMA_CONTAINER_ResponseBlock) + { + uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0)); + + if (ParamBytes) + Pipe_Read_Stream_LE(&PIMAHeader->Params, ParamBytes, NO_STREAM_CALLBACK); + + Pipe_ClearIN(); + } + + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +uint8_t SI_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + void* Buffer, + const uint16_t Bytes) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); + Pipe_Unfreeze(); + + ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes, NO_STREAM_CALLBACK); + + Pipe_ClearOUT(); + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + void* Buffer, + const uint16_t Bytes) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + + ErrorCode = Pipe_Read_Stream_LE(Buffer, Bytes, NO_STREAM_CALLBACK); + + Pipe_Freeze(); + + return ErrorCode; +} + +bool SI_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) +{ + bool IsEventReceived = false; + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return false; + + Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber); + Pipe_Unfreeze(); + + if (Pipe_BytesInPipe()) + IsEventReceived = true; + + Pipe_Freeze(); + + return IsEventReceived; +} + +uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + PIMA_Container_t* const PIMAHeader) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipeNumber); + Pipe_Unfreeze(); + + ErrorCode = Pipe_Read_Stream_LE(PIMAHeader, sizeof(PIMA_Container_t), NO_STREAM_CALLBACK); + + Pipe_ClearIN(); + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + SIInterfaceInfo->State.TransactionID = 0; + SIInterfaceInfo->State.IsSessionOpen = false; + + PIMA_Container_t PIMABlock = (PIMA_Container_t) + { + .DataLength = PIMA_COMMAND_SIZE(1), + .Type = PIMA_CONTAINER_CommandBlock, + .Code = 0x1002, + .Params = {1}, + }; + + if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((PIMABlock.Type != PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001)) + return SI_ERROR_LOGICAL_CMD_FAILED; + + SIInterfaceInfo->State.IsSessionOpen = true; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + PIMA_Container_t PIMABlock = (PIMA_Container_t) + { + .DataLength = PIMA_COMMAND_SIZE(1), + .Type = PIMA_CONTAINER_CommandBlock, + .Code = 0x1003, + .Params = {1}, + }; + + if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + SIInterfaceInfo->State.IsSessionOpen = false; + + if ((PIMABlock.Type != PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001)) + return SI_ERROR_LOGICAL_CMD_FAILED; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + const uint16_t Operation, + const uint8_t TotalParams, + uint32_t* const Params) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t ErrorCode; + + PIMA_Container_t PIMABlock = (PIMA_Container_t) + { + .DataLength = PIMA_COMMAND_SIZE(TotalParams), + .Type = PIMA_CONTAINER_CommandBlock, + .Code = Operation, + }; + + memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams); + + if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + return PIPE_RWSTREAM_NoError; +} + +uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) +{ + uint8_t ErrorCode; + PIMA_Container_t PIMABlock; + + if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((PIMABlock.Type != PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001)) + return SI_ERROR_LOGICAL_CMD_FAILED; + + return PIPE_RWSTREAM_NoError; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/StillImage.h b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.h new file mode 100644 index 0000000..5a6de02 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.h @@ -0,0 +1,331 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Host mode driver for the library USB Still Image Class driver. + * + * Host mode driver for the library USB Still Image 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_USBClassSI + * @defgroup Group_USBClassStillImageHost Still Image Class Host 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/Host/StillImage.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Host Mode USB Class driver framework interface, for the Still Image USB Class driver. + * + * @{ + */ + +#ifndef __SI_CLASS_HOST_H__ +#define __SI_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/StillImage.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SI_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + #if defined(__INCLUDE_FROM_STILLIMAGE_HOST_C) && defined(NO_STREAM_CALLBACKS) + #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Error code for some Still Image Host functions, indicating a logical (and not hardware) error. */ + #define SI_ERROR_LOGICAL_CMD_FAILED 0x80 + + /* Type Defines: */ + /** \brief Still Image Class Host Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made within the user application, + * and passed to each of the Still Image class driver functions as the SIInterfaceInfo parameter. This + * stores each Still Image interface's configuration and state information. + */ + typedef struct + { + const struct + { + uint8_t DataINPipeNumber; /**< Pipe number of the Still Image interface's IN data pipe. */ + bool DataINPipeDoubleBank; /**< Indicates if the Still Image interface's IN data pipe should use double banking. */ + + uint8_t DataOUTPipeNumber; /**< Pipe number of the Still Image interface's OUT data pipe. */ + bool DataOUTPipeDoubleBank; /**< Indicates if the Still Image interface's OUT data pipe should use double banking. */ + + uint8_t EventsPipeNumber; /**< Pipe number of the Still Image interface's IN events endpoint, if used. */ + bool EventsPipeDoubleBank; /**< Indicates if the Still Image interface's events data pipe 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 + { + bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid + * after \ref SI_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t InterfaceNumber; /**< Interface index of the Mass Storage interface within the attached device. */ + + uint16_t DataINPipeSize; /**< Size in bytes of the Still Image interface's IN data pipe. */ + uint16_t DataOUTPipeSize; /**< Size in bytes of the Still Image interface's OUT data pipe. */ + uint16_t EventsPipeSize; /**< Size in bytes of the Still Image interface's IN events pipe. */ + + bool IsSessionOpen; /**< Indicates if a PIMA session is currently open with the attached device. */ + uint32_t TransactionID; /**< Transaction ID for the next transaction to send to the device. */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * may be set to initial values, but may also be ignored to default to sane values when + * the interface is enumerated. + */ + } USB_ClassInfo_SI_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref SI_Host_ConfigurePipes() function. */ + enum SI_Host_EnumerationFailure_ErrorCodes_t + { + SI_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + SI_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + SI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Still Image interface was not found in the device's + * Configuration Descriptor. + */ + }; + + /* Function Prototypes: */ + /** Host interface configuration routine, to configure a given Still Image host interface instance using the + * Configuration Descriptor read from an attached USB device. This function automatically updates the given Still + * Image Host instance's state values and configures the pipes required to communicate with the interface if it is + * found within the device. This should be called once after the stack has enumerated the attached device, while + * the host state machine is in the Addressed state. + * + * \note The pipe index numbers as given in the interface's configuration structure must not overlap with any other + * interface, or pipe bank corruption will occur. Gaps in the allocated pipe numbers or non-sequential indexes + * within a single interface is allowed, but no two interfaces of any type have have interleaved pipe indexes. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor. + * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor. + * + * \return A value from the \ref SI_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Opens a new PIMA session with the attached device. This should be used before any session-orientated PIMA commands + * are issued to the device. Only one session can be open at the one time. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device + * returned a logical command failure. + */ + uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Closes an already opened PIMA session with the attached device. This should be used after all session-orientated + * PIMA commands have been issued to the device. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device + * returned a logical command failure. + */ + uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a raw PIMA block header to the device, filling out the transaction ID automatically. This can be used to send + * arbitrary PIMA blocks to the device with or without parameters. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[in] PIMAHeader Pointer to a PIMA container structure that is to be sent. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(2); + + /** Receives a raw PIMA block header to the device. This can be used to receive arbitrary PIMA blocks from the device with + * or without parameters. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[out] PIMAHeader Pointer to a PIMA container structure where the received block is to be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given PIMA command to the attached device, filling out the PIMA command header's Transaction ID automatically. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[in] Operation PIMA operation code to issue to the device. + * \param[in] TotalParams Total number of 32-bit parameters to send to the device in the issued command block. + * \param[in] Params Pointer to an array of 32-bit values containing the parameters to send in the command block. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device + * returned a logical command failure. + */ + uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + const uint16_t Operation, + const uint8_t TotalParams, + uint32_t* const Params) ATTR_NON_NULL_PTR_ARG(1); + + /** Receives and checks a response block from the attached PIMA device, once a command has been issued and all data + * associated with the command has been transferred. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device + * returned a logical command failure. + */ + uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Indicates if the device has issued a PIMA event block to the host via the asynchronous events pipe. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * + * \return Boolean true if an event is waiting to be read, false otherwise. + */ + bool SI_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Receives an asynchronous event block from the device via the asynchronous events pipe. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[out] PIMAHeader Pointer to a PIMA container structure where the event should be stored. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device + * returned a logical command failure. + */ + uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1) + ATTR_NON_NULL_PTR_ARG(2); + + /** Sends arbitrary data to the attached device, for use in the data phase of PIMA commands which require data + * transfer beyond the regular PIMA command block parameters. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[in] Buffer Pointer to a buffer where the data to send has been stored. + * \param[in] Bytes Length in bytes of the data in the buffer to send to the attached device. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t SI_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + void* Buffer, + const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Receives arbitrary data from the attached device, for use in the data phase of PIMA commands which require data + * transfer beyond the regular PIMA command block parameters. + * + * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the + * call will fail. + * + * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + * \param[out] Buffer Pointer to a buffer where the received data is to be stored. + * \param[in] Bytes Length in bytes of the data to read. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo, + void* Buffer, + const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /* Inline Functions: */ + /** General management task for a given Still Image host 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] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state. + */ + static inline void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + static inline void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) + { + (void)SIInterfaceInfo; + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define SI_COMMAND_DATA_TIMEOUT_MS 10000 + + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_STILLIMAGE_HOST_C) + static uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Host/StillImage.lst b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.lst new file mode 100644 index 0000000..7f91201 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.lst @@ -0,0 +1,19 @@ + 1 .file "StillImage.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 StillImage.c + /tmp/ccgWRdZN.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccgWRdZN.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccgWRdZN.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccgWRdZN.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccgWRdZN.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccgWRdZN.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/Class/Host/StillImage.o b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.o new file mode 100644 index 0000000..46bdbe2 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/Class/Host/StillImage.o differ diff --git a/firmware/LUFA/Drivers/USB/Class/MIDI.h b/firmware/LUFA/Drivers/USB/Class/MIDI.h new file mode 100644 index 0000000..d26c5f7 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/MIDI.h @@ -0,0 +1,83 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 MIDI Class driver. + * + * Master include file for the library USB MIDI 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_USBClassMIDI MIDI 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/MIDI.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/MIDI.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * MIDI Class Driver module. This module contains an internal implementation of the USB MIDI Class, for both Device + * and Host USB modes. User applications can use this class driver instead of implementing the MIDI 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 MIDI Class. + * + * \note The USB MIDI class is actually a special case of the regular Audio class, thus this module depends on + * structure definitions from the \ref Group_USBClassAudioDevice class driver module. + * + * @{ + */ + +#ifndef _MIDI_CLASS_H_ +#define _MIDI_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_MIDI_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/MIDI.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/MIDI.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/MassStorage.h b/firmware/LUFA/Drivers/USB/Class/MassStorage.h new file mode 100644 index 0000000..c4b03dd --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/MassStorage.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Mass Storage Class driver. + * + * Master include file for the library USB Mass Storage 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_USBClassMS Mass Storage 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/MassStorage.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/MassStorage.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Mass Storage Class Driver module. This module contains an internal implementation of the USB Mass Storage Class, for both + * Device and Host USB modes. User applications can use this class driver instead of implementing the Mass Storage 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 Mass Storage Class. + * + * @{ + */ + +#ifndef _MS_CLASS_H_ +#define _MS_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_MS_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/MassStorage.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/MassStorage.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/Printer.h b/firmware/LUFA/Drivers/USB/Class/Printer.h new file mode 100644 index 0000000..2d5504f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/Printer.h @@ -0,0 +1,77 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Printer Class driver. + * + * Master include file for the library USB Printer 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_USBClassPrinter Printer 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/Host/Printer.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Printer Class Driver module. This module contains an internal implementation of the USB Printer Class, for the base + * USB Printer transport layer for USB Host mode only. Note that printers are free to implement whatever printer language + * they choose on top of this (e.g. Postscript), and so this driver exposes low level data transport functions only rather + * than high level raster or text functions. User applications can use this class driver instead of implementing the Printer + * 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 + * Devices using the USB Printer Class. + * + * @{ + */ + +#ifndef _PRINTER_CLASS_H_ +#define _PRINTER_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_PRINTER_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_HOST) + #include "Host/Printer.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/RNDIS.h b/firmware/LUFA/Drivers/USB/Class/RNDIS.h new file mode 100644 index 0000000..98dbda4 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/RNDIS.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 RNDIS Class driver. + * + * Master include file for the library USB RNDIS 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_USBClassRNDIS RNDIS (Networking) 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/RNDIS.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/RNDIS.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * RNDIS Class Driver module. This module contains an internal implementation of the Microsoft USB RNDIS Networking + * Class, for both Device and Host USB modes. User applications can use this class driver instead of implementing the + * RNDIS 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 using the USB RNDIS Class. + * + * @{ + */ + +#ifndef _RNDIS_CLASS_H_ +#define _RNDIS_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_RNDIS_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/RNDIS.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/RNDIS.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/Class/StillImage.h b/firmware/LUFA/Drivers/USB/Class/StillImage.h new file mode 100644 index 0000000..dd1b16b --- /dev/null +++ b/firmware/LUFA/Drivers/USB/Class/StillImage.h @@ -0,0 +1,75 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Still Image Class driver. + * + * Master include file for the library USB Still Image 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_USBClassSI Still Image 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/Host/StillImage.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Module Description + * Still Image Class Driver module. This module contains an internal implementation of the USB Still Image Class, + * for USB Host mode only. User applications can use this class driver instead of implementing the Still Image 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 + * Devices using the USB Still Image Class. + * + * @{ + */ + +#ifndef _SI_CLASS_H_ +#define _SI_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_SI_DRIVER + + /* Includes: */ + #include "../HighLevel/USBMode.h" + + #if defined(USB_CAN_BE_HOST) + #include "Host/StillImage.h" + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c new file mode 100644 index 0000000..977d9e1 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c @@ -0,0 +1,142 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, + void* BufferPtr, 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 = 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/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h new file mode 100644 index 0000000..dc33391 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h @@ -0,0 +1,287 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Configuration descriptor parser API. + * + * 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. + * + * \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 + * + * Functions, macros, variables, enums and types related to the parsing of Configuration Descriptors. + * + * @{ + */ + +#ifndef __CONFIGDESCRIPTOR_H__ +#define __CONFIGDESCRIPTOR_H__ + + /* Includes: */ + #include + + #include "../../../Common/Common.h" + #include "HostStandardReq.h" + #include "USBMode.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: */ + /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared + * with the EP_TYPE_* masks to determine the exact type of the endpoint. + */ + #define EP_TYPE_MASK 0x03 + + /** 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 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 uint16_t 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(uint8_t ConfigNumber, uint16_t* const ConfigSizePtr, void* BufferPtr, + 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; + + *CurrConfigLoc = ((uint8_t*)*CurrConfigLoc) + CurrDescriptorSize; + *BytesRem -= CurrDescriptorSize; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.lst b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.lst new file mode 100644 index 0000000..d2407d9 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.lst @@ -0,0 +1,306 @@ + 1 .file "ConfigDescriptor.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_GetNextDescriptorOfType,"ax",@progbits + 17 .global USB_GetNextDescriptorOfType + 19 USB_GetNextDescriptorOfType: + 20 .LFB69: + 21 .LSM0: + 22 .LVL0: + 23 0000 CF93 push r28 + 24 0002 DF93 push r29 + 25 /* prologue: function */ + 26 /* frame size = 0 */ + 27 0004 EC01 movw r28,r24 + 28 0006 DB01 movw r26,r22 + 29 0008 00C0 rjmp .L2 + 30 .LVL1: + 31 .L4: + 32 .LBB9: + 33 .LBB10: + 34 .LSM1: + 35 000a ED91 ld r30,X+ + 36 000c FC91 ld r31,X + 37 000e 1197 sbiw r26,1 + 38 0010 2081 ld r18,Z + 39 .LVL2: + 40 0012 30E0 ldi r19,lo8(0) + 41 .LSM2: + 42 0014 E20F add r30,r18 + 43 0016 F31F adc r31,r19 + 44 .LVL3: + 45 0018 1196 adiw r26,1 + 46 001a FC93 st X,r31 + 47 001c EE93 st -X,r30 + 48 .LSM3: + 49 001e 8881 ld r24,Y + 50 0020 9981 ldd r25,Y+1 + 51 0022 821B sub r24,r18 + 52 0024 930B sbc r25,r19 + 53 0026 9983 std Y+1,r25 + 54 0028 8883 st Y,r24 + 55 .LBE10: + 56 .LBE9: + 57 .LSM4: + 58 002a ED91 ld r30,X+ + 59 002c FC91 ld r31,X + 60 002e 1197 sbiw r26,1 + 61 0030 8181 ldd r24,Z+1 + 62 0032 8417 cp r24,r20 + 63 0034 01F0 breq .L5 + 64 .LVL4: + 65 .L2: + 66 .LSM5: + 67 0036 8881 ld r24,Y + 68 0038 9981 ldd r25,Y+1 + 69 003a 892B or r24,r25 + 70 003c 01F4 brne .L4 + 71 .L5: + 72 /* epilogue start */ + 73 .LSM6: + 74 003e DF91 pop r29 + 75 0040 CF91 pop r28 + 76 .LVL5: + 77 0042 0895 ret + 78 .LFE69: + 80 .section .text.USB_GetNextDescriptorOfTypeBefore,"ax",@progbits + 81 .global USB_GetNextDescriptorOfTypeBefore + 83 USB_GetNextDescriptorOfTypeBefore: + 84 .LFB70: + 85 .LSM7: + 86 .LVL6: + 87 0000 CF93 push r28 + 88 0002 DF93 push r29 + 89 /* prologue: function */ + 90 /* frame size = 0 */ + 91 0004 DC01 movw r26,r24 + 92 0006 EB01 movw r28,r22 + 93 0008 522F mov r21,r18 + 94 000a 00C0 rjmp .L7 + 95 .LVL7: + 96 .L9: + 97 .LBB11: + 98 .LBB12: + 99 .LSM8: + 100 000c E881 ld r30,Y + 101 000e F981 ldd r31,Y+1 + 102 0010 2081 ld r18,Z + 103 .LVL8: + 104 0012 30E0 ldi r19,lo8(0) + 105 .LSM9: + 106 0014 E20F add r30,r18 + 107 0016 F31F adc r31,r19 + 108 .LVL9: + 109 0018 F983 std Y+1,r31 + 110 001a E883 st Y,r30 + 111 .LSM10: + 112 001c 8D91 ld r24,X+ + 113 001e 9C91 ld r25,X + 114 0020 1197 sbiw r26,1 + 115 0022 821B sub r24,r18 + 116 0024 930B sbc r25,r19 + 117 0026 1196 adiw r26,1 + 118 0028 9C93 st X,r25 + 119 002a 8E93 st -X,r24 + 120 .LBE12: + 121 .LBE11: + 122 .LSM11: + 123 002c E881 ld r30,Y + 124 002e F981 ldd r31,Y+1 + 125 0030 8181 ldd r24,Z+1 + 126 0032 8417 cp r24,r20 + 127 0034 01F0 breq .L10 + 128 .LSM12: + 129 0036 8517 cp r24,r21 + 130 0038 01F4 brne .L7 + 131 .LSM13: + 132 003a 1D92 st X+,__zero_reg__ + 133 003c 1C92 st X,__zero_reg__ + 134 003e 00C0 rjmp .L10 + 135 .LVL10: + 136 .L7: + 137 .LSM14: + 138 0040 8D91 ld r24,X+ + 139 0042 9C91 ld r25,X + 140 0044 1197 sbiw r26,1 + 141 0046 892B or r24,r25 + 142 0048 01F4 brne .L9 + 143 .L10: + 144 /* epilogue start */ + 145 .LSM15: + 146 004a DF91 pop r29 + 147 004c CF91 pop r28 + 148 .LVL11: + 149 004e 0895 ret + 150 .LFE70: + 152 .section .text.USB_GetNextDescriptorOfTypeAfter,"ax",@progbits + 153 .global USB_GetNextDescriptorOfTypeAfter + 155 USB_GetNextDescriptorOfTypeAfter: + 156 .LFB71: + 157 .LSM16: + 158 .LVL12: + 159 0000 FF92 push r15 + 160 0002 0F93 push r16 + 161 0004 1F93 push r17 + 162 0006 CF93 push r28 + 163 0008 DF93 push r29 + 164 /* prologue: function */ + 165 /* frame size = 0 */ + 166 000a EC01 movw r28,r24 + 167 000c 8B01 movw r16,r22 + 168 000e F42E mov r15,r20 + 169 .LSM17: + 170 0010 422F mov r20,r18 + 171 .LVL13: + 172 0012 0E94 0000 call USB_GetNextDescriptorOfType + 173 .LVL14: + 174 .LSM18: + 175 0016 8881 ld r24,Y + 176 0018 9981 ldd r25,Y+1 + 177 001a 892B or r24,r25 + 178 001c 01F0 breq .L14 + 179 .LSM19: + 180 001e CE01 movw r24,r28 + 181 0020 B801 movw r22,r16 + 182 0022 4F2D mov r20,r15 + 183 0024 0E94 0000 call USB_GetNextDescriptorOfType + 184 .L14: + 185 /* epilogue start */ + 186 .LSM20: + 187 0028 DF91 pop r29 + 188 002a CF91 pop r28 + 189 .LVL15: + 190 002c 1F91 pop r17 + 191 002e 0F91 pop r16 + 192 .LVL16: + 193 0030 FF90 pop r15 + 194 .LVL17: + 195 0032 0895 ret + 196 .LFE71: + 198 .section .text.USB_GetNextDescriptorComp,"ax",@progbits + 199 .global USB_GetNextDescriptorComp + 201 USB_GetNextDescriptorComp: + 202 .LFB72: + 203 .LSM21: + 204 .LVL18: + 205 0000 AF92 push r10 + 206 0002 BF92 push r11 + 207 0004 CF92 push r12 + 208 0006 DF92 push r13 + 209 0008 EF92 push r14 + 210 000a FF92 push r15 + 211 000c 0F93 push r16 + 212 000e 1F93 push r17 + 213 0010 CF93 push r28 + 214 0012 DF93 push r29 + 215 /* prologue: function */ + 216 /* frame size = 0 */ + 217 0014 7C01 movw r14,r24 + 218 0016 8B01 movw r16,r22 + 219 0018 5A01 movw r10,r20 + 220 001a 00C0 rjmp .L16 + 221 .LVL19: + 222 .L19: + 223 .LBB13: + 224 .LSM22: + 225 001c F801 movw r30,r16 + 226 001e C081 ld r28,Z + 227 0020 D181 ldd r29,Z+1 + 228 .LBB14: + 229 .LBB15: + 230 .LSM23: + 231 0022 8881 ld r24,Y + 232 .LVL20: + 233 0024 90E0 ldi r25,lo8(0) + 234 .LVL21: + 235 .LSM24: + 236 0026 9E01 movw r18,r28 + 237 0028 280F add r18,r24 + 238 002a 391F adc r19,r25 + 239 .LVL22: + 240 002c 3183 std Z+1,r19 + 241 002e 2083 st Z,r18 + 242 .LSM25: + 243 0030 F701 movw r30,r14 + 244 0032 2081 ld r18,Z + 245 0034 3181 ldd r19,Z+1 + 246 0036 281B sub r18,r24 + 247 0038 390B sbc r19,r25 + 248 003a 3183 std Z+1,r19 + 249 003c 2083 st Z,r18 + 250 .LBE15: + 251 .LBE14: + 252 .LSM26: + 253 003e F801 movw r30,r16 + 254 0040 8081 ld r24,Z + 255 0042 9181 ldd r25,Z+1 + 256 .LVL23: + 257 0044 F501 movw r30,r10 + 258 0046 0995 icall + 259 .LVL24: + 260 0048 8230 cpi r24,lo8(2) + 261 .LVL25: + 262 004a 01F0 breq .L16 + 263 .LSM27: + 264 004c 8130 cpi r24,lo8(1) + 265 004e 01F4 brne .L18 + 266 .LSM28: + 267 0050 F801 movw r30,r16 + 268 0052 C083 st Z,r28 + 269 0054 D183 std Z+1,r29 + 270 .LSM29: + 271 0056 F701 movw r30,r14 + 272 0058 D182 std Z+1,r13 + 273 005a C082 st Z,r12 + 274 005c 00C0 rjmp .L18 + 275 .LVL26: + 276 .L16: + 277 .LBE13: + 278 .LSM30: + 279 005e F701 movw r30,r14 + 280 0060 C080 ld r12,Z + 281 0062 D180 ldd r13,Z+1 + 282 0064 C114 cp r12,__zero_reg__ + 283 0066 D104 cpc r13,__zero_reg__ + 284 0068 01F4 brne .L19 + 285 006a 82E0 ldi r24,lo8(2) + 286 .LVL27: + 287 .L18: + 288 .LVL28: + 289 /* epilogue start */ + 290 .LSM31: + 291 006c DF91 pop r29 + 292 006e CF91 pop r28 + 293 0070 1F91 pop r17 + 294 0072 0F91 pop r16 + 295 .LVL29: + 296 0074 FF90 pop r15 + 297 0076 EF90 pop r14 + 298 .LVL30: + 299 0078 DF90 pop r13 + 300 007a CF90 pop r12 + 301 007c BF90 pop r11 + 302 007e AF90 pop r10 + 303 .LVL31: + 304 0080 0895 ret + 305 .LFE72: + 355 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 ConfigDescriptor.c + /tmp/cc806buQ.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cc806buQ.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cc806buQ.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cc806buQ.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cc806buQ.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cc806buQ.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/cc806buQ.s:19 .text.USB_GetNextDescriptorOfType:0000000000000000 USB_GetNextDescriptorOfType + /tmp/cc806buQ.s:83 .text.USB_GetNextDescriptorOfTypeBefore:0000000000000000 USB_GetNextDescriptorOfTypeBefore + /tmp/cc806buQ.s:155 .text.USB_GetNextDescriptorOfTypeAfter:0000000000000000 USB_GetNextDescriptorOfTypeAfter + /tmp/cc806buQ.s:201 .text.USB_GetNextDescriptorComp:0000000000000000 USB_GetNextDescriptorComp + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.o b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.o new file mode 100644 index 0000000..0173c2f Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.o differ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c new file mode 100644 index 0000000..a27151e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c @@ -0,0 +1,382 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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_ConfigurationNumber; + +#if !defined(NO_DEVICE_SELF_POWER) +bool USB_CurrentlySelfPowered; +#endif + +#if !defined(NO_DEVICE_REMOTE_WAKEUP) +bool USB_RemoteWakeupEnabled; +#endif + +void USB_Device_ProcessControlRequest(void) +{ + uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; + + for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) + *(RequestHeader++) = Endpoint_Read_Byte(); + + 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); + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + Endpoint_ClearSETUP(); + + Endpoint_ClearStatusStage(); + + while (!(Endpoint_IsINReady())); + + USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; + + USB_Device_SetDeviceAddress(DeviceAddress); + } +} + +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(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 + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr + #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS) + , &MemoryAddressSpace + #endif + ) == NO_DESCRIPTOR) + { + return; + } + + 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; + } + #endif + + Endpoint_ClearSETUP(); + + USB_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue; + + Endpoint_ClearStatusStage(); + + if (USB_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_Byte(USB_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; + wchar_t UnicodeString[20]; + } SignatureDescriptor; + + SignatureDescriptor.Header.Type = DTYPE_String; + SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor); + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + uint8_t SigReadAddress = 0x0E; + + for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++) + { + uint8_t SerialByte = boot_signature_byte_get(SigReadAddress); + + if (SerialCharNum & 0x01) + { + SerialByte >>= 4; + SigReadAddress++; + } + + SerialByte &= 0x0F; + + SignatureDescriptor.UnicodeString[SerialCharNum] = (SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte); + } + } + + 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(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(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS) + , &DescriptorAddressSpace + #endif + )) == NO_DESCRIPTOR) + { + return; + } + + Endpoint_ClearSETUP(); + + #if defined(USE_RAM_DESCRIPTORS) + 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_CurrentlySelfPowered) + CurrentStatus |= FEATURE_SELFPOWERED_ENABLED; + #endif + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + if (USB_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_Word_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_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_ResetFIFO(EndpointIndex); + Endpoint_ResetDataToggle(); + } + } + } + + break; + #endif + default: + return; + } + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + Endpoint_ClearSETUP(); + + Endpoint_ClearStatusStage(); +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.h b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.h new file mode 100644 index 0000000..df5a79a --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.h @@ -0,0 +1,165 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 + #include + #include + #include + #include + #include + + #include "StdDescriptors.h" + #include "Events.h" + #include "StdRequestType.h" + #include "USBTask.h" + #include "../LowLevel/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(USE_SINGLE_DEVICE_CONFIGURATION) + #define FIXED_NUM_CONFIGURATIONS 1 + #endif + + /* Enums: */ + #if !defined(USE_FLASH_DESCRIPTORS) && !defined(USE_EEPROM_DESCRIPTORS) && !defined(USE_RAM_DESCRIPTORS) + /** Enum for the possible descriptor memory spaces, for the MemoryAddressSpace of the + * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the USE_*_DESCRIPTORS + * compile time options are used, to indicate in which memory space the descriptor is stored. + * + * \ingroup Group_Device + */ + enum USB_DescriptorMemorySpaces_t + { + MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory. */ + MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */ + 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_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 + * 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_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_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/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.lst b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.lst new file mode 100644 index 0000000..eed7de6 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.lst @@ -0,0 +1,569 @@ + 1 .file "DeviceStandardReq.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_Device_ProcessControlRequest,"ax",@progbits + 17 .global USB_Device_ProcessControlRequest + 19 USB_Device_ProcessControlRequest: + 20 .LFB68: + 21 .LSM0: + 22 0000 0F93 push r16 + 23 0002 1F93 push r17 + 24 0004 DF93 push r29 + 25 0006 CF93 push r28 + 26 0008 00D0 rcall . + 27 000a CDB7 in r28,__SP_L__ + 28 000c DEB7 in r29,__SP_H__ + 29 /* prologue: function */ + 30 /* frame size = 2 */ + 31 .LSM1: + 32 000e E0E0 ldi r30,lo8(USB_ControlRequest) + 33 0010 F0E0 ldi r31,hi8(USB_ControlRequest) + 34 .LVL0: + 35 .L2: + 36 .LBB146: + 37 .LBB147: + 38 .LBB148: + 39 .LSM2: + 40 0012 8091 F100 lds r24,241 + 41 .LBE148: + 42 .LBE147: + 43 .LSM3: + 44 0016 8193 st Z+,r24 + 45 .LSM4: + 46 0018 80E0 ldi r24,hi8(USB_ControlRequest+8) + 47 001a E030 cpi r30,lo8(USB_ControlRequest+8) + 48 001c F807 cpc r31,r24 + 49 001e 01F4 brne .L2 + 50 .LBE146: + 51 .LSM5: + 52 0020 0E94 0000 call EVENT_USB_Device_ControlRequest + 53 .LVL1: + 54 .LBB149: + 55 .LBB150: + 56 .LSM6: + 57 0024 8091 E800 lds r24,232 + 58 .LBE150: + 59 .LBE149: + 60 .LSM7: + 61 0028 83FF sbrs r24,3 + 62 002a 00C0 rjmp .L3 + 63 .LBB151: + 64 .LSM8: + 65 002c 8091 0000 lds r24,USB_ControlRequest + 66 .LVL2: + 67 .LSM9: + 68 0030 3091 0000 lds r19,USB_ControlRequest+1 + 69 0034 3530 cpi r19,lo8(5) + 70 0036 01F4 brne .+2 + 71 0038 00C0 rjmp .L6 + 72 003a 3630 cpi r19,lo8(6) + 73 003c 00F4 brsh .L10 + 74 003e 3130 cpi r19,lo8(1) + 75 0040 01F0 breq .L5 + 76 0042 3130 cpi r19,lo8(1) + 77 0044 00F0 brlo .L4 + 78 0046 3330 cpi r19,lo8(3) + 79 0048 01F0 breq .+2 + 80 004a 00C0 rjmp .L3 + 81 004c 00C0 rjmp .L5 + 82 .L10: + 83 004e 3830 cpi r19,lo8(8) + 84 0050 01F4 brne .+2 + 85 0052 00C0 rjmp .L8 + 86 0054 3930 cpi r19,lo8(9) + 87 0056 01F4 brne .+2 + 88 0058 00C0 rjmp .L9 + 89 005a 3630 cpi r19,lo8(6) + 90 005c 01F0 breq .+2 + 91 005e 00C0 rjmp .L3 + 92 0060 00C0 rjmp .L34 + 93 .L4: + 94 .LSM10: + 95 0062 8038 cpi r24,lo8(-128) + 96 0064 01F0 breq .L11 + 97 0066 8238 cpi r24,lo8(-126) + 98 0068 01F0 breq .+2 + 99 006a 00C0 rjmp .L3 + 100 006c 00C0 rjmp .L35 + 101 .L11: + 102 006e 9091 0000 lds r25,USB_CurrentlySelfPowered + 103 .LVL3: + 104 .LBB152: + 105 .LBB153: + 106 .LSM11: + 107 0072 8091 0000 lds r24,USB_RemoteWakeupEnabled + 108 .LVL4: + 109 0076 8823 tst r24 + 110 0078 01F0 breq .L13 + 111 .LSM12: + 112 007a 9260 ori r25,lo8(2) + 113 007c 00C0 rjmp .L13 + 114 .LVL5: + 115 .L35: + 116 .LSM13: + 117 007e 8091 0000 lds r24,USB_ControlRequest+4 + 118 .LVL6: + 119 0082 8770 andi r24,lo8(7) + 120 .LBB154: + 121 .LBB155: + 122 .LSM14: + 123 0084 8093 E900 sts 233,r24 + 124 .LBE155: + 125 .LBE154: + 126 .LBB156: + 127 .LBB157: + 128 .LSM15: + 129 0088 8091 EB00 lds r24,235 + 130 .LBE157: + 131 .LBE156: + 132 .LSM16: + 133 008c 90E0 ldi r25,lo8(0) + 134 008e 25E0 ldi r18,5 + 135 0090 9695 1: lsr r25 + 136 0092 8795 ror r24 + 137 0094 2A95 dec r18 + 138 0096 01F4 brne 1b + 139 0098 982F mov r25,r24 + 140 .LVL7: + 141 009a 9170 andi r25,lo8(1) + 142 .LBB158: + 143 .LBB159: + 144 .LSM17: + 145 009c 1092 E900 sts 233,__zero_reg__ + 146 .L13: + 147 .LBE159: + 148 .LBE158: + 149 .LBB160: + 150 .LBB161: + 151 .LSM18: + 152 00a0 8091 E800 lds r24,232 + 153 00a4 877F andi r24,lo8(-9) + 154 00a6 8093 E800 sts 232,r24 + 155 .LBE161: + 156 .LBE160: + 157 .LBB162: + 158 .LBB163: + 159 .LSM19: + 160 00aa 9093 F100 sts 241,r25 + 161 .LSM20: + 162 00ae 1092 F100 sts 241,__zero_reg__ + 163 00b2 00C0 rjmp .L33 + 164 .LVL8: + 165 .L5: + 166 .LBE163: + 167 .LBE162: + 168 .LBE153: + 169 .LBE152: + 170 .LSM21: + 171 00b4 8823 tst r24 + 172 00b6 01F0 breq .L14 + 173 00b8 8230 cpi r24,lo8(2) + 174 00ba 01F0 breq .+2 + 175 00bc 00C0 rjmp .L3 + 176 .L14: + 177 .LBB164: + 178 .LBB165: + 179 .LSM22: + 180 00be 90E0 ldi r25,lo8(0) + 181 00c0 8F71 andi r24,lo8(31) + 182 00c2 9070 andi r25,hi8(31) + 183 .LVL9: + 184 00c4 0097 sbiw r24,0 + 185 00c6 01F0 breq .L15 + 186 00c8 0297 sbiw r24,2 + 187 00ca 01F0 breq .+2 + 188 00cc 00C0 rjmp .L3 + 189 00ce 00C0 rjmp .L36 + 190 .L15: + 191 .LSM23: + 192 00d0 8091 0000 lds r24,USB_ControlRequest+2 + 193 00d4 8130 cpi r24,lo8(1) + 194 00d6 01F0 breq .+2 + 195 00d8 00C0 rjmp .L3 + 196 .LSM24: + 197 00da 1092 0000 sts USB_RemoteWakeupEnabled,__zero_reg__ + 198 00de 3330 cpi r19,lo8(3) + 199 00e0 01F4 brne .L18 + 200 00e2 8093 0000 sts USB_RemoteWakeupEnabled,r24 + 201 00e6 00C0 rjmp .L18 + 202 .L36: + 203 .LSM25: + 204 00e8 8091 0000 lds r24,USB_ControlRequest+2 + 205 00ec 8823 tst r24 + 206 00ee 01F4 brne .L18 + 207 .LBB166: + 208 .LSM26: + 209 00f0 2091 0000 lds r18,USB_ControlRequest+4 + 210 .LVL10: + 211 00f4 2770 andi r18,lo8(7) + 212 .LSM27: + 213 00f6 01F4 brne .+2 + 214 00f8 00C0 rjmp .L3 + 215 .LBB167: + 216 .LBB168: + 217 .LSM28: + 218 00fa 2093 E900 sts 233,r18 + 219 .LBE168: + 220 .LBE167: + 221 .LBB169: + 222 .LBB170: + 223 .LSM29: + 224 00fe 8091 EB00 lds r24,235 + 225 .LBE170: + 226 .LBE169: + 227 .LSM30: + 228 0102 80FF sbrs r24,0 + 229 0104 00C0 rjmp .L18 + 230 .LSM31: + 231 0106 3330 cpi r19,lo8(3) + 232 0108 01F4 brne .L19 + 233 .LBB171: + 234 .LBB172: + 235 .LSM32: + 236 010a 8091 EB00 lds r24,235 + 237 010e 8062 ori r24,lo8(32) + 238 0110 00C0 rjmp .L31 + 239 .L19: + 240 .LBE172: + 241 .LBE171: + 242 .LBB173: + 243 .LBB174: + 244 .LSM33: + 245 0112 8091 EB00 lds r24,235 + 246 0116 8061 ori r24,lo8(16) + 247 0118 8093 EB00 sts 235,r24 + 248 .LBE174: + 249 .LBE173: + 250 .LBB175: + 251 .LBB176: + 252 .LSM34: + 253 011c 81E0 ldi r24,lo8(1) + 254 011e 90E0 ldi r25,hi8(1) + 255 0120 00C0 rjmp 2f + 256 0122 880F 1: lsl r24 + 257 0124 991F rol r25 + 258 0126 2A95 2: dec r18 + 259 0128 02F4 brpl 1b + 260 012a 8093 EA00 sts 234,r24 + 261 .LSM35: + 262 012e 1092 EA00 sts 234,__zero_reg__ + 263 .LBE176: + 264 .LBE175: + 265 .LBB177: + 266 .LBB178: + 267 .LSM36: + 268 0132 8091 EB00 lds r24,235 + 269 0136 8860 ori r24,lo8(8) + 270 .L31: + 271 0138 8093 EB00 sts 235,r24 + 272 .L18: + 273 .LBE178: + 274 .LBE177: + 275 .LBE166: + 276 .LBB179: + 277 .LBB180: + 278 .LSM37: + 279 013c 1092 E900 sts 233,__zero_reg__ + 280 .LBE180: + 281 .LBE179: + 282 .LBB181: + 283 .LBB182: + 284 .LSM38: + 285 0140 8091 E800 lds r24,232 + 286 0144 877F andi r24,lo8(-9) + 287 0146 00C0 rjmp .L32 + 288 .LVL11: + 289 .L6: + 290 .LBE182: + 291 .LBE181: + 292 .LBE165: + 293 .LBE164: + 294 .LSM39: + 295 0148 8823 tst r24 + 296 014a 01F0 breq .+2 + 297 014c 00C0 rjmp .L3 + 298 .LBB183: + 299 .LBB184: + 300 .LSM40: + 301 014e 1091 0000 lds r17,USB_ControlRequest+2 + 302 .LVL12: + 303 0152 1F77 andi r17,lo8(127) + 304 .LBB185: + 305 .LSM41: + 306 0154 0FB7 in r16,__SREG__ + 307 .LBB186: + 308 .LBB187: + 309 .LSM42: + 310 /* #APP */ + 311 ; 50 "/usr/lib/gcc/avr/4.3.5/../../../avr/include/util/atomic.h" 1 + 312 0156 F894 cli + 313 ; 0 "" 2 + 314 /* #NOAPP */ + 315 .LBE187: + 316 .LBE186: + 317 .LBB188: + 318 .LBB189: + 319 .LSM43: + 320 0158 8091 E800 lds r24,232 + 321 .LVL13: + 322 015c 877F andi r24,lo8(-9) + 323 015e 8093 E800 sts 232,r24 + 324 .LBE189: + 325 .LBE188: + 326 .LSM44: + 327 0162 0E94 0000 call Endpoint_ClearStatusStage + 328 .L20: + 329 .LBB190: + 330 .LBB191: + 331 .LSM45: + 332 0166 8091 E800 lds r24,232 + 333 .LBE191: + 334 .LBE190: + 335 .LSM46: + 336 016a 80FF sbrs r24,0 + 337 016c 00C0 rjmp .L20 + 338 .LSM47: + 339 016e 1123 tst r17 + 340 0170 01F4 brne .L21 + 341 0172 82E0 ldi r24,lo8(2) + 342 0174 00C0 rjmp .L22 + 343 .L21: + 344 0176 83E0 ldi r24,lo8(3) + 345 .L22: + 346 0178 8093 0000 sts USB_DeviceState,r24 + 347 .LBB192: + 348 .LBB193: + 349 .LSM48: + 350 017c 8091 E300 lds r24,227 + 351 0180 8078 andi r24,lo8(-128) + 352 0182 182B or r17,r24 + 353 0184 1093 E300 sts 227,r17 + 354 .LSM49: + 355 0188 8091 E300 lds r24,227 + 356 018c 8068 ori r24,lo8(-128) + 357 018e 8093 E300 sts 227,r24 + 358 .LBE193: + 359 .LBE192: + 360 .LBB194: + 361 .LBB195: + 362 .LSM50: + 363 0192 0FBF out __SREG__,r16 + 364 .LSM51: + 365 0194 00C0 rjmp .L3 + 366 .LVL14: + 367 .L34: + 368 .LBE195: + 369 .LBE194: + 370 .LBE185: + 371 .LBE184: + 372 .LBE183: + 373 .LSM52: + 374 0196 8058 subi r24,lo8(-(-128)) + 375 0198 8230 cpi r24,lo8(2) + 376 019a 00F0 brlo .+2 + 377 019c 00C0 rjmp .L3 + 378 .LBB196: + 379 .LSM53: + 380 019e 8091 0000 lds r24,USB_ControlRequest+2 + 381 01a2 9091 0000 lds r25,(USB_ControlRequest+2)+1 + 382 .LVL15: + 383 01a6 6091 0000 lds r22,USB_ControlRequest+4 + 384 01aa AE01 movw r20,r28 + 385 01ac 4F5F subi r20,lo8(-(1)) + 386 01ae 5F4F sbci r21,hi8(-(1)) + 387 01b0 0E94 0000 call CALLBACK_USB_GetDescriptor + 388 01b4 BC01 movw r22,r24 + 389 .LVL16: + 390 .LBB197: + 391 01b6 0097 sbiw r24,0 + 392 01b8 01F4 brne .+2 + 393 01ba 00C0 rjmp .L3 + 394 .LVL17: + 395 .LBB198: + 396 .LBB199: + 397 .LSM54: + 398 01bc 8091 E800 lds r24,232 + 399 .LVL18: + 400 01c0 877F andi r24,lo8(-9) + 401 01c2 8093 E800 sts 232,r24 + 402 .LBE199: + 403 .LBE198: + 404 .LSM55: + 405 01c6 8981 ldd r24,Y+1 + 406 01c8 9A81 ldd r25,Y+2 + 407 .LVL19: + 408 01ca 0E94 0000 call Endpoint_Write_Control_PStream_LE + 409 .LVL20: + 410 .LBB200: + 411 .LBB201: + 412 .LSM56: + 413 01ce 8091 E800 lds r24,232 + 414 01d2 8B77 andi r24,lo8(123) + 415 01d4 8093 E800 sts 232,r24 + 416 01d8 00C0 rjmp .L3 + 417 .LVL21: + 418 .L8: + 419 .LBE201: + 420 .LBE200: + 421 .LBE197: + 422 .LBE196: + 423 .LSM57: + 424 01da 8038 cpi r24,lo8(-128) + 425 01dc 01F4 brne .L3 + 426 .LBB202: + 427 .LBB203: + 428 .LBB204: + 429 .LBB205: + 430 .LSM58: + 431 01de 8091 E800 lds r24,232 + 432 .LVL22: + 433 01e2 877F andi r24,lo8(-9) + 434 01e4 8093 E800 sts 232,r24 + 435 .LBE205: + 436 .LBE204: + 437 .LSM59: + 438 01e8 8091 0000 lds r24,USB_ConfigurationNumber + 439 .LBB206: + 440 .LBB207: + 441 .LSM60: + 442 01ec 8093 F100 sts 241,r24 + 443 .LVL23: + 444 .L33: + 445 .LBE207: + 446 .LBE206: + 447 .LBB208: + 448 .LBB209: + 449 .LSM61: + 450 01f0 8091 E800 lds r24,232 + 451 01f4 8E77 andi r24,lo8(126) + 452 .LVL24: + 453 .L32: + 454 01f6 8093 E800 sts 232,r24 + 455 .LBE209: + 456 .LBE208: + 457 .LSM62: + 458 01fa 0E94 0000 call Endpoint_ClearStatusStage + 459 .LVL25: + 460 01fe 00C0 rjmp .L3 + 461 .LVL26: + 462 .L9: + 463 .LBE203: + 464 .LBE202: + 465 .LSM63: + 466 0200 8823 tst r24 + 467 0202 01F4 brne .L3 + 468 .LBB210: + 469 .LBB211: + 470 .LSM64: + 471 0204 9091 0000 lds r25,USB_ControlRequest+2 + 472 0208 9230 cpi r25,lo8(2) + 473 020a 00F4 brsh .L3 + 474 .LBB212: + 475 .LBB213: + 476 .LSM65: + 477 020c 8091 E800 lds r24,232 + 478 .LVL27: + 479 0210 877F andi r24,lo8(-9) + 480 0212 8093 E800 sts 232,r24 + 481 .LBE213: + 482 .LBE212: + 483 .LSM66: + 484 0216 9093 0000 sts USB_ConfigurationNumber,r25 + 485 .LSM67: + 486 021a 0E94 0000 call Endpoint_ClearStatusStage + 487 .LSM68: + 488 021e 8091 0000 lds r24,USB_ConfigurationNumber + 489 0222 8823 tst r24 + 490 0224 01F4 brne .L25 + 491 .L23: + 492 .LBB214: + 493 .LBB215: + 494 .LSM69: + 495 0226 8091 E300 lds r24,227 + 496 .LBE215: + 497 .LBE214: + 498 .LSM70: + 499 022a 87FD sbrc r24,7 + 500 022c 00C0 rjmp .L25 + 501 022e 81E0 ldi r24,lo8(1) + 502 0230 00C0 rjmp .L26 + 503 .L25: + 504 0232 84E0 ldi r24,lo8(4) + 505 .L26: + 506 0234 8093 0000 sts USB_DeviceState,r24 + 507 .LSM71: + 508 0238 0E94 0000 call EVENT_USB_Device_ConfigurationChanged + 509 .LVL28: + 510 .L3: + 511 .LBE211: + 512 .LBE210: + 513 .LBE151: + 514 .LBB216: + 515 .LBB217: + 516 .LSM72: + 517 023c 8091 E800 lds r24,232 + 518 .LVL29: + 519 .LBE217: + 520 .LBE216: + 521 .LSM73: + 522 0240 83FF sbrs r24,3 + 523 0242 00C0 rjmp .L28 + 524 .LBB218: + 525 .LBB219: + 526 .LSM74: + 527 0244 8091 EB00 lds r24,235 + 528 0248 8062 ori r24,lo8(32) + 529 024a 8093 EB00 sts 235,r24 + 530 .LBE219: + 531 .LBE218: + 532 .LBB220: + 533 .LBB221: + 534 .LSM75: + 535 024e 8091 E800 lds r24,232 + 536 0252 877F andi r24,lo8(-9) + 537 0254 8093 E800 sts 232,r24 + 538 .L28: + 539 /* epilogue start */ + 540 .LBE221: + 541 .LBE220: + 542 .LSM76: + 543 0258 0F90 pop __tmp_reg__ + 544 025a 0F90 pop __tmp_reg__ + 545 025c CF91 pop r28 + 546 025e DF91 pop r29 + 547 0260 1F91 pop r17 + 548 .LVL30: + 549 0262 0F91 pop r16 + 550 0264 0895 ret + 551 .LFE68: + 553 .comm USB_ConfigurationNumber,1,1 + 554 .comm USB_RemoteWakeupEnabled,1,1 + 555 .comm USB_CurrentlySelfPowered,1,1 + 580 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 DeviceStandardReq.c + /tmp/ccT135RT.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccT135RT.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccT135RT.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccT135RT.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccT135RT.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccT135RT.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccT135RT.s:19 .text.USB_Device_ProcessControlRequest:0000000000000000 USB_Device_ProcessControlRequest + *COM*:0000000000000001 USB_CurrentlySelfPowered + *COM*:0000000000000001 USB_RemoteWakeupEnabled + *COM*:0000000000000001 USB_ConfigurationNumber + +UNDEFINED SYMBOLS +USB_ControlRequest +EVENT_USB_Device_ControlRequest +Endpoint_ClearStatusStage +USB_DeviceState +CALLBACK_USB_GetDescriptor +Endpoint_Write_Control_PStream_LE +EVENT_USB_Device_ConfigurationChanged +__do_clear_bss diff --git a/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.o b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.o new file mode 100644 index 0000000..5984660 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/DeviceStandardReq.o differ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.c b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.c new file mode 100644 index 0000000..7e92b7e --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.c @@ -0,0 +1,233 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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.h" + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_Discard_Stream(uint16_t Length + __CALLBACK_PARAM) +{ + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + Endpoint_Discard_Byte(); + case 7: Endpoint_Discard_Byte(); + case 6: Endpoint_Discard_Byte(); + case 5: Endpoint_Discard_Byte(); + case 4: Endpoint_Discard_Byte(); + case 3: Endpoint_Discard_Byte(); + case 2: Endpoint_Discard_Byte(); + case 1: Endpoint_Discard_Byte(); + } while (Length >= 8); + } + } + #endif + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Discard_Byte(); + Length--; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +#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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)BufferPtr++)) +#include "Template/Template_Endpoint_RW.c" + +#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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) +#include "Template/Template_Endpoint_RW.c" + +#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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte() +#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_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) +#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_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte() +#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_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) +#include "Template/Template_Endpoint_RW.c" + +#endif + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)BufferPtr++)) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte() +#include "Template/Template_Endpoint_Control_R.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) +#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_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte() +#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_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) +#include "Template/Template_Endpoint_Control_R.c" + +#endif diff --git a/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.h b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.h new file mode 100644 index 0000000..a8b9021 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.h @@ -0,0 +1,524 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 endpoint stream function definitions. + * + * This file contains structures, function prototypes and macros related to the sending and receiving of + * arbitrary data streams through the device's data endpoints when the library is initialized 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. + */ + +/** \ingroup Group_EndpointRW + * @defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams + * + * 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 + #include + #include + + #include "../../../Common/Common.h" + #include "USBTask.h" + + #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__) + #include "StreamCallbacks.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 + + #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__) + #define __CALLBACK_PARAM , StreamCallbackPtr_t Callback + #else + #define __CALLBACK_PARAM + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the possible error return codes of the 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_CallbackAborted = 5, /**< Indicates that the stream's callback function + * aborted the transfer early. + */ + }; + + /** Enum for the possible error return codes of the 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. + */ + }; + + /* Function Prototypes: */ + /** Reads and discards the given number of bytes from the endpoint from the given buffer, + * 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. 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. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Discard_Stream(uint16_t Length + __CALLBACK_PARAM); + + /** 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. Between each USB packet, the given stream callback function + * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early + * aborts of stream transfers. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * \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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_LE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /** 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_LE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /** 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_LE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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. Between each USB packet, the given stream callback function + * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early + * aborts of stream transfers. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * \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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_BE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_BE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_BE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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. Between + * each USB packet, the given stream callback function is executed repeatedly until the endpoint + * is ready to accept the next packet, allowing for early aborts of stream transfers. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * \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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_LE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_LE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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. Between + * each USB packet, the given stream callback function is executed repeatedly until the endpoint + * is ready to accept the next packet, allowing for early aborts of stream transfers. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * \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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_BE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_BE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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* Buffer, + uint16_t Length) 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. + * + * \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* Buffer, + uint16_t Length) 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. + * + * \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* 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* 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. + * + * \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* 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. + * + * \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* 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* 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. + * + * \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* 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* 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. + * + * \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* Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.lst b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.lst new file mode 100644 index 0000000..47a008f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.lst @@ -0,0 +1,3174 @@ + 1 .file "EndpointStream.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.Endpoint_Write_Control_Stream_LE,"ax",@progbits + 17 .global Endpoint_Write_Control_Stream_LE + 19 Endpoint_Write_Control_Stream_LE: + 20 .LFB79: + 21 .LSM0: + 22 .LVL0: + 23 /* prologue: function */ + 24 /* frame size = 0 */ + 25 0000 9C01 movw r18,r24 + 26 .LVL1: + 27 .LSM1: + 28 0002 4091 0000 lds r20,USB_ControlRequest+6 + 29 0006 5091 0000 lds r21,(USB_ControlRequest+6)+1 + 30 .LVL2: + 31 000a 4617 cp r20,r22 + 32 000c 5707 cpc r21,r23 + 33 000e 00F4 brsh .L2 + 34 .L5: + 35 .LSM2: + 36 0010 F901 movw r30,r18 + 37 .LVL3: + 38 0012 90E0 ldi r25,lo8(0) + 39 .LVL4: + 40 0014 00C0 rjmp .L21 + 41 .LVL5: + 42 .L2: + 43 .LSM3: + 44 0016 6115 cp r22,__zero_reg__ + 45 0018 7105 cpc r23,__zero_reg__ + 46 001a 01F0 breq .L4 + 47 .LVL6: + 48 001c AB01 movw r20,r22 + 49 001e 00C0 rjmp .L5 + 50 .L4: + 51 .LBB250: + 52 .LBB251: + 53 .LSM4: + 54 0020 8091 E800 lds r24,232 + 55 0024 8E77 andi r24,lo8(126) + 56 0026 8093 E800 sts 232,r24 + 57 002a 40E0 ldi r20,lo8(0) + 58 002c 50E0 ldi r21,hi8(0) + 59 .LVL7: + 60 002e 00C0 rjmp .L5 + 61 .LVL8: + 62 .L15: + 63 .LBE251: + 64 .LBE250: + 65 .LBB252: + 66 .LSM5: + 67 0030 8091 0000 lds r24,USB_DeviceState + 68 .LVL9: + 69 .LSM6: + 70 0034 8823 tst r24 + 71 0036 01F0 breq .L6 + 72 .LSM7: + 73 0038 8530 cpi r24,lo8(5) + 74 003a 01F0 breq .L7 + 75 .LBB253: + 76 .LBB254: + 77 .LSM8: + 78 003c 8091 E800 lds r24,232 + 79 .LVL10: + 80 .LBE254: + 81 .LBE253: + 82 .LSM9: + 83 0040 83FF sbrs r24,3 + 84 0042 00C0 rjmp .L8 + 85 0044 81E0 ldi r24,lo8(1) + 86 0046 0895 ret + 87 .L8: + 88 .LBB255: + 89 .LBB256: + 90 .LSM10: + 91 0048 8091 E800 lds r24,232 + 92 .LBE256: + 93 .LBE255: + 94 .LSM11: + 95 004c 82FD sbrc r24,2 + 96 004e 00C0 rjmp .L19 + 97 .LBB257: + 98 .LBB258: + 99 .LSM12: + 100 0050 8091 E800 lds r24,232 + 101 .LBE258: + 102 .LBE257: + 103 .LSM13: + 104 0054 80FF sbrs r24,0 + 105 0056 00C0 rjmp .L21 + 106 .LBB259: + 107 .LBB260: + 108 .LBB261: + 109 .LSM14: + 110 0058 8091 F200 lds r24,242 + 111 005c 282F mov r18,r24 + 112 005e 30E0 ldi r19,lo8(0) + 113 0060 00C0 rjmp .L11 + 114 .L13: + 115 .LBE261: + 116 .LBE260: + 117 .LSM15: + 118 0062 8191 ld r24,Z+ + 119 .LBB262: + 120 .LBB263: + 121 .LSM16: + 122 0064 8093 F100 sts 241,r24 + 123 .LBE263: + 124 .LBE262: + 125 .LSM17: + 126 0068 4150 subi r20,lo8(-(-1)) + 127 006a 5040 sbci r21,hi8(-(-1)) + 128 .LSM18: + 129 006c 2F5F subi r18,lo8(-(1)) + 130 006e 3F4F sbci r19,hi8(-(1)) + 131 .LVL11: + 132 .L11: + 133 .LSM19: + 134 0070 4115 cp r20,__zero_reg__ + 135 0072 5105 cpc r21,__zero_reg__ + 136 0074 01F0 breq .L12 + 137 0076 2830 cpi r18,8 + 138 0078 3105 cpc r19,__zero_reg__ + 139 007a 00F0 brlo .L13 + 140 .L12: + 141 .LSM20: + 142 007c 90E0 ldi r25,lo8(0) + 143 007e 2830 cpi r18,8 + 144 0080 3105 cpc r19,__zero_reg__ + 145 0082 01F4 brne .L14 + 146 0084 91E0 ldi r25,lo8(1) + 147 .L14: + 148 .LBB264: + 149 .LBB265: + 150 .LSM21: + 151 0086 8091 E800 lds r24,232 + 152 008a 8E77 andi r24,lo8(126) + 153 008c 8093 E800 sts 232,r24 + 154 .LVL12: + 155 .L21: + 156 .LBE265: + 157 .LBE264: + 158 .LBE259: + 159 .LBE252: + 160 .LSM22: + 161 0090 4115 cp r20,__zero_reg__ + 162 0092 5105 cpc r21,__zero_reg__ + 163 0094 01F4 brne .L15 + 164 0096 9923 tst r25 + 165 0098 01F4 brne .L15 + 166 009a 00C0 rjmp .L19 + 167 .L16: + 168 .LBB266: + 169 .LSM23: + 170 009c 8091 0000 lds r24,USB_DeviceState + 171 .LVL13: + 172 .LSM24: + 173 00a0 8823 tst r24 + 174 00a2 01F0 breq .L6 + 175 .LSM25: + 176 00a4 8530 cpi r24,lo8(5) + 177 00a6 01F0 breq .L7 + 178 .L19: + 179 .LBE266: + 180 .LBB267: + 181 .LBB268: + 182 .LSM26: + 183 00a8 8091 E800 lds r24,232 + 184 .LVL14: + 185 .LBE268: + 186 .LBE267: + 187 .LSM27: + 188 00ac 82FF sbrs r24,2 + 189 00ae 00C0 rjmp .L16 + 190 00b0 80E0 ldi r24,lo8(0) + 191 00b2 0895 ret + 192 .LVL15: + 193 .L6: + 194 00b4 82E0 ldi r24,lo8(2) + 195 .LVL16: + 196 00b6 0895 ret + 197 .LVL17: + 198 .L7: + 199 00b8 83E0 ldi r24,lo8(3) + 200 .LVL18: + 201 .LSM28: + 202 00ba 0895 ret + 203 .LFE79: + 205 .section .text.Endpoint_Write_Control_PStream_LE,"ax",@progbits + 206 .global Endpoint_Write_Control_PStream_LE + 208 Endpoint_Write_Control_PStream_LE: + 209 .LFB80: + 210 .LSM29: + 211 .LVL19: + 212 /* prologue: function */ + 213 /* frame size = 0 */ + 214 0000 9C01 movw r18,r24 + 215 .LVL20: + 216 .LSM30: + 217 0002 4091 0000 lds r20,USB_ControlRequest+6 + 218 0006 5091 0000 lds r21,(USB_ControlRequest+6)+1 + 219 .LVL21: + 220 000a 4617 cp r20,r22 + 221 000c 5707 cpc r21,r23 + 222 000e 00F4 brsh .L23 + 223 .L26: + 224 .LSM31: + 225 0010 60E0 ldi r22,lo8(0) + 226 .LVL22: + 227 0012 00C0 rjmp .L42 + 228 .LVL23: + 229 .L23: + 230 .LSM32: + 231 0014 6115 cp r22,__zero_reg__ + 232 0016 7105 cpc r23,__zero_reg__ + 233 0018 01F0 breq .L25 + 234 .LVL24: + 235 001a AB01 movw r20,r22 + 236 001c 00C0 rjmp .L26 + 237 .L25: + 238 .LBB269: + 239 .LBB270: + 240 .LSM33: + 241 001e 8091 E800 lds r24,232 + 242 0022 8E77 andi r24,lo8(126) + 243 0024 8093 E800 sts 232,r24 + 244 0028 40E0 ldi r20,lo8(0) + 245 002a 50E0 ldi r21,hi8(0) + 246 .LVL25: + 247 002c 00C0 rjmp .L26 + 248 .LVL26: + 249 .L36: + 250 .LBE270: + 251 .LBE269: + 252 .LBB271: + 253 .LSM34: + 254 002e 8091 0000 lds r24,USB_DeviceState + 255 .LVL27: + 256 .LSM35: + 257 0032 8823 tst r24 + 258 0034 01F4 brne .+2 + 259 0036 00C0 rjmp .L27 + 260 .LSM36: + 261 0038 8530 cpi r24,lo8(5) + 262 003a 01F4 brne .+2 + 263 003c 00C0 rjmp .L28 + 264 .LBB272: + 265 .LBB273: + 266 .LSM37: + 267 003e 8091 E800 lds r24,232 + 268 .LVL28: + 269 .LBE273: + 270 .LBE272: + 271 .LSM38: + 272 0042 83FF sbrs r24,3 + 273 0044 00C0 rjmp .L29 + 274 0046 81E0 ldi r24,lo8(1) + 275 0048 0895 ret + 276 .L29: + 277 .LBB274: + 278 .LBB275: + 279 .LSM39: + 280 004a 8091 E800 lds r24,232 + 281 .LBE275: + 282 .LBE274: + 283 .LSM40: + 284 004e 82FD sbrc r24,2 + 285 0050 00C0 rjmp .L40 + 286 .LBB276: + 287 .LBB277: + 288 .LSM41: + 289 0052 8091 E800 lds r24,232 + 290 .LBE277: + 291 .LBE276: + 292 .LSM42: + 293 0056 80FF sbrs r24,0 + 294 0058 00C0 rjmp .L42 + 295 .LBB278: + 296 .LBB279: + 297 .LBB280: + 298 .LSM43: + 299 005a 8091 F200 lds r24,242 + 300 005e 90E0 ldi r25,lo8(0) + 301 0060 00C0 rjmp .L32 + 302 .LVL29: + 303 .L34: + 304 .LSM44: + 305 0062 F901 movw r30,r18 + 306 .LVL30: + 307 .LBE280: + 308 .LBE279: + 309 .LBB281: + 310 .LSM45: + 311 0064 2F5F subi r18,lo8(-(1)) + 312 0066 3F4F sbci r19,hi8(-(1)) + 313 /* #APP */ + 314 ; 31 "LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_W.c" 1 + 315 0068 E491 lpm r30, Z + 316 + 317 ; 0 "" 2 + 318 .LVL31: + 319 /* #NOAPP */ + 320 .LBE281: + 321 .LBB282: + 322 .LBB283: + 323 .LSM46: + 324 006a E093 F100 sts 241,r30 + 325 .LBE283: + 326 .LBE282: + 327 .LSM47: + 328 006e 4150 subi r20,lo8(-(-1)) + 329 0070 5040 sbci r21,hi8(-(-1)) + 330 .LSM48: + 331 0072 0196 adiw r24,1 + 332 .L32: + 333 .LSM49: + 334 0074 4115 cp r20,__zero_reg__ + 335 0076 5105 cpc r21,__zero_reg__ + 336 0078 01F0 breq .L33 + 337 007a 8830 cpi r24,8 + 338 007c 9105 cpc r25,__zero_reg__ + 339 007e 00F0 brlo .L34 + 340 .L33: + 341 .LSM50: + 342 0080 60E0 ldi r22,lo8(0) + 343 0082 0897 sbiw r24,8 + 344 0084 01F4 brne .L35 + 345 0086 61E0 ldi r22,lo8(1) + 346 .L35: + 347 .LBB284: + 348 .LBB285: + 349 .LSM51: + 350 0088 8091 E800 lds r24,232 + 351 .LVL32: + 352 008c 8E77 andi r24,lo8(126) + 353 008e 8093 E800 sts 232,r24 + 354 .L42: + 355 .LBE285: + 356 .LBE284: + 357 .LBE278: + 358 .LBE271: + 359 .LSM52: + 360 0092 4115 cp r20,__zero_reg__ + 361 0094 5105 cpc r21,__zero_reg__ + 362 0096 01F4 brne .L36 + 363 0098 6623 tst r22 + 364 009a 01F4 brne .L36 + 365 009c 00C0 rjmp .L40 + 366 .L37: + 367 .LBB286: + 368 .LSM53: + 369 009e 8091 0000 lds r24,USB_DeviceState + 370 .LVL33: + 371 .LSM54: + 372 00a2 8823 tst r24 + 373 00a4 01F0 breq .L27 + 374 .LSM55: + 375 00a6 8530 cpi r24,lo8(5) + 376 00a8 01F0 breq .L28 + 377 .L40: + 378 .LBE286: + 379 .LBB287: + 380 .LBB288: + 381 .LSM56: + 382 00aa 8091 E800 lds r24,232 + 383 .LVL34: + 384 .LBE288: + 385 .LBE287: + 386 .LSM57: + 387 00ae 82FF sbrs r24,2 + 388 00b0 00C0 rjmp .L37 + 389 00b2 80E0 ldi r24,lo8(0) + 390 00b4 0895 ret + 391 .LVL35: + 392 .L27: + 393 00b6 82E0 ldi r24,lo8(2) + 394 .LVL36: + 395 00b8 0895 ret + 396 .LVL37: + 397 .L28: + 398 00ba 83E0 ldi r24,lo8(3) + 399 .LVL38: + 400 .LSM58: + 401 00bc 0895 ret + 402 .LFE80: + 404 .section .text.Endpoint_Write_Control_Stream_BE,"ax",@progbits + 405 .global Endpoint_Write_Control_Stream_BE + 407 Endpoint_Write_Control_Stream_BE: + 408 .LFB82: + 409 .LSM59: + 410 .LVL39: + 411 /* prologue: function */ + 412 /* frame size = 0 */ + 413 0000 9C01 movw r18,r24 + 414 .LSM60: + 415 0002 4091 0000 lds r20,USB_ControlRequest+6 + 416 0006 5091 0000 lds r21,(USB_ControlRequest+6)+1 + 417 .LVL40: + 418 000a 4617 cp r20,r22 + 419 000c 5707 cpc r21,r23 + 420 000e 00F4 brsh .L44 + 421 .LVL41: + 422 .L47: + 423 .LSM61: + 424 0010 FB01 movw r30,r22 + 425 .LVL42: + 426 0012 3197 sbiw r30,1 + 427 0014 E20F add r30,r18 + 428 0016 F31F adc r31,r19 + 429 0018 90E0 ldi r25,lo8(0) + 430 .LVL43: + 431 001a 00C0 rjmp .L63 + 432 .LVL44: + 433 .L44: + 434 .LSM62: + 435 001c 6115 cp r22,__zero_reg__ + 436 001e 7105 cpc r23,__zero_reg__ + 437 0020 01F0 breq .L46 + 438 .LVL45: + 439 0022 AB01 movw r20,r22 + 440 0024 00C0 rjmp .L47 + 441 .L46: + 442 .LBB289: + 443 .LBB290: + 444 .LSM63: + 445 0026 8091 E800 lds r24,232 + 446 002a 8E77 andi r24,lo8(126) + 447 002c 8093 E800 sts 232,r24 + 448 0030 40E0 ldi r20,lo8(0) + 449 0032 50E0 ldi r21,hi8(0) + 450 .LVL46: + 451 0034 00C0 rjmp .L47 + 452 .LVL47: + 453 .L57: + 454 .LBE290: + 455 .LBE289: + 456 .LBB291: + 457 .LSM64: + 458 0036 8091 0000 lds r24,USB_DeviceState + 459 .LVL48: + 460 .LSM65: + 461 003a 8823 tst r24 + 462 003c 01F4 brne .+2 + 463 003e 00C0 rjmp .L48 + 464 .LSM66: + 465 0040 8530 cpi r24,lo8(5) + 466 0042 01F4 brne .+2 + 467 0044 00C0 rjmp .L49 + 468 .LBB292: + 469 .LBB293: + 470 .LSM67: + 471 0046 8091 E800 lds r24,232 + 472 .LVL49: + 473 .LBE293: + 474 .LBE292: + 475 .LSM68: + 476 004a 83FF sbrs r24,3 + 477 004c 00C0 rjmp .L50 + 478 004e 81E0 ldi r24,lo8(1) + 479 0050 0895 ret + 480 .L50: + 481 .LBB294: + 482 .LBB295: + 483 .LSM69: + 484 0052 8091 E800 lds r24,232 + 485 .LBE295: + 486 .LBE294: + 487 .LSM70: + 488 0056 82FD sbrc r24,2 + 489 0058 00C0 rjmp .L61 + 490 .LBB296: + 491 .LBB297: + 492 .LSM71: + 493 005a 8091 E800 lds r24,232 + 494 .LBE297: + 495 .LBE296: + 496 .LSM72: + 497 005e 80FF sbrs r24,0 + 498 0060 00C0 rjmp .L63 + 499 .LBB298: + 500 .LBB299: + 501 .LBB300: + 502 .LSM73: + 503 0062 8091 F200 lds r24,242 + 504 0066 282F mov r18,r24 + 505 .LVL50: + 506 0068 30E0 ldi r19,lo8(0) + 507 006a 00C0 rjmp .L53 + 508 .L55: + 509 .LBE300: + 510 .LBE299: + 511 .LSM74: + 512 006c 8081 ld r24,Z + 513 006e 3197 sbiw r30,1 + 514 .LBB301: + 515 .LBB302: + 516 .LSM75: + 517 0070 8093 F100 sts 241,r24 + 518 .LBE302: + 519 .LBE301: + 520 .LSM76: + 521 0074 4150 subi r20,lo8(-(-1)) + 522 0076 5040 sbci r21,hi8(-(-1)) + 523 .LSM77: + 524 0078 2F5F subi r18,lo8(-(1)) + 525 007a 3F4F sbci r19,hi8(-(1)) + 526 .LVL51: + 527 .L53: + 528 .LSM78: + 529 007c 4115 cp r20,__zero_reg__ + 530 007e 5105 cpc r21,__zero_reg__ + 531 0080 01F0 breq .L54 + 532 0082 2830 cpi r18,8 + 533 0084 3105 cpc r19,__zero_reg__ + 534 0086 00F0 brlo .L55 + 535 .L54: + 536 .LSM79: + 537 0088 90E0 ldi r25,lo8(0) + 538 008a 2830 cpi r18,8 + 539 008c 3105 cpc r19,__zero_reg__ + 540 008e 01F4 brne .L56 + 541 0090 91E0 ldi r25,lo8(1) + 542 .L56: + 543 .LBB303: + 544 .LBB304: + 545 .LSM80: + 546 0092 8091 E800 lds r24,232 + 547 0096 8E77 andi r24,lo8(126) + 548 0098 8093 E800 sts 232,r24 + 549 .LVL52: + 550 .L63: + 551 .LBE304: + 552 .LBE303: + 553 .LBE298: + 554 .LBE291: + 555 .LSM81: + 556 009c 4115 cp r20,__zero_reg__ + 557 009e 5105 cpc r21,__zero_reg__ + 558 00a0 01F4 brne .L57 + 559 00a2 9923 tst r25 + 560 00a4 01F4 brne .L57 + 561 00a6 00C0 rjmp .L61 + 562 .LVL53: + 563 .L58: + 564 .LBB305: + 565 .LSM82: + 566 00a8 8091 0000 lds r24,USB_DeviceState + 567 .LVL54: + 568 .LSM83: + 569 00ac 8823 tst r24 + 570 00ae 01F0 breq .L48 + 571 .LSM84: + 572 00b0 8530 cpi r24,lo8(5) + 573 00b2 01F0 breq .L49 + 574 .LVL55: + 575 .L61: + 576 .LBE305: + 577 .LBB306: + 578 .LBB307: + 579 .LSM85: + 580 00b4 8091 E800 lds r24,232 + 581 .LVL56: + 582 .LBE307: + 583 .LBE306: + 584 .LSM86: + 585 00b8 82FF sbrs r24,2 + 586 00ba 00C0 rjmp .L58 + 587 00bc 80E0 ldi r24,lo8(0) + 588 00be 0895 ret + 589 .LVL57: + 590 .L48: + 591 00c0 82E0 ldi r24,lo8(2) + 592 .LVL58: + 593 00c2 0895 ret + 594 .LVL59: + 595 .L49: + 596 00c4 83E0 ldi r24,lo8(3) + 597 .LVL60: + 598 .LSM87: + 599 00c6 0895 ret + 600 .LFE82: + 602 .section .text.Endpoint_Write_Control_PStream_BE,"ax",@progbits + 603 .global Endpoint_Write_Control_PStream_BE + 605 Endpoint_Write_Control_PStream_BE: + 606 .LFB83: + 607 .LSM88: + 608 .LVL61: + 609 /* prologue: function */ + 610 /* frame size = 0 */ + 611 0000 AC01 movw r20,r24 + 612 .LSM89: + 613 0002 2091 0000 lds r18,USB_ControlRequest+6 + 614 0006 3091 0000 lds r19,(USB_ControlRequest+6)+1 + 615 .LVL62: + 616 000a 2617 cp r18,r22 + 617 000c 3707 cpc r19,r23 + 618 000e 00F4 brsh .L65 + 619 .LVL63: + 620 .L68: + 621 .LSM90: + 622 0010 6150 subi r22,lo8(-(-1)) + 623 0012 7040 sbci r23,hi8(-(-1)) + 624 .LVL64: + 625 0014 640F add r22,r20 + 626 0016 751F adc r23,r21 + 627 0018 40E0 ldi r20,lo8(0) + 628 .LVL65: + 629 001a 00C0 rjmp .L84 + 630 .LVL66: + 631 .L65: + 632 .LSM91: + 633 001c 6115 cp r22,__zero_reg__ + 634 001e 7105 cpc r23,__zero_reg__ + 635 0020 01F0 breq .L67 + 636 .LVL67: + 637 0022 9B01 movw r18,r22 + 638 0024 00C0 rjmp .L68 + 639 .L67: + 640 .LBB308: + 641 .LBB309: + 642 .LSM92: + 643 0026 8091 E800 lds r24,232 + 644 002a 8E77 andi r24,lo8(126) + 645 002c 8093 E800 sts 232,r24 + 646 0030 20E0 ldi r18,lo8(0) + 647 0032 30E0 ldi r19,hi8(0) + 648 .LVL68: + 649 0034 00C0 rjmp .L68 + 650 .LVL69: + 651 .L78: + 652 .LBE309: + 653 .LBE308: + 654 .LBB310: + 655 .LSM93: + 656 0036 8091 0000 lds r24,USB_DeviceState + 657 .LVL70: + 658 .LSM94: + 659 003a 8823 tst r24 + 660 003c 01F4 brne .+2 + 661 003e 00C0 rjmp .L69 + 662 .LSM95: + 663 0040 8530 cpi r24,lo8(5) + 664 0042 01F4 brne .+2 + 665 0044 00C0 rjmp .L70 + 666 .LBB311: + 667 .LBB312: + 668 .LSM96: + 669 0046 8091 E800 lds r24,232 + 670 .LVL71: + 671 .LBE312: + 672 .LBE311: + 673 .LSM97: + 674 004a 83FF sbrs r24,3 + 675 004c 00C0 rjmp .L71 + 676 004e 81E0 ldi r24,lo8(1) + 677 0050 0895 ret + 678 .L71: + 679 .LBB313: + 680 .LBB314: + 681 .LSM98: + 682 0052 8091 E800 lds r24,232 + 683 .LBE314: + 684 .LBE313: + 685 .LSM99: + 686 0056 82FD sbrc r24,2 + 687 0058 00C0 rjmp .L82 + 688 .LBB315: + 689 .LBB316: + 690 .LSM100: + 691 005a 8091 E800 lds r24,232 + 692 .LBE316: + 693 .LBE315: + 694 .LSM101: + 695 005e 80FF sbrs r24,0 + 696 0060 00C0 rjmp .L84 + 697 .LBB317: + 698 .LBB318: + 699 .LBB319: + 700 .LSM102: + 701 0062 8091 F200 lds r24,242 + 702 0066 90E0 ldi r25,lo8(0) + 703 0068 00C0 rjmp .L74 + 704 .LVL72: + 705 .L76: + 706 .LSM103: + 707 006a FB01 movw r30,r22 + 708 .LVL73: + 709 .LBE319: + 710 .LBE318: + 711 .LBB320: + 712 .LSM104: + 713 006c 6150 subi r22,lo8(-(-1)) + 714 006e 7040 sbci r23,hi8(-(-1)) + 715 /* #APP */ + 716 ; 31 "LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_W.c" 1 + 717 0070 E491 lpm r30, Z + 718 + 719 ; 0 "" 2 + 720 .LVL74: + 721 /* #NOAPP */ + 722 .LBE320: + 723 .LBB321: + 724 .LBB322: + 725 .LSM105: + 726 0072 E093 F100 sts 241,r30 + 727 .LBE322: + 728 .LBE321: + 729 .LSM106: + 730 0076 2150 subi r18,lo8(-(-1)) + 731 0078 3040 sbci r19,hi8(-(-1)) + 732 .LSM107: + 733 007a 0196 adiw r24,1 + 734 .L74: + 735 .LSM108: + 736 007c 2115 cp r18,__zero_reg__ + 737 007e 3105 cpc r19,__zero_reg__ + 738 0080 01F0 breq .L75 + 739 0082 8830 cpi r24,8 + 740 0084 9105 cpc r25,__zero_reg__ + 741 0086 00F0 brlo .L76 + 742 .L75: + 743 .LSM109: + 744 0088 40E0 ldi r20,lo8(0) + 745 008a 0897 sbiw r24,8 + 746 008c 01F4 brne .L77 + 747 008e 41E0 ldi r20,lo8(1) + 748 .L77: + 749 .LBB323: + 750 .LBB324: + 751 .LSM110: + 752 0090 8091 E800 lds r24,232 + 753 .LVL75: + 754 0094 8E77 andi r24,lo8(126) + 755 0096 8093 E800 sts 232,r24 + 756 .LVL76: + 757 .L84: + 758 .LBE324: + 759 .LBE323: + 760 .LBE317: + 761 .LBE310: + 762 .LSM111: + 763 009a 2115 cp r18,__zero_reg__ + 764 009c 3105 cpc r19,__zero_reg__ + 765 009e 01F4 brne .L78 + 766 00a0 4423 tst r20 + 767 00a2 01F4 brne .L78 + 768 00a4 00C0 rjmp .L82 + 769 .LVL77: + 770 .L79: + 771 .LBB325: + 772 .LSM112: + 773 00a6 8091 0000 lds r24,USB_DeviceState + 774 .LVL78: + 775 .LSM113: + 776 00aa 8823 tst r24 + 777 00ac 01F0 breq .L69 + 778 .LSM114: + 779 00ae 8530 cpi r24,lo8(5) + 780 00b0 01F0 breq .L70 + 781 .LVL79: + 782 .L82: + 783 .LBE325: + 784 .LBB326: + 785 .LBB327: + 786 .LSM115: + 787 00b2 8091 E800 lds r24,232 + 788 .LVL80: + 789 .LBE327: + 790 .LBE326: + 791 .LSM116: + 792 00b6 82FF sbrs r24,2 + 793 00b8 00C0 rjmp .L79 + 794 00ba 80E0 ldi r24,lo8(0) + 795 00bc 0895 ret + 796 .LVL81: + 797 .L69: + 798 00be 82E0 ldi r24,lo8(2) + 799 .LVL82: + 800 00c0 0895 ret + 801 .LVL83: + 802 .L70: + 803 00c2 83E0 ldi r24,lo8(3) + 804 .LVL84: + 805 .LSM117: + 806 00c4 0895 ret + 807 .LFE83: + 809 .section .text.Endpoint_Read_Control_Stream_LE,"ax",@progbits + 810 .global Endpoint_Read_Control_Stream_LE + 812 Endpoint_Read_Control_Stream_LE: + 813 .LFB85: + 814 .LSM118: + 815 .LVL85: + 816 /* prologue: function */ + 817 /* frame size = 0 */ + 818 0000 9C01 movw r18,r24 + 819 .LVL86: + 820 .LSM119: + 821 0002 6115 cp r22,__zero_reg__ + 822 0004 7105 cpc r23,__zero_reg__ + 823 0006 01F4 brne .L86 + 824 .LBB328: + 825 .LBB329: + 826 .LSM120: + 827 0008 8091 E800 lds r24,232 + 828 000c 8B77 andi r24,lo8(123) + 829 000e 8093 E800 sts 232,r24 + 830 .L86: + 831 .LBE329: + 832 .LBE328: + 833 .LSM121: + 834 0012 F901 movw r30,r18 + 835 .LVL87: + 836 0014 00C0 rjmp .L87 + 837 .LVL88: + 838 .L100: + 839 .LBB330: + 840 .LSM122: + 841 0016 8091 0000 lds r24,USB_DeviceState + 842 .LVL89: + 843 .LSM123: + 844 001a 8823 tst r24 + 845 001c 01F0 breq .L88 + 846 .LSM124: + 847 001e 8530 cpi r24,lo8(5) + 848 0020 01F0 breq .L89 + 849 .LBB331: + 850 .LBB332: + 851 .LSM125: + 852 0022 8091 E800 lds r24,232 + 853 .LVL90: + 854 .LBE332: + 855 .LBE331: + 856 .LSM126: + 857 0026 83FF sbrs r24,3 + 858 0028 00C0 rjmp .L90 + 859 002a 81E0 ldi r24,lo8(1) + 860 002c 0895 ret + 861 .L90: + 862 .LBB333: + 863 .LBB334: + 864 .LSM127: + 865 002e 8091 E800 lds r24,232 + 866 .LBE334: + 867 .LBE333: + 868 .LSM128: + 869 0032 82FF sbrs r24,2 + 870 0034 00C0 rjmp .L100 + 871 0036 00C0 rjmp .L99 + 872 .L95: + 873 .LBB335: + 874 .LBB336: + 875 .LSM129: + 876 0038 8091 F100 lds r24,241 + 877 .LBE336: + 878 .LBE335: + 879 .LSM130: + 880 003c 8193 st Z+,r24 + 881 .LSM131: + 882 003e 6150 subi r22,lo8(-(-1)) + 883 0040 7040 sbci r23,hi8(-(-1)) + 884 .LVL91: + 885 .LSM132: + 886 0042 01F0 breq .L94 + 887 .L99: + 888 .LBB337: + 889 .LBB338: + 890 .LSM133: + 891 0044 8091 F200 lds r24,242 + 892 .LBE338: + 893 .LBE337: + 894 .LSM134: + 895 0048 8823 tst r24 + 896 004a 01F4 brne .L95 + 897 .L94: + 898 .LBB339: + 899 .LBB340: + 900 .LSM135: + 901 004c 8091 E800 lds r24,232 + 902 0050 8B77 andi r24,lo8(123) + 903 0052 8093 E800 sts 232,r24 + 904 .L87: + 905 .LBE340: + 906 .LBE339: + 907 .LBE330: + 908 .LSM136: + 909 0056 6115 cp r22,__zero_reg__ + 910 0058 7105 cpc r23,__zero_reg__ + 911 005a 01F4 brne .L100 + 912 005c 00C0 rjmp .L101 + 913 .L97: + 914 .LBB341: + 915 .LSM137: + 916 005e 8091 0000 lds r24,USB_DeviceState + 917 .LVL92: + 918 .LSM138: + 919 0062 8823 tst r24 + 920 0064 01F0 breq .L88 + 921 .LSM139: + 922 0066 8530 cpi r24,lo8(5) + 923 0068 01F0 breq .L89 + 924 .L101: + 925 .LBE341: + 926 .LBB342: + 927 .LBB343: + 928 .LSM140: + 929 006a 8091 E800 lds r24,232 + 930 .LVL93: + 931 .LBE343: + 932 .LBE342: + 933 .LSM141: + 934 006e 80FF sbrs r24,0 + 935 0070 00C0 rjmp .L97 + 936 0072 80E0 ldi r24,lo8(0) + 937 0074 0895 ret + 938 .LVL94: + 939 .L88: + 940 0076 82E0 ldi r24,lo8(2) + 941 .LVL95: + 942 0078 0895 ret + 943 .LVL96: + 944 .L89: + 945 007a 83E0 ldi r24,lo8(3) + 946 .LVL97: + 947 .LSM142: + 948 007c 0895 ret + 949 .LFE85: + 951 .section .text.Endpoint_Read_Control_Stream_BE,"ax",@progbits + 952 .global Endpoint_Read_Control_Stream_BE + 954 Endpoint_Read_Control_Stream_BE: + 955 .LFB87: + 956 .LSM143: + 957 .LVL98: + 958 /* prologue: function */ + 959 /* frame size = 0 */ + 960 0000 AC01 movw r20,r24 + 961 .LSM144: + 962 0002 6115 cp r22,__zero_reg__ + 963 0004 7105 cpc r23,__zero_reg__ + 964 0006 01F0 breq .L103 + 965 .LVL99: + 966 0008 9B01 movw r18,r22 + 967 000a 00C0 rjmp .L104 + 968 .LVL100: + 969 .L103: + 970 .LBB344: + 971 .LBB345: + 972 .LSM145: + 973 000c 8091 E800 lds r24,232 + 974 0010 8B77 andi r24,lo8(123) + 975 0012 8093 E800 sts 232,r24 + 976 0016 20E0 ldi r18,lo8(0) + 977 0018 30E0 ldi r19,hi8(0) + 978 .LVL101: + 979 .L104: + 980 .LBE345: + 981 .LBE344: + 982 .LSM146: + 983 001a FB01 movw r30,r22 + 984 .LVL102: + 985 001c 3197 sbiw r30,1 + 986 001e E40F add r30,r20 + 987 0020 F51F adc r31,r21 + 988 0022 00C0 rjmp .L105 + 989 .L118: + 990 .LBB346: + 991 .LSM147: + 992 0024 8091 0000 lds r24,USB_DeviceState + 993 .LVL103: + 994 .LSM148: + 995 0028 8823 tst r24 + 996 002a 01F0 breq .L106 + 997 .LSM149: + 998 002c 8530 cpi r24,lo8(5) + 999 002e 01F0 breq .L107 + 1000 .LBB347: + 1001 .LBB348: + 1002 .LSM150: + 1003 0030 8091 E800 lds r24,232 + 1004 .LVL104: + 1005 .LBE348: + 1006 .LBE347: + 1007 .LSM151: + 1008 0034 83FF sbrs r24,3 + 1009 0036 00C0 rjmp .L108 + 1010 0038 81E0 ldi r24,lo8(1) + 1011 003a 0895 ret + 1012 .L108: + 1013 .LBB349: + 1014 .LBB350: + 1015 .LSM152: + 1016 003c 8091 E800 lds r24,232 + 1017 .LBE350: + 1018 .LBE349: + 1019 .LSM153: + 1020 0040 82FF sbrs r24,2 + 1021 0042 00C0 rjmp .L118 + 1022 0044 00C0 rjmp .L117 + 1023 .L113: + 1024 .LBB351: + 1025 .LBB352: + 1026 .LSM154: + 1027 0046 8091 F100 lds r24,241 + 1028 .LBE352: + 1029 .LBE351: + 1030 .LSM155: + 1031 004a 8083 st Z,r24 + 1032 004c 3197 sbiw r30,1 + 1033 .LSM156: + 1034 004e 2150 subi r18,lo8(-(-1)) + 1035 0050 3040 sbci r19,hi8(-(-1)) + 1036 .LSM157: + 1037 0052 01F0 breq .L112 + 1038 .LVL105: + 1039 .L117: + 1040 .LBB353: + 1041 .LBB354: + 1042 .LSM158: + 1043 0054 8091 F200 lds r24,242 + 1044 .LBE354: + 1045 .LBE353: + 1046 .LSM159: + 1047 0058 8823 tst r24 + 1048 005a 01F4 brne .L113 + 1049 .L112: + 1050 .LBB355: + 1051 .LBB356: + 1052 .LSM160: + 1053 005c 8091 E800 lds r24,232 + 1054 0060 8B77 andi r24,lo8(123) + 1055 0062 8093 E800 sts 232,r24 + 1056 .LVL106: + 1057 .L105: + 1058 .LBE356: + 1059 .LBE355: + 1060 .LBE346: + 1061 .LSM161: + 1062 0066 2115 cp r18,__zero_reg__ + 1063 0068 3105 cpc r19,__zero_reg__ + 1064 006a 01F4 brne .L118 + 1065 006c 00C0 rjmp .L119 + 1066 .LVL107: + 1067 .L115: + 1068 .LBB357: + 1069 .LSM162: + 1070 006e 8091 0000 lds r24,USB_DeviceState + 1071 .LVL108: + 1072 .LSM163: + 1073 0072 8823 tst r24 + 1074 0074 01F0 breq .L106 + 1075 .LSM164: + 1076 0076 8530 cpi r24,lo8(5) + 1077 0078 01F0 breq .L107 + 1078 .LVL109: + 1079 .L119: + 1080 .LBE357: + 1081 .LBB358: + 1082 .LBB359: + 1083 .LSM165: + 1084 007a 8091 E800 lds r24,232 + 1085 .LVL110: + 1086 .LBE359: + 1087 .LBE358: + 1088 .LSM166: + 1089 007e 80FF sbrs r24,0 + 1090 0080 00C0 rjmp .L115 + 1091 0082 80E0 ldi r24,lo8(0) + 1092 0084 0895 ret + 1093 .LVL111: + 1094 .L106: + 1095 0086 82E0 ldi r24,lo8(2) + 1096 .LVL112: + 1097 0088 0895 ret + 1098 .LVL113: + 1099 .L107: + 1100 008a 83E0 ldi r24,lo8(3) + 1101 .LVL114: + 1102 .LSM167: + 1103 008c 0895 ret + 1104 .LFE87: + 1106 .section .text.Endpoint_Read_Control_EStream_BE,"ax",@progbits + 1107 .global Endpoint_Read_Control_EStream_BE + 1109 Endpoint_Read_Control_EStream_BE: + 1110 .LFB88: + 1111 .LSM168: + 1112 .LVL115: + 1113 0000 0F93 push r16 + 1114 0002 1F93 push r17 + 1115 0004 CF93 push r28 + 1116 0006 DF93 push r29 + 1117 /* prologue: function */ + 1118 /* frame size = 0 */ + 1119 0008 AC01 movw r20,r24 + 1120 .LSM169: + 1121 000a 6115 cp r22,__zero_reg__ + 1122 000c 7105 cpc r23,__zero_reg__ + 1123 000e 01F0 breq .L121 + 1124 .LVL116: + 1125 0010 8B01 movw r16,r22 + 1126 0012 00C0 rjmp .L122 + 1127 .LVL117: + 1128 .L121: + 1129 .LBB360: + 1130 .LBB361: + 1131 .LSM170: + 1132 0014 8091 E800 lds r24,232 + 1133 0018 8B77 andi r24,lo8(123) + 1134 001a 8093 E800 sts 232,r24 + 1135 001e 00E0 ldi r16,lo8(0) + 1136 0020 10E0 ldi r17,hi8(0) + 1137 .LVL118: + 1138 .L122: + 1139 .LBE361: + 1140 .LBE360: + 1141 .LSM171: + 1142 0022 9B01 movw r18,r22 + 1143 .LVL119: + 1144 0024 2150 subi r18,lo8(-(-1)) + 1145 0026 3040 sbci r19,hi8(-(-1)) + 1146 0028 240F add r18,r20 + 1147 002a 351F adc r19,r21 + 1148 002c 00C0 rjmp .L123 + 1149 .LVL120: + 1150 .L136: + 1151 .LBB362: + 1152 .LSM172: + 1153 002e 8091 0000 lds r24,USB_DeviceState + 1154 .LVL121: + 1155 .LSM173: + 1156 0032 8823 tst r24 + 1157 0034 01F0 breq .L124 + 1158 .LSM174: + 1159 0036 8530 cpi r24,lo8(5) + 1160 0038 01F0 breq .L125 + 1161 .LBB363: + 1162 .LBB364: + 1163 .LSM175: + 1164 003a 8091 E800 lds r24,232 + 1165 .LVL122: + 1166 .LBE364: + 1167 .LBE363: + 1168 .LSM176: + 1169 003e 83FF sbrs r24,3 + 1170 0040 00C0 rjmp .L126 + 1171 0042 81E0 ldi r24,lo8(1) + 1172 0044 00C0 rjmp .L127 + 1173 .L126: + 1174 .LBB365: + 1175 .LBB366: + 1176 .LSM177: + 1177 0046 8091 E800 lds r24,232 + 1178 .LBE366: + 1179 .LBE365: + 1180 .LSM178: + 1181 004a 82FF sbrs r24,2 + 1182 004c 00C0 rjmp .L136 + 1183 004e 00C0 rjmp .L135 + 1184 .L131: + 1185 .LSM179: + 1186 0050 E901 movw r28,r18 + 1187 0052 2197 sbiw r28,1 + 1188 .LVL123: + 1189 .LBB367: + 1190 .LBB368: + 1191 .LSM180: + 1192 0054 6091 F100 lds r22,241 + 1193 .LBE368: + 1194 .LBE367: + 1195 .LSM181: + 1196 0058 C901 movw r24,r18 + 1197 005a 0E94 0000 call __eeupd_byte_usb162 + 1198 .LVL124: + 1199 .LSM182: + 1200 005e 0150 subi r16,lo8(-(-1)) + 1201 0060 1040 sbci r17,hi8(-(-1)) + 1202 .LSM183: + 1203 0062 01F0 breq .L130 + 1204 0064 9E01 movw r18,r28 + 1205 .LVL125: + 1206 .L135: + 1207 .LBB369: + 1208 .LBB370: + 1209 .LSM184: + 1210 0066 8091 F200 lds r24,242 + 1211 .LBE370: + 1212 .LBE369: + 1213 .LSM185: + 1214 006a 8823 tst r24 + 1215 006c 01F4 brne .L131 + 1216 006e E901 movw r28,r18 + 1217 .LVL126: + 1218 .L130: + 1219 .LBB371: + 1220 .LBB372: + 1221 .LSM186: + 1222 0070 8091 E800 lds r24,232 + 1223 0074 8B77 andi r24,lo8(123) + 1224 0076 8093 E800 sts 232,r24 + 1225 007a 9E01 movw r18,r28 + 1226 .LVL127: + 1227 .L123: + 1228 .LBE372: + 1229 .LBE371: + 1230 .LBE362: + 1231 .LSM187: + 1232 007c 0115 cp r16,__zero_reg__ + 1233 007e 1105 cpc r17,__zero_reg__ + 1234 0080 01F4 brne .L136 + 1235 0082 00C0 rjmp .L137 + 1236 .LVL128: + 1237 .L133: + 1238 .LBB373: + 1239 .LSM188: + 1240 0084 8091 0000 lds r24,USB_DeviceState + 1241 .LVL129: + 1242 .LSM189: + 1243 0088 8823 tst r24 + 1244 008a 01F0 breq .L124 + 1245 .LSM190: + 1246 008c 8530 cpi r24,lo8(5) + 1247 008e 01F0 breq .L125 + 1248 .LVL130: + 1249 .L137: + 1250 .LBE373: + 1251 .LBB374: + 1252 .LBB375: + 1253 .LSM191: + 1254 0090 8091 E800 lds r24,232 + 1255 .LVL131: + 1256 .LBE375: + 1257 .LBE374: + 1258 .LSM192: + 1259 0094 80FF sbrs r24,0 + 1260 0096 00C0 rjmp .L133 + 1261 0098 80E0 ldi r24,lo8(0) + 1262 009a 00C0 rjmp .L127 + 1263 .LVL132: + 1264 .L124: + 1265 009c 82E0 ldi r24,lo8(2) + 1266 .LVL133: + 1267 009e 00C0 rjmp .L127 + 1268 .LVL134: + 1269 .L125: + 1270 00a0 83E0 ldi r24,lo8(3) + 1271 .LVL135: + 1272 .L127: + 1273 /* epilogue start */ + 1274 .LSM193: + 1275 00a2 DF91 pop r29 + 1276 00a4 CF91 pop r28 + 1277 00a6 1F91 pop r17 + 1278 00a8 0F91 pop r16 + 1279 .LVL136: + 1280 00aa 0895 ret + 1281 .LFE88: + 1283 .section .text.Endpoint_Read_Control_EStream_LE,"ax",@progbits + 1284 .global Endpoint_Read_Control_EStream_LE + 1286 Endpoint_Read_Control_EStream_LE: + 1287 .LFB86: + 1288 .LSM194: + 1289 .LVL137: + 1290 0000 0F93 push r16 + 1291 0002 1F93 push r17 + 1292 0004 CF93 push r28 + 1293 0006 DF93 push r29 + 1294 /* prologue: function */ + 1295 /* frame size = 0 */ + 1296 0008 9C01 movw r18,r24 + 1297 .LVL138: + 1298 000a 8B01 movw r16,r22 + 1299 .LSM195: + 1300 000c 6115 cp r22,__zero_reg__ + 1301 000e 7105 cpc r23,__zero_reg__ + 1302 0010 01F4 brne .L140 + 1303 .LBB376: + 1304 .LBB377: + 1305 .LSM196: + 1306 0012 8091 E800 lds r24,232 + 1307 0016 8B77 andi r24,lo8(123) + 1308 0018 8093 E800 sts 232,r24 + 1309 001c 00C0 rjmp .L140 + 1310 .LVL139: + 1311 .L153: + 1312 .LBE377: + 1313 .LBE376: + 1314 .LBB378: + 1315 .LSM197: + 1316 001e 8091 0000 lds r24,USB_DeviceState + 1317 .LVL140: + 1318 .LSM198: + 1319 0022 8823 tst r24 + 1320 0024 01F0 breq .L141 + 1321 .LSM199: + 1322 0026 8530 cpi r24,lo8(5) + 1323 0028 01F0 breq .L142 + 1324 .LBB379: + 1325 .LBB380: + 1326 .LSM200: + 1327 002a 8091 E800 lds r24,232 + 1328 .LVL141: + 1329 .LBE380: + 1330 .LBE379: + 1331 .LSM201: + 1332 002e 83FF sbrs r24,3 + 1333 0030 00C0 rjmp .L143 + 1334 0032 81E0 ldi r24,lo8(1) + 1335 0034 00C0 rjmp .L144 + 1336 .L143: + 1337 .LBB381: + 1338 .LBB382: + 1339 .LSM202: + 1340 0036 8091 E800 lds r24,232 + 1341 .LBE382: + 1342 .LBE381: + 1343 .LSM203: + 1344 003a 82FF sbrs r24,2 + 1345 003c 00C0 rjmp .L153 + 1346 003e 00C0 rjmp .L152 + 1347 .L148: + 1348 .LSM204: + 1349 0040 E901 movw r28,r18 + 1350 0042 2196 adiw r28,1 + 1351 .LVL142: + 1352 .LBB383: + 1353 .LBB384: + 1354 .LSM205: + 1355 0044 6091 F100 lds r22,241 + 1356 .LBE384: + 1357 .LBE383: + 1358 .LSM206: + 1359 0048 C901 movw r24,r18 + 1360 004a 0E94 0000 call __eeupd_byte_usb162 + 1361 .LSM207: + 1362 004e 0150 subi r16,lo8(-(-1)) + 1363 0050 1040 sbci r17,hi8(-(-1)) + 1364 .LSM208: + 1365 0052 01F0 breq .L147 + 1366 0054 9E01 movw r18,r28 + 1367 .LVL143: + 1368 .L152: + 1369 .LBB385: + 1370 .LBB386: + 1371 .LSM209: + 1372 0056 8091 F200 lds r24,242 + 1373 .LBE386: + 1374 .LBE385: + 1375 .LSM210: + 1376 005a 8823 tst r24 + 1377 005c 01F4 brne .L148 + 1378 005e E901 movw r28,r18 + 1379 .LVL144: + 1380 .L147: + 1381 .LBB387: + 1382 .LBB388: + 1383 .LSM211: + 1384 0060 8091 E800 lds r24,232 + 1385 0064 8B77 andi r24,lo8(123) + 1386 0066 8093 E800 sts 232,r24 + 1387 006a 9E01 movw r18,r28 + 1388 .LVL145: + 1389 .L140: + 1390 .LBE388: + 1391 .LBE387: + 1392 .LBE378: + 1393 .LSM212: + 1394 006c 0115 cp r16,__zero_reg__ + 1395 006e 1105 cpc r17,__zero_reg__ + 1396 0070 01F4 brne .L153 + 1397 0072 00C0 rjmp .L154 + 1398 .L150: + 1399 .LBB389: + 1400 .LSM213: + 1401 0074 8091 0000 lds r24,USB_DeviceState + 1402 .LVL146: + 1403 .LSM214: + 1404 0078 8823 tst r24 + 1405 007a 01F0 breq .L141 + 1406 .LSM215: + 1407 007c 8530 cpi r24,lo8(5) + 1408 007e 01F0 breq .L142 + 1409 .L154: + 1410 .LBE389: + 1411 .LBB390: + 1412 .LBB391: + 1413 .LSM216: + 1414 0080 8091 E800 lds r24,232 + 1415 .LVL147: + 1416 .LBE391: + 1417 .LBE390: + 1418 .LSM217: + 1419 0084 80FF sbrs r24,0 + 1420 0086 00C0 rjmp .L150 + 1421 0088 80E0 ldi r24,lo8(0) + 1422 008a 00C0 rjmp .L144 + 1423 .LVL148: + 1424 .L141: + 1425 008c 82E0 ldi r24,lo8(2) + 1426 .LVL149: + 1427 008e 00C0 rjmp .L144 + 1428 .LVL150: + 1429 .L142: + 1430 0090 83E0 ldi r24,lo8(3) + 1431 .LVL151: + 1432 .L144: + 1433 /* epilogue start */ + 1434 .LSM218: + 1435 0092 DF91 pop r29 + 1436 0094 CF91 pop r28 + 1437 0096 1F91 pop r17 + 1438 0098 0F91 pop r16 + 1439 .LVL152: + 1440 009a 0895 ret + 1441 .LFE86: + 1443 .section .text.Endpoint_Write_Control_EStream_BE,"ax",@progbits + 1444 .global Endpoint_Write_Control_EStream_BE + 1446 Endpoint_Write_Control_EStream_BE: + 1447 .LFB84: + 1448 .LSM219: + 1449 .LVL153: + 1450 0000 EF92 push r14 + 1451 0002 FF92 push r15 + 1452 0004 0F93 push r16 + 1453 0006 1F93 push r17 + 1454 0008 CF93 push r28 + 1455 000a DF93 push r29 + 1456 /* prologue: function */ + 1457 /* frame size = 0 */ + 1458 000c 9C01 movw r18,r24 + 1459 .LSM220: + 1460 000e E090 0000 lds r14,USB_ControlRequest+6 + 1461 0012 F090 0000 lds r15,(USB_ControlRequest+6)+1 + 1462 .LVL154: + 1463 0016 E616 cp r14,r22 + 1464 0018 F706 cpc r15,r23 + 1465 001a 00F4 brsh .L156 + 1466 .LVL155: + 1467 .L159: + 1468 .LSM221: + 1469 001c 6150 subi r22,lo8(-(-1)) + 1470 001e 7040 sbci r23,hi8(-(-1)) + 1471 .LVL156: + 1472 0020 620F add r22,r18 + 1473 0022 731F adc r23,r19 + 1474 0024 90E0 ldi r25,lo8(0) + 1475 .LVL157: + 1476 0026 00C0 rjmp .L175 + 1477 .LVL158: + 1478 .L156: + 1479 .LSM222: + 1480 0028 6115 cp r22,__zero_reg__ + 1481 002a 7105 cpc r23,__zero_reg__ + 1482 002c 01F0 breq .L158 + 1483 .LVL159: + 1484 002e 7B01 movw r14,r22 + 1485 0030 00C0 rjmp .L159 + 1486 .L158: + 1487 .LBB392: + 1488 .LBB393: + 1489 .LSM223: + 1490 0032 8091 E800 lds r24,232 + 1491 0036 8E77 andi r24,lo8(126) + 1492 0038 8093 E800 sts 232,r24 + 1493 003c EE24 clr r14 + 1494 003e FF24 clr r15 + 1495 .LVL160: + 1496 0040 00C0 rjmp .L159 + 1497 .LVL161: + 1498 .L169: + 1499 .LBE393: + 1500 .LBE392: + 1501 .LBB394: + 1502 .LSM224: + 1503 0042 8091 0000 lds r24,USB_DeviceState + 1504 .LVL162: + 1505 .LSM225: + 1506 0046 8823 tst r24 + 1507 0048 01F4 brne .+2 + 1508 004a 00C0 rjmp .L160 + 1509 .LSM226: + 1510 004c 8530 cpi r24,lo8(5) + 1511 004e 01F4 brne .+2 + 1512 0050 00C0 rjmp .L161 + 1513 .LBB395: + 1514 .LBB396: + 1515 .LSM227: + 1516 0052 8091 E800 lds r24,232 + 1517 .LVL163: + 1518 .LBE396: + 1519 .LBE395: + 1520 .LSM228: + 1521 0056 83FF sbrs r24,3 + 1522 0058 00C0 rjmp .L162 + 1523 005a 81E0 ldi r24,lo8(1) + 1524 005c 00C0 rjmp .L163 + 1525 .L162: + 1526 .LBB397: + 1527 .LBB398: + 1528 .LSM229: + 1529 005e 8091 E800 lds r24,232 + 1530 .LBE398: + 1531 .LBE397: + 1532 .LSM230: + 1533 0062 82FD sbrc r24,2 + 1534 0064 00C0 rjmp .L173 + 1535 .LBB399: + 1536 .LBB400: + 1537 .LSM231: + 1538 0066 8091 E800 lds r24,232 + 1539 .LBE400: + 1540 .LBE399: + 1541 .LSM232: + 1542 006a 80FF sbrs r24,0 + 1543 006c 00C0 rjmp .L175 + 1544 .LBB401: + 1545 .LBB402: + 1546 .LBB403: + 1547 .LSM233: + 1548 006e 8091 F200 lds r24,242 + 1549 0072 C82F mov r28,r24 + 1550 .LVL164: + 1551 0074 D0E0 ldi r29,lo8(0) + 1552 0076 00C0 rjmp .L165 + 1553 .L167: + 1554 .LBE403: + 1555 .LBE402: + 1556 .LSM234: + 1557 0078 8B01 movw r16,r22 + 1558 007a 0150 subi r16,lo8(-(-1)) + 1559 007c 1040 sbci r17,hi8(-(-1)) + 1560 .LVL165: + 1561 007e CB01 movw r24,r22 + 1562 0080 0E94 0000 call __eerd_byte_usb162 + 1563 .LVL166: + 1564 .LBB404: + 1565 .LBB405: + 1566 .LSM235: + 1567 0084 8093 F100 sts 241,r24 + 1568 .LBE405: + 1569 .LBE404: + 1570 .LSM236: + 1571 0088 0894 sec + 1572 008a E108 sbc r14,__zero_reg__ + 1573 008c F108 sbc r15,__zero_reg__ + 1574 .LSM237: + 1575 008e 2196 adiw r28,1 + 1576 0090 B801 movw r22,r16 + 1577 .LVL167: + 1578 .L165: + 1579 .LSM238: + 1580 0092 E114 cp r14,__zero_reg__ + 1581 0094 F104 cpc r15,__zero_reg__ + 1582 0096 01F0 breq .L166 + 1583 0098 C830 cpi r28,8 + 1584 009a D105 cpc r29,__zero_reg__ + 1585 009c 00F0 brlo .L167 + 1586 .L166: + 1587 .LSM239: + 1588 009e 90E0 ldi r25,lo8(0) + 1589 00a0 2897 sbiw r28,8 + 1590 00a2 01F4 brne .L168 + 1591 00a4 91E0 ldi r25,lo8(1) + 1592 .L168: + 1593 .LBB406: + 1594 .LBB407: + 1595 .LSM240: + 1596 00a6 8091 E800 lds r24,232 + 1597 00aa 8E77 andi r24,lo8(126) + 1598 00ac 8093 E800 sts 232,r24 + 1599 .LVL168: + 1600 .L175: + 1601 .LBE407: + 1602 .LBE406: + 1603 .LBE401: + 1604 .LBE394: + 1605 .LSM241: + 1606 00b0 E114 cp r14,__zero_reg__ + 1607 00b2 F104 cpc r15,__zero_reg__ + 1608 00b4 01F4 brne .L169 + 1609 00b6 9923 tst r25 + 1610 00b8 01F4 brne .L169 + 1611 00ba 00C0 rjmp .L173 + 1612 .LVL169: + 1613 .L170: + 1614 .LBB408: + 1615 .LSM242: + 1616 00bc 8091 0000 lds r24,USB_DeviceState + 1617 .LVL170: + 1618 .LSM243: + 1619 00c0 8823 tst r24 + 1620 00c2 01F0 breq .L160 + 1621 .LSM244: + 1622 00c4 8530 cpi r24,lo8(5) + 1623 00c6 01F0 breq .L161 + 1624 .LVL171: + 1625 .L173: + 1626 .LBE408: + 1627 .LBB409: + 1628 .LBB410: + 1629 .LSM245: + 1630 00c8 8091 E800 lds r24,232 + 1631 .LVL172: + 1632 .LBE410: + 1633 .LBE409: + 1634 .LSM246: + 1635 00cc 82FF sbrs r24,2 + 1636 00ce 00C0 rjmp .L170 + 1637 00d0 80E0 ldi r24,lo8(0) + 1638 00d2 00C0 rjmp .L163 + 1639 .LVL173: + 1640 .L160: + 1641 00d4 82E0 ldi r24,lo8(2) + 1642 .LVL174: + 1643 00d6 00C0 rjmp .L163 + 1644 .LVL175: + 1645 .L161: + 1646 00d8 83E0 ldi r24,lo8(3) + 1647 .LVL176: + 1648 .L163: + 1649 /* epilogue start */ + 1650 .LSM247: + 1651 00da DF91 pop r29 + 1652 .LVL177: + 1653 00dc CF91 pop r28 + 1654 .LVL178: + 1655 00de 1F91 pop r17 + 1656 00e0 0F91 pop r16 + 1657 00e2 FF90 pop r15 + 1658 00e4 EF90 pop r14 + 1659 .LVL179: + 1660 00e6 0895 ret + 1661 .LFE84: + 1663 .section .text.Endpoint_Write_Control_EStream_LE,"ax",@progbits + 1664 .global Endpoint_Write_Control_EStream_LE + 1666 Endpoint_Write_Control_EStream_LE: + 1667 .LFB81: + 1668 .LSM248: + 1669 .LVL180: + 1670 0000 EF92 push r14 + 1671 0002 FF92 push r15 + 1672 0004 0F93 push r16 + 1673 0006 1F93 push r17 + 1674 0008 CF93 push r28 + 1675 000a DF93 push r29 + 1676 /* prologue: function */ + 1677 /* frame size = 0 */ + 1678 000c 9C01 movw r18,r24 + 1679 .LVL181: + 1680 .LSM249: + 1681 000e E090 0000 lds r14,USB_ControlRequest+6 + 1682 0012 F090 0000 lds r15,(USB_ControlRequest+6)+1 + 1683 .LVL182: + 1684 0016 E616 cp r14,r22 + 1685 0018 F706 cpc r15,r23 + 1686 001a 00F4 brsh .L177 + 1687 .L180: + 1688 .LSM250: + 1689 001c 90E0 ldi r25,lo8(0) + 1690 .LVL183: + 1691 001e 00C0 rjmp .L196 + 1692 .LVL184: + 1693 .L177: + 1694 .LSM251: + 1695 0020 6115 cp r22,__zero_reg__ + 1696 0022 7105 cpc r23,__zero_reg__ + 1697 0024 01F0 breq .L179 + 1698 .LVL185: + 1699 0026 7B01 movw r14,r22 + 1700 0028 00C0 rjmp .L180 + 1701 .L179: + 1702 .LBB411: + 1703 .LBB412: + 1704 .LSM252: + 1705 002a 8091 E800 lds r24,232 + 1706 002e 8E77 andi r24,lo8(126) + 1707 0030 8093 E800 sts 232,r24 + 1708 0034 EE24 clr r14 + 1709 0036 FF24 clr r15 + 1710 .LVL186: + 1711 0038 00C0 rjmp .L180 + 1712 .LVL187: + 1713 .L190: + 1714 .LBE412: + 1715 .LBE411: + 1716 .LBB413: + 1717 .LSM253: + 1718 003a 8091 0000 lds r24,USB_DeviceState + 1719 .LVL188: + 1720 .LSM254: + 1721 003e 8823 tst r24 + 1722 0040 01F4 brne .+2 + 1723 0042 00C0 rjmp .L181 + 1724 .LSM255: + 1725 0044 8530 cpi r24,lo8(5) + 1726 0046 01F4 brne .+2 + 1727 0048 00C0 rjmp .L182 + 1728 .LBB414: + 1729 .LBB415: + 1730 .LSM256: + 1731 004a 8091 E800 lds r24,232 + 1732 .LVL189: + 1733 .LBE415: + 1734 .LBE414: + 1735 .LSM257: + 1736 004e 83FF sbrs r24,3 + 1737 0050 00C0 rjmp .L183 + 1738 0052 81E0 ldi r24,lo8(1) + 1739 0054 00C0 rjmp .L184 + 1740 .L183: + 1741 .LBB416: + 1742 .LBB417: + 1743 .LSM258: + 1744 0056 8091 E800 lds r24,232 + 1745 .LBE417: + 1746 .LBE416: + 1747 .LSM259: + 1748 005a 82FD sbrc r24,2 + 1749 005c 00C0 rjmp .L194 + 1750 .LBB418: + 1751 .LBB419: + 1752 .LSM260: + 1753 005e 8091 E800 lds r24,232 + 1754 .LBE419: + 1755 .LBE418: + 1756 .LSM261: + 1757 0062 80FF sbrs r24,0 + 1758 0064 00C0 rjmp .L196 + 1759 .LBB420: + 1760 .LBB421: + 1761 .LBB422: + 1762 .LSM262: + 1763 0066 8091 F200 lds r24,242 + 1764 006a C82F mov r28,r24 + 1765 .LVL190: + 1766 006c D0E0 ldi r29,lo8(0) + 1767 006e 00C0 rjmp .L186 + 1768 .L188: + 1769 .LBE422: + 1770 .LBE421: + 1771 .LSM263: + 1772 0070 8901 movw r16,r18 + 1773 0072 0F5F subi r16,lo8(-(1)) + 1774 0074 1F4F sbci r17,hi8(-(1)) + 1775 .LVL191: + 1776 0076 C901 movw r24,r18 + 1777 0078 0E94 0000 call __eerd_byte_usb162 + 1778 .LVL192: + 1779 .LBB423: + 1780 .LBB424: + 1781 .LSM264: + 1782 007c 8093 F100 sts 241,r24 + 1783 .LBE424: + 1784 .LBE423: + 1785 .LSM265: + 1786 0080 0894 sec + 1787 0082 E108 sbc r14,__zero_reg__ + 1788 0084 F108 sbc r15,__zero_reg__ + 1789 .LSM266: + 1790 0086 2196 adiw r28,1 + 1791 0088 9801 movw r18,r16 + 1792 .LVL193: + 1793 .L186: + 1794 .LSM267: + 1795 008a E114 cp r14,__zero_reg__ + 1796 008c F104 cpc r15,__zero_reg__ + 1797 008e 01F0 breq .L187 + 1798 0090 C830 cpi r28,8 + 1799 0092 D105 cpc r29,__zero_reg__ + 1800 0094 00F0 brlo .L188 + 1801 .L187: + 1802 .LSM268: + 1803 0096 90E0 ldi r25,lo8(0) + 1804 0098 2897 sbiw r28,8 + 1805 009a 01F4 brne .L189 + 1806 009c 91E0 ldi r25,lo8(1) + 1807 .L189: + 1808 .LBB425: + 1809 .LBB426: + 1810 .LSM269: + 1811 009e 8091 E800 lds r24,232 + 1812 00a2 8E77 andi r24,lo8(126) + 1813 00a4 8093 E800 sts 232,r24 + 1814 .L196: + 1815 .LBE426: + 1816 .LBE425: + 1817 .LBE420: + 1818 .LBE413: + 1819 .LSM270: + 1820 00a8 E114 cp r14,__zero_reg__ + 1821 00aa F104 cpc r15,__zero_reg__ + 1822 00ac 01F4 brne .L190 + 1823 00ae 9923 tst r25 + 1824 00b0 01F4 brne .L190 + 1825 00b2 00C0 rjmp .L194 + 1826 .L191: + 1827 .LBB427: + 1828 .LSM271: + 1829 00b4 8091 0000 lds r24,USB_DeviceState + 1830 .LVL194: + 1831 .LSM272: + 1832 00b8 8823 tst r24 + 1833 00ba 01F0 breq .L181 + 1834 .LSM273: + 1835 00bc 8530 cpi r24,lo8(5) + 1836 00be 01F0 breq .L182 + 1837 .L194: + 1838 .LBE427: + 1839 .LBB428: + 1840 .LBB429: + 1841 .LSM274: + 1842 00c0 8091 E800 lds r24,232 + 1843 .LVL195: + 1844 .LBE429: + 1845 .LBE428: + 1846 .LSM275: + 1847 00c4 82FF sbrs r24,2 + 1848 00c6 00C0 rjmp .L191 + 1849 00c8 80E0 ldi r24,lo8(0) + 1850 00ca 00C0 rjmp .L184 + 1851 .LVL196: + 1852 .L181: + 1853 00cc 82E0 ldi r24,lo8(2) + 1854 .LVL197: + 1855 00ce 00C0 rjmp .L184 + 1856 .LVL198: + 1857 .L182: + 1858 00d0 83E0 ldi r24,lo8(3) + 1859 .LVL199: + 1860 .L184: + 1861 /* epilogue start */ + 1862 .LSM276: + 1863 00d2 DF91 pop r29 + 1864 .LVL200: + 1865 00d4 CF91 pop r28 + 1866 .LVL201: + 1867 00d6 1F91 pop r17 + 1868 00d8 0F91 pop r16 + 1869 00da FF90 pop r15 + 1870 00dc EF90 pop r14 + 1871 .LVL202: + 1872 00de 0895 ret + 1873 .LFE81: + 1875 .section .text.Endpoint_Read_EStream_BE,"ax",@progbits + 1876 .global Endpoint_Read_EStream_BE + 1878 Endpoint_Read_EStream_BE: + 1879 .LFB78: + 1880 .LSM277: + 1881 .LVL203: + 1882 0000 BF92 push r11 + 1883 0002 CF92 push r12 + 1884 0004 DF92 push r13 + 1885 0006 EF92 push r14 + 1886 0008 FF92 push r15 + 1887 000a 0F93 push r16 + 1888 000c 1F93 push r17 + 1889 000e CF93 push r28 + 1890 0010 DF93 push r29 + 1891 /* prologue: function */ + 1892 /* frame size = 0 */ + 1893 0012 7C01 movw r14,r24 + 1894 0014 EB01 movw r28,r22 + 1895 0016 6A01 movw r12,r20 + 1896 .LSM278: + 1897 0018 0E94 0000 call Endpoint_WaitUntilReady + 1898 .LVL204: + 1899 001c B82E mov r11,r24 + 1900 .LVL205: + 1901 001e 8823 tst r24 + 1902 0020 01F4 brne .L198 + 1903 .LVL206: + 1904 .LSM279: + 1905 0022 2197 sbiw r28,1 + 1906 0024 EC0E add r14,r28 + 1907 0026 FD1E adc r15,r29 + 1908 .LVL207: + 1909 0028 2196 adiw r28,1 + 1910 002a 00C0 rjmp .L205 + 1911 .LVL208: + 1912 .L203: + 1913 .LBB430: + 1914 .LBB431: + 1915 .LSM280: + 1916 002c 8091 E800 lds r24,232 + 1917 .LBE431: + 1918 .LBE430: + 1919 .LSM281: + 1920 0030 85FD sbrc r24,5 + 1921 0032 00C0 rjmp .L200 + 1922 .LBB432: + 1923 .LBB433: + 1924 .LSM282: + 1925 0034 8091 E800 lds r24,232 + 1926 0038 8B77 andi r24,lo8(123) + 1927 003a 8093 E800 sts 232,r24 + 1928 .LBE433: + 1929 .LBE432: + 1930 .LSM283: + 1931 003e C114 cp r12,__zero_reg__ + 1932 0040 D104 cpc r13,__zero_reg__ + 1933 0042 01F0 breq .L201 + 1934 0044 F601 movw r30,r12 + 1935 0046 0995 icall + 1936 0048 8130 cpi r24,lo8(1) + 1937 004a 01F4 brne .L201 + 1938 004c 85E0 ldi r24,lo8(5) + 1939 .LVL209: + 1940 004e 00C0 rjmp .L202 + 1941 .LVL210: + 1942 .L201: + 1943 .LSM284: + 1944 0050 0E94 0000 call Endpoint_WaitUntilReady + 1945 0054 8823 tst r24 + 1946 0056 01F0 breq .L205 + 1947 .LVL211: + 1948 0058 00C0 rjmp .L202 + 1949 .LVL212: + 1950 .L200: + 1951 .LSM285: + 1952 005a 8701 movw r16,r14 + 1953 005c 0150 subi r16,lo8(-(-1)) + 1954 005e 1040 sbci r17,hi8(-(-1)) + 1955 .LVL213: + 1956 .LBB434: + 1957 .LBB435: + 1958 .LSM286: + 1959 0060 6091 F100 lds r22,241 + 1960 .LBE435: + 1961 .LBE434: + 1962 .LSM287: + 1963 0064 C701 movw r24,r14 + 1964 0066 0E94 0000 call __eeupd_byte_usb162 + 1965 .LSM288: + 1966 006a 2197 sbiw r28,1 + 1967 006c 7801 movw r14,r16 + 1968 .LVL214: + 1969 .L205: + 1970 .LSM289: + 1971 006e 2097 sbiw r28,0 + 1972 0070 01F4 brne .L203 + 1973 .LVL215: + 1974 .L198: + 1975 0072 8B2D mov r24,r11 + 1976 .L202: + 1977 .LVL216: + 1978 /* epilogue start */ + 1979 .LSM290: + 1980 0074 DF91 pop r29 + 1981 0076 CF91 pop r28 + 1982 .LVL217: + 1983 0078 1F91 pop r17 + 1984 007a 0F91 pop r16 + 1985 007c FF90 pop r15 + 1986 007e EF90 pop r14 + 1987 .LVL218: + 1988 0080 DF90 pop r13 + 1989 0082 CF90 pop r12 + 1990 .LVL219: + 1991 0084 BF90 pop r11 + 1992 .LVL220: + 1993 0086 0895 ret + 1994 .LFE78: + 1996 .section .text.Endpoint_Read_Stream_BE,"ax",@progbits + 1997 .global Endpoint_Read_Stream_BE + 1999 Endpoint_Read_Stream_BE: + 2000 .LFB77: + 2001 .LSM291: + 2002 .LVL221: + 2003 0000 DF92 push r13 + 2004 0002 EF92 push r14 + 2005 0004 FF92 push r15 + 2006 0006 0F93 push r16 + 2007 0008 1F93 push r17 + 2008 000a CF93 push r28 + 2009 000c DF93 push r29 + 2010 /* prologue: function */ + 2011 /* frame size = 0 */ + 2012 000e 8C01 movw r16,r24 + 2013 0010 EB01 movw r28,r22 + 2014 0012 7A01 movw r14,r20 + 2015 .LSM292: + 2016 0014 0E94 0000 call Endpoint_WaitUntilReady + 2017 .LVL222: + 2018 0018 D82E mov r13,r24 + 2019 .LVL223: + 2020 001a 8823 tst r24 + 2021 001c 01F4 brne .L207 + 2022 .LVL224: + 2023 .LSM293: + 2024 001e 2197 sbiw r28,1 + 2025 0020 0C0F add r16,r28 + 2026 0022 1D1F adc r17,r29 + 2027 .LVL225: + 2028 0024 2196 adiw r28,1 + 2029 0026 00C0 rjmp .L214 + 2030 .L212: + 2031 .LBB436: + 2032 .LBB437: + 2033 .LSM294: + 2034 0028 8091 E800 lds r24,232 + 2035 .LVL226: + 2036 .LBE437: + 2037 .LBE436: + 2038 .LSM295: + 2039 002c 85FD sbrc r24,5 + 2040 002e 00C0 rjmp .L209 + 2041 .LBB438: + 2042 .LBB439: + 2043 .LSM296: + 2044 0030 8091 E800 lds r24,232 + 2045 0034 8B77 andi r24,lo8(123) + 2046 0036 8093 E800 sts 232,r24 + 2047 .LBE439: + 2048 .LBE438: + 2049 .LSM297: + 2050 003a E114 cp r14,__zero_reg__ + 2051 003c F104 cpc r15,__zero_reg__ + 2052 003e 01F0 breq .L210 + 2053 0040 F701 movw r30,r14 + 2054 0042 0995 icall + 2055 0044 8130 cpi r24,lo8(1) + 2056 0046 01F4 brne .L210 + 2057 0048 85E0 ldi r24,lo8(5) + 2058 .LVL227: + 2059 004a 00C0 rjmp .L211 + 2060 .LVL228: + 2061 .L210: + 2062 .LSM298: + 2063 004c 0E94 0000 call Endpoint_WaitUntilReady + 2064 0050 8823 tst r24 + 2065 0052 01F0 breq .L214 + 2066 .LVL229: + 2067 0054 00C0 rjmp .L211 + 2068 .LVL230: + 2069 .L209: + 2070 .LBB440: + 2071 .LBB441: + 2072 .LSM299: + 2073 0056 8091 F100 lds r24,241 + 2074 .LBE441: + 2075 .LBE440: + 2076 .LSM300: + 2077 005a F801 movw r30,r16 + 2078 005c 8083 st Z,r24 + 2079 005e 0150 subi r16,lo8(-(-1)) + 2080 0060 1040 sbci r17,hi8(-(-1)) + 2081 .LSM301: + 2082 0062 2197 sbiw r28,1 + 2083 .LVL231: + 2084 .L214: + 2085 .LSM302: + 2086 0064 2097 sbiw r28,0 + 2087 0066 01F4 brne .L212 + 2088 .LVL232: + 2089 .L207: + 2090 0068 8D2D mov r24,r13 + 2091 .L211: + 2092 .LVL233: + 2093 /* epilogue start */ + 2094 .LSM303: + 2095 006a DF91 pop r29 + 2096 006c CF91 pop r28 + 2097 .LVL234: + 2098 006e 1F91 pop r17 + 2099 0070 0F91 pop r16 + 2100 .LVL235: + 2101 0072 FF90 pop r15 + 2102 0074 EF90 pop r14 + 2103 .LVL236: + 2104 0076 DF90 pop r13 + 2105 .LVL237: + 2106 0078 0895 ret + 2107 .LFE77: + 2109 .section .text.Endpoint_Read_EStream_LE,"ax",@progbits + 2110 .global Endpoint_Read_EStream_LE + 2112 Endpoint_Read_EStream_LE: + 2113 .LFB76: + 2114 .LSM304: + 2115 .LVL238: + 2116 0000 BF92 push r11 + 2117 0002 CF92 push r12 + 2118 0004 DF92 push r13 + 2119 0006 EF92 push r14 + 2120 0008 FF92 push r15 + 2121 000a 0F93 push r16 + 2122 000c 1F93 push r17 + 2123 000e CF93 push r28 + 2124 0010 DF93 push r29 + 2125 /* prologue: function */ + 2126 /* frame size = 0 */ + 2127 0012 8C01 movw r16,r24 + 2128 .LVL239: + 2129 0014 7B01 movw r14,r22 + 2130 0016 6A01 movw r12,r20 + 2131 .LSM305: + 2132 0018 0E94 0000 call Endpoint_WaitUntilReady + 2133 .LVL240: + 2134 001c B82E mov r11,r24 + 2135 .LVL241: + 2136 001e 8823 tst r24 + 2137 0020 01F4 brne .L216 + 2138 .LVL242: + 2139 .LSM306: + 2140 0022 E801 movw r28,r16 + 2141 .LVL243: + 2142 0024 00C0 rjmp .L223 + 2143 .LVL244: + 2144 .L221: + 2145 .LBB442: + 2146 .LBB443: + 2147 .LSM307: + 2148 0026 8091 E800 lds r24,232 + 2149 .LVL245: + 2150 .LBE443: + 2151 .LBE442: + 2152 .LSM308: + 2153 002a 85FD sbrc r24,5 + 2154 002c 00C0 rjmp .L218 + 2155 .LBB444: + 2156 .LBB445: + 2157 .LSM309: + 2158 002e 8091 E800 lds r24,232 + 2159 0032 8B77 andi r24,lo8(123) + 2160 0034 8093 E800 sts 232,r24 + 2161 .LBE445: + 2162 .LBE444: + 2163 .LSM310: + 2164 0038 C114 cp r12,__zero_reg__ + 2165 003a D104 cpc r13,__zero_reg__ + 2166 003c 01F0 breq .L219 + 2167 003e F601 movw r30,r12 + 2168 0040 0995 icall + 2169 0042 8130 cpi r24,lo8(1) + 2170 0044 01F4 brne .L219 + 2171 0046 85E0 ldi r24,lo8(5) + 2172 .LVL246: + 2173 0048 00C0 rjmp .L220 + 2174 .LVL247: + 2175 .L219: + 2176 .LSM311: + 2177 004a 0E94 0000 call Endpoint_WaitUntilReady + 2178 004e 8823 tst r24 + 2179 0050 01F0 breq .L223 + 2180 .LVL248: + 2181 0052 00C0 rjmp .L220 + 2182 .LVL249: + 2183 .L218: + 2184 .LSM312: + 2185 0054 8E01 movw r16,r28 + 2186 0056 0F5F subi r16,lo8(-(1)) + 2187 0058 1F4F sbci r17,hi8(-(1)) + 2188 .LVL250: + 2189 .LBB446: + 2190 .LBB447: + 2191 .LSM313: + 2192 005a 6091 F100 lds r22,241 + 2193 .LBE447: + 2194 .LBE446: + 2195 .LSM314: + 2196 005e CE01 movw r24,r28 + 2197 0060 0E94 0000 call __eeupd_byte_usb162 + 2198 .LSM315: + 2199 0064 0894 sec + 2200 0066 E108 sbc r14,__zero_reg__ + 2201 0068 F108 sbc r15,__zero_reg__ + 2202 006a E801 movw r28,r16 + 2203 .LVL251: + 2204 .L223: + 2205 .LSM316: + 2206 006c E114 cp r14,__zero_reg__ + 2207 006e F104 cpc r15,__zero_reg__ + 2208 0070 01F4 brne .L221 + 2209 .LVL252: + 2210 .L216: + 2211 0072 8B2D mov r24,r11 + 2212 .L220: + 2213 .LVL253: + 2214 /* epilogue start */ + 2215 .LSM317: + 2216 0074 DF91 pop r29 + 2217 0076 CF91 pop r28 + 2218 .LVL254: + 2219 0078 1F91 pop r17 + 2220 007a 0F91 pop r16 + 2221 .LVL255: + 2222 007c FF90 pop r15 + 2223 007e EF90 pop r14 + 2224 .LVL256: + 2225 0080 DF90 pop r13 + 2226 0082 CF90 pop r12 + 2227 .LVL257: + 2228 0084 BF90 pop r11 + 2229 .LVL258: + 2230 0086 0895 ret + 2231 .LFE76: + 2233 .section .text.Endpoint_Read_Stream_LE,"ax",@progbits + 2234 .global Endpoint_Read_Stream_LE + 2236 Endpoint_Read_Stream_LE: + 2237 .LFB75: + 2238 .LSM318: + 2239 .LVL259: + 2240 0000 DF92 push r13 + 2241 0002 EF92 push r14 + 2242 0004 FF92 push r15 + 2243 0006 0F93 push r16 + 2244 0008 1F93 push r17 + 2245 000a CF93 push r28 + 2246 000c DF93 push r29 + 2247 /* prologue: function */ + 2248 /* frame size = 0 */ + 2249 000e 182F mov r17,r24 + 2250 0010 092F mov r16,r25 + 2251 .LVL260: + 2252 0012 EB01 movw r28,r22 + 2253 0014 7A01 movw r14,r20 + 2254 .LSM319: + 2255 0016 0E94 0000 call Endpoint_WaitUntilReady + 2256 .LVL261: + 2257 001a D82E mov r13,r24 + 2258 .LVL262: + 2259 001c 8823 tst r24 + 2260 001e 01F4 brne .L225 + 2261 .LVL263: + 2262 .LSM320: + 2263 0020 812F mov r24,r17 + 2264 .LVL264: + 2265 0022 902F mov r25,r16 + 2266 .LVL265: + 2267 0024 9C01 movw r18,r24 + 2268 .LVL266: + 2269 0026 8901 movw r16,r18 + 2270 .LVL267: + 2271 0028 00C0 rjmp .L232 + 2272 .LVL268: + 2273 .L230: + 2274 .LBB448: + 2275 .LBB449: + 2276 .LSM321: + 2277 002a 8091 E800 lds r24,232 + 2278 .LBE449: + 2279 .LBE448: + 2280 .LSM322: + 2281 002e 85FD sbrc r24,5 + 2282 0030 00C0 rjmp .L227 + 2283 .LBB450: + 2284 .LBB451: + 2285 .LSM323: + 2286 0032 8091 E800 lds r24,232 + 2287 0036 8B77 andi r24,lo8(123) + 2288 0038 8093 E800 sts 232,r24 + 2289 .LBE451: + 2290 .LBE450: + 2291 .LSM324: + 2292 003c E114 cp r14,__zero_reg__ + 2293 003e F104 cpc r15,__zero_reg__ + 2294 0040 01F0 breq .L228 + 2295 0042 F701 movw r30,r14 + 2296 0044 0995 icall + 2297 .LVL269: + 2298 0046 8130 cpi r24,lo8(1) + 2299 0048 01F4 brne .L228 + 2300 004a 85E0 ldi r24,lo8(5) + 2301 .LVL270: + 2302 004c 00C0 rjmp .L229 + 2303 .LVL271: + 2304 .L228: + 2305 .LSM325: + 2306 004e 0E94 0000 call Endpoint_WaitUntilReady + 2307 .LVL272: + 2308 0052 8823 tst r24 + 2309 0054 01F0 breq .L232 + 2310 .LVL273: + 2311 0056 00C0 rjmp .L229 + 2312 .LVL274: + 2313 .L227: + 2314 .LBB452: + 2315 .LBB453: + 2316 .LSM326: + 2317 0058 8091 F100 lds r24,241 + 2318 .LBE453: + 2319 .LBE452: + 2320 .LSM327: + 2321 005c F801 movw r30,r16 + 2322 005e 8193 st Z+,r24 + 2323 0060 8F01 movw r16,r30 + 2324 .LSM328: + 2325 0062 2197 sbiw r28,1 + 2326 .LVL275: + 2327 .L232: + 2328 .LSM329: + 2329 0064 2097 sbiw r28,0 + 2330 0066 01F4 brne .L230 + 2331 .LVL276: + 2332 .L225: + 2333 0068 8D2D mov r24,r13 + 2334 .L229: + 2335 .LVL277: + 2336 /* epilogue start */ + 2337 .LSM330: + 2338 006a DF91 pop r29 + 2339 006c CF91 pop r28 + 2340 .LVL278: + 2341 006e 1F91 pop r17 + 2342 .LVL279: + 2343 0070 0F91 pop r16 + 2344 .LVL280: + 2345 0072 FF90 pop r15 + 2346 0074 EF90 pop r14 + 2347 .LVL281: + 2348 0076 DF90 pop r13 + 2349 .LVL282: + 2350 0078 0895 ret + 2351 .LFE75: + 2353 .section .text.Endpoint_Write_PStream_BE,"ax",@progbits + 2354 .global Endpoint_Write_PStream_BE + 2356 Endpoint_Write_PStream_BE: + 2357 .LFB74: + 2358 .LSM331: + 2359 .LVL283: + 2360 0000 DF92 push r13 + 2361 0002 EF92 push r14 + 2362 0004 FF92 push r15 + 2363 0006 0F93 push r16 + 2364 0008 1F93 push r17 + 2365 000a CF93 push r28 + 2366 000c DF93 push r29 + 2367 /* prologue: function */ + 2368 /* frame size = 0 */ + 2369 000e 8C01 movw r16,r24 + 2370 0010 EB01 movw r28,r22 + 2371 0012 7A01 movw r14,r20 + 2372 .LSM332: + 2373 0014 0E94 0000 call Endpoint_WaitUntilReady + 2374 .LVL284: + 2375 0018 D82E mov r13,r24 + 2376 .LVL285: + 2377 001a 8823 tst r24 + 2378 001c 01F4 brne .L234 + 2379 .LVL286: + 2380 .LSM333: + 2381 001e 2197 sbiw r28,1 + 2382 0020 0C0F add r16,r28 + 2383 0022 1D1F adc r17,r29 + 2384 .LVL287: + 2385 0024 2196 adiw r28,1 + 2386 0026 00C0 rjmp .L241 + 2387 .LVL288: + 2388 .L239: + 2389 .LBB454: + 2390 .LBB455: + 2391 .LSM334: + 2392 0028 8091 E800 lds r24,232 + 2393 .LBE455: + 2394 .LBE454: + 2395 .LSM335: + 2396 002c 85FD sbrc r24,5 + 2397 002e 00C0 rjmp .L236 + 2398 .LBB456: + 2399 .LBB457: + 2400 .LSM336: + 2401 0030 8091 E800 lds r24,232 + 2402 0034 8E77 andi r24,lo8(126) + 2403 0036 8093 E800 sts 232,r24 + 2404 .LBE457: + 2405 .LBE456: + 2406 .LSM337: + 2407 003a E114 cp r14,__zero_reg__ + 2408 003c F104 cpc r15,__zero_reg__ + 2409 003e 01F0 breq .L237 + 2410 0040 F701 movw r30,r14 + 2411 0042 0995 icall + 2412 .LVL289: + 2413 0044 8130 cpi r24,lo8(1) + 2414 0046 01F4 brne .L237 + 2415 0048 85E0 ldi r24,lo8(5) + 2416 .LVL290: + 2417 004a 00C0 rjmp .L238 + 2418 .LVL291: + 2419 .L237: + 2420 .LSM338: + 2421 004c 0E94 0000 call Endpoint_WaitUntilReady + 2422 .LVL292: + 2423 0050 8823 tst r24 + 2424 0052 01F0 breq .L241 + 2425 .LVL293: + 2426 0054 00C0 rjmp .L238 + 2427 .LVL294: + 2428 .L236: + 2429 .LBB458: + 2430 .LSM339: + 2431 0056 F801 movw r30,r16 + 2432 .LVL295: + 2433 0058 0150 subi r16,lo8(-(-1)) + 2434 005a 1040 sbci r17,hi8(-(-1)) + 2435 /* #APP */ + 2436 ; 67 "LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_RW.c" 1 + 2437 005c E491 lpm r30, Z + 2438 + 2439 ; 0 "" 2 + 2440 .LVL296: + 2441 /* #NOAPP */ + 2442 .LBE458: + 2443 .LBB459: + 2444 .LBB460: + 2445 .LSM340: + 2446 005e E093 F100 sts 241,r30 + 2447 .LBE460: + 2448 .LBE459: + 2449 .LSM341: + 2450 0062 2197 sbiw r28,1 + 2451 .LVL297: + 2452 .L241: + 2453 .LSM342: + 2454 0064 2097 sbiw r28,0 + 2455 0066 01F4 brne .L239 + 2456 .LVL298: + 2457 .L234: + 2458 0068 8D2D mov r24,r13 + 2459 .L238: + 2460 .LVL299: + 2461 /* epilogue start */ + 2462 .LSM343: + 2463 006a DF91 pop r29 + 2464 006c CF91 pop r28 + 2465 .LVL300: + 2466 006e 1F91 pop r17 + 2467 0070 0F91 pop r16 + 2468 .LVL301: + 2469 0072 FF90 pop r15 + 2470 0074 EF90 pop r14 + 2471 .LVL302: + 2472 0076 DF90 pop r13 + 2473 .LVL303: + 2474 0078 0895 ret + 2475 .LFE74: + 2477 .section .text.Endpoint_Write_EStream_BE,"ax",@progbits + 2478 .global Endpoint_Write_EStream_BE + 2480 Endpoint_Write_EStream_BE: + 2481 .LFB73: + 2482 .LSM344: + 2483 .LVL304: + 2484 0000 BF92 push r11 + 2485 0002 CF92 push r12 + 2486 0004 DF92 push r13 + 2487 0006 EF92 push r14 + 2488 0008 FF92 push r15 + 2489 000a 0F93 push r16 + 2490 000c 1F93 push r17 + 2491 000e CF93 push r28 + 2492 0010 DF93 push r29 + 2493 /* prologue: function */ + 2494 /* frame size = 0 */ + 2495 0012 7C01 movw r14,r24 + 2496 0014 EB01 movw r28,r22 + 2497 0016 6A01 movw r12,r20 + 2498 .LSM345: + 2499 0018 0E94 0000 call Endpoint_WaitUntilReady + 2500 .LVL305: + 2501 001c B82E mov r11,r24 + 2502 .LVL306: + 2503 001e 8823 tst r24 + 2504 0020 01F4 brne .L243 + 2505 .LVL307: + 2506 .LSM346: + 2507 0022 2197 sbiw r28,1 + 2508 0024 EC0E add r14,r28 + 2509 0026 FD1E adc r15,r29 + 2510 .LVL308: + 2511 0028 2196 adiw r28,1 + 2512 002a 00C0 rjmp .L250 + 2513 .LVL309: + 2514 .L248: + 2515 .LBB461: + 2516 .LBB462: + 2517 .LSM347: + 2518 002c 8091 E800 lds r24,232 + 2519 .LBE462: + 2520 .LBE461: + 2521 .LSM348: + 2522 0030 85FD sbrc r24,5 + 2523 0032 00C0 rjmp .L245 + 2524 .LBB463: + 2525 .LBB464: + 2526 .LSM349: + 2527 0034 8091 E800 lds r24,232 + 2528 0038 8E77 andi r24,lo8(126) + 2529 003a 8093 E800 sts 232,r24 + 2530 .LBE464: + 2531 .LBE463: + 2532 .LSM350: + 2533 003e C114 cp r12,__zero_reg__ + 2534 0040 D104 cpc r13,__zero_reg__ + 2535 0042 01F0 breq .L246 + 2536 0044 F601 movw r30,r12 + 2537 0046 0995 icall + 2538 0048 8130 cpi r24,lo8(1) + 2539 004a 01F4 brne .L246 + 2540 004c 85E0 ldi r24,lo8(5) + 2541 .LVL310: + 2542 004e 00C0 rjmp .L247 + 2543 .LVL311: + 2544 .L246: + 2545 .LSM351: + 2546 0050 0E94 0000 call Endpoint_WaitUntilReady + 2547 0054 8823 tst r24 + 2548 0056 01F0 breq .L250 + 2549 .LVL312: + 2550 0058 00C0 rjmp .L247 + 2551 .LVL313: + 2552 .L245: + 2553 .LSM352: + 2554 005a 8701 movw r16,r14 + 2555 005c 0150 subi r16,lo8(-(-1)) + 2556 005e 1040 sbci r17,hi8(-(-1)) + 2557 .LVL314: + 2558 0060 C701 movw r24,r14 + 2559 0062 0E94 0000 call __eerd_byte_usb162 + 2560 .LBB465: + 2561 .LBB466: + 2562 .LSM353: + 2563 0066 8093 F100 sts 241,r24 + 2564 .LBE466: + 2565 .LBE465: + 2566 .LSM354: + 2567 006a 2197 sbiw r28,1 + 2568 006c 7801 movw r14,r16 + 2569 .LVL315: + 2570 .L250: + 2571 .LSM355: + 2572 006e 2097 sbiw r28,0 + 2573 0070 01F4 brne .L248 + 2574 .LVL316: + 2575 .L243: + 2576 0072 8B2D mov r24,r11 + 2577 .L247: + 2578 .LVL317: + 2579 /* epilogue start */ + 2580 .LSM356: + 2581 0074 DF91 pop r29 + 2582 0076 CF91 pop r28 + 2583 .LVL318: + 2584 0078 1F91 pop r17 + 2585 007a 0F91 pop r16 + 2586 007c FF90 pop r15 + 2587 007e EF90 pop r14 + 2588 .LVL319: + 2589 0080 DF90 pop r13 + 2590 0082 CF90 pop r12 + 2591 .LVL320: + 2592 0084 BF90 pop r11 + 2593 .LVL321: + 2594 0086 0895 ret + 2595 .LFE73: + 2597 .section .text.Endpoint_Write_Stream_BE,"ax",@progbits + 2598 .global Endpoint_Write_Stream_BE + 2600 Endpoint_Write_Stream_BE: + 2601 .LFB72: + 2602 .LSM357: + 2603 .LVL322: + 2604 0000 DF92 push r13 + 2605 0002 EF92 push r14 + 2606 0004 FF92 push r15 + 2607 0006 0F93 push r16 + 2608 0008 1F93 push r17 + 2609 000a CF93 push r28 + 2610 000c DF93 push r29 + 2611 /* prologue: function */ + 2612 /* frame size = 0 */ + 2613 000e 8C01 movw r16,r24 + 2614 0010 EB01 movw r28,r22 + 2615 0012 7A01 movw r14,r20 + 2616 .LSM358: + 2617 0014 0E94 0000 call Endpoint_WaitUntilReady + 2618 .LVL323: + 2619 0018 D82E mov r13,r24 + 2620 .LVL324: + 2621 001a 8823 tst r24 + 2622 001c 01F4 brne .L252 + 2623 .LVL325: + 2624 .LSM359: + 2625 001e 2197 sbiw r28,1 + 2626 0020 0C0F add r16,r28 + 2627 0022 1D1F adc r17,r29 + 2628 .LVL326: + 2629 0024 2196 adiw r28,1 + 2630 0026 00C0 rjmp .L259 + 2631 .L257: + 2632 .LBB467: + 2633 .LBB468: + 2634 .LSM360: + 2635 0028 8091 E800 lds r24,232 + 2636 .LVL327: + 2637 .LBE468: + 2638 .LBE467: + 2639 .LSM361: + 2640 002c 85FD sbrc r24,5 + 2641 002e 00C0 rjmp .L254 + 2642 .LBB469: + 2643 .LBB470: + 2644 .LSM362: + 2645 0030 8091 E800 lds r24,232 + 2646 0034 8E77 andi r24,lo8(126) + 2647 0036 8093 E800 sts 232,r24 + 2648 .LBE470: + 2649 .LBE469: + 2650 .LSM363: + 2651 003a E114 cp r14,__zero_reg__ + 2652 003c F104 cpc r15,__zero_reg__ + 2653 003e 01F0 breq .L255 + 2654 0040 F701 movw r30,r14 + 2655 0042 0995 icall + 2656 0044 8130 cpi r24,lo8(1) + 2657 0046 01F4 brne .L255 + 2658 0048 85E0 ldi r24,lo8(5) + 2659 .LVL328: + 2660 004a 00C0 rjmp .L256 + 2661 .LVL329: + 2662 .L255: + 2663 .LSM364: + 2664 004c 0E94 0000 call Endpoint_WaitUntilReady + 2665 0050 8823 tst r24 + 2666 0052 01F0 breq .L259 + 2667 .LVL330: + 2668 0054 00C0 rjmp .L256 + 2669 .LVL331: + 2670 .L254: + 2671 .LSM365: + 2672 0056 F801 movw r30,r16 + 2673 0058 8081 ld r24,Z + 2674 005a 0150 subi r16,lo8(-(-1)) + 2675 005c 1040 sbci r17,hi8(-(-1)) + 2676 .LBB471: + 2677 .LBB472: + 2678 .LSM366: + 2679 005e 8093 F100 sts 241,r24 + 2680 .LBE472: + 2681 .LBE471: + 2682 .LSM367: + 2683 0062 2197 sbiw r28,1 + 2684 .LVL332: + 2685 .L259: + 2686 .LSM368: + 2687 0064 2097 sbiw r28,0 + 2688 0066 01F4 brne .L257 + 2689 .LVL333: + 2690 .L252: + 2691 0068 8D2D mov r24,r13 + 2692 .L256: + 2693 .LVL334: + 2694 /* epilogue start */ + 2695 .LSM369: + 2696 006a DF91 pop r29 + 2697 006c CF91 pop r28 + 2698 .LVL335: + 2699 006e 1F91 pop r17 + 2700 0070 0F91 pop r16 + 2701 .LVL336: + 2702 0072 FF90 pop r15 + 2703 0074 EF90 pop r14 + 2704 .LVL337: + 2705 0076 DF90 pop r13 + 2706 .LVL338: + 2707 0078 0895 ret + 2708 .LFE72: + 2710 .section .text.Endpoint_Write_EStream_LE,"ax",@progbits + 2711 .global Endpoint_Write_EStream_LE + 2713 Endpoint_Write_EStream_LE: + 2714 .LFB71: + 2715 .LSM370: + 2716 .LVL339: + 2717 0000 BF92 push r11 + 2718 0002 CF92 push r12 + 2719 0004 DF92 push r13 + 2720 0006 EF92 push r14 + 2721 0008 FF92 push r15 + 2722 000a 0F93 push r16 + 2723 000c 1F93 push r17 + 2724 000e CF93 push r28 + 2725 0010 DF93 push r29 + 2726 /* prologue: function */ + 2727 /* frame size = 0 */ + 2728 0012 8C01 movw r16,r24 + 2729 .LVL340: + 2730 0014 7B01 movw r14,r22 + 2731 0016 6A01 movw r12,r20 + 2732 .LSM371: + 2733 0018 0E94 0000 call Endpoint_WaitUntilReady + 2734 .LVL341: + 2735 001c B82E mov r11,r24 + 2736 .LVL342: + 2737 001e 8823 tst r24 + 2738 0020 01F4 brne .L261 + 2739 .LVL343: + 2740 .LSM372: + 2741 0022 E801 movw r28,r16 + 2742 .LVL344: + 2743 0024 00C0 rjmp .L268 + 2744 .LVL345: + 2745 .L266: + 2746 .LBB473: + 2747 .LBB474: + 2748 .LSM373: + 2749 0026 8091 E800 lds r24,232 + 2750 .LVL346: + 2751 .LBE474: + 2752 .LBE473: + 2753 .LSM374: + 2754 002a 85FD sbrc r24,5 + 2755 002c 00C0 rjmp .L263 + 2756 .LBB475: + 2757 .LBB476: + 2758 .LSM375: + 2759 002e 8091 E800 lds r24,232 + 2760 0032 8E77 andi r24,lo8(126) + 2761 0034 8093 E800 sts 232,r24 + 2762 .LBE476: + 2763 .LBE475: + 2764 .LSM376: + 2765 0038 C114 cp r12,__zero_reg__ + 2766 003a D104 cpc r13,__zero_reg__ + 2767 003c 01F0 breq .L264 + 2768 003e F601 movw r30,r12 + 2769 0040 0995 icall + 2770 0042 8130 cpi r24,lo8(1) + 2771 0044 01F4 brne .L264 + 2772 0046 85E0 ldi r24,lo8(5) + 2773 .LVL347: + 2774 0048 00C0 rjmp .L265 + 2775 .LVL348: + 2776 .L264: + 2777 .LSM377: + 2778 004a 0E94 0000 call Endpoint_WaitUntilReady + 2779 004e 8823 tst r24 + 2780 0050 01F0 breq .L268 + 2781 .LVL349: + 2782 0052 00C0 rjmp .L265 + 2783 .LVL350: + 2784 .L263: + 2785 .LSM378: + 2786 0054 8E01 movw r16,r28 + 2787 0056 0F5F subi r16,lo8(-(1)) + 2788 0058 1F4F sbci r17,hi8(-(1)) + 2789 .LVL351: + 2790 005a CE01 movw r24,r28 + 2791 005c 0E94 0000 call __eerd_byte_usb162 + 2792 .LBB477: + 2793 .LBB478: + 2794 .LSM379: + 2795 0060 8093 F100 sts 241,r24 + 2796 .LBE478: + 2797 .LBE477: + 2798 .LSM380: + 2799 0064 0894 sec + 2800 0066 E108 sbc r14,__zero_reg__ + 2801 0068 F108 sbc r15,__zero_reg__ + 2802 006a E801 movw r28,r16 + 2803 .LVL352: + 2804 .L268: + 2805 .LSM381: + 2806 006c E114 cp r14,__zero_reg__ + 2807 006e F104 cpc r15,__zero_reg__ + 2808 0070 01F4 brne .L266 + 2809 .LVL353: + 2810 .L261: + 2811 0072 8B2D mov r24,r11 + 2812 .L265: + 2813 .LVL354: + 2814 /* epilogue start */ + 2815 .LSM382: + 2816 0074 DF91 pop r29 + 2817 0076 CF91 pop r28 + 2818 .LVL355: + 2819 0078 1F91 pop r17 + 2820 007a 0F91 pop r16 + 2821 .LVL356: + 2822 007c FF90 pop r15 + 2823 007e EF90 pop r14 + 2824 .LVL357: + 2825 0080 DF90 pop r13 + 2826 0082 CF90 pop r12 + 2827 .LVL358: + 2828 0084 BF90 pop r11 + 2829 .LVL359: + 2830 0086 0895 ret + 2831 .LFE71: + 2833 .section .text.Endpoint_Write_PStream_LE,"ax",@progbits + 2834 .global Endpoint_Write_PStream_LE + 2836 Endpoint_Write_PStream_LE: + 2837 .LFB70: + 2838 .LSM383: + 2839 .LVL360: + 2840 0000 BF92 push r11 + 2841 0002 CF92 push r12 + 2842 0004 DF92 push r13 + 2843 0006 EF92 push r14 + 2844 0008 FF92 push r15 + 2845 000a 0F93 push r16 + 2846 000c 1F93 push r17 + 2847 000e CF93 push r28 + 2848 0010 DF93 push r29 + 2849 /* prologue: function */ + 2850 /* frame size = 0 */ + 2851 0012 F82E mov r15,r24 + 2852 0014 E92E mov r14,r25 + 2853 .LVL361: + 2854 0016 8B01 movw r16,r22 + 2855 0018 6A01 movw r12,r20 + 2856 .LSM384: + 2857 001a 0E94 0000 call Endpoint_WaitUntilReady + 2858 .LVL362: + 2859 001e B82E mov r11,r24 + 2860 .LVL363: + 2861 0020 8823 tst r24 + 2862 0022 01F4 brne .L270 + 2863 .LVL364: + 2864 .LSM385: + 2865 0024 8F2D mov r24,r15 + 2866 .LVL365: + 2867 0026 9E2D mov r25,r14 + 2868 .LVL366: + 2869 0028 9C01 movw r18,r24 + 2870 .LVL367: + 2871 002a E901 movw r28,r18 + 2872 .LVL368: + 2873 002c 00C0 rjmp .L277 + 2874 .LVL369: + 2875 .L275: + 2876 .LBB479: + 2877 .LBB480: + 2878 .LSM386: + 2879 002e 8091 E800 lds r24,232 + 2880 .LBE480: + 2881 .LBE479: + 2882 .LSM387: + 2883 0032 85FD sbrc r24,5 + 2884 0034 00C0 rjmp .L272 + 2885 .LBB481: + 2886 .LBB482: + 2887 .LSM388: + 2888 0036 8091 E800 lds r24,232 + 2889 003a 8E77 andi r24,lo8(126) + 2890 003c 8093 E800 sts 232,r24 + 2891 .LBE482: + 2892 .LBE481: + 2893 .LSM389: + 2894 0040 C114 cp r12,__zero_reg__ + 2895 0042 D104 cpc r13,__zero_reg__ + 2896 0044 01F0 breq .L273 + 2897 0046 F601 movw r30,r12 + 2898 0048 0995 icall + 2899 .LVL370: + 2900 004a 8130 cpi r24,lo8(1) + 2901 004c 01F4 brne .L273 + 2902 004e 85E0 ldi r24,lo8(5) + 2903 .LVL371: + 2904 0050 00C0 rjmp .L274 + 2905 .LVL372: + 2906 .L273: + 2907 .LSM390: + 2908 0052 0E94 0000 call Endpoint_WaitUntilReady + 2909 .LVL373: + 2910 0056 8823 tst r24 + 2911 0058 01F0 breq .L277 + 2912 .LVL374: + 2913 005a 00C0 rjmp .L274 + 2914 .LVL375: + 2915 .L272: + 2916 .LBB483: + 2917 .LSM391: + 2918 005c FE01 movw r30,r28 + 2919 .LVL376: + 2920 005e 2196 adiw r28,1 + 2921 /* #APP */ + 2922 ; 67 "LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_RW.c" 1 + 2923 0060 E491 lpm r30, Z + 2924 + 2925 ; 0 "" 2 + 2926 .LVL377: + 2927 /* #NOAPP */ + 2928 .LBE483: + 2929 .LBB484: + 2930 .LBB485: + 2931 .LSM392: + 2932 0062 E093 F100 sts 241,r30 + 2933 .LBE485: + 2934 .LBE484: + 2935 .LSM393: + 2936 0066 0150 subi r16,lo8(-(-1)) + 2937 0068 1040 sbci r17,hi8(-(-1)) + 2938 .LVL378: + 2939 .L277: + 2940 .LSM394: + 2941 006a 0115 cp r16,__zero_reg__ + 2942 006c 1105 cpc r17,__zero_reg__ + 2943 006e 01F4 brne .L275 + 2944 .LVL379: + 2945 .L270: + 2946 0070 8B2D mov r24,r11 + 2947 .L274: + 2948 .LVL380: + 2949 /* epilogue start */ + 2950 .LSM395: + 2951 0072 DF91 pop r29 + 2952 0074 CF91 pop r28 + 2953 .LVL381: + 2954 0076 1F91 pop r17 + 2955 0078 0F91 pop r16 + 2956 .LVL382: + 2957 007a FF90 pop r15 + 2958 .LVL383: + 2959 007c EF90 pop r14 + 2960 .LVL384: + 2961 007e DF90 pop r13 + 2962 0080 CF90 pop r12 + 2963 .LVL385: + 2964 0082 BF90 pop r11 + 2965 .LVL386: + 2966 0084 0895 ret + 2967 .LFE70: + 2969 .section .text.Endpoint_Write_Stream_LE,"ax",@progbits + 2970 .global Endpoint_Write_Stream_LE + 2972 Endpoint_Write_Stream_LE: + 2973 .LFB69: + 2974 .LSM396: + 2975 .LVL387: + 2976 0000 DF92 push r13 + 2977 0002 EF92 push r14 + 2978 0004 FF92 push r15 + 2979 0006 0F93 push r16 + 2980 0008 1F93 push r17 + 2981 000a CF93 push r28 + 2982 000c DF93 push r29 + 2983 /* prologue: function */ + 2984 /* frame size = 0 */ + 2985 000e 182F mov r17,r24 + 2986 0010 092F mov r16,r25 + 2987 .LVL388: + 2988 0012 EB01 movw r28,r22 + 2989 0014 7A01 movw r14,r20 + 2990 .LSM397: + 2991 0016 0E94 0000 call Endpoint_WaitUntilReady + 2992 .LVL389: + 2993 001a D82E mov r13,r24 + 2994 .LVL390: + 2995 001c 8823 tst r24 + 2996 001e 01F4 brne .L279 + 2997 .LVL391: + 2998 .LSM398: + 2999 0020 812F mov r24,r17 + 3000 .LVL392: + 3001 0022 902F mov r25,r16 + 3002 .LVL393: + 3003 0024 9C01 movw r18,r24 + 3004 .LVL394: + 3005 0026 8901 movw r16,r18 + 3006 .LVL395: + 3007 0028 00C0 rjmp .L286 + 3008 .LVL396: + 3009 .L284: + 3010 .LBB486: + 3011 .LBB487: + 3012 .LSM399: + 3013 002a 8091 E800 lds r24,232 + 3014 .LBE487: + 3015 .LBE486: + 3016 .LSM400: + 3017 002e 85FD sbrc r24,5 + 3018 0030 00C0 rjmp .L281 + 3019 .LBB488: + 3020 .LBB489: + 3021 .LSM401: + 3022 0032 8091 E800 lds r24,232 + 3023 0036 8E77 andi r24,lo8(126) + 3024 0038 8093 E800 sts 232,r24 + 3025 .LBE489: + 3026 .LBE488: + 3027 .LSM402: + 3028 003c E114 cp r14,__zero_reg__ + 3029 003e F104 cpc r15,__zero_reg__ + 3030 0040 01F0 breq .L282 + 3031 0042 F701 movw r30,r14 + 3032 0044 0995 icall + 3033 .LVL397: + 3034 0046 8130 cpi r24,lo8(1) + 3035 0048 01F4 brne .L282 + 3036 004a 85E0 ldi r24,lo8(5) + 3037 .LVL398: + 3038 004c 00C0 rjmp .L283 + 3039 .LVL399: + 3040 .L282: + 3041 .LSM403: + 3042 004e 0E94 0000 call Endpoint_WaitUntilReady + 3043 .LVL400: + 3044 0052 8823 tst r24 + 3045 0054 01F0 breq .L286 + 3046 .LVL401: + 3047 0056 00C0 rjmp .L283 + 3048 .LVL402: + 3049 .L281: + 3050 .LSM404: + 3051 0058 F801 movw r30,r16 + 3052 005a 8191 ld r24,Z+ + 3053 005c 8F01 movw r16,r30 + 3054 .LBB490: + 3055 .LBB491: + 3056 .LSM405: + 3057 005e 8093 F100 sts 241,r24 + 3058 .LBE491: + 3059 .LBE490: + 3060 .LSM406: + 3061 0062 2197 sbiw r28,1 + 3062 .LVL403: + 3063 .L286: + 3064 .LSM407: + 3065 0064 2097 sbiw r28,0 + 3066 0066 01F4 brne .L284 + 3067 .LVL404: + 3068 .L279: + 3069 0068 8D2D mov r24,r13 + 3070 .L283: + 3071 .LVL405: + 3072 /* epilogue start */ + 3073 .LSM408: + 3074 006a DF91 pop r29 + 3075 006c CF91 pop r28 + 3076 .LVL406: + 3077 006e 1F91 pop r17 + 3078 .LVL407: + 3079 0070 0F91 pop r16 + 3080 .LVL408: + 3081 0072 FF90 pop r15 + 3082 0074 EF90 pop r14 + 3083 .LVL409: + 3084 0076 DF90 pop r13 + 3085 .LVL410: + 3086 0078 0895 ret + 3087 .LFE69: + 3089 .section .text.Endpoint_Discard_Stream,"ax",@progbits + 3090 .global Endpoint_Discard_Stream + 3092 Endpoint_Discard_Stream: + 3093 .LFB68: + 3094 .LSM409: + 3095 .LVL411: + 3096 0000 FF92 push r15 + 3097 0002 0F93 push r16 + 3098 0004 1F93 push r17 + 3099 0006 CF93 push r28 + 3100 0008 DF93 push r29 + 3101 /* prologue: function */ + 3102 /* frame size = 0 */ + 3103 000a EC01 movw r28,r24 + 3104 000c 8B01 movw r16,r22 + 3105 .LSM410: + 3106 000e 0E94 0000 call Endpoint_WaitUntilReady + 3107 .LVL412: + 3108 0012 F82E mov r15,r24 + 3109 .LVL413: + 3110 0014 8823 tst r24 + 3111 0016 01F0 breq .L295 + 3112 .LVL414: + 3113 0018 00C0 rjmp .L288 + 3114 .LVL415: + 3115 .L293: + 3116 .LBB492: + 3117 .LBB493: + 3118 .LSM411: + 3119 001a 8091 E800 lds r24,232 + 3120 .LVL416: + 3121 .LBE493: + 3122 .LBE492: + 3123 .LSM412: + 3124 001e 85FD sbrc r24,5 + 3125 0020 00C0 rjmp .L290 + 3126 .LBB494: + 3127 .LBB495: + 3128 .LSM413: + 3129 0022 8091 E800 lds r24,232 + 3130 0026 8B77 andi r24,lo8(123) + 3131 0028 8093 E800 sts 232,r24 + 3132 .LBE495: + 3133 .LBE494: + 3134 .LSM414: + 3135 002c 0115 cp r16,__zero_reg__ + 3136 002e 1105 cpc r17,__zero_reg__ + 3137 0030 01F0 breq .L291 + 3138 0032 F801 movw r30,r16 + 3139 0034 0995 icall + 3140 0036 8130 cpi r24,lo8(1) + 3141 0038 01F4 brne .L291 + 3142 003a 85E0 ldi r24,lo8(5) + 3143 .LVL417: + 3144 003c 00C0 rjmp .L292 + 3145 .LVL418: + 3146 .L291: + 3147 .LSM415: + 3148 003e 0E94 0000 call Endpoint_WaitUntilReady + 3149 0042 8823 tst r24 + 3150 0044 01F0 breq .L295 + 3151 .LVL419: + 3152 0046 00C0 rjmp .L292 + 3153 .LVL420: + 3154 .L290: + 3155 .LBB496: + 3156 .LBB497: + 3157 .LSM416: + 3158 0048 8091 F100 lds r24,241 + 3159 .LVL421: + 3160 .LBE497: + 3161 .LBE496: + 3162 .LSM417: + 3163 004c 2197 sbiw r28,1 + 3164 .LVL422: + 3165 .L295: + 3166 .LSM418: + 3167 004e 2097 sbiw r28,0 + 3168 0050 01F4 brne .L293 + 3169 .L288: + 3170 0052 8F2D mov r24,r15 + 3171 .LVL423: + 3172 .L292: + 3173 .LVL424: + 3174 /* epilogue start */ + 3175 .LSM419: + 3176 0054 DF91 pop r29 + 3177 0056 CF91 pop r28 + 3178 .LVL425: + 3179 0058 1F91 pop r17 + 3180 005a 0F91 pop r16 + 3181 .LVL426: + 3182 005c FF90 pop r15 + 3183 .LVL427: + 3184 005e 0895 ret + 3185 .LFE68: + 3371 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 EndpointStream.c + /tmp/ccfOEB0Q.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccfOEB0Q.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccfOEB0Q.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccfOEB0Q.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccfOEB0Q.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccfOEB0Q.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccfOEB0Q.s:19 .text.Endpoint_Write_Control_Stream_LE:0000000000000000 Endpoint_Write_Control_Stream_LE + /tmp/ccfOEB0Q.s:208 .text.Endpoint_Write_Control_PStream_LE:0000000000000000 Endpoint_Write_Control_PStream_LE + /tmp/ccfOEB0Q.s:407 .text.Endpoint_Write_Control_Stream_BE:0000000000000000 Endpoint_Write_Control_Stream_BE + /tmp/ccfOEB0Q.s:605 .text.Endpoint_Write_Control_PStream_BE:0000000000000000 Endpoint_Write_Control_PStream_BE + /tmp/ccfOEB0Q.s:812 .text.Endpoint_Read_Control_Stream_LE:0000000000000000 Endpoint_Read_Control_Stream_LE + /tmp/ccfOEB0Q.s:954 .text.Endpoint_Read_Control_Stream_BE:0000000000000000 Endpoint_Read_Control_Stream_BE + /tmp/ccfOEB0Q.s:1109 .text.Endpoint_Read_Control_EStream_BE:0000000000000000 Endpoint_Read_Control_EStream_BE + /tmp/ccfOEB0Q.s:1286 .text.Endpoint_Read_Control_EStream_LE:0000000000000000 Endpoint_Read_Control_EStream_LE + /tmp/ccfOEB0Q.s:1446 .text.Endpoint_Write_Control_EStream_BE:0000000000000000 Endpoint_Write_Control_EStream_BE + /tmp/ccfOEB0Q.s:1666 .text.Endpoint_Write_Control_EStream_LE:0000000000000000 Endpoint_Write_Control_EStream_LE + /tmp/ccfOEB0Q.s:1878 .text.Endpoint_Read_EStream_BE:0000000000000000 Endpoint_Read_EStream_BE + /tmp/ccfOEB0Q.s:1999 .text.Endpoint_Read_Stream_BE:0000000000000000 Endpoint_Read_Stream_BE + /tmp/ccfOEB0Q.s:2112 .text.Endpoint_Read_EStream_LE:0000000000000000 Endpoint_Read_EStream_LE + /tmp/ccfOEB0Q.s:2236 .text.Endpoint_Read_Stream_LE:0000000000000000 Endpoint_Read_Stream_LE + /tmp/ccfOEB0Q.s:2356 .text.Endpoint_Write_PStream_BE:0000000000000000 Endpoint_Write_PStream_BE + /tmp/ccfOEB0Q.s:2480 .text.Endpoint_Write_EStream_BE:0000000000000000 Endpoint_Write_EStream_BE + /tmp/ccfOEB0Q.s:2600 .text.Endpoint_Write_Stream_BE:0000000000000000 Endpoint_Write_Stream_BE + /tmp/ccfOEB0Q.s:2713 .text.Endpoint_Write_EStream_LE:0000000000000000 Endpoint_Write_EStream_LE + /tmp/ccfOEB0Q.s:2836 .text.Endpoint_Write_PStream_LE:0000000000000000 Endpoint_Write_PStream_LE + /tmp/ccfOEB0Q.s:2972 .text.Endpoint_Write_Stream_LE:0000000000000000 Endpoint_Write_Stream_LE + /tmp/ccfOEB0Q.s:3092 .text.Endpoint_Discard_Stream:0000000000000000 Endpoint_Discard_Stream + +UNDEFINED SYMBOLS +USB_ControlRequest +USB_DeviceState +__eeupd_byte_usb162 +__eerd_byte_usb162 +Endpoint_WaitUntilReady diff --git a/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.o b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.o new file mode 100644 index 0000000..9ba8202 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/EndpointStream.o differ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/Events.c b/firmware/LUFA/Drivers/USB/HighLevel/Events.c new file mode 100644 index 0000000..b73a7d1 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Events.c @@ -0,0 +1,39 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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/firmware/LUFA/Drivers/USB/HighLevel/Events.h b/firmware/LUFA/Drivers/USB/HighLevel/Events.h new file mode 100644 index 0000000..a7d3543 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Events.h @@ -0,0 +1,375 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 events manager. + * + * This file 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). + * + * \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 + * + * 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 + + #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 connected before the role change). + * + * \note This event only exists on USB AVR models which support dual role modes. + * \n\n + * + * \note This event does not exist if the USB_DEVICE_ONLY or 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 USB AVR models which supports host mode. + * \n\n + * + * \note This event does not exist if the 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 USB AVR models which supports host mode. + * \n\n + * + * \note This event does not exist if the 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 USB AVR models which supports host mode. + * \n\n + * + * \note This event does not exist if the 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 USB AVR models which supports host mode. + * \n\n + * + * \note This event does not exist if the 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 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 AVR in device mode and the device is connected + * to a host, beginning the enumeration process, measured by a rising level on the AVR's VBUS 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 smaller series 2 USB AVRs with limited USB controllers, VBUS 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 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 series 2 USB AVRs with limited USB controllers + * if NO_LIMITED_CONTROLLER_CONNECT is not defined. + * + * \see USBTask.h 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 AVR in device mode and the device is disconnected + * from a host, measured by a falling level on the AVR's VBUS pin. + * + * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS 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 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 series 2 USB AVRs with limited USB controllers + * if NO_LIMITED_CONTROLLER_CONNECT is not defined. + * + * \see USBTask.h 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 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_ConfigurationNumber has been changed. + * + * \note This event does not exist if the 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 USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note This event does not exist on the series 2 USB AVRs when the 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 USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT + * compile time token is not set - see \ref EVENT_USB_Device_Connect. + * + * \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 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. + * + * \note 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 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/firmware/LUFA/Drivers/USB/HighLevel/Events.lst b/firmware/LUFA/Drivers/USB/HighLevel/Events.lst new file mode 100644 index 0000000..73ddf6a --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Events.lst @@ -0,0 +1,55 @@ + 1 .file "Events.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_Event_Stub,"ax",@progbits + 17 .global USB_Event_Stub + 19 USB_Event_Stub: + 20 .LFB6: + 21 .LSM0: + 22 /* prologue: function */ + 23 /* frame size = 0 */ + 24 /* epilogue start */ + 25 .LSM1: + 26 0000 0895 ret + 27 .LFE6: + 29 .weak EVENT_USB_Device_Connect + 30 .set EVENT_USB_Device_Connect,USB_Event_Stub + 31 .weak EVENT_USB_Device_Disconnect + 32 .set EVENT_USB_Device_Disconnect,USB_Event_Stub + 33 .weak EVENT_USB_Device_ControlRequest + 34 .set EVENT_USB_Device_ControlRequest,USB_Event_Stub + 35 .weak EVENT_USB_Device_ConfigurationChanged + 36 .set EVENT_USB_Device_ConfigurationChanged,USB_Event_Stub + 37 .weak EVENT_USB_Device_Suspend + 38 .set EVENT_USB_Device_Suspend,USB_Event_Stub + 39 .weak EVENT_USB_Device_WakeUp + 40 .set EVENT_USB_Device_WakeUp,USB_Event_Stub + 41 .weak EVENT_USB_Device_Reset + 42 .set EVENT_USB_Device_Reset,USB_Event_Stub + 43 .weak EVENT_USB_Device_StartOfFrame + 44 .set EVENT_USB_Device_StartOfFrame,USB_Event_Stub + 69 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Events.c + /tmp/ccamxlGJ.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccamxlGJ.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccamxlGJ.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccamxlGJ.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccamxlGJ.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccamxlGJ.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 USB_Event_Stub + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_Connect + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_Disconnect + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_ControlRequest + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_ConfigurationChanged + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_Suspend + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_WakeUp + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_Reset + /tmp/ccamxlGJ.s:19 .text.USB_Event_Stub:0000000000000000 EVENT_USB_Device_StartOfFrame + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/HighLevel/Events.o b/firmware/LUFA/Drivers/USB/HighLevel/Events.o new file mode 100644 index 0000000..7b2f08b Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/Events.o differ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.c b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.c new file mode 100644 index 0000000..2eee726 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.c @@ -0,0 +1,180 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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_SendControlRequest(void* const BufferPtr) +{ + uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest; + 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_ClearErrorFlags(); + + Pipe_Unfreeze(); + + for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Request_Header_t); HeaderByte++) + Pipe_Write_Byte(*(HeaderStream++)); + + 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_Byte(); + 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_ControlPipeSize)) + { + Pipe_Write_Byte(*(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; +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.h b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.h new file mode 100644 index 0000000..4b9b3dc --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.h @@ -0,0 +1,118 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 + #include + + #include "USBMode.h" + #include "StdRequestType.h" + #include "../LowLevel/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: */ + /** 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. */ + }; + + /* 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 + * 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); + + /* 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/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.lst b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.lst new file mode 100644 index 0000000..499a9dd --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.lst @@ -0,0 +1,19 @@ + 1 .file "HostStandardReq.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 HostStandardReq.c + /tmp/ccRphupV.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccRphupV.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccRphupV.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccRphupV.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccRphupV.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccRphupV.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.o b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.o new file mode 100644 index 0000000..b9865fa Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/HostStandardReq.o differ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.c b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.c new file mode 100644 index 0000000..25100ca --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.c @@ -0,0 +1,196 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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.h" + +uint8_t Pipe_Discard_Stream(uint16_t Length + __CALLBACK_PARAM) +{ + uint8_t ErrorCode; + + Pipe_SetPipeToken(PIPE_TOKEN_IN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Pipe_BytesInPipe() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearIN(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return PIPE_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + Pipe_Discard_Byte(); + case 7: Pipe_Discard_Byte(); + case 6: Pipe_Discard_Byte(); + case 5: Pipe_Discard_Byte(); + case 4: Pipe_Discard_Byte(); + case 3: Pipe_Discard_Byte(); + case 2: Pipe_Discard_Byte(); + case 1: Pipe_Discard_Byte(); + } while (Length >= 8); + } + } + #endif + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearIN(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return PIPE_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Discard_Byte(); + Length--; + } + } + + return PIPE_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-past 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_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(*((uint8_t*)BufferPtr++)) +#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_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(*((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)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_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Pipe_Read_Byte() +#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_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr++, Pipe_Read_Byte()) +#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_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Pipe_Read_Byte() +#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_TRANSFER_BYTE(BufferPtr) eeprom_update_byte((uint8_t*)BufferPtr--, Pipe_Read_Byte()) +#include "Template/Template_Pipe_RW.c" + +#endif + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.h b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.h new file mode 100644 index 0000000..730a338 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.h @@ -0,0 +1,298 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 pipe stream function definitions. + * + * This file contains structures, function prototypes and macros related to the sending and receiving of + * arbitrary data streams through the device's data pipes when the library is initialized 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. + */ + +/** \ingroup Group_PipeRW + * @defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams + * + * 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 + #include + #include + + #include "../../../Common/Common.h" + #include "USBTask.h" + + #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__) + #include "StreamCallbacks.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 + + #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__) + #define __CALLBACK_PARAM , StreamCallbackPtr_t Callback + #else + #define __CALLBACK_PARAM + #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_CallbackAborted = 4, /**< Indicates that the stream's callback function aborted + * the transfer early. + */ + }; + + /* Function Prototypes: */ + /** 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. + * 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. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * 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 send via the currently selected pipe. + * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Discard_Stream(uint16_t Length + __CALLBACK_PARAM); + + /** 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. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_LE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /** 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_EStream_LE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /** 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_PStream_LE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_BE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_EStream_BE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_PStream_BE(const void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_LE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_EStream_LE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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. + * + * The callback routine should be created according to the information in \ref Group_StreamCallbacks. + * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are + * disabled and this function has the Callback parameter omitted. + * + * 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_BE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) 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] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_EStream_BE(void* Buffer, + uint16_t Length + __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.lst b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.lst new file mode 100644 index 0000000..f931e06 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.lst @@ -0,0 +1,19 @@ + 1 .file "PipeStream.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 PipeStream.c + /tmp/cct2dEBX.s:2 *ABS*:000000000000003f __SREG__ + /tmp/cct2dEBX.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/cct2dEBX.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/cct2dEBX.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/cct2dEBX.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/cct2dEBX.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.o b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.o new file mode 100644 index 0000000..32ff384 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/PipeStream.o differ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/StdDescriptors.h b/firmware/LUFA/Drivers/USB/HighLevel/StdDescriptors.h new file mode 100644 index 0000000..6001325 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/StdDescriptors.h @@ -0,0 +1,692 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 standard descriptor definitions. + * + * This file contains structures and macros for the easy creation of standard USB descriptors in USB device projects. + * + * \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_Descriptors USB Descriptors + * + * 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 + #include + #include + #include + + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "Events.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "../LowLevel/Device.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: */ + /* 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 + + #if (!defined(NO_INTERNAL_SERIAL) && \ + (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \ + defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \ + defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))) + /** 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 USB AVRs 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 NO_DESCRIPTOR and so will force the host to create a pseudo-serial + * number for the device. + */ + #define USE_INTERNAL_SERIAL 0xDC + #else + #define USE_INTERNAL_SERIAL NO_DESCRIPTOR + #endif + + /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. */ + #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. + */ + #define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 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. + */ + #define VERSION_BCD(x) ((((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 Endpoint Address Direction Masks */ + //@{ + /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's + * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from + * device to host). + */ + #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80 + + /** Can be masked with an endpoint address for a \ref USB_Descriptor_Endpoint_t endpoint descriptor's + * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from + * host to device). + */ + #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00 + //@} + + /** \name USB Configuration Descriptor Attribute Masks */ + //@{ + /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t + * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power + * from the host's VBUS line. + */ + #define USB_CONFIG_ATTR_BUSPOWERED 0x80 + + /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t + * descriptor's 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 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 + * 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 + * 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 + * 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 + * 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 + * 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 + * 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 + * 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. + */ + 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. + */ + } 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. + */ + 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. + */ + } 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. + */ + 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 AVR 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. + */ + } 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. + */ + 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 AVR 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. + */ + } USB_StdDescriptor_Device_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. + */ + 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 zero or + * more USB_CONFIG_ATTR_* masks. + */ + + uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the + * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() + * macro. + */ + } 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. + */ + 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 zero or + * more USB_CONFIG_ATTR_* masks. + */ + uint8_t bMaxPower; /**< Maximum power consumption of the device while in the + * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() + * macro. + */ + } 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. + */ + 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. */ + } 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. + */ + 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. + */ + } 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. + */ + 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. + */ + } 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. + */ + 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. + */ + } 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. + */ + 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. + */ + } 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. + */ + 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. + */ + } 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. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + wchar_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. + */ + } 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. + */ + 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. + */ + int16_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. + */ + } 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/firmware/LUFA/Drivers/USB/HighLevel/StdRequestType.h b/firmware/LUFA/Drivers/USB/HighLevel/StdRequestType.h new file mode 100644 index 0000000..7c18ead --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/StdRequestType.h @@ -0,0 +1,247 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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. + * + * This file contains structures and macros for the easy creation and parsing of standard USB control requests. + * + * \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 + * + * 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 + + /* 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 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 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 (Standard, Class + * or Vendor Specific). The result of this mask should then be compared to the request recipient + * masks. + * + * \see 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. */ + } 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, endpoint 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_ClearFeature = 1, /**< Implemented in the library for device, endpoint 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_SetFeature = 3, /**< Implemented in the library for device, endpoint 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_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 + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h b/firmware/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h new file mode 100644 index 0000000..6109de5 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/StreamCallbacks.h @@ -0,0 +1,87 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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/pipe stream callback management. + * + * This file contains definitions for the creation of optional callback routines which can be passed to the + * endpoint and/or pipe stream APIs, to abort the transfer currently in progress when a condition is met. + * + * \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_StreamCallbacks Endpoint and Pipe Stream Callbacks + * + * Macros and enums for the stream callback routines. This module contains the code required to easily set up + * stream callback functions which can be used to force early abort of a stream read/write process. Each callback + * should take no arguments, and return a value from the \ref StreamCallback_Return_ErrorCodes_t enum. + * + * @{ + */ + +#ifndef __STREAMCALLBACK_H__ +#define __STREAMCALLBACK_H__ + + /* Includes: */ + #include + + /* 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: */ + /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream + * call has no callback function to be called between USB packets. + */ + #define NO_STREAM_CALLBACK NULL + + /* Enums: */ + /** Enum for the possible error return codes of a stream callback function. */ + enum StreamCallback_Return_ErrorCodes_t + { + STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */ + STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */ + }; + + /* Type Defines: */ + /** Type define for a Stream Callback function (function taking no arguments and retuning a + * uint8_t value). Stream callback functions should have an identical function signature if they + * are to be used as the callback parameter of the stream functions. + */ + typedef uint8_t (* const StreamCallbackPtr_t)(void); + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_R.c b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_R.c new file mode 100644 index 0000000..893a390 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_R.c @@ -0,0 +1,48 @@ +uint8_t TEMPLATE_FUNC_NAME (void* 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); + 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_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE diff --git a/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_W.c b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_W.c new file mode 100644 index 0000000..1bc550f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_Control_W.c @@ -0,0 +1,56 @@ +uint8_t TEMPLATE_FUNC_NAME (const void* 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_ControlEndpointSize)) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + Length--; + BytesInEndpoint++; + } + + LastPacketFull = (BytesInEndpoint == USB_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_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE diff --git a/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_RW.c b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_RW.c new file mode 100644 index 0000000..a1a1e4b --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Endpoint_RW.c @@ -0,0 +1,79 @@ +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer, + uint16_t Length + __CALLBACK_PARAM) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_ENDPOINT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + TEMPLATE_TRANSFER_BYTE(DataStream); + case 7: TEMPLATE_TRANSFER_BYTE(DataStream); + case 6: TEMPLATE_TRANSFER_BYTE(DataStream); + case 5: TEMPLATE_TRANSFER_BYTE(DataStream); + case 4: TEMPLATE_TRANSFER_BYTE(DataStream); + case 3: TEMPLATE_TRANSFER_BYTE(DataStream); + case 2: TEMPLATE_TRANSFER_BYTE(DataStream); + case 1: TEMPLATE_TRANSFER_BYTE(DataStream); + } while (Length >= 8); + } + } + #endif + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_ENDPOINT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + Length--; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_ENDPOINT +#undef TEMPLATE_BUFFER_OFFSET diff --git a/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Pipe_RW.c b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Pipe_RW.c new file mode 100644 index 0000000..3f8d91f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/Template/Template_Pipe_RW.c @@ -0,0 +1,83 @@ +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer, + uint16_t Length + __CALLBACK_PARAM) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint8_t ErrorCode; + + Pipe_SetPipeToken(TEMPLATE_TOKEN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Pipe_BytesInPipe() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Pipe_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_PIPE(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return PIPE_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + TEMPLATE_TRANSFER_BYTE(DataStream); + case 7: TEMPLATE_TRANSFER_BYTE(DataStream); + case 6: TEMPLATE_TRANSFER_BYTE(DataStream); + case 5: TEMPLATE_TRANSFER_BYTE(DataStream); + case 4: TEMPLATE_TRANSFER_BYTE(DataStream); + case 3: TEMPLATE_TRANSFER_BYTE(DataStream); + case 2: TEMPLATE_TRANSFER_BYTE(DataStream); + case 1: TEMPLATE_TRANSFER_BYTE(DataStream); + } while (Length >= 8); + } + } + #endif + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_PIPE(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return PIPE_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + Length--; + } + } + + 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 + diff --git a/firmware/LUFA/Drivers/USB/HighLevel/USBMode.h b/firmware/LUFA/Drivers/USB/HighLevel/USBMode.h new file mode 100644 index 0000000..09d3631 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/USBMode.h @@ -0,0 +1,138 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 capability macros. + * + * 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. + * + * \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 + * + * 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__ + + /* 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 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 USB controller + * (i.e. ATMEGAxxU4) when defined. + */ + #define USB_SERIES_4_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 6 USB controller + * (i.e. AT90USBxxx6) when defined. + */ + #define USB_SERIES_6_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 7 USB controller + * (i.e. AT90USBxxx7) when defined. + */ + #define USB_SERIES_7_AVR + + /** Indicates that the target AVR 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 AVR 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 AVR 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 + #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)) + #define USB_SERIES_4_AVR + #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) + #define USB_SERIES_6_AVR + #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) + #define USB_SERIES_7_AVR + #endif + + #if !defined(USB_SERIES_7_AVR) + #if defined(USB_HOST_ONLY) + #error USB_HOST_ONLY is not available for the currently selected USB AVR model. + #endif + + #if !defined(USB_DEVICE_ONLY) + #define USB_DEVICE_ONLY + #endif + #endif + + #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY)) + #define USB_CAN_BE_BOTH + #define USB_CAN_BE_HOST + #define USB_CAN_BE_DEVICE + #elif defined(USB_HOST_ONLY) + #define USB_CAN_BE_HOST + #elif defined(USB_DEVICE_ONLY) + #define USB_CAN_BE_DEVICE + #endif + + #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY)) + #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive. + #endif + #endif + +#endif + +/** @} */ diff --git a/firmware/LUFA/Drivers/USB/HighLevel/USBTask.c b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.c new file mode 100644 index 0000000..6967283 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.c @@ -0,0 +1,89 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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(); + else if (USB_CurrentMode == USB_MODE_Host) + USB_HostTask(); + #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/firmware/LUFA/Drivers/USB/HighLevel/USBTask.h b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.h new file mode 100644 index 0000000..0af39bf --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.h @@ -0,0 +1,206 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 + #include + #include + + #include "../LowLevel/USBController.h" + #include "Events.h" + #include "StdRequestType.h" + #include "StdDescriptors.h" + #include "USBMode.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(). + * + * \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 may be altered by the user application to implement the \ref HOST_STATE_Addressed, + * \ref HOST_STATE_Configured and \ref HOST_STATE_Suspended states which are not implemented by + * the library internally. + * + * To reduce program size and speed up checks of this global, it can be placed into one of the AVR's + * GPIOR hardware registers instead of RAM by defining the 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, it can be placed into one of the AVR's + * GPIOR hardware registers instead of RAM by defining the 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/firmware/LUFA/Drivers/USB/HighLevel/USBTask.lst b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.lst new file mode 100644 index 0000000..4881054 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.lst @@ -0,0 +1,88 @@ + 1 .file "USBTask.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_USBTask,"ax",@progbits + 17 .global USB_USBTask + 19 USB_USBTask: + 20 .LFB68: + 21 .LSM0: + 22 0000 1F93 push r17 + 23 /* prologue: function */ + 24 /* frame size = 0 */ + 25 .LBB22: + 26 .LBB23: + 27 .LSM1: + 28 0002 8091 0000 lds r24,USB_DeviceState + 29 0006 8823 tst r24 + 30 0008 01F0 breq .L4 + 31 .LBB24: + 32 .LBB25: + 33 .LBB26: + 34 .LSM2: + 35 000a 1091 E900 lds r17,233 + 36 .LBE26: + 37 .LBE25: + 38 .LBB28: + 39 .LBB29: + 40 .LSM3: + 41 000e 1092 E900 sts 233,__zero_reg__ + 42 .LBE29: + 43 .LBE28: + 44 .LBB30: + 45 .LBB31: + 46 .LSM4: + 47 0012 8091 E800 lds r24,232 + 48 .LBE31: + 49 .LBE30: + 50 .LSM5: + 51 0016 83FF sbrs r24,3 + 52 0018 00C0 rjmp .L3 + 53 .LSM6: + 54 001a 0E94 0000 call USB_Device_ProcessControlRequest + 55 .L3: + 56 .LBB32: + 57 .LBB27: + 58 .LSM7: + 59 001e 1770 andi r17,lo8(7) + 60 .LBE27: + 61 .LBE32: + 62 .LBB33: + 63 .LBB34: + 64 .LSM8: + 65 0020 1093 E900 sts 233,r17 + 66 .L4: + 67 /* epilogue start */ + 68 .LBE34: + 69 .LBE33: + 70 .LBE24: + 71 .LBE23: + 72 .LBE22: + 73 .LSM9: + 74 0024 1F91 pop r17 + 75 0026 0895 ret + 76 .LFE68: + 78 .comm USB_IsInitialized,1,1 + 79 .comm USB_ControlRequest,8,1 + 80 .comm USB_DeviceState,1,1 + 105 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 USBTask.c + /tmp/ccROWpPW.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccROWpPW.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccROWpPW.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccROWpPW.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccROWpPW.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccROWpPW.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccROWpPW.s:19 .text.USB_USBTask:0000000000000000 USB_USBTask + *COM*:0000000000000001 USB_DeviceState + *COM*:0000000000000001 USB_IsInitialized + *COM*:0000000000000008 USB_ControlRequest + +UNDEFINED SYMBOLS +USB_Device_ProcessControlRequest +__do_clear_bss diff --git a/firmware/LUFA/Drivers/USB/HighLevel/USBTask.o b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.o new file mode 100644 index 0000000..1db7f83 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/HighLevel/USBTask.o differ diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Device.c b/firmware/LUFA/Drivers/USB/LowLevel/Device.c new file mode 100644 index 0000000..917fc19 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Device.c @@ -0,0 +1,53 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../HighLevel/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/firmware/LUFA/Drivers/USB/LowLevel/Device.h b/firmware/LUFA/Drivers/USB/LowLevel/Device.h new file mode 100644 index 0000000..631c883 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Device.h @@ -0,0 +1,247 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 mode definitions. + * + * This file contains structures, function prototypes and macros related to 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. + */ + +/** \ingroup Group_USB + * @defgroup Group_Device Device Management + * + * USB Device mode related macros and enums. This module contains macros and enums which are used when + * the USB controller is initialized in device mode. + * + * @{ + */ + +#ifndef __USBDEVICE_H__ +#define __USBDEVICE_H__ + + /* Includes: */ + #include + #include + #include + + #include "../../../Common/Common.h" + #include "../HighLevel/StdDescriptors.h" + #include "USBInterrupt.h" + #include "Endpoint.h" + + /* Preprocessor Checks: */ + #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #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 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) + //@} + + /* 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_RemoteWakeupEnabled flag is set). When the 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_Descriptors for more information on the RMWAKEUP feature and device descriptors. + */ + void USB_Device_SendRemoteWakeup(void); + + /* Type Defines: */ + 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. + */ + }; + + /* 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. + */ + 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 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 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 + + /* 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 wValue type indicates 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 USE_*_DESCRIPTORS compile time options is used. + * + * \note By default, the library expects all descriptors to be located in flash memory via the 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 USE_RAM_DESCRIPTORS or the + * 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(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); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Inline Functions: */ + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + 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) + { + UDADDR = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F)); + UDADDR |= (1 << ADDEN); + } + + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE; + static inline bool USB_Device_IsAddressSet(void) + { + return (UDADDR & (1 << ADDEN)); + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Device.lst b/firmware/LUFA/Drivers/USB/LowLevel/Device.lst new file mode 100644 index 0000000..58529ac --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Device.lst @@ -0,0 +1,64 @@ + 1 .file "Device.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_Device_SendRemoteWakeup,"ax",@progbits + 17 .global USB_Device_SendRemoteWakeup + 19 USB_Device_SendRemoteWakeup: + 20 .LFB68: + 21 .LSM0: + 22 /* prologue: function */ + 23 /* frame size = 0 */ + 24 .LBB8: + 25 .LBB9: + 26 .LSM1: + 27 0000 84E0 ldi r24,lo8(4) + 28 0002 89BD out 73-32,r24 + 29 .LSM2: + 30 0004 89B5 in r24,73-32 + 31 0006 8260 ori r24,lo8(2) + 32 0008 89BD out 73-32,r24 + 33 .L2: + 34 .LBE9: + 35 .LBE8: + 36 .LSM3: + 37 000a 09B4 in __tmp_reg__,73-32 + 38 000c 00FE sbrs __tmp_reg__,0 + 39 000e 00C0 rjmp .L2 + 40 .LBB10: + 41 .LBB11: + 42 .LSM4: + 43 0010 8091 D800 lds r24,216 + 44 0014 8F7D andi r24,lo8(-33) + 45 0016 8093 D800 sts 216,r24 + 46 .LBE11: + 47 .LBE10: + 48 .LSM5: + 49 001a 8091 E000 lds r24,224 + 50 001e 8260 ori r24,lo8(2) + 51 0020 8093 E000 sts 224,r24 + 52 .L3: + 53 .LSM6: + 54 0024 8091 E000 lds r24,224 + 55 0028 81FF sbrs r24,1 + 56 002a 00C0 rjmp .L3 + 57 /* epilogue start */ + 58 .LSM7: + 59 002c 0895 ret + 60 .LFE68: + 86 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Device.c + /tmp/ccs5tzLN.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccs5tzLN.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccs5tzLN.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccs5tzLN.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccs5tzLN.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccs5tzLN.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccs5tzLN.s:19 .text.USB_Device_SendRemoteWakeup:0000000000000000 USB_Device_SendRemoteWakeup + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Device.o b/firmware/LUFA/Drivers/USB/LowLevel/Device.o new file mode 100644 index 0000000..acfaa56 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/LowLevel/Device.o differ diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.c b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.c new file mode 100644 index 0000000..6fb842b --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -0,0 +1,141 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../HighLevel/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "Endpoint.h" + +#if !defined(FIXED_CONTROL_ENDPOINT_SIZE) +uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; +#endif + +bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, + const uint8_t UECFG0XData, + const uint8_t UECFG1XData) +{ + Endpoint_SelectEndpoint(Number); + Endpoint_EnableEndpoint(); + + UECFG1X = 0; + UECFG0X = UECFG0XData; + UECFG1X = UECFG1XData; + + return Endpoint_IsConfigured(); +} + +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/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.h b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.h new file mode 100644 index 0000000..88856d8 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.h @@ -0,0 +1,892 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 endpoint management definitions. + * + * This file contains structures, function prototypes and macros related to the management of the device's + * data endpoints when the library is initialized 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. + */ + +/** \ingroup Group_EndpointManagement + * @defgroup Group_EndpointRW Endpoint Data Reading and Writing + * + * 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 + * + * 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 + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_USB + * @defgroup Group_EndpointManagement Endpoint Management + * + * 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 + #include + + #include "../../../Common/Common.h" + #include "../HighLevel/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, 2 + #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, 2 + #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 Direction Masks */ + //@{ + /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint + * should be initialized in the OUT direction - i.e. data flows from host to device. + */ + #define ENDPOINT_DIR_OUT (0 << EPDIR) + + /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint + * should be initialized in the IN direction - i.e. data flows from device to host. + */ + #define ENDPOINT_DIR_IN (1 << EPDIR) + //@} + + /** \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) + //@} + + /** 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 + + #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 FIXED_CONTROL_ENDPOINT_SIZE token is defined. + */ + #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 + #endif + + /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's + * numerical address in the device. + */ + #define ENDPOINT_EPNUM_MASK 0x07 + + /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's + * direction for comparing with the ENDPOINT_DESCRIPTOR_DIR_* masks. + */ + #define ENDPOINT_EPDIR_MASK 0x80 + + /** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's + * bank size in the device. + */ + #define ENDPOINT_EPSIZE_MASK 0x7F + + /** Maximum size in bytes of a given endpoint. + * + * \param[in] EPIndex Endpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1) + */ + #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex) + + /** Indicates the total number of banks supported by the given endpoint. + * + * \param[in] EPIndex Endpoint number, a value between 0 and (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 + */ + 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 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 ENDPOINT_BANK_* mask. + * More banks uses more USB DPRAM, but offers better performance. Isochronous type + * endpoints must have at least two banks. + * + * \note Endpoints must be configured in ascending order, or bank corruption will occur. + * \n\n + * + * \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's + * index - refer to the chosen USB AVR'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 true if the configuration succeeded, 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 << 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 + * + * \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 + * 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_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetFIFO(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 True if the currently selected endpoint is enabled, 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); + } + + /** 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 + */ + static inline void Endpoint_AbortPendingIN(void) + { + while (UESTA0X & (0x03 << NBUSYBK0)) + { + UEINTX |= (1 << RXOUTI); + while (UEINTX & (1 << RXOUTI)); + } + } + + /** 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 + * + * \return Total number of busy banks in the selected endpoint. + */ + static inline uint8_t Endpoint_GetBusyBanks(void) + { + return (UESTA0X & (0x03 << NBUSYBK0)); + } + + /** 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 + * + * \return Boolean 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 true if the currently selected endpoint has been configured, 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 true if the specified endpoint has interrupted, 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 ((UEINT & (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 + * + * \return Boolean true if the current endpoint is ready for an IN packet, 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 + * + * \return Boolean true if current endpoint is has received an OUT packet, 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 + * + * \return Boolean true if the selected endpoint has received a SETUP packet, 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 + * + * \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 + */ + 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 + */ + 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 + */ + 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 + */ + 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 + * + * \return Boolean true if the currently selected endpoint is stalled, 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 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 & ENDPOINT_DIR_IN); + } + + /** Sets the direction of the currently selected endpoint. + * + * \param[in] DirectionMask New endpoint direction, as a 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 & ~ENDPOINT_DIR_IN) | DirectionMask); + } + + /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \return Next byte in the currently selected endpoint's FIFO buffer. + */ + static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_Read_Byte(void) + { + return UEDATX; + } + + /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \param[in] Byte Next byte to write into the the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_Byte(const uint8_t Byte) + { + UEDATX = Byte; + } + + /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + */ + static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_Byte(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + } + + /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \return Next word in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_Word_LE(void) + { + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; + + return Data.Word; + } + + /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \return Next word in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_Word_BE(void) + { + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; + + return Data.Word; + } + + /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_Word_LE(const uint16_t Word) + { + UEDATX = (Word & 0xFF); + UEDATX = (Word >> 8); + } + + /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_Word_BE(const uint16_t Word) + { + UEDATX = (Word >> 8); + UEDATX = (Word & 0xFF); + } + + /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + */ + static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_Word(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + Dummy = UEDATX; + } + + /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \return Next double word in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_DWord_LE(void) + { + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[2] = UEDATX; + Data.Bytes[3] = UEDATX; + + return Data.DWord; + } + + /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \return Next double word in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_DWord_BE(void) + { + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[3] = UEDATX; + Data.Bytes[2] = UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; + + return Data.DWord; + } + + /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) + { + UEDATX = (DWord & 0xFF); + UEDATX = (DWord >> 8); + UEDATX = (DWord >> 16); + UEDATX = (DWord >> 24); + } + + /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + * + * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) + { + UEDATX = (DWord >> 24); + UEDATX = (DWord >> 16); + UEDATX = (DWord >> 8); + UEDATX = (DWord & 0xFF); + } + + /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW + */ + static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_DWord(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + Dummy = UEDATX; + Dummy = UEDATX; + Dummy = UEDATX; + } + + /* 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 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 + * FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the FIXED_CONTROL_ENDPOINT_SIZE token + * be used in the 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_ControlEndpointSize; + #else + #define USB_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 + * + * \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/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.lst b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.lst new file mode 100644 index 0000000..4072e12 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.lst @@ -0,0 +1,283 @@ + 1 .file "Endpoint.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.Endpoint_ConfigureEndpoint_Prv,"ax",@progbits + 17 .global Endpoint_ConfigureEndpoint_Prv + 19 Endpoint_ConfigureEndpoint_Prv: + 20 .LFB68: + 21 .LSM0: + 22 .LVL0: + 23 /* prologue: function */ + 24 /* frame size = 0 */ + 25 .LBB34: + 26 .LBB35: + 27 .LSM1: + 28 0000 8093 E900 sts 233,r24 + 29 .LBE35: + 30 .LBE34: + 31 .LBB36: + 32 .LBB37: + 33 .LSM2: + 34 0004 8091 EB00 lds r24,235 + 35 .LVL1: + 36 0008 8160 ori r24,lo8(1) + 37 000a 8093 EB00 sts 235,r24 + 38 .LBE37: + 39 .LBE36: + 40 .LSM3: + 41 000e 1092 ED00 sts 237,__zero_reg__ + 42 .LSM4: + 43 0012 6093 EC00 sts 236,r22 + 44 .LSM5: + 45 0016 4093 ED00 sts 237,r20 + 46 .LBB38: + 47 .LBB39: + 48 .LSM6: + 49 001a 8091 EE00 lds r24,238 + 50 .LBE39: + 51 .LBE38: + 52 .LSM7: + 53 001e 881F rol r24 + 54 0020 8827 clr r24 + 55 0022 881F rol r24 + 56 /* epilogue start */ + 57 0024 0895 ret + 58 .LFE68: + 60 .section .text.Endpoint_ClearEndpoints,"ax",@progbits + 61 .global Endpoint_ClearEndpoints + 63 Endpoint_ClearEndpoints: + 64 .LFB69: + 65 .LSM8: + 66 /* prologue: function */ + 67 /* frame size = 0 */ + 68 .LSM9: + 69 0000 1092 F400 sts 244,__zero_reg__ + 70 0004 90E0 ldi r25,lo8(0) + 71 .LVL2: + 72 .L5: + 73 .LBB40: + 74 .LBB41: + 75 .LBB42: + 76 .LSM10: + 77 0006 9093 E900 sts 233,r25 + 78 .LBE42: + 79 .LBE41: + 80 .LSM11: + 81 000a 1092 F000 sts 240,__zero_reg__ + 82 .LSM12: + 83 000e 1092 E800 sts 232,__zero_reg__ + 84 .LSM13: + 85 0012 1092 ED00 sts 237,__zero_reg__ + 86 .LBB43: + 87 .LBB44: + 88 .LSM14: + 89 0016 8091 EB00 lds r24,235 + 90 001a 8E7F andi r24,lo8(-2) + 91 001c 8093 EB00 sts 235,r24 + 92 .LBE44: + 93 .LBE43: + 94 .LSM15: + 95 0020 9F5F subi r25,lo8(-(1)) + 96 0022 9530 cpi r25,lo8(5) + 97 0024 01F4 brne .L5 + 98 /* epilogue start */ + 99 .LBE40: + 100 .LSM16: + 101 0026 0895 ret + 102 .LFE69: + 104 .section .text.Endpoint_ClearStatusStage,"ax",@progbits + 105 .global Endpoint_ClearStatusStage + 107 Endpoint_ClearStatusStage: + 108 .LFB70: + 109 .LSM17: + 110 /* prologue: function */ + 111 /* frame size = 0 */ + 112 .LSM18: + 113 0000 8091 0000 lds r24,USB_ControlRequest + 114 0004 8823 tst r24 + 115 0006 04F4 brge .L16 + 116 0008 00C0 rjmp .L15 + 117 .L12: + 118 .LSM19: + 119 000a 8091 0000 lds r24,USB_DeviceState + 120 000e 8823 tst r24 + 121 0010 01F0 breq .L14 + 122 .L15: + 123 .LBB45: + 124 .LBB46: + 125 .LSM20: + 126 0012 8091 E800 lds r24,232 + 127 .LBE46: + 128 .LBE45: + 129 .LSM21: + 130 0016 82FF sbrs r24,2 + 131 0018 00C0 rjmp .L12 + 132 .LBB47: + 133 .LBB48: + 134 .LSM22: + 135 001a 8091 E800 lds r24,232 + 136 001e 8B77 andi r24,lo8(123) + 137 0020 8093 E800 sts 232,r24 + 138 0024 0895 ret + 139 .L13: + 140 .LBE48: + 141 .LBE47: + 142 .LSM23: + 143 0026 8091 0000 lds r24,USB_DeviceState + 144 002a 8823 tst r24 + 145 002c 01F0 breq .L14 + 146 .L16: + 147 .LBB49: + 148 .LBB50: + 149 .LSM24: + 150 002e 8091 E800 lds r24,232 + 151 .LBE50: + 152 .LBE49: + 153 .LSM25: + 154 0032 80FF sbrs r24,0 + 155 0034 00C0 rjmp .L13 + 156 .LBB51: + 157 .LBB52: + 158 .LSM26: + 159 0036 8091 E800 lds r24,232 + 160 003a 8E77 andi r24,lo8(126) + 161 003c 8093 E800 sts 232,r24 + 162 .L14: + 163 0040 0895 ret + 164 .LBE52: + 165 .LBE51: + 166 .LFE70: + 168 .section .text.Endpoint_WaitUntilReady,"ax",@progbits + 169 .global Endpoint_WaitUntilReady + 171 Endpoint_WaitUntilReady: + 172 .LFB71: + 173 .LSM27: + 174 /* prologue: function */ + 175 /* frame size = 0 */ + 176 .LBB53: + 177 .LBB54: + 178 .LSM28: + 179 0000 4091 E400 lds r20,228 + 180 0004 5091 E500 lds r21,(228)+1 + 181 .LVL3: + 182 0008 24E6 ldi r18,lo8(100) + 183 .LVL4: + 184 .L30: + 185 .LBE54: + 186 .LBE53: + 187 .LBB55: + 188 .LBB56: + 189 .LBB57: + 190 .LSM29: + 191 000a 8091 EC00 lds r24,236 + 192 .LVL5: + 193 .LBE57: + 194 .LBE56: + 195 .LSM30: + 196 000e 80FF sbrs r24,0 + 197 0010 00C0 rjmp .L18 + 198 .LBB58: + 199 .LBB59: + 200 .LSM31: + 201 0012 8091 E800 lds r24,232 + 202 .LBE59: + 203 .LBE58: + 204 .LSM32: + 205 0016 80FF sbrs r24,0 + 206 0018 00C0 rjmp .L20 + 207 001a 00C0 rjmp .L19 + 208 .L18: + 209 .LBB60: + 210 .LBB61: + 211 .LSM33: + 212 001c 8091 E800 lds r24,232 + 213 .LBE61: + 214 .LBE60: + 215 .LSM34: + 216 0020 82FD sbrc r24,2 + 217 0022 00C0 rjmp .L19 + 218 .L20: + 219 .LSM35: + 220 0024 8091 0000 lds r24,USB_DeviceState + 221 .LVL6: + 222 .LSM36: + 223 0028 8823 tst r24 + 224 002a 01F4 brne .L21 + 225 002c 82E0 ldi r24,lo8(2) + 226 .LVL7: + 227 002e 0895 ret + 228 .LVL8: + 229 .L21: + 230 .LSM37: + 231 0030 8530 cpi r24,lo8(5) + 232 0032 01F4 brne .L23 + 233 0034 83E0 ldi r24,lo8(3) + 234 .LVL9: + 235 0036 0895 ret + 236 .LVL10: + 237 .L23: + 238 .LBB62: + 239 .LBB63: + 240 .LSM38: + 241 0038 8091 EB00 lds r24,235 + 242 .LVL11: + 243 .LBE63: + 244 .LBE62: + 245 .LSM39: + 246 003c 85FF sbrs r24,5 + 247 003e 00C0 rjmp .L24 + 248 0040 81E0 ldi r24,lo8(1) + 249 0042 0895 ret + 250 .L24: + 251 .LBB64: + 252 .LBB65: + 253 .LSM40: + 254 0044 8091 E400 lds r24,228 + 255 0048 9091 E500 lds r25,(228)+1 + 256 .LVL12: + 257 .LBE65: + 258 .LBE64: + 259 .LSM41: + 260 004c 8417 cp r24,r20 + 261 004e 9507 cpc r25,r21 + 262 0050 01F0 breq .L30 + 263 .LSM42: + 264 0052 2223 tst r18 + 265 0054 01F4 brne .L26 + 266 0056 84E0 ldi r24,lo8(4) + 267 .LVL13: + 268 0058 0895 ret + 269 .LVL14: + 270 .L26: + 271 005a 2150 subi r18,lo8(-(-1)) + 272 005c AC01 movw r20,r24 + 273 005e 00C0 rjmp .L30 + 274 .LVL15: + 275 .L19: + 276 0060 80E0 ldi r24,lo8(0) + 277 .LBE55: + 278 .LSM43: + 279 0062 0895 ret + 280 .LFE71: + 330 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Endpoint.c + /tmp/ccC3I4DX.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccC3I4DX.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccC3I4DX.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccC3I4DX.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccC3I4DX.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccC3I4DX.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccC3I4DX.s:19 .text.Endpoint_ConfigureEndpoint_Prv:0000000000000000 Endpoint_ConfigureEndpoint_Prv + /tmp/ccC3I4DX.s:63 .text.Endpoint_ClearEndpoints:0000000000000000 Endpoint_ClearEndpoints + /tmp/ccC3I4DX.s:107 .text.Endpoint_ClearStatusStage:0000000000000000 Endpoint_ClearStatusStage + /tmp/ccC3I4DX.s:171 .text.Endpoint_WaitUntilReady:0000000000000000 Endpoint_WaitUntilReady + +UNDEFINED SYMBOLS +USB_ControlRequest +USB_DeviceState diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.o b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.o new file mode 100644 index 0000000..e669870 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/LowLevel/Endpoint.o differ diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Host.c b/firmware/LUFA/Drivers/USB/LowLevel/Host.c new file mode 100644 index 0000000..7f76a1c --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Host.c @@ -0,0 +1,355 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../HighLevel/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(); + + 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_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_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); + + EVENT_USB_Host_DeviceEnumerationComplete(); + USB_HostState = HOST_STATE_Addressed; + 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() == true) + { + Pipe_ClearError(); + ErrorCode = HOST_WAITERROR_PipeError; + + break; + } + + if (Pipe_IsStalled() == true) + { + 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(); + + 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); +} + +uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) +{ + 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); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetDescriptor, + .wValue = (DTYPE_Device << 8), + .wIndex = 0, + .wLength = sizeof(USB_Descriptor_Device_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(DeviceDescriptorPtr); +} + +uint8_t USB_Host_GetDeviceStringDescriptor(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 = (DTYPE_String << 8) | Index, + .wIndex = 0, + .wLength = BufferLength, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Buffer); +} + +uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT), + .bRequest = REQ_ClearFeature, + .wValue = FEATURE_SEL_EndpointHalt, + .wIndex = EndpointNum, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +#endif + diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Host.h b/firmware/LUFA/Drivers/USB/LowLevel/Host.h new file mode 100644 index 0000000..dce3a95 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Host.h @@ -0,0 +1,527 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 mode definitions. + * + * This file contains structures, function prototypes and macros related to 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. + */ + +/** \ingroup Group_USB + * @defgroup Group_Host Host Management + * + * 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 + #include + #include + + #include "../../../Common/Common.h" + #include "../HighLevel/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 + + /* 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(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 + + #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 definining the + * HOST_DEVICE_SETTLE_DELAY_MS token to tbe required delay in milliseconds, and passed to the + * compiler using the -D switch. + */ + #define HOST_DEVICE_SETTLE_DELAY_MS 1000 + #endif + + /* Enums: */ + /** Enum for the various states of the USB Host 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 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_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be + * used by the library to wait until the attached device is + * removed by the user - useful for when an error occurs or + * further communication with the device is not needed. This + * allows for other code to run while the state machine is + * effectively disabled. + */ + HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates + * that the stack is waiting for an interval to elapse before + * continuing with the next step of the device enumeration + * process. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates + * that the host state machine is waiting for a device to be + * attached so that it can start the enumeration process. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates + * that a device has been attached, and the library's internals + * are being configured to begin the enumeration process. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates + * that the stack is waiting for the initial settling period to + * elapse before beginning the enumeration process. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. 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. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates + * that a valid USB device has been attached, and that it is + * will now be reset to ensure it is ready for enumeration. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates + * that the attached device is currently powered and reset, and + * that the control pipe is now being configured by the stack. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Default = 8, /**< Internally implemented by the library. 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. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. 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. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. 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 user-implemented + * \ref HOST_STATE_Addressed state for further communications. + * + * \note Do not manually change to this state in the user code. + */ + HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should + * set the device configuration before progressing to the + * \ref HOST_STATE_Configured state. Other processing (such as the + * retrieval and processing of the device descriptor) should also + * be placed in this state. + */ + HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the + * actual work performed on the attached device and changed to the + * \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed. + */ + HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained + * while the bus is suspended, and changed to either the \ref HOST_STATE_Configured + * (after resuming the bus with the USB_Host_ResumeBus() macro) or the + * \ref HOST_STATE_WaitForDeviceRemoval states as needed. + */ + }; + + /** 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. + */ + 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 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 true if no bus reset is currently being sent, 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. + */ + 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 true if the bus is currently suspended, 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 true if the attached device is enumerated in Full Speed mode, 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 true if the attached device has sent a Remote Wakeup request, 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 true if no resume request is currently being sent, 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); + } + + /* Function Prototypes: */ + /** Convenience function. This routine sends a SetConfiguration standard request to the attached + * device, with the given configuration index. This can be used to easily set the device + * configuration without creating and sending the request manually. + * + * \note After this routine returns, the control pipe will be selected. + * + * \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); + + /** Convenience function. This routine sends a GetDescriptor 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. + * + * \note After this routine returns, the control pipe will be selected. + * + * \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. + */ + uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr); + + /** Convenience function. This routine sends a GetDescriptor 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. + * + * \note After this routine returns, the control pipe will be selected. + * + * \param[in] Index Index of the string index 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_GetDeviceStringDescriptor(const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength); + + /** Clears a stall condition on the given pipe, via a ClearFeature request to the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \param[in] EndpointIndex Index 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_ClearPipeStall(const uint8_t EndpointIndex); + + /* 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) + { + PORTE |= (1 << 7); + } + + 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) + { + PORTE &= ~(1 << 7); + } + + 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/firmware/LUFA/Drivers/USB/LowLevel/Host.lst b/firmware/LUFA/Drivers/USB/LowLevel/Host.lst new file mode 100644 index 0000000..06eeba6 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Host.lst @@ -0,0 +1,19 @@ + 1 .file "Host.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Host.c + /tmp/ccLGscsA.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccLGscsA.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccLGscsA.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccLGscsA.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccLGscsA.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccLGscsA.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Host.o b/firmware/LUFA/Drivers/USB/LowLevel/Host.o new file mode 100644 index 0000000..740d45f Binary files /dev/null and b/firmware/LUFA/Drivers/USB/LowLevel/Host.o differ diff --git a/firmware/LUFA/Drivers/USB/LowLevel/OTG.h b/firmware/LUFA/Drivers/USB/LowLevel/OTG.h new file mode 100644 index 0000000..d213552 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/OTG.h @@ -0,0 +1,155 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 mode definitions. + * + * This file contains structures, function prototypes and macros related to USB OTG mode, where two USB devices + * may be linked directly together and exchange host/device roles as needed. + * + * \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 + * + * 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 + #include + + #include "../../../Common/Common.h" + + /* 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 true if currently sending a HNP to the other connected device, false otherwise + */ + static inline bool USB_OTG_Device_IsSendingHNP(void) 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 not currently sending a HNP request. + * + * \return Boolean true if a HNP is currently being issued by the connected device, 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); + } + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Pipe.c b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.c new file mode 100644 index 0000000..c414129 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -0,0 +1,140 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 "../HighLevel/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "Pipe.h" + +uint8_t USB_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) +{ + 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(); +} + +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; + + uint8_t PipeToken = Pipe_GetPipeToken(); + bool PipeTokenCorrect = true; + + if (PipeToken != PIPE_TOKEN_SETUP) + PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT)); + + if (PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK))) + 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/firmware/LUFA/Drivers/USB/LowLevel/Pipe.h b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.h new file mode 100644 index 0000000..7bdb508 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -0,0 +1,941 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 pipe management definitions. + * + * This file contains structures, function prototypes and macros related to the management of the device's + * data pipes when the library is initialized 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. + */ + +/** \ingroup Group_PipeManagement + * @defgroup Group_PipeRW Pipe Data Reading and Writing + * + * 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 + * + * 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 + * + * Functions, macros, variables, enums and types related to packet management of pipes. + */ + +/** \ingroup Group_PipeManagement + * @defgroup Group_PipeControlReq Pipe Control Request Management + * + * 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 + * + * 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 + #include + + #include "../../../Common/Common.h" + #include "../HighLevel/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) + //@} + + /** 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 + + /** 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 + + /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address + * in the device. + */ + #define PIPE_PIPENUM_MASK 0x07 + + /** 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 + + /** 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 ENDPOINT_DESCRIPTOR_DIR_* masks. + */ + #define PIPE_EPDIR_MASK 0x80 + + /* Enums: */ + /** Enum for the possible error return codes of the Pipe_WaitUntilReady function. + * + * \ingroup Group_PipeRW + */ + 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 + * + * \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 True if the currently selected pipe is enabled, 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 PIPE_TOKEN_* mask. + */ + static inline uint8_t Pipe_GetPipeToken(void) 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 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 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 true if the selected pipe is configured, 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 number of the endpoint within the attached device that the currently selected + * pipe is bound to. + * + * \return Endpoint number the currently selected pipe is bound to. + */ + static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_BoundEndpointNumber(void) + { + return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK); + } + + /** 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 true if the specified pipe has interrupted, 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 true if the currently selected pipe is frozen, 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 master pipe error flag. */ + static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearError(void) + { + 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 true if an error has occurred on the selected pipe, 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); + } + + /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error + * flag for the pipe. + */ + static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearErrorFlags(void) + { + UPERRX = 0; + } + + /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This + * value can then be masked against the PIPE_ERRORFLAG_* masks to determine what error has occurred. + * + * \return Mask comprising of 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 + * + * \return Total number of busy banks in the selected pipe. + */ + 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 + * + * \return Boolean 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 + * + * \return Boolean true if the current pipe has received an IN packet, 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 + * + * \return Boolean true if the current pipe is ready for an OUT packet, 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 + * + * \return Boolean true if the current pipe is ready for a SETUP packet, 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 + */ + 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 + */ + 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 + */ + 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 + * + * \return Boolean true if an NAK has been received on the current pipe, 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 + * + * \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 + * + * \return Boolean true if the current pipe has been stalled by the attached device, 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 + */ + 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 + * + * \return Next byte in the currently selected pipe's FIFO buffer. + */ + static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_Read_Byte(void) + { + return UPDATX; + } + + /** Writes one byte from the currently selected pipe's bank, for IN direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \param[in] Byte Next byte to write into the the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_Byte(const uint8_t Byte) + { + UPDATX = Byte; + } + + /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW + */ + static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_Byte(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + } + + /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \return Next word in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_Word_LE(void) + { + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; + + return Data.Word; + } + + /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \return Next word in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_Word_BE(void) + { + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[1] = UPDATX; + Data.Bytes[0] = UPDATX; + + return Data.Word; + } + + /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_Word_LE(const uint16_t Word) + { + UPDATX = (Word & 0xFF); + UPDATX = (Word >> 8); + } + + /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_Word_BE(const uint16_t Word) + { + UPDATX = (Word >> 8); + UPDATX = (Word & 0xFF); + } + + /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW + */ + static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_Word(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + Dummy = UPDATX; + } + + /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \return Next double word in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_DWord_LE(void) + { + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; + Data.Bytes[2] = UPDATX; + Data.Bytes[3] = UPDATX; + + return Data.DWord; + } + + /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \return Next double word in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_DWord_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 + * + * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_DWord_LE(const uint32_t DWord) + { + UPDATX = (DWord & 0xFF); + UPDATX = (DWord >> 8); + UPDATX = (DWord >> 16); + UPDATX = (DWord >> 24); + } + + /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW + * + * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_DWord_BE(const uint32_t DWord) + { + UPDATX = (DWord >> 24); + UPDATX = (DWord >> 16); + UPDATX = (DWord >> 8); + UPDATX = (DWord & 0xFF); + } + + /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW + */ + static inline void Pipe_Discard_DWord(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_DWord(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + Dummy = UPDATX; + Dummy = UPDATX; + Dummy = UPDATX; + } + + /* 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_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, a 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 PIPE_BANK_* mask. More banks + * uses more USB DPRAM, but offers better performance. Isochronous type pipes must + * have at least two banks. + * + * \note Endpoints must be configured in ascending order, or bank corruption will occur. + * \n\n + * + * \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's + * index - refer to the chosen USB AVR'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 true if the configuration succeeded, 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 packed 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 + * + * \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 true if a pipe bound to the given endpoint address of the specified direction is found, false + * otherwise. + */ + bool Pipe_IsEndpointBound(const uint8_t EndpointAddress); + + /* 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/firmware/LUFA/Drivers/USB/LowLevel/Pipe.lst b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.lst new file mode 100644 index 0000000..9fdc61f --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.lst @@ -0,0 +1,19 @@ + 1 .file "Pipe.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 Pipe.c + /tmp/ccJappoz.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccJappoz.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccJappoz.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccJappoz.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccJappoz.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccJappoz.s:7 *ABS*:0000000000000001 __zero_reg__ + +NO UNDEFINED SYMBOLS diff --git a/firmware/LUFA/Drivers/USB/LowLevel/Pipe.o b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.o new file mode 100644 index 0000000..204b8df Binary files /dev/null and b/firmware/LUFA/Drivers/USB/LowLevel/Pipe.o differ diff --git a/firmware/LUFA/Drivers/USB/LowLevel/USBController.c b/firmware/LUFA/Drivers/USB/LowLevel/USBController.c new file mode 100644 index 0000000..b7f6bc7 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/USBController.c @@ -0,0 +1,232 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 defined(USB_CAN_BE_BOTH) + if (Mode == USB_MODE_UID) + { + UHWCON |= (1 << UIDE); + USB_INT_Enable(USB_INT_IDTI); + USB_CurrentMode = USB_GetUSBModeFromUID(); + } + else + { + USB_CurrentMode = Mode; + } + #endif + + USB_IsInitialized = true; + + USB_ResetInterface(); +} + +void USB_ShutDown(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 (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_4_AVR) + PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1)); + #endif + + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + #if defined(USB_CAN_BE_BOTH) + if (UIDModeSelectEnabled) + { + UHWCON |= (1 << UIDE); + 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 + + USB_Init_Device(); + #endif + } + else if (USB_CurrentMode == USB_MODE_Host) + { + #if defined(USB_CAN_BE_HOST) + UHWCON &= ~(1 << UIMOD); + 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_ConfigurationNumber = 0; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + USB_RemoteWakeupEnabled = false; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + USB_CurrentlySelfPowered = false; + #endif + + #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) + USB_Descriptor_Device_t* DeviceDescriptorPtr; + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) + { + #if defined(USE_RAM_DESCRIPTORS) + USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + #elif defined(USE_EEPROM_DESCRIPTORS) + USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #else + USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #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_VBUS); + #endif + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + ENDPOINT_DIR_OUT, USB_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_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/firmware/LUFA/Drivers/USB/LowLevel/USBController.h b/firmware/LUFA/Drivers/USB/LowLevel/USBController.h new file mode 100644 index 0000000..3ac73aa --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/USBController.h @@ -0,0 +1,471 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 low level USB controller definitions. + * + * This file contains structures, function prototypes and macros related to the low level configuration of the + * USB controller, to start, stop and reset the USB library core. + * + * \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 + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_H__ +#define __USBCONTROLLER_H__ + + /* Includes: */ + #include + #include + #include + + #include "../HighLevel/USBMode.h" + + #include "../../../Common/Common.h" + #include "../HighLevel/USBMode.h" + #include "../HighLevel/Events.h" + #include "../HighLevel/USBTask.h" + #include "USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "Host.h" + #include "OTG.h" + #include "Pipe.h" + #include "../HighLevel/HostStandardReq.h" + #include "../HighLevel/PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "Device.h" + #include "Endpoint.h" + #include "../HighLevel/DeviceStandardReq.h" + #include "../HighLevel/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_CLOCK) + #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled input clock in your project makefile. + #endif + + #if (F_CLOCK == 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_CLOCK == 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_CLOCK 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 enabled to regulate the data pin voltages to within the USB standard. + * + * \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 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_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) + //@} + + /** \name Endpoint/Pipe Type Masks */ + //@{ + /** 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 + //@} + + #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__) + /** Returns boolean true if the VBUS line is currently high (i.e. the USB host is supplying power), + * otherwise returns false. + * + * \note This function is not available on some AVR models which do not support hardware VBUS monitoring. + */ + 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 USB_OPT_REG_* mask to control the regulator, a USB_OPT_*_PLL mask to control the + * PLL, and a 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 USB_DEVICE_ONLY + * (for device mode) or 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 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 Device.h for the 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_ShutDown(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 autodetection 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 USB_DEVICE_ONLY or 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 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 |= (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) + { + const uint8_t Temp = USBCON; + + USBCON = (Temp & ~(1 << USBE)); + USBCON = (Temp | (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/firmware/LUFA/Drivers/USB/LowLevel/USBController.lst b/firmware/LUFA/Drivers/USB/LowLevel/USBController.lst new file mode 100644 index 0000000..8adcf06 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/USBController.lst @@ -0,0 +1,204 @@ + 1 .file "USBController.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_ShutDown,"ax",@progbits + 17 .global USB_ShutDown + 19 USB_ShutDown: + 20 .LFB69: + 21 .LSM0: + 22 /* prologue: function */ + 23 /* frame size = 0 */ + 24 .LSM1: + 25 0000 0E94 0000 call USB_INT_DisableAllInterrupts + 26 .LSM2: + 27 0004 0E94 0000 call USB_INT_ClearAllInterrupts + 28 .LBB28: + 29 .LBB29: + 30 .LSM3: + 31 0008 E0EE ldi r30,lo8(224) + 32 000a F0E0 ldi r31,hi8(224) + 33 000c 8081 ld r24,Z + 34 000e 8160 ori r24,lo8(1) + 35 0010 8083 st Z,r24 + 36 .LBE29: + 37 .LBE28: + 38 .LBB30: + 39 .LBB31: + 40 .LSM4: + 41 0012 E8ED ldi r30,lo8(216) + 42 0014 F0E0 ldi r31,hi8(216) + 43 0016 8081 ld r24,Z + 44 0018 8F77 andi r24,lo8(127) + 45 001a 8083 st Z,r24 + 46 .LBE31: + 47 .LBE30: + 48 .LBB32: + 49 .LBB33: + 50 .LSM5: + 51 001c 19BC out 73-32,__zero_reg__ + 52 .LBE33: + 53 .LBE32: + 54 .LBB34: + 55 .LBB35: + 56 .LSM6: + 57 001e E3E6 ldi r30,lo8(99) + 58 0020 F0E0 ldi r31,hi8(99) + 59 0022 8081 ld r24,Z + 60 0024 8160 ori r24,lo8(1) + 61 0026 8083 st Z,r24 + 62 .LBE35: + 63 .LBE34: + 64 .LSM7: + 65 0028 1092 0000 sts USB_IsInitialized,__zero_reg__ + 66 /* epilogue start */ + 67 .LSM8: + 68 002c 0895 ret + 69 .LFE69: + 71 .section .text.USB_ResetInterface,"ax",@progbits + 72 .global USB_ResetInterface + 74 USB_ResetInterface: + 75 .LFB70: + 76 .LSM9: + 77 /* prologue: function */ + 78 /* frame size = 0 */ + 79 .LSM10: + 80 0000 0E94 0000 call USB_INT_DisableAllInterrupts + 81 .LSM11: + 82 0004 0E94 0000 call USB_INT_ClearAllInterrupts + 83 .LBB52: + 84 .LBB53: + 85 .LSM12: + 86 0008 8091 D800 lds r24,216 + 87 .LVL0: + 88 .LSM13: + 89 000c 982F mov r25,r24 + 90 000e 9F77 andi r25,lo8(127) + 91 0010 9093 D800 sts 216,r25 + 92 .LSM14: + 93 0014 8068 ori r24,lo8(-128) + 94 0016 8093 D800 sts 216,r24 + 95 .LBE53: + 96 .LBE52: + 97 .LBB54: + 98 .LBB55: + 99 .LSM15: + 100 001a 84E0 ldi r24,lo8(4) + 101 .LVL1: + 102 001c 89BD out 73-32,r24 + 103 .LSM16: + 104 001e 89B5 in r24,73-32 + 105 0020 8260 ori r24,lo8(2) + 106 0022 89BD out 73-32,r24 + 107 .L4: + 108 .LBE55: + 109 .LBE54: + 110 .LSM17: + 111 0024 09B4 in __tmp_reg__,73-32 + 112 0026 00FE sbrs __tmp_reg__,0 + 113 0028 00C0 rjmp .L4 + 114 .LBB56: + 115 .LBB57: + 116 .LSM18: + 117 002a 8091 D800 lds r24,216 + 118 002e 8F7D andi r24,lo8(-33) + 119 0030 8093 D800 sts 216,r24 + 120 .LBE57: + 121 .LBE56: + 122 .LBB58: + 123 .LBB59: + 124 .LSM19: + 125 0034 1092 0000 sts USB_DeviceState,__zero_reg__ + 126 .LSM20: + 127 0038 1092 0000 sts USB_ConfigurationNumber,__zero_reg__ + 128 .LSM21: + 129 003c 1092 0000 sts USB_RemoteWakeupEnabled,__zero_reg__ + 130 .LSM22: + 131 0040 1092 0000 sts USB_CurrentlySelfPowered,__zero_reg__ + 132 .LBB60: + 133 .LBB61: + 134 .LSM23: + 135 0044 80E0 ldi r24,lo8(0) + 136 0046 60E0 ldi r22,lo8(0) + 137 0048 42E0 ldi r20,lo8(2) + 138 004a 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 139 .LBE61: + 140 .LBE60: + 141 .LSM24: + 142 004e 8091 E100 lds r24,225 + 143 0052 8E7F andi r24,lo8(-2) + 144 0054 8093 E100 sts 225,r24 + 145 .LSM25: + 146 0058 8091 E200 lds r24,226 + 147 005c 8160 ori r24,lo8(1) + 148 005e 8093 E200 sts 226,r24 + 149 .LSM26: + 150 0062 8091 E200 lds r24,226 + 151 0066 8860 ori r24,lo8(8) + 152 0068 8093 E200 sts 226,r24 + 153 .LBB62: + 154 .LBB63: + 155 .LSM27: + 156 006c 8091 E000 lds r24,224 + 157 0070 8E7F andi r24,lo8(-2) + 158 0072 8093 E000 sts 224,r24 + 159 /* epilogue start */ + 160 .LBE63: + 161 .LBE62: + 162 .LBE59: + 163 .LBE58: + 164 .LSM28: + 165 0076 0895 ret + 166 .LFE70: + 168 .section .text.USB_Init,"ax",@progbits + 169 .global USB_Init + 171 USB_Init: + 172 .LFB68: + 173 .LSM29: + 174 /* prologue: function */ + 175 /* frame size = 0 */ + 176 .LBB64: + 177 .LBB65: + 178 .LSM30: + 179 0000 E3E6 ldi r30,lo8(99) + 180 0002 F0E0 ldi r31,hi8(99) + 181 0004 8081 ld r24,Z + 182 0006 8E7F andi r24,lo8(-2) + 183 0008 8083 st Z,r24 + 184 .LBE65: + 185 .LBE64: + 186 .LSM31: + 187 000a 81E0 ldi r24,lo8(1) + 188 000c 8093 0000 sts USB_IsInitialized,r24 + 189 .LSM32: + 190 0010 0E94 0000 call USB_ResetInterface + 191 /* epilogue start */ + 192 .LSM33: + 193 0014 0895 ret + 194 .LFE68: + 236 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 USBController.c + /tmp/ccyRmSJF.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccyRmSJF.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccyRmSJF.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccyRmSJF.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccyRmSJF.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccyRmSJF.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccyRmSJF.s:19 .text.USB_ShutDown:0000000000000000 USB_ShutDown + /tmp/ccyRmSJF.s:74 .text.USB_ResetInterface:0000000000000000 USB_ResetInterface + /tmp/ccyRmSJF.s:171 .text.USB_Init:0000000000000000 USB_Init + +UNDEFINED SYMBOLS +USB_INT_DisableAllInterrupts +USB_INT_ClearAllInterrupts +USB_IsInitialized +USB_DeviceState +USB_ConfigurationNumber +USB_RemoteWakeupEnabled +USB_CurrentlySelfPowered +Endpoint_ConfigureEndpoint_Prv diff --git a/firmware/LUFA/Drivers/USB/LowLevel/USBController.o b/firmware/LUFA/Drivers/USB/LowLevel/USBController.o new file mode 100644 index 0000000..561d66f Binary files /dev/null and b/firmware/LUFA/Drivers/USB/LowLevel/USBController.o differ diff --git a/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.c b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.c new file mode 100644 index 0000000..c3e87e3 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.c @@ -0,0 +1,269 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS)) + { + USB_INT_Clear(USB_INT_VBUS); + + if (USB_VBUS_GetStatus()) + { + USB_DeviceState = DEVICE_STATE_Powered; + EVENT_USB_Device_Connect(); + } + else + { + 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_Clear(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_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_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_ControlEndpointSize, + ENDPOINT_BANK_SINGLE); + + #if defined(INTERRUPT_CONTROL_ENDPOINT) + USB_INT_Enable(USB_INT_RXSTPI); + #endif + + EVENT_USB_Device_Reset(); + } + + #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 + #endif + + #if defined(USB_CAN_BE_HOST) + 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(); + } + + #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 + #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); + + NONATOMIC_BLOCK(NONATOMIC_FORCEOFF) + { + USB_Device_ProcessControlRequest(); + } + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Enable(USB_INT_RXSTPI); + Endpoint_SelectEndpoint(PrevSelectedEndpoint); +} +#endif + diff --git a/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.h b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.h new file mode 100644 index 0000000..5d0c991 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.h @@ -0,0 +1,106 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 + #include + #include + #include + + /* 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 USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE + #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE + #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE + #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false) + #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false) + + #define USB_INT_GET_EN_REG(a, b, c, d) a + #define USB_INT_GET_EN_MASK(a, b, c, d) b + #define USB_INT_GET_INT_REG(a, b, c, d) c + #define USB_INT_GET_INT_MASK(a, b, c, d) d + + #define USB_INT_VBUS USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI) + #define USB_INT_IDTI USBCON, (1 << IDTE) , USBINT, (1 << IDTI) + #define USB_INT_WAKEUPI UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI) + #define USB_INT_SUSPI UDIEN , (1 << SUSPE) , UDINT , (1 << SUSPI) + #define USB_INT_EORSTI UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI) + #define USB_INT_DCONNI UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI) + #define USB_INT_DDISCI UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI) + #define USB_INT_BCERRI OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI) + #define USB_INT_VBERRI OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI) + #define USB_INT_SOFI UDIEN, (1 << SOFE) , UDINT , (1 << SOFI) + #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI) + #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI) + #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI) + #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI) + + /* Includes: */ + #include "../../../Common/Common.h" + #include "../HighLevel/USBMode.h" + #include "../HighLevel/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/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.lst b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.lst new file mode 100644 index 0000000..16c61f0 --- /dev/null +++ b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.lst @@ -0,0 +1,261 @@ + 1 .file "USBInterrupt.c" + 2 __SREG__ = 0x3f + 3 __SP_H__ = 0x3e + 4 __SP_L__ = 0x3d + 5 __CCP__ = 0x34 + 6 __tmp_reg__ = 0 + 7 __zero_reg__ = 1 + 15 .Ltext0: + 16 .section .text.USB_INT_DisableAllInterrupts,"ax",@progbits + 17 .global USB_INT_DisableAllInterrupts + 19 USB_INT_DisableAllInterrupts: + 20 .LFB68: + 21 .LSM0: + 22 /* prologue: function */ + 23 /* frame size = 0 */ + 24 .LSM1: + 25 0000 1092 E200 sts 226,__zero_reg__ + 26 /* epilogue start */ + 27 .LSM2: + 28 0004 0895 ret + 29 .LFE68: + 31 .section .text.USB_INT_ClearAllInterrupts,"ax",@progbits + 32 .global USB_INT_ClearAllInterrupts + 34 USB_INT_ClearAllInterrupts: + 35 .LFB69: + 36 .LSM3: + 37 /* prologue: function */ + 38 /* frame size = 0 */ + 39 .LSM4: + 40 0000 1092 E100 sts 225,__zero_reg__ + 41 /* epilogue start */ + 42 .LSM5: + 43 0004 0895 ret + 44 .LFE69: + 46 .section .text.__vector_11,"ax",@progbits + 47 .global __vector_11 + 49 __vector_11: + 50 .LFB70: + 51 .LSM6: + 52 0000 1F92 push __zero_reg__ + 53 0002 0F92 push r0 + 54 0004 0FB6 in r0,__SREG__ + 55 0006 0F92 push r0 + 56 0008 1124 clr __zero_reg__ + 57 000a 2F93 push r18 + 58 000c 3F93 push r19 + 59 000e 4F93 push r20 + 60 0010 5F93 push r21 + 61 0012 6F93 push r22 + 62 0014 7F93 push r23 + 63 0016 8F93 push r24 + 64 0018 9F93 push r25 + 65 001a AF93 push r26 + 66 001c BF93 push r27 + 67 001e EF93 push r30 + 68 0020 FF93 push r31 + 69 /* prologue: Signal */ + 70 /* frame size = 0 */ + 71 .LSM7: + 72 0022 8091 E100 lds r24,225 + 73 0026 80FF sbrs r24,0 + 74 0028 00C0 rjmp .L6 + 75 002a 8091 E200 lds r24,226 + 76 002e 80FF sbrs r24,0 + 77 0030 00C0 rjmp .L6 + 78 .LSM8: + 79 0032 8091 E100 lds r24,225 + 80 0036 8E7F andi r24,lo8(-2) + 81 0038 8093 E100 sts 225,r24 + 82 .LSM9: + 83 003c 8091 E200 lds r24,226 + 84 0040 8E7F andi r24,lo8(-2) + 85 0042 8093 E200 sts 226,r24 + 86 .LSM10: + 87 0046 8091 E200 lds r24,226 + 88 004a 8061 ori r24,lo8(16) + 89 004c 8093 E200 sts 226,r24 + 90 .LBB20: + 91 .LBB21: + 92 .LSM11: + 93 0050 8091 D800 lds r24,216 + 94 0054 8062 ori r24,lo8(32) + 95 0056 8093 D800 sts 216,r24 + 96 .LBE21: + 97 .LBE20: + 98 .LBB22: + 99 .LBB23: + 100 .LSM12: + 101 005a 19BC out 73-32,__zero_reg__ + 102 .LBE23: + 103 .LBE22: + 104 .LSM13: + 105 005c 1092 0000 sts USB_DeviceState,__zero_reg__ + 106 .LSM14: + 107 0060 0E94 0000 call EVENT_USB_Device_Disconnect + 108 .L6: + 109 .LSM15: + 110 0064 8091 E100 lds r24,225 + 111 0068 84FF sbrs r24,4 + 112 006a 00C0 rjmp .L7 + 113 006c 8091 E200 lds r24,226 + 114 0070 84FF sbrs r24,4 + 115 0072 00C0 rjmp .L7 + 116 .LBB24: + 117 .LBB25: + 118 .LSM16: + 119 0074 84E0 ldi r24,lo8(4) + 120 0076 89BD out 73-32,r24 + 121 .LSM17: + 122 0078 89B5 in r24,73-32 + 123 007a 8260 ori r24,lo8(2) + 124 007c 89BD out 73-32,r24 + 125 .L8: + 126 .LBE25: + 127 .LBE24: + 128 .LSM18: + 129 007e 09B4 in __tmp_reg__,73-32 + 130 0080 00FE sbrs __tmp_reg__,0 + 131 0082 00C0 rjmp .L8 + 132 .LBB26: + 133 .LBB27: + 134 .LSM19: + 135 0084 8091 D800 lds r24,216 + 136 0088 8F7D andi r24,lo8(-33) + 137 008a 8093 D800 sts 216,r24 + 138 .LBE27: + 139 .LBE26: + 140 .LSM20: + 141 008e 8091 E100 lds r24,225 + 142 0092 8F7E andi r24,lo8(-17) + 143 0094 8093 E100 sts 225,r24 + 144 .LSM21: + 145 0098 8091 E200 lds r24,226 + 146 009c 8F7E andi r24,lo8(-17) + 147 009e 8093 E200 sts 226,r24 + 148 .LSM22: + 149 00a2 8091 E200 lds r24,226 + 150 00a6 8160 ori r24,lo8(1) + 151 00a8 8093 E200 sts 226,r24 + 152 .LSM23: + 153 00ac 8091 0000 lds r24,USB_ConfigurationNumber + 154 00b0 8823 tst r24 + 155 00b2 01F4 brne .L11 + 156 .L9: + 157 .LBB28: + 158 .LBB29: + 159 .LSM24: + 160 00b4 8091 E300 lds r24,227 + 161 .LBE29: + 162 .LBE28: + 163 .LSM25: + 164 00b8 87FD sbrc r24,7 + 165 00ba 00C0 rjmp .L11 + 166 00bc 81E0 ldi r24,lo8(1) + 167 .LVL0: + 168 00be 00C0 rjmp .L12 + 169 .LVL1: + 170 .L11: + 171 00c0 84E0 ldi r24,lo8(4) + 172 .LVL2: + 173 .L12: + 174 00c2 8093 0000 sts USB_DeviceState,r24 + 175 .LSM26: + 176 00c6 0E94 0000 call EVENT_USB_Device_Connect + 177 .LVL3: + 178 .L7: + 179 .LSM27: + 180 00ca 8091 E100 lds r24,225 + 181 00ce 83FF sbrs r24,3 + 182 00d0 00C0 rjmp .L13 + 183 00d2 8091 E200 lds r24,226 + 184 00d6 83FF sbrs r24,3 + 185 00d8 00C0 rjmp .L13 + 186 .LSM28: + 187 00da 8091 E100 lds r24,225 + 188 00de 877F andi r24,lo8(-9) + 189 00e0 8093 E100 sts 225,r24 + 190 .LSM29: + 191 00e4 82E0 ldi r24,lo8(2) + 192 00e6 8093 0000 sts USB_DeviceState,r24 + 193 .LSM30: + 194 00ea 1092 0000 sts USB_ConfigurationNumber,__zero_reg__ + 195 .LSM31: + 196 00ee 8091 E100 lds r24,225 + 197 00f2 8E7F andi r24,lo8(-2) + 198 00f4 8093 E100 sts 225,r24 + 199 .LSM32: + 200 00f8 8091 E200 lds r24,226 + 201 00fc 8E7F andi r24,lo8(-2) + 202 00fe 8093 E200 sts 226,r24 + 203 .LSM33: + 204 0102 8091 E200 lds r24,226 + 205 0106 8061 ori r24,lo8(16) + 206 0108 8093 E200 sts 226,r24 + 207 .LBB30: + 208 .LBB31: + 209 .LSM34: + 210 010c 80E0 ldi r24,lo8(0) + 211 010e 60E0 ldi r22,lo8(0) + 212 0110 42E0 ldi r20,lo8(2) + 213 0112 0E94 0000 call Endpoint_ConfigureEndpoint_Prv + 214 .LBE31: + 215 .LBE30: + 216 .LSM35: + 217 0116 0E94 0000 call EVENT_USB_Device_Reset + 218 .L13: + 219 .LSM36: + 220 011a 8091 E100 lds r24,225 + 221 011e 82FF sbrs r24,2 + 222 0120 00C0 rjmp .L15 + 223 0122 8091 E200 lds r24,226 + 224 0126 82FF sbrs r24,2 + 225 0128 00C0 rjmp .L15 + 226 .LSM37: + 227 012a 8091 E100 lds r24,225 + 228 012e 8B7F andi r24,lo8(-5) + 229 0130 8093 E100 sts 225,r24 + 230 .LSM38: + 231 0134 0E94 0000 call EVENT_USB_Device_StartOfFrame + 232 .L15: + 233 /* epilogue start */ + 234 .LSM39: + 235 0138 FF91 pop r31 + 236 013a EF91 pop r30 + 237 013c BF91 pop r27 + 238 013e AF91 pop r26 + 239 0140 9F91 pop r25 + 240 0142 8F91 pop r24 + 241 0144 7F91 pop r23 + 242 0146 6F91 pop r22 + 243 0148 5F91 pop r21 + 244 014a 4F91 pop r20 + 245 014c 3F91 pop r19 + 246 014e 2F91 pop r18 + 247 0150 0F90 pop r0 + 248 0152 0FBE out __SREG__,r0 + 249 0154 0F90 pop r0 + 250 0156 1F90 pop __zero_reg__ + 251 0158 1895 reti + 252 .LFE70: + 294 .Letext0: +DEFINED SYMBOLS + *ABS*:0000000000000000 USBInterrupt.c + /tmp/ccbAo69F.s:2 *ABS*:000000000000003f __SREG__ + /tmp/ccbAo69F.s:3 *ABS*:000000000000003e __SP_H__ + /tmp/ccbAo69F.s:4 *ABS*:000000000000003d __SP_L__ + /tmp/ccbAo69F.s:5 *ABS*:0000000000000034 __CCP__ + /tmp/ccbAo69F.s:6 *ABS*:0000000000000000 __tmp_reg__ + /tmp/ccbAo69F.s:7 *ABS*:0000000000000001 __zero_reg__ + /tmp/ccbAo69F.s:19 .text.USB_INT_DisableAllInterrupts:0000000000000000 USB_INT_DisableAllInterrupts + /tmp/ccbAo69F.s:34 .text.USB_INT_ClearAllInterrupts:0000000000000000 USB_INT_ClearAllInterrupts + /tmp/ccbAo69F.s:49 .text.__vector_11:0000000000000000 __vector_11 + +UNDEFINED SYMBOLS +USB_DeviceState +EVENT_USB_Device_Disconnect +USB_ConfigurationNumber +EVENT_USB_Device_Connect +Endpoint_ConfigureEndpoint_Prv +EVENT_USB_Device_Reset +EVENT_USB_Device_StartOfFrame diff --git a/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.o b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.o new file mode 100644 index 0000000..e4eefd0 Binary files /dev/null and b/firmware/LUFA/Drivers/USB/LowLevel/USBInterrupt.o differ diff --git a/firmware/LUFA/Drivers/USB/USB.h b/firmware/LUFA/Drivers/USB/USB.h new file mode 100644 index 0000000..71a337c --- /dev/null +++ b/firmware/LUFA/Drivers/USB/USB.h @@ -0,0 +1,408 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 + * including any headers in the USB/LowLevel/ or USB/HighLevel/ subdirectories. + */ + +/** @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/LowLevel/Device.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/LowLevel/Endpoint.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/LowLevel/Host.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/LowLevel/Pipe.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/LowLevel/USBController.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/LowLevel/USBInterrupt.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/DeviceStandardReq.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/Events.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/EndpointStream.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/HostStandardReq.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/PipeStream.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/HighLevel/USBTask.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Module Description + * Driver and framework for the USB controller hardware on the USB series of AVR microcontrollers. 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 AVR timers, etc. 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
AudioYesNo
CDCYesYes
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 SSec_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 ClassInfo + * structure. + * + * Inside the ClassInfo structure lies two sections, a Config section, and a State section. The 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. + * + * The State section of the 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 set 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 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 thus: + * + * \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 (;;) + * { + * 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 "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 "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 SSec_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 ClassInfo + * structure. + * + * Inside the ClassInfo structure lies two sections, a Config section, and a State section. The 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. + * + * The State section of the 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 set by the user application. + * + * The following is an example of a properly initialized instance of the MIDI 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 host state machine entering the \ref HOST_STATE_Addressed state. This function + * 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 + * switch (USB_HostState) + * { + * case HOST_STATE_Addressed: + * 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); + * USB_HostState = HOST_STATE_WaitForDeviceRemoval; + * break; + * } + * + * if (MIDI_Host_ConfigurePipes(&My_MIDI_Interface, + * ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * USB_HostState = HOST_STATE_WaitForDeviceRemoval; + * break; + * } + * + * // Other state handler code here + * \endcode + * + * Note that the function also required 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. + * + * 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 (;;) + * { + * switch (USB_HostState) + * { + * // Host state machine handling here + * } + * + * MIDI_Host_USBTask(&My_Audio_Interface); + * USB_USBTask(); + * } + * } + * \endcode + * + * Each class driver may also define a set of callback functions (which are prefixed by "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 "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: */ + #if !defined(__DOXYGEN__) + #define __INCLUDE_FROM_USB_DRIVER + #endif + + /* Includes: */ + #include "HighLevel/USBMode.h" + + /* Preprocessor Checks: */ + #if (!defined(USB_SERIES_2_AVR) && !defined(USB_SERIES_4_AVR) && \ + !defined(USB_SERIES_6_AVR) && !defined(USB_SERIES_7_AVR)) + #error The currently selected AVR model is not supported under the USB component of the LUFA library. + #endif + + /* Includes: */ + #include "HighLevel/USBTask.h" + #include "HighLevel/Events.h" + #include "HighLevel/StdDescriptors.h" + #include "HighLevel/ConfigDescriptor.h" + + #include "LowLevel/USBController.h" + #include "LowLevel/USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "LowLevel/Host.h" + #include "LowLevel/Pipe.h" + #include "HighLevel/HostStandardReq.h" + #include "HighLevel/PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "LowLevel/Device.h" + #include "LowLevel/Endpoint.h" + #include "HighLevel/DeviceStandardReq.h" + #include "HighLevel/EndpointStream.h" + #endif + + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + #include "LowLevel/OTG.h" + #endif + + #include "Class/Audio.h" + #include "Class/CDC.h" + #include "Class/HID.h" + #include "Class/MassStorage.h" + #include "Class/MIDI.h" + #include "Class/Printer.h" + #include "Class/RNDIS.h" + #include "Class/StillImage.h" + +#endif + diff --git a/firmware/LUFA/License.txt b/firmware/LUFA/License.txt new file mode 100644 index 0000000..c46c6b0 --- /dev/null +++ b/firmware/LUFA/License.txt @@ -0,0 +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. + diff --git a/firmware/LUFA/ManPages/AboutLUFA.txt b/firmware/LUFA/ManPages/AboutLUFA.txt new file mode 100644 index 0000000..697535c --- /dev/null +++ b/firmware/LUFA/ManPages/AboutLUFA.txt @@ -0,0 +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 + */ + diff --git a/firmware/LUFA/ManPages/AlternativeStacks.txt b/firmware/LUFA/ManPages/AlternativeStacks.txt new file mode 100644 index 0000000..889183c --- /dev/null +++ b/firmware/LUFA/ManPages/AlternativeStacks.txt @@ -0,0 +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. + */ + diff --git a/firmware/LUFA/ManPages/Author.jpg b/firmware/LUFA/ManPages/Author.jpg new file mode 100644 index 0000000..e8f5541 Binary files /dev/null and b/firmware/LUFA/ManPages/Author.jpg differ diff --git a/firmware/LUFA/ManPages/BuildingLinkableLibraries.txt b/firmware/LUFA/ManPages/BuildingLinkableLibraries.txt new file mode 100644 index 0000000..ff5fdc5 --- /dev/null +++ b/firmware/LUFA/ManPages/BuildingLinkableLibraries.txt @@ -0,0 +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. + */ + diff --git a/firmware/LUFA/ManPages/ChangeLog.txt b/firmware/LUFA/ManPages/ChangeLog.txt new file mode 100644 index 0000000..1cd368d --- /dev/null +++ b/firmware/LUFA/ManPages/ChangeLog.txt @@ -0,0 +1,1099 @@ +/** \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_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 scancode 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 seperately 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 inbetween 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 incomming events in a loop until the bank becomes empty rather than one at a time + * - Changed LowLevel MIDI demos to only clear the incomming 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_CLOCK 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 dependancies 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 Søren 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_CLOCK 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 31st 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 5 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/firmware/LUFA/ManPages/CompileTimeTokens.txt b/firmware/LUFA/ManPages/CompileTimeTokens.txt new file mode 100644 index 0000000..86fa438 --- /dev/null +++ b/firmware/LUFA/ManPages/CompileTimeTokens.txt @@ -0,0 +1,212 @@ +/** \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. + * + * + * \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 ) \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 ) \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 ) \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 ) \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 ) \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 ) \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 ) \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 + * 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. + * + * NO_STREAM_CALLBACKS - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n + * Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the + * host easily via a single function call (rather than complex routines worrying about sending full packets, waiting for the endpoint/ + * pipe to become ready, etc.). By default, these stream functions require a callback function which is executed after each byte processed, + * allowing for early-aborts of stream transfers by the application. If callbacks are not required in an application, they can be removed + * by defining this token, reducing the compiled binary size. When removed, the stream functions no longer accept a callback function as + * a parameter. + * + * FAST_STREAM_TRANSFERS - ( \ref Group_EndpointPacketManagement , \ref Group_PipePacketManagement )\n + * By default, streams are transferred internally via a loop, sending or receiving one byte per iteration before checking for a bank full + * or empty condition. This allows for multiple stream functions to be chained together easily, as there are no alignment issues. However, + * this can lead to heavy performance penalties in applications where large streams are used frequently. When this compile time option is + * used, bytes are sent or received in groups of 8 bytes at a time increasing performance at the expense of a larger flash memory consumption + * due to the extra code required to deal with byte alignment. + * + * USE_STATIC_OPTIONS=x - ( \ref Group_USBManagement ) \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 ) \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 ) \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 ) \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 ) \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 ) \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_Descriptors ) \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_Descriptors ) \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_Descriptors ) \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_Descriptors ) \n + * Some AVR models contain a unique 20-digit 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 ) \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 ) \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 ) \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 \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 ) \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 ) \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 ) \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_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 ) \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 ) \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 ) \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. + */ + diff --git a/firmware/LUFA/ManPages/CompilingApps.txt b/firmware/LUFA/ManPages/CompilingApps.txt new file mode 100644 index 0000000..ff34534 --- /dev/null +++ b/firmware/LUFA/ManPages/CompilingApps.txt @@ -0,0 +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. + */ diff --git a/firmware/LUFA/ManPages/ConfiguringApps.txt b/firmware/LUFA/ManPages/ConfiguringApps.txt new file mode 100644 index 0000000..9ab0c5a --- /dev/null +++ b/firmware/LUFA/ManPages/ConfiguringApps.txt @@ -0,0 +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 AVR model, 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 AVR 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 AVR processor + * - BOARD, the target board hardware + * - F_CLOCK, the target raw master clock frequency, before any prescaling is performed + * - F_CPU, the target AVR CPU master clock frequency, after any prescaling + * - 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 AVR model for the compiled application. This should be set to the model of the target AVR + * (such as the AT90USB1287, or the ATMEGA32U4), in all lower-case (e.g. "at90usb1287"). Note that not all demos support all the + * USB AVR models, as they may make use of peripherals or modes only present in some devices. + * + * For supported processor models, see \ref Page_DeviceSupport. + * + * \section Sec_BOARD The BOARD Parameter + * This parameter indicates the target AVR 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 /BoardStubs/ + * 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_CLOCK The F_CLOCK Parameter + * This parameter indicates the target AVR's input clock frequency, in Hz. This is the actual clock input, before any prescaling is performed. In the + * USB AVR architecture, the input clock before any prescaling is fed directly to the PLL subsystem, and thus the PLL is derived directly from the + * clock input. The PLL then feeds the USB and other sections of the AVR with the correct upscaled frequencies required for those sections to function. + * + * Note that this value does not actually *alter* the AVR's input clock frequency, it is just a way to indicate to the library the clock frequency + * of the AVR as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more + * library components will occur. + * + * \section Sec_F_CPU The F_CPU Parameter + * This parameter indicates the target AVR's master CPU clock frequency, in Hz. + * + * Note that this value does not actually *alter* the AVR's CPU clock frequency, it is just a way to indicate to the library the clock frequency + * of the AVR core as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more + * library components will occur. + * + * \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 AVR to the current configuration - if the options are incorrect, then the demo is most likely incompatible with the chosen USB AVR + * 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 (Low or Full 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/firmware/LUFA/ManPages/DevelopingWithLUFA.txt b/firmware/LUFA/ManPages/DevelopingWithLUFA.txt new file mode 100644 index 0000000..1b73fa6 --- /dev/null +++ b/firmware/LUFA/ManPages/DevelopingWithLUFA.txt @@ -0,0 +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 + */ + diff --git a/firmware/LUFA/ManPages/DeviceSupport.txt b/firmware/LUFA/ManPages/DeviceSupport.txt new file mode 100644 index 0000000..157b8c6 --- /dev/null +++ b/firmware/LUFA/ManPages/DeviceSupport.txt @@ -0,0 +1,51 @@ +/** \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 + * + * Currently supported AVR models: + * - AT90USB82 (USB Device Only) + * - ATMEGA8U2 (USB Device Only) + * - AT90USB162 (USB Device Only) + * - ATMEGA16U2 (USB Device Only) + * - ATMEGA16U4 (USB Device Only) + * - ATMEGA32U2 (USB Device Only) + * - ATMEGA32U4 (USB Device Only) + * - ATMEGA32U6 (USB Device Only) + * - AT90USB646 (USB Device Only) + * - AT90USB647 (USB Host and Device) + * - AT90USB1286 (USB Device Only) + * - AT90USB1287 (USB Host and Device) + * + * Currently supported Atmel boards (see \ref Group_BoardTypes): + * - AT90USBKEY + * - ATAVRUSBRF01 + * - EVK527 + * - RZUSBSTICK + * - STK525 + * - STK526 + * - XPLAIN (Both original first revision board, and newer boards with a different Dataflash model) + * + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile BOARD constant names): + * - Adafruit U4 Breakout Board + * - Arduino Uno + * - Busware BUI + * - Busware CUL V3 + * - Fletchtronics Bumble-B (using officially recommended peripheral layout) + * - Kernel Concepts USBFOO + * - Linnix UDIP + * - MattairTech JM-DB-U2 + * - Maximus USB + * - Minimus USB + * - Olimex AVR-USB-162 + * - PJRC Teensy (all revisions and versions) + * - TCNISO Blackcat USB JTAG + * - Tempusdictum Benito + * - Tom's USBTINY-MKII (all revisions and versions) + * - Any Other Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + diff --git a/firmware/LUFA/ManPages/DirectorySummaries.txt b/firmware/LUFA/ManPages/DirectorySummaries.txt new file mode 100644 index 0000000..d4b862b --- /dev/null +++ b/firmware/LUFA/ManPages/DirectorySummaries.txt @@ -0,0 +1,192 @@ +/** \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 and USB AVR + * microcontroller model. + * + * \dir LUFA/Drivers/Misc + * \brief Miscellaneous driver files. + * + * This folder contains drivers for aspects other than the USB interface, board hardware or AVR peripherals. + * + * \dir LUFA/Drivers/Peripheral + * \brief USB AVR peripheral driver files. + * + * This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible with + * all USB AVR models. + * + * \dir LUFA/Drivers/Peripheral/AVRU4U6U7 + * \brief AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 AVR model peripheral driver files. + * + * This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible only with + * the AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 USB AVR models, such as the AT90USB1287. Its contents should not be + * included by the user application - the dispatch header file located in the parent directory should be used + * instead. + * + * \dir LUFA/Drivers/USB + * \brief USB controller peripheral driver files. + * + * This folder contains the main header files required to implement the USB interface in the USB supporting AVR models. + * The header files contained directly in this folder should be included in the user application in order to gain USB + * functionality, and the appropriate C source files in the LowLevel and HighLevel driver folders added to the compile + * and link stages. + * + * \dir LUFA/Drivers/USB/LowLevel + * \brief Low level USB driver files. + * + * This folder contains low level USB driver source files required to implement USB functionality on the USB AVR microcontrollers. + * + * \dir LUFA/Drivers/USB/HighLevel + * \brief High level USB driver files. + * + * This folder contains high level USB driver source files required to implement USB functionality on the USB AVR microcontrollers. + * + * \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/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/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/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/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/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/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/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/Drivers/Board/EVK527 + * \brief XPLAIN 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/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/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/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/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/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/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/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/firmware/LUFA/ManPages/Donating.txt b/firmware/LUFA/ManPages/Donating.txt new file mode 100644 index 0000000..9538982 --- /dev/null +++ b/firmware/LUFA/ManPages/Donating.txt @@ -0,0 +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 21 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/firmware/LUFA/ManPages/FutureChanges.txt b/firmware/LUFA/ManPages/FutureChanges.txt new file mode 100644 index 0000000..bfe1528 --- /dev/null +++ b/firmware/LUFA/ManPages/FutureChanges.txt @@ -0,0 +1,42 @@ +/** \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 + * -# Add ability to get number of bytes not written with pipe/endpoint write routines after an error + * -# Change makefiles to allow for absolute LUFA location to be used + * -# Re-add interrupt Pipe/Endpoint support + * -# Add HID report macros to make HID report editing easier + * -# Investigate dynamically created device descriptors + * - Documentation/Support + * -# Add detailed overviews of how each demo works + * -# Add board overviews + * -# Write LUFA tutorials + * - Demos/Projects + * -# Multiple-Report HID device + * -# Device/Host USB bridge + * -# Alternative (USB-IF endorsed) USB-CDC Ethernet Class + * -# Finish Test and Measurement Class demo + * -# Finish BluetoothHost demo + * -# Finish SideShow demo + * -# Finish StandaloneProgrammer project + * -# Arduino Uno compatible USB-MIDI, USB-HID + * -# Make Webserver project work in RNDIS device mode + * - Ports + * -# AVR32 UC3B series microcontrollers + * -# Atmel ARM7 series microcontrollers + * -# Other (commercial) C compilers + */ + diff --git a/firmware/LUFA/ManPages/GettingStarted.txt b/firmware/LUFA/ManPages/GettingStarted.txt new file mode 100644 index 0000000..cc936ab --- /dev/null +++ b/firmware/LUFA/ManPages/GettingStarted.txt @@ -0,0 +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 + */ + diff --git a/firmware/LUFA/ManPages/Groups.txt b/firmware/LUFA/ManPages/Groups.txt new file mode 100644 index 0000000..c1c4a43 --- /dev/null +++ b/firmware/LUFA/ManPages/Groups.txt @@ -0,0 +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. + */ + +/** @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. + */ + diff --git a/firmware/LUFA/ManPages/LUFA.png b/firmware/LUFA/ManPages/LUFA.png new file mode 100644 index 0000000..54fa1a6 Binary files /dev/null and b/firmware/LUFA/ManPages/LUFA.png differ diff --git a/firmware/LUFA/ManPages/LUFAPoweredProjects.txt b/firmware/LUFA/ManPages/LUFAPoweredProjects.txt new file mode 100644 index 0000000..17fbfd4 --- /dev/null +++ b/firmware/LUFA/ManPages/LUFAPoweredProjects.txt @@ -0,0 +1,95 @@ +/** \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 + * - 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/ + * - 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 + * - AVR USB Modem, a 3G Wireless Modem host: http://code.google.com/p/avrusbmodem/ + * - Bicycle POV: http://www.code.google.com/p/bicycleledpov/ + * - 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/ + * - EMUCOMBOX, a USB-RS422 adapter for E-Mu Emax samplers: http://users.skynet.be/emxp/EMUCOMBOX.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/ + * - 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/ + * - Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/ + * - 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 + * - PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove + * - Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/ + * - Linux Secure Storage Dongle: http://github.com/TomMD/teensy + * - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g + * - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster + * - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3 + * - NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm + * - 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 XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/ + * - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ + * - SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/ + * - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 + * - Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/ + * - 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 + * - USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001 + * - Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/ + * - XUM1541, a Commodore 64 floppy drive to USB adapter: http://www.root.org/~nate/c64/xum1541/ + * + * \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. + * + * - Arduino Uno, the official Arduino board: www.arduino.cc + * - ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en + * - Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.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 + * - Many of Busware's Products: http://www.busware.de/ + * - MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/ + * - Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org + * - USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php + * - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/ + * + * \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 + */ diff --git a/firmware/LUFA/ManPages/LUFAvsAtmelStack.txt b/firmware/LUFA/ManPages/LUFAvsAtmelStack.txt new file mode 100644 index 0000000..97035b5 --- /dev/null +++ b/firmware/LUFA/ManPages/LUFAvsAtmelStack.txt @@ -0,0 +1,46 @@ +/** \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 Stack + * + * Atmel offers an official 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. Below are just some of the advantages to choosing LUFA over the official 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. + */ + diff --git a/firmware/LUFA/ManPages/LibraryApps.txt b/firmware/LUFA/ManPages/LibraryApps.txt new file mode 100644 index 0000000..1de0ea7 --- /dev/null +++ b/firmware/LUFA/ManPages/LibraryApps.txt @@ -0,0 +1,116 @@ +/** \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 + * - 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 + * - 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 + * - 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 + * - JoystickHostWithParser - Joystick host demo with HID Descriptor parser, using the low level LUFA APIs to implement + * the USB HID class + * - GenericHIDHost - Generic HID host demo, 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 + * - DFU - DFU Class USB bootloader, compatible with Atmel's FLIP and the open source dfu-programmer software + * - CDC - CDC Class USB bootloader, compatible with any AVR910 protocol programming software such as AVRDude + * - Projects + * - AVRISP-MKII - AVRISP-MKII Programmer Clone project + * - Benito - Benito Board Arduino Programmer project + * - LEDNotifier - USB LED Notification project + * - Magstripe - Magnetic Stripe Card Reader 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/firmware/LUFA/ManPages/LibraryResources.txt b/firmware/LUFA/ManPages/LibraryResources.txt new file mode 100644 index 0000000..eef36d9 --- /dev/null +++ b/firmware/LUFA/ManPages/LibraryResources.txt @@ -0,0 +1,32 @@ +/** \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_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 + * Author's Skype: abcminiuser + * + * \section Sec_InDevelopment Latest In-Development Source Code + * Issue Tracker: http://www.lufa-lib.org/tracker \n + * Bazaar Access: http://www.lufa-lib.org/bzr \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/firmware/LUFA/ManPages/LicenseInfo.txt b/firmware/LUFA/ManPages/LicenseInfo.txt new file mode 100644 index 0000000..091ce94 --- /dev/null +++ b/firmware/LUFA/ManPages/LicenseInfo.txt @@ -0,0 +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 + */ + diff --git a/firmware/LUFA/ManPages/MainPage.txt b/firmware/LUFA/ManPages/MainPage.txt new file mode 100644 index 0000000..d5935c2 --- /dev/null +++ b/firmware/LUFA/ManPages/MainPage.txt @@ -0,0 +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 + *
Logo design by Ryo Photography
+ * \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/firmware/LUFA/ManPages/MigrationInformation.txt b/firmware/LUFA/ManPages/MigrationInformation.txt new file mode 100644 index 0000000..be5e949 --- /dev/null +++ b/firmware/LUFA/ManPages/MigrationInformation.txt @@ -0,0 +1,564 @@ +/** \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_Migration101122 Migrating from 100807 to 101122 + * USB Core + * - A new USB driver source file, 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, 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 EVENT_USB_InitFailure() event has been removed, as the 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 LUFA/Drivers/USB/USB.h master dispatch header, and should + * no longer be included seperately. Class driver module source files must still be added as a seperate 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 CALLBACK_USB_GetDescriptor() callback has changed, the "void** const DescriptorAddress" parameter is + * now "const void** const DescriptorAddress". Existing applications should update their callback signatures to match this, and + * eliminate any casting of descriptor pointers to a non-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 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 greated than 2 to regain the previous functionality. + * - The 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 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 "SImage_" to "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, 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 Drivers/USB/LowLevel/DevChapter9.c source file has moved to 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 Drivers/USB/LowLevel/HostChapter9.h source file has moved to 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 Drivers/USB/LowLevel/LowLevel.c source file has moved to 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 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 USB_Device_IsRemoteWakeupSent(). + * - The 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_Device_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 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 USBInterrupt.c USB driver source file has been relocated from LUFA/Drivers/USB/HighLevel/ to LUFA/Drivers/USB/LowLevel. + * Projects must update their makefile SRC values accordingly. + * - The HID Device Class driver's function signature for the CALLBACK_HID_Device_ProcessHIDReport() function has been changed, to + * allow for a new 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 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 USBInterrupt.c USB driver source file has been relocated from LUFA/Drivers/USB/HighLevel/ to LUFA/Drivers/USB/LowLevel. + * Projects must update their makefile SRC values accordingly. + * - The HID Host Class driver's function signature for the HID_Host_SendReportByID() function has been changed, to allow for a new + * ReportType parameter. Existing calls to this function should substitute 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 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 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 SI_Host_USBTask() and SI_Host_ConfigurePipes() functions were misnamed, and are + * now named SImage_Host_USBTask() and SImage_Host_ConfigurePipes() respectively. + * - The 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 CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new 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 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 HID_ReportItem_t to the + * user application, instead of just its attributes. + * - The 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 ADC_Off() function has been renamed to \ref 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 SPI_Init() before using the Dataflash driver + * + * Host Mode + * - The 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 HID_ENABLE_FEATURE_PROCESSING + * and HID_INCLUDE_CONSTANT_DATA_ITEMS compile time tokens now have no effect. + * - 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 that both may be used in + * the one project. For existing projects using the standardized names, change all code to use the USB_StdDescriptor_* variants. + * + * Device Mode + * - 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 that both may be used in + * the one project. For existing projects using the standardized names, change all code to use the 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. The library is available from the author's website for those wishing to still use it in their + * applications. + * + * Non-USB Library Components + * - The ATTR_NOINLINE function attribute macro has been renamed to 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 HIDParser.c module has moved from LUFA/Drivers/USB/Class/ to LUFA/Drivers/USB/Class/Host/. + * - The 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 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 USE_FLASH_DESCRIPTORS + * token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter. + * - The USB_IsSuspended global has been removed - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead. + * - The 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 USB_Connect and 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 INTERRUPT_CONTROL_ENDPOINT token defined. + * - The 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 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 uint8_t value. + * - The Event_DeviceError() event no longer exists, as its sole caller (unlinked USB_GetDescriptor() function) now produces a + * compilation error rather than a runtime error. The StdDescriptors.c file no longer exists as a result, and should be removed + * from project makefiles. + * - The USB_GetDescriptor() function has been renamed to CALLBACK_USB_GetDescriptor() to be in line with the new 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 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 uint8_t value. + * - The 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 uint8_t value. + * + * \section Sec_Migration090510 Migrating from 090401 to 090510 + * + * All + * - The ButtLoadTag.h header has been removed, as it was never used for its intended purpose. Projects should either remove all + * BUTTLOADTAG elements, or download and extract ButtLoadTag.h header from the ButtLoad project. + * - The Drivers/AT90USBXXX directory has been renamed to Drivers/Peripheral. + * - The Serial_Stream driver has been renamed to SerialStream to remain consistent with the rest of the library naming scheme. + * - The HWB driver has changed to the Buttons driver. See the board Buttons driver documentation for the new API. + * + * Dual Role Mode + * - The USB_PowerOnFail even has been renamed to USB_InitFailure. + * - The functions in OTG.h have been renamed to remain more consistent with the library API. See the functions in OTG.h for more + * details. + * + * Library Demos + * - Most demos, bootloaders and applications have had significant changes from previous versions. Applications built off of any + * library demos should update to the latest versions. + * + * Device Mode + * - The Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the Endpoint_ClearIN(), Endpoint_ClearOUT() + * macros. See Endpoint.h documentation for more details on the new endpoint management macros. + * - The Endpoint_ReadWriteAllowed() macro has been renamed to Endpoint_IsReadWriteAllowed() to be more consistent with the rest of + * the API naming scheme. + * - The Endpoint_IsSetupINReady() and Endpoint_IsSetupOutReceived() macros have been renamed to Endpoint_IsINReady() and + * Endpoint_IsOUTReceived() respectively. + * - The Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(). + * - The Endpoint_ClearSetupReceived() macro has been renamed to Endpoint_ClearSETUP(). + * - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as Endpoint_Read_Word()) have + * been removed for clarity. Existing projects should use the "_LE" suffix on such calls to use the explicit Little Endian versions. + * - The 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 FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to CONTROL_ONLY_DEVICE. + * - The STATIC_ENDPOINT_CONFIGURATION is no longer applicable as the library will apply this optimization when appropriate automatically. + * - The values of the Endpoint_Stream_RW_ErrorCodes_t and Endpoint_ControlStream_RW_ErrorCodes_t enums have had the "ERROR_" portion + * of their names removed. + * + * Host Mode + * - The 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 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 Pipe_ReadWriteAllowed() macro has been renamed to Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API + * naming scheme. + * - The Pipe_IsSetupINReceived() and Pipe_IsOutReady() macros have been renamed to Pipe_IsINReceived() and Pipe_IsOUTReady() + * respectively. + * - The new Pipe_ClearSETUP() macro should be used to send SETUP transactions, rather than the previous Pipe_ClearSetupOUT() macro. + * - The Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent(). + * - The 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 Pipe_Read_Word()) have + * been removed for clarity. Existing projects should use the "_LE" suffix on such calls to use the explicit Little Endian versions. + * - The Host_IsResetBusDone() macro has been renamed to Host_IsBusResetComplete(). + * - The Pipe_Ignore_Word() and Pipe_Ignore_DWord() functions have been renamed to Pipe_Discard_Word() and Pipe_Discard_DWord() to remain + * consistent with the rest of the pipe API. + * - It is no longer needed to manually include the headers from LUFA/Drivers/USB/Class, as they are now included along with the rest + * of the USB headers when LUFA/Drivers/USB/USB.h is included. + * - Functions in the ConfigDescriptor.h header file no longer have "Host_" as part of their names. + * - The ProcessHIDReport() has been renamed to USB_ProcessHIDReport(), GetReportItemInfo() has been renamed to USB_GetHIDReportItemInfo() + * and SetReportItemInfo() has been renamed to USB_GetHIDReportItemInfo(). + * - The values of the DSearch_Return_ErrorCodes_t and DSearch_Comp_Return_ErrorCodes_t enums have had their respective "Descriptor_Search" + * and "Descriptor_Search_Comp" prefixes changed to all caps. + * - The USB_HostRequest global has been renamed to USB_ControlRequest, and is used in Device mode also. The USB_Host_Request_Header_t + * structure type has been renamed to USB_Request_Header_t. + * - The values of the Pipe_Stream_RW_ErrorCodes_t enum have had the "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 "F_CLOCK", + * 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 SetSystemClockPrescaler() macro has been removed. + * Include and call 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. + * - Most demos, bootloaders and applications have had their control request handling code corrected, to properly send the status + * stage in all handled requests. If you are using code based off one of the library demos, bootloaders or applications, you should + * update to the latest revisions. + * + * Non-USB Library Components + * - The ATTR_ALWAYSINLINE function attribute macro has been renamed to ATTR_ALWAYS_INLINE. + * - Custom board Dataflash drivers now require the implementation of Dataflash_SelectChipFromPage() and Dataflash_SendAddressBytes(). + * + * Device Mode + * - 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. On all applications currently using the + * NO_CLEARSET_FEATURE_REQUEST compile time token, it can be replaced with the FEATURELESS_CONTROL_ONLY_DEVICE token with no further + * modifications required. + * + * \section Sec_Migration090209 Migrating from 081217 to 090209 + * + * Device Mode + * - The ENDPOINT_MAX_ENDPOINTS constant has been renamed to the more appropriate name of ENDPOINT_TOTAL_ENDPOINTS. + * - The 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 PIPE_MAX_ENDPOINTS constant has been renamed to the more appropriate name of PIPE_TOTAL_ENDPOINTS. + * - The 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 USB_DeviceEnumerationFailed event now contains a second "SubErrorCode" parameter, giving the error code of the function + * which failed. + * - The HID_PARSE_Sucessful enum member constant has been corrected to HID_PARSE_Successful. + * + * Non-USB Library Components + * - The previous SPI_SendByte() functionality is now located in SPI_TransferByte(). SPI_SendByte() now discards the return byte + * for speed, to compliment the new SPI_ReceiveByte() function. If two-way SPI transfers are required, calls to SPI_SendByte() + * should be changed to SPI_TransferByte(). + * - The serial driver now sets the Tx line as an output explicitly, and enables the pull-up of the Rx line. + * - The Serial_Init() and SerialStream_Init() functions now take a second 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. + * + * Library Demos + * - Most library demos have been enhanced and/or had errors corrected. All users of all demos should upgrade their codebase to + * the latest demo versions. + * + * \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/firmware/LUFA/ManPages/ProgrammingApps.txt b/firmware/LUFA/ManPages/ProgrammingApps.txt new file mode 100644 index 0000000..ea5a447 --- /dev/null +++ b/firmware/LUFA/ManPages/ProgrammingApps.txt @@ -0,0 +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". + */ diff --git a/firmware/LUFA/ManPages/SoftwareBootloaderJump.txt b/firmware/LUFA/ManPages/SoftwareBootloaderJump.txt new file mode 100644 index 0000000..a553ebd --- /dev/null +++ b/firmware/LUFA/ManPages/SoftwareBootloaderJump.txt @@ -0,0 +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_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 snippet 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. + * + * \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 + * USB_ShutDown(); + * + * // Disable all interrupts + * cli(); + * + * // Wait two seconds for the USB detachment to register on the host + * for (uint8_t i = 0; i < 128; i++) + * _delay_ms(16); + * + * // 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/firmware/LUFA/ManPages/VIDAndPIDValues.txt b/firmware/LUFA/ManPages/VIDAndPIDValues.txt new file mode 100644 index 0000000..1dd2515 --- /dev/null +++ b/firmware/LUFA/ManPages/VIDAndPIDValues.txt @@ -0,0 +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 + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x2067 + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x2068 + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x2069 + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206A + * + * Currently Unallocated + *
+ * 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/firmware/LUFA/ManPages/WhyUseLUFA.txt b/firmware/LUFA/ManPages/WhyUseLUFA.txt new file mode 100644 index 0000000..43df7e5 --- /dev/null +++ b/firmware/LUFA/ManPages/WhyUseLUFA.txt @@ -0,0 +1,46 @@ +/** \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 (under most cases with the correct compile options) + * requires less FLASH space than Atmel's stack, meaning more space for the user application*. + * + * - 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). + * + * * Atmel Stack Mouse Device Demo 4292 bytes, LUFA Mouse Low Level Device Demo 3332 bytes, under identical build + * environments + */ + diff --git a/firmware/LUFA/ManPages/WritingBoardDrivers.txt b/firmware/LUFA/ManPages/WritingBoardDrivers.txt new file mode 100644 index 0000000..1b33269 --- /dev/null +++ b/firmware/LUFA/ManPages/WritingBoardDrivers.txt @@ -0,0 +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. + */ + diff --git a/firmware/LUFA/Scheduler/Scheduler.c b/firmware/LUFA/Scheduler/Scheduler.c new file mode 100644 index 0000000..3780a31 --- /dev/null +++ b/firmware/LUFA/Scheduler/Scheduler.c @@ -0,0 +1,99 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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. +*/ + +#include "Scheduler.h" + +volatile SchedulerDelayCounter_t Scheduler_TickCounter; +volatile uint8_t Scheduler_TotalTasks; + +bool Scheduler_HasDelayElapsed(const uint16_t Delay, + SchedulerDelayCounter_t* const DelayCounter) +{ + SchedulerDelayCounter_t CurrentTickValue_LCL; + SchedulerDelayCounter_t DelayCounter_LCL; + + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + CurrentTickValue_LCL = Scheduler_TickCounter; + } + + DelayCounter_LCL = *DelayCounter; + + if (CurrentTickValue_LCL >= DelayCounter_LCL) + { + if ((CurrentTickValue_LCL - DelayCounter_LCL) >= Delay) + { + *DelayCounter = CurrentTickValue_LCL; + return true; + } + } + else + { + if (((MAX_DELAYCTR_COUNT - DelayCounter_LCL) + CurrentTickValue_LCL) >= Delay) + { + *DelayCounter = CurrentTickValue_LCL; + return true; + } + } + + return false; +} + +void Scheduler_SetTaskMode(const TaskPtr_t Task, + const bool TaskStatus) +{ + TaskEntry_t* CurrTask = &Scheduler_TaskList[0]; + + while (CurrTask != &Scheduler_TaskList[Scheduler_TotalTasks]) + { + if (CurrTask->Task == Task) + { + CurrTask->TaskStatus = TaskStatus; + break; + } + + CurrTask++; + } +} + +void Scheduler_SetGroupTaskMode(const uint8_t GroupID, + const bool TaskStatus) +{ + TaskEntry_t* CurrTask = &Scheduler_TaskList[0]; + + while (CurrTask != &Scheduler_TaskList[Scheduler_TotalTasks]) + { + if (CurrTask->GroupID == GroupID) + CurrTask->TaskStatus = TaskStatus; + + CurrTask++; + } +} + diff --git a/firmware/LUFA/Scheduler/Scheduler.h b/firmware/LUFA/Scheduler/Scheduler.h new file mode 100644 index 0000000..a6f8ddd --- /dev/null +++ b/firmware/LUFA/Scheduler/Scheduler.h @@ -0,0 +1,313 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 Simple round-robbin pseudo-task scheduler. + * + * Simple round-robbin cooperative scheduler for use in basic projects where non real-time tasks need + * to be executed. Each task is executed in sequence, and can be enabled or disabled individually or as a group. + * + * \deprecated This module is deprecated and will be removed in a future library release. + */ + +/** @defgroup Group_Scheduler Simple Task Scheduler - LUFA/Scheduler/Scheduler.h + * + * \deprecated This module is deprecated and will be removed in a future library release. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Scheduler/Scheduler.c (Makefile source module name: LUFA_SRC_SCHEDULER) + * + * \section Module Description + * Simple round-robbin cooperative scheduler for use in basic projects where non real-time tasks need + * to be executed. Each task is executed in sequence, and can be enabled or disabled individually or as a group. + * + * For a task to yield it must return, thus each task should have persistent data marked with the static attribute. + * + * Each LUFA scheduler task should be written similar to an ISR; it should execute quickly (so that no one task + * hogs the processor, preventing another from running before some sort of timeout is exceeded). Unlike normal RTOS + * tasks, each LUFA scheduler task is a regular function, and thus must be designed to be called, and designed to + * return to the calling scheduler function repeatedly. Data which must be preserved between task calls should be + * declared as global or (preferably) as a static local variable inside the task. + * + * The scheduler consists of a task list, listing all the tasks which can be executed by the scheduler. Once started, + * each task is then called one after another, unless the task is stopped by another running task or interrupt. + * + * Usage Example: + * \code + * #include + * + * TASK(MyTask1); // Task prototype + * TASK(MyTask2); // Task prototype + * + * TASK_LIST + * { + * { .Task = MyTask1, .TaskStatus = TASK_RUN, .GroupID = 1 }, + * { .Task = MyTask2, .TaskStatus = TASK_RUN, .GroupID = 1 }, + * } + * + * int main(void) + * { + * Scheduler_Init(); + * + * // Other initialisation here + * + * Scheduler_Start(); + * } + * + * TASK(MyTask1) + * { + * // Task implementation here + * } + * + * TASK(MyTask2) + * { + * // Task implementation here + * } + * \endcode + * + * If desired, the LUFA scheduler does not need to be used in a LUFA powered application. A more conventional + * approach to application design can be used, or a proper scheduling RTOS inserted in the place of the LUFA scheduler. + * In the case of the former the USB task must be run manually repeatedly to maintain USB communications, and in the + * case of the latter a proper RTOS task must be set up to do the same. + * + * @{ + */ + +#ifndef __SCHEDULER_H__ +#define __SCHEDULER_H__ + + /* Includes: */ + #include + #include + + #include + + #include "../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Creates a new scheduler task body or prototype. Should be used in the form: + * \code + * TASK(TaskName); // Prototype + * + * TASK(TaskName) + * { + * // Task body + * } + * \endcode + */ + #define TASK(name) void name (void) + + /** Defines a task list array, containing one or more task entries of the type TaskEntry_t. Each task list + * should be encased in curly braces and ended with a comma. + * + * Usage Example: + * \code + * TASK_LIST + * { + * { .Task = MyTask1, .TaskStatus = TASK_RUN, .GroupID = 1 }, + * // More task entries here + * } + * \endcode + */ + #define TASK_LIST TaskEntry_t Scheduler_TaskList[] = + + /** Constant, giving the maximum delay in scheduler ticks which can be stored in a variable of type + * \ref SchedulerDelayCounter_t. + */ + #define TASK_MAX_DELAY (MAX_DELAYCTR_COUNT - 1) + + /** Task status mode constant, for passing to \ref Scheduler_SetTaskMode() or \ref Scheduler_SetGroupTaskMode(). */ + #define TASK_RUN true + + /** Task status mode constant, for passing to \ref Scheduler_SetTaskMode() or \ref Scheduler_SetGroupTaskMode(). */ + #define TASK_STOP false + + /* Pseudo-Function Macros: */ + #if defined(__DOXYGEN__) + /** Starts the scheduler in its infinite loop, executing running tasks. This should be placed at the end + * of the user application's main() function, as it can never return to the calling function. + */ + void Scheduler_Start(void); + + /** Initialises the scheduler so that the scheduler functions can be called before the scheduler itself + * is started. This must be executed before any scheduler function calls other than Scheduler_Start(), + * and can be omitted if no such functions could be called before the scheduler is started. + */ + void Scheduler_Init(void); + #else + #define Scheduler_Start() Scheduler_GoSchedule(TOTAL_TASKS); + #define Scheduler_Init() Scheduler_InitScheduler(TOTAL_TASKS); + #endif + + /* Type Defines: */ + /** Type define for a pointer to a scheduler task. */ + typedef void (*TaskPtr_t)(void); + + /** Type define for a variable which can hold a tick delay value for the scheduler up to the maximum delay + * possible. + */ + typedef uint16_t SchedulerDelayCounter_t; + + /** \brief Scheduler Task List Entry Structure. + * + * Structure for holding a single task's information in the scheduler task list. + */ + typedef struct + { + TaskPtr_t Task; /**< Pointer to the task to execute. */ + bool TaskStatus; /**< Status of the task (either TASK_RUN or TASK_STOP). */ + uint8_t GroupID; /**< Group ID of the task so that its status can be changed as a group. */ + } TaskEntry_t; + + /* Global Variables: */ + /** Task entry list, containing the scheduler tasks, task statuses and group IDs. Each entry is of type + * TaskEntry_t and can be manipulated as desired, although it is preferential that the proper Scheduler + * functions should be used instead of direct manipulation. + */ + exter TaskEntry_t Scheduler_TaskList[]; + + /** Contains the total number of tasks in the task list, irrespective of if the task's status is set to + * \ref TASK_RUN or \ref TASK_STOP. + * + * \note This value should be treated as read-only, and never altered in user-code. + */ + extern volatile uint8_t Scheduler_TotalTasks; + + /** Contains the current scheduler tick count, for use with the delay functions. If the delay functions + * are used in the user code, this should be incremented each tick period so that the delays can be + * calculated. + */ + extern volatile SchedulerDelayCounter_t Scheduler_TickCounter; + + /* Inline Functions: */ + /** Resets the delay counter value to the current tick count. This should be called to reset the period + * for a delay in a task which is dependant on the current tick value. + * + * \param[out] DelayCounter Counter which is storing the starting tick count for a given delay. + */ + static inline void Scheduler_ResetDelay(SchedulerDelayCounter_t* const DelayCounter) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Scheduler_ResetDelay(SchedulerDelayCounter_t* const DelayCounter) + { + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) + { + *DelayCounter = Scheduler_TickCounter; + } + } + + /* Function Prototypes: */ + /** Determines if the given tick delay has elapsed, based on the given delay period and tick counter value. + * + * \param[in] Delay The delay to test for, measured in ticks. + * \param[in] DelayCounter The counter which is storing the starting tick value for the delay. + * + * \return Boolean true if the delay has elapsed, false otherwise. + * + * Usage Example: + * \code + * static SchedulerDelayCounter_t DelayCounter = 10000; // Force immediate run on start-up + * + * // Task runs every 10000 ticks, 10 seconds for this demo + * if (Scheduler_HasDelayElapsed(10000, &DelayCounter)) + * { + * // Code to execute after delay interval elapsed here + * } + * \endcode + */ + bool Scheduler_HasDelayElapsed(const uint16_t Delay, + SchedulerDelayCounter_t* const DelayCounter) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(2); + + /** Sets the task mode for a given task. + * + * \param[in] Task Name of the task whose status is to be changed. + * \param[in] TaskStatus New task status for the task (\ref TASK_RUN or \ref TASK_STOP). + */ + void Scheduler_SetTaskMode(const TaskPtr_t Task, + const bool TaskStatus); + + /** Sets the task mode for a given task group ID, allowing for an entire group of tasks to have their + * statuses changed at once. + * + * \param[in] GroupID Value of the task group ID whose status is to be changed. + * \param[in] TaskStatus New task status for tasks in the specified group (\ref TASK_RUN or \ref TASK_STOP). + */ + void Scheduler_SetGroupTaskMode(const uint8_t GroupID, + const bool TaskStatus); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define TOTAL_TASKS (sizeof(Scheduler_TaskList) / sizeof(TaskEntry_t)) + #define MAX_DELAYCTR_COUNT 0xFFFF + + /* Inline Functions: */ + static inline void Scheduler_InitScheduler(const uint8_t TotalTasks) ATTR_ALWAYS_INLINE; + static inline void Scheduler_InitScheduler(const uint8_t TotalTasks) + { + Scheduler_TotalTasks = TotalTasks; + } + + static inline void Scheduler_GoSchedule(const uint8_t TotalTasks) ATTR_NO_RETURN ATTR_ALWAYS_INLINE ATTR_DEPRECATED; + static inline void Scheduler_GoSchedule(const uint8_t TotalTasks) + { + Scheduler_InitScheduler(TotalTasks); + + for (;;) + { + TaskEntry_t* CurrTask = &Scheduler_TaskList[0]; + + while (CurrTask != &Scheduler_TaskList[TotalTasks]) + { + if (CurrTask->TaskStatus == TASK_RUN) + CurrTask->Task(); + + CurrTask++; + } + } + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/firmware/LUFA/Version.h b/firmware/LUFA/Version.h new file mode 100644 index 0000000..5f2434f --- /dev/null +++ b/firmware/LUFA/Version.h @@ -0,0 +1,52 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2010 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 0x101122 + + /** Indicates the version number of the library, as a string. */ + #define LUFA_VERSION_STRING "101122" + +#endif + diff --git a/firmware/LUFA/makefile b/firmware/LUFA/makefile new file mode 100644 index 0000000..511c648 --- /dev/null +++ b/firmware/LUFA/makefile @@ -0,0 +1,77 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2010. +# +# 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 = . +else + LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA +endif + +# Define module source file lists +LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Device.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Endpoint.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Host.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Pipe.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/USBController.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/USBInterrupt.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/ConfigDescriptor.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/DeviceStandardReq.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/Events.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/EndpointStream.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/HostStandardReq.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/PipeStream.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/USBTask.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDParser.c +LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/Audio.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDC.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HID.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorage.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDI.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDIS.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDC.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HID.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorage.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDI.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/Printer.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDIS.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImage.c +LUFA_SRC_TEMPERATURE = $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c +LUFA_SRC_SERIAL = $(LUFA_ROOT_PATH)/Drivers/Peripheral/Serial.c +LUFA_SRC_SERIALSTREAM = $(LUFA_ROOT_PATH)/Drivers/Peripheral/SerialStream.c +LUFA_SRC_TWI = $(LUFA_ROOT_PATH)/Drivers/Peripheral/TWI.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_SERIALSTREAM) $(LUFA_SRC_TWI) \ + $(LUFA_SRC_SCHEDULER) + + all: + + clean: + rm -f $(LUFA_SRC_ALL_FILES:%.c=%.o) + + clean_list: + + doxygen: + @echo Generating 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 + + .PHONY: all clean clean_list doxygen clean_doxygen +endif -- cgit v1.2.3