From a074364c3731d66b56d988c8a6c960a83ea0e0a1 Mon Sep 17 00:00:00 2001 From: tmk Date: Fri, 10 Apr 2015 01:32:04 +0900 Subject: [PATCH] Squashed 'tmk_core/' content from commit 05caacc git-subtree-dir: tmk_core git-subtree-split: 05caaccec92694bb24c8c3c3a9940b96efd4605c --- .gitignore | 13 + .gitmodules | 6 + README.md | 296 +++ common.mk | 77 + common/action.c | 565 +++++ common/action.h | 82 + common/action_code.h | 315 +++ common/action_layer.c | 138 ++ common/action_layer.h | 77 + common/action_macro.c | 83 + common/action_macro.h | 102 + common/action_tapping.c | 376 ++++ common/action_tapping.h | 39 + common/action_util.c | 307 +++ common/action_util.h | 66 + common/avr/bootloader.c | 148 ++ common/avr/eeconfig.c | 45 + common/avr/suspend.c | 122 ++ common/avr/suspend_avr.h | 27 + common/avr/timer.c | 117 ++ common/avr/timer_avr.h | 42 + common/avr/xprintf.S | 500 +++++ common/avr/xprintf.h | 111 + common/backlight.c | 85 + common/backlight.h | 40 + common/bootloader.h | 25 + common/bootmagic.c | 128 ++ common/bootmagic.h | 100 + common/command.c | 644 ++++++ common/command.h | 35 + common/debug.c | 24 + common/debug.h | 117 ++ common/eeconfig.h | 75 + common/host.c | 97 + common/host.h | 57 + common/host_driver.h | 33 + common/keyboard.c | 150 ++ common/keyboard.h | 72 + common/keycode.h | 489 +++++ common/keymap.c | 185 ++ common/keymap.h | 71 + common/led.h | 33 + common/matrix.h | 68 + common/mbed/bootloader.c | 4 + common/mbed/suspend.c | 6 + common/mbed/timer.c | 41 + common/mbed/xprintf.cpp | 51 + common/mbed/xprintf.h | 17 + common/mousekey.c | 196 ++ common/mousekey.h | 77 + common/nodebug.h | 25 + common/print.c | 48 + common/print.h | 137 ++ common/progmem.h | 12 + common/report.h | 183 ++ common/sendchar.h | 35 + common/sendchar_null.c | 23 + common/sendchar_uart.c | 25 + common/sleep_led.c | 95 + common/sleep_led.h | 21 + common/suspend.h | 13 + common/timer.h | 53 + common/uart.c | 129 ++ common/uart.h | 11 + common/util.c | 101 + common/util.h | 43 + common/wait.h | 20 + doc/COPYING.GPLv2 | 339 +++ doc/COPYING.GPLv3 | 674 ++++++ doc/FUSE.txt | 40 + doc/POWER.txt | 62 + doc/USB_NKRO.txt | 160 ++ doc/build.md | 186 ++ doc/keycode.txt | 261 +++ doc/keymap.md | 593 ++++++ doc/other_projects.md | 62 + ldscript_keymap_avr5.x | 268 +++ protocol.mk | 50 + protocol/adb.c | 456 +++++ protocol/adb.h | 62 + protocol/bluefruit.mk | 27 + protocol/bluefruit/bluefruit.c | 202 ++ protocol/bluefruit/bluefruit.h | 28 + protocol/bluefruit/main.c | 116 ++ protocol/ibm4704.c | 169 ++ protocol/ibm4704.h | 110 + protocol/iwrap.mk | 26 + protocol/iwrap/iWRAP4.txt | 376 ++++ protocol/iwrap/iWRAP5.txt | 356 ++++ protocol/iwrap/iwrap.c | 469 +++++ protocol/iwrap/iwrap.h | 49 + protocol/iwrap/main.c | 376 ++++ protocol/iwrap/mux_exit.rb | 7 + protocol/iwrap/suart.S | 156 ++ protocol/iwrap/suart.h | 8 + protocol/iwrap/wd.h | 159 ++ protocol/lufa.mk | 50 + .../HID_EEPROM_Loader/HID_EEPROM_Loader.c | 61 + .../LUFA/Build/HID_EEPROM_Loader/makefile | 40 + .../LUFA-120730/LUFA/Build/lufa_atprogram.mk | 101 + .../LUFA-120730/LUFA/Build/lufa_avrdude.mk | 84 + .../lufa/LUFA-120730/LUFA/Build/lufa_build.mk | 296 +++ .../lufa/LUFA-120730/LUFA/Build/lufa_core.mk | 152 ++ .../LUFA-120730/LUFA/Build/lufa_cppcheck.mk | 104 + .../lufa/LUFA-120730/LUFA/Build/lufa_dfu.mk | 93 + .../LUFA-120730/LUFA/Build/lufa_doxygen.mk | 81 + .../lufa/LUFA-120730/LUFA/Build/lufa_hid.mk | 88 + .../LUFA-120730/LUFA/Build/lufa_sources.mk | 116 ++ .../LUFA/CodeTemplates/DriverStubs/Buttons.h | 90 + .../CodeTemplates/DriverStubs/Dataflash.h | 220 ++ .../LUFA/CodeTemplates/DriverStubs/Joystick.h | 102 + .../LUFA/CodeTemplates/DriverStubs/LEDs.h | 130 ++ .../LUFA/CodeTemplates/LUFAConfig.h | 167 ++ .../LUFA/CodeTemplates/makefile_template | 36 + .../LUFA/Common/ArchitectureSpecific.h | 177 ++ .../LUFA-120730/LUFA/Common/Architectures.h | 84 + .../lufa/LUFA-120730/LUFA/Common/Attributes.h | 150 ++ .../lufa/LUFA-120730/LUFA/Common/BoardTypes.h | 231 +++ .../lufa/LUFA-120730/LUFA/Common/Common.h | 381 ++++ .../LUFA/Common/CompilerSpecific.h | 97 + .../lufa/LUFA-120730/LUFA/Common/Endianness.h | 489 +++++ protocol/lufa/LUFA-120730/LUFA/Doxygen.conf | 1809 +++++++++++++++++ .../LUFA/DoxygenPages/BuildSystem.txt | 846 ++++++++ .../BuildingLinkableLibraries.txt | 23 + .../LUFA/DoxygenPages/ChangeLog.txt | 1444 +++++++++++++ .../LUFA/DoxygenPages/CompileTimeTokens.txt | 223 ++ .../LUFA/DoxygenPages/CompilingApps.txt | 50 + .../LUFA/DoxygenPages/ConfiguringApps.txt | 104 + .../LUFA/DoxygenPages/DevelopingWithLUFA.txt | 23 + .../LUFA/DoxygenPages/DeviceSupport.txt | 432 ++++ .../LUFA/DoxygenPages/DirectorySummaries.txt | 80 + .../LUFA/DoxygenPages/Donating.txt | 24 + .../LUFA/DoxygenPages/ExportingLibrary.txt | 106 + .../LUFA/DoxygenPages/FutureChanges.txt | 49 + .../LUFA/DoxygenPages/GettingStarted.txt | 25 + .../LUFA-120730/LUFA/DoxygenPages/Groups.txt | 38 + .../AS5_AS6_Import/AS5_AS6_Import_Step1.png | Bin 0 -> 98201 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step2.png | Bin 0 -> 100532 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step3.png | Bin 0 -> 32987 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step4.png | Bin 0 -> 161824 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step5_1.png | Bin 0 -> 43666 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step5_2.png | Bin 0 -> 28918 bytes .../AS5_AS6_Import/AS5_AS6_Import_Step5_3.png | Bin 0 -> 23561 bytes .../LUFA/DoxygenPages/Images/Author.jpg | Bin 0 -> 28410 bytes .../LUFA/DoxygenPages/Images/LUFA.png | Bin 0 -> 10296 bytes .../LUFA/DoxygenPages/Images/LUFA_thumb.png | Bin 0 -> 3729 bytes .../LUFA/DoxygenPages/KnownIssues.txt | 44 + .../LUFA/DoxygenPages/LUFAPoweredProjects.txt | 181 ++ .../LUFA/DoxygenPages/LibraryResources.txt | 34 + .../LUFA/DoxygenPages/LicenseInfo.txt | 22 + .../LUFA/DoxygenPages/MainPage.txt | 52 + .../DoxygenPages/MigrationInformation.txt | 674 ++++++ .../LUFA/DoxygenPages/ProgrammingApps.txt | 30 + .../DoxygenPages/SoftwareBootloaderJump.txt | 71 + .../LUFA/DoxygenPages/Style/Footer.htm | 35 + .../LUFA/DoxygenPages/Style/Style.css | 1123 ++++++++++ .../LUFA/DoxygenPages/VIDAndPIDValues.txt | 424 ++++ .../LUFA/DoxygenPages/WritingBoardDrivers.txt | 27 + .../LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h | 135 ++ .../Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h | 103 + .../Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h | 139 ++ .../LUFA/Drivers/Board/AVR8/BENITO/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/BENITO/LEDs.h | 139 ++ .../LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h | 161 ++ .../LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h | 139 ++ .../LUFA/Drivers/Board/AVR8/BUI/LEDs.h | 143 ++ .../LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h | 105 + .../Drivers/Board/AVR8/BUMBLEB/Joystick.h | 123 ++ .../LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h | 149 ++ .../LUFA/Drivers/Board/AVR8/CULV3/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/CULV3/LEDs.h | 135 ++ .../LUFA/Drivers/Board/AVR8/DUCE/LEDs.h | 147 ++ .../LUFA/Drivers/Board/AVR8/EVK527/Buttons.h | 103 + .../Drivers/Board/AVR8/EVK527/Dataflash.h | 220 ++ .../LUFA/Drivers/Board/AVR8/EVK527/Joystick.h | 130 ++ .../LUFA/Drivers/Board/AVR8/EVK527/LEDs.h | 143 ++ .../LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h | 135 ++ .../LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h | 139 ++ .../Drivers/Board/AVR8/MICROPENDOUS/Buttons.h | 208 ++ .../Drivers/Board/AVR8/MICROPENDOUS/LEDs.h | 177 ++ .../Drivers/Board/AVR8/MICROSIN162/Buttons.h | 103 + .../Drivers/Board/AVR8/MICROSIN162/LEDs.h | 135 ++ .../LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h | 143 ++ .../LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h | 161 ++ .../Drivers/Board/AVR8/OLIMEX162/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h | 135 ++ .../Drivers/Board/AVR8/OLIMEX32U4/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h | 179 ++ .../Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h | 103 + .../Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h | 143 ++ .../Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h | 103 + .../Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h | 169 ++ .../LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h | 175 ++ .../Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h | 135 ++ .../LUFA/Drivers/Board/AVR8/STK525/Buttons.h | 103 + .../Drivers/Board/AVR8/STK525/Dataflash.h | 220 ++ .../LUFA/Drivers/Board/AVR8/STK525/Joystick.h | 130 ++ .../LUFA/Drivers/Board/AVR8/STK525/LEDs.h | 147 ++ .../LUFA/Drivers/Board/AVR8/STK526/Buttons.h | 103 + .../Drivers/Board/AVR8/STK526/Dataflash.h | 220 ++ .../LUFA/Drivers/Board/AVR8/STK526/Joystick.h | 123 ++ .../LUFA/Drivers/Board/AVR8/STK526/LEDs.h | 147 ++ .../LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h | 176 ++ .../LUFA/Drivers/Board/AVR8/TUL/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/TUL/LEDs.h | 135 ++ .../LUFA/Drivers/Board/AVR8/UDIP/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/UDIP/LEDs.h | 163 ++ .../LUFA/Drivers/Board/AVR8/UNO/LEDs.h | 139 ++ .../LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h | 113 + .../LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h | 196 ++ .../LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h | 103 + .../LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h | 135 ++ .../LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h | 103 + .../Drivers/Board/AVR8/USBKEY/Dataflash.h | 229 +++ .../LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h | 130 ++ .../LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h | 147 ++ .../Drivers/Board/AVR8/USBTINYMKII/Buttons.h | 103 + .../Drivers/Board/AVR8/USBTINYMKII/LEDs.h | 143 ++ .../Drivers/Board/AVR8/XPLAIN/Dataflash.h | 243 +++ .../LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h | 142 ++ .../LUFA-120730/LUFA/Drivers/Board/Buttons.h | 178 ++ .../LUFA/Drivers/Board/Dataflash.h | 252 +++ .../LUFA-120730/LUFA/Drivers/Board/Joystick.h | 144 ++ .../LUFA-120730/LUFA/Drivers/Board/LEDs.h | 274 +++ .../LUFA/Drivers/Board/Temperature.c | 66 + .../LUFA/Drivers/Board/Temperature.h | 147 ++ .../LUFA/Drivers/Board/UC3/EVK1100/Buttons.h | 117 ++ .../LUFA/Drivers/Board/UC3/EVK1100/Joystick.h | 122 ++ .../LUFA/Drivers/Board/UC3/EVK1100/LEDs.h | 173 ++ .../LUFA/Drivers/Board/UC3/EVK1101/Buttons.h | 113 + .../LUFA/Drivers/Board/UC3/EVK1101/Joystick.h | 131 ++ .../LUFA/Drivers/Board/UC3/EVK1101/LEDs.h | 156 ++ .../LUFA/Drivers/Board/UC3/EVK1104/Buttons.h | 109 + .../LUFA/Drivers/Board/UC3/EVK1104/LEDs.h | 174 ++ .../Board/XMEGA/A3BU_XPLAINED/Buttons.h | 119 ++ .../Board/XMEGA/A3BU_XPLAINED/Dataflash.h | 222 ++ .../Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h | 144 ++ .../Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h | 119 ++ .../Board/XMEGA/B1_XPLAINED/Dataflash.h | 224 ++ .../Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h | 182 ++ .../LUFA/Drivers/Misc/AT45DB321C.h | 100 + .../LUFA/Drivers/Misc/AT45DB642D.h | 116 ++ .../LUFA/Drivers/Misc/RingBuffer.h | 303 +++ .../LUFA/Drivers/Misc/TerminalCodes.h | 231 +++ .../LUFA-120730/LUFA/Drivers/Peripheral/ADC.h | 75 + .../LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h | 456 +++++ .../LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h | 256 +++ .../Drivers/Peripheral/AVR8/SerialSPI_AVR8.h | 200 ++ .../Drivers/Peripheral/AVR8/Serial_AVR8.c | 119 ++ .../Drivers/Peripheral/AVR8/Serial_AVR8.h | 239 +++ .../LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c | 207 ++ .../LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h | 304 +++ .../LUFA-120730/LUFA/Drivers/Peripheral/SPI.h | 76 + .../LUFA/Drivers/Peripheral/Serial.h | 76 + .../LUFA/Drivers/Peripheral/SerialSPI.h | 76 + .../LUFA-120730/LUFA/Drivers/Peripheral/TWI.h | 74 + .../LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h | 248 +++ .../Peripheral/XMEGA/SerialSPI_XMEGA.h | 203 ++ .../Drivers/Peripheral/XMEGA/Serial_XMEGA.c | 122 ++ .../Drivers/Peripheral/XMEGA/Serial_XMEGA.h | 252 +++ .../Drivers/USB/Class/AndroidAccessoryClass.h | 76 + .../LUFA/Drivers/USB/Class/AudioClass.h | 80 + .../LUFA/Drivers/USB/Class/CDCClass.h | 80 + .../Common/AndroidAccessoryClassCommon.h | 128 ++ .../USB/Class/Common/AudioClassCommon.h | 774 +++++++ .../Drivers/USB/Class/Common/CDCClassCommon.h | 386 ++++ .../Drivers/USB/Class/Common/HIDClassCommon.h | 655 ++++++ .../LUFA/Drivers/USB/Class/Common/HIDParser.c | 363 ++++ .../LUFA/Drivers/USB/Class/Common/HIDParser.h | 364 ++++ .../Drivers/USB/Class/Common/HIDReportData.h | 126 ++ .../USB/Class/Common/MIDIClassCommon.h | 320 +++ .../USB/Class/Common/MassStorageClassCommon.h | 365 ++++ .../USB/Class/Common/PrinterClassCommon.h | 119 ++ .../USB/Class/Common/RNDISClassCommon.h | 414 ++++ .../USB/Class/Common/StillImageClassCommon.h | 161 ++ .../USB/Class/Device/AudioClassDevice.c | 198 ++ .../USB/Class/Device/AudioClassDevice.h | 396 ++++ .../Drivers/USB/Class/Device/CDCClassDevice.c | 339 +++ .../Drivers/USB/Class/Device/CDCClassDevice.h | 352 ++++ .../Drivers/USB/Class/Device/HIDClassDevice.c | 200 ++ .../Drivers/USB/Class/Device/HIDClassDevice.h | 210 ++ .../USB/Class/Device/MIDIClassDevice.c | 125 ++ .../USB/Class/Device/MIDIClassDevice.h | 175 ++ .../USB/Class/Device/MassStorageClassDevice.c | 215 ++ .../USB/Class/Device/MassStorageClassDevice.h | 161 ++ .../USB/Class/Device/RNDISClassDevice.c | 502 +++++ .../USB/Class/Device/RNDISClassDevice.h | 203 ++ .../LUFA/Drivers/USB/Class/HIDClass.h | 81 + .../Class/Host/AndroidAccessoryClassHost.c | 422 ++++ .../Class/Host/AndroidAccessoryClassHost.h | 314 +++ .../Drivers/USB/Class/Host/AudioClassHost.c | 223 ++ .../Drivers/USB/Class/Host/AudioClassHost.h | 411 ++++ .../Drivers/USB/Class/Host/CDCClassHost.c | 478 +++++ .../Drivers/USB/Class/Host/CDCClassHost.h | 351 ++++ .../Drivers/USB/Class/Host/HIDClassHost.c | 396 ++++ .../Drivers/USB/Class/Host/HIDClassHost.h | 313 +++ .../Drivers/USB/Class/Host/MIDIClassHost.c | 231 +++ .../Drivers/USB/Class/Host/MIDIClassHost.h | 190 ++ .../USB/Class/Host/MassStorageClassHost.c | 579 ++++++ .../USB/Class/Host/MassStorageClassHost.h | 335 +++ .../Drivers/USB/Class/Host/PrinterClassHost.c | 400 ++++ .../Drivers/USB/Class/Host/PrinterClassHost.h | 285 +++ .../Drivers/USB/Class/Host/RNDISClassHost.c | 476 +++++ .../Drivers/USB/Class/Host/RNDISClassHost.h | 270 +++ .../USB/Class/Host/StillImageClassHost.c | 436 ++++ .../USB/Class/Host/StillImageClassHost.h | 317 +++ .../LUFA/Drivers/USB/Class/MIDIClass.h | 83 + .../LUFA/Drivers/USB/Class/MassStorageClass.h | 80 + .../LUFA/Drivers/USB/Class/PrinterClass.h | 77 + .../LUFA/Drivers/USB/Class/RNDISClass.h | 80 + .../LUFA/Drivers/USB/Class/StillImageClass.h | 75 + .../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c | 57 + .../LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 264 +++ .../USB/Core/AVR8/EndpointStream_AVR8.c | 275 +++ .../USB/Core/AVR8/EndpointStream_AVR8.h | 648 ++++++ .../Drivers/USB/Core/AVR8/Endpoint_AVR8.c | 201 ++ .../Drivers/USB/Core/AVR8/Endpoint_AVR8.h | 819 ++++++++ .../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 294 +++ .../LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | 372 ++++ .../LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h | 159 ++ .../Drivers/USB/Core/AVR8/PipeStream_AVR8.c | 221 ++ .../Drivers/USB/Core/AVR8/PipeStream_AVR8.h | 442 ++++ .../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c | 210 ++ .../LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h | 921 +++++++++ .../Template/Template_Endpoint_Control_R.c | 85 + .../Template/Template_Endpoint_Control_W.c | 94 + .../Core/AVR8/Template/Template_Endpoint_RW.c | 90 + .../USB/Core/AVR8/Template/Template_Pipe_RW.c | 89 + .../USB/Core/AVR8/USBController_AVR8.c | 265 +++ .../USB/Core/AVR8/USBController_AVR8.h | 436 ++++ .../Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c | 279 +++ .../Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h | 369 ++++ .../LUFA/Drivers/USB/Core/ConfigDescriptors.c | 146 ++ .../LUFA/Drivers/USB/Core/ConfigDescriptors.h | 286 +++ .../LUFA/Drivers/USB/Core/Device.h | 159 ++ .../LUFA/Drivers/USB/Core/DeviceStandardReq.c | 378 ++++ .../LUFA/Drivers/USB/Core/DeviceStandardReq.h | 158 ++ .../LUFA/Drivers/USB/Core/Endpoint.h | 130 ++ .../LUFA/Drivers/USB/Core/EndpointStream.h | 124 ++ .../LUFA/Drivers/USB/Core/Events.c | 40 + .../LUFA/Drivers/USB/Core/Events.h | 366 ++++ .../LUFA-120730/LUFA/Drivers/USB/Core/Host.h | 139 ++ .../LUFA/Drivers/USB/Core/HostStandardReq.c | 322 +++ .../LUFA/Drivers/USB/Core/HostStandardReq.h | 292 +++ .../LUFA-120730/LUFA/Drivers/USB/Core/OTG.h | 80 + .../LUFA-120730/LUFA/Drivers/USB/Core/Pipe.h | 144 ++ .../LUFA/Drivers/USB/Core/PipeStream.h | 100 + .../LUFA/Drivers/USB/Core/StdDescriptors.h | 739 +++++++ .../LUFA/Drivers/USB/Core/StdRequestType.h | 258 +++ .../LUFA/Drivers/USB/Core/UC3/Device_UC3.c | 51 + .../LUFA/Drivers/USB/Core/UC3/Device_UC3.h | 260 +++ .../Drivers/USB/Core/UC3/EndpointStream_UC3.c | 235 +++ .../Drivers/USB/Core/UC3/EndpointStream_UC3.h | 434 ++++ .../LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c | 196 ++ .../LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h | 795 ++++++++ .../LUFA/Drivers/USB/Core/UC3/Host_UC3.c | 294 +++ .../LUFA/Drivers/USB/Core/UC3/Host_UC3.h | 363 ++++ .../Drivers/USB/Core/UC3/PipeStream_UC3.c | 166 ++ .../Drivers/USB/Core/UC3/PipeStream_UC3.h | 352 ++++ .../LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c | 209 ++ .../LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h | 924 +++++++++ .../Template/Template_Endpoint_Control_R.c | 85 + .../Template/Template_Endpoint_Control_W.c | 94 + .../Core/UC3/Template/Template_Endpoint_RW.c | 90 + .../USB/Core/UC3/Template/Template_Pipe_RW.c | 89 + .../Drivers/USB/Core/UC3/USBController_UC3.c | 222 ++ .../Drivers/USB/Core/UC3/USBController_UC3.h | 365 ++++ .../Drivers/USB/Core/UC3/USBInterrupt_UC3.c | 228 +++ .../Drivers/USB/Core/UC3/USBInterrupt_UC3.h | 370 ++++ .../LUFA/Drivers/USB/Core/USBController.h | 151 ++ .../LUFA/Drivers/USB/Core/USBInterrupt.h | 73 + .../LUFA/Drivers/USB/Core/USBMode.h | 286 +++ .../LUFA/Drivers/USB/Core/USBTask.c | 91 + .../LUFA/Drivers/USB/Core/USBTask.h | 204 ++ .../Drivers/USB/Core/XMEGA/Device_XMEGA.c | 49 + .../Drivers/USB/Core/XMEGA/Device_XMEGA.h | 258 +++ .../USB/Core/XMEGA/EndpointStream_XMEGA.c | 275 +++ .../USB/Core/XMEGA/EndpointStream_XMEGA.h | 648 ++++++ .../Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c | 168 ++ .../Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h | 777 +++++++ .../LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c | 41 + .../Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c | 41 + .../LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c | 37 + .../Template/Template_Endpoint_Control_R.c | 87 + .../Template/Template_Endpoint_Control_W.c | 96 + .../XMEGA/Template/Template_Endpoint_RW.c | 90 + .../USB/Core/XMEGA/USBController_XMEGA.c | 189 ++ .../USB/Core/XMEGA/USBController_XMEGA.h | 313 +++ .../USB/Core/XMEGA/USBInterrupt_XMEGA.c | 106 + .../USB/Core/XMEGA/USBInterrupt_XMEGA.h | 166 ++ .../lufa/LUFA-120730/LUFA/Drivers/USB/USB.h | 418 ++++ protocol/lufa/LUFA-120730/LUFA/License.txt | 24 + .../lufa/LUFA-120730/LUFA/Platform/Platform.h | 80 + .../LUFA/Platform/UC3/ClockManagement.h | 338 +++ .../LUFA-120730/LUFA/Platform/UC3/Exception.S | 128 ++ .../LUFA/Platform/UC3/InterruptManagement.c | 68 + .../LUFA/Platform/UC3/InterruptManagement.h | 163 ++ .../LUFA/Platform/XMEGA/ClockManagement.h | 397 ++++ protocol/lufa/LUFA-120730/LUFA/Version.h | 52 + protocol/lufa/LUFA-120730/LUFA/makefile | 50 + protocol/lufa/LUFA-120730/README.txt | 56 + protocol/lufa/LUFA-git | 1 + protocol/lufa/descriptor.c | 630 ++++++ protocol/lufa/descriptor.h | 176 ++ protocol/lufa/lufa.c | 605 ++++++ protocol/lufa/lufa.h | 80 + protocol/m0110.c | 591 ++++++ protocol/m0110.h | 92 + protocol/mbed/HIDKeyboard.cpp | 271 +++ protocol/mbed/HIDKeyboard.h | 31 + protocol/mbed/mbed_driver.cpp | 41 + protocol/mbed/mbed_driver.h | 3 + protocol/news.c | 168 ++ protocol/news.h | 51 + protocol/next_kbd.c | 204 ++ protocol/next_kbd.h | 63 + protocol/pjrc.mk | 26 + protocol/pjrc/MEMO.txt | 25 + protocol/pjrc/main.c | 72 + protocol/pjrc/pjrc.c | 76 + protocol/pjrc/pjrc.h | 26 + protocol/pjrc/usb.c | 1002 +++++++++ protocol/pjrc/usb.h | 137 ++ protocol/pjrc/usb_debug.c | 102 + protocol/pjrc/usb_debug.h | 42 + protocol/pjrc/usb_extra.c | 70 + protocol/pjrc/usb_extra.h | 46 + protocol/pjrc/usb_keyboard.c | 110 + protocol/pjrc/usb_keyboard.h | 40 + protocol/pjrc/usb_mouse.c | 81 + protocol/pjrc/usb_mouse.h | 50 + protocol/ps2.h | 134 ++ protocol/ps2_busywait.c | 189 ++ protocol/ps2_interrupt.c | 279 +++ protocol/ps2_io.h | 15 + protocol/ps2_io_avr.c | 75 + protocol/ps2_io_mbed.c | 60 + protocol/ps2_mouse.c | 220 ++ protocol/ps2_mouse.h | 66 + protocol/ps2_usart.c | 223 ++ protocol/serial.h | 47 + protocol/serial_mouse.h | 33 + protocol/serial_mouse_microsoft.c | 124 ++ protocol/serial_mouse_mousesystems.c | 131 ++ protocol/serial_soft.c | 240 +++ protocol/serial_uart.c | 112 + protocol/usb_hid.mk | 74 + protocol/usb_hid/README | 47 + protocol/usb_hid/USB_Host_Shield_2.0 | 1 + .../arduino-1.0.1/cores/arduino/Arduino.h | 215 ++ .../arduino-1.0.1/cores/arduino/CDC.cpp | 233 +++ .../arduino-1.0.1/cores/arduino/Client.h | 26 + .../arduino-1.0.1/cores/arduino/HID.cpp | 520 +++++ .../cores/arduino/HardwareSerial.cpp | 428 ++++ .../cores/arduino/HardwareSerial.h | 81 + .../arduino-1.0.1/cores/arduino/IPAddress.cpp | 56 + .../arduino-1.0.1/cores/arduino/IPAddress.h | 76 + .../arduino-1.0.1/cores/arduino/Platform.h | 23 + .../arduino-1.0.1/cores/arduino/Print.cpp | 263 +++ .../arduino-1.0.1/cores/arduino/Print.h | 78 + .../arduino-1.0.1/cores/arduino/Printable.h | 40 + .../arduino-1.0.1/cores/arduino/Server.h | 9 + .../arduino-1.0.1/cores/arduino/Stream.cpp | 270 +++ .../arduino-1.0.1/cores/arduino/Stream.h | 96 + .../arduino-1.0.1/cores/arduino/Tone.cpp | 601 ++++++ .../arduino-1.0.1/cores/arduino/USBAPI.h | 195 ++ .../arduino-1.0.1/cores/arduino/USBCore.cpp | 672 ++++++ .../arduino-1.0.1/cores/arduino/USBCore.h | 303 +++ .../arduino-1.0.1/cores/arduino/USBDesc.h | 63 + .../usb_hid/arduino-1.0.1/cores/arduino/Udp.h | 88 + .../arduino-1.0.1/cores/arduino/WCharacter.h | 168 ++ .../arduino-1.0.1/cores/arduino/WInterrupts.c | 298 +++ .../arduino-1.0.1/cores/arduino/WMath.cpp | 60 + .../arduino-1.0.1/cores/arduino/WString.cpp | 645 ++++++ .../arduino-1.0.1/cores/arduino/WString.h | 205 ++ .../arduino-1.0.1/cores/arduino/binary.h | 515 +++++ .../arduino-1.0.1/cores/arduino/main.cpp | 20 + .../arduino-1.0.1/cores/arduino/new.cpp | 18 + .../usb_hid/arduino-1.0.1/cores/arduino/new.h | 22 + .../arduino-1.0.1/cores/arduino/wiring.c | 324 +++ .../cores/arduino/wiring_analog.c | 282 +++ .../cores/arduino/wiring_digital.c | 178 ++ .../cores/arduino/wiring_private.h | 69 + .../cores/arduino/wiring_pulse.c | 69 + .../cores/arduino/wiring_shift.c | 55 + .../variants/eightanaloginputs/pins_arduino.h | 27 + .../variants/leonardo/pins_arduino.h | 256 +++ .../variants/mega/pins_arduino.h | 363 ++++ .../variants/standard/pins_arduino.h | 218 ++ protocol/usb_hid/leonardo_led.h | 10 + protocol/usb_hid/override_Serial.cpp | 51 + protocol/usb_hid/override_wiring.c | 29 + protocol/usb_hid/parser.cpp | 24 + protocol/usb_hid/parser.h | 12 + protocol/usb_hid/test/Makefile | 126 ++ protocol/usb_hid/test/config.h | 40 + protocol/usb_hid/test/test.cpp | 92 + protocol/usb_hid/usb_hid.h | 10 + protocol/vusb.mk | 21 + protocol/vusb/main.c | 100 + protocol/vusb/sendchar_usart.c | 23 + protocol/vusb/usbdrv/Changelog.txt | 308 +++ protocol/vusb/usbdrv/CommercialLicense.txt | 166 ++ protocol/vusb/usbdrv/License.txt | 361 ++++ protocol/vusb/usbdrv/Readme.txt | 172 ++ protocol/vusb/usbdrv/USB-ID-FAQ.txt | 149 ++ protocol/vusb/usbdrv/USB-IDs-for-free.txt | 148 ++ protocol/vusb/usbdrv/asmcommon.inc | 188 ++ protocol/vusb/usbdrv/oddebug.c | 50 + protocol/vusb/usbdrv/oddebug.h | 123 ++ protocol/vusb/usbdrv/usbconfig-prototype.h | 376 ++++ protocol/vusb/usbdrv/usbdrv.c | 625 ++++++ protocol/vusb/usbdrv/usbdrv.h | 735 +++++++ protocol/vusb/usbdrv/usbdrvasm.S | 393 ++++ protocol/vusb/usbdrv/usbdrvasm.asm | 21 + protocol/vusb/usbdrv/usbdrvasm12.inc | 393 ++++ protocol/vusb/usbdrv/usbdrvasm128.inc | 750 +++++++ protocol/vusb/usbdrv/usbdrvasm15.inc | 423 ++++ protocol/vusb/usbdrv/usbdrvasm16.inc | 346 ++++ protocol/vusb/usbdrv/usbdrvasm165.inc | 453 +++++ protocol/vusb/usbdrv/usbdrvasm18-crc.inc | 707 +++++++ protocol/vusb/usbdrv/usbdrvasm20.inc | 360 ++++ protocol/vusb/usbdrv/usbportability.h | 144 ++ protocol/vusb/vusb.c | 496 +++++ protocol/vusb/vusb.h | 27 + rules.mk | 619 ++++++ tool/mbed/common.mk | 81 + tool/mbed/gcc.mk | 89 + tool/mbed/lpc-vector-checksum.c | 99 + tool/mbed/lpc11u35_501.mk | 50 + tool/mbed/mbed.mk | 85 + 533 files changed, 102049 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100644 common.mk create mode 100644 common/action.c create mode 100644 common/action.h create mode 100644 common/action_code.h create mode 100644 common/action_layer.c create mode 100644 common/action_layer.h create mode 100644 common/action_macro.c create mode 100644 common/action_macro.h create mode 100644 common/action_tapping.c create mode 100644 common/action_tapping.h create mode 100644 common/action_util.c create mode 100644 common/action_util.h create mode 100644 common/avr/bootloader.c create mode 100644 common/avr/eeconfig.c create mode 100644 common/avr/suspend.c create mode 100644 common/avr/suspend_avr.h create mode 100644 common/avr/timer.c create mode 100644 common/avr/timer_avr.h create mode 100644 common/avr/xprintf.S create mode 100644 common/avr/xprintf.h create mode 100644 common/backlight.c create mode 100644 common/backlight.h create mode 100644 common/bootloader.h create mode 100644 common/bootmagic.c create mode 100644 common/bootmagic.h create mode 100644 common/command.c create mode 100644 common/command.h create mode 100644 common/debug.c create mode 100644 common/debug.h create mode 100644 common/eeconfig.h create mode 100644 common/host.c create mode 100644 common/host.h create mode 100644 common/host_driver.h create mode 100644 common/keyboard.c create mode 100644 common/keyboard.h create mode 100644 common/keycode.h create mode 100644 common/keymap.c create mode 100644 common/keymap.h create mode 100644 common/led.h create mode 100644 common/matrix.h create mode 100644 common/mbed/bootloader.c create mode 100644 common/mbed/suspend.c create mode 100644 common/mbed/timer.c create mode 100644 common/mbed/xprintf.cpp create mode 100644 common/mbed/xprintf.h create mode 100644 common/mousekey.c create mode 100644 common/mousekey.h create mode 100644 common/nodebug.h create mode 100644 common/print.c create mode 100644 common/print.h create mode 100644 common/progmem.h create mode 100644 common/report.h create mode 100644 common/sendchar.h create mode 100644 common/sendchar_null.c create mode 100644 common/sendchar_uart.c create mode 100644 common/sleep_led.c create mode 100644 common/sleep_led.h create mode 100644 common/suspend.h create mode 100644 common/timer.h create mode 100644 common/uart.c create mode 100644 common/uart.h create mode 100644 common/util.c create mode 100644 common/util.h create mode 100644 common/wait.h create mode 100644 doc/COPYING.GPLv2 create mode 100644 doc/COPYING.GPLv3 create mode 100644 doc/FUSE.txt create mode 100644 doc/POWER.txt create mode 100644 doc/USB_NKRO.txt create mode 100644 doc/build.md create mode 100644 doc/keycode.txt create mode 100644 doc/keymap.md create mode 100644 doc/other_projects.md create mode 100644 ldscript_keymap_avr5.x create mode 100644 protocol.mk create mode 100644 protocol/adb.c create mode 100644 protocol/adb.h create mode 100644 protocol/bluefruit.mk create mode 100644 protocol/bluefruit/bluefruit.c create mode 100644 protocol/bluefruit/bluefruit.h create mode 100644 protocol/bluefruit/main.c create mode 100644 protocol/ibm4704.c create mode 100644 protocol/ibm4704.h create mode 100644 protocol/iwrap.mk create mode 100644 protocol/iwrap/iWRAP4.txt create mode 100644 protocol/iwrap/iWRAP5.txt create mode 100644 protocol/iwrap/iwrap.c create mode 100644 protocol/iwrap/iwrap.h create mode 100644 protocol/iwrap/main.c create mode 100644 protocol/iwrap/mux_exit.rb create mode 100644 protocol/iwrap/suart.S create mode 100644 protocol/iwrap/suart.h create mode 100644 protocol/iwrap/wd.h create mode 100644 protocol/lufa.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/HID_EEPROM_Loader/HID_EEPROM_Loader.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/HID_EEPROM_Loader/makefile create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_atprogram.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_avrdude.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_build.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_core.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_cppcheck.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_dfu.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_doxygen.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_hid.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/Build/lufa_sources.mk create mode 100644 protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/CodeTemplates/LUFAConfig.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/CodeTemplates/makefile_template create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/ArchitectureSpecific.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/Architectures.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/Attributes.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/BoardTypes.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/Common.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/CompilerSpecific.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Common/Endianness.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Doxygen.conf create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildSystem.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildingLinkableLibraries.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ChangeLog.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompileTimeTokens.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompilingApps.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ConfiguringApps.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DevelopingWithLUFA.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DeviceSupport.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DirectorySummaries.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Donating.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ExportingLibrary.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/FutureChanges.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/GettingStarted.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Groups.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step1.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step2.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step3.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step4.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_1.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_2.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_3.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/Author.jpg create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/LUFA.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/LUFA_thumb.png create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/KnownIssues.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LUFAPoweredProjects.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LibraryResources.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LicenseInfo.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MainPage.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MigrationInformation.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ProgrammingApps.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/SoftwareBootloaderJump.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Footer.htm create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Style.css create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/VIDAndPIDValues.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/DoxygenPages/WritingBoardDrivers.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUI/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/DUCE/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UNO/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Joystick.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB321C.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB642D.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/RingBuffer.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/TerminalCodes.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/ADC.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SerialSPI_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SPI.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/Serial.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SerialSPI.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/TWI.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SerialSPI_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AndroidAccessoryClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AudioClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/CDCClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDReportData.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/HIDClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MIDIClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MassStorageClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/PrinterClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/RNDISClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/StillImageClass.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Device.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Endpoint.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/EndpointStream.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Host.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/OTG.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Pipe.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/PipeStream.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdDescriptors.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdRequestType.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_R.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_RW.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Pipe_RW.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBController.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBInterrupt.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBMode.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_R.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_RW.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Drivers/USB/USB.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/License.txt create mode 100644 protocol/lufa/LUFA-120730/LUFA/Platform/Platform.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Platform/UC3/ClockManagement.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Platform/UC3/Exception.S create mode 100644 protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.c create mode 100644 protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Platform/XMEGA/ClockManagement.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/Version.h create mode 100644 protocol/lufa/LUFA-120730/LUFA/makefile create mode 100644 protocol/lufa/LUFA-120730/README.txt create mode 160000 protocol/lufa/LUFA-git create mode 100644 protocol/lufa/descriptor.c create mode 100644 protocol/lufa/descriptor.h create mode 100644 protocol/lufa/lufa.c create mode 100644 protocol/lufa/lufa.h create mode 100644 protocol/m0110.c create mode 100644 protocol/m0110.h create mode 100644 protocol/mbed/HIDKeyboard.cpp create mode 100644 protocol/mbed/HIDKeyboard.h create mode 100644 protocol/mbed/mbed_driver.cpp create mode 100644 protocol/mbed/mbed_driver.h create mode 100644 protocol/news.c create mode 100644 protocol/news.h create mode 100644 protocol/next_kbd.c create mode 100644 protocol/next_kbd.h create mode 100644 protocol/pjrc.mk create mode 100644 protocol/pjrc/MEMO.txt create mode 100644 protocol/pjrc/main.c create mode 100644 protocol/pjrc/pjrc.c create mode 100644 protocol/pjrc/pjrc.h create mode 100644 protocol/pjrc/usb.c create mode 100644 protocol/pjrc/usb.h create mode 100644 protocol/pjrc/usb_debug.c create mode 100644 protocol/pjrc/usb_debug.h create mode 100644 protocol/pjrc/usb_extra.c create mode 100644 protocol/pjrc/usb_extra.h create mode 100644 protocol/pjrc/usb_keyboard.c create mode 100644 protocol/pjrc/usb_keyboard.h create mode 100644 protocol/pjrc/usb_mouse.c create mode 100644 protocol/pjrc/usb_mouse.h create mode 100644 protocol/ps2.h create mode 100644 protocol/ps2_busywait.c create mode 100644 protocol/ps2_interrupt.c create mode 100644 protocol/ps2_io.h create mode 100644 protocol/ps2_io_avr.c create mode 100644 protocol/ps2_io_mbed.c create mode 100644 protocol/ps2_mouse.c create mode 100644 protocol/ps2_mouse.h create mode 100644 protocol/ps2_usart.c create mode 100644 protocol/serial.h create mode 100644 protocol/serial_mouse.h create mode 100644 protocol/serial_mouse_microsoft.c create mode 100644 protocol/serial_mouse_mousesystems.c create mode 100644 protocol/serial_soft.c create mode 100644 protocol/serial_uart.c create mode 100644 protocol/usb_hid.mk create mode 100644 protocol/usb_hid/README create mode 160000 protocol/usb_hid/USB_Host_Shield_2.0 create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Arduino.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/CDC.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Client.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/HID.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Platform.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Printable.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Server.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Tone.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/USBAPI.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/USBCore.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/USBCore.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/USBDesc.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/Udp.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/WCharacter.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/WInterrupts.c create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/WMath.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/binary.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/main.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/new.cpp create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/new.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring.c create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_analog.c create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_digital.c create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_private.h create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_pulse.c create mode 100644 protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_shift.c create mode 100644 protocol/usb_hid/arduino-1.0.1/variants/eightanaloginputs/pins_arduino.h create mode 100644 protocol/usb_hid/arduino-1.0.1/variants/leonardo/pins_arduino.h create mode 100644 protocol/usb_hid/arduino-1.0.1/variants/mega/pins_arduino.h create mode 100644 protocol/usb_hid/arduino-1.0.1/variants/standard/pins_arduino.h create mode 100644 protocol/usb_hid/leonardo_led.h create mode 100644 protocol/usb_hid/override_Serial.cpp create mode 100644 protocol/usb_hid/override_wiring.c create mode 100644 protocol/usb_hid/parser.cpp create mode 100644 protocol/usb_hid/parser.h create mode 100644 protocol/usb_hid/test/Makefile create mode 100644 protocol/usb_hid/test/config.h create mode 100644 protocol/usb_hid/test/test.cpp create mode 100644 protocol/usb_hid/usb_hid.h create mode 100644 protocol/vusb.mk create mode 100644 protocol/vusb/main.c create mode 100644 protocol/vusb/sendchar_usart.c create mode 100644 protocol/vusb/usbdrv/Changelog.txt create mode 100644 protocol/vusb/usbdrv/CommercialLicense.txt create mode 100644 protocol/vusb/usbdrv/License.txt create mode 100644 protocol/vusb/usbdrv/Readme.txt create mode 100644 protocol/vusb/usbdrv/USB-ID-FAQ.txt create mode 100644 protocol/vusb/usbdrv/USB-IDs-for-free.txt create mode 100644 protocol/vusb/usbdrv/asmcommon.inc create mode 100644 protocol/vusb/usbdrv/oddebug.c create mode 100644 protocol/vusb/usbdrv/oddebug.h create mode 100644 protocol/vusb/usbdrv/usbconfig-prototype.h create mode 100644 protocol/vusb/usbdrv/usbdrv.c create mode 100644 protocol/vusb/usbdrv/usbdrv.h create mode 100644 protocol/vusb/usbdrv/usbdrvasm.S create mode 100644 protocol/vusb/usbdrv/usbdrvasm.asm create mode 100644 protocol/vusb/usbdrv/usbdrvasm12.inc create mode 100644 protocol/vusb/usbdrv/usbdrvasm128.inc create mode 100644 protocol/vusb/usbdrv/usbdrvasm15.inc create mode 100644 protocol/vusb/usbdrv/usbdrvasm16.inc create mode 100644 protocol/vusb/usbdrv/usbdrvasm165.inc create mode 100644 protocol/vusb/usbdrv/usbdrvasm18-crc.inc create mode 100644 protocol/vusb/usbdrv/usbdrvasm20.inc create mode 100644 protocol/vusb/usbdrv/usbportability.h create mode 100644 protocol/vusb/vusb.c create mode 100644 protocol/vusb/vusb.h create mode 100644 rules.mk create mode 100644 tool/mbed/common.mk create mode 100644 tool/mbed/gcc.mk create mode 100644 tool/mbed/lpc-vector-checksum.c create mode 100644 tool/mbed/lpc11u35_501.mk create mode 100644 tool/mbed/mbed.mk diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..f3f46872a --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +.dep +*.o +*.eep +*.elf +*.hex +*.lss +*.lst +*.map +*.sym +tags +*~ +build/ +*.bak diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..e21f44961 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "protocol/lufa/LUFA-git"] + path = protocol/lufa/LUFA-git + url = https://github.com/abcminiuser/lufa.git +[submodule "protocol/usb_hid/USB_Host_Shield_2.0"] + path = protocol/usb_hid/USB_Host_Shield_2.0 + url = https://github.com/felis/USB_Host_Shield_2.0.git diff --git a/README.md b/README.md new file mode 100644 index 000000000..dd03e1403 --- /dev/null +++ b/README.md @@ -0,0 +1,296 @@ +TMK Keyboard Firmware Collection +================================ +This is a keyboard firmware with some useful features for Atmel AVR controller. + +Source code is available here: + + +Features +-------- +These features can be used in your keyboard. + +* Multi-layer Keymap - Multiple keyboard layouts with layer switching +* Mouse key - Mouse control with keyboard +* System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up +* Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc +* USB NKRO - 120 keys(+ 8 modifiers) simultaneously +* PS/2 mouse support - PS/2 mouse(TrackPoint) as composite device +* Keyboard protocols - PS/2, ADB, M0110, Sun and other old keyboard protocols +* User Function - Customizable function of key with writing code +* Macro - Very primitive at this time +* Keyboard Tricks - Oneshot modifier and modifier with tapping feature +* Debug Console - Messages for debug and interaction with firmware +* Virtual DIP Switch - Configurations stored EEPROM(Boot Magic) +* Locking CapsLock - Mechanical switch support for CapsLock +* Breathing Sleep LED - Sleep indicator with charm during USB suspend +* Backlight - Control backlight levels + + +Projects +-------- +You can find some keyboard specific projects under `converter` and `keyboard` directory. + +### converter +* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2] +* [adb_usb](converter/adb_usb/) - [ADB keyboard to USB][GH_adb] +* [m0110_usb](converter/m0110_usb) - [Macintosh 128K/512K/Plus keyboard to USB][GH_m0110] +* [terminal_usb](converter/terminal_usb/) - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal] +* [news_usb](converter/news_usb/) - [Sony NEWS keyboard to USB][GH_news] +* [x68k_usb](converter/x68k_usb/) - [Sharp X68000 keyboard to USB][GH_x68k] +* [sun_usb](converter/sun_usb/) - [Sun] to USB(type4, 5 and 3?) +* [pc98_usb](converter/pc98_usb/) - [PC98] to USB +* [usb_usb](converter/usb_usb/) - USB to USB(experimental) +* [ascii_usb](converter/ascii_usb/) - ASCII(Serial console terminal) to USB +* [ibm4704_usb](converter/ibm4704_usb) - [IBM 4704 keyboard Converter][GH_ibm4704] + +### keyboard +* [hhkb](keyboard/hhkb/) - [Happy Hacking Keyboard pro][GH_hhkb] **my main board** +* [gh60](keyboard/gh60/) - [GH60] DIY 60% keyboard [prototype][GH60_proto] **my second board** +* [hbkb](keyboard/hbkb/) - [Happy Buckling spring keyboard][GH_hbkb](IBM Model M 60% mod) +* [hid_liber](keyboard/hid_liber/) - [HID liberation][HID_liber] controller (by alaricljs) +* [phantom](keyboard/phantom/) - [Phantom] keyboard (by Tranquilite) +* [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung) +* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired] +* [KMAC](keyboard/kmac/) - Korean custom keyboard +* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard +* [Infinity](keyboard/infinity/) - Massdrop [Infinity keyboard][Infinity] +* [NerD](keyboard/nerd/) - Korean custom keyboard +* [KittenPaw](keyboard/kitten_paw) - Custom Majestouch controller +* [Lightpad](keyboard/lightpad) - Korean custom keypad +* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt] + +### Extenal projects using tmk_keyboard +* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org] +* [mcdox][mcdox_tmk] - [mcdox][mcdox] + + +[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930 +[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047 +[GH_ps2]: http://geekhack.org/showwiki.php?title=Island:14618 +[GH_adb]: http://geekhack.org/showwiki.php?title=Island:14290 +[GH_hhkb_bt]: http://geekhack.org/showwiki.php?title=Island:20851 +[GH_m0110]: http://geekhack.org/showwiki.php?title=Island:24965 +[GH_news]: http://geekhack.org/showwiki.php?title=Island:25759 +[GH_terminal]: http://geekhack.org/showwiki.php?title=Island:27272 +[GH_x68k]: http://geekhack.org/showwiki.php?title=Island:29060 +[GH_hbkb]: http://geekhack.org/showwiki.php?title=Island:29483 +[GH_ibm4704]: http://geekhack.org/index.php?topic=54706.0 +[HID_liber]: http://deskthority.net/wiki/HID_Liberation_Device_-_DIY_Instructions +[Phantom]: http://geekhack.org/index.php?topic=26742 +[GH60]: http://geekhack.org/index.php?topic=34959 +[GH60_proto]: http://geekhack.org/index.php?topic=37570.0 +[PC98]: http://en.wikipedia.org/wiki/NEC_PC-9801 +[Sun]: http://en.wikipedia.org/wiki/Sun-3 +[IIGS]: http://en.wikipedia.org/wiki/Apple_IIGS +[Infinity]: https://www.massdrop.com/buy/infinity-keyboard-kit +[ghost_squid]: http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid +[cmxt]: http://gaming.coolermaster.com/en/products/keyboards/quickfirext/ +[ergodox_org]: http://ergodox.org/ +[cub-uanic]: https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox +[mcdox]: https://github.com/DavidMcEwan/mcdox +[mcdox_tmk]: https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox + + + +License +------- +**GPLv2** or later. Some protocol files are under **Modified BSD License**. +LUFA, PJRC and V-USB stack have their own license respectively. + + + +Build Firmware and Program Controller +------------------------------------- +See [doc/build.md](doc/build.md). + + + +Change your keymap +------------------ +See [doc/keymap.md](doc/keymap.md). + + + +Magic Commands +-------------- +To see help press `Magic` + `H`. + + `Magic` key bind may be `LShift` + `RShift` in many project, but `Power` key on ADB converter. `Magic` keybind can be vary on each project, check `config.h` in project directory. + +Following commands can be also executed with `Magic` + key. In console mode `Magic` keybind is not needed. + + ----- Command Help ----- + c: enter console mode + d: toggle debug enable + x: toggle matrix debug + k: toggle keyboard debug + m: toggle mouse debug + v: print device version & info + t: print timer count + s: print status + e: print eeprom config + n: toggle NKRO + 0/F10: switch to Layer0 + 1/F1: switch to Layer1 + 2/F2: switch to Layer2 + 3/F3: switch to Layer3 + 4/F4: switch to Layer4 + PScr: power down/remote wake-up + Caps: Lock Keyboard(Child Proof) + Paus: jump to bootloader + +**TBD** + +### Boot Magic Configuration - Virtual DIP Switch +Boot Magic are executed during boot up time. Press Magic key below then plug in keyboard cable. +Note that you must use keys of **Layer 0** as Magic keys. These settings are stored in EEPROM so that retain your configure over power cycles. + +To avoid configuring accidentally additive salt key `KC_SPACE` also needs to be pressed along with the following configuration keys. The salt key is configurable in `config.h`. See [common/bootmagic.h](common/bootmagic.h). + +#### General +- Skip reading EEPROM to start with default configuration(`ESC`) +- Clear configuration stored in EEPROM to reset configuration(`Backspace`) + +#### Bootloader +- Kick up Bootloader(`B`) + +#### Debug +- Debug enable(`D`) +- Debug matrix enable(`D`+`X`) +- Debug keyboard enable(`D`+`K`) +- Debug mouse enable(`D`+`M`) + +#### Keymap +- Swap Control and CapsLock(`Left Control`) +- Change CapsLock to Control(`Caps Lock`) +- Swap LeftAlt and Gui(`Left Alt`) +- Swap RightAlt and Gui(`Right Alt`) +- Disable Gui(`Left Gui`) +- Swap Grave and Escape(`Grave`) +- Swap BackSlash and BackSpace(`Back Slash`) +- Enable NKRO on boot(`N`) + +#### Default Layer +- Set Default Layer to 0(`0`) +- Set Default Layer to 1(`1`) +- Set Default Layer to 2(`2`) +- Set Default Layer to 3(`3`) +- Set Default Layer to 4(`4`) +- Set Default Layer to 5(`5`) +- Set Default Layer to 6(`6`) +- Set Default Layer to 7(`7`) + +#### Caution +Unintentional use of this feature will cause user confusion. + +TODO: Magic key combination to avoid unintentional press during plug in + +**TBD** + + +Mechanical Locking support +-------------------------- +This feature makes it possible for you to use mechanical switch for `CapsLock`, `NumLock` or `ScrollLock`. To enable this feature define these macros in `config.h` and use `KC_LCAP`, `KC_LNUM` or `KC_LSCR` in keymap for locking key instead of normal `KC_CAPS`, `KC_NLCK` or `KC_SLCK`. Resync option tries to keep lock switch state consistent with keyboard LED state. + + #define LOCKING_SUPPORT_ENABLE + #define LOCKING_RESYNC_ENABLE + + +Start Your Own Project +----------------------- +**TBD** +### Config.h Options +#### 1. USB vendor/product ID and device description + #define VENDOR_ID 0xFEED + #define PRODUCT_ID 0xBEEF + #define MANUFACTURER t.m.k. + #define PRODUCT Macway mod + #define DESCRIPTION t.m.k. keyboard firmware for Macway mod + +#### 2. Keyboard matrix configuration + #define MATRIX_ROWS 8 + #define MATRIX_COLS 8 + #define MATRIX_HAS_GHOST + + + +Architecture +------------ + Architecture Diagram + +---------------+---------------+-------------+ + | Host | Keyboard | Matrix, LED | + ___________ |-----------+-+ +-------------+ | +-----------| + / /| Keys/Mouse | Protocol |d| | Action | | | Protocol | + /__________/ |<-----------| LUFA |r| | Layer, Tap | | | Matrix | + |.--------.| | LED | V-USB |i| |-------------| | | PS/2,IBM | __________________ + || || |----------->| PJRC |v| | Keymap | | | ADB,M0110| Keys / /_/_/_/_/_/_/_/ /| + || Host || | Console | iWRAP(BT)|e| | Mousekey | | | SUN/NEWS |<----------/ /_/_/_/_/_/_/_/ / / + ||________||/.<-----------| UART |r| | Report | | | X68K/PC98| Control / /_/_/_/_/_/_/_/ / / + `_========_'/| |---------------------------------------------|-------->/___ /_______/ ___/ / + |_o______o_|/ | Sendchar, Print, Debug, Command, ... | |_________________|/ + +---------------------------------------------+ Keyboard + + + +Debugging +-------- +Use PJRC's `hid_listen` to see debug messages. You can use the tool for debug even if firmware use LUFA stack. + +You can use xprintf() to display debug info on `hid_listen`, see `common/xprintf.h`. + + + +Files and Directories +------------------- +### Top +* common/ - common codes +* protocol/ - keyboard protocol support +* keyboard/ - keyboard projects +* converter/ - protocol converter projects +* doc/ - documents +* common.mk - Makefile for common +* protocol.mk - Makefile for protocol +* rules.mk - Makefile for build rules + +### Common +* host.h +* host_driver.h +* keyboard.h +* command.h +* keymap.h +* action.h +* keycode.h +* matrix.h +* led.h +* mousekey.h +* report.h +* debug.h +* print.h +* bootloader.h +* sendchar.h +* timer.h +* util.h + +### Keyboard Protocols +* lufa/ - LUFA USB stack +* pjrc/ - PJRC USB stack +* vusb/ - Objective Development V-USB +* iwrap/ - Bluetooth HID for Bluegiga iWRAP +* ps2.c - PS/2 protocol +* adb.c - Apple Desktop Bus protocol +* m0110.c - Macintosh 128K/512K/Plus keyboard protocol +* news.c - Sony NEWS keyboard protocol +* x68k.c - Sharp X68000 keyboard protocol +* serial_soft.c - Asynchronous Serial protocol implemented by software + + + +Coding Style +------------- +- Doesn't use Tab to indent, use 4-spaces instead. + + + +Other Keyboard Firmware Projects +------------------ +You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](doc/other_projects.md). diff --git a/common.mk b/common.mk new file mode 100644 index 000000000..d22adff51 --- /dev/null +++ b/common.mk @@ -0,0 +1,77 @@ +COMMON_DIR = common +SRC += $(COMMON_DIR)/host.c \ + $(COMMON_DIR)/keyboard.c \ + $(COMMON_DIR)/action.c \ + $(COMMON_DIR)/action_tapping.c \ + $(COMMON_DIR)/action_macro.c \ + $(COMMON_DIR)/action_layer.c \ + $(COMMON_DIR)/action_util.c \ + $(COMMON_DIR)/keymap.c \ + $(COMMON_DIR)/print.c \ + $(COMMON_DIR)/debug.c \ + $(COMMON_DIR)/util.c \ + $(COMMON_DIR)/avr/suspend.c \ + $(COMMON_DIR)/avr/xprintf.S \ + $(COMMON_DIR)/avr/timer.c \ + $(COMMON_DIR)/avr/bootloader.c + + +# Option modules +ifdef BOOTMAGIC_ENABLE + SRC += $(COMMON_DIR)/bootmagic.c + SRC += $(COMMON_DIR)/avr/eeconfig.c + OPT_DEFS += -DBOOTMAGIC_ENABLE +endif + +ifdef MOUSEKEY_ENABLE + SRC += $(COMMON_DIR)/mousekey.c + OPT_DEFS += -DMOUSEKEY_ENABLE + OPT_DEFS += -DMOUSE_ENABLE +endif + +ifdef EXTRAKEY_ENABLE + OPT_DEFS += -DEXTRAKEY_ENABLE +endif + +ifdef CONSOLE_ENABLE + OPT_DEFS += -DCONSOLE_ENABLE +else + OPT_DEFS += -DNO_PRINT + OPT_DEFS += -DNO_DEBUG +endif + +ifdef COMMAND_ENABLE + SRC += $(COMMON_DIR)/command.c + OPT_DEFS += -DCOMMAND_ENABLE +endif + +ifdef NKRO_ENABLE + OPT_DEFS += -DNKRO_ENABLE +endif + +ifdef USB_6KRO_ENABLE + OPT_DEFS += -DUSB_6KRO_ENABLE +endif + +ifdef SLEEP_LED_ENABLE + SRC += $(COMMON_DIR)/sleep_led.c + OPT_DEFS += -DSLEEP_LED_ENABLE + OPT_DEFS += -DNO_SUSPEND_POWER_DOWN +endif + +ifdef BACKLIGHT_ENABLE + SRC += $(COMMON_DIR)/backlight.c + OPT_DEFS += -DBACKLIGHT_ENABLE +endif + +ifdef KEYMAP_SECTION_ENABLE + OPT_DEFS += -DKEYMAP_SECTION_ENABLE + EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr5.x +endif + +# Version string +OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null) + + +# Search Path +VPATH += $(TMK_DIR)/common diff --git a/common/action.c b/common/action.c new file mode 100644 index 000000000..ec8eeae7b --- /dev/null +++ b/common/action.c @@ -0,0 +1,565 @@ +/* +Copyright 2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "host.h" +#include "keycode.h" +#include "keyboard.h" +#include "mousekey.h" +#include "command.h" +#include "led.h" +#include "backlight.h" +#include "action_layer.h" +#include "action_tapping.h" +#include "action_macro.h" +#include "action_util.h" +#include "action.h" + +#ifdef DEBUG_ACTION +#include "debug.h" +#else +#include "nodebug.h" +#endif + + +void action_exec(keyevent_t event) +{ + if (!IS_NOEVENT(event)) { + dprint("\n---- action_exec: start -----\n"); + dprint("EVENT: "); debug_event(event); dprintln(); + } + + keyrecord_t record = { .event = event }; + +#ifndef NO_ACTION_TAPPING + action_tapping_process(record); +#else + process_action(&record); + if (!IS_NOEVENT(record.event)) { + dprint("processed: "); debug_record(record); dprintln(); + } +#endif +} + +void process_action(keyrecord_t *record) +{ + keyevent_t event = record->event; +#ifndef NO_ACTION_TAPPING + uint8_t tap_count = record->tap.count; +#endif + + if (IS_NOEVENT(event)) { return; } + + action_t action = layer_switch_get_action(event.key); + dprint("ACTION: "); debug_action(action); +#ifndef NO_ACTION_LAYER + dprint(" layer_state: "); layer_debug(); + dprint(" default_layer_state: "); default_layer_debug(); +#endif + dprintln(); + + switch (action.kind.id) { + /* Key and Mods */ + case ACT_LMODS: + case ACT_RMODS: + { + uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods : + action.key.mods<<4; + if (event.pressed) { + if (mods) { + add_weak_mods(mods); + send_keyboard_report(); + } + register_code(action.key.code); + } else { + unregister_code(action.key.code); + if (mods) { + del_weak_mods(mods); + send_keyboard_report(); + } + } + } + break; +#ifndef NO_ACTION_TAPPING + case ACT_LMODS_TAP: + case ACT_RMODS_TAP: + { + uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : + action.key.mods<<4; + switch (action.layer_tap.code) { + #ifndef NO_ACTION_ONESHOT + case MODS_ONESHOT: + // Oneshot modifier + if (event.pressed) { + if (tap_count == 0) { + register_mods(mods); + } + else if (tap_count == 1) { + dprint("MODS_TAP: Oneshot: start\n"); + set_oneshot_mods(mods); + } + else { + register_mods(mods); + } + } else { + if (tap_count == 0) { + clear_oneshot_mods(); + unregister_mods(mods); + } + else if (tap_count == 1) { + // Retain Oneshot mods + } + else { + clear_oneshot_mods(); + unregister_mods(mods); + } + } + break; + #endif + case MODS_TAP_TOGGLE: + if (event.pressed) { + if (tap_count <= TAPPING_TOGGLE) { + register_mods(mods); + } + } else { + if (tap_count < TAPPING_TOGGLE) { + unregister_mods(mods); + } + } + break; + default: + if (event.pressed) { + if (tap_count > 0) { + if (record->tap.interrupted) { + dprint("MODS_TAP: Tap: Cancel: add_mods\n"); + // ad hoc: set 0 to cancel tap + record->tap.count = 0; + register_mods(mods); + } else { + dprint("MODS_TAP: Tap: register_code\n"); + register_code(action.key.code); + } + } else { + dprint("MODS_TAP: No tap: add_mods\n"); + register_mods(mods); + } + } else { + if (tap_count > 0) { + dprint("MODS_TAP: Tap: unregister_code\n"); + unregister_code(action.key.code); + } else { + dprint("MODS_TAP: No tap: add_mods\n"); + unregister_mods(mods); + } + } + break; + } + } + break; +#endif +#ifdef EXTRAKEY_ENABLE + /* other HID usage */ + case ACT_USAGE: + switch (action.usage.page) { + case PAGE_SYSTEM: + if (event.pressed) { + host_system_send(action.usage.code); + } else { + host_system_send(0); + } + break; + case PAGE_CONSUMER: + if (event.pressed) { + host_consumer_send(action.usage.code); + } else { + host_consumer_send(0); + } + break; + } + break; +#endif +#ifdef MOUSEKEY_ENABLE + /* Mouse key */ + case ACT_MOUSEKEY: + if (event.pressed) { + mousekey_on(action.key.code); + mousekey_send(); + } else { + mousekey_off(action.key.code); + mousekey_send(); + } + break; +#endif +#ifndef NO_ACTION_LAYER + case ACT_LAYER: + if (action.layer_bitop.on == 0) { + /* Default Layer Bitwise Operation */ + if (!event.pressed) { + uint8_t shift = action.layer_bitop.part*4; + uint32_t bits = ((uint32_t)action.layer_bitop.bits)< 0) { + dprint("KEYMAP_TAP_KEY: Tap: register_code\n"); + register_code(action.layer_tap.code); + } else { + dprint("KEYMAP_TAP_KEY: No tap: On on press\n"); + layer_on(action.layer_tap.val); + } + } else { + if (tap_count > 0) { + dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n"); + unregister_code(action.layer_tap.code); + } else { + dprint("KEYMAP_TAP_KEY: No tap: Off on release\n"); + layer_off(action.layer_tap.val); + } + } + break; + } + break; + #endif +#endif + /* Extentions */ +#ifndef NO_ACTION_MACRO + case ACT_MACRO: + action_macro_play(action_get_macro(record, action.func.id, action.func.opt)); + break; +#endif +#ifdef BACKLIGHT_ENABLE + case ACT_BACKLIGHT: + if (!event.pressed) { + switch (action.backlight.opt) { + case BACKLIGHT_INCREASE: + backlight_increase(); + break; + case BACKLIGHT_DECREASE: + backlight_decrease(); + break; + case BACKLIGHT_TOGGLE: + backlight_toggle(); + break; + case BACKLIGHT_STEP: + backlight_step(); + break; + case BACKLIGHT_LEVEL: + backlight_level(action.backlight.level); + break; + } + } + break; +#endif + case ACT_COMMAND: + break; +#ifndef NO_ACTION_FUNCTION + case ACT_FUNCTION: + action_function(record, action.func.id, action.func.opt); + break; +#endif + default: + break; + } +} + + + + +/* + * Utilities for actions. + */ +void register_code(uint8_t code) +{ + if (code == KC_NO) { + return; + } + +#ifdef LOCKING_SUPPORT_ENABLE + else if (KC_LOCKING_CAPS == code) { +#ifdef LOCKING_RESYNC_ENABLE + // Resync: ignore if caps lock already is on + if (host_keyboard_leds() & (1<>8, action.kind.param&0xff); +} diff --git a/common/action.h b/common/action.h new file mode 100644 index 000000000..8a4736d7b --- /dev/null +++ b/common/action.h @@ -0,0 +1,82 @@ +/* +Copyright 2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTION_H +#define ACTION_H + +#include +#include +#include "keyboard.h" +#include "keycode.h" +#include "action_code.h" +#include "action_macro.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* tapping count and state */ +typedef struct { + bool interrupted :1; + bool reserved2 :1; + bool reserved1 :1; + bool reserved0 :1; + uint8_t count :4; +} tap_t; + +/* Key event container for recording */ +typedef struct { + keyevent_t event; +#ifndef NO_ACTION_TAPPING + tap_t tap; +#endif +} keyrecord_t; + +/* Execute action per keyevent */ +void action_exec(keyevent_t event); + +/* action for key */ +action_t action_for_key(uint8_t layer, keypos_t key); + +/* macro */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); + +/* user defined special function */ +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); + +/* Utilities for actions. */ +void process_action(keyrecord_t *record); +void register_code(uint8_t code); +void unregister_code(uint8_t code); +void register_mods(uint8_t mods); +void unregister_mods(uint8_t mods); +//void set_mods(uint8_t mods); +void clear_keyboard(void); +void clear_keyboard_but_mods(void); +void layer_switch(uint8_t new_layer); +bool is_tap_key(keypos_t key); + +/* debug */ +void debug_event(keyevent_t event); +void debug_record(keyrecord_t record); +void debug_action(action_t action); + +#ifdef __cplusplus +} +#endif + +#endif /* ACTION_H */ diff --git a/common/action_code.h b/common/action_code.h new file mode 100644 index 000000000..bc40e2c6f --- /dev/null +++ b/common/action_code.h @@ -0,0 +1,315 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTION_CODE_H +#define ACTION_CODE_H + +/* Action codes + * ============ + * 16bit code: action_kind(4bit) + action_parameter(12bit) + * + * + * Key Actions(00xx) + * ----------------- + * ACT_MODS(000r): + * 000r|0000|0000 0000 No action code + * 000r|0000|0000 0001 Transparent code + * 000r|0000| keycode Key + * 000r|mods|0000 0000 Modifiers + * 000r|mods| keycode Modifiers+Key(Modified key) + * r: Left/Right flag(Left:0, Right:1) + * + * ACT_MODS_TAP(001r): + * 001r|mods|0000 0000 Modifiers with OneShot + * 001r|mods|0000 0001 Modifiers with tap toggle + * 001r|mods|0000 00xx (reserved) + * 001r|mods| keycode Modifiers with Tap Key(Dual role) + * + * + * Other Keys(01xx) + * ---------------- + * ACT_USAGE(0100): TODO: Not needed? + * 0100|00| usage(10) System control(0x80) - General Desktop page(0x01) + * 0100|01| usage(10) Consumer control(0x01) - Consumer page(0x0C) + * 0100|10| usage(10) (reserved) + * 0100|11| usage(10) (reserved) + * + * ACT_MOUSEKEY(0110): TODO: Not needed? + * 0101|xxxx| keycode Mouse key + * + * 011x|xxxx xxxx xxxx (reseved) + * + * + * Layer Actions(10xx) + * ------------------- + * ACT_LAYER(1000): + * 1000|oo00|pppE BBBB Default Layer Bitwise operation + * oo: operation(00:AND, 01:OR, 10:XOR, 11:SET) + * ppp: 4-bit chunk part(0-7) + * EBBBB: bits and extra bit + * 1000|ooee|pppE BBBB Layer Bitwise Operation + * oo: operation(00:AND, 01:OR, 10:XOR, 11:SET) + * ppp: 4-bit chunk part(0-7) + * EBBBB: bits and extra bit + * ee: on event(01:press, 10:release, 11:both) + * + * 1001|xxxx|xxxx xxxx (reserved) + * 1001|oopp|BBBB BBBB 8-bit Bitwise Operation??? + * + * ACT_LAYER_TAP(101x): + * 101E|LLLL| keycode On/Off with tap key + * 101E|LLLL|1110 mods On/Off with modifiers(0xE0-EF) + * 101E|LLLL|1111 0000 Invert with tap toggle(0xF0) + * 101E|LLLL|1111 0001 On/Off + * 101E|LLLL|1111 0010 Off/On + * 101E|LLLL|1111 0011 Set/Clear + * 101E|LLLL|1111 xxxx Reserved(0xF4-FF) + * ELLLL: layer 0-31(E: extra bit for layer 16-31) + * + * + * Extensions(11xx) + * ---------------- + * ACT_MACRO(1100): + * 1100|opt | id(8) Macro play? + * 1100|1111| id(8) Macro record? + * + * ACT_BACKLIGHT(1101): + * 1101|opt |level(8) Backlight commands + * + * ACT_COMMAND(1110): + * 1110|opt | id(8) Built-in Command exec + * + * ACT_FUNCTION(1111): + * 1111| address(12) Function? + * 1111|opt | id(8) Function? + */ +enum action_kind_id { + /* Key Actions */ + ACT_MODS = 0b0000, + ACT_LMODS = 0b0000, + ACT_RMODS = 0b0001, + ACT_MODS_TAP = 0b0010, + ACT_LMODS_TAP = 0b0010, + ACT_RMODS_TAP = 0b0011, + /* Other Keys */ + ACT_USAGE = 0b0100, + ACT_MOUSEKEY = 0b0101, + /* Layer Actions */ + ACT_LAYER = 0b1000, + ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */ + ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */ + /* Extensions */ + ACT_MACRO = 0b1100, + ACT_BACKLIGHT = 0b1101, + ACT_COMMAND = 0b1110, + ACT_FUNCTION = 0b1111 +}; + + +/* Action Code Struct + * + * NOTE: + * In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15). + * AVR looks like a little endian in avr-gcc. + * Not portable across compiler/endianness? + * + * Byte order and bit order of 0x1234: + * Big endian: Little endian: + * -------------------- -------------------- + * FEDC BA98 7654 3210 0123 4567 89AB CDEF + * 0001 0010 0011 0100 0010 1100 0100 1000 + * 0x12 0x34 0x34 0x12 + */ +typedef union { + uint16_t code; + struct action_kind { + uint16_t param :12; + uint8_t id :4; + } kind; + struct action_key { + uint8_t code :8; + uint8_t mods :4; + uint8_t kind :4; + } key; + struct action_layer_bitop { + uint8_t bits :4; + uint8_t xbit :1; + uint8_t part :3; + uint8_t on :2; + uint8_t op :2; + uint8_t kind :4; + } layer_bitop; + struct action_layer_tap { + uint8_t code :8; + uint8_t val :5; + uint8_t kind :3; + } layer_tap; + struct action_usage { + uint16_t code :10; + uint8_t page :2; + uint8_t kind :4; + } usage; + struct action_backlight { + uint8_t level :8; + uint8_t opt :4; + uint8_t kind :4; + } backlight; + struct action_command { + uint8_t id :8; + uint8_t opt :4; + uint8_t kind :4; + } command; + struct action_function { + uint8_t id :8; + uint8_t opt :4; + uint8_t kind :4; + } func; +} action_t; + + +/* action utility */ +#define ACTION_NO 0 +#define ACTION_TRANSPARENT 1 +#define ACTION(kind, param) ((kind)<<12 | (param)) + + +/* + * Key Actions + */ +/* Mod bits: 43210 + * bit 0 ||||+- Control + * bit 1 |||+-- Shift + * bit 2 ||+--- Alt + * bit 3 |+---- Gui + * bit 4 +----- LR flag(Left:0, Right:1) + */ +enum mods_bit { + MOD_LCTL = 0x01, + MOD_LSFT = 0x02, + MOD_LALT = 0x04, + MOD_LGUI = 0x08, + MOD_RCTL = 0x11, + MOD_RSFT = 0x12, + MOD_RALT = 0x14, + MOD_RGUI = 0x18, +}; +enum mods_codes { + MODS_ONESHOT = 0x00, + MODS_TAP_TOGGLE = 0x01, +}; +#define ACTION_KEY(key) ACTION(ACT_MODS, (key)) +#define ACTION_MODS(mods) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | 0) +#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | (key)) +#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | (key)) +#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_ONESHOT) +#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_TAP_TOGGLE) + + +/* + * Other Keys + */ +enum usage_pages { + PAGE_SYSTEM, + PAGE_CONSUMER +}; +#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id)) +#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id)) +#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key) + + + +/* + * Layer Actions + */ +enum layer_param_on { + ON_PRESS = 1, + ON_RELEASE = 2, + ON_BOTH = 3, +}; +enum layer_param_bit_op { + OP_BIT_AND = 0, + OP_BIT_OR = 1, + OP_BIT_XOR = 2, + OP_BIT_SET = 3, +}; +enum layer_pram_tap_op { + OP_TAP_TOGGLE = 0xF0, + OP_ON_OFF, + OP_OFF_ON, + OP_SET_CLEAR, +}; +#define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f)) +#define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key)) +/* Default Layer */ +#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4)) +/* Layer Operation */ +#define ACTION_LAYER_CLEAR(on) ACTION_LAYER_BIT_AND(0, 0, (on)) +#define ACTION_LAYER_MOMENTARY(layer) ACTION_LAYER_ON_OFF(layer) +#define ACTION_LAYER_TOGGLE(layer) ACTION_LAYER_INVERT(layer, ON_RELEASE) +#define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer)/4, 1<<((layer)%4), (on)) +#define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR( (layer)/4, 1<<((layer)%4), (on)) +#define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer)/4, ~(1<<((layer)%4)), (on)) +#define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer)/4, 1<<((layer)%4), (on)) +#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) +#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) +#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) +#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f) +/* With Tapping */ +#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) +#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE) +/* Bitwise Operation */ +#define ACTION_LAYER_BIT_AND(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), (on)) +#define ACTION_LAYER_BIT_OR( part, bits, on) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), (on)) +#define ACTION_LAYER_BIT_XOR(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), (on)) +#define ACTION_LAYER_BIT_SET(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), (on)) +/* Default Layer Bitwise Operation */ +#define ACTION_DEFAULT_LAYER_BIT_AND(part, bits) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), 0) +#define ACTION_DEFAULT_LAYER_BIT_OR( part, bits) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), 0) +#define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0) +#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0) + + +/* + * Extensions + */ +enum backlight_opt { + BACKLIGHT_INCREASE = 0, + BACKLIGHT_DECREASE = 1, + BACKLIGHT_TOGGLE = 2, + BACKLIGHT_STEP = 3, + BACKLIGHT_LEVEL = 4, +}; +/* Macro */ +#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id)) +#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id)) +#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id)) +/* Backlight */ +#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8) +#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8) +#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8) +#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8) +#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level) +/* Command */ +#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr)) +/* Function */ +enum function_opts { + FUNC_TAP = 0x8, /* indciates function is tappable */ +}; +#define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id)) +#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | (id)) +#define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | (id)) + +#endif /* ACTION_CODE_H */ diff --git a/common/action_layer.c b/common/action_layer.c new file mode 100644 index 000000000..c535615f4 --- /dev/null +++ b/common/action_layer.c @@ -0,0 +1,138 @@ +#include +#include "keyboard.h" +#include "action.h" +#include "util.h" +#include "action_layer.h" + +#ifdef DEBUG_ACTION +#include "debug.h" +#else +#include "nodebug.h" +#endif + + +/* + * Default Layer State + */ +uint32_t default_layer_state = 0; + +static void default_layer_state_set(uint32_t state) +{ + debug("default_layer_state: "); + default_layer_debug(); debug(" to "); + default_layer_state = state; + default_layer_debug(); debug("\n"); + clear_keyboard_but_mods(); // To avoid stuck keys +} + +void default_layer_debug(void) +{ + dprintf("%08lX(%u)", default_layer_state, biton32(default_layer_state)); +} + +void default_layer_set(uint32_t state) +{ + default_layer_state_set(state); +} + +#ifndef NO_ACTION_LAYER +void default_layer_or(uint32_t state) +{ + default_layer_state_set(default_layer_state | state); +} +void default_layer_and(uint32_t state) +{ + default_layer_state_set(default_layer_state & state); +} +void default_layer_xor(uint32_t state) +{ + default_layer_state_set(default_layer_state ^ state); +} +#endif + + +#ifndef NO_ACTION_LAYER +/* + * Keymap Layer State + */ +uint32_t layer_state = 0; + +static void layer_state_set(uint32_t state) +{ + dprint("layer_state: "); + layer_debug(); dprint(" to "); + layer_state = state; + layer_debug(); dprintln(); + clear_keyboard_but_mods(); // To avoid stuck keys +} + +void layer_clear(void) +{ + layer_state_set(0); +} + +void layer_move(uint8_t layer) +{ + layer_state_set(1UL<= 0; i--) { + if (layers & (1UL< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTION_LAYER_H +#define ACTION_LAYER_H + +#include +#include "keyboard.h" +#include "action.h" + + +/* + * Default Layer + */ +extern uint32_t default_layer_state; +void default_layer_debug(void); +void default_layer_set(uint32_t state); + +#ifndef NO_ACTION_LAYER +/* bitwise operation */ +void default_layer_or(uint32_t state); +void default_layer_and(uint32_t state); +void default_layer_xor(uint32_t state); +#else +#define default_layer_or(state) +#define default_layer_and(state) +#define default_layer_xor(state) +#endif + + +/* + * Keymap Layer + */ +#ifndef NO_ACTION_LAYER +extern uint32_t layer_state; +void layer_debug(void); +void layer_clear(void); +void layer_move(uint8_t layer); +void layer_on(uint8_t layer); +void layer_off(uint8_t layer); +void layer_invert(uint8_t layer); +/* bitwise operation */ +void layer_or(uint32_t state); +void layer_and(uint32_t state); +void layer_xor(uint32_t state); +#else +#define layer_state 0 +#define layer_clear() +#define layer_move(layer) +#define layer_on(layer) +#define layer_off(layer) +#define layer_invert(layer) + +#define layer_or(state) +#define layer_and(state) +#define layer_xor(state) +#define layer_debug() +#endif + + +/* return action depending on current layer status */ +action_t layer_switch_get_action(keypos_t key); + +#endif diff --git a/common/action_macro.c b/common/action_macro.c new file mode 100644 index 000000000..ba93fc8b2 --- /dev/null +++ b/common/action_macro.c @@ -0,0 +1,83 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "action.h" +#include "action_util.h" +#include "action_macro.h" +#include "wait.h" + +#ifdef DEBUG_ACTION +#include "debug.h" +#else +#include "nodebug.h" +#endif + + +#ifndef NO_ACTION_MACRO + +#define MACRO_READ() (macro = MACRO_GET(macro_p++)) +void action_macro_play(const macro_t *macro_p) +{ + macro_t macro = END; + uint8_t interval = 0; + + if (!macro_p) return; + while (true) { + switch (MACRO_READ()) { + case KEY_DOWN: + MACRO_READ(); + dprintf("KEY_DOWN(%02X)\n", macro); + if (IS_MOD(macro)) { + add_weak_mods(MOD_BIT(macro)); + } else { + register_code(macro); + } + break; + case KEY_UP: + MACRO_READ(); + dprintf("KEY_UP(%02X)\n", macro); + if (IS_MOD(macro)) { + del_weak_mods(MOD_BIT(macro)); + } else { + unregister_code(macro); + } + break; + case WAIT: + MACRO_READ(); + dprintf("WAIT(%u)\n", macro); + { uint8_t ms = macro; while (ms--) wait_ms(1); } + break; + case INTERVAL: + interval = MACRO_READ(); + dprintf("INTERVAL(%u)\n", interval); + break; + case 0x04 ... 0x73: + dprintf("DOWN(%02X)\n", macro); + register_code(macro); + break; + case 0x84 ... 0xF3: + dprintf("UP(%02X)\n", macro); + unregister_code(macro&0x7F); + break; + case END: + default: + return; + } + // interval + { uint8_t ms = interval; while (ms--) wait_ms(1); } + } +} +#endif diff --git a/common/action_macro.h b/common/action_macro.h new file mode 100644 index 000000000..aedc32ec6 --- /dev/null +++ b/common/action_macro.h @@ -0,0 +1,102 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTION_MACRO_H +#define ACTION_MACRO_H +#include +#include "progmem.h" + + +#define MACRO_NONE 0 +#define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; }) +#define MACRO_GET(p) pgm_read_byte(p) + +typedef uint8_t macro_t; + + +#ifndef NO_ACTION_MACRO +void action_macro_play(const macro_t *macro_p); +#else +#define action_macro_play(macro) +#endif + + + +/* Macro commands + * code(0x04-73) // key down(1byte) + * code(0x04-73) | 0x80 // key up(1byte) + * { KEY_DOWN, code(0x04-0xff) } // key down(2bytes) + * { KEY_UP, code(0x04-0xff) } // key up(2bytes) + * WAIT // wait milli-seconds + * INTERVAL // set interval between macro commands + * END // stop macro execution + * + * Ideas(Not implemented): + * modifiers + * system usage + * consumer usage + * unicode usage + * function call + * conditionals + * loop + */ +enum macro_command_id{ + /* 0x00 - 0x03 */ + END = 0x00, + KEY_DOWN, + KEY_UP, + + /* 0x04 - 0x73 (reserved for keycode down) */ + + /* 0x74 - 0x83 */ + WAIT = 0x74, + INTERVAL, + + /* 0x84 - 0xf3 (reserved for keycode up) */ + + /* 0xf4 - 0xff */ +}; + + +/* TODO: keycode:0x04-0x73 can be handled by 1byte command else 2bytes are needed + * if keycode between 0x04 and 0x73 + * keycode / (keycode|0x80) + * else + * {KEY_DOWN, keycode} / {KEY_UP, keycode} +*/ +#define DOWN(key) KEY_DOWN, (key) +#define UP(key) KEY_UP, (key) +#define TYPE(key) DOWN(key), UP(key) +#define WAIT(ms) WAIT, (ms) +#define INTERVAL(ms) INTERVAL, (ms) + +/* key down */ +#define D(key) DOWN(KC_##key) +/* key up */ +#define U(key) UP(KC_##key) +/* key type */ +#define T(key) TYPE(KC_##key) +/* wait */ +#define W(ms) WAIT(ms) +/* interval */ +#define I(ms) INTERVAL(ms) + +/* for backward comaptibility */ +#define MD(key) DOWN(KC_##key) +#define MU(key) UP(KC_##key) + + +#endif /* ACTION_MACRO_H */ diff --git a/common/action_tapping.c b/common/action_tapping.c new file mode 100644 index 000000000..826c23309 --- /dev/null +++ b/common/action_tapping.c @@ -0,0 +1,376 @@ +#include +#include +#include "action.h" +#include "action_layer.h" +#include "action_tapping.h" +#include "keycode.h" +#include "timer.h" + +#ifdef DEBUG_ACTION +#include "debug.h" +#else +#include "nodebug.h" +#endif + +#ifndef NO_ACTION_TAPPING + +#define IS_TAPPING() !IS_NOEVENT(tapping_key.event) +#define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) +#define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) +#define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) +#define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM) + + +static keyrecord_t tapping_key = {}; +static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; +static uint8_t waiting_buffer_head = 0; +static uint8_t waiting_buffer_tail = 0; + +static bool process_tapping(keyrecord_t *record); +static bool waiting_buffer_enq(keyrecord_t record); +static void waiting_buffer_clear(void); +static bool waiting_buffer_typed(keyevent_t event); +static bool waiting_buffer_has_anykey_pressed(void); +static void waiting_buffer_scan_tap(void); +static void debug_tapping_key(void); +static void debug_waiting_buffer(void); + + +void action_tapping_process(keyrecord_t record) +{ + if (process_tapping(&record)) { + if (!IS_NOEVENT(record.event)) { + debug("processed: "); debug_record(record); debug("\n"); + } + } else { + if (!waiting_buffer_enq(record)) { + // clear all in case of overflow. + debug("OVERFLOW: CLEAR ALL STATES\n"); + clear_keyboard(); + waiting_buffer_clear(); + tapping_key = (keyrecord_t){}; + } + } + + // process waiting_buffer + if (!IS_NOEVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) { + debug("---- action_exec: process waiting_buffer -----\n"); + } + for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { + if (process_tapping(&waiting_buffer[waiting_buffer_tail])) { + debug("processed: waiting_buffer["); debug_dec(waiting_buffer_tail); debug("] = "); + debug_record(waiting_buffer[waiting_buffer_tail]); debug("\n\n"); + } else { + break; + } + } + if (!IS_NOEVENT(record.event)) { + debug("\n"); + } +} + + +/* Tapping + * + * Rule: Tap key is typed(pressed and released) within TAPPING_TERM. + * (without interfering by typing other key) + */ +/* return true when key event is processed or consumed. */ +bool process_tapping(keyrecord_t *keyp) +{ + keyevent_t event = keyp->event; + + // if tapping + if (IS_TAPPING_PRESSED()) { + if (WITHIN_TAPPING_TERM(event)) { + if (tapping_key.tap.count == 0) { + if (IS_TAPPING_KEY(event.key) && !event.pressed) { + // first tap! + debug("Tapping: First tap(0->1).\n"); + tapping_key.tap.count = 1; + debug_tapping_key(); + process_action(&tapping_key); + + // copy tapping state + keyp->tap = tapping_key.tap; + // enqueue + return false; + } +#if TAPPING_TERM >= 500 + /* Process a key typed within TAPPING_TERM + * This can register the key before settlement of tapping, + * useful for long TAPPING_TERM but may prevent fast typing. + */ + else if (IS_RELEASED(event) && waiting_buffer_typed(event)) { + debug("Tapping: End. No tap. Interfered by typing key\n"); + process_action(&tapping_key); + tapping_key = (keyrecord_t){}; + debug_tapping_key(); + // enqueue + return false; + } +#endif + /* Process release event of a key pressed before tapping starts + * Without this unexpected repeating will occur with having fast repeating setting + * https://github.com/tmk/tmk_keyboard/issues/60 + */ + else if (IS_RELEASED(event) && !waiting_buffer_typed(event)) { + // Modifier should be retained till end of this tapping. + action_t action = layer_switch_get_action(event.key); + switch (action.kind.id) { + case ACT_LMODS: + case ACT_RMODS: + if (action.key.mods && !action.key.code) return false; + if (IS_MOD(action.key.code)) return false; + break; + case ACT_LMODS_TAP: + case ACT_RMODS_TAP: + if (action.key.mods && keyp->tap.count == 0) return false; + if (IS_MOD(action.key.code)) return false; + break; + } + // Release of key should be process immediately. + debug("Tapping: release event of a key pressed before tapping\n"); + process_action(keyp); + return true; + } + else { + // set interrupted flag when other key preesed during tapping + if (event.pressed) { + tapping_key.tap.interrupted = true; + } + // enqueue + return false; + } + } + // tap_count > 0 + else { + if (IS_TAPPING_KEY(event.key) && !event.pressed) { + debug("Tapping: Tap release("); debug_dec(tapping_key.tap.count); debug(")\n"); + keyp->tap = tapping_key.tap; + process_action(keyp); + tapping_key = *keyp; + debug_tapping_key(); + return true; + } + else if (is_tap_key(event.key) && event.pressed) { + if (tapping_key.tap.count > 1) { + debug("Tapping: Start new tap with releasing last tap(>1).\n"); + // unregister key + process_action(&(keyrecord_t){ + .tap = tapping_key.tap, + .event.key = tapping_key.event.key, + .event.time = event.time, + .event.pressed = false + }); + } else { + debug("Tapping: Start while last tap(1).\n"); + } + tapping_key = *keyp; + waiting_buffer_scan_tap(); + debug_tapping_key(); + return true; + } + else { + if (!IS_NOEVENT(event)) { + debug("Tapping: key event while last tap(>0).\n"); + } + process_action(keyp); + return true; + } + } + } + // after TAPPING_TERM + else { + if (tapping_key.tap.count == 0) { + debug("Tapping: End. Timeout. Not tap(0): "); + debug_event(event); debug("\n"); + process_action(&tapping_key); + tapping_key = (keyrecord_t){}; + debug_tapping_key(); + return false; + } else { + if (IS_TAPPING_KEY(event.key) && !event.pressed) { + debug("Tapping: End. last timeout tap release(>0)."); + keyp->tap = tapping_key.tap; + process_action(keyp); + tapping_key = (keyrecord_t){}; + return true; + } + else if (is_tap_key(event.key) && event.pressed) { + if (tapping_key.tap.count > 1) { + debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); + // unregister key + process_action(&(keyrecord_t){ + .tap = tapping_key.tap, + .event.key = tapping_key.event.key, + .event.time = event.time, + .event.pressed = false + }); + } else { + debug("Tapping: Start while last timeout tap(1).\n"); + } + tapping_key = *keyp; + waiting_buffer_scan_tap(); + debug_tapping_key(); + return true; + } + else { + if (!IS_NOEVENT(event)) { + debug("Tapping: key event while last timeout tap(>0).\n"); + } + process_action(keyp); + return true; + } + } + } + } else if (IS_TAPPING_RELEASED()) { + if (WITHIN_TAPPING_TERM(event)) { + if (event.pressed) { + if (IS_TAPPING_KEY(event.key)) { + if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { + // sequential tap. + keyp->tap = tapping_key.tap; + if (keyp->tap.count < 15) keyp->tap.count += 1; + debug("Tapping: Tap press("); debug_dec(keyp->tap.count); debug(")\n"); + process_action(keyp); + tapping_key = *keyp; + debug_tapping_key(); + return true; + } else { + // FIX: start new tap again + tapping_key = *keyp; + return true; + } + } else if (is_tap_key(event.key)) { + // Sequential tap can be interfered with other tap key. + debug("Tapping: Start with interfering other tap.\n"); + tapping_key = *keyp; + waiting_buffer_scan_tap(); + debug_tapping_key(); + return true; + } else { + // should none in buffer + // FIX: interrupted when other key is pressed + tapping_key.tap.interrupted = true; + process_action(keyp); + return true; + } + } else { + if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n"); + process_action(keyp); + return true; + } + } else { + // FIX: process_aciton here? + // timeout. no sequential tap. + debug("Tapping: End(Timeout after releasing last tap): "); + debug_event(event); debug("\n"); + tapping_key = (keyrecord_t){}; + debug_tapping_key(); + return false; + } + } + // not tapping state + else { + if (event.pressed && is_tap_key(event.key)) { + debug("Tapping: Start(Press tap key).\n"); + tapping_key = *keyp; + waiting_buffer_scan_tap(); + debug_tapping_key(); + return true; + } else { + process_action(keyp); + return true; + } + } +} + + +/* + * Waiting buffer + */ +bool waiting_buffer_enq(keyrecord_t record) +{ + if (IS_NOEVENT(record.event)) { + return true; + } + + if ((waiting_buffer_head + 1) % WAITING_BUFFER_SIZE == waiting_buffer_tail) { + debug("waiting_buffer_enq: Over flow.\n"); + return false; + } + + waiting_buffer[waiting_buffer_head] = record; + waiting_buffer_head = (waiting_buffer_head + 1) % WAITING_BUFFER_SIZE; + + debug("waiting_buffer_enq: "); debug_waiting_buffer(); + return true; +} + +void waiting_buffer_clear(void) +{ + waiting_buffer_head = 0; + waiting_buffer_tail = 0; +} + +bool waiting_buffer_typed(keyevent_t event) +{ + for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { + if (KEYEQ(event.key, waiting_buffer[i].event.key) && event.pressed != waiting_buffer[i].event.pressed) { + return true; + } + } + return false; +} + +bool waiting_buffer_has_anykey_pressed(void) +{ + for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { + if (waiting_buffer[i].event.pressed) return true; + } + return false; +} + +/* scan buffer for tapping */ +void waiting_buffer_scan_tap(void) +{ + // tapping already is settled + if (tapping_key.tap.count > 0) return; + // invalid state: tapping_key released && tap.count == 0 + if (!tapping_key.event.pressed) return; + + for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { + if (IS_TAPPING_KEY(waiting_buffer[i].event.key) && + !waiting_buffer[i].event.pressed && + WITHIN_TAPPING_TERM(waiting_buffer[i].event)) { + tapping_key.tap.count = 1; + waiting_buffer[i].tap.count = 1; + process_action(&tapping_key); + + debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n"); + debug_waiting_buffer(); + return; + } + } +} + + +/* + * debug print + */ +static void debug_tapping_key(void) +{ + debug("TAPPING_KEY="); debug_record(tapping_key); debug("\n"); +} + +static void debug_waiting_buffer(void) +{ + debug("{ "); + for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) { + debug("["); debug_dec(i); debug("]="); debug_record(waiting_buffer[i]); debug(" "); + } + debug("}\n"); +} + +#endif diff --git a/common/action_tapping.h b/common/action_tapping.h new file mode 100644 index 000000000..9b42d50dc --- /dev/null +++ b/common/action_tapping.h @@ -0,0 +1,39 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTION_TAPPING_H +#define ACTION_TAPPING_H + + + +/* period of tapping(ms) */ +#ifndef TAPPING_TERM +#define TAPPING_TERM 200 +#endif + +/* tap count needed for toggling a feature */ +#ifndef TAPPING_TOGGLE +#define TAPPING_TOGGLE 5 +#endif + +#define WAITING_BUFFER_SIZE 8 + + +#ifndef NO_ACTION_TAPPING +void action_tapping_process(keyrecord_t record); +#endif + +#endif diff --git a/common/action_util.c b/common/action_util.c new file mode 100644 index 000000000..dbee630d1 --- /dev/null +++ b/common/action_util.c @@ -0,0 +1,307 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "host.h" +#include "report.h" +#include "debug.h" +#include "action_util.h" +#include "timer.h" + +static inline void add_key_byte(uint8_t code); +static inline void del_key_byte(uint8_t code); +#ifdef NKRO_ENABLE +static inline void add_key_bit(uint8_t code); +static inline void del_key_bit(uint8_t code); +#endif + +static uint8_t real_mods = 0; +static uint8_t weak_mods = 0; + +#ifdef USB_6KRO_ENABLE +#define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS) +#define RO_SUB(a, b) ((a - b + KEYBOARD_REPORT_KEYS) % KEYBOARD_REPORT_KEYS) +#define RO_INC(a) RO_ADD(a, 1) +#define RO_DEC(a) RO_SUB(a, 1) +static int8_t cb_head = 0; +static int8_t cb_tail = 0; +static int8_t cb_count = 0; +#endif + +// TODO: pointer variable is not needed +//report_keyboard_t keyboard_report = {}; +report_keyboard_t *keyboard_report = &(report_keyboard_t){}; + +#ifndef NO_ACTION_ONESHOT +static int8_t oneshot_mods = 0; +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) +static int16_t oneshot_time = 0; +#endif +#endif + + +void send_keyboard_report(void) { + keyboard_report->mods = real_mods; + keyboard_report->mods |= weak_mods; +#ifndef NO_ACTION_ONESHOT + if (oneshot_mods) { +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + if (TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT) { + dprintf("Oneshot: timeout\n"); + clear_oneshot_mods(); + } +#endif + keyboard_report->mods |= oneshot_mods; + if (has_anykey()) { + clear_oneshot_mods(); + } + } +#endif + host_keyboard_send(keyboard_report); +} + +/* key */ +void add_key(uint8_t key) +{ +#ifdef NKRO_ENABLE + if (keyboard_nkro) { + add_key_bit(key); + return; + } +#endif + add_key_byte(key); +} + +void del_key(uint8_t key) +{ +#ifdef NKRO_ENABLE + if (keyboard_nkro) { + del_key_bit(key); + return; + } +#endif + del_key_byte(key); +} + +void clear_keys(void) +{ + // not clear mods + for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { + keyboard_report->raw[i] = 0; + } +} + + +/* modifier */ +uint8_t get_mods(void) { return real_mods; } +void add_mods(uint8_t mods) { real_mods |= mods; } +void del_mods(uint8_t mods) { real_mods &= ~mods; } +void set_mods(uint8_t mods) { real_mods = mods; } +void clear_mods(void) { real_mods = 0; } + +/* weak modifier */ +uint8_t get_weak_mods(void) { return weak_mods; } +void add_weak_mods(uint8_t mods) { weak_mods |= mods; } +void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; } +void set_weak_mods(uint8_t mods) { weak_mods = mods; } +void clear_weak_mods(void) { weak_mods = 0; } + +/* Oneshot modifier */ +#ifndef NO_ACTION_ONESHOT +void set_oneshot_mods(uint8_t mods) +{ + oneshot_mods = mods; +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + oneshot_time = timer_read(); +#endif +} +void clear_oneshot_mods(void) +{ + oneshot_mods = 0; +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + oneshot_time = 0; +#endif +} +#endif + + + + +/* + * inspect keyboard state + */ +uint8_t has_anykey(void) +{ + uint8_t cnt = 0; + for (uint8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { + if (keyboard_report->raw[i]) + cnt++; + } + return cnt; +} + +uint8_t has_anymod(void) +{ + return bitpop(real_mods); +} + +uint8_t get_first_key(void) +{ +#ifdef NKRO_ENABLE + if (keyboard_nkro) { + uint8_t i = 0; + for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) + ; + return i<<3 | biton(keyboard_report->nkro.bits[i]); + } +#endif +#ifdef USB_6KRO_ENABLE + uint8_t i = cb_head; + do { + if (keyboard_report->keys[i] != 0) { + break; + } + i = RO_INC(i); + } while (i != cb_tail); + return keyboard_report->keys[i]; +#else + return keyboard_report->keys[0]; +#endif +} + + + +/* local functions */ +static inline void add_key_byte(uint8_t code) +{ +#ifdef USB_6KRO_ENABLE + int8_t i = cb_head; + int8_t empty = -1; + if (cb_count) { + do { + if (keyboard_report->keys[i] == code) { + return; + } + if (empty == -1 && keyboard_report->keys[i] == 0) { + empty = i; + } + i = RO_INC(i); + } while (i != cb_tail); + if (i == cb_tail) { + if (cb_tail == cb_head) { + // buffer is full + if (empty == -1) { + // pop head when has no empty space + cb_head = RO_INC(cb_head); + cb_count--; + } + else { + // left shift when has empty space + uint8_t offset = 1; + i = RO_INC(empty); + do { + if (keyboard_report->keys[i] != 0) { + keyboard_report->keys[empty] = keyboard_report->keys[i]; + keyboard_report->keys[i] = 0; + empty = RO_INC(empty); + } + else { + offset++; + } + i = RO_INC(i); + } while (i != cb_tail); + cb_tail = RO_SUB(cb_tail, offset); + } + } + } + } + // add to tail + keyboard_report->keys[cb_tail] = code; + cb_tail = RO_INC(cb_tail); + cb_count++; +#else + int8_t i = 0; + int8_t empty = -1; + for (; i < KEYBOARD_REPORT_KEYS; i++) { + if (keyboard_report->keys[i] == code) { + break; + } + if (empty == -1 && keyboard_report->keys[i] == 0) { + empty = i; + } + } + if (i == KEYBOARD_REPORT_KEYS) { + if (empty != -1) { + keyboard_report->keys[empty] = code; + } + } +#endif +} + +static inline void del_key_byte(uint8_t code) +{ +#ifdef USB_6KRO_ENABLE + uint8_t i = cb_head; + if (cb_count) { + do { + if (keyboard_report->keys[i] == code) { + keyboard_report->keys[i] = 0; + cb_count--; + if (cb_count == 0) { + // reset head and tail + cb_tail = cb_head = 0; + } + if (i == RO_DEC(cb_tail)) { + // left shift when next to tail + do { + cb_tail = RO_DEC(cb_tail); + if (keyboard_report->keys[RO_DEC(cb_tail)] != 0) { + break; + } + } while (cb_tail != cb_head); + } + break; + } + i = RO_INC(i); + } while (i != cb_tail); + } +#else + for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { + if (keyboard_report->keys[i] == code) { + keyboard_report->keys[i] = 0; + } + } +#endif +} + +#ifdef NKRO_ENABLE +static inline void add_key_bit(uint8_t code) +{ + if ((code>>3) < KEYBOARD_REPORT_BITS) { + keyboard_report->nkro.bits[code>>3] |= 1<<(code&7); + } else { + dprintf("add_key_bit: can't add: %02X\n", code); + } +} + +static inline void del_key_bit(uint8_t code) +{ + if ((code>>3) < KEYBOARD_REPORT_BITS) { + keyboard_report->nkro.bits[code>>3] &= ~(1<<(code&7)); + } else { + dprintf("del_key_bit: can't del: %02X\n", code); + } +} +#endif diff --git a/common/action_util.h b/common/action_util.h new file mode 100644 index 000000000..a955638b4 --- /dev/null +++ b/common/action_util.h @@ -0,0 +1,66 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef ACTION_UTIL_H +#define ACTION_UTIL_H + +#include +#include "report.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern report_keyboard_t *keyboard_report; + +void send_keyboard_report(void); + +/* key */ +void add_key(uint8_t key); +void del_key(uint8_t key); +void clear_keys(void); + +/* modifier */ +uint8_t get_mods(void); +void add_mods(uint8_t mods); +void del_mods(uint8_t mods); +void set_mods(uint8_t mods); +void clear_mods(void); + +/* weak modifier */ +uint8_t get_weak_mods(void); +void add_weak_mods(uint8_t mods); +void del_weak_mods(uint8_t mods); +void set_weak_mods(uint8_t mods); +void clear_weak_mods(void); + +/* oneshot modifier */ +void set_oneshot_mods(uint8_t mods); +void clear_oneshot_mods(void); +void oneshot_toggle(void); +void oneshot_enable(void); +void oneshot_disable(void); + +/* inspect */ +uint8_t has_anykey(void); +uint8_t has_anymod(void); +uint8_t get_first_key(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/avr/bootloader.c b/common/avr/bootloader.c new file mode 100644 index 000000000..cda295b18 --- /dev/null +++ b/common/avr/bootloader.c @@ -0,0 +1,148 @@ +#include +#include +#include +#include +#include +#include +#include "bootloader.h" + +#ifdef PROTOCOL_LUFA +#include +#endif + + +/* Boot Section Size in *BYTEs* + * Teensy halfKay 512 + * Teensy++ halfKay 1024 + * Atmel DFU loader 4096 + * LUFA bootloader 4096 + * USBaspLoader 2048 + */ +#ifndef BOOTLOADER_SIZE +#warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h. +#define BOOTLOADER_SIZE 4096 +#endif + +#define FLASH_SIZE (FLASHEND + 1L) +#define BOOTLOADER_START (FLASH_SIZE - BOOTLOADER_SIZE) + + +/* + * Entering the Bootloader via Software + * http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html + */ +#define BOOTLOADER_RESET_KEY 0xB007B007 +uint32_t reset_key __attribute__ ((section (".noinit"))); + +/* initialize MCU status by watchdog reset */ +void bootloader_jump(void) { +#ifdef PROTOCOL_LUFA + USB_Disable(); + cli(); + _delay_ms(2000); +#endif + +#ifdef PROTOCOL_PJRC + cli(); + UDCON = 1; + USBCON = (1< +#include +#include +#include "eeconfig.h" + +void eeconfig_init(void) +{ + eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); + eeprom_write_byte(EECONFIG_DEBUG, 0); + eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0); + eeprom_write_byte(EECONFIG_KEYMAP, 0); + eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); +#ifdef BACKLIGHT_ENABLE + eeprom_write_byte(EECONFIG_BACKLIGHT, 0); +#endif +} + +void eeconfig_enable(void) +{ + eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); +} + +void eeconfig_disable(void) +{ + eeprom_write_word(EECONFIG_MAGIC, 0xFFFF); +} + +bool eeconfig_is_enabled(void) +{ + return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); +} + +uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } +void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); } + +uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } +void eeconfig_write_default_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } + +uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); } +void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); } + +#ifdef BACKLIGHT_ENABLE +uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } +void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); } +#endif diff --git a/common/avr/suspend.c b/common/avr/suspend.c new file mode 100644 index 000000000..80243f02b --- /dev/null +++ b/common/avr/suspend.c @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include "matrix.h" +#include "action.h" +#include "backlight.h" +#include "suspend_avr.h" +#include "suspend.h" +#include "timer.h" +#ifdef PROTOCOL_LUFA +#include "lufa.h" +#endif + + +#define wdt_intr_enable(value) \ +__asm__ __volatile__ ( \ + "in __tmp_reg__,__SREG__" "\n\t" \ + "cli" "\n\t" \ + "wdr" "\n\t" \ + "sts %0,%1" "\n\t" \ + "out __SREG__,__tmp_reg__" "\n\t" \ + "sts %0,%2" "\n\t" \ + : /* no outputs */ \ + : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \ + "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \ + "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \ + _BV(WDIE) | (value & 0x07)) ) \ + : "r0" \ +) + + +void suspend_idle(uint8_t time) +{ + cli(); + set_sleep_mode(SLEEP_MODE_IDLE); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); +} + +/* Power down MCU with watchdog timer + * wdto: watchdog timer timeout defined in + * WDTO_15MS + * WDTO_30MS + * WDTO_60MS + * WDTO_120MS + * WDTO_250MS + * WDTO_500MS + * WDTO_1S + * WDTO_2S + * WDTO_4S + * WDTO_8S + */ +static uint8_t wdt_timeout = 0; +static void power_down(uint8_t wdto) +{ +#ifdef PROTOCOL_LUFA + if (USB_DeviceState == DEVICE_STATE_Configured) return; +#endif + wdt_timeout = wdto; + + // Watchdog Interrupt Mode + wdt_intr_enable(wdto); + + // TODO: more power saving + // See PicoPower application note + // - I/O port input with pullup + // - prescale clock + // - BOD disable + // - Power Reduction Register PRR + set_sleep_mode(SLEEP_MODE_PWR_DOWN); + sleep_enable(); + sei(); + sleep_cpu(); + sleep_disable(); + + // Disable watchdog after sleep + wdt_disable(); +} + +void suspend_power_down(void) +{ + power_down(WDTO_15MS); +} + +bool suspend_wakeup_condition(void) +{ + matrix_power_up(); + matrix_scan(); + matrix_power_down(); + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + if (matrix_get_row(r)) return true; + } + return false; +} + +// run immediately after wakeup +void suspend_wakeup_init(void) +{ + // clear keyboard state + clear_keyboard(); +#ifdef BACKLIGHT_ENABLE + backlight_init(); +#endif +} + +#ifndef NO_SUSPEND_POWER_DOWN +/* watchdog timeout */ +ISR(WDT_vect) +{ + // compensate timer for sleep + switch (wdt_timeout) { + case WDTO_15MS: + timer_count += 15 + 2; // WDTO_15MS + 2(from observation) + break; + default: + ; + } +} +#endif diff --git a/common/avr/suspend_avr.h b/common/avr/suspend_avr.h new file mode 100644 index 000000000..357102da4 --- /dev/null +++ b/common/avr/suspend_avr.h @@ -0,0 +1,27 @@ +#ifndef SUSPEND_AVR_H +#define SUSPEND_AVR_H + +#include +#include +#include +#include +#include + + +#define wdt_intr_enable(value) \ +__asm__ __volatile__ ( \ + "in __tmp_reg__,__SREG__" "\n\t" \ + "cli" "\n\t" \ + "wdr" "\n\t" \ + "sts %0,%1" "\n\t" \ + "out __SREG__,__tmp_reg__" "\n\t" \ + "sts %0,%2" "\n\t" \ + : /* no outputs */ \ + : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \ + "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \ + "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \ + _BV(WDIE) | (value & 0x07)) ) \ + : "r0" \ +) + +#endif diff --git a/common/avr/timer.c b/common/avr/timer.c new file mode 100644 index 000000000..292b41c3a --- /dev/null +++ b/common/avr/timer.c @@ -0,0 +1,117 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include "timer_avr.h" +#include "timer.h" + + +// counter resolution 1ms +// NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} +volatile uint32_t timer_count = 0; + +void timer_init(void) +{ + // Timer0 CTC mode + TCCR0A = 0x02; + +#if TIMER_PRESCALER == 1 + TCCR0B = 0x01; +#elif TIMER_PRESCALER == 8 + TCCR0B = 0x02; +#elif TIMER_PRESCALER == 64 + TCCR0B = 0x03; +#elif TIMER_PRESCALER == 256 + TCCR0B = 0x04; +#elif TIMER_PRESCALER == 1024 + TCCR0B = 0x05; +#else +# error "Timer prescaler value is NOT vaild." +#endif + + OCR0A = TIMER_RAW_TOP; + TIMSK0 = (1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef TIMER_AVR_H +#define TIMER_AVR_H 1 + +#include + +#ifndef TIMER_PRESCALER +# if F_CPU > 16000000 +# define TIMER_PRESCALER 256 +# elif F_CPU > 2000000 +# define TIMER_PRESCALER 64 +# elif F_CPU > 250000 +# define TIMER_PRESCALER 8 +# else +# define TIMER_PRESCALER 1 +# endif +#endif +#define TIMER_RAW_FREQ (F_CPU/TIMER_PRESCALER) +#define TIMER_RAW TCNT0 +#define TIMER_RAW_TOP (TIMER_RAW_FREQ/1000) + +#if (TIMER_RAW_TOP > 255) +# error "Timer0 can't count 1ms at this clock freq. Use larger prescaler." +#endif + +#endif diff --git a/common/avr/xprintf.S b/common/avr/xprintf.S new file mode 100644 index 000000000..0cec70ce2 --- /dev/null +++ b/common/avr/xprintf.S @@ -0,0 +1,500 @@ +;---------------------------------------------------------------------------; +; Extended itoa, puts, printf and atoi (C)ChaN, 2011 +;---------------------------------------------------------------------------; + + // Base size is 152 bytes +#define CR_CRLF 0 // Convert \n to \r\n (+10 bytes) +#define USE_XPRINTF 1 // Enable xprintf function (+194 bytes) +#define USE_XSPRINTF 0 // Add xsprintf function (+78 bytes) +#define USE_XFPRINTF 0 // Add xfprintf function (+54 bytes) +#define USE_XATOI 0 // Enable xatoi function (+182 bytes) + + +#if FLASHEND > 0x1FFFF +#error xitoa module does not support 256K devices +#endif + +.nolist +#include // Include device specific definitions. +.list + +#ifdef SPM_PAGESIZE // Recent devices have "lpm Rd,Z+" and "movw". +.macro _LPMI reg + lpm \reg, Z+ +.endm +.macro _MOVW dh,dl, sh,sl + movw \dl, \sl +.endm +#else // Earlier devices do not have "lpm Rd,Z+" nor "movw". +.macro _LPMI reg + lpm + mov \reg, r0 + adiw ZL, 1 +.endm +.macro _MOVW dh,dl, sh,sl + mov \dl, \sl + mov \dh, \sh +.endm +#endif + + + +;--------------------------------------------------------------------------- +; Stub function to forward to user output function +; +;Prototype: void xputc (char chr // a character to be output +; ); +;Size: 12/12 words + +.section .bss +.global xfunc_out ; xfunc_out must be initialized before using this module. +xfunc_out: .ds.w 1 +.section .text + + +.func xputc +.global xputc +xputc: +#if CR_CRLF + cpi r24, 10 ;LF --> CRLF + brne 1f ; + ldi r24, 13 ; + rcall 1f ; + ldi r24, 10 ;/ +1: +#endif + push ZH + push ZL + lds ZL, xfunc_out+0 ;Pointer to the registered output function. + lds ZH, xfunc_out+1 ;/ + sbiw ZL, 0 ;Skip if null + breq 2f ;/ + icall +2: pop ZL + pop ZH + ret +.endfunc + + + +;--------------------------------------------------------------------------- +; Direct ROM string output +; +;Prototype: void xputs (const char *str_p // rom string to be output +; ); + +.func xputs +.global xputs +xputs: + _MOVW ZH,ZL, r25,r24 ; Z = pointer to rom string +1: _LPMI r24 + cpi r24, 0 + breq 2f + rcall xputc + rjmp 1b +2: ret +.endfunc + + +;--------------------------------------------------------------------------- +; Extended direct numeral string output (32bit version) +; +;Prototype: void xitoa (long value, // value to be output +; char radix, // radix +; char width); // minimum width +; + +.func xitoa +.global xitoa +xitoa: + ;r25:r22 = value, r20 = base, r18 = digits + clr r31 ;r31 = stack level + ldi r30, ' ' ;r30 = sign + ldi r19, ' ' ;r19 = filler + sbrs r20, 7 ;When base indicates signd format and the value + rjmp 0f ;is minus, add a '-'. + neg r20 ; + sbrs r25, 7 ; + rjmp 0f ; + ldi r30, '-' ; + com r22 ; + com r23 ; + com r24 ; + com r25 ; + adc r22, r1 ; + adc r23, r1 ; + adc r24, r1 ; + adc r25, r1 ;/ +0: sbrs r18, 7 ;When digits indicates zero filled, + rjmp 1f ;filler is '0'. + neg r18 ; + ldi r19, '0' ;/ + ;----- string conversion loop +1: ldi r21, 32 ;r26 = r25:r22 % r20 + clr r26 ;r25:r22 /= r20 +2: lsl r22 ; + rol r23 ; + rol r24 ; + rol r25 ; + rol r26 ; + cp r26, r20 ; + brcs 3f ; + sub r26, r20 ; + inc r22 ; +3: dec r21 ; + brne 2b ;/ + cpi r26, 10 ;r26 is a numeral digit '0'-'F' + brcs 4f ; + subi r26, -7 ; +4: subi r26, -'0' ;/ + push r26 ;Stack it + inc r31 ;/ + cp r22, r1 ;Repeat until r25:r22 gets zero + cpc r23, r1 ; + cpc r24, r1 ; + cpc r25, r1 ; + brne 1b ;/ + + cpi r30, '-' ;Minus sign if needed + brne 5f ; + push r30 ; + inc r31 ;/ +5: cp r31, r18 ;Filler + brcc 6f ; + push r19 ; + inc r31 ; + rjmp 5b ;/ + +6: pop r24 ;Flush stacked digits and exit + rcall xputc ; + dec r31 ; + brne 6b ;/ + + ret +.endfunc + + + +;---------------------------------------------------------------------------; +; Formatted string output (16/32bit version) +; +;Prototype: +; void __xprintf (const char *format_p, ...); +; void __xsprintf(char*, const char *format_p, ...); +; void __xfprintf(void(*func)(char), const char *format_p, ...); +; + +#if USE_XPRINTF + +.func xvprintf +xvprintf: + ld ZL, Y+ ;Z = pointer to format string + ld ZH, Y+ ;/ + +0: _LPMI r24 ;Get a format char + cpi r24, 0 ;End of format string? + breq 90f ;/ + cpi r24, '%' ;Is format? + breq 20f ;/ +1: rcall xputc ;Put a normal character + rjmp 0b ;/ +90: ret + +20: ldi r18, 0 ;r18: digits + clt ;T: filler + _LPMI r21 ;Get flags + cpi r21, '%' ;Is a %? + breq 1b ;/ + cpi r21, '0' ;Zero filled? + brne 23f ; + set ;/ +22: _LPMI r21 ;Get width +23: cpi r21, '9'+1 ; + brcc 24f ; + subi r21, '0' ; + brcs 90b ; + lsl r18 ; + mov r0, r18 ; + lsl r18 ; + lsl r18 ; + add r18, r0 ; + add r18, r21 ; + rjmp 22b ;/ + +24: brtc 25f ;get value (low word) + neg r18 ; +25: ld r24, Y+ ; + ld r25, Y+ ;/ + cpi r21, 'c' ;Is type character? + breq 1b ;/ + cpi r21, 's' ;Is type RAM string? + breq 50f ;/ + cpi r21, 'S' ;Is type ROM string? + breq 60f ;/ + _MOVW r23,r22,r25,r24 ;r25:r22 = value + clr r24 ; + clr r25 ; + clt ;/ + cpi r21, 'l' ;Is long int? + brne 26f ; + ld r24, Y+ ;get value (high word) + ld r25, Y+ ; + set ; + _LPMI r21 ;/ +26: cpi r21, 'd' ;Is type signed decimal? + brne 27f ;/ + ldi r20, -10 ; + brts 40f ; + sbrs r23, 7 ; + rjmp 40f ; + ldi r24, -1 ; + ldi r25, -1 ; + rjmp 40f ;/ +27: cpi r21, 'u' ;Is type unsigned decimal? + ldi r20, 10 ; + breq 40f ;/ + cpi r21, 'X' ;Is type hexdecimal? + ldi r20, 16 ; + breq 40f ;/ + cpi r21, 'b' ;Is type binary? + ldi r20, 2 ; + breq 40f ;/ + ret ;abort +40: push ZH ;Output the value + push ZL ; + rcall xitoa ; +42: pop ZL ; + pop ZH ; + rjmp 0b ;/ + +50: push ZH ;Put a string on the RAM + push ZL + _MOVW ZH,ZL, r25,r24 +51: ld r24, Z+ + cpi r24, 0 + breq 42b + rcall xputc + rjmp 51b + +60: push ZH ;Put a string on the ROM + push ZL + rcall xputs + rjmp 42b +.endfunc + + +.func __xprintf +.global __xprintf +__xprintf: + push YH + push YL + in YL, _SFR_IO_ADDR(SPL) +#ifdef SPH + in YH, _SFR_IO_ADDR(SPH) +#else + clr YH +#endif + adiw YL, 5 ;Y = pointer to arguments + rcall xvprintf + pop YL + pop YH + ret +.endfunc + + +#if USE_XSPRINTF + +.func __xsprintf +putram: + _MOVW ZH,ZL, r15,r14 + st Z+, r24 + _MOVW r15,r14, ZH,ZL + ret +.global __xsprintf +__xsprintf: + push YH + push YL + in YL, _SFR_IO_ADDR(SPL) +#ifdef SPH + in YH, _SFR_IO_ADDR(SPH) +#else + clr YH +#endif + adiw YL, 5 ;Y = pointer to arguments + lds ZL, xfunc_out+0 ;Save registered output function + lds ZH, xfunc_out+1 ; + push ZL ; + push ZH ;/ + ldi ZL, lo8(pm(putram));Set local output function + ldi ZH, hi8(pm(putram)); + sts xfunc_out+0, ZL ; + sts xfunc_out+1, ZH ;/ + push r15 ;Initialize pointer to string buffer + push r14 ; + ld r14, Y+ ; + ld r15, Y+ ;/ + rcall xvprintf + _MOVW ZH,ZL, r15,r14 ;Terminate string + st Z, r1 ; + pop r14 ; + pop r15 ;/ + pop ZH ;Restore registered output function + pop ZL ; + sts xfunc_out+0, ZL ; + sts xfunc_out+1, ZH ;/ + pop YL + pop YH + ret +.endfunc +#endif + + +#if USE_XFPRINTF +.func __xfprintf +.global __xfprintf +__xfprintf: + push YH + push YL + in YL, _SFR_IO_ADDR(SPL) +#ifdef SPH + in YH, _SFR_IO_ADDR(SPH) +#else + clr YH +#endif + adiw YL, 5 ;Y = pointer to arguments + lds ZL, xfunc_out+0 ;Save registered output function + lds ZH, xfunc_out+1 ; + push ZL ; + push ZH ;/ + ld ZL, Y+ ;Set output function + ld ZH, Y+ ; + sts xfunc_out+0, ZL ; + sts xfunc_out+1, ZH ;/ + rcall xvprintf + pop ZH ;Restore registered output function + pop ZL ; + sts xfunc_out+0, ZL ; + sts xfunc_out+1, ZH ;/ + pop YL + pop YH + ret +.endfunc +#endif + +#endif + + + +;--------------------------------------------------------------------------- +; Extended numeral string input +; +;Prototype: +; char xatoi ( /* 1: Successful, 0: Failed */ +; const char **str, /* pointer to pointer to source string */ +; long *res /* result */ +; ); +; + + +#if USE_XATOI +.func xatoi +.global xatoi +xatoi: + _MOVW r1, r0, r23, r22 + _MOVW XH, XL, r25, r24 + ld ZL, X+ + ld ZH, X+ + clr r18 ;r21:r18 = 0; + clr r19 ; + clr r20 ; + clr r21 ;/ + clt ;T = 0; + + ldi r25, 10 ;r25 = 10; + rjmp 41f ;/ +40: adiw ZL, 1 ;Z++; +41: ld r22, Z ;r22 = *Z; + cpi r22, ' ' ;if(r22 == ' ') continue + breq 40b ;/ + brcs 70f ;if(r22 < ' ') error; + cpi r22, '-' ;if(r22 == '-') { + brne 42f ; T = 1; + set ; continue; + rjmp 40b ;} +42: cpi r22, '9'+1 ;if(r22 > '9') error; + brcc 70f ;/ + cpi r22, '0' ;if(r22 < '0') error; + brcs 70f ;/ + brne 51f ;if(r22 > '0') cv_start; + ldi r25, 8 ;r25 = 8; + adiw ZL, 1 ;r22 = *(++Z); + ld r22, Z ;/ + cpi r22, ' '+1 ;if(r22 <= ' ') exit; + brcs 80f ;/ + cpi r22, 'b' ;if(r22 == 'b') { + brne 43f ; r25 = 2; + ldi r25, 2 ; cv_start; + rjmp 50f ;} +43: cpi r22, 'x' ;if(r22 != 'x') error; + brne 51f ;/ + ldi r25, 16 ;r25 = 16; + +50: adiw ZL, 1 ;Z++; + ld r22, Z ;r22 = *Z; +51: cpi r22, ' '+1 ;if(r22 <= ' ') break; + brcs 80f ;/ + cpi r22, 'a' ;if(r22 >= 'a') r22 =- 0x20; + brcs 52f ; + subi r22, 0x20 ;/ +52: subi r22, '0' ;if((r22 -= '0') < 0) error; + brcs 70f ;/ + cpi r22, 10 ;if(r22 >= 10) { + brcs 53f ; r22 -= 7; + subi r22, 7 ; if(r22 < 10) + cpi r22, 10 ; + brcs 70f ;} +53: cp r22, r25 ;if(r22 >= r25) error; + brcc 70f ;/ +60: ldi r24, 33 ;r21:r18 *= r25; + sub r23, r23 ; +61: brcc 62f ; + add r23, r25 ; +62: lsr r23 ; + ror r21 ; + ror r20 ; + ror r19 ; + ror r18 ; + dec r24 ; + brne 61b ;/ + add r18, r22 ;r21:r18 += r22; + adc r19, r24 ; + adc r20, r24 ; + adc r21, r24 ;/ + rjmp 50b ;repeat + +70: ldi r24, 0 + rjmp 81f +80: ldi r24, 1 +81: brtc 82f + clr r22 + com r18 + com r19 + com r20 + com r21 + adc r18, r22 + adc r19, r22 + adc r20, r22 + adc r21, r22 +82: st -X, ZH + st -X, ZL + _MOVW XH, XL, r1, r0 + st X+, r18 + st X+, r19 + st X+, r20 + st X+, r21 + clr r1 + ret +.endfunc +#endif + + diff --git a/common/avr/xprintf.h b/common/avr/xprintf.h new file mode 100644 index 000000000..59c6f2531 --- /dev/null +++ b/common/avr/xprintf.h @@ -0,0 +1,111 @@ +/*--------------------------------------------------------------------------- + Extended itoa, puts and printf (C)ChaN, 2011 +-----------------------------------------------------------------------------*/ + +#ifndef XPRINTF_H +#define XPRINTF_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void (*xfunc_out)(uint8_t); +#define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func) + +/* This is a pointer to user defined output function. It must be initialized + before using this modle. +*/ + +void xputc(char chr); + +/* This is a stub function to forward outputs to user defined output function. + All outputs from this module are output via this function. +*/ + + +/*-----------------------------------------------------------------------------*/ +void xputs(const char *string_p); + +/* The string placed in the ROM is forwarded to xputc() directly. +*/ + + +/*-----------------------------------------------------------------------------*/ +void xitoa(long value, char radix, char width); + +/* Extended itoa(). + + value radix width output + 100 10 6 " 100" + 100 10 -6 "000100" + 100 10 0 "100" + 4294967295 10 0 "4294967295" + 4294967295 -10 0 "-1" + 655360 16 -8 "000A0000" + 1024 16 0 "400" + 0x55 2 -8 "01010101" +*/ + + +/*-----------------------------------------------------------------------------*/ +#define xprintf(format, ...) __xprintf(PSTR(format), ##__VA_ARGS__) +#define xsprintf(str, format, ...) __xsprintf(str, PSTR(format), ##__VA_ARGS__) +#define xfprintf(func, format, ...) __xfprintf(func, PSTR(format), ##__VA_ARGS__) + +void __xprintf(const char *format_p, ...); /* Send formatted string to the registered device */ +void __xsprintf(char*, const char *format_p, ...); /* Put formatted string to the memory */ +void __xfprintf(void(*func)(uint8_t), const char *format_p, ...); /* Send formatted string to the specified device */ + +/* Format string is placed in the ROM. The format flags is similar to printf(). + + %[flag][width][size]type + + flag + A '0' means filled with '0' when output is shorter than width. + ' ' is used in default. This is effective only numeral type. + width + Minimum width in decimal number. This is effective only numeral type. + Default width is zero. + size + A 'l' means the argument is long(32bit). Default is short(16bit). + This is effective only numeral type. + type + 'c' : Character, argument is the value + 's' : String placed on the RAM, argument is the pointer + 'S' : String placed on the ROM, argument is the pointer + 'd' : Signed decimal, argument is the value + 'u' : Unsigned decimal, argument is the value + 'X' : Hexdecimal, argument is the value + 'b' : Binary, argument is the value + '%' : '%' + +*/ + + +/*-----------------------------------------------------------------------------*/ +char xatoi(char **str, long *ret); + +/* Get value of the numeral string. + + str + Pointer to pointer to source string + + "0b11001010" binary + "0377" octal + "0xff800" hexdecimal + "1250000" decimal + "-25000" decimal + + ret + Pointer to return value +*/ + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/common/backlight.c b/common/backlight.c new file mode 100644 index 000000000..558ad9b01 --- /dev/null +++ b/common/backlight.c @@ -0,0 +1,85 @@ +/* +Copyright 2013 Mathias Andersson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "backlight.h" +#include "eeconfig.h" +#include "debug.h" + +backlight_config_t backlight_config; + +void backlight_init(void) +{ + /* check signature */ + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + backlight_config.raw = eeconfig_read_backlight(); + backlight_set(backlight_config.enable ? backlight_config.level : 0); +} + +void backlight_increase(void) +{ + if(backlight_config.level < BACKLIGHT_LEVELS) + { + backlight_config.level++; + backlight_config.enable = 1; + eeconfig_write_backlight(backlight_config.raw); + } + dprintf("backlight increase: %u\n", backlight_config.level); + backlight_set(backlight_config.level); +} + +void backlight_decrease(void) +{ + if(backlight_config.level > 0) + { + backlight_config.level--; + backlight_config.enable = !!backlight_config.level; + eeconfig_write_backlight(backlight_config.raw); + } + dprintf("backlight decrease: %u\n", backlight_config.level); + backlight_set(backlight_config.level); +} + +void backlight_toggle(void) +{ + backlight_config.enable ^= 1; + eeconfig_write_backlight(backlight_config.raw); + dprintf("backlight toggle: %u\n", backlight_config.enable); + backlight_set(backlight_config.enable ? backlight_config.level : 0); +} + +void backlight_step(void) +{ + backlight_config.level++; + if(backlight_config.level > BACKLIGHT_LEVELS) + { + backlight_config.level = 0; + } + backlight_config.enable = !!backlight_config.level; + eeconfig_write_backlight(backlight_config.raw); + dprintf("backlight step: %u\n", backlight_config.level); + backlight_set(backlight_config.level); +} + +void backlight_level(uint8_t level) +{ + backlight_config.level ^= level; + backlight_config.enable = !!backlight_config.level; + eeconfig_write_backlight(backlight_config.raw); + backlight_set(backlight_config.level); +} diff --git a/common/backlight.h b/common/backlight.h new file mode 100644 index 000000000..525ec8bbe --- /dev/null +++ b/common/backlight.h @@ -0,0 +1,40 @@ +/* +Copyright 2013 Mathias Andersson + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef BACKLIGHT_H +#define BACKLIGHT_H + +#include +#include + +typedef union { + uint8_t raw; + struct { + bool enable :1; + uint8_t level :7; + }; +} backlight_config_t; + +void backlight_init(void); +void backlight_increase(void); +void backlight_decrease(void); +void backlight_toggle(void); +void backlight_step(void); +void backlight_set(uint8_t level); +void backlight_level(uint8_t level); + +#endif diff --git a/common/bootloader.h b/common/bootloader.h new file mode 100644 index 000000000..44775039d --- /dev/null +++ b/common/bootloader.h @@ -0,0 +1,25 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef BOOTLOADER_H +#define BOOTLOADER_H + + +/* give code for your bootloader to come up if needed */ +void bootloader_jump(void); + +#endif diff --git a/common/bootmagic.c b/common/bootmagic.c new file mode 100644 index 000000000..b002a5856 --- /dev/null +++ b/common/bootmagic.c @@ -0,0 +1,128 @@ +#include +#include +#include +#include "matrix.h" +#include "bootloader.h" +#include "debug.h" +#include "keymap.h" +#include "host.h" +#include "action_layer.h" +#include "eeconfig.h" +#include "bootmagic.h" + + +void bootmagic(void) +{ + /* check signature */ + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + + /* do scans in case of bounce */ + print("boogmagic scan: ... "); + uint8_t scan = 100; + while (scan--) { matrix_scan(); _delay_ms(10); } + print("done.\n"); + + /* bootmagic skip */ + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) { + return; + } + + /* eeconfig clear */ + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) { + eeconfig_init(); + } + + /* bootloader */ + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_BOOTLOADER)) { + bootloader_jump(); + } + + /* debug enable */ + debug_config.raw = eeconfig_read_debug(); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { + debug_config.matrix = !debug_config.matrix; + } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { + debug_config.keyboard = !debug_config.keyboard; + } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MOUSE)) { + debug_config.mouse = !debug_config.mouse; + } else { + debug_config.enable = !debug_config.enable; + } + } + eeconfig_write_debug(debug_config.raw); + + /* keymap config */ + keymap_config.raw = eeconfig_read_keymap(); + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { + keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; + } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { + keymap_config.capslock_to_control = !keymap_config.capslock_to_control; + } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { + keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; + } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { + keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; + } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_NO_GUI)) { + keymap_config.no_gui = !keymap_config.no_gui; + } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { + keymap_config.swap_grave_esc = !keymap_config.swap_grave_esc; + } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { + keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; + } + if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) { + keymap_config.nkro = !keymap_config.nkro; + } + eeconfig_write_keymap(keymap_config.raw); + +#ifdef NKRO_ENABLE + keyboard_nkro = keymap_config.nkro; +#endif + + /* default layer */ + uint8_t default_layer = 0; + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { default_layer |= (1<<1); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { default_layer |= (1<<2); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { default_layer |= (1<<3); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { default_layer |= (1<<4); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { default_layer |= (1<<5); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } + if (default_layer) { + eeconfig_write_default_layer(default_layer); + default_layer_set((uint32_t)default_layer); + } else { + default_layer = eeconfig_read_default_layer(); + default_layer_set((uint32_t)default_layer); + } +} + +static bool scan_keycode(uint8_t keycode) +{ + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + matrix_row_t matrix_row = matrix_get_row(r); + for (uint8_t c = 0; c < MATRIX_COLS; c++) { + if (matrix_row & ((matrix_row_t)1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include +#include +#include +#include "keycode.h" +#include "host.h" +#include "keymap.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "timer.h" +#include "keyboard.h" +#include "bootloader.h" +#include "action_layer.h" +#include "action_util.h" +#include "eeconfig.h" +#include "sleep_led.h" +#include "led.h" +#include "command.h" +#include "backlight.h" + +#ifdef MOUSEKEY_ENABLE +#include "mousekey.h" +#endif + +#ifdef PROTOCOL_PJRC +# include "usb_keyboard.h" +# ifdef EXTRAKEY_ENABLE +# include "usb_extra.h" +# endif +#endif + +#ifdef PROTOCOL_VUSB +# include "usbdrv.h" +#endif + + +static bool command_common(uint8_t code); +static void command_common_help(void); +static bool command_console(uint8_t code); +static void command_console_help(void); +#ifdef MOUSEKEY_ENABLE +static bool mousekey_console(uint8_t code); +static void mousekey_console_help(void); +#endif + +static uint8_t numkey2num(uint8_t code); +static void switch_default_layer(uint8_t layer); + + +command_state_t command_state = ONESHOT; + + +bool command_proc(uint8_t code) +{ + switch (command_state) { + case ONESHOT: + if (!IS_COMMAND()) + return false; + return (command_extra(code) || command_common(code)); + break; + case CONSOLE: + if (IS_COMMAND()) + return (command_extra(code) || command_common(code)); + else + return (command_console_extra(code) || command_console(code)); + break; +#ifdef MOUSEKEY_ENABLE + case MOUSEKEY: + mousekey_console(code); + break; +#endif + default: + command_state = ONESHOT; + return false; + } + return true; +} + +/* TODO: Refactoring is needed. */ +/* This allows to define extra commands. return false when not processed. */ +bool command_extra(uint8_t code) __attribute__ ((weak)); +bool command_extra(uint8_t code) +{ + return false; +} + +bool command_console_extra(uint8_t code) __attribute__ ((weak)); +bool command_console_extra(uint8_t code) +{ + return false; +} + + +/*********************************************************** + * Command common + ***********************************************************/ +static void command_common_help(void) +{ + print("\n\n----- Command Help -----\n"); + print("c: enter console mode\n"); + print("d: toggle debug enable\n"); + print("x: toggle matrix debug\n"); + print("k: toggle keyboard debug\n"); + print("m: toggle mouse debug\n"); +#ifdef SLEEP_LED_ENABLE + print("z: toggle sleep LED test\n"); +#endif + print("v: print device version & info\n"); + print("t: print timer count\n"); + print("s: print status\n"); + print("e: print eeprom config\n"); +#ifdef NKRO_ENABLE + print("n: toggle NKRO\n"); +#endif + print("0/F10: switch to Layer0 \n"); + print("1/F1: switch to Layer1 \n"); + print("2/F2: switch to Layer2 \n"); + print("3/F3: switch to Layer3 \n"); + print("4/F4: switch to Layer4 \n"); + print("PScr: power down/remote wake-up\n"); + print("Caps: Lock Keyboard(Child Proof)\n"); + print("Paus: jump to bootloader\n"); +} + +#ifdef BOOTMAGIC_ENABLE +static void print_eeconfig(void) +{ + print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n"); + + debug_config_t dc; + dc.raw = eeconfig_read_debug(); + print("debug_config.raw: "); print_hex8(dc.raw); print("\n"); + print(".enable: "); print_dec(dc.enable); print("\n"); + print(".matrix: "); print_dec(dc.matrix); print("\n"); + print(".keyboard: "); print_dec(dc.keyboard); print("\n"); + print(".mouse: "); print_dec(dc.mouse); print("\n"); + + keymap_config_t kc; + kc.raw = eeconfig_read_keymap(); + print("keymap_config.raw: "); print_hex8(kc.raw); print("\n"); + print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n"); + print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n"); + print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n"); + print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n"); + print(".no_gui: "); print_dec(kc.no_gui); print("\n"); + print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n"); + print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n"); + print(".nkro: "); print_dec(kc.nkro); print("\n"); + +#ifdef BACKLIGHT_ENABLE + backlight_config_t bc; + bc.raw = eeconfig_read_backlight(); + print("backlight_config.raw: "); print_hex8(bc.raw); print("\n"); + print(".enable: "); print_dec(bc.enable); print("\n"); + print(".level: "); print_dec(bc.level); print("\n"); +#endif +} +#endif + +static bool command_common(uint8_t code) +{ + static host_driver_t *host_driver = 0; + switch (code) { +#ifdef SLEEP_LED_ENABLE + case KC_Z: + // test breathing sleep LED + print("Sleep LED test\n"); + sleep_led_toggle(); + led_set(host_keyboard_leds()); + break; +#endif +#ifdef BOOTMAGIC_ENABLE + case KC_E: + print("eeconfig:\n"); + print_eeconfig(); + break; +#endif + case KC_CAPSLOCK: + if (host_get_driver()) { + host_driver = host_get_driver(); + clear_keyboard(); + host_set_driver(0); + print("Locked.\n"); + } else { + host_set_driver(host_driver); + print("Unlocked.\n"); + } + break; + case KC_H: + case KC_SLASH: /* ? */ + command_common_help(); + break; + case KC_C: + debug_matrix = false; + debug_keyboard = false; + debug_mouse = false; + debug_enable = false; + command_console_help(); + print("\nEnter Console Mode\n"); + print("C> "); + command_state = CONSOLE; + break; + case KC_PAUSE: + clear_keyboard(); + print("\n\nJump to bootloader... "); + _delay_ms(1000); + bootloader_jump(); // not return + print("not supported.\n"); + break; + case KC_D: + if (debug_enable) { + print("\nDEBUG: disabled.\n"); + debug_matrix = false; + debug_keyboard = false; + debug_mouse = false; + debug_enable = false; + } else { + print("\nDEBUG: enabled.\n"); + debug_enable = true; + } + break; + case KC_X: // debug matrix toggle + debug_matrix = !debug_matrix; + if (debug_matrix) { + print("\nDEBUG: matrix enabled.\n"); + debug_enable = true; + } else { + print("\nDEBUG: matrix disabled.\n"); + } + break; + case KC_K: // debug keyboard toggle + debug_keyboard = !debug_keyboard; + if (debug_keyboard) { + print("\nDEBUG: keyboard enabled.\n"); + debug_enable = true; + } else { + print("\nDEBUG: keyboard disabled.\n"); + } + break; + case KC_M: // debug mouse toggle + debug_mouse = !debug_mouse; + if (debug_mouse) { + print("\nDEBUG: mouse enabled.\n"); + debug_enable = true; + } else { + print("\nDEBUG: mouse disabled.\n"); + } + break; + case KC_V: // print version & information + print("\n\n----- Version -----\n"); + print("DESC: " STR(DESCRIPTION) "\n"); + print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " + "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " + "VER: " STR(DEVICE_VER) "\n"); + print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n"); + /* build options */ + print("OPTIONS:" +#ifdef PROTOCOL_PJRC + " PJRC" +#endif +#ifdef PROTOCOL_LUFA + " LUFA" +#endif +#ifdef PROTOCOL_VUSB + " VUSB" +#endif +#ifdef BOOTMAGIC_ENABLE + " BOOTMAGIC" +#endif +#ifdef MOUSEKEY_ENABLE + " MOUSEKEY" +#endif +#ifdef EXTRAKEY_ENABLE + " EXTRAKEY" +#endif +#ifdef CONSOLE_ENABLE + " CONSOLE" +#endif +#ifdef COMMAND_ENABLE + " COMMAND" +#endif +#ifdef NKRO_ENABLE + " NKRO" +#endif +#ifdef KEYMAP_SECTION_ENABLE + " KEYMAP_SECTION" +#endif + " " STR(BOOTLOADER_SIZE) "\n"); + + print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) + " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ + " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n"); + break; + case KC_T: // print timer + print_val_hex32(timer_count); + break; + case KC_S: + print("\n\n----- Status -----\n"); + print_val_hex8(host_keyboard_leds()); + print_val_hex8(keyboard_protocol); + print_val_hex8(keyboard_idle); +#ifdef PROTOCOL_PJRC + print_val_hex8(UDCON); + print_val_hex8(UDIEN); + print_val_hex8(UDINT); + print_val_hex8(usb_keyboard_leds); + print_val_hex8(usb_keyboard_idle_count); +#endif + +#ifdef PROTOCOL_PJRC +# if USB_COUNT_SOF + print_val_hex8(usbSofCount); +# endif +#endif + break; +#ifdef NKRO_ENABLE + case KC_N: + clear_keyboard(); //Prevents stuck keys. + keyboard_nkro = !keyboard_nkro; + if (keyboard_nkro) + print("NKRO: enabled\n"); + else + print("NKRO: disabled\n"); + break; +#endif +#ifdef EXTRAKEY_ENABLE + case KC_PSCREEN: + // TODO: Power key should take this feature? otherwise any key during suspend. +#ifdef PROTOCOL_PJRC + if (suspend && remote_wakeup) { + usb_remote_wakeup(); + } else { + host_system_send(SYSTEM_POWER_DOWN); + host_system_send(0); + _delay_ms(500); + } +#else + host_system_send(SYSTEM_POWER_DOWN); + _delay_ms(100); + host_system_send(0); + _delay_ms(500); +#endif + break; +#endif + case KC_ESC: + case KC_GRV: + case KC_0: + switch_default_layer(0); + break; + case KC_1 ... KC_9: + switch_default_layer((code - KC_1) + 1); + break; + case KC_F1 ... KC_F12: + switch_default_layer((code - KC_F1) + 1); + break; + default: + print("?"); + return false; + } + return true; +} + + +/*********************************************************** + * Command console + ***********************************************************/ +static void command_console_help(void) +{ + print("\n\n----- Console Help -----\n"); + print("ESC/q: quit\n"); +#ifdef MOUSEKEY_ENABLE + print("m: mousekey\n"); +#endif +} + +static bool command_console(uint8_t code) +{ + switch (code) { + case KC_H: + case KC_SLASH: /* ? */ + command_console_help(); + break; + case KC_Q: + case KC_ESC: + print("\nQuit Console Mode\n"); + command_state = ONESHOT; + return false; +#ifdef MOUSEKEY_ENABLE + case KC_M: + mousekey_console_help(); + print("\nEnter Mousekey Console\n"); + print("M0>"); + command_state = MOUSEKEY; + return true; +#endif + default: + print("?"); + return false; + } + print("C> "); + return true; +} + + +#ifdef MOUSEKEY_ENABLE +/*********************************************************** + * Mousekey console + ***********************************************************/ +static uint8_t mousekey_param = 0; + +static void mousekey_param_print(void) +{ + print("\n\n----- Mousekey Parameters -----\n"); + print("1: mk_delay(*10ms): "); pdec(mk_delay); print("\n"); + print("2: mk_interval(ms): "); pdec(mk_interval); print("\n"); + print("3: mk_max_speed: "); pdec(mk_max_speed); print("\n"); + print("4: mk_time_to_max: "); pdec(mk_time_to_max); print("\n"); + print("5: mk_wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n"); + print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n"); +} + +#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n"); +static void mousekey_param_inc(uint8_t param, uint8_t inc) +{ + switch (param) { + case 1: + if (mk_delay + inc < UINT8_MAX) + mk_delay += inc; + else + mk_delay = UINT8_MAX; + PRINT_SET_VAL(mk_delay); + break; + case 2: + if (mk_interval + inc < UINT8_MAX) + mk_interval += inc; + else + mk_interval = UINT8_MAX; + PRINT_SET_VAL(mk_interval); + break; + case 3: + if (mk_max_speed + inc < UINT8_MAX) + mk_max_speed += inc; + else + mk_max_speed = UINT8_MAX; + PRINT_SET_VAL(mk_max_speed); + break; + case 4: + if (mk_time_to_max + inc < UINT8_MAX) + mk_time_to_max += inc; + else + mk_time_to_max = UINT8_MAX; + PRINT_SET_VAL(mk_time_to_max); + break; + case 5: + if (mk_wheel_max_speed + inc < UINT8_MAX) + mk_wheel_max_speed += inc; + else + mk_wheel_max_speed = UINT8_MAX; + PRINT_SET_VAL(mk_wheel_max_speed); + break; + case 6: + if (mk_wheel_time_to_max + inc < UINT8_MAX) + mk_wheel_time_to_max += inc; + else + mk_wheel_time_to_max = UINT8_MAX; + PRINT_SET_VAL(mk_wheel_time_to_max); + break; + } +} + +static void mousekey_param_dec(uint8_t param, uint8_t dec) +{ + switch (param) { + case 1: + if (mk_delay > dec) + mk_delay -= dec; + else + mk_delay = 0; + PRINT_SET_VAL(mk_delay); + break; + case 2: + if (mk_interval > dec) + mk_interval -= dec; + else + mk_interval = 0; + PRINT_SET_VAL(mk_interval); + break; + case 3: + if (mk_max_speed > dec) + mk_max_speed -= dec; + else + mk_max_speed = 0; + PRINT_SET_VAL(mk_max_speed); + break; + case 4: + if (mk_time_to_max > dec) + mk_time_to_max -= dec; + else + mk_time_to_max = 0; + PRINT_SET_VAL(mk_time_to_max); + break; + case 5: + if (mk_wheel_max_speed > dec) + mk_wheel_max_speed -= dec; + else + mk_wheel_max_speed = 0; + PRINT_SET_VAL(mk_wheel_max_speed); + break; + case 6: + if (mk_wheel_time_to_max > dec) + mk_wheel_time_to_max -= dec; + else + mk_wheel_time_to_max = 0; + PRINT_SET_VAL(mk_wheel_time_to_max); + break; + } +} + +static void mousekey_console_help(void) +{ + print("\n\n----- Mousekey Parameters Help -----\n"); + print("ESC/q: quit\n"); + print("1: select mk_delay(*10ms)\n"); + print("2: select mk_interval(ms)\n"); + print("3: select mk_max_speed\n"); + print("4: select mk_time_to_max\n"); + print("5: select mk_wheel_max_speed\n"); + print("6: select mk_wheel_time_to_max\n"); + print("p: print parameters\n"); + print("d: set default values\n"); + print("up: increase parameters(+1)\n"); + print("down: decrease parameters(-1)\n"); + print("pgup: increase parameters(+10)\n"); + print("pgdown: decrease parameters(-10)\n"); + print("\nspeed = delta * max_speed * (repeat / time_to_max)\n"); + print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA); + print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n"); + print("See http://en.wikipedia.org/wiki/Mouse_keys\n"); +} + +static bool mousekey_console(uint8_t code) +{ + switch (code) { + case KC_H: + case KC_SLASH: /* ? */ + mousekey_console_help(); + break; + case KC_Q: + case KC_ESC: + mousekey_param = 0; + print("\nQuit Mousekey Console\n"); + print("C> "); + command_state = CONSOLE; + return false; + case KC_P: + mousekey_param_print(); + break; + case KC_1: + case KC_2: + case KC_3: + case KC_4: + case KC_5: + case KC_6: + case KC_7: + case KC_8: + case KC_9: + case KC_0: + mousekey_param = numkey2num(code); + print("selected parameter: "); pdec(mousekey_param); print("\n"); + break; + case KC_UP: + mousekey_param_inc(mousekey_param, 1); + break; + case KC_DOWN: + mousekey_param_dec(mousekey_param, 1); + break; + case KC_PGUP: + mousekey_param_inc(mousekey_param, 10); + break; + case KC_PGDN: + mousekey_param_dec(mousekey_param, 10); + break; + case KC_D: + mk_delay = MOUSEKEY_DELAY/10; + mk_interval = MOUSEKEY_INTERVAL; + mk_max_speed = MOUSEKEY_MAX_SPEED; + mk_time_to_max = MOUSEKEY_TIME_TO_MAX; + mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; + mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; + print("set default values.\n"); + break; + default: + print("?"); + return false; + } + print("M"); pdec(mousekey_param); print("> "); + return true; +} +#endif + + +/*********************************************************** + * Utilities + ***********************************************************/ +static uint8_t numkey2num(uint8_t code) +{ + switch (code) { + case KC_1: return 1; + case KC_2: return 2; + case KC_3: return 3; + case KC_4: return 4; + case KC_5: return 5; + case KC_6: return 6; + case KC_7: return 7; + case KC_8: return 8; + case KC_9: return 9; + case KC_0: return 0; + } + return 0; +} + +static void switch_default_layer(uint8_t layer) +{ + print("switch_default_layer: "); print_dec(biton32(default_layer_state)); + print(" to "); print_dec(layer); print("\n"); + default_layer_set(1UL< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef COMMAND_H +#define COMMAND + +/* TODO: Refactoring */ +typedef enum { ONESHOT, CONSOLE, MOUSEKEY } command_state_t; +extern command_state_t command_state; + +/* This allows to extend commands. Return false when command is not processed. */ +bool command_extra(uint8_t code); +bool command_console_extra(uint8_t code); + +#ifdef COMMAND_ENABLE +bool command_proc(uint8_t code); +#else +#define command_proc(code) false +#endif + +#endif diff --git a/common/debug.c b/common/debug.c new file mode 100644 index 000000000..18613fc28 --- /dev/null +++ b/common/debug.c @@ -0,0 +1,24 @@ +#include +#include "debug.h" + +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + +debug_config_t debug_config = { +/* GCC Bug 10676 - Using unnamed fields in initializers + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676 */ +#if GCC_VERSION >= 40600 + .enable = false, + .matrix = false, + .keyboard = false, + .mouse = false, + .reserved = 0 +#else + { + false, // .enable + false, // .matrix + false, // .keyboard + false, // .mouse + 0 // .reserved + } +#endif +}; diff --git a/common/debug.h b/common/debug.h new file mode 100644 index 000000000..3cbe2092d --- /dev/null +++ b/common/debug.h @@ -0,0 +1,117 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef DEBUG_H +#define DEBUG_H 1 + +#include +#include "print.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Debug output control + */ +typedef union { + struct { + bool enable:1; + bool matrix:1; + bool keyboard:1; + bool mouse:1; + uint8_t reserved:4; + }; + uint8_t raw; +} debug_config_t; + +extern debug_config_t debug_config; + +#ifdef __cplusplus +} +#endif + +/* for backward compatibility */ +#define debug_enable (debug_config.enable) +#define debug_matrix (debug_config.matrix) +#define debug_keyboard (debug_config.keyboard) +#define debug_mouse (debug_config.mouse) + + +/* + * Debug print utils + */ +#ifndef NO_DEBUG + +#define dprint(s) do { if (debug_enable) print(s); } while (0) +#define dprintln(s) do { if (debug_enable) println(s); } while (0) +#define dprintf(fmt, ...) do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0) +#define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s)) + +/* Deprecated. DO NOT USE these anymore, use dprintf instead. */ +#define debug(s) do { if (debug_enable) print(s); } while (0) +#define debugln(s) do { if (debug_enable) println(s); } while (0) +#define debug_msg(s) do { \ + if (debug_enable) { \ + print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ + } \ +} while (0) +#define debug_dec(data) do { if (debug_enable) print_dec(data); } while (0) +#define debug_decs(data) do { if (debug_enable) print_decs(data); } while (0) +#define debug_hex4(data) do { if (debug_enable) print_hex4(data); } while (0) +#define debug_hex8(data) do { if (debug_enable) print_hex8(data); } while (0) +#define debug_hex16(data) do { if (debug_enable) print_hex16(data); } while (0) +#define debug_hex32(data) do { if (debug_enable) print_hex32(data); } while (0) +#define debug_bin8(data) do { if (debug_enable) print_bin8(data); } while (0) +#define debug_bin16(data) do { if (debug_enable) print_bin16(data); } while (0) +#define debug_bin32(data) do { if (debug_enable) print_bin32(data); } while (0) +#define debug_bin_reverse8(data) do { if (debug_enable) print_bin_reverse8(data); } while (0) +#define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0) +#define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0) +#define debug_hex(data) debug_hex8(data) +#define debug_bin(data) debug_bin8(data) +#define debug_bin_reverse(data) debug_bin8(data) + +#else /* NO_DEBUG */ + +#define dprint(s) +#define dprintln(s) +#define dprintf(fmt, ...) +#define dmsg(s) +#define debug(s) +#define debugln(s) +#define debug_msg(s) +#define debug_dec(data) +#define debug_decs(data) +#define debug_hex4(data) +#define debug_hex8(data) +#define debug_hex16(data) +#define debug_hex32(data) +#define debug_bin8(data) +#define debug_bin16(data) +#define debug_bin32(data) +#define debug_bin_reverse8(data) +#define debug_bin_reverse16(data) +#define debug_bin_reverse32(data) +#define debug_hex(data) +#define debug_bin(data) +#define debug_bin_reverse(data) + +#endif /* NO_DEBUG */ + +#endif diff --git a/common/eeconfig.h b/common/eeconfig.h new file mode 100644 index 000000000..3cd1a174f --- /dev/null +++ b/common/eeconfig.h @@ -0,0 +1,75 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef EECONFIG_H +#define EECONFIG_H + +#include +#include + + +#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED + +/* eeprom parameteter address */ +#define EECONFIG_MAGIC (uint16_t *)0 +#define EECONFIG_DEBUG (uint8_t *)2 +#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 +#define EECONFIG_KEYMAP (uint8_t *)4 +#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 +#define EECONFIG_BACKLIGHT (uint8_t *)6 + + +/* debug bit */ +#define EECONFIG_DEBUG_ENABLE (1<<0) +#define EECONFIG_DEBUG_MATRIX (1<<1) +#define EECONFIG_DEBUG_KEYBOARD (1<<2) +#define EECONFIG_DEBUG_MOUSE (1<<3) + +/* keyconf bit */ +#define EECONFIG_KEYMAP_SWAP_CONTROL_CAPSLOCK (1<<0) +#define EECONFIG_KEYMAP_CAPSLOCK_TO_CONTROL (1<<1) +#define EECONFIG_KEYMAP_SWAP_LALT_LGUI (1<<2) +#define EECONFIG_KEYMAP_SWAP_RALT_RGUI (1<<3) +#define EECONFIG_KEYMAP_NO_GUI (1<<4) +#define EECONFIG_KEYMAP_SWAP_GRAVE_ESC (1<<5) +#define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1<<6) +#define EECONFIG_KEYMAP_NKRO (1<<7) + + +bool eeconfig_is_enabled(void); + +void eeconfig_init(void); + +void eeconfig_enable(void); + +void eeconfig_disable(void); + +uint8_t eeconfig_read_debug(void); +void eeconfig_write_debug(uint8_t val); + +uint8_t eeconfig_read_default_layer(void); +void eeconfig_write_default_layer(uint8_t val); + +uint8_t eeconfig_read_keymap(void); +void eeconfig_write_keymap(uint8_t val); + +#ifdef BACKLIGHT_ENABLE +uint8_t eeconfig_read_backlight(void); +void eeconfig_write_backlight(uint8_t val); +#endif + +#endif diff --git a/common/host.c b/common/host.c new file mode 100644 index 000000000..e9b791670 --- /dev/null +++ b/common/host.c @@ -0,0 +1,97 @@ +/* +Copyright 2011,2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +//#include +#include "keycode.h" +#include "host.h" +#include "util.h" +#include "debug.h" + + +#ifdef NKRO_ENABLE +bool keyboard_nkro = true; +#endif + +static host_driver_t *driver; +static uint16_t last_system_report = 0; +static uint16_t last_consumer_report = 0; + + +void host_set_driver(host_driver_t *d) +{ + driver = d; +} + +host_driver_t *host_get_driver(void) +{ + return driver; +} + +uint8_t host_keyboard_leds(void) +{ + if (!driver) return 0; + return (*driver->keyboard_leds)(); +} +/* send report */ +void host_keyboard_send(report_keyboard_t *report) +{ + if (!driver) return; + (*driver->send_keyboard)(report); + + if (debug_keyboard) { + dprint("keyboard_report: "); + for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { + dprintf("%02X ", report->raw[i]); + } + dprint("\n"); + } +} + +void host_mouse_send(report_mouse_t *report) +{ + if (!driver) return; + (*driver->send_mouse)(report); +} + +void host_system_send(uint16_t report) +{ + if (report == last_system_report) return; + last_system_report = report; + + if (!driver) return; + (*driver->send_system)(report); +} + +void host_consumer_send(uint16_t report) +{ + if (report == last_consumer_report) return; + last_consumer_report = report; + + if (!driver) return; + (*driver->send_consumer)(report); +} + +uint16_t host_last_sysytem_report(void) +{ + return last_system_report; +} + +uint16_t host_last_consumer_report(void) +{ + return last_consumer_report; +} diff --git a/common/host.h b/common/host.h new file mode 100644 index 000000000..918af69e8 --- /dev/null +++ b/common/host.h @@ -0,0 +1,57 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef HOST_H +#define HOST_H + +#include +#include +#include "report.h" +#include "host_driver.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NKRO_ENABLE +extern bool keyboard_nkro; +#endif + +extern uint8_t keyboard_idle; +extern uint8_t keyboard_protocol; + + +/* host driver */ +void host_set_driver(host_driver_t *driver); +host_driver_t *host_get_driver(void); + +/* host driver interface */ +uint8_t host_keyboard_leds(void); +void host_keyboard_send(report_keyboard_t *report); +void host_mouse_send(report_mouse_t *report); +void host_system_send(uint16_t data); +void host_consumer_send(uint16_t data); + +uint16_t host_last_sysytem_report(void); +uint16_t host_last_consumer_report(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/host_driver.h b/common/host_driver.h new file mode 100644 index 000000000..edb9e5dd9 --- /dev/null +++ b/common/host_driver.h @@ -0,0 +1,33 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef HOST_DRIVER_H +#define HOST_DRIVER_H + +#include +#include "report.h" + + +typedef struct { + uint8_t (*keyboard_leds)(void); + void (*send_keyboard)(report_keyboard_t *); + void (*send_mouse)(report_mouse_t *); + void (*send_system)(uint16_t); + void (*send_consumer)(uint16_t); +} host_driver_t; + +#endif diff --git a/common/keyboard.c b/common/keyboard.c new file mode 100644 index 000000000..1e3fb510a --- /dev/null +++ b/common/keyboard.c @@ -0,0 +1,150 @@ +/* +Copyright 2011,2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include +#include "keyboard.h" +#include "matrix.h" +#include "keymap.h" +#include "host.h" +#include "led.h" +#include "keycode.h" +#include "timer.h" +#include "print.h" +#include "debug.h" +#include "command.h" +#include "util.h" +#include "sendchar.h" +#include "bootmagic.h" +#include "eeconfig.h" +#include "backlight.h" +#ifdef MOUSEKEY_ENABLE +# include "mousekey.h" +#endif +#ifdef PS2_MOUSE_ENABLE +# include "ps2_mouse.h" +#endif +#ifdef SERIAL_MOUSE_ENABLE +#include "serial_mouse.h" +#endif + + +#ifdef MATRIX_HAS_GHOST +static bool has_ghost_in_row(uint8_t row) +{ + matrix_row_t matrix_row = matrix_get_row(row); + // No ghost exists when less than 2 keys are down on the row + if (((matrix_row - 1) & matrix_row) == 0) + return false; + + // Ghost occurs when the row shares column line with other row + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + if (i != row && (matrix_get_row(i) & matrix_row)) + return true; + } + return false; +} +#endif + + +void keyboard_init(void) +{ + timer_init(); + matrix_init(); +#ifdef PS2_MOUSE_ENABLE + ps2_mouse_init(); +#endif +#ifdef SERIAL_MOUSE_ENABLE + serial_mouse_init(); +#endif + + +#ifdef BOOTMAGIC_ENABLE + bootmagic(); +#endif + +#ifdef BACKLIGHT_ENABLE + backlight_init(); +#endif +} + +/* + * Do keyboard routine jobs: scan mantrix, light LEDs, ... + * This is repeatedly called as fast as possible. + */ +void keyboard_task(void) +{ + static matrix_row_t matrix_prev[MATRIX_ROWS]; + static uint8_t led_status = 0; + matrix_row_t matrix_row = 0; + matrix_row_t matrix_change = 0; + + matrix_scan(); + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + matrix_row = matrix_get_row(r); + matrix_change = matrix_row ^ matrix_prev[r]; + if (matrix_change) { + if (debug_matrix) matrix_print(); +#ifdef MATRIX_HAS_GHOST + if (has_ghost_in_row(r)) { + matrix_prev[r] = matrix_row; + continue; + } +#endif + for (uint8_t c = 0; c < MATRIX_COLS; c++) { + if (matrix_change & ((matrix_row_t)1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef KEYBOARD_H +#define KEYBOARD_H + +#include +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/* key matrix position */ +typedef struct { + uint8_t col; + uint8_t row; +} keypos_t; + +/* key event */ +typedef struct { + keypos_t key; + bool pressed; + uint16_t time; +} keyevent_t; + +/* equivalent test of keypos_t */ +#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col) + +/* Rules for No Event: + * 1) (time == 0) to handle (keyevent_t){} as empty event + * 2) Matrix(255, 255) to make TICK event available + */ +static inline bool IS_NOEVENT(keyevent_t event) { return event.time == 0 || (event.key.row == 255 && event.key.col == 255); } +static inline bool IS_PRESSED(keyevent_t event) { return (!IS_NOEVENT(event) && event.pressed); } +static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && !event.pressed); } + +/* Tick event */ +#define TICK (keyevent_t){ \ + .key = (keypos_t){ .row = 255, .col = 255 }, \ + .pressed = false, \ + .time = (timer_read() | 1) \ +} + + +void keyboard_init(void); +void keyboard_task(void); +void keyboard_set_leds(uint8_t leds); + +__attribute__ ((weak)) void matrix_power_up(void) {} +__attribute__ ((weak)) void matrix_power_down(void) {} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/keycode.h b/common/keycode.h new file mode 100644 index 000000000..ac4ef00db --- /dev/null +++ b/common/keycode.h @@ -0,0 +1,489 @@ +/* +Copyright 2011,2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +/* + * Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes + * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf + */ +#ifndef KEYCODE_H +#define KEYCODE_H + + +#define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED) +#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF) +#define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL) +#define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI) + + +#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF)) +#define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE) +#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV) +#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31) +#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) +#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT) +#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN5) +#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT) +#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2) + +#define MOD_BIT(code) (1< */ + KC_SLASH, /* / and ? */ + KC_CAPSLOCK, + KC_F1, + KC_F2, + KC_F3, + KC_F4, + KC_F5, + KC_F6, + KC_F7, /* 0x40 */ + KC_F8, + KC_F9, + KC_F10, + KC_F11, + KC_F12, + KC_PSCREEN, + KC_SCROLLLOCK, + KC_PAUSE, + KC_INSERT, + KC_HOME, + KC_PGUP, + KC_DELETE, + KC_END, + KC_PGDOWN, + KC_RIGHT, + KC_LEFT, /* 0x50 */ + KC_DOWN, + KC_UP, + KC_NUMLOCK, + KC_KP_SLASH, + KC_KP_ASTERISK, + KC_KP_MINUS, + KC_KP_PLUS, + KC_KP_ENTER, + KC_KP_1, + KC_KP_2, + KC_KP_3, + KC_KP_4, + KC_KP_5, + KC_KP_6, + KC_KP_7, + KC_KP_8, /* 0x60 */ + KC_KP_9, + KC_KP_0, + KC_KP_DOT, + KC_NONUS_BSLASH, /* Non-US \ and | */ + KC_APPLICATION, + KC_POWER, + KC_KP_EQUAL, + KC_F13, + KC_F14, + KC_F15, + KC_F16, + KC_F17, + KC_F18, + KC_F19, + KC_F20, + KC_F21, /* 0x70 */ + KC_F22, + KC_F23, + KC_F24, + KC_EXECUTE, + KC_HELP, + KC_MENU, + KC_SELECT, + KC_STOP, + KC_AGAIN, + KC_UNDO, + KC_CUT, + KC_COPY, + KC_PASTE, + KC_FIND, + KC__MUTE, + KC__VOLUP, /* 0x80 */ + KC__VOLDOWN, + KC_LOCKING_CAPS, /* locking Caps Lock */ + KC_LOCKING_NUM, /* locking Num Lock */ + KC_LOCKING_SCROLL, /* locking Scroll Lock */ + KC_KP_COMMA, + KC_KP_EQUAL_AS400, /* equal sign on AS/400 */ + KC_INT1, + KC_INT2, + KC_INT3, + KC_INT4, + KC_INT5, + KC_INT6, + KC_INT7, + KC_INT8, + KC_INT9, + KC_LANG1, /* 0x90 */ + KC_LANG2, + KC_LANG3, + KC_LANG4, + KC_LANG5, + KC_LANG6, + KC_LANG7, + KC_LANG8, + KC_LANG9, + KC_ALT_ERASE, + KC_SYSREQ, + KC_CANCEL, + KC_CLEAR, + KC_PRIOR, + KC_RETURN, + KC_SEPARATOR, + KC_OUT, /* 0xA0 */ + KC_OPER, + KC_CLEAR_AGAIN, + KC_CRSEL, + KC_EXSEL, /* 0xA4 */ + + /* NOTE: 0xA5-DF are used for internal special purpose */ + +#if 0 + /* NOTE: Following codes(0xB0-DD) are not used. Leave them for reference. */ + KC_KP_00 = 0xB0, + KC_KP_000, + KC_THOUSANDS_SEPARATOR, + KC_DECIMAL_SEPARATOR, + KC_CURRENCY_UNIT, + KC_CURRENCY_SUB_UNIT, + KC_KP_LPAREN, + KC_KP_RPAREN, + KC_KP_LCBRACKET, /* { */ + KC_KP_RCBRACKET, /* } */ + KC_KP_TAB, + KC_KP_BSPACE, + KC_KP_A, + KC_KP_B, + KC_KP_C, + KC_KP_D, + KC_KP_E, /* 0xC0 */ + KC_KP_F, + KC_KP_XOR, + KC_KP_HAT, + KC_KP_PERC, + KC_KP_LT, + KC_KP_GT, + KC_KP_AND, + KC_KP_LAZYAND, + KC_KP_OR, + KC_KP_LAZYOR, + KC_KP_COLON, + KC_KP_HASH, + KC_KP_SPACE, + KC_KP_ATMARK, + KC_KP_EXCLAMATION, + KC_KP_MEM_STORE, /* 0xD0 */ + KC_KP_MEM_RECALL, + KC_KP_MEM_CLEAR, + KC_KP_MEM_ADD, + KC_KP_MEM_SUB, + KC_KP_MEM_MUL, + KC_KP_MEM_DIV, + KC_KP_PLUS_MINUS, + KC_KP_CLEAR, + KC_KP_CLEAR_ENTRY, + KC_KP_BINARY, + KC_KP_OCTAL, + KC_KP_DECIMAL, + KC_KP_HEXADECIMAL, /* 0xDD */ +#endif + + /* Modifiers */ + KC_LCTRL = 0xE0, + KC_LSHIFT, + KC_LALT, + KC_LGUI, + KC_RCTRL, + KC_RSHIFT, + KC_RALT, + KC_RGUI, + + /* NOTE: 0xE8-FF are used for internal special purpose */ +}; + +/* Special keycodes */ +/* NOTE: 0xA5-DF and 0xE8-FF are used for internal special purpose */ +enum internal_special_keycodes { + /* System Control */ + KC_SYSTEM_POWER = 0xA5, + KC_SYSTEM_SLEEP, + KC_SYSTEM_WAKE, + + /* Media Control */ + KC_AUDIO_MUTE, + KC_AUDIO_VOL_UP, + KC_AUDIO_VOL_DOWN, + KC_MEDIA_NEXT_TRACK, + KC_MEDIA_PREV_TRACK, + KC_MEDIA_STOP, + KC_MEDIA_PLAY_PAUSE, + KC_MEDIA_SELECT, + KC_MEDIA_EJECT, + KC_MAIL, + KC_CALCULATOR, + KC_MY_COMPUTER, + KC_WWW_SEARCH, + KC_WWW_HOME, + KC_WWW_BACK, + KC_WWW_FORWARD, + KC_WWW_STOP, + KC_WWW_REFRESH, + KC_WWW_FAVORITES, + KC_MEDIA_FAST_FORWARD, + KC_MEDIA_REWIND, /* 0xBC */ + + /* Fn key */ + KC_FN0 = 0xC0, + KC_FN1, + KC_FN2, + KC_FN3, + KC_FN4, + KC_FN5, + KC_FN6, + KC_FN7, + KC_FN8, + KC_FN9, + KC_FN10, + KC_FN11, + KC_FN12, + KC_FN13, + KC_FN14, + KC_FN15, + + KC_FN16 = 0xD0, + KC_FN17, + KC_FN18, + KC_FN19, + KC_FN20, + KC_FN21, + KC_FN22, + KC_FN23, + KC_FN24, + KC_FN25, + KC_FN26, + KC_FN27, + KC_FN28, + KC_FN29, + KC_FN30, + KC_FN31, /* 0xDF */ + + /**************************************/ + /* 0xE0-E7 for Modifiers. DO NOT USE. */ + /**************************************/ + + /* Mousekey */ + KC_MS_UP = 0xF0, + KC_MS_DOWN, + KC_MS_LEFT, + KC_MS_RIGHT, + KC_MS_BTN1, + KC_MS_BTN2, + KC_MS_BTN3, + KC_MS_BTN4, + KC_MS_BTN5, /* 0xF8 */ + /* Mousekey wheel */ + KC_MS_WH_UP, + KC_MS_WH_DOWN, + KC_MS_WH_LEFT, + KC_MS_WH_RIGHT, /* 0xFC */ + /* Mousekey accel */ + KC_MS_ACCEL0, + KC_MS_ACCEL1, + KC_MS_ACCEL2 /* 0xFF */ +}; + +#endif /* KEYCODE_H */ diff --git a/common/keymap.c b/common/keymap.c new file mode 100644 index 000000000..4c0b61b8c --- /dev/null +++ b/common/keymap.c @@ -0,0 +1,185 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "keymap.h" +#include "report.h" +#include "keycode.h" +#include "action_layer.h" +#include "action.h" +#include "action_macro.h" +#include "debug.h" + + +static action_t keycode_to_action(uint8_t keycode); + + +/* converts key to action */ +action_t action_for_key(uint8_t layer, keypos_t key) +{ + uint8_t keycode = keymap_key_to_keycode(layer, key); + switch (keycode) { + case KC_FN0 ... KC_FN31: + return keymap_fn_to_action(keycode); +#ifdef BOOTMAGIC_ENABLE + case KC_CAPSLOCK: + case KC_LOCKING_CAPS: + if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) { + return keycode_to_action(KC_LCTL); + } + return keycode_to_action(keycode); + case KC_LCTL: + if (keymap_config.swap_control_capslock) { + return keycode_to_action(KC_CAPSLOCK); + } + return keycode_to_action(KC_LCTL); + case KC_LALT: + if (keymap_config.swap_lalt_lgui) { + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_LGUI); + } + return keycode_to_action(KC_LALT); + case KC_LGUI: + if (keymap_config.swap_lalt_lgui) { + return keycode_to_action(KC_LALT); + } + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_LGUI); + case KC_RALT: + if (keymap_config.swap_ralt_rgui) { + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_RGUI); + } + return keycode_to_action(KC_RALT); + case KC_RGUI: + if (keymap_config.swap_ralt_rgui) { + return keycode_to_action(KC_RALT); + } + if (keymap_config.no_gui) { + return keycode_to_action(ACTION_NO); + } + return keycode_to_action(KC_RGUI); + case KC_GRAVE: + if (keymap_config.swap_grave_esc) { + return keycode_to_action(KC_ESC); + } + return keycode_to_action(KC_GRAVE); + case KC_ESC: + if (keymap_config.swap_grave_esc) { + return keycode_to_action(KC_GRAVE); + } + return keycode_to_action(KC_ESC); + case KC_BSLASH: + if (keymap_config.swap_backslash_backspace) { + return keycode_to_action(KC_BSPACE); + } + return keycode_to_action(KC_BSLASH); + case KC_BSPACE: + if (keymap_config.swap_backslash_backspace) { + return keycode_to_action(KC_BSLASH); + } + return keycode_to_action(KC_BSPACE); +#endif + default: + return keycode_to_action(keycode); + } +} + + +/* Macro */ +__attribute__ ((weak)) +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + return MACRO_NONE; +} + +/* Function */ +__attribute__ ((weak)) +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ +} + + + +/* translates keycode to action */ +static action_t keycode_to_action(uint8_t keycode) +{ + action_t action; + switch (keycode) { + case KC_A ... KC_EXSEL: + case KC_LCTRL ... KC_RGUI: + action.code = ACTION_KEY(keycode); + break; + case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE: + action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode)); + break; + case KC_AUDIO_MUTE ... KC_WWW_FAVORITES: + action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode)); + break; + case KC_MS_UP ... KC_MS_ACCEL2: + action.code = ACTION_MOUSEKEY(keycode); + break; + case KC_TRNS: + action.code = ACTION_TRANSPARENT; + break; + default: + action.code = ACTION_NO; + break; + } + return action; +} + + + +#ifdef USE_LEGACY_KEYMAP +/* + * Legacy keymap support + * Consider using new keymap API instead. + */ +__attribute__ ((weak)) +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return keymap_get_keycode(layer, key.row, key.col); +} + + +/* Legacy keymap support */ +__attribute__ ((weak)) +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action = { .code = ACTION_NO }; + switch (keycode) { + case KC_FN0 ... KC_FN31: + { + uint8_t layer = keymap_fn_layer(FN_INDEX(keycode)); + uint8_t key = keymap_fn_keycode(FN_INDEX(keycode)); + if (key) { + action.code = ACTION_LAYER_TAP_KEY(layer, key); + } else { + action.code = ACTION_LAYER_MOMENTARY(layer); + } + } + return action; + default: + return action; + } +} +#endif diff --git a/common/keymap.h b/common/keymap.h new file mode 100644 index 000000000..e1a6f992e --- /dev/null +++ b/common/keymap.h @@ -0,0 +1,71 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef KEYMAP_H +#define KEYMAP_H + +#include +#include +#include "action.h" + + +#ifdef BOOTMAGIC_ENABLE +/* NOTE: Not portable. Bit field order depends on implementation */ +typedef union { + uint8_t raw; + struct { + bool swap_control_capslock:1; + bool capslock_to_control:1; + bool swap_lalt_lgui:1; + bool swap_ralt_rgui:1; + bool no_gui:1; + bool swap_grave_esc:1; + bool swap_backslash_backspace:1; + bool nkro:1; + }; +} keymap_config_t; +keymap_config_t keymap_config; +#endif + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key); + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode); + + + +#ifdef USE_LEGACY_KEYMAP +/* + * Legacy keymap + * Consider using new keymap API above instead. + */ +/* keycode of key */ +__attribute__ ((deprecated)) +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col); + +/* layer to move during press Fn key */ +__attribute__ ((deprecated)) +uint8_t keymap_fn_layer(uint8_t fn_bits); + +/* keycode to send when release Fn key without using */ +__attribute__ ((deprecated)) +uint8_t keymap_fn_keycode(uint8_t fn_bits); +#endif + +#endif diff --git a/common/led.h b/common/led.h new file mode 100644 index 000000000..402a247b9 --- /dev/null +++ b/common/led.h @@ -0,0 +1,33 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef LED_H +#define LED_H +#include "stdint.h" + + +/* keyboard LEDs */ +#define USB_LED_NUM_LOCK 0 +#define USB_LED_CAPS_LOCK 1 +#define USB_LED_SCROLL_LOCK 2 +#define USB_LED_COMPOSE 3 +#define USB_LED_KANA 4 + + +void led_set(uint8_t usb_led); + +#endif diff --git a/common/matrix.h b/common/matrix.h new file mode 100644 index 000000000..107ee7265 --- /dev/null +++ b/common/matrix.h @@ -0,0 +1,68 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef MATRIX_H +#define MATRIX_H + +#include +#include + + +#if (MATRIX_COLS <= 8) +typedef uint8_t matrix_row_t; +#elif (MATRIX_COLS <= 16) +typedef uint16_t matrix_row_t; +#elif (MATRIX_COLS <= 32) +typedef uint32_t matrix_row_t; +#else +#error "MATRIX_COLS: invalid value" +#endif + +#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1< + + +void suspend_power_down(void) {} +bool suspend_wakeup_condition(void) { return true; } +void suspend_wakeup_init(void) {} diff --git a/common/mbed/timer.c b/common/mbed/timer.c new file mode 100644 index 000000000..c357ceb78 --- /dev/null +++ b/common/mbed/timer.c @@ -0,0 +1,41 @@ +#include "cmsis.h" +#include "timer.h" + +/* Mill second tick count */ +volatile uint32_t timer_count = 0; + +/* Timer interrupt handler */ +void SysTick_Handler(void) { + timer_count++; +} + +void timer_init(void) +{ + timer_count = 0; + SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */ +} + +void timer_clear(void) +{ + timer_count = 0; +} + +uint16_t timer_read(void) +{ + return (uint16_t)(timer_count & 0xFFFF); +} + +uint32_t timer_read32(void) +{ + return timer_count; +} + +uint16_t timer_elapsed(uint16_t last) +{ + return TIMER_DIFF_16(timer_read(), last); +} + +uint32_t timer_elapsed32(uint32_t last) +{ + return TIMER_DIFF_32(timer_read32(), last); +} diff --git a/common/mbed/xprintf.cpp b/common/mbed/xprintf.cpp new file mode 100644 index 000000000..3647ece75 --- /dev/null +++ b/common/mbed/xprintf.cpp @@ -0,0 +1,51 @@ +#include +//#include +#include "mbed.h" +#include "mbed/xprintf.h" + + +#define STRING_STACK_LIMIT 120 + +//TODO +int xprintf(const char* format, ...) { return 0; } + +#if 0 +/* mbed Serial */ +Serial ser(UART_TX, UART_RX); + +/* TODO: Need small implementation for embedded */ +int xprintf(const char* format, ...) +{ + /* copy from mbed/common/RawSerial.cpp */ + std::va_list arg; + va_start(arg, format); + int len = vsnprintf(NULL, 0, format, arg); + if (len < STRING_STACK_LIMIT) { + char temp[STRING_STACK_LIMIT]; + vsprintf(temp, format, arg); + ser.puts(temp); + } else { + char *temp = new char[len + 1]; + vsprintf(temp, format, arg); + ser.puts(temp); + delete[] temp; + } + va_end(arg); + return len; + +/* Fail: __builtin_va_arg_pack? + * https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Constructing-Calls.html#Constructing-Calls + void *arg = __builtin_apply_args(); + void *ret = __builtin_apply((void*)(&(ser.printf)), arg, 100); + __builtin_return(ret) +*/ +/* Fail: varargs can not be passed to printf + //int r = ser.printf("test %i\r\n", 123); + va_list arg; + va_start(arg, format); + int r = ser.printf(format, arg); + va_end(arg); + return r; +*/ +} +#endif diff --git a/common/mbed/xprintf.h b/common/mbed/xprintf.h new file mode 100644 index 000000000..26bc529e5 --- /dev/null +++ b/common/mbed/xprintf.h @@ -0,0 +1,17 @@ +#ifndef XPRINTF_H +#define XPRINTF_H + +//#define xprintf(format, ...) __xprintf(format, ##__VA_ARGS__) + +#ifdef __cplusplus +extern "C" { +#endif + +int xprintf(const char *format, ...); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/common/mousekey.c b/common/mousekey.c new file mode 100644 index 000000000..23469476e --- /dev/null +++ b/common/mousekey.c @@ -0,0 +1,196 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include "keycode.h" +#include "host.h" +#include "timer.h" +#include "print.h" +#include "debug.h" +#include "mousekey.h" + + + +static report_mouse_t mouse_report = {}; +static uint8_t mousekey_repeat = 0; +static uint8_t mousekey_accel = 0; + +static void mousekey_debug(void); + + +/* + * Mouse keys acceleration algorithm + * http://en.wikipedia.org/wiki/Mouse_keys + * + * speed = delta * max_speed * (repeat / time_to_max)**((1000+curve)/1000) + */ +/* milliseconds between the initial key press and first repeated motion event (0-2550) */ +uint8_t mk_delay = MOUSEKEY_DELAY/10; +/* milliseconds between repeated motion events (0-255) */ +uint8_t mk_interval = MOUSEKEY_INTERVAL; +/* steady speed (in action_delta units) applied each event (0-255) */ +uint8_t mk_max_speed = MOUSEKEY_MAX_SPEED; +/* number of events (count) accelerating to steady speed (0-255) */ +uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX; +/* ramp used to reach maximum pointer speed (NOT SUPPORTED) */ +//int8_t mk_curve = 0; +/* wheel params */ +uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; +uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; + + +static uint16_t last_timer = 0; + + +static uint8_t move_unit(void) +{ + uint16_t unit; + if (mousekey_accel & (1<<0)) { + unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/4; + } else if (mousekey_accel & (1<<1)) { + unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/2; + } else if (mousekey_accel & (1<<2)) { + unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed); + } else if (mousekey_repeat == 0) { + unit = MOUSEKEY_MOVE_DELTA; + } else if (mousekey_repeat >= mk_time_to_max) { + unit = MOUSEKEY_MOVE_DELTA * mk_max_speed; + } else { + unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max; + } + return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit)); +} + +static uint8_t wheel_unit(void) +{ + uint16_t unit; + if (mousekey_accel & (1<<0)) { + unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed)/4; + } else if (mousekey_accel & (1<<1)) { + unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed)/2; + } else if (mousekey_accel & (1<<2)) { + unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed); + } else if (mousekey_repeat == 0) { + unit = MOUSEKEY_WHEEL_DELTA; + } else if (mousekey_repeat >= mk_wheel_time_to_max) { + unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed; + } else { + unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max; + } + return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit)); +} + +void mousekey_task(void) +{ + if (timer_elapsed(last_timer) < (mousekey_repeat ? mk_interval : mk_delay*10)) + return; + + if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0) + return; + + if (mousekey_repeat != UINT8_MAX) + mousekey_repeat++; + + + if (mouse_report.x > 0) mouse_report.x = move_unit(); + if (mouse_report.x < 0) mouse_report.x = move_unit() * -1; + if (mouse_report.y > 0) mouse_report.y = move_unit(); + if (mouse_report.y < 0) mouse_report.y = move_unit() * -1; + + /* diagonal move [1/sqrt(2) = 0.7] */ + if (mouse_report.x && mouse_report.y) { + mouse_report.x *= 0.7; + mouse_report.y *= 0.7; + } + + if (mouse_report.v > 0) mouse_report.v = wheel_unit(); + if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1; + if (mouse_report.h > 0) mouse_report.h = wheel_unit(); + if (mouse_report.h < 0) mouse_report.h = wheel_unit() * -1; + + mousekey_send(); +} + +void mousekey_on(uint8_t code) +{ + if (code == KC_MS_UP) mouse_report.y = move_unit() * -1; + else if (code == KC_MS_DOWN) mouse_report.y = move_unit(); + else if (code == KC_MS_LEFT) mouse_report.x = move_unit() * -1; + else if (code == KC_MS_RIGHT) mouse_report.x = move_unit(); + else if (code == KC_MS_WH_UP) mouse_report.v = wheel_unit(); + else if (code == KC_MS_WH_DOWN) mouse_report.v = wheel_unit() * -1; + else if (code == KC_MS_WH_LEFT) mouse_report.h = wheel_unit() * -1; + else if (code == KC_MS_WH_RIGHT) mouse_report.h = wheel_unit(); + else if (code == KC_MS_BTN1) mouse_report.buttons |= MOUSE_BTN1; + else if (code == KC_MS_BTN2) mouse_report.buttons |= MOUSE_BTN2; + else if (code == KC_MS_BTN3) mouse_report.buttons |= MOUSE_BTN3; + else if (code == KC_MS_BTN4) mouse_report.buttons |= MOUSE_BTN4; + else if (code == KC_MS_BTN5) mouse_report.buttons |= MOUSE_BTN5; + else if (code == KC_MS_ACCEL0) mousekey_accel |= (1<<0); + else if (code == KC_MS_ACCEL1) mousekey_accel |= (1<<1); + else if (code == KC_MS_ACCEL2) mousekey_accel |= (1<<2); +} + +void mousekey_off(uint8_t code) +{ + if (code == KC_MS_UP && mouse_report.y < 0) mouse_report.y = 0; + else if (code == KC_MS_DOWN && mouse_report.y > 0) mouse_report.y = 0; + else if (code == KC_MS_LEFT && mouse_report.x < 0) mouse_report.x = 0; + else if (code == KC_MS_RIGHT && mouse_report.x > 0) mouse_report.x = 0; + else if (code == KC_MS_WH_UP && mouse_report.v > 0) mouse_report.v = 0; + else if (code == KC_MS_WH_DOWN && mouse_report.v < 0) mouse_report.v = 0; + else if (code == KC_MS_WH_LEFT && mouse_report.h < 0) mouse_report.h = 0; + else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0; + else if (code == KC_MS_BTN1) mouse_report.buttons &= ~MOUSE_BTN1; + else if (code == KC_MS_BTN2) mouse_report.buttons &= ~MOUSE_BTN2; + else if (code == KC_MS_BTN3) mouse_report.buttons &= ~MOUSE_BTN3; + else if (code == KC_MS_BTN4) mouse_report.buttons &= ~MOUSE_BTN4; + else if (code == KC_MS_BTN5) mouse_report.buttons &= ~MOUSE_BTN5; + else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1<<0); + else if (code == KC_MS_ACCEL1) mousekey_accel &= ~(1<<1); + else if (code == KC_MS_ACCEL2) mousekey_accel &= ~(1<<2); + + if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0) + mousekey_repeat = 0; +} + +void mousekey_send(void) +{ + mousekey_debug(); + host_mouse_send(&mouse_report); + last_timer = timer_read(); +} + +void mousekey_clear(void) +{ + mouse_report = (report_mouse_t){}; + mousekey_repeat = 0; + mousekey_accel = 0; +} + +static void mousekey_debug(void) +{ + if (!debug_mouse) return; + print("mousekey [btn|x y v h](rep/acl): ["); + phex(mouse_report.buttons); print("|"); + print_decs(mouse_report.x); print(" "); + print_decs(mouse_report.y); print(" "); + print_decs(mouse_report.v); print(" "); + print_decs(mouse_report.h); print("]("); + print_dec(mousekey_repeat); print("/"); + print_dec(mousekey_accel); print(")\n"); +} diff --git a/common/mousekey.h b/common/mousekey.h new file mode 100644 index 000000000..6eede06b4 --- /dev/null +++ b/common/mousekey.h @@ -0,0 +1,77 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef MOUSEKEY_H +#define MOUSEKEY_H + +#include +#include "host.h" + + +/* max value on report descriptor */ +#define MOUSEKEY_MOVE_MAX 127 +#define MOUSEKEY_WHEEL_MAX 127 + +#ifndef MOUSEKEY_MOVE_DELTA +#define MOUSEKEY_MOVE_DELTA 5 +#endif +#ifndef MOUSEKEY_WHEEL_DELTA +#define MOUSEKEY_WHEEL_DELTA 1 +#endif +#ifndef MOUSEKEY_DELAY +#define MOUSEKEY_DELAY 300 +#endif +#ifndef MOUSEKEY_INTERVAL +#define MOUSEKEY_INTERVAL 50 +#endif +#ifndef MOUSEKEY_MAX_SPEED +#define MOUSEKEY_MAX_SPEED 10 +#endif +#ifndef MOUSEKEY_TIME_TO_MAX +#define MOUSEKEY_TIME_TO_MAX 20 +#endif +#ifndef MOUSEKEY_WHEEL_MAX_SPEED +#define MOUSEKEY_WHEEL_MAX_SPEED 8 +#endif +#ifndef MOUSEKEY_WHEEL_TIME_TO_MAX +#define MOUSEKEY_WHEEL_TIME_TO_MAX 40 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint8_t mk_delay; +extern uint8_t mk_interval; +extern uint8_t mk_max_speed; +extern uint8_t mk_time_to_max; +extern uint8_t mk_wheel_max_speed; +extern uint8_t mk_wheel_time_to_max; + + +void mousekey_task(void); +void mousekey_on(uint8_t code); +void mousekey_off(uint8_t code); +void mousekey_clear(void); +void mousekey_send(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/nodebug.h b/common/nodebug.h new file mode 100644 index 000000000..93309ada4 --- /dev/null +++ b/common/nodebug.h @@ -0,0 +1,25 @@ +/* +Copyright 2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef NODEBUG_H +#define NODEBUG_H 1 + +#define NO_DEBUG +#include "debug.h" +#undef NO_DEBUG + +#endif diff --git a/common/print.c b/common/print.c new file mode 100644 index 000000000..ca94e1e5d --- /dev/null +++ b/common/print.c @@ -0,0 +1,48 @@ +/* Copyright 2012,2013 Jun Wako */ +/* Very basic print functions, intended to be used with usb_debug_only.c + * http://www.pjrc.com/teensy/ + * Copyright (c) 2008 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include "print.h" + + +#ifndef NO_PRINT + +#if defined(__AVR__) + +#define sendchar(c) xputc(c) + + +void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) +{ + xdev_out(sendchar_func); +} + +#elif defined(__arm__) + +// TODO +//void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { } + +#endif + +#endif diff --git a/common/print.h b/common/print.h new file mode 100644 index 000000000..c0e9e1430 --- /dev/null +++ b/common/print.h @@ -0,0 +1,137 @@ +/* Copyright 2012 Jun Wako */ +/* Very basic print functions, intended to be used with usb_debug_only.c + * http://www.pjrc.com/teensy/ + * Copyright (c) 2008 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef PRINT_H__ +#define PRINT_H__ 1 + +#include +#include +#include "util.h" + + + + +#ifndef NO_PRINT + + +#if defined(__AVR__) + +#include "avr/xprintf.h" +#define print(s) xputs(PSTR(s)) +#define println(s) xputs(PSTR(s "\r\n")) + +#ifdef __cplusplus +extern "C" +#endif +/* function pointer of sendchar to be used by print utility */ +void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t)); + +#elif defined(__arm__) + +#include "mbed/xprintf.h" + +#define print(s) xprintf(s) +#define println(s) xprintf(s "\r\n") + +/* TODO: to select output destinations: UART/USBSerial */ +#define print_set_sendchar(func) + +#endif /* __AVR__ */ + + +/* decimal */ +#define print_dec(i) xprintf("%u", i) +#define print_decs(i) xprintf("%d", i) +/* hex */ +#define print_hex4(i) xprintf("%X", i) +#define print_hex8(i) xprintf("%02X", i) +#define print_hex16(i) xprintf("%04X", i) +#define print_hex32(i) xprintf("%08lX", i) +/* binary */ +#define print_bin4(i) xprintf("%04b", i) +#define print_bin8(i) xprintf("%08b", i) +#define print_bin16(i) xprintf("%016b", i) +#define print_bin32(i) xprintf("%032lb", i) +#define print_bin_reverse8(i) xprintf("%08b", bitrev(i)) +#define print_bin_reverse16(i) xprintf("%016b", bitrev16(i)) +#define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i)) +/* print value utility */ +#define print_val_dec(v) xprintf(#v ": %u\n", v) +#define print_val_decs(v) xprintf(#v ": %d\n", v) +#define print_val_hex8(v) xprintf(#v ": %X\n", v) +#define print_val_hex16(v) xprintf(#v ": %02X\n", v) +#define print_val_hex32(v) xprintf(#v ": %04lX\n", v) +#define print_val_bin8(v) xprintf(#v ": %08b\n", v) +#define print_val_bin16(v) xprintf(#v ": %016b\n", v) +#define print_val_bin32(v) xprintf(#v ": %032lb\n", v) +#define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v)) +#define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v)) +#define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v)) + +#else /* NO_PRINT */ + +#define xprintf +#define print +#define println +#define print_set_sendchar(func) +#define print_dec(data) +#define print_decs(data) +#define print_hex4(data) +#define print_hex8(data) +#define print_hex16(data) +#define print_hex32(data) +#define print_bin4(data) +#define print_bin8(data) +#define print_bin16(data) +#define print_bin32(data) +#define print_bin_reverse8(data) +#define print_bin_reverse16(data) +#define print_bin_reverse32(data) +#define print_val_dec(v) +#define print_val_decs(v) +#define print_val_hex8(v) +#define print_val_hex16(v) +#define print_val_hex32(v) +#define print_val_bin8(v) +#define print_val_bin16(v) +#define print_val_bin32(v) +#define print_val_bin_reverse8(v) +#define print_val_bin_reverse16(v) +#define print_val_bin_reverse32(v) + +#endif /* NO_PRINT */ + + +/* Backward compatiblitly for old name */ +#define pdec(data) print_dec(data) +#define pdec16(data) print_dec(data) +#define phex(data) print_hex8(data) +#define phex16(data) print_hex16(data) +#define pbin(data) print_bin8(data) +#define pbin16(data) print_bin16(data) +#define pbin_reverse(data) print_bin_reverse8(data) +#define pbin_reverse16(data) print_bin_reverse16(data) + + +#endif diff --git a/common/progmem.h b/common/progmem.h new file mode 100644 index 000000000..199b1bedf --- /dev/null +++ b/common/progmem.h @@ -0,0 +1,12 @@ +#ifndef PROGMEM_H +#define PROGMEM_H 1 + +#if defined(__AVR__) +# include +#elif defined(__arm__) +# define PROGMEM +# define pgm_read_byte(p) *(p) +# define pgm_read_word(p) *(p) +#endif + +#endif diff --git a/common/report.h b/common/report.h new file mode 100644 index 000000000..f6c0a315d --- /dev/null +++ b/common/report.h @@ -0,0 +1,183 @@ +/* +Copyright 2011,2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef REPORT_H +#define REPORT_H + +#include +#include "keycode.h" + + +/* report id */ +#define REPORT_ID_MOUSE 1 +#define REPORT_ID_SYSTEM 2 +#define REPORT_ID_CONSUMER 3 + +/* mouse buttons */ +#define MOUSE_BTN1 (1<<0) +#define MOUSE_BTN2 (1<<1) +#define MOUSE_BTN3 (1<<2) +#define MOUSE_BTN4 (1<<3) +#define MOUSE_BTN5 (1<<4) + +/* Consumer Page(0x0C) + * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx + */ +#define AUDIO_MUTE 0x00E2 +#define AUDIO_VOL_UP 0x00E9 +#define AUDIO_VOL_DOWN 0x00EA +#define TRANSPORT_NEXT_TRACK 0x00B5 +#define TRANSPORT_PREV_TRACK 0x00B6 +#define TRANSPORT_STOP 0x00B7 +#define TRANSPORT_STOP_EJECT 0x00CC +#define TRANSPORT_PLAY_PAUSE 0x00CD +/* application launch */ +#define AL_CC_CONFIG 0x0183 +#define AL_EMAIL 0x018A +#define AL_CALCULATOR 0x0192 +#define AL_LOCAL_BROWSER 0x0194 +/* application control */ +#define AC_SEARCH 0x0221 +#define AC_HOME 0x0223 +#define AC_BACK 0x0224 +#define AC_FORWARD 0x0225 +#define AC_STOP 0x0226 +#define AC_REFRESH 0x0227 +#define AC_BOOKMARKS 0x022A +/* supplement for Bluegiga iWRAP HID(not supported by Windows?) */ +#define AL_LOCK 0x019E +#define TRANSPORT_RECORD 0x00B2 +#define TRANSPORT_FAST_FORWARD 0x00B3 +#define TRANSPORT_REWIND 0x00B4 +#define TRANSPORT_EJECT 0x00B8 +#define AC_MINIMIZE 0x0206 + +/* Generic Desktop Page(0x01) - system power control */ +#define SYSTEM_POWER_DOWN 0x0081 +#define SYSTEM_SLEEP 0x0082 +#define SYSTEM_WAKE_UP 0x0083 + + +/* key report size(NKRO or boot mode) */ +#if defined(PROTOCOL_PJRC) && defined(NKRO_ENABLE) +# include "usb.h" +# define KEYBOARD_REPORT_SIZE KBD2_SIZE +# define KEYBOARD_REPORT_KEYS (KBD2_SIZE - 2) +# define KEYBOARD_REPORT_BITS (KBD2_SIZE - 1) + +#elif defined(PROTOCOL_LUFA) && defined(NKRO_ENABLE) +# include "protocol/lufa/descriptor.h" +# define KEYBOARD_REPORT_SIZE NKRO_EPSIZE +# define KEYBOARD_REPORT_KEYS (NKRO_EPSIZE - 2) +# define KEYBOARD_REPORT_BITS (NKRO_EPSIZE - 1) + +#else +# define KEYBOARD_REPORT_SIZE 8 +# define KEYBOARD_REPORT_KEYS 6 +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * keyboard report is 8-byte array retains state of 8 modifiers and 6 keys. + * + * byte |0 |1 |2 |3 |4 |5 |6 |7 + * -----+--------+--------+--------+--------+--------+--------+--------+-------- + * desc |mods |reserved|keys[0] |keys[1] |keys[2] |keys[3] |keys[4] |keys[5] + * + * It is exended to 16 bytes to retain 120keys+8mods when NKRO mode. + * + * byte |0 |1 |2 |3 |4 |5 |6 |7 ... |15 + * -----+--------+--------+--------+--------+--------+--------+--------+-------- +-------- + * desc |mods |bits[0] |bits[1] |bits[2] |bits[3] |bits[4] |bits[5] |bits[6] ... |bit[14] + * + * mods retains state of 8 modifiers. + * + * bit |0 |1 |2 |3 |4 |5 |6 |7 + * -----+--------+--------+--------+--------+--------+--------+--------+-------- + * desc |Lcontrol|Lshift |Lalt |Lgui |Rcontrol|Rshift |Ralt |Rgui + * + */ +typedef union { + uint8_t raw[KEYBOARD_REPORT_SIZE]; + struct { + uint8_t mods; + uint8_t reserved; + uint8_t keys[KEYBOARD_REPORT_KEYS]; + }; +#ifdef NKRO_ENABLE + struct { + uint8_t mods; + uint8_t bits[KEYBOARD_REPORT_BITS]; + } nkro; +#endif +} __attribute__ ((packed)) report_keyboard_t; +/* +typedef struct { + uint8_t mods; + uint8_t reserved; + uint8_t keys[REPORT_KEYS]; +} __attribute__ ((packed)) report_keyboard_t; +*/ + +typedef struct { + uint8_t buttons; + int8_t x; + int8_t y; + int8_t v; + int8_t h; +} __attribute__ ((packed)) report_mouse_t; + + +/* keycode to system usage */ +#define KEYCODE2SYSTEM(key) \ + (key == KC_SYSTEM_POWER ? SYSTEM_POWER_DOWN : \ + (key == KC_SYSTEM_SLEEP ? SYSTEM_SLEEP : \ + (key == KC_SYSTEM_WAKE ? SYSTEM_WAKE_UP : 0))) + +/* keycode to consumer usage */ +#define KEYCODE2CONSUMER(key) \ + (key == KC_AUDIO_MUTE ? AUDIO_MUTE : \ + (key == KC_AUDIO_VOL_UP ? AUDIO_VOL_UP : \ + (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \ + (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \ + (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \ + (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \ + (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \ + (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \ + (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \ + (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \ + (key == KC_MEDIA_SELECT ? AL_CC_CONFIG : \ + (key == KC_MAIL ? AL_EMAIL : \ + (key == KC_CALCULATOR ? AL_CALCULATOR : \ + (key == KC_MY_COMPUTER ? AL_LOCAL_BROWSER : \ + (key == KC_WWW_SEARCH ? AC_SEARCH : \ + (key == KC_WWW_HOME ? AC_HOME : \ + (key == KC_WWW_BACK ? AC_BACK : \ + (key == KC_WWW_FORWARD ? AC_FORWARD : \ + (key == KC_WWW_STOP ? AC_STOP : \ + (key == KC_WWW_REFRESH ? AC_REFRESH : \ + (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/sendchar.h b/common/sendchar.h new file mode 100644 index 000000000..7a64d00c7 --- /dev/null +++ b/common/sendchar.h @@ -0,0 +1,35 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef SENDCHAR_H +#define SENDCHAR_H + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/* transmit a character. return 0 on success, -1 on error. */ +int8_t sendchar(uint8_t c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/sendchar_null.c b/common/sendchar_null.c new file mode 100644 index 000000000..293330622 --- /dev/null +++ b/common/sendchar_null.c @@ -0,0 +1,23 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "sendchar.h" + + +int8_t sendchar(uint8_t c) +{ + return 0; +} diff --git a/common/sendchar_uart.c b/common/sendchar_uart.c new file mode 100644 index 000000000..0241859eb --- /dev/null +++ b/common/sendchar_uart.c @@ -0,0 +1,25 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "uart.h" +#include "sendchar.h" + + +int8_t sendchar(uint8_t c) +{ + uart_putchar(c); + return 0; +} diff --git a/common/sleep_led.c b/common/sleep_led.c new file mode 100644 index 000000000..dab3eb0f3 --- /dev/null +++ b/common/sleep_led.c @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include "led.h" +#include "sleep_led.h" + +/* Software PWM + * ______ ______ __ + * | ON |___OFF___| ON |___OFF___| .... + * |<-------------->|<-------------->|<- .... + * PWM period PWM period + * + * 256 interrupts/period[resolution] + * 64 periods/second[frequency] + * 256*64 interrupts/second + * F_CPU/(256*64) clocks/interrupt + */ +#define SLEEP_LED_TIMER_TOP F_CPU/(256*64) + +void sleep_led_init(void) +{ + /* Timer1 setup */ + /* CTC mode */ + TCCR1B |= _BV(WGM12); + /* Clock selelct: clk/1 */ + TCCR1B |= _BV(CS10); + /* Set TOP value */ + uint8_t sreg = SREG; + cli(); + OCR1AH = (SLEEP_LED_TIMER_TOP>>8)&0xff; + OCR1AL = SLEEP_LED_TIMER_TOP&0xff; + SREG = sreg; +} + +void sleep_led_enable(void) +{ + /* Enable Compare Match Interrupt */ + TIMSK1 |= _BV(OCIE1A); +} + +void sleep_led_disable(void) +{ + /* Disable Compare Match Interrupt */ + TIMSK1 &= ~_BV(OCIE1A); +} + +void sleep_led_toggle(void) +{ + /* Disable Compare Match Interrupt */ + TIMSK1 ^= _BV(OCIE1A); +} + + +/* Breathing Sleep LED brighness(PWM On period) table + * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle + * + * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63 + * (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i } + */ +static const uint8_t breathing_table[64] PROGMEM = { +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, +15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, +255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, +15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +ISR(TIMER1_COMPA_vect) +{ + /* Software PWM + * timer:1111 1111 1111 1111 + * \_____/\/ \_______/____ count(0-255) + * \ \______________ duration of step(4) + * \__________________ index of step table(0-63) + */ + static union { + uint16_t row; + struct { + uint8_t count:8; + uint8_t duration:2; + uint8_t index:6; + } pwm; + } timer = { .row = 0 }; + + timer.row++; + + // LED on + if (timer.pwm.count == 0) { + led_set(1< +#include + + +void suspend_idle(uint8_t timeout); +void suspend_power_down(void); +bool suspend_wakeup_condition(void); +void suspend_wakeup_init(void); + +#endif diff --git a/common/timer.h b/common/timer.h new file mode 100644 index 000000000..fe23f87ae --- /dev/null +++ b/common/timer.h @@ -0,0 +1,53 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef TIMER_H +#define TIMER_H 1 + +#include + +#if defined(__AVR__) +#include "avr/timer_avr.h" +#endif + + +#define TIMER_DIFF(a, b, max) ((a) >= (b) ? (a) - (b) : (max) - (b) + (a)) +#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX) +#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX) +#define TIMER_DIFF_32(a, b) TIMER_DIFF(a, b, UINT32_MAX) +#define TIMER_DIFF_RAW(a, b) TIMER_DIFF_8(a, b) + + +#ifdef __cplusplus +extern "C" { +#endif + +extern volatile uint32_t timer_count; + + +void timer_init(void); +void timer_clear(void); +uint16_t timer_read(void); +uint32_t timer_read32(void); +uint16_t timer_elapsed(uint16_t last); +uint32_t timer_elapsed32(uint32_t last); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/common/uart.c b/common/uart.c new file mode 100644 index 000000000..c17649b08 --- /dev/null +++ b/common/uart.c @@ -0,0 +1,129 @@ +// TODO: Teensy support(ATMega32u4/AT90USB128) +// Fixed for Arduino Duemilanove ATmega168p by Jun Wako +/* UART Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/ + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Version 1.0: Initial Release +// Version 1.1: Add support for Teensy 2.0, minor optimizations + + +#include +#include + +#include "uart.h" + +// These buffers may be any size from 2 to 256 bytes. +#define RX_BUFFER_SIZE 64 +#define TX_BUFFER_SIZE 40 + +static volatile uint8_t tx_buffer[TX_BUFFER_SIZE]; +static volatile uint8_t tx_buffer_head; +static volatile uint8_t tx_buffer_tail; +static volatile uint8_t rx_buffer[RX_BUFFER_SIZE]; +static volatile uint8_t rx_buffer_head; +static volatile uint8_t rx_buffer_tail; + +// Initialize the UART +void uart_init(uint32_t baud) +{ + cli(); + UBRR0 = (F_CPU / 4 / baud - 1) / 2; + UCSR0A = (1<= TX_BUFFER_SIZE) i = 0; + while (tx_buffer_tail == i) ; // wait until space in buffer + //cli(); + tx_buffer[i] = c; + tx_buffer_head = i; + UCSR0B = (1<= RX_BUFFER_SIZE) i = 0; + c = rx_buffer[i]; + rx_buffer_tail = i; + return c; +} + +// Return the number of bytes waiting in the receive buffer. +// Call this before uart_getchar() to check if it will need +// to wait for a byte to arrive. +uint8_t uart_available(void) +{ + uint8_t head, tail; + + head = rx_buffer_head; + tail = rx_buffer_tail; + if (head >= tail) return head - tail; + return RX_BUFFER_SIZE + head - tail; +} + +// Transmit Interrupt +ISR(USART_UDRE_vect) +{ + uint8_t i; + + if (tx_buffer_head == tx_buffer_tail) { + // buffer is empty, disable transmit interrupt + UCSR0B = (1<= TX_BUFFER_SIZE) i = 0; + UDR0 = tx_buffer[i]; + tx_buffer_tail = i; + } +} + +// Receive Interrupt +ISR(USART_RX_vect) +{ + uint8_t c, i; + + c = UDR0; + i = rx_buffer_head + 1; + if (i >= RX_BUFFER_SIZE) i = 0; + if (i != rx_buffer_tail) { + rx_buffer[i] = c; + rx_buffer_head = i; + } +} + diff --git a/common/uart.h b/common/uart.h new file mode 100644 index 000000000..41136a396 --- /dev/null +++ b/common/uart.h @@ -0,0 +1,11 @@ +#ifndef _uart_included_h_ +#define _uart_included_h_ + +#include + +void uart_init(uint32_t baud); +void uart_putchar(uint8_t c); +uint8_t uart_getchar(void); +uint8_t uart_available(void); + +#endif diff --git a/common/util.c b/common/util.c new file mode 100644 index 000000000..7e0d54299 --- /dev/null +++ b/common/util.c @@ -0,0 +1,101 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "util.h" + +// bit population - return number of on-bit +uint8_t bitpop(uint8_t bits) +{ + uint8_t c; + for (c = 0; bits; c++) + bits &= bits - 1; + return c; +/* + const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; + return bit_count[bits>>4] + bit_count[bits&0x0F] +*/ +} + +uint8_t bitpop16(uint16_t bits) +{ + uint8_t c; + for (c = 0; bits; c++) + bits &= bits - 1; + return c; +} + +uint8_t bitpop32(uint32_t bits) +{ + uint8_t c; + for (c = 0; bits; c++) + bits &= bits - 1; + return c; +} + +// most significant on-bit - return highest location of on-bit +// NOTE: return 0 when bit0 is on or all bits are off +uint8_t biton(uint8_t bits) +{ + uint8_t n = 0; + if (bits >> 4) { bits >>= 4; n += 4;} + if (bits >> 2) { bits >>= 2; n += 2;} + if (bits >> 1) { bits >>= 1; n += 1;} + return n; +} + +uint8_t biton16(uint16_t bits) +{ + uint8_t n = 0; + if (bits >> 8) { bits >>= 8; n += 8;} + if (bits >> 4) { bits >>= 4; n += 4;} + if (bits >> 2) { bits >>= 2; n += 2;} + if (bits >> 1) { bits >>= 1; n += 1;} + return n; +} + +uint8_t biton32(uint32_t bits) +{ + uint8_t n = 0; + if (bits >>16) { bits >>=16; n +=16;} + if (bits >> 8) { bits >>= 8; n += 8;} + if (bits >> 4) { bits >>= 4; n += 4;} + if (bits >> 2) { bits >>= 2; n += 2;} + if (bits >> 1) { bits >>= 1; n += 1;} + return n; +} + + + +uint8_t bitrev(uint8_t bits) +{ + bits = (bits & 0x0f)<<4 | (bits & 0xf0)>>4; + bits = (bits & 0b00110011)<<2 | (bits & 0b11001100)>>2; + bits = (bits & 0b01010101)<<1 | (bits & 0b10101010)>>1; + return bits; +} + +uint16_t bitrev16(uint16_t bits) +{ + bits = bitrev(bits & 0x00ff)<<8 | bitrev((bits & 0xff00)>>8); + return bits; +} + +uint32_t bitrev32(uint32_t bits) +{ + bits = (uint32_t)bitrev16(bits & 0x0000ffff)<<16 | bitrev16((bits & 0xffff0000)>>16); + return bits; +} diff --git a/common/util.h b/common/util.h new file mode 100644 index 000000000..7451cc084 --- /dev/null +++ b/common/util.h @@ -0,0 +1,43 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef UTIL_H +#define UTIL_H + +#include + +// convert to L string +#define LSTR(s) XLSTR(s) +#define XLSTR(s) L ## #s +// convert to string +#define STR(s) XSTR(s) +#define XSTR(s) #s + + +uint8_t bitpop(uint8_t bits); +uint8_t bitpop16(uint16_t bits); +uint8_t bitpop32(uint32_t bits); + +uint8_t biton(uint8_t bits); +uint8_t biton16(uint16_t bits); +uint8_t biton32(uint32_t bits); + +uint8_t bitrev(uint8_t bits); +uint16_t bitrev16(uint16_t bits); +uint32_t bitrev32(uint32_t bits); + +#endif diff --git a/common/wait.h b/common/wait.h new file mode 100644 index 000000000..40d00b0c7 --- /dev/null +++ b/common/wait.h @@ -0,0 +1,20 @@ +#ifndef WAIT_H +#define WAIT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__AVR__) +# include +# define wait_ms(ms) _delay_ms(ms) +# define wait_us(us) _delay_us(us) +#elif defined(__arm__) +# include "wait_api.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/doc/COPYING.GPLv2 b/doc/COPYING.GPLv2 new file mode 100644 index 000000000..d159169d1 --- /dev/null +++ b/doc/COPYING.GPLv2 @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/doc/COPYING.GPLv3 b/doc/COPYING.GPLv3 new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/doc/COPYING.GPLv3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/doc/FUSE.txt b/doc/FUSE.txt new file mode 100644 index 000000000..40055e5ab --- /dev/null +++ b/doc/FUSE.txt @@ -0,0 +1,40 @@ +ATMega168P Fuse/Lock Bits +========================= +This configuration is from usbasploader's Makefile. + + HFUSE 0xD6 + LFUSE 0xDF + EFUSE 0x00 + LOCK 0x3F(intact) + +#--------------------------------------------------------------------- +# ATMega168P +#--------------------------------------------------------------------- +# Fuse extended byte: +# 0x00 = 0 0 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800) +# \+/ +# +------- BOOTSZ (00 = 2k bytes) +# Fuse high byte: +# 0xd6 = 1 1 0 1 0 1 1 0 +# ^ ^ ^ ^ ^ \-+-/ +# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V) +# | | | | + --------- EESAVE (preserve EEPROM over chip erase) +# | | | +-------------- WDTON (if 0: watchdog always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire enable) +# +-------------------- RSTDISBL (reset pin is enabled) +# Fuse low byte: +# 0xdf = 1 1 0 1 1 1 1 1 +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (external >8M crystal) +# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) +# | +------------------ CKOUT (if 0: Clock output enabled) +# +-------------------- CKDIV8 (if 0: divide by 8) + + +# Lock Bits +# 0x3f = - - 1 1 1 1 1 1 +# \ / \-/ \-/ +# | | +----- LB 2..1 (No memory lock features enabled) +# | +--------- BLB0 2..1 (No restrictions for SPM or LPM accessing the Application section) +# +--------------- BLB1 2..1 (No restrictions for SPM or LPM accessing the Boot Loader section) diff --git a/doc/POWER.txt b/doc/POWER.txt new file mode 100644 index 000000000..0abbbe48e --- /dev/null +++ b/doc/POWER.txt @@ -0,0 +1,62 @@ +Time to Sleep +============= +USB suspend no activity on USB line for 3ms +No Interaction no user interaction + matrix has no change + matrix has no switch on + + +AVR Power Management +==================== + +V-USB suspend + USB suspend + http://vusb.wikidot.com/examples + +MCUSR MCU Status Register + WDRF Watchdog Reset Flag + BORF + EXTRF + PORF Power-on Reset Flag + +SMCR Sleep Mode Control Register + SE Sleep Enable + SM2:0 + #define set_sleep_mode(mode) \ + #define SLEEP_MODE_IDLE (0) + #define SLEEP_MODE_ADC _BV(SM0) + #define SLEEP_MODE_PWR_DOWN _BV(SM1) + #define SLEEP_MODE_PWR_SAVE (_BV(SM0) | _BV(SM1)) + #define SLEEP_MODE_STANDBY (_BV(SM1) | _BV(SM2)) + #define SLEEP_MODE_EXT_STANDBY (_BV(SM0) | _BV(SM1) | _BV(SM2)) + + +ACSR Analog Comparator Control and Status Register + To disable Analog Comparator + ACSR = 0x80; + or + ACSR &= ~_BV(ACIE); + ACSR |= _BV(ACD); + + ACD: Analog Comparator Disable + When this bit is written logic one, the power to the Analog Comparator is + switched off. This bit can be set at any time to turn off the Analog + Comparator. This will reduce power consumption in Active and Idle mode. + When changing the ACD bit, the Analog Comparator Interrupt must be disabled + by clearing the ACIE bit in ACSR. Otherwise an interrupt can occur when + the bit is changed. + +DIDR1 Digital Input Disable Register 1 + AIN1D + AIN0D + When this bit is written logic one, the digital input buffer on the AIN1/0 pin is disabled. The corresponding PIN Register bit will always read as zero when this bit is set. When an analog signal is applied to the AIN1/0 pin and the digital input from this pin is not needed, this bit should be written logic one to reduce power consumption in the digital input buffer. + + +PRR Power Reduction Register + PRTWI + PRTIM2 + PRTIM0 + PRTIM1 + PRSPI + PRUSART0 + PRADC diff --git a/doc/USB_NKRO.txt b/doc/USB_NKRO.txt new file mode 100644 index 000000000..d9f1d1229 --- /dev/null +++ b/doc/USB_NKRO.txt @@ -0,0 +1,160 @@ +USB NKRO MEMO +============= +2010/12/09 + + +References +---------- +USB - boot mode, NKRO, compatibility, etc... + http://geekhack.org/showthread.php?t=13162 +NKey Rollover - Overview, Testing Methodology, and Results + http://geekhack.org/showwiki.php?title=NKey+Rollover+-+Overview+Testing+Methodology+and+Results +dfj's NKRO(2010/06) + http://geekhack.org/showpost.php?p=191195&postcount=251 + http://geekhack.org/showthread.php?p=204389#post204389 + + +Terminology +--------- +NKRO +ghost +matrix +mechanical with diodes +membrane + + +OS Support Status +----------------- +USB NKRO is possible *without* a custom driver. +At least following OS's supports. + Windows7 64bit + WindowsXP + Windows2000 SP4 + Ubuntu10.4(Linux 2.6) + MacOSX(To be tested) + + +Custom Driver for USB NKRO +-------------------------- +NOT NEEDED +at least when using following report formats on Windows, Linux or MacOSX. + + +USB NKRO methods +---------------- +1. Virtual keyboards + Keyboard can increase its KRO by using virtual keyboards with Standard or Extended report. + If the keyboard has 2 virtual keyboard with Standard report(6KRO), it gets 12KRO. + Using this method means the keyboard is a composite device. + +2. Extended report + It needs large report size for this method to achieve NKRO. + If a keyboard has 101keys, it needs 103byte report. It seems to be inefficient. + +3. Bitmap report + If the keyboard has less than 128keys, 16byte report will be enough for NKRO. + The 16byte report seems to be reasonable cost to get NKRO. + + +Report Format +------------- +Other report formats than followings are possible, though these format are typical one. + +1. Standard 8bytes + modifiers(bitmap) 1byte + reserved 1byte(not used) + keys(array) 1byte*6 +Standard report can send 6keys plus 8modifiers simultaneously. +Standard report is used by most keyboards in the marketplace. +Standard report is identical to boot protocol report. +Standard report is hard to suffer from compatibility problems. + +2. Extended standard 16,32,64bytes + modifiers(bitmap) 1byte + reserved 1byte(not used) + keys(array) 1byte*(14,32,62) +Extended report can send N-keys by using N+2bytes. +Extended report is expected to be compatible with boot protocol. + +3. Bitmap 16,32,64bytes + keys(bitmap) (16,32)bytes +Bitmap report can send at most 128keys by 16bytes and 256keys by 32bytes. +Bitmap report can achieve USB NKRO efficiently in terms of report size. +Bitmap report needs a deliberation for boot protocol implementation. +Bitmap report descriptor sample: + 0x05, 0x01, // Usage Page (Generic Desktop), + 0x09, 0x06, // Usage (Keyboard), + 0xA1, 0x01, // Collection (Application), + // bitmap of modifiers + 0x75, 0x01, // Report Size (1), + 0x95, 0x08, // Report Count (8), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0xE0, // Usage Minimum (224), + 0x29, 0xE7, // Usage Maximum (231), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0x01, // Logical Maximum (1), + 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte + // LED output report + 0x95, 0x05, // Report Count (5), + 0x75, 0x01, // Report Size (1), + 0x05, 0x08, // Usage Page (LEDs), + 0x19, 0x01, // Usage Minimum (1), + 0x29, 0x05, // Usage Maximum (5), + 0x91, 0x02, // Output (Data, Variable, Absolute), + 0x95, 0x01, // Report Count (1), + 0x75, 0x03, // Report Size (3), + 0x91, 0x03, // Output (Constant), + // bitmap of keys + 0x95, (REPORT_BYTES-1)*8, // Report Count (), + 0x75, 0x01, // Report Size (1), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0x01, // Logical Maximum(1), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0x00, // Usage Minimum (0), + 0x29, (REPORT_BYTES-1)*8-1, // Usage Maximum (), + 0x81, 0x02, // Input (Data, Variable, Absolute), + 0xc0 // End Collection +where REPORT_BYTES is a report size in bytes. + + +Considerations +-------------- +Compatibility + boot protocol + minor/old system + Some BIOS doesn't send SET_PROTOCOL request, a keyboard can't switch to boot protocol mode. + This may cause a problem on a keyboard which uses other report than Standard. +Reactivity + USB polling time + OS/Driver processing time + + +Windows Problem +--------------- +1. Windows accepts only 6keys in case of Standard report. + It should be able to send 6keys plus 8modifiers. +2. Windows accepts only 10keys in case of 16bytes Extended report. + It should be able to send 14keys plus 8modifiers. +3. Windows accepts only 18keys in case of 32bytes Extended report. + It should be able to send 30keys plus 8modifiers. +If keys are pressed in excess of the number, wrong keys are registered on Windows. + +This problem will be reportedly fixed soon.(2010/12/05) + http://forums.anandtech.com/showpost.php?p=30873364&postcount=17 + + +Tools for testing NKRO +---------------------- +Browser App: +http://www.microsoft.com/appliedsciences/content/projects/KeyboardGhostingDemo.aspx +http://random.xem.us/rollover.html + +Windows: +AquaKeyTest.exe http://geekhack.org/showthread.php?t=6643 + +Linux: +xkeycaps +xev +showkeys + +EOF diff --git a/doc/build.md b/doc/build.md new file mode 100644 index 000000000..20702e94c --- /dev/null +++ b/doc/build.md @@ -0,0 +1,186 @@ +Build Firmware and Program Controller +===================================== + + +Download and Install +-------------------- +### 1. Install Tools + +1. **Toolchain** On Windows install [MHV AVR Tools][mhv] for AVR GCC compiler and [Cygwin][cygwin](or [MinGW][mingw]) for shell terminal. On Mac you can use [CrossPack][crosspack]. On Linux you can install AVR GCC with your favorite package manager. + +2. **Programmer** On Windows install [Atmel FLIP][flip]. On Mac and Linux install [dfu-programmer][dfu-prog]. + +3. **Driver** On Windows you start DFU bootloader on the chip first time you will see 'Found New Hardware Wizard' to install driver. If you install device driver properly you can find chip name like 'ATmega32U4' under 'LibUSB-Win32 Devices' tree on 'Device Manager'. If not you shall need to update its driver on 'Device Manager'. You will find the driver in `FLIP` install directory like: C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\. In case of `dfu-programmer` use its driver. + +If you use PJRC Teensy you don't need step 2 and 3 above, just get [Teensy loader][teensy-loader]. + + +### 2. Download source +You can find firmware source at github: + +- + +If you are familiar with `Git` tools you are recommended to use it but you can also download zip archive from: + +- + + +Build firmware +-------------- +### 1. Open terminal +Open terminal window to get access to commands. Use Cygwin(or MingGW) `shell terminal` in Windows or `Terminal.app` on Mac OSX. In Windows press `Windows` key and `R` then enter `cmd` in 'Run command' dialog showing up. + +### 2. Change directory +Move to project directory in the firmware source. + + cd tmk_keyboard/{'keyboard' or 'converter'}/ + +### 3. Make +Build firmware using GNU `make` command. You'll see `_.hex` file in that directory unless something unexpected occurs in build process. + + + make -f Makefile. clean + make -f Makefile. + + + + +Program Controller +------------------ +Now you have **hex** file to program on current directory. This **hex** is only needed to program your controller, other files are used for development and you may leave and forget them. + +### 1. Start bootloader +How to program controller depends on controller chip and its board design. To program AVR USB chips you'll need to start it up in bootloader mode. Most of boards with the chip have a push button to let bootloader come up. Consult with your controller board manual. + +### 2. Program with DFU bootloader +Stock AVR USB chip including ATmega32U4 has DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. Open source command line tool `dfu-programmer` also supports AVR chips, it runs on Linux, Mac OSX and even Windows. + +To program AVR chip with DFU bootloader use `FLIP` or `dfu-programmer`. +If you have a proper program command in `Makefile` just type this. + +`FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below. +To use command line tool run this command. Note that you need to set PATH variable properly. + + $ make -f Makefile. flip + +Or to program with `dfu-programmer` run: + + $ make -f Makefile. dfu + +#### FLIP GUI tutorial +1. On menu bar click Device -> Select, then. `ATmega32u4`. +2. On menu bar click Settings -> Communication -> USB, then click 'Open' button on 'USB Port Connection' dialog. +At this point you'll see grey-outed widgets on the app get colored and ready. + +3. On menu bar click File -> Load HEX File, then select your firmware hex file on File Selector dialog. +4. On 'Operations Flow' panel click 'Run' button to load the firmware binary to the chip. Note that you should keep 'Erase', 'Blank Check', 'Program' and 'Verify' check boxes selected. +5. Re-plug USB cord or click 'Start Application' button to restart your controller. +Done. + +See also these instructions if you need. + +- +- + + +### 3. Program with Teensy Loader +If you have PJRC Teensy see instruction of `Teensy Loader`. + +- + +Or use this command if you have command line version of Teensy Loader installed. + + $ make -f Makefile. teensy + + +### 4. Program with Other programmer +You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or USBasp. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile. + + $ make -f Makefile. program + + +[cygwin]: https://www.cygwin.com/ +[mingw]: http://www.mingw.org/ +[mhv]: https://infernoembedded.com/products/avr-tools +[winavr]: http://winavr.sourceforge.net/ +[crosspack]: http://www.obdev.at/products/crosspack/index.html +[flip]: http://www.atmel.com/tools/FLIP.aspx +[dfu-prog]: http://dfu-programmer.sourceforge.net/ +[teensy-loader]:http://www.pjrc.com/teensy/loader.html + + + +Makefile Options +---------------- +### 1. MCU and Frequency. + + MCU = atmega32u4 # Teensy 2.0 + #MCU = at90usb1286 # Teensy++ 2.0 + F_CPU = 16000000 + +Set your MCU and its clock in Hz. + + # Boot Section Size in *bytes* + # Teensy halfKay 512 + # Atmel DFU loader 4096 + # LUFA bootloader 4096 + OPT_DEFS += -DBOOTLOADER_SIZE=4096 + +If you are using PJRC Teensy use `512` for `BOOTLOADER_SIZE`, otherwise use `4096` unless you are sure. + +### 2. Features +Optional. Note that ***comment out*** with `#` to disable them. + + BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) + MOUSEKEY_ENABLE = yes # Mouse keys(+4700) + EXTRAKEY_ENABLE = yes # Audio control and System control(+450) + CONSOLE_ENABLE = yes # Console for debug(+400) + COMMAND_ENABLE = yes # Commands for debug and configuration + SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend + #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA + #BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality + +### 3. Programmer +Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`. + + # avrdude with AVRISPmkII + PROGRAM_CMD = avrdude -p $(MCU) -c avrispmkII -P USB -U flash:w:$(TARGET).hex + + # avrdude with USBaspLoader + PROGRAM_CMD = avrdude -p $(MCU) -c usbasp -U flash:w:$(TARGET).hex + + # avrdude with arduino + PROGRAM_CMD = avrdude -p $(MCU) -c arduino -P COM1 -b 57600 -U flash:w:$(TARGET).hex + + + +Config.h Options +---------------- +### 1. Magic command key combination + + #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT))) + +### 2. Mechanical Locking Support for CapsLock + + /* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */ + #define CAPSLOCK_LOCKING_ENABLE + /* Locking CapsLock re-synchronize hack */ + #define CAPSLOCK_LOCKING_RESYNC_ENABLE + +### 3. Disable Debug and Print + + /* disable debug print */ + #define NO_DEBUG + + /* disable print */ + #define NO_PRINT + +### 4. Disable Action Features + + #define NO_ACTION_LAYER + #define NO_ACTION_TAPPING + #define NO_ACTION_ONESHOT + #define NO_ACTION_MACRO + #define NO_ACTION_FUNCTION + +***TBD*** diff --git a/doc/keycode.txt b/doc/keycode.txt new file mode 100644 index 000000000..760c726e3 --- /dev/null +++ b/doc/keycode.txt @@ -0,0 +1,261 @@ +Keycode Symbol Table +==================== +Keycodes are defined in `common/keycode.h`. +Range of 00-A4 and E0-E7 are identical with HID Usage: + +Virtual keycodes are defined out of above range to support special actions. + + +Keycode Symbol Short name Description +-------------------------------------------------------------------------------- +KC_NO 00 Reserved (no event indicated) +KC_ROLL_OVER 01 Keyboard ErrorRollOver +KC_POST_FAIL 02 Keyboard POSTFail +KC_UNDEFINED 03 Keyboard ErrorUndefined +KC_A 04 Keyboard a and A +KC_B 05 Keyboard b and B +KC_C 06 Keyboard c and C +KC_D 07 Keyboard d and D +KC_E 08 Keyboard e and E +KC_F 09 Keyboard f and F +KC_G 0A Keyboard g and G +KC_H 0B Keyboard h and H +KC_I 0C Keyboard i and I +KC_J 0D Keyboard j and J +KC_K 0E Keyboard k and K +KC_L 0F Keyboard l and L +KC_M 10 Keyboard m and M +KC_N 11 Keyboard n and N +KC_O 12 Keyboard o and O +KC_P 13 Keyboard p and P +KC_Q 14 Keyboard q and Q +KC_R 15 Keyboard r and R +KC_S 16 Keyboard s and S +KC_T 17 Keyboard t and T +KC_U 18 Keyboard u and U +KC_V 19 Keyboard v and V +KC_W 1A Keyboard w and W +KC_X 1B Keyboard x and X +KC_Y 1C Keyboard y and Y +KC_Z 1D Keyboard z and Z +KC_1 1E Keyboard 1 and ! +KC_2 1F Keyboard 2 and @ +KC_3 20 Keyboard 3 and # +KC_4 21 Keyboard 4 and $ +KC_5 22 Keyboard 5 and % +KC_6 23 Keyboard 6 and ^ +KC_7 24 Keyboard 7 and & +KC_8 25 Keyboard 8 and * +KC_9 26 Keyboard 9 and ( +KC_0 27 Keyboard 0 and ) +KC_ENTER KC_ENT 28 Keyboard Return (ENTER) +KC_ESCAPE KC_ESC 29 Keyboard ESCAPE +KC_BSPACE KC_BSPC 2A Keyboard DELETE (Backspace) +KC_TAB 2B Keyboard Tab +KC_SPACE KC_SPC 2C Keyboard Spacebar +KC_MINUS KC_MINS 2D Keyboard - and (underscore) +KC_EQUAL KC_EQL 2E Keyboard = and + +KC_LBRACKET KC_LBRC 2F Keyboard [ and { +KC_RBRACKET KC_RBRC 30 Keyboard ] and } +KC_BSLASH KC_BSLS 31 Keyboard \ and | +KC_NONUS_HASH KC_NUHS 32 Keyboard Non-US # and ~ +KC_SCOLON KC_SCLN 33 Keyboard ; and : +KC_QUOTE KC_QUOT 34 Keyboard ‘ and “ +KC_GRAVE KC_GRV 35 Keyboard Grave Accent and Tilde +KC_COMMA KC_COMM 36 Keyboard, and < +KC_DOT 37 Keyboard . and > +KC_SLASH KC_SLSH 38 Keyboard / and ? +KC_CAPSLOCK KC_CAPS 39 Keyboard Caps Lock +KC_F1 3A Keyboard F1 +KC_F2 3B Keyboard F2 +KC_F3 3C Keyboard F3 +KC_F4 3D Keyboard F4 +KC_F5 3E Keyboard F5 +KC_F6 3F Keyboard F6 +KC_F7 40 Keyboard F7 +KC_F8 41 Keyboard F8 +KC_F9 42 Keyboard F9 +KC_F10 43 Keyboard F10 +KC_F11 44 Keyboard F11 +KC_F12 45 Keyboard F12 +KC_PSCREEN KC_PSCR 46 Keyboard PrintScreen1 +KC_SCKLOCK KC_SLCK 47 Keyboard Scroll Lock11 +KC_PAUSE KC_PAUS 48 Keyboard Pause1 +KC_INSERT KC_INS 49 Keyboard Insert1 +KC_HOME 4A Keyboard Home1 +KC_PGUP 4B Keyboard PageUp1 +KC_DELETE KC_DELETE 4C Keyboard Delete Forward +KC_END 4D Keyboard End1 +KC_PGDOWN KC_PGDN 4E Keyboard PageDown1 +KC_RIGHT KC_RGHT 4F Keyboard RightArrow1 +KC_LEFT 50 Keyboard LeftArrow1 +KC_DOWN 51 Keyboard DownArrow1 +KC_UP 52 Keyboard UpArrow1 +KC_NUMLOCK KC_NLCK 53 Keypad Num Lock and Clear11 +KC_KP_SLASH KC_PSLS 54 Keypad /1 +KC_KP_ASTERISK KC_PAST 55 Keypad * +KC_KP_MINUS KC_PMNS 56 Keypad - +KC_KP_PLUS KC_PPLS 57 Keypad + +KC_KP_ENTER KC_PENT 58 Keypad ENTER5 +KC_KP_1 KC_P1 59 Keypad 1 and End +KC_KP_2 KC_P2 5A Keypad 2 and Down Arrow +KC_KP_3 KC_P3 5B Keypad 3 and PageDn +KC_KP_4 KC_P4 5C Keypad 4 and Left Arrow +KC_KP_5 KC_P5 5D Keypad 5 +KC_KP_6 KC_P6 5E Keypad 6 and Right Arrow +KC_KP_7 KC_P7 5F Keypad 7 and Home +KC_KP_8 KC_P8 60 Keypad 8 and Up Arrow +KC_KP_9 KC_P9 61 Keypad 9 and PageUp +KC_KP_0 KC_P0 62 Keypad 0 and Insert +KC_KP_DOT KC_PDOT 63 Keypad . and Delete +KC_NONUS_BSLASH KC_NUBS 64 Keyboard Non-US \ and | +KC_APPLICATION KC_APP 65 Keyboard Application10 +KC_POWER 66 Keyboard Power9 +KC_KP_EQUAL KC_PEQL 67 Keypad = +KC_F13 68 Keyboard F13 +KC_F14 69 Keyboard F14 +KC_F15 6A Keyboard F15 +KC_F16 6B Keyboard F16 +KC_F17 6C Keyboard F17 +KC_F18 6D Keyboard F18 +KC_F19 6E Keyboard F19 +KC_F20 6F Keyboard F20 +KC_F21 70 Keyboard F21 +KC_F22 71 Keyboard F22 +KC_F23 72 Keyboard F23 +KC_F24 73 Keyboard F24 +KC_EXECUTE 74 Keyboard Execute +KC_HELP 75 Keyboard Help +KC_MENU 76 Keyboard Menu +KC_SELECT 77 Keyboard Select +KC_STOP 78 Keyboard Stop +KC_AGAIN 79 Keyboard Again +KC_UNDO 7A Keyboard Undo +KC_CUT 7B Keyboard Cut +KC_COPY 7C Keyboard Copy +KC_PASTE 7D Keyboard Paste +KC_FIND 7E Keyboard Find +KC__MUTE 7F Keyboard Mute +KC__VOLUP 80 Keyboard Volume Up +KC__VOLDOWN 81 Keyboard Volume Down +KC_LOCKING_CAPS 82 Keyboard Locking Caps Lock12 +KC_LOCKING_NUM 83 Keyboard Locking Num Lock12 +KC_LOCKING_SCROLL 84 Keyboard Locking Scroll Lock12 +KC_KP_COMMA KC_PCMM 85 Keypad Comma27 +KC_KP_EQUAL_AS400 86 Keypad Equal Sign29 +KC_INT1 KC_RO 87 Keyboard International115,28 +KC_INT2 KC_KANA 88 Keyboard International216 +KC_INT3 KC_JYEN 89 Keyboard International317 +KC_INT4 KC_HENK 8A Keyboard International418 +KC_INT5 KC_MHEN 8B Keyboard International519 +KC_INT6 8C Keyboard International620 +KC_INT7 8D Keyboard International721 +KC_INT8 8E Keyboard International822 +KC_INT9 8F Keyboard International922 +KC_LANG1 90 Keyboard LANG125 +KC_LANG2 91 Keyboard LANG226 +KC_LANG3 92 Keyboard LANG330 +KC_LANG4 93 Keyboard LANG431 +KC_LANG5 94 Keyboard LANG532 +KC_LANG6 95 Keyboard LANG68 +KC_LANG7 96 Keyboard LANG78 +KC_LANG8 97 Keyboard LANG88 +KC_LANG9 98 Keyboard LANG98 +KC_ALT_ERASE 99 Keyboard Alternate Erase7 +KC_SYSREQ 9A Keyboard SysReq/Attention1 +KC_CANCEL 9B Keyboard Cancel +KC_CLEAR 9C Keyboard Clear +KC_PRIOR 9D Keyboard Prior +KC_RETURN 9E Keyboard Return +KC_SEPARATOR 9F Keyboard Separator +KC_OUT A0 Keyboard Out +KC_OPER A1 Keyboard Oper +KC_CLEAR_AGAIN A2 Keyboard Clear/Again +KC_CRSEL A3 Keyboard CrSel/Props +KC_EXSEL A4 Keyboard ExSel +/* Modifiers */ +KC_LCTRL KC_LCTRL E0 Keyboard LeftControl +KC_LSHIFT KC_LSFT E1 Keyboard LeftShift +KC_LALT E2 Keyboard LeftAlt +KC_LGUI E3 Keyboard Left GUI(Windows/Apple/Meta key) +KC_RCTRL KC_RCTL E4 Keyboard RightControl +KC_RSHIFT KC_RSFT E5 Keyboard RightShift +KC_RALT E6 Keyboard RightAlt +KC_RGUI E7 Keyboard Right GUI(Windows/Apple/Meta key) + +/* + * Virtual keycodes + */ +/* System Control */ +KC_SYSTEM_POWER KC_PWR System Power Down +KC_SYSTEM_SLEEP KC_SLEP System Sleep +KC_SYSTEM_WAKE KC_WAKE System Wake +/* Consumer Page */ +KC_AUDIO_MUTE KC_MUTE +KC_AUDIO_VOL_UP KC_VOLU +KC_AUDIO_VOL_DOWN KC_VOLD +KC_MEDIA_NEXT_TRACK KC_MNXT +KC_MEDIA_PREV_TRACK KC_MPRV +KC_MEDIA_STOP KC_MSTP +KC_MEDIA_PLAY_PAUSE KC_MPLY +KC_MEDIA_SELECT KC_MSEL +KC_MAIL KC_MAIL +KC_CALCULATOR KC_CALC +KC_MY_COMPUTER KC_MYCM +KC_WWW_SEARCH KC_WSCH +KC_WWW_HOME KC_WHOM +KC_WWW_BACK KC_WBAK +KC_WWW_FORWARD KC_WFWD +KC_WWW_STOP KC_WSTP +KC_WWW_REFRESH KC_WREF +KC_WWW_FAVORITES KC_WFAV +/* Mousekey */ +KC_MS_UP KC_MS_U Mouse Cursor Up +KC_MS_DOWN KC_MS_D Mouse Cursor Down +KC_MS_LEFT KC_MS_L Mouse Cursor Left +KC_MS_RIGHT KC_MS_R Mouse Cursor Right +KC_MS_BTN1 KC_BTN1 Mouse Button 1 +KC_MS_BTN2 KC_BTN2 Mouse Button 2 +KC_MS_BTN3 KC_BTN3 Mouse Button 3 +KC_MS_BTN4 KC_BTN4 Mouse Button 4 +KC_MS_BTN5 KC_BTN5 Mouse Button 5 +KC_MS_WH_UP KC_WH_U Mouse Wheel Up +KC_MS_WH_DOWN KC_WH_D Mouse Wheel Down +KC_MS_WH_LEFT KC_WH_L Mouse Wheel Left +KC_MS_WH_RIGHT KC_WH_R Mouse Wheel Right +KC_MS_ACCEL0 KC_ACL0 Mouse Acceleration 0 +KC_MS_ACCEL1 KC_ACL1 Mouse Acceleration 1 +KC_MS_ACCEL2 KC_ACL2 Mouse Acceleration 2 +/* Fn key */ +KC_FN0 +KC_FN1 +KC_FN2 +KC_FN3 +KC_FN4 +KC_FN5 +KC_FN6 +KC_FN7 +KC_FN8 +KC_FN9 +KC_FN10 +KC_FN11 +KC_FN12 +KC_FN13 +KC_FN14 +KC_FN15 +KC_FN16 +KC_FN17 +KC_FN18 +KC_FN19 +KC_FN20 +KC_FN21 +KC_FN22 +KC_FN23 +KC_FN24 +KC_FN25 +KC_FN26 +KC_FN27 +KC_FN28 +KC_FN29 +KC_FN30 +KC_FN31 diff --git a/doc/keymap.md b/doc/keymap.md new file mode 100644 index 000000000..9d986a8c5 --- /dev/null +++ b/doc/keymap.md @@ -0,0 +1,593 @@ +Keymap framework - how to define your keymap +============================================ +***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.*** + +## 0. Keymap and layers +**Keymap** is comprised of multiple layers of key layout, you can define **32 layers** at most. +**Layer** is an array of **keycodes** to define **actions** for each physical keys. +respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence. + + Keymap: 32 Layers Layer: Keycode matrix + ----------------- --------------------- + stack of layers array_of_keycode[row][column] + ____________ precedence _______________________ + / / | high / ESC / F1 / F2 / F3 .... + 31 /___________// | /-----/-----/-----/----- + 30 /___________// | / TAB / Q / W / E .... + 29 /___________/ | /-----/-----/-----/----- + : _:_:_:_:_:__ | : /LCtrl/ A / S / D .... + : / : : : : : / | : / : : : : + 2 /___________// | 2 `-------------------------- + 1 /___________// | 1 `-------------------------- + 0 /___________/ V low 0 `-------------------------- + + + +### 0.1 Keymap status +Keymap has its state in two parameters: +**`default_layer`** indicates a base keymap layer(0-31) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit. + +Keymap layer '0' is usually `default_layer` and which is the only valid layer and other layers is initially off after boot up firmware, though, you can configured them in `config.h`. +To change `default_layer` will be useful when you switch key layout completely, say you want Colmak instead of Qwerty. + + Initial state of Keymap Change base layout + ----------------------- ------------------ + + 31 31 + 30 30 + 29 29 + : : + : : ____________ + 2 ____________ 2 / / + 1 / / ,->1 /___________/ + ,->0 /___________/ | 0 + | | + `--- default_layer = 0 `--- default_layer = 1 + layer_state = 0x00000001 layer_state = 0x00000002 + +On the other hand, you shall change `layer_state` to overlay base layer with some layers for feature such as navigation keys, function key(F1-F12), media keys or special actions. + + Overlay feature layer + --------------------- bit|status + ____________ ---+------ + 31 / / 31 | 0 + 30 /___________// -----> 30 | 1 + 29 /___________/ -----> 29 | 1 + : : | : + : ____________ : | : + 2 / / 2 | 0 + ,->1 /___________/ -----> 1 | 1 + | 0 0 | 0 + | + + `--- default_layer = 1 | + layer_state = 0x60000002 <-' + + + +### 0.2 Layer Precedence and Transparency +Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred. + +You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer. +Key with `KC_TRANS` doesn't has its own keycode and refers to lower valid layers for keycode, instead. +See example below. + + +### 0.3 Keymap Example +Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array. + +This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard. +This example has three layers, 'Qwerty' as base layer, 'Cursor' and 'Mousekey'. +In this example, + + `Fn0` is a **momentary layer switching** key, you can use keys on Cursor layer while holding the key. + + `Fn1` is a momentary layer switching key with tapping feature, you can get semicolon **';'** with taping the key and switch layers while holding the key. The word **'tap'** or **'tapping'** mean to press and release a key quickly. + + `Fn2` is a **toggle layer switch** key, you can stay switched layer after releasing the key unlike momentary switching. + +You can find other keymap definitions in file `keymap.c` located on project directories. + + static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: Qwerty + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn1| '|Enter | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0| + * `-----------------------------------------------------------' + * |Gui|Alt |Space |Alt |Fn2| + * `-------------------------------------------' + */ + KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, FN1, QUOT,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \ + LGUI,LALT, SPC, RALT,FN2), + /* 1: Cursor(HHKB mode) + * ,-----------------------------------------------------------. + * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt |Space |Alt |Gui| + * `--------------------------------------------' + */ + KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,BSPC, \ + LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ + LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ + LGUI,LALT, SPC, RALT,RGUI), + /* 2: Mousekey + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| | | | | |McL|McD|McU|McR| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt |Mb1 |Alt | | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,BSPC, \ + LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \ + LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,TRNS, \ + LGUI,LALT, BTN1, RALT,TRNS), + }; + + static const uint16_t PROGMEM fn_actions[] = { + ACTION_LAYER_MOMENTARY(1), // FN0 + ACTION_LAYER_TAP_KEY(2, KC_SCLN), // FN1 + ACTION_LAYER_TOGGLE(2), // FN2 + }; + + + + +## 1. Keycode +See [`common/keycode.h`](../common/keycode.h) or keycode table below for the detail. Keycode is internal **8bit code** to indicate action performed on key in keymap. Keycode has `KC_` prefixed symbol respectively. Most of keycodes like `KC_A` have simple action registers key to host on press and unregister on release, while some of other keycodes has some special actions like `Fn` keys, Media control keys, System control keys and Mousekeys. + + ***In `KEYMAP()` macro you should omit prefix part `KC_` of keycode to keep keymap compact.*** For example, just use `A` instead you place `KC_A` in `KEYMAP()`. Some keycodes has 4-letter **short name** in addition to descriptive name, you'll prefer short one in `KEYMAP()`. + +### 1.0 Other key +- `KC_NO` for no action +- `KC_TRNS` for layer transparency (See above) + +### 1.1 Normal key +- `KC_A` to `KC_Z`, `KC_1` to `KC_0` for alpha numeric key +- `KC_MINS`, `KC_EQL`, `KC_GRV`, `KC_RBRC`, `KC_LBRC`, `KC_COMM`, `KC_DOT`, `KC_BSLS`, `KC_SLSH`, `KC_SCLN`, `KC_QUOT` +- `KC_ESC`, `KC_TAB`, `KC_SPC`, `KC_BSPC`, `KC_ENT`, `KC_DEL`, `KC_INS` +- `KC_UP`, `KC_DOWN`, `KC_RGHT`, `KC_LEFT`, `KC_PGUP`, `KC_PGDN`, `KC_HOME`, `KC_END` +- `KC_CAPS`, `KC_NLCK`, `KC_SLCK`, `KC_PSCR`, `KC_PAUS`, `KC_APP`, `KC_F1` to `KC_F24` +- `KC_P1` to `KC_P0`, `KC_PDOT`, `KC_PCMM`, `KC_PSLS`, `KC_PAST`, `KC_PMNS`, `KC_PPLS`, `KC_PEQL`, `KC_PENT` for keypad. + +### 1.2 Modifier +There are 8 modifiers which has discrimination between left and right. + +- `KC_LCTL` and `KC_RCTL` for Control +- `KC_LSFT` and `KC_RSFT` for Shift +- `KC_LALT` and `KC_RALT` for Alt +- `KC_LGUI` and `KC_RGUI` for Windows key or Command key in Mac + +### 1.3 Mousekey +- `KC_MS_U`, `KC_MS_D`, `KC_MS_L`, `KC_MS_R` for mouse cursor +- `KC_WH_U`, `KC_WH_D`, `KC_WH_L`, `KC_WH_R` for mouse wheel +- `KC_BTN1`, `KC_BTN2`, `KC_BTN3`, `KC_BTN4`, `KC_BTN5` for mouse buttons + +### 1.4 System & Media key +- `KC_PWR`, `KC_SLEP`, `KC_WAKE` for Power, Sleep, Wake +- `KC_MUTE`, `KC_VOLU`, `KC_VOLD` for audio volume control +- `KC_MNXT`, `KC_MPRV`, `KC_MSTP`, `KC_MPLY`, `KC_MSEL` for media control +- `KC_MAIL`, `KC_CALC`, `KC_MYCM` for application launch +- `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation + +### 1.5 Fn key +`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.*** + +### 1.6 Keycode Table + See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes. + + In regard to implementation side most of keycodes are identical with [HID usage][HID_usage](pdf) sent to host for real and some virtual keycodes are defined to support special actions. +[HID_usage]: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf + + + +## 2. Action +See [`common/action_code.h`](../common/action_code.h). Action is a **16bit code** and defines function to perform on events of a key like press, release, holding and tapping. + +Most of keys just register 8bit scancode to host, but to support other complex features needs 16bit extended action codes internally. However, using 16bit action codes in keymap results in double size in memory compared to using just keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP()` instead of action codes. + +***You can just use keycodes of `Normal key`, `Modifier`, `Mousekey` and `System & Media key` in keymap*** to indicate corresponding actions instead of using action codes. While ***to use other special actions you should use keycode of `Fn` key defined in `fn_actions[]`.*** + + +### 2.1 Key Action +This is a simple action that registers scancodes(HID usage in fact) to host on press event of key and unregister on release. + +#### Parameters ++ **mods**: { ` MOD_LCTL`, ` MOD_LSFT`, ` MOD_LALT`, ` MOD_LGUI`, + ` MOD_RCTL`, ` MOD_RSFT`, ` MOD_RALT`, ` MOD_RGUI` } ++ **key**: keycode + + +#### 2.1.1 Normal key and Modifier +***This action usually won't be used expressly in keymap*** because you can just use keycodes in `KEYMAP()` instead. + +You can define these actions on *'A'* key and *'left shift'* modifier with: + + ACTION_KEY(KC_A) + ACTION_KEY(KC_LSFT) + +#### 2.1.2 Modified key +This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes. + +Say you want to assign a key to `Shift + 1` to get character *'!'* or `Alt + Tab` to switch application windows. + + ACTION_MODS_KEY(MOD_LSFT, KC_1) + ACTION_MODS_KEY(MOD_LALT, KC_TAB) + +Or `Alt,Shift + Tab` can be defined. `ACTION_MODS_KEY(mods, key)` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro. + + ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB) + +#### 2.1.3 Multiple Modifiers +Registers multiple modifiers with pressing a key. To specify multiple modifiers use `|`. + + ACTION_MODS(MOD_ALT | MOD_LSFT) + +#### 2.1.3 Modifier with Tap key([Dual role][dual_role]) +Works as a modifier key while holding, but registers a key on tap(press and release quickly). + + + ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT) + + + +### 2.2 Layer Action +These actions operate layers of keymap. + +#### Parameters +You can specify a **target layer** of action and **when the action is executed**. Some actions take a **bit value** for bitwise operation. + + ++ **layer**: `0`-`31` ++ **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` } ++ **bits**: 4-bit value and 1-bit mask bit + + +#### 2.2.1 Default Layer +Default Layer is a layer which always is valid and referred to when actions is not defined on other overlay layers. + +This sets Default Layer to given parameter `layer` and activate it. + + ACTION_DEFAULT_LAYER_SET(layer) + + +#### 2.2.2 Momentary +Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released. + + ACTION_LAYER_MOMENTARY(layer) + + +#### 2.2.3 Toggle Switch +Turns on `layer` with first type(press and release) and turns off with next. + + ACTION_LAYER_TOGGLE(layer) + + +#### 2.2.4 Momentary Switch with tap key +Turns on `layer` momentary while holding, but registers key on tap(press and release quickly). + + ACTION_LAYER_TAP_KEY(layer, key) + + +#### 2.2.5 Momentary Switch with tap toggle +Turns on `layer` momentary while holding and toggles it with serial taps. + + ACTION_LAYER_TAP_TOGGLE(layer) + + +#### 2.2.6 Invert state of layer +Inverts current state of `layer`. If the layer is on it becomes off with this action. + + ACTION_LAYER_INVERT(layer, on) + + +#### 2.2.7 Turn On layer +Turns on layer state. + + ACTION_LAYER_ON(layer, on) + +Turns on layer state on press and turns off on release. + + ACTION_LAYER_ON_OFF(layer) + + +#### 2.2.8 Turn Off layer +Turns off layer state. + + ACTION_LAYER_OFF(layer, on) + +Turns off layer state on press and activates on release. + + ACTION_LAYER_OFF_ON(layer) + + +#### 2.2.9 Set layer +Turn on layer only. +`layer_state = (1< ((bits< diff --git a/doc/other_projects.md b/doc/other_projects.md new file mode 100644 index 000000000..bf980b0a9 --- /dev/null +++ b/doc/other_projects.md @@ -0,0 +1,62 @@ +Other Keyboard Firmware Projects +================================ +## PJRC USB Keyboard/Mouse Example[USB][PJRC][Teensy][AVR] +- +- + +## kbupgrade[USB][V-USB][AVR] +- +- + +## c64key[USB][V-USB][AVR] +- + +## rump[USB][V-USB][AVR] +- +- + +## dulcimer[USB][V-USB][AVR] +- + +## humblehacker-keyboard[USB][LUFA][AVR][Ergo] +- +- +- + +## ps2avr[PS/2][AVR] +- + +## ErgoDox[Ergo][Split][USB][AVR] +- +- +- + +## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR] +- +- + +## bpiphany's AVR-Keyboard[PJRC][AVR][USB] +- +- +- + +## USB-USB keyboard remapper[converter][USB-USB][AVR][Arduino] +- +- + +## USB-USB converter threads[converter][USB-USB] +- +- + +## kbdbabel.org[converter][vintage][protocol][8051] +Great resource of vintage keyboard protocol information and code + +- + +## Haata's kiibohd Controller[converter][vintage][protocol][AVR][PJRC][Cortex] +A lots of vintage keyboard protocol supports + +- + +## Kinesis ergonomic keyboard firmware replacement[V-USB][LUFA][Ergo] +- diff --git a/ldscript_keymap_avr5.x b/ldscript_keymap_avr5.x new file mode 100644 index 000000000..c09693e51 --- /dev/null +++ b/ldscript_keymap_avr5.x @@ -0,0 +1,268 @@ +/* + * linker script for configurable keymap + * + * This adds keymap section which places keymap at fixed address and + * is based on binutils-avr ldscripts(/usr/lib/ldscripts/avr5.x). + */ +OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr") +OUTPUT_ARCH(avr:5) +MEMORY +{ + /* With keymap section + * + * Flash Map of ATMega32U4(32KB) + * +------------+ 0x0000 + * | .vectors | + * | .progmem | + * | .init0-9 | > text region + * | .text | + * | .fini9-0 | + * | | + * |------------| _etext + * | .data | + * | .bss | > data region + * | .noinit | + * | | + * |------------| 0x6800 + * | .keymap | > keymap region(2KB) + * |------------| 0x7000 + * | bootloader | 4KB + * +------------+ 0x7FFF + */ + text (rx) : ORIGIN = 0, LENGTH = 128K + keymap (rw!x) : ORIGIN = 0x6800, LENGTH = 2K + data (rw!x) : ORIGIN = 0x800060, LENGTH = 0xffa0 + eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 64K + fuse (rw!x) : ORIGIN = 0x820000, LENGTH = 1K + lock (rw!x) : ORIGIN = 0x830000, LENGTH = 1K + signature (rw!x) : ORIGIN = 0x840000, LENGTH = 1K +} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.text : + { + *(.rel.text) + *(.rel.text.*) + *(.rel.gnu.linkonce.t*) + } + .rela.text : + { + *(.rela.text) + *(.rela.text.*) + *(.rela.gnu.linkonce.t*) + } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.rodata : + { + *(.rel.rodata) + *(.rel.rodata.*) + *(.rel.gnu.linkonce.r*) + } + .rela.rodata : + { + *(.rela.rodata) + *(.rela.rodata.*) + *(.rela.gnu.linkonce.r*) + } + .rel.data : + { + *(.rel.data) + *(.rel.data.*) + *(.rel.gnu.linkonce.d*) + } + .rela.data : + { + *(.rela.data) + *(.rela.data.*) + *(.rela.gnu.linkonce.d*) + } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + /* Internal text space or external memory. */ + .text : + { + *(.vectors) + KEEP(*(.vectors)) + /* For data that needs to reside in the lower 64k of progmem. */ + *(.progmem.gcc*) + *(.progmem*) + . = ALIGN(2); + __trampolines_start = . ; + /* The jump trampolines for the 16-bit limited relocs will reside here. */ + *(.trampolines) + *(.trampolines*) + __trampolines_end = . ; + /* For future tablejump instruction arrays for 3 byte pc devices. + We don't relax jump/call instructions within these sections. */ + *(.jumptables) + *(.jumptables*) + /* For code that needs to reside in the lower 128k progmem. */ + *(.lowtext) + *(.lowtext*) + __ctors_start = . ; + *(.ctors) + __ctors_end = . ; + __dtors_start = . ; + *(.dtors) + __dtors_end = . ; + KEEP(SORT(*)(.ctors)) + KEEP(SORT(*)(.dtors)) + /* From this point on, we don't bother about wether the insns are + below or above the 16 bits boundary. */ + *(.init0) /* Start here after reset. */ + KEEP (*(.init0)) + *(.init1) + KEEP (*(.init1)) + *(.init2) /* Clear __zero_reg__, set up stack pointer. */ + KEEP (*(.init2)) + *(.init3) + KEEP (*(.init3)) + *(.init4) /* Initialize data and BSS. */ + KEEP (*(.init4)) + *(.init5) + KEEP (*(.init5)) + *(.init6) /* C++ constructors. */ + KEEP (*(.init6)) + *(.init7) + KEEP (*(.init7)) + *(.init8) + KEEP (*(.init8)) + *(.init9) /* Call main(). */ + KEEP (*(.init9)) + *(.text) + . = ALIGN(2); + *(.text.*) + . = ALIGN(2); + *(.fini9) /* _exit() starts here. */ + KEEP (*(.fini9)) + *(.fini8) + KEEP (*(.fini8)) + *(.fini7) + KEEP (*(.fini7)) + *(.fini6) /* C++ destructors. */ + KEEP (*(.fini6)) + *(.fini5) + KEEP (*(.fini5)) + *(.fini4) + KEEP (*(.fini4)) + *(.fini3) + KEEP (*(.fini3)) + *(.fini2) + KEEP (*(.fini2)) + *(.fini1) + KEEP (*(.fini1)) + *(.fini0) /* Infinite loop after program termination. */ + KEEP (*(.fini0)) + _etext = . ; + } > text + .data : AT (ADDR (.text) + SIZEOF (.text)) + { + PROVIDE (__data_start = .) ; + *(.data) + *(.data*) + *(.rodata) /* We need to include .rodata here if gcc is used */ + *(.rodata*) /* with -fdata-sections. */ + *(.gnu.linkonce.d*) + . = ALIGN(2); + _edata = . ; + PROVIDE (__data_end = .) ; + } > data + .bss : AT (ADDR (.bss)) + { + PROVIDE (__bss_start = .) ; + *(.bss) + *(.bss*) + *(COMMON) + PROVIDE (__bss_end = .) ; + } > data + __data_load_start = LOADADDR(.data); + __data_load_end = __data_load_start + SIZEOF(.data); + /* Global data not cleared after reset. */ + .noinit : + { + PROVIDE (__noinit_start = .) ; + *(.noinit*) + PROVIDE (__noinit_end = .) ; + _end = . ; + PROVIDE (__heap_start = .) ; + } > data + /* keymap region is located at end of flash + * .fn_actions Fn actions definitions + * .keymaps Mapping layers + */ + .keymap : + { + PROVIDE(__keymap_start = .) ; + *(.keymap.fn_actions) /* 32*actions = 64bytes */ + . = ALIGN(0x40); + *(.keymap.keymaps) /* rest of .keymap section */ + *(.keymap*) + /* . = ALIGN(0x800); */ /* keymap section takes 2KB- */ + } > keymap = 0x00 /* zero fill */ + .eeprom : + { + *(.eeprom*) + __eeprom_end = . ; + } > eeprom + .fuse : + { + KEEP(*(.fuse)) + KEEP(*(.lfuse)) + KEEP(*(.hfuse)) + KEEP(*(.efuse)) + } > fuse + .lock : + { + KEEP(*(.lock*)) + } > lock + .signature : + { + KEEP(*(.signature*)) + } > signature + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } +} diff --git a/protocol.mk b/protocol.mk new file mode 100644 index 000000000..726f658a0 --- /dev/null +++ b/protocol.mk @@ -0,0 +1,50 @@ +PROTOCOL_DIR = protocol + + +ifdef PS2_MOUSE_ENABLE + SRC += $(PROTOCOL_DIR)/ps2_mouse.c + OPT_DEFS += -DPS2_MOUSE_ENABLE + OPT_DEFS += -DMOUSE_ENABLE +endif + +ifdef PS2_USE_BUSYWAIT + SRC += protocol/ps2_busywait.c + SRC += protocol/ps2_io_avr.c + OPT_DEFS += -DPS2_USE_BUSYWAIT +endif + +ifdef PS2_USE_INT + SRC += protocol/ps2_interrupt.c + SRC += protocol/ps2_io_avr.c + OPT_DEFS += -DPS2_USE_INT +endif + +ifdef PS2_USE_USART + SRC += protocol/ps2_usart.c + SRC += protocol/ps2_io_avr.c + OPT_DEFS += -DPS2_USE_USART +endif + + +ifdef SERIAL_MOUSE_MICROSOFT_ENABLE + SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c + OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \ + -DMOUSE_ENABLE +endif + +ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE + SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c + OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \ + -DMOUSE_ENABLE +endif + +ifdef SERIAL_MOUSE_USE_SOFT + SRC += $(PROTOCOL_DIR)/serial_soft.c +endif + +ifdef SERIAL_MOUSE_USE_UART + SRC += $(PROTOCOL_DIR)/serial_uart.c +endif + +# Search Path +VPATH += $(TMK_DIR)/protocol diff --git a/protocol/adb.c b/protocol/adb.c new file mode 100644 index 000000000..bbff66df0 --- /dev/null +++ b/protocol/adb.c @@ -0,0 +1,456 @@ +/* +Copyright 2011 Jun WAKO +Copyright 2013 Shay Green + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include "adb.h" + + +// GCC doesn't inline functions normally +#define data_lo() (ADB_DDR |= (1< + * + */ + +// ADB Bit Cells +// +// bit cell time: 70-130us +// low part of bit0: 60-70% of bit cell +// low part of bit1: 30-40% of bit cell +// +// bit cell time 70us 130us +// -------------------------------------------- +// low part of bit0 42-49 78-91 +// high part of bit0 21-28 39-52 +// low part of bit1 21-28 39-52 +// high part of bit1 42-49 78-91 +// +// +// bit0: +// 70us bit cell: +// ____________~~~~~~ +// 42-49 21-28 +// +// 130us bit cell: +// ____________~~~~~~ +// 78-91 39-52 +// +// bit1: +// 70us bit cell: +// ______~~~~~~~~~~~~ +// 21-28 42-49 +// +// 130us bit cell: +// ______~~~~~~~~~~~~ +// 39-52 78-91 +// +// [from Apple IIgs Hardware Reference Second Edition] + +uint16_t adb_host_kbd_recv(void) +{ + uint16_t data = 0; + cli(); + attention(); + send_byte(0x2C); // Addr:Keyboard(0010), Cmd:Talk(11), Register0(00) + place_bit0(); // Stopbit(0) + if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored + sei(); + return -30; // something wrong + } + if (!wait_data_lo(500)) { // Tlt/Stop to Start(140-260us) + sei(); + return 0; // No data to send + } + + uint8_t n = 17; // start bit + 16 data bits + do { + uint8_t lo = (uint8_t) wait_data_hi(130); + if (!lo) + goto error; + + uint8_t hi = (uint8_t) wait_data_lo(lo); + if (!hi) + goto error; + + hi = lo - hi; + lo = 130 - lo; + + data <<= 1; + if (lo < hi) { + data |= 1; + } + else if (n == 17) { + sei(); + return -20; + } + } + while ( --n ); + + // Stop bit can't be checked normally since it could have service request lenghtening + // and its high state never goes low. + if (!wait_data_hi(351) || wait_data_lo(91)) { + sei(); + return -21; + } + sei(); + return data; + +error: + sei(); + return -n; +} + +void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l) +{ + cli(); + attention(); + send_byte(cmd); + place_bit0(); // Stopbit(0) + _delay_us(200); // Tlt/Stop to Start + place_bit1(); // Startbit(1) + send_byte(data_h); + send_byte(data_l); + place_bit0(); // Stopbit(0); + sei(); +} + +// send state of LEDs +void adb_host_kbd_led(uint8_t led) +{ + // Addr:Keyboard(0010), Cmd:Listen(10), Register2(10) + // send upper byte (not used) + // send lower byte (bit2: ScrollLock, bit1: CapsLock, bit0: + adb_host_listen(0x2A,0,led&0x07); +} + + +#ifdef ADB_PSW_BIT +static inline void psw_lo() +{ + ADB_DDR |= (1<>i)) + place_bit1(); + else + place_bit0(); + } +} + +// These are carefully coded to take 6 cycles of overhead. +// inline asm approach became too convoluted +static inline uint16_t wait_data_lo(uint16_t us) +{ + do { + if ( !data_in() ) + break; + _delay_us(1 - (6 * 1000000.0 / F_CPU)); + } + while ( --us ); + return us; +} + +static inline uint16_t wait_data_hi(uint16_t us) +{ + do { + if ( data_in() ) + break; + _delay_us(1 - (6 * 1000000.0 / F_CPU)); + } + while ( --us ); + return us; +} + + +/* +ADB Protocol +============ + +Resources +--------- +ADB - The Untold Story: Space Aliens Ate My Mouse + http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html +ADB Manager + http://developer.apple.com/legacy/mac/library/documentation/mac/pdf/Devices/ADB_Manager.pdf + Service request(5-17) +Apple IIgs Hardware Reference Second Edition [Chapter6 p121] + ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf +ADB Keycode + http://72.0.193.250/Documentation/macppc/adbkeycodes/ + http://m0115.web.fc2.com/m0115.jpg + [Inside Macintosh volume V, pages 191-192] + http://www.opensource.apple.com/source/IOHIDFamily/IOHIDFamily-421.18.3/IOHIDFamily/Cosmo_USB2ADB.c +ADB Signaling + http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf +ADB Overview & History + http://en.wikipedia.org/wiki/Apple_Desktop_Bus +Microchip Application Note: ADB device(with code for PIC16C) + http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011062 +AVR ATtiny2131 ADB to PS/2 converter(Japanese) + http://hp.vector.co.jp/authors/VA000177/html/KeyBoardA5DEA5CBA5A2II.html + + +Pinouts +------- + ADB female socket from the front: + __________ + | | <--- top + | 4o o3 | + |2o o1| + | == | + |________| <--- bottom + | | <--- 4pins + + + ADB female socket from bottom: + + ========== <--- front + | | + | | + |2o o1| + |4o o3| + ---------- <--- back + + 1: Data + 2: Power SW(low when press Power key) + 3: Vcc(5V) + 4: GND + + +Commands +-------- + ADB command is 1byte and consists of 4bit-address, 2bit-command + type and 2bit-register. The commands are always sent by Host. + + Command format: + 7 6 5 4 3 2 1 0 + | | | |------------ address + | |-------- command type + | |---- register + + bits commands + ------------------------------------------------------ + - - - - 0 0 0 0 Send Request(reset all devices) + A A A A 0 0 0 1 Flush(reset a device) + - - - - 0 0 1 0 Reserved + - - - - 0 0 1 1 Reserved + - - - - 0 1 - - Reserved + A A A A 1 0 R R Listen(write to a device) + A A A A 1 1 R R Talk(read from a device) + + The command to read keycodes from keyboard is 0x2C which + consist of keyboard address 2 and Talk against register 0. + + Address: + 2: keyboard + 3: mice + + Registers: + 0: application(keyboard uses this to store its data.) + 1: application + 2: application(keyboard uses this for LEDs and state of modifiers) + 3: status and command + + +Communication +------------- + This is a minimum information for keyboard communication. + See "Resources" for detail. + + Signaling: + + ~~~~____________~~||||||||||||__~~~~~_~~|||||||||||||||__~~~~ + + |800us | |7 Command 0| | | |15-64 Data 0|Stopbit(0) + +Attention | | | +Startbit(1) + +Startbit(1) | +Tlt(140-260us) + +stopbit(0) + + Bit cells: + + bit0: ______~~~ + 65 :35us + + bit1: ___~~~~~~ + 35 :65us + + bit0 low time: 60-70% of bit cell(42-91us) + bit1 low time: 30-40% of bit cell(21-52us) + bit cell time: 70-130us + [from Apple IIgs Hardware Reference Second Edition] + + Criterion for bit0/1: + After 55us if line is low/high then bit is 0/1. + + Attention & start bit: + Host asserts low in 560-1040us then places start bit(1). + + Tlt(Stop to Start): + Bus stays high in 140-260us then device places start bit(1). + + Global reset: + Host asserts low in 2.8-5.2ms. All devices are forced to reset. + + Service request from device(Srq): + Device can request to send at commad(Global only?) stop bit. + Requesting device keeps low for 140-260us at stop bit of command. + + +Keyboard Data(Register0) + This 16bit data can contains two keycodes and two released flags. + First keycode is palced in upper byte. When one keyocode is sent, + lower byte is 0xFF. + Release flag is 1 when key is released. + + 1514 . . . . . 8 7 6 . . . . . 0 + | | | | | | | | | +-+-+-+-+-+-+- Keycode2 + | | | | | | | | +--------------- Released2(1 when the key is released) + | +-+-+-+-+-+-+----------------- Keycode1 + +------------------------------- Released1(1 when the key is released) + + Keycodes: + Scancode consists of 7bit keycode and 1bit release flag. + Device can send two keycodes at once. If just one keycode is sent + keycode1 contains it and keyocode2 is 0xFF. + + Power switch: + You can read the state from PSW line(active low) however + the switch has a special scancode 0x7F7F, so you can + also read from Data line. It uses 0xFFFF for release scancode. + +Keyboard LEDs & state of keys(Register2) + This register hold current state of three LEDs and nine keys. + The state of LEDs can be changed by sending Listen command. + + 1514 . . . . . . 7 6 5 . 3 2 1 0 + | | | | | | | | | | | | | | | +- LED1(NumLock) + | | | | | | | | | | | | | | +--- LED2(CapsLock) + | | | | | | | | | | | | | +----- LED3(ScrollLock) + | | | | | | | | | | +-+-+------- Reserved + | | | | | | | | | +------------- ScrollLock + | | | | | | | | +--------------- NumLock + | | | | | | | +----------------- Apple/Command + | | | | | | +------------------- Option + | | | | | +--------------------- Shift + | | | | +----------------------- Control + | | | +------------------------- Reset/Power + | | +--------------------------- CapsLock + | +----------------------------- Delete + +------------------------------- Reserved + +END_OF_ADB +*/ diff --git a/protocol/adb.h b/protocol/adb.h new file mode 100644 index 000000000..bfe598bbf --- /dev/null +++ b/protocol/adb.h @@ -0,0 +1,62 @@ +/* +Copyright 2011 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef ADB_H +#define ADB_H + +#include +#include + +#if !(defined(ADB_PORT) && \ + defined(ADB_PIN) && \ + defined(ADB_DDR) && \ + defined(ADB_DATA_BIT)) +# error "ADB port setting is required in config.h" +#endif + +#define ADB_POWER 0x7F +#define ADB_CAPS 0x39 + + +// ADB host +void adb_host_init(void); +bool adb_host_psw(void); +uint16_t adb_host_kbd_recv(void); +void adb_host_listen(uint8_t cmd, uint8_t data_h, uint8_t data_l); +void adb_host_kbd_led(uint8_t led); + +#endif diff --git a/protocol/bluefruit.mk b/protocol/bluefruit.mk new file mode 100644 index 000000000..e1c5fff77 --- /dev/null +++ b/protocol/bluefruit.mk @@ -0,0 +1,27 @@ +BLUEFRUIT_DIR = protocol/bluefruit +PJRC_DIR = protocol/pjrc + +SRC += $(BLUEFRUIT_DIR)/main.c \ + $(BLUEFRUIT_DIR)/bluefruit.c \ + serial_uart.c \ + $(PJRC_DIR)/pjrc.c \ + $(PJRC_DIR)/usb_keyboard.c \ + $(PJRC_DIR)/usb_debug.c \ + $(PJRC_DIR)/usb.c + +# Option modules +ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) + SRC += $(PJRC_DIR)/usb_mouse.c +endif + +ifdef EXTRAKEY_ENABLE + SRC += $(PJRC_DIR)/usb_extra.c +endif + +# Search Path +VPATH += $(TMK_DIR)/$(BLUEFRUIT_DIR) +#VPATH += $(TMK_DIR)/$(BLUEFRUIT_DIR)/usb_debug_only +VPATH += $(TMK_DIR)/$(PJRC_DIR) + +OPT_DEFS += -DPROTOCOL_BLUEFRUIT +OPT_DEFS += -DPROTOCOL_PJRC diff --git a/protocol/bluefruit/bluefruit.c b/protocol/bluefruit/bluefruit.c new file mode 100644 index 000000000..cf26b83df --- /dev/null +++ b/protocol/bluefruit/bluefruit.c @@ -0,0 +1,202 @@ +/* +Bluefruit Protocol for TMK firmware +Author: Benjamin Gould, 2013 +Based on code Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include +#include "host.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "host_driver.h" +#include "serial.h" +#include "bluefruit.h" + +#define BLUEFRUIT_TRACE_SERIAL 1 + +static uint8_t bluefruit_keyboard_leds = 0; + +static void bluefruit_serial_send(uint8_t); + +void bluefruit_keyboard_print_report(report_keyboard_t *report) +{ + if (!debug_keyboard) return; + dprintf("keys: "); for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); } + dprintf(" mods: "); debug_hex8(report->mods); + dprintf(" reserved: "); debug_hex8(report->reserved); + dprintf("\n"); +} + +#ifdef BLUEFRUIT_TRACE_SERIAL +static void bluefruit_trace_header() +{ + dprintf("+------------------------------------+\n"); + dprintf("| HID report to Bluefruit via serial |\n"); + dprintf("+------------------------------------+\n|"); +} + +static void bluefruit_trace_footer() +{ + dprintf("|\n+------------------------------------+\n\n"); +} +#endif + +static void bluefruit_serial_send(uint8_t data) +{ +#ifdef BLUEFRUIT_TRACE_SERIAL + dprintf(" "); + debug_hex8(data); + dprintf(" "); +#endif + serial_send(data); +} + +/*------------------------------------------------------------------* + * Host driver + *------------------------------------------------------------------*/ + +static uint8_t keyboard_leds(void); +static void send_keyboard(report_keyboard_t *report); +static void send_mouse(report_mouse_t *report); +static void send_system(uint16_t data); +static void send_consumer(uint16_t data); + +static host_driver_t driver = { + keyboard_leds, + send_keyboard, + send_mouse, + send_system, + send_consumer +}; + +host_driver_t *bluefruit_driver(void) +{ + return &driver; +} + +static uint8_t keyboard_leds(void) { + return bluefruit_keyboard_leds; +} + +static void send_keyboard(report_keyboard_t *report) +{ +#ifdef BLUEFRUIT_TRACE_SERIAL + bluefruit_trace_header(); +#endif + bluefruit_serial_send(0xFD); + for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) { + bluefruit_serial_send(report->raw[i]); + } +#ifdef BLUEFRUIT_TRACE_SERIAL + bluefruit_trace_footer(); +#endif +} + +static void send_mouse(report_mouse_t *report) +{ +#ifdef BLUEFRUIT_TRACE_SERIAL + bluefruit_trace_header(); +#endif + bluefruit_serial_send(0xFD); + bluefruit_serial_send(0x00); + bluefruit_serial_send(0x03); + bluefruit_serial_send(report->buttons); + bluefruit_serial_send(report->x); + bluefruit_serial_send(report->y); + bluefruit_serial_send(report->v); // should try sending the wheel v here + bluefruit_serial_send(report->h); // should try sending the wheel h here + bluefruit_serial_send(0x00); +#ifdef BLUEFRUIT_TRACE_SERIAL + bluefruit_trace_footer(); +#endif +} + +static void send_system(uint16_t data) +{ +} + +/* ++-----------------+-------------------+-------+ +| Consumer Key | Bit Map | Hex | ++-----------------+-------------------+-------+ +| Home | 00000001 00000000 | 01 00 | +| KeyboardLayout | 00000010 00000000 | 02 00 | +| Search | 00000100 00000000 | 04 00 | +| Snapshot | 00001000 00000000 | 08 00 | +| VolumeUp | 00010000 00000000 | 10 00 | +| VolumeDown | 00100000 00000000 | 20 00 | +| Play/Pause | 01000000 00000000 | 40 00 | +| Fast Forward | 10000000 00000000 | 80 00 | +| Rewind | 00000000 00000001 | 00 01 | +| Scan Next Track | 00000000 00000010 | 00 02 | +| Scan Prev Track | 00000000 00000100 | 00 04 | +| Random Play | 00000000 00001000 | 00 08 | +| Stop | 00000000 00010000 | 00 10 | ++-------------------------------------+-------+ +*/ +#define CONSUMER2BLUEFRUIT(usage) \ + (usage == AUDIO_MUTE ? 0x0000 : \ + (usage == AUDIO_VOL_UP ? 0x1000 : \ + (usage == AUDIO_VOL_DOWN ? 0x2000 : \ + (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : \ + (usage == TRANSPORT_PREV_TRACK ? 0x0004 : \ + (usage == TRANSPORT_STOP ? 0x0010 : \ + (usage == TRANSPORT_STOP_EJECT ? 0x0000 : \ + (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : \ + (usage == AL_CC_CONFIG ? 0x0000 : \ + (usage == AL_EMAIL ? 0x0000 : \ + (usage == AL_CALCULATOR ? 0x0000 : \ + (usage == AL_LOCAL_BROWSER ? 0x0000 : \ + (usage == AC_SEARCH ? 0x0400 : \ + (usage == AC_HOME ? 0x0100 : \ + (usage == AC_BACK ? 0x0000 : \ + (usage == AC_FORWARD ? 0x0000 : \ + (usage == AC_STOP ? 0x0000 : \ + (usage == AC_REFRESH ? 0x0000 : \ + (usage == AC_BOOKMARKS ? 0x0000 : 0))))))))))))))))))) + +static void send_consumer(uint16_t data) +{ + static uint16_t last_data = 0; + if (data == last_data) return; + last_data = data; + + uint16_t bitmap = CONSUMER2BLUEFRUIT(data); + +#ifdef BLUEFRUIT_TRACE_SERIAL + dprintf("\nData: "); + debug_hex16(data); + dprintf("; bitmap: "); + debug_hex16(bitmap); + dprintf("\n"); + bluefruit_trace_header(); +#endif + bluefruit_serial_send(0xFD); + bluefruit_serial_send(0x00); + bluefruit_serial_send(0x02); + bluefruit_serial_send((bitmap>>8)&0xFF); + bluefruit_serial_send(bitmap&0xFF); + bluefruit_serial_send(0x00); + bluefruit_serial_send(0x00); + bluefruit_serial_send(0x00); + bluefruit_serial_send(0x00); +#ifdef BLUEFRUIT_TRACE_SERIAL + bluefruit_trace_footer(); +#endif +} + diff --git a/protocol/bluefruit/bluefruit.h b/protocol/bluefruit/bluefruit.h new file mode 100644 index 000000000..4f9b58836 --- /dev/null +++ b/protocol/bluefruit/bluefruit.h @@ -0,0 +1,28 @@ +/* +Bluefruit Protocol for TMK firmware +Author: Benjamin Gould, 2013 +Based on code Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef VUSB_H +#define VUSB_H + +#include "host_driver.h" + + +host_driver_t *bluefruit_driver(void); + +#endif diff --git a/protocol/bluefruit/main.c b/protocol/bluefruit/main.c new file mode 100644 index 000000000..871062ab1 --- /dev/null +++ b/protocol/bluefruit/main.c @@ -0,0 +1,116 @@ +/* +Bluefruit Protocol for TMK firmware +Author: Benjamin Gould, 2013 +Based on code Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include +#include +#include "serial.h" +#include "keyboard.h" +#include "usb.h" +#include "host.h" +#include "timer.h" +#include "print.h" +#include "debug.h" +#include "sendchar.h" +#include "suspend.h" +#include "bluefruit.h" +#include "pjrc.h" + +#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) + +#define HOST_DRIVER_NOT_SET 0 +#define BLUEFRUIT_HOST_DRIVER 1 +#define PJRC_HOST_DRIVER 2 + +int main(void) +{ + + CPU_PRESCALE(0); + + DDRD = _BV(PD5); + DDRB = _BV(PB0); + + PORTD = _BV(PD5); + PORTB = _BV(PB0); + + print_set_sendchar(sendchar); + + usb_init(); + _delay_ms(2000); + // while (!usb_configured()) /* wait */ + + dprintf("Initializing keyboard...\n"); + keyboard_init(); + + // This implementation is pretty simplistic... if the USB connection + // is not configured, choose the Bluefruit, otherwise use USB + // Definitely would prefer to have this driven by an input pin and make + // it switch dynamically - BCG + if (!usb_configured()) { + + // Send power to Bluefruit... Adafruit says it takes 27 mA, I think + // the pins should provide 40 mA, but just in case I switch the + // Bluefruit using a transistor - BCG + DDRB = _BV(PB6); + PORTB |= _BV(PB6); + + dprintf("Setting host driver to bluefruit...\n"); + host_set_driver(bluefruit_driver()); + + dprintf("Initializing serial...\n"); + serial_init(); + + // wait an extra second for the PC's operating system + // to load drivers and do whatever it does to actually + // be ready for input + _delay_ms(1000); + PORTD = ~_BV(PD5); + dprintf("Starting main loop"); + while (1) { + keyboard_task(); + } + + } else { + + // I'm not smart enough to get this done with LUFA - BCG + dprintf("Setting host driver to PJRC...\n"); + host_set_driver(pjrc_driver()); +#ifdef SLEEP_LED_ENABLE + sleep_led_init(); +#endif + // wait an extra second for the PC's operating system + // to load drivers and do whatever it does to actually + // be ready for input + _delay_ms(1000); + PORTB = ~_BV(PB0); + dprintf("Starting main loop"); + while (1) { + while (suspend) { + suspend_power_down(); + if (remote_wakeup && suspend_wakeup_condition()) { + usb_remote_wakeup(); + } + } + keyboard_task(); + } + } + +} diff --git a/protocol/ibm4704.c b/protocol/ibm4704.c new file mode 100644 index 000000000..10e229fd1 --- /dev/null +++ b/protocol/ibm4704.c @@ -0,0 +1,169 @@ +/* +Copyright 2010,2011,2012,2013 Jun WAKO +*/ +#include +#include +#include "debug.h" +#include "ibm4704.h" + + +#define WAIT(stat, us, err) do { \ + if (!wait_##stat(us)) { \ + ibm4704_error = err; \ + goto ERROR; \ + } \ +} while (0) + + +uint8_t ibm4704_error = 0; + + +void ibm4704_init(void) +{ + inhibit(); +} + +/* +Host to Keyboard +---------------- +Data bits are LSB first and Parity is odd. Clock has around 60us high and 30us low part. + + ____ __ __ __ __ __ __ __ __ __ ________ +Clock \______/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ + ^ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___ +Data ____|__/ X____X____X____X____X____X____X____X____X____X \___ + | Start 0 1 2 3 4 5 6 7 P Stop + Request by host + +Start bit: can be long as 300-350us. +Request: Host pulls Clock line down to request to send a command. +Timing: After Request keyboard pull up Data and down Clock line to low for start bit. + After request host release Clock line once Data line becomes hi. + Host writes a bit while Clock is hi and Keyboard reads while low. +Stop bit: Host releases or pulls up Data line to hi after 9th clock and waits for keyboard pull down the line to lo. +*/ +uint8_t ibm4704_send(uint8_t data) +{ + bool parity = true; // odd parity + ibm4704_error = 0; + + /* Request to send */ + idle(); + clock_lo(); + + /* wait for Start bit(Clock:lo/Data:hi) */ + WAIT(data_hi, 300, 0x30); + + /* Data bit */ + for (uint8_t i = 0; i < 8; i++) { + WAIT(clock_hi, 100, 0x40+i); + //_delay_us(5); + if (data&(1<= 0x30) { + xprintf("x%02X ", ibm4704_error); + } + _delay_us(200); // wait to recover clock to hi + return -1; +} + +/* receive data when host want else inhibit communication */ +uint8_t ibm4704_recv_response(void) +{ + // 250 * 100us(wait start bit in ibm4704_recv) + uint8_t data = 0; + uint8_t try = 250; + do { + data = ibm4704_recv(); + } while (try-- && ibm4704_error); + return data; +} + +/* +Keyboard to Host +---------------- +Data bits are LSB first and Parity is odd. Clock has around 60us high and 30us low part. + + ____ __ __ __ __ __ __ __ __ __ ________ +Clock \____/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ + ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ +Data ____/ X____X____X____X____X____X____X____X____X____X________ + Start 0 1 2 3 4 5 6 7 P Stop + +Start bit: can be long as 300-350us. +Inhibit: Pull Data line down to inhibit keyboard to send. +Timing: Host reads bit while Clock is hi. +Stop bit: Keyboard pulls down Data line to lo after 9th clock. +*/ +uint8_t ibm4704_recv(void) +{ + uint8_t data = 0; + bool parity = true; // odd parity + ibm4704_error = IBM4704_ERR_NONE; + + idle(); + _delay_us(5); // wait for line settles + + /* start bit */ + WAIT(clock_lo, 100, 0x11); // wait for keyboard to send + WAIT(data_hi, 100, 0x12); // can be delayed that long + + WAIT(clock_hi, 100, 0x13); // first rising edge which can take longer + /* data */ + for (uint8_t i = 0; i < 8; i++) { + WAIT(clock_hi, 100, 0x20+i); + //_delay_us(5); + if (data_in()) { + parity = !parity; + data |= (1< 0x12) { + xprintf("x%02X ", ibm4704_error); + } + inhibit(); + _delay_us(200); // wait to recover clock to hi + return -1; +} diff --git a/protocol/ibm4704.h b/protocol/ibm4704.h new file mode 100644 index 000000000..618cce6be --- /dev/null +++ b/protocol/ibm4704.h @@ -0,0 +1,110 @@ +/* +Copyright 2014 Jun WAKO +*/ +#ifndef IBM4704_H +#define IBM4704_H + +#define IBM4704_ERR_NONE 0 +#define IBM4704_ERR_PARITY 0x70 + + +void ibm4704_init(void); +uint8_t ibm4704_send(uint8_t data); +uint8_t ibm4704_recv_response(void); +uint8_t ibm4704_recv(void); + + +/* Check pin configuration */ +#if !(defined(IBM4704_CLOCK_PORT) && \ + defined(IBM4704_CLOCK_PIN) && \ + defined(IBM4704_CLOCK_DDR) && \ + defined(IBM4704_CLOCK_BIT)) +# error "ibm4704 clock pin configuration is required in config.h" +#endif + +#if !(defined(IBM4704_DATA_PORT) && \ + defined(IBM4704_DATA_PIN) && \ + defined(IBM4704_DATA_DDR) && \ + defined(IBM4704_DATA_BIT)) +# error "ibm4704 data pin configuration is required in config.h" +#endif + + +/*-------------------------------------------------------------------- + * static functions + *------------------------------------------------------------------*/ +static inline void clock_lo(void) +{ + IBM4704_CLOCK_PORT &= ~(1< + : 0:display only 1:display+yes/no button 2:keyboard only 3:none +SET BT SSP 2 1 # 2:keyboard only 1:Man-in-the-middle protection is needed +SET BT SSP 2 0 # 2:keyboard only 0:Man-in-the-middle protection is not needed + + +SET BT SSP 2 1 + bond only if MITM protection is supported by host +SET BT SSP 2 0 + bond even if MITM protection is not supported by host + +On Windows 'Add device' causes SSP PASSKEY event on iWRAP + SSP PASSKEY 78:dd:08:b7:e4:a2 ? + +If device has display(0 or 1) this event occurs. User should be shown this code on the device. + SSP CONFIRM 78:dd:08:b7:e4:a2 517572 + + +SET BT SSP 3 0 + No input/output, No MITM protection. + Without procedure of authentication the divice is bond to host. + + +Connect +======= +CALL 78:dd:08:b7:e4:a2 11 HID + + +Setting +======== +Following settings need to be done before wiring into keyboard. +- UART speed: 38400bps(115200bps didn't work with software serial) +- No SSP procedure(without MITM protection) +- No Power Saving + +# clear pairing record and set default +SET BT PAIR * +SET RESET + +SET CONTROL INIT SET CONTROL MUX 0 +SET CONTROL BAUD 38400,8n1 +SET BT NAME TMK Blootooth WT12 +SET BT CLASS 0005c0 +SET BT AUTH * 0000 +SET BT SSP 3 0 +SET CONTROL CONFIG 4800 +SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) +SET PROFILE SPP + +# power saving? +SET BT SNIFF 100 20 1 8 + + +# Report Descriptor +# combo keyboard + mouse + consumer +HID SET d2 05010906a1010507850119e029e715002501750195088102950175088101950575010508850119012905910295017503910395067508150025650507190029658100c005010902a1010901a1008502050919012908150025017501950881020501093009311581257f750895028106093895018106050c0a380295018106c0c0050c0901a1018503050c1500250109e909ea09e209cd19b529b87501950881020a8a010a21020a2a021a23022a27027501950881020a83010a96010a92010a9e010a94010a060209b209b4750195088102c0 + + + +SET PROFILE HID +--------------- + SET PROFILE HID 0d c0 100 0 en 0409 HHKB pro Bluetooth keyboard + {function bit} uint8 + {subclass} uint8 + {version} uint16 + {country} uint8 + {BTlang} char[2] + {USBlang} uint16 + {name} string + + +SET BT CLASS +------------ + See Class of Device + composite device: keyboard and mouse + SET BT CLASS 005c0 + + + + + + +---------- +after setting +---------- +set +SET BT BDADDR 00:07:80:47:22:14 +SET BT NAME TMK Blootooth WT12 +SET BT CLASS 0005c0 +SET BT AUTH * 0000 +SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP +SET BT LAP 9e8b33 +SET BT PAGEMODE 4 2000 1 +SET BT PAIR 78:dd:08:b7:e4:a2 9e3d85c91bcae73fef8cc10bec18b42f +SET BT POWER 3 3 3 +SET BT ROLE 0 f 7d00 +SET BT SNIFF 0 20 1 8 +SET BT SSP 3 0 +SET BT MTU 667 +SET CONTROL BAUD 38400,8n1 +SET CONTROL CD 00 0 +SET CONTROL ECHO 7 +SET CONTROL ESCAPE 43 00 1 +SET CONTROL GAIN 0 5 +SET CONTROL INIT SET CONTROL MUX 0 +SET CONTROL MSC DTE 00 00 00 00 00 00 +SET CONTROL MUX 1 +SET CONTROL PIO 00 00 +SET CONTROL READY 00 +SET PROFILE HID 0f c0 0100 00 en 0409 TMK Bluetooth keyboard(WT12) +SET + +set control config list +SET CONTROL CONFIG 0000 0000 0000 4900 KLUDGE INTERACTIVE_PIN UART_LATENCY + + +info config +WRAP THOR AI (5.0.1 build 620) +Copyright (c) 2003-2012 Bluegiga Technologies Inc. +Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 + BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME + - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) + - Bluetooth version 3.0, Power class 2 + - Loader 8615, firmware 8825 (56-bit encryption), native execution mode + - up 0 days, 01:50, 2 connections (pool 2) + - User configuration: +&028d = 0001 +&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 +&0298 = c053 +&0299 = 0000 0000 +&02a3 = 0030 0030 0030 0030 +&02a4 = 009d 0000 +&02a5 = 0053 0045 0054 0020 0043 004f 004e 0054 0052 004f 004c 0020 004d 0055 0058 0020 0030 +&02a7 = 0000 05c0 +&02a8 = 0800 0000 0000 0000 +&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 +&02ad = 4d54 204b 6c42 6f6f 6f74 746f 2068 5457 3231 +&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 +&02b3 = 0004 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0003 0005 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0005 +&02b7 = 000f 00c0 0100 0000 0065 006e 0409 4d54 204b 6c42 6575 6f74 746f &02bb = 8000 +READY. +---------- + + + +----- +After 5.0.1 Firmware update +Firmware: ai-5.0.1-620-25b.bc4.dfu +PSR: wt12-a.ai-5.0.1-620-25b.psrf +----- +info config +WRAP THOR AI (5.0.1 build 620) +Copyright (c) 2003-2012 Bluegiga Technologies Inc. +Compiled on Oct 1 2012 10:56:21, running on WT12-A module, psr v31 + BGIO FTP HFP HFP_AG HID HID_CONSUMER_PAGE HSP MAP MDP OTA PBAP PIO=0x00fc SSP SUBRATE TEST VOLUME + - BOCK4 version 620 (Oct 1 2012 10:56:03) (max acl/sco 7/1) + - Bluetooth version 3.0, Power class 2 + - Loader 8615, firmware 8825 (56-bit encryption), native execution mode + - up 0 days, 00:03, 0 connections (pool 1) + - User configuration: +&0295 = 0000 0005 000b 0000 0003 0000 0000 0000 0000 0000 0000 +&0299 = 0000 0000 +&02aa = 0004 2000 0001 0033 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +&02ac = 0000 0000 002b 0000 0000 0000 0000 0000 0000 0000 0002 0000 0000 0000 0010 0000 0000 0000 0000 029b 0000 0000 0000 0000 +&02ad = 5457 3231 412d +&02b0 = fa65 b0aa 934a 077b a600 d1cc fe58 8dd5 +READY. + +set +SET BT BDADDR 00:07:80:47:22:14 +SET BT NAME WT12-A +SET BT CLASS 001f00 +SET BT IDENT BT:47 f000 5.0.1 Bluegiga iWRAP +SET BT LAP 9e8b33 +SET BT PAGEMODE 4 2000 1 +SET BT PAIR 78:dd:08:b7:e4:a2 af18f81faa107e6dd068762ef921f48b +SET BT POWER 3 3 3 +SET BT ROLE 0 f 7d00 +SET BT SNIFF 0 20 1 8 +SET BT SSP 3 0 +SET BT MTU 667 +SET CONTROL BAUD 115200,8n1 +SET CONTROL CD 00 0 +SET CONTROL ECHO 7 +SET CONTROL ESCAPE 43 00 1 +SET CONTROL GAIN 0 5 +SET CONTROL MSC DTE 00 00 00 00 00 00 +SET CONTROL PIO 00 00 +SET CONTROL READY 00 +SET PROFILE SPP Bluetooth Serial Port +SET + +set control config list +SET CONTROL CONFIG 0000 0000 0000 0100 KLUDGE +--------- diff --git a/protocol/iwrap/iwrap.c b/protocol/iwrap/iwrap.c new file mode 100644 index 000000000..6a404116a --- /dev/null +++ b/protocol/iwrap/iwrap.c @@ -0,0 +1,469 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +/* host driver for Bulegiga iWRAP */ +/* Bluegiga BT12 + * Connections + * Hardware UART Software UART BlueTooth + * PC=====UART=======AVR=====SUART====iWRAP(BT12)-----------PC + * + * - Hardware UART for Debug Console to communicate iWRAP + * - Software UART for iWRAP control to send keyboard/mouse data + */ + +#include +#include +#include +#include +#include "keycode.h" +#include "suart.h" +#include "uart.h" +#include "report.h" +#include "host_driver.h" +#include "iwrap.h" +#include "print.h" + + +/* iWRAP MUX mode utils. 3.10 HID raw mode(iWRAP_HID_Application_Note.pdf) */ +#define MUX_HEADER(LINK, LENGTH) do { \ + xmit(0xbf); /* SOF */ \ + xmit(LINK); /* Link */ \ + xmit(0x00); /* Flags */ \ + xmit(LENGTH); /* Length */ \ +} while (0) +#define MUX_FOOTER(LINK) xmit(LINK^0xff) + + +static uint8_t connected = 0; +//static uint8_t channel = 1; + +/* iWRAP buffer */ +#define MUX_BUF_SIZE 64 +static char buf[MUX_BUF_SIZE]; +static uint8_t snd_pos = 0; + +#define MUX_RCV_BUF_SIZE 256 +static char rcv_buf[MUX_RCV_BUF_SIZE]; +static uint8_t rcv_head = 0; +static uint8_t rcv_tail = 0; + + +/* receive buffer */ +static void rcv_enq(char c) +{ + uint8_t next = (rcv_head + 1) % MUX_RCV_BUF_SIZE; + if (next != rcv_tail) { + rcv_buf[rcv_head] = c; + rcv_head = next; + } +} + +static char rcv_deq(void) +{ + char c = 0; + if (rcv_head != rcv_tail) { + c = rcv_buf[rcv_tail++]; + rcv_tail %= MUX_RCV_BUF_SIZE; + } + return c; +} + +/* +static char rcv_peek(void) +{ + if (rcv_head == rcv_tail) + return 0; + return rcv_buf[rcv_tail]; +} +*/ + +static void rcv_clear(void) +{ + rcv_tail = rcv_head = 0; +} + +/* iWRAP response */ +ISR(PCINT1_vect, ISR_BLOCK) // recv() runs away in case of ISR_NOBLOCK +{ + if ((SUART_IN_PIN & (1<mods); + xmit(0x00); // reserved byte(always 0) + xmit(report->keys[0]); + xmit(report->keys[1]); + xmit(report->keys[2]); + xmit(report->keys[3]); + xmit(report->keys[4]); + xmit(report->keys[5]); + MUX_FOOTER(0x01); +} + +static void send_mouse(report_mouse_t *report) +{ +#if defined(MOUSEKEY_ENABLE) || defined(PS2_MOUSE_ENABLE) + if (!iwrap_connected() && !iwrap_check_connection()) return; + MUX_HEADER(0x01, 0x09); + // HID raw mode header + xmit(0x9f); + xmit(0x07); // Length + xmit(0xa1); // DATA(Input) + xmit(0x02); // Report ID + xmit(report->buttons); + xmit(report->x); + xmit(report->y); + xmit(report->v); + xmit(report->h); + MUX_FOOTER(0x01); +#endif +} + +static void send_system(uint16_t data) +{ + /* not supported */ +} + +static void send_consumer(uint16_t data) +{ +#ifdef EXTRAKEY_ENABLE + static uint16_t last_data = 0; + uint8_t bits1 = 0; + uint8_t bits2 = 0; + uint8_t bits3 = 0; + + if (!iwrap_connected() && !iwrap_check_connection()) return; + if (data == last_data) return; + last_data = data; + + // 3.10 HID raw mode(iWRAP_HID_Application_Note.pdf) + switch (data) { + case AUDIO_VOL_UP: + bits1 = 0x01; + break; + case AUDIO_VOL_DOWN: + bits1 = 0x02; + break; + case AUDIO_MUTE: + bits1 = 0x04; + break; + case TRANSPORT_PLAY_PAUSE: + bits1 = 0x08; + break; + case TRANSPORT_NEXT_TRACK: + bits1 = 0x10; + break; + case TRANSPORT_PREV_TRACK: + bits1 = 0x20; + break; + case TRANSPORT_STOP: + bits1 = 0x40; + break; + case TRANSPORT_EJECT: + bits1 = 0x80; + break; + case AL_EMAIL: + bits2 = 0x01; + break; + case AC_SEARCH: + bits2 = 0x02; + break; + case AC_BOOKMARKS: + bits2 = 0x04; + break; + case AC_HOME: + bits2 = 0x08; + break; + case AC_BACK: + bits2 = 0x10; + break; + case AC_FORWARD: + bits2 = 0x20; + break; + case AC_STOP: + bits2 = 0x40; + break; + case AC_REFRESH: + bits2 = 0x80; + break; + case AL_CC_CONFIG: + bits3 = 0x01; + break; + case AL_CALCULATOR: + bits3 = 0x04; + break; + case AL_LOCK: + bits3 = 0x08; + break; + case AL_LOCAL_BROWSER: + bits3 = 0x10; + break; + case AC_MINIMIZE: + bits3 = 0x20; + break; + case TRANSPORT_RECORD: + bits3 = 0x40; + break; + case TRANSPORT_REWIND: + bits3 = 0x80; + break; + } + + MUX_HEADER(0x01, 0x07); + xmit(0x9f); + xmit(0x05); // Length + xmit(0xa1); // DATA(Input) + xmit(0x03); // Report ID + xmit(bits1); + xmit(bits2); + xmit(bits3); + MUX_FOOTER(0x01); +#endif +} diff --git a/protocol/iwrap/iwrap.h b/protocol/iwrap/iwrap.h new file mode 100644 index 000000000..ffaad9395 --- /dev/null +++ b/protocol/iwrap/iwrap.h @@ -0,0 +1,49 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef IWRAP_H +#define IWRAP_H + +#include +#include +#include "host_driver.h" + + +/* enable iWRAP MUX mode */ +#define MUX_MODE + + +host_driver_t *iwrap_driver(void); + +void iwrap_init(void); +void iwrap_send(const char *s); +void iwrap_mux_send(const char *s); +void iwrap_buf_send(void); +void iwrap_buf_add(uint8_t c); +void iwrap_buf_del(void); + +void iwrap_call(void); +void iwrap_kill(void); +void iwrap_unpair(void); +void iwrap_sleep(void); +void iwrap_sniff(void); +void iwrap_subrate(void); +bool iwrap_failed(void); +uint8_t iwrap_connected(void); +uint8_t iwrap_check_connection(void); + +#endif diff --git a/protocol/iwrap/main.c b/protocol/iwrap/main.c new file mode 100644 index 000000000..3abdce8df --- /dev/null +++ b/protocol/iwrap/main.c @@ -0,0 +1,376 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include +#include +#include +//#include +#include "wd.h" // in order to use watchdog in interrupt mode +#include +#include +#include +#include "keyboard.h" +#include "matrix.h" +#include "host.h" +#include "action.h" +#include "iwrap.h" +#ifdef PROTOCOL_VUSB +# include "vusb.h" +# include "usbdrv.h" +#endif +#include "uart.h" +#include "suart.h" +#include "timer.h" +#include "debug.h" +#include "keycode.h" +#include "command.h" + + +static void sleep(uint8_t term); +static bool console(void); +static bool console_command(uint8_t c); +static uint8_t key2asc(uint8_t key); + + +/* +static void set_prr(void) +{ + power_adc_disable(); + power_spi_disable(); + power_twi_disable(); +#ifndef TIMER_H + //power_timer0_disable(); // used in timer.c +#endif + power_timer1_disable(); + power_timer2_disable(); +} +*/ + +/* +static void pullup_pins(void) +{ + // DDRs are set to 0(input) by default. +#ifdef PORTA + PORTA = 0xFF; +#endif + PORTB = 0xFF; + PORTC = 0xFF; + PORTD = 0xFF; +#ifdef PORTE + PORTE = 0xFF; +#endif +#ifdef PORTE + PORTF = 0xFF; +#endif +} +*/ + + +#ifdef PROTOCOL_VUSB +static void disable_vusb(void) +{ + // disable interrupt & disconnect to prevent host from enumerating + USB_INTR_ENABLE &= ~(1 << USB_INTR_ENABLE_BIT); + usbDeviceDisconnect(); +} + +static void enable_vusb(void) +{ + USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT); + usbDeviceConnect(); +} + +static void init_vusb(void) +{ + uint8_t i = 0; + + usbInit(); + disable_vusb(); + /* fake USB disconnect for > 250 ms */ + while(--i){ + _delay_ms(1); + } + enable_vusb(); +} +#endif + +void change_driver(host_driver_t *driver) +{ + /* + host_clear_keyboard_report(); + host_swap_keyboard_report(); + host_clear_keyboard_report(); + host_send_keyboard_report(); + */ + clear_keyboard(); + _delay_ms(1000); + host_set_driver(driver); +} + + +static bool sleeping = false; +static bool insomniac = false; // TODO: should be false for power saving +static uint16_t last_timer = 0; + +int main(void) +{ + MCUSR = 0; + clock_prescale_set(clock_div_1); + WD_SET(WD_OFF); + + // power saving: the result is worse than nothing... why? + //pullup_pins(); + //set_prr(); + +#ifdef PROTOCOL_VUSB + disable_vusb(); +#endif + uart_init(115200); + keyboard_init(); + print("\nSend BREAK for UART Console Commands.\n"); + + // TODO: move to iWRAP/suart file + print("suart init\n"); + // suart init + // PC4: Tx Output IDLE(Hi) + PORTC |= (1<<4); + DDRC |= (1<<4); + // PC5: Rx Input(pull-up) + PORTC |= (1<<5); + DDRC &= ~(1<<5); + // suart receive interrut(PC5/PCINT13) + PCMSK1 = 0b00100000; + PCICR = 0b00000010; + + host_set_driver(iwrap_driver()); + + print("iwrap_init()\n"); + iwrap_init(); + iwrap_call(); + + last_timer = timer_read(); + while (true) { +#ifdef PROTOCOL_VUSB + if (host_get_driver() == vusb_driver()) + usbPoll(); +#endif + keyboard_task(); +#ifdef PROTOCOL_VUSB + if (host_get_driver() == vusb_driver()) + vusb_transfer_keyboard(); +#endif + // TODO: depricated + if (matrix_is_modified() || console()) { + last_timer = timer_read(); + sleeping = false; + } else if (!sleeping && timer_elapsed(last_timer) > 4000) { + sleeping = true; + iwrap_check_connection(); + } + + // TODO: suspend.h + if (host_get_driver() == iwrap_driver()) { + if (sleeping && !insomniac) { + _delay_ms(1); // wait for UART to send + iwrap_sleep(); + sleep(WDTO_60MS); + } + } + } +} + +static void sleep(uint8_t term) +{ + WD_SET(WD_IRQ, term); + + cli(); + set_sleep_mode(SLEEP_MODE_PWR_DOWN); + sleep_enable(); + sleep_bod_disable(); + sei(); + sleep_cpu(); + sleep_disable(); + + WD_SET(WD_OFF); +} + +static bool console(void) +{ + // Send to Bluetoot module WT12 + static bool breaked = false; + if (!uart_available()) + return false; + else { + uint8_t c; + c = uart_getchar(); + uart_putchar(c); + switch (c) { + case 0x00: // BREAK signal + if (!breaked) { + print("break(? for help): "); + breaked = true; + } + break; + case '\r': + uart_putchar('\n'); + iwrap_buf_send(); + break; + case '\b': + iwrap_buf_del(); + break; + default: + if (breaked) { + print("\n"); + console_command(c); + breaked = false; + } else { + iwrap_buf_add(c); + } + break; + } + return true; + } +} + +bool command_extra(uint8_t code) +{ + return console_command(key2asc(code)); +} + +static bool console_command(uint8_t c) +{ + switch (c) { + case 'h': + case '?': + print("\nCommands for Bluetooth(WT12/iWRAP):\n"); + print("r: reset. software reset by watchdog\n"); + print("i: insomniac. prevent KB from sleeping\n"); + print("c: iwrap_call. CALL for BT connection.\n"); +#ifdef PROTOCOL_VUSB + print("u: USB mode. switch to USB.\n"); + print("w: BT mode. switch to Bluetooth.\n"); +#endif + print("k: kill first connection.\n"); + print("Del: unpair first pairing.\n"); + print("\n"); + return 0; + case 'r': + print("reset\n"); + WD_AVR_RESET(); + return 1; + case 'i': + insomniac = !insomniac; + if (insomniac) + print("insomniac\n"); + else + print("not insomniac\n"); + return 1; + case 'c': + print("iwrap_call()\n"); + iwrap_call(); + return 1; +#ifdef PROTOCOL_VUSB + case 'u': + print("USB mode\n"); + init_vusb(); + change_driver(vusb_driver()); + //iwrap_kill(); + //iwrap_sleep(); + // disable suart receive interrut(PC5/PCINT13) + PCMSK1 &= ~(0b00100000); + PCICR &= ~(0b00000010); + return 1; + case 'w': + print("iWRAP mode\n"); + change_driver(iwrap_driver()); + disable_vusb(); + // enable suart receive interrut(PC5/PCINT13) + PCMSK1 |= 0b00100000; + PCICR |= 0b00000010; + return 1; +#endif + case 'k': + print("kill\n"); + iwrap_kill(); + return 1; + case 0x7F: // DELETE + print("unpair\n"); + iwrap_unpair(); + return 1; + } + return 0; +} + +// convert keycode into ascii charactor +static uint8_t key2asc(uint8_t key) +{ + switch (key) { + case KC_A: return 'a'; + case KC_B: return 'b'; + case KC_C: return 'c'; + case KC_D: return 'd'; + case KC_E: return 'e'; + case KC_F: return 'f'; + case KC_G: return 'g'; + case KC_H: return 'h'; + case KC_I: return 'i'; + case KC_J: return 'j'; + case KC_K: return 'k'; + case KC_L: return 'l'; + case KC_M: return 'm'; + case KC_N: return 'n'; + case KC_O: return 'o'; + case KC_P: return 'p'; + case KC_Q: return 'q'; + case KC_R: return 'r'; + case KC_S: return 's'; + case KC_T: return 't'; + case KC_U: return 'u'; + case KC_V: return 'v'; + case KC_W: return 'w'; + case KC_X: return 'x'; + case KC_Y: return 'y'; + case KC_Z: return 'z'; + case KC_1: return '1'; + case KC_2: return '2'; + case KC_3: return '3'; + case KC_4: return '4'; + case KC_5: return '5'; + case KC_6: return '6'; + case KC_7: return '7'; + case KC_8: return '8'; + case KC_9: return '9'; + case KC_0: return '0'; + case KC_ENTER: return '\n'; + case KC_ESCAPE: return 0x1B; + case KC_BSPACE: return '\b'; + case KC_TAB: return '\t'; + case KC_SPACE: return ' '; + case KC_MINUS: return '-'; + case KC_EQUAL: return '='; + case KC_LBRACKET: return '['; + case KC_RBRACKET: return ']'; + case KC_BSLASH: return '\\'; + case KC_NONUS_HASH: return '\\'; + case KC_SCOLON: return ';'; + case KC_QUOTE: return '\''; + case KC_GRAVE: return '`'; + case KC_COMMA: return ','; + case KC_DOT: return '.'; + case KC_SLASH: return '/'; + default: return 0x00; + } +} diff --git a/protocol/iwrap/mux_exit.rb b/protocol/iwrap/mux_exit.rb new file mode 100644 index 000000000..1f6be48af --- /dev/null +++ b/protocol/iwrap/mux_exit.rb @@ -0,0 +1,7 @@ +# +# Rescue from Bluegiga iWRAP MUX mode +# 6.75 of iWRAP5_User_Guid.pdf +# +[0xBF, 0xFF, 0x00, 0x11, 0x53, 0x45, 0x54, 0x20, 0x43, 0x4f, 0x4e, 0x54, 0x52, 0x4f, 0x4c, 0x20, 0x4d, 0x55, 0x58, 0x20, 0x30, 0x00].each do |x| + print x.chr +end diff --git a/protocol/iwrap/suart.S b/protocol/iwrap/suart.S new file mode 100644 index 000000000..1b0290963 --- /dev/null +++ b/protocol/iwrap/suart.S @@ -0,0 +1,156 @@ +;---------------------------------------------------------------------------; +; Software implemented UART module ; +; (C)ChaN, 2005 (http://elm-chan.org/) ; +;---------------------------------------------------------------------------; +; Bit rate settings: +; +; 1MHz 2MHz 4MHz 6MHz 8MHz 10MHz 12MHz 16MHz 20MHz +; 2.4kbps 138 - - - - - - - - +; 4.8kbps 68 138 - - - - - - - +; 9.6kbps 33 68 138 208 - - - - - +; 19.2kbps - 33 68 102 138 173 208 - - +; 38.4kbps - - 33 50 68 85 102 138 172 +; 57.6kbps - - 21 33 44 56 68 91 114 +; 115.2kbps - - - - 21 27 33 44 56 + +.nolist +#include +.list + +#define BPS 102 /* Bit delay. (see above table) */ +#define BIDIR 0 /* 0:Separated Tx/Rx, 1:Shared Tx/Rx */ + +#define OUT_1 sbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 1 */ +#define OUT_0 cbi _SFR_IO_ADDR(SUART_OUT_PORT), SUART_OUT_BIT /* Output 0 */ +#define SKIP_IN_1 sbis _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 1 */ +#define SKIP_IN_0 sbic _SFR_IO_ADDR(SUART_IN_PIN), SUART_IN_BIT /* Skip if 0 */ + + + +#ifdef SPM_PAGESIZE +.macro _LPMI reg + lpm \reg, Z+ +.endm +.macro _MOVW dh,dl, sh,sl + movw \dl, \sl +.endm +#else +.macro _LPMI reg + lpm + mov \reg, r0 + adiw ZL, 1 +.endm +.macro _MOVW dh,dl, sh,sl + mov \dl, \sl + mov \dh, \sh +.endm +#endif + + + +;---------------------------------------------------------------------------; +; Transmit a byte in serial format of N81 +; +;Prototype: void xmit (uint8_t data); +;Size: 16 words + +.global xmit +.func xmit +xmit: +#if BIDIR + ldi r23, BPS-1 ;Pre-idle time for bidirectional data line +5: dec r23 ; + brne 5b ;/ +#endif + in r0, _SFR_IO_ADDR(SREG) ;Save flags + + com r24 ;C = start bit + ldi r25, 10 ;Bit counter + cli ;Start critical section + +1: ldi r23, BPS-1 ;----- Bit transferring loop +2: dec r23 ;Wait for a bit time + brne 2b ;/ + brcs 3f ;MISO = bit to be sent + OUT_1 ; +3: brcc 4f ; + OUT_0 ;/ +4: lsr r24 ;Get next bit into C + dec r25 ;All bits sent? + brne 1b ; no, coutinue + + out _SFR_IO_ADDR(SREG), r0 ;End of critical section + ret +.endfunc + + + +;---------------------------------------------------------------------------; +; Receive a byte +; +;Prototype: uint8_t rcvr (void); +;Size: 19 words + +.global rcvr +.func rcvr +rcvr: + in r0, _SFR_IO_ADDR(SREG) ;Save flags + + ldi r24, 0x80 ;Receiving shift reg + cli ;Start critical section + +1: SKIP_IN_1 ;Wait for idle + rjmp 1b +2: SKIP_IN_0 ;Wait for start bit + rjmp 2b + ldi r25, BPS/2 ;Wait for half bit time +3: dec r25 + brne 3b + +4: ldi r25, BPS ;----- Bit receiving loop +5: dec r25 ;Wait for a bit time + brne 5b ;/ + lsr r24 ;Next bit + SKIP_IN_0 ;Get a data bit into r24.7 + ori r24, 0x80 + brcc 4b ;All bits received? no, continue + + out _SFR_IO_ADDR(SREG), r0 ;End of critical section + ret +.endfunc + + +; Not wait for start bit. This should be called after detecting start bit. +.global recv +.func recv +recv: + in r0, _SFR_IO_ADDR(SREG) ;Save flags + + ldi r24, 0x80 ;Receiving shift reg + cli ;Start critical section + +;1: SKIP_IN_1 ;Wait for idle +; rjmp 1b +;2: SKIP_IN_0 ;Wait for start bit +; rjmp 2b + ldi r25, BPS/2 ;Wait for half bit time +3: dec r25 + brne 3b + +4: ldi r25, BPS ;----- Bit receiving loop +5: dec r25 ;Wait for a bit time + brne 5b ;/ + lsr r24 ;Next bit + SKIP_IN_0 ;Get a data bit into r24.7 + ori r24, 0x80 + brcc 4b ;All bits received? no, continue + + ldi r25, BPS/2 ;Wait for half bit time +6: dec r25 + brne 6b +7: SKIP_IN_1 ;Wait for stop bit + rjmp 7b + + out _SFR_IO_ADDR(SREG), r0 ;End of critical section + ret +.endfunc diff --git a/protocol/iwrap/suart.h b/protocol/iwrap/suart.h new file mode 100644 index 000000000..72725b998 --- /dev/null +++ b/protocol/iwrap/suart.h @@ -0,0 +1,8 @@ +#ifndef SUART +#define SUART + +void xmit(uint8_t); +uint8_t rcvr(void); +uint8_t recv(void); + +#endif /* SUART */ diff --git a/protocol/iwrap/wd.h b/protocol/iwrap/wd.h new file mode 100644 index 000000000..99058f033 --- /dev/null +++ b/protocol/iwrap/wd.h @@ -0,0 +1,159 @@ +/* This is from http://www.mtcnet.net/~henryvm/wdt/ */ +#ifndef _AVR_WD_H_ +#define _AVR_WD_H_ + +#include + +/* +Copyright (c) 2009, Curt Van Maanen + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER 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 usage- + #include "wd.h" //if in same directory as project + #include //if wd.h is in avr directory + +set watchdog modes and prescale + +usage- + WD_SET(mode,[timeout]); //prescale always set + +modes- + WD_OFF disabled + WD_RST normal reset mode + WD_IRQ interrupt only mode (if supported) + WD_RST_IRQ interrupt+reset mode (if supported) + +timeout- + WDTO_15MS default if no timeout provided + WDTO_30MS + WDTO_60MS + WDTO_120MS + WDTO_250MS + WDTO_500MS + WDTO_1S + WDTO_2S + WDTO_4S (if supported) + WDTO_8S (if supported) + +examples- + WD_SET(WD_RST,WDTO_1S); //reset mode, 1s timeout + WD_SET(WD_OFF); //watchdog disabled (if not fused on) + WD_SET(WD_RST); //reset mode, 15ms (default timeout) + WD_SET(WD_IRQ,WDTO_120MS); //interrupt only mode, 120ms timeout + WD_SET(WD_RST_IRQ,WDTO_2S); //interrupt+reset mode, 2S timeout + + +for enhanced watchdogs, if the watchdog is not being used WDRF should be +cleared on every power up or reset, along with disabling the watchdog- + WD_DISABLE(); //clear WDRF, then turn off watchdog + +*/ + +//reset registers to the same name (MCUCSR) +#if !defined(MCUCSR) +#define MCUCSR MCUSR +#endif + +//watchdog registers to the same name (WDTCSR) +#if !defined(WDTCSR) +#define WDTCSR WDTCR +#endif + +//if enhanced watchdog, define irq values, create disable macro +#if defined(WDIF) +#define WD_IRQ 0xC0 +#define WD_RST_IRQ 0xC8 +#define WD_DISABLE() do{ \ + MCUCSR &= ~(1< +#include +#include + +/* References to the binary EEPROM data linked in the AVR's FLASH memory space */ +extern const char _binary_InputEEData_bin_start[]; +extern const char _binary_InputEEData_bin_end[]; +extern const char _binary_InputEEData_bin_size[]; + +/* Friendly names for the embedded binary data stored in FLASH memory space */ +#define InputEEData _binary_InputEEData_bin_start +#define InputEEData_size ((int)_binary_InputEEData_bin_size) + +int main(void) +{ + /* Copy out the embedded EEPROM data from FLASH to EEPROM memory space */ + for (uint16_t i = 0; i < InputEEData_size; i++) + eeprom_update_byte((uint8_t*)i, pgm_read_byte(&InputEEData[i])); + + /* Infinite loop once complete */ + for (;;); +} diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/HID_EEPROM_Loader/makefile b/protocol/lufa/LUFA-120730/LUFA/Build/HID_EEPROM_Loader/makefile new file mode 100644 index 000000000..f6dcbea67 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/HID_EEPROM_Loader/makefile @@ -0,0 +1,40 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# +# -------------------------------------- +# LUFA Project Makefile. +# -------------------------------------- + +MCU = at90usb1287 +ARCH = AVR8 +F_CPU = 1000000 +F_USB = $(F_CPU) +OPTIMIZATION = s +TARGET = HID_EEPROM_Loader +SRC = $(TARGET).c +LUFA_PATH = ../../../LUFA +CC_FLAGS = +LD_FLAGS = +OBJECT_FILES = InputEEData.o + +# Default target +all: + +# Determine the AVR sub-architecture of the build main application object file +FIND_AVR_SUBARCH = avr$(shell avr-objdump -f $(TARGET).o | grep architecture | cut -d':' -f3 | cut -d',' -f1) + +# Create a linkable object file with the input binary EEPROM data stored in the FLASH section +InputEEData.o: InputEEData.bin $(TARGET).o $(MAKEFILE_LIST) + @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a object file \"$@\" + avr-objcopy -I binary -O elf32-avr -B $(call FIND_AVR_SUBARCH) --rename-section .data=.progmem.data,contents,alloc,readonly,data $< $@ + +# Include LUFA build script makefiles +include $(LUFA_PATH)/Build/lufa_core.mk +include $(LUFA_PATH)/Build/lufa_build.mk +include $(LUFA_PATH)/Build/lufa_cppcheck.mk +include $(LUFA_PATH)/Build/lufa_doxygen.mk +include $(LUFA_PATH)/Build/lufa_hid.mk diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_atprogram.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_atprogram.mk new file mode 100644 index 000000000..4e15e3997 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_atprogram.mk @@ -0,0 +1,101 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += ATPROGRAM +LUFA_BUILD_TARGETS += atprogram atprogram-ee +LUFA_BUILD_MANDATORY_VARS += MCU TARGET +LUFA_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_PORT +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA ATPROGRAM Programmer Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to re-program a device using the Atmel atprogram +# utility in AVR Studio 5.x and Atmel Studio 6.0 onwards. +# ----------------------------------------------------------------------------- +# TARGETS: +# +# atprogram - Program target FLASH with application using +# atprogram +# atprogram-ee - Program target EEPROM with application data +# using atprogram +# +# MANDATORY PARAMETERS: +# +# MCU - Microcontroller device model name +# TARGET - Application name +# +# OPTIONAL PARAMETERS: +# +# ATPROGRAM_PROGRAMMER - Name of programming hardware to use +# ATPROGRAM_INTERFACE - Name of programming interface to use +# ATPROGRAM_PORT - Name of communication port to use +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Default values of optionally user-supplied variables +ATPROGRAM_PROGRAMMER ?= jtagice3 +ATPROGRAM_INTERFACE ?= jtag +ATPROGRAM_PORT ?= + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, MCU) +$(call ERROR_IF_EMPTY, TARGET) +$(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER) +$(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE) + +# Output Messages +MSG_ATPROGRAM_CMD := ' [ATPRGRM] :' + +# Construct base atprogram command flags +BASE_ATPROGRAM_FLAGS := --tool $(ATPROGRAM_PROGRAMMER) --interface $(ATPROGRAM_INTERFACE) --device $(MCU) +ifneq ($(ATPROGRAM_PORT),) + BASE_ATPROGRAM_FLAGS += --port $(ATPROGRAM_PORT) +endif + +# Construct the flags to use for the various memory spaces +ifeq ($(ARCH), AVR8) + ATPROGRAM_FLASH_FLAGS := --chiperase --flash + ATPROGRAM_EEPROM_FLAGS := --eeprom +else ifeq ($(ARCH), XMEGA) + ATPROGRAM_FLASH_FLAGS := --erase --flash + ATPROGRAM_EEPROM_FLAGS := --eeprom +else ifeq ($(ARCH), UC3) + ATPROGRAM_FLASH_FLAGS := --erase + ATPROGRAM_EEPROM_FLAGS := --eeprom +else + $(error Unsupported architecture "$(ARCH)") +endif + +atprogram: $(TARGET).elf $(MAKEFILE_LIST) + @echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" FLASH using \"$(ATPROGRAM_PROGRAMMER)\" + atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_FLASH_FLAGS) --file $< + +atprogram-ee: $(TARGET).elf $(MAKEFILE_LIST) + @echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" EEPROM using \"$(ATPROGRAM_PROGRAMMER)\" + atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_EEPROM_FLAGS) --file $< + +# Phony build targets for this module +.PHONY: atprogram atprogram-ee diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_avrdude.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_avrdude.mk new file mode 100644 index 000000000..839362528 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_avrdude.mk @@ -0,0 +1,84 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += AVRDUDE +LUFA_BUILD_TARGETS += avrdude avrdude-ee +LUFA_BUILD_MANDATORY_VARS += MCU TARGET +LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA AVRDUDE Programmer Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to re-program a device using the open source +# avr-dude utility. +# ----------------------------------------------------------------------------- +# TARGETS: +# +# avrdude - Program target FLASH with application using +# avrdude +# avrdude-ee - Program target EEPROM with application data +# using avrdude +# +# MANDATORY PARAMETERS: +# +# MCU - Microcontroller device model name +# TARGET - Application name +# +# OPTIONAL PARAMETERS: +# +# AVRDUDE_PROGRAMMER - Name of programming hardware to use +# AVRDUDE_PORT - Name of communication port to use +# AVRDUDE_FLAGS - Flags to pass to avr-dude +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Default values of optionally user-supplied variables +AVRDUDE_PROGRAMMER ?= jtagicemkii +AVRDUDE_PORT ?= usb +AVRDUDE_FLAGS ?= + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, MCU) +$(call ERROR_IF_EMPTY, TARGET) +$(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER) +$(call ERROR_IF_EMPTY, AVRDUDE_PORT) + +# Output Messages +MSG_AVRDUDE_CMD := ' [AVRDUDE] :' + +# Construct base avrdude command flags +BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) + +avrdude: $(TARGET).hex $(MAKEFILE_LIST) + @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" + avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS) + +avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST) + @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\" + avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS) + +# Phony build targets for this module +.PHONY: avrdude avrdude-ee diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_build.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_build.mk new file mode 100644 index 000000000..878860627 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_build.mk @@ -0,0 +1,296 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += BUILD +LUFA_BUILD_TARGETS += size check-source symbol-sizes all lib elf hex lss clean mostlyclean +LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH +LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA GCC Compiler Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to build a C, C++ and/or Assembly application +# via the AVR-GCC compiler. +# ----------------------------------------------------------------------------- +# TARGETS: +# +# size - List built application size +# symbol-sizes - Print application symbols from the binary ELF +# file as a list sorted by size in bytes +# check-source - Print a list of SRC source files that cannot +# be found +# all - Build application and list size +# lib - Build and archive source files into a library +# elf - Build application ELF debug object file +# hex - Build application HEX object files +# lss - Build application LSS assembly listing file +# clean - Remove all project intermediatary and binary +# output files +# mostlyclean - Remove intermediatary output files, but +# preserve binaries +# +# MANDATORY PARAMETERS: +# +# TARGET - Application name +# ARCH - Device architecture name +# MCU - Microcontroller device model name +# SRC - List of input source files (*.c, *.cpp, *.S) +# F_USB - Speed of the input clock of the USB controller +# in Hz +# LUFA_PATH - Path to the LUFA library core +# +# OPTIONAL PARAMETERS: +# +# BOARD - LUFA board hardware +# OPTIMIZATION - Optimization level +# C_STANDARD - C Language Standard to use +# CPP_STANDARD - C++ Language Standard to use +# F_CPU - Speed of the CPU, in Hz +# C_FLAGS - Flags to pass to the C compiler only +# CPP_FLAGS - Flags to pass to the C++ compiler only +# ASM_FLAGS - Flags to pass to the assembler only +# CC_FLAGS - Common flags to pass to the C/C++ compiler and +# assembler +# LD_FLAGS - Flags to pass to the linker +# OBJDIR - Directory for the output object and dependency +# files; if equal to ".", the output files will +# be generated in the same folder as the sources +# OBJECT_FILES - Extra object files to link in to the binaries +# DEBUG_FORMAT - Format of the debugging information to +# generate in the compiled object files +# DEBUG_LEVEL - Level the debugging information to generate in +# the compiled object files +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Default values of optionally user-supplied variables +BOARD ?= NONE +OPTIMIZATION ?= s +F_CPU ?= +C_STANDARD ?= gnu99 +CPP_STANDARD ?= gnu++98 +C_FLAGS ?= +CPP_FLAGS ?= +ASM_FLAGS ?= +CC_FLAGS ?= +OBJDIR ?= . +OBJECT_FILES ?= +DEBUG_FORMAT ?= dwarf-2 +DEBUG_LEVEL ?= 3 + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, MCU) +$(call ERROR_IF_EMPTY, TARGET) +$(call ERROR_IF_EMPTY, ARCH) +$(call ERROR_IF_EMPTY, F_USB) +$(call ERROR_IF_EMPTY, LUFA_PATH) +$(call ERROR_IF_EMPTY, BOARD) +$(call ERROR_IF_EMPTY, OPTIMIZATION) +$(call ERROR_IF_EMPTY, C_STANDARD) +$(call ERROR_IF_EMPTY, CPP_STANDARD) +$(call ERROR_IF_EMPTY, OBJDIR) +$(call ERROR_IF_EMPTY, DEBUG_FORMAT) +$(call ERROR_IF_EMPTY, DEBUG_LEVEL) + +# Determine the utility prefix to use for the selected architecture +ifeq ($(ARCH), AVR8) + CROSS := avr +else ifeq ($(ARCH), XMEGA) + CROSS := avr + $(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.) +else ifeq ($(ARCH), UC3) + CROSS := avr32 + $(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.) +else + $(error Unsupported architecture "$(ARCH)") +endif + +# Output Messages +MSG_COMPILE_CMD := ' [GCC] :' +MSG_ASSEMBLE_CMD := ' [GAS] :' +MSG_NM_CMD := ' [NM] :' +MSG_REMOVE_CMD := ' [RM] :' +MSG_LINK_CMD := ' [LNK] :' +MSG_ARCHIVE_CMD := ' [AR] :' +MSG_SIZE_CMD := ' [SIZE] :' +MSG_OBJCPY_CMD := ' [OBJCPY] :' +MSG_OBJDMP_CMD := ' [OBJDMP] :' + +# Convert input source file list to differentiate them by type +C_SOURCE := $(filter %.c, $(SRC)) +CPP_SOURCE := $(filter %.cpp, $(SRC)) +ASM_SOURCE := $(filter %.S, $(SRC)) + +# Create a list of unknown source file types, if any are found throw an error +UNKNOWN_SOURCE := $(filter-out $(C_SOURCE) $(CPP_SOURCE) $(ASM_SOURCE), $(SRC)) +ifneq ($(UNKNOWN_SOURCE),) + $(error Unknown input source file formats: $(UNKNOWN_SOURCE)) +endif + +# Convert input source filenames into a list of required output object files +OBJECT_FILES += $(addsuffix .o, $(basename $(SRC))) +ifneq ($(OBJDIR),.) + $(shell mkdir $(OBJDIR) 2> /dev/null) + VPATH += $(dir $(SRC)) + OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(OBJECT_FILES))) + + # Check if any object file (without path) appears more than once in the object file list + ifneq ($(words $(sort $(OBJECT_FILES))), $(words $(OBJECT_FILES))) + $(error Cannot build with OBJDIR parameter set - one or more object file name is not unique) + endif +endif + +# Create a list of dependency files from the list of object files +DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d) + +# Create a list of common flags to pass to the compiler/linker/assembler +BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL) +ifeq ($(ARCH), AVR8) + BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct +else ifeq ($(ARCH), XMEGA) + BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct +else ifeq ($(ARCH), UC3) + BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos +endif +BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections +BASE_CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/.. +BASE_CC_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL +ifneq ($(F_CPU),) + BASE_CC_FLAGS += -DF_CPU=$(F_CPU)UL +endif + +# Additional language specific compiler flags +BASE_C_FLAGS := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes +BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD) +BASE_ASM_FLAGS := -x assembler-with-cpp + +# Create a list of flags to pass to the linker +BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -Wl,--relax +ifeq ($(ARCH), AVR8) + BASE_LD_FLAGS += -mmcu=$(MCU) +else ifeq ($(ARCH), XMEGA) + BASE_LD_FLAGS += -mmcu=$(MCU) +else ifeq ($(ARCH), UC3) + BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data +endif + +# Determine flags to pass to the size utility based on its reported features (only invoke if size target required) +size: SIZE_MCU_FLAG := $(shell $(CROSS)-size --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +size: SIZE_FORMAT_FLAG := $(shell $(CROSS)-size --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + + +build_begin: + @echo "" + @echo Begin compilation of project \"$(TARGET)\"... + @echo "" + +build_end: + @echo Finished building project \"$(TARGET)\". + @echo "" + +gcc-version: + @$(CROSS)-gcc --version + +check-source: + @for f in $(SRC); do \ + if [ ! -f $$f ]; then \ + echo "Error: Source file not found: $$f"; \ + exit 1; \ + fi; \ + done + +size: $(TARGET).elf + @echo $(MSG_SIZE_CMD) Determining size of \"$<\" + @echo "" + $(CROSS)-size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $< ; 2>/dev/null; + +symbol-sizes: $(TARGET).elf + @echo $(MSG_NM_CMD) Extracting \"$<\" symbols with decimal byte sizes + $(CROSS)-nm --size-sort --demangle --radix=d $< + +mostlyclean: + @echo $(MSG_REMOVE_CMD) Removing object files of \"$(TARGET)\" + rm -f $(OBJECT_FILES) + @echo $(MSG_REMOVE_CMD) Removing dependency files of \"$(TARGET)\" + rm -f $(DEPENDENCY_FILES) + +clean: mostlyclean + @echo $(MSG_REMOVE_CMD) Removing output files of \"$(TARGET)\" + rm -f $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).map $(TARGET).lss $(TARGET).sym $(TARGET).a + +all: build_begin check-source gcc-version elf hex lss sym size build_end + +lib: lib$(TARGET).a +elf: $(TARGET).elf +hex: $(TARGET).hex $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym + +$(OBJDIR)/%.o: %.c $(MAKEFILE_LIST) + @echo $(MSG_COMPILE_CMD) Compiling C file \"$(notdir $<)\" + $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ + +$(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST) + @echo $(MSG_COMPILE_CMD) Compiling C++ file \"$(notdir $<)\" + $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ + +$(OBJDIR)/%.o: %.S $(MAKEFILE_LIST) + @echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\" + $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@ + +.PRECIOUS : $(OBJECT_FILES) +.SECONDARY : %.a +%.a: $(OBJECT_FILES) + @echo $(MSG_ARCHIVE_CMD) Archiving object files into \"$@\" + $(CROSS)-ar rcs $@ $(OBJECT_FILES) + +.PRECIOUS : $(OBJECT_FILES) +.SECONDARY : %.elf +%.elf: $(OBJECT_FILES) + @echo $(MSG_LINK_CMD) Linking object files into \"$@\" + $(CROSS)-gcc $(BASE_LD_FLAGS) $(LD_FLAGS) $^ -o $@ + +%.hex: %.elf + @echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\" + $(CROSS)-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@ + +%.eep: %.elf + @echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$<\" + $(CROSS)-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0 + +%.lss: %.elf + @echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$<\" + $(CROSS)-objdump -h -S -z $< > $@ + +%.sym: %.elf + @echo $(MSG_NM_CMD) Extracting SYM file data from \"$<\" + $(CROSS)-nm -n $< > $@ + +# Include build dependency files +-include $(DEPENDENCY_FILES) + +# Phony build targets for this module +.PHONY: build_begin build_end gcc-version check-source size symbol-sizes lib elf hex lss clean mostlyclean diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_core.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_core.mk new file mode 100644 index 000000000..bde1e11c9 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_core.mk @@ -0,0 +1,152 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += CORE +LUFA_BUILD_TARGETS += help list_targets list_modules list_mandatory list_optional list_provided list_macros +LUFA_BUILD_MANDATORY_VARS += +LUFA_BUILD_OPTIONAL_VARS += +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA Core Build System Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of core build targets for the LUFA build system +# ----------------------------------------------------------------------------- +# TARGETS: +# +# help - Build system help +# list_targets - List all build targets +# list_modules - List all build modules +# list_mandatory - List all mandatory make variables required by +# the included build modules of the application +# list_optional - List all optional make variables required by +# the included build modules of the application +# list_provided - List all provided make variables from the +# included build modules of the application +# list_macros - List all provided make macros from the +# included build modules of the application +# +# MANDATORY PARAMETERS: +# +# (None) +# +# OPTIONAL PARAMETERS: +# +# (None) +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +# Build sorted and filtered lists of the included build module data +SORTED_LUFA_BUILD_MODULES = $(sort $(LUFA_BUILD_MODULES)) +SORTED_LUFA_BUILD_TARGETS = $(sort $(LUFA_BUILD_TARGETS)) +SORTED_LUFA_MANDATORY_VARS = $(sort $(LUFA_BUILD_MANDATORY_VARS)) +SORTED_LUFA_OPTIONAL_VARS = $(filter-out $(SORTED_LUFA_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS))) +SORTED_LUFA_PROVIDED_VARS = $(sort $(LUFA_BUILD_PROVIDED_VARS)) +SORTED_LUFA_PROVIDED_MACROS = $(sort $(LUFA_BUILD_PROVIDED_MACROS)) + +# Create printable versions of the sorted build module data (use "(None)" when no data is available) +PRINTABLE_LUFA_BUILD_MODULES = $(if $(strip $(SORTED_LUFA_BUILD_MODULES)), $(SORTED_LUFA_BUILD_MODULES), (None)) +PRINTABLE_LUFA_BUILD_TARGETS = $(if $(strip $(SORTED_LUFA_BUILD_TARGETS)), $(SORTED_LUFA_BUILD_TARGETS), (None)) +PRINTABLE_LUFA_MANDATORY_VARS = $(if $(strip $(SORTED_LUFA_MANDATORY_VARS)), $(SORTED_LUFA_MANDATORY_VARS), (None)) +PRINTABLE_LUFA_OPTIONAL_VARS = $(if $(strip $(SORTED_LUFA_OPTIONAL_VARS)), $(SORTED_LUFA_OPTIONAL_VARS), (None)) +PRINTABLE_LUFA_PROVIDED_VARS = $(if $(strip $(SORTED_LUFA_PROVIDED_VARS)), $(SORTED_LUFA_PROVIDED_VARS), (None)) +PRINTABLE_LUFA_PROVIDED_MACROS = $(if $(strip $(SORTED_LUFA_PROVIDED_MACROS)), $(SORTED_LUFA_PROVIDED_MACROS), (None)) + +help: + @echo "===================================================================" + @echo " LUFA Build System 2.0 " + @echo " (C) Dean Camera, 2012 { dean @ fourwalledcubicle . com } " + @echo "===================================================================" + @echo "DESCRIPTION: " + @echo " This build system is a set of makefile modules for (GNU) Make, to " + @echo " provide a simple system for building LUFA powered applications. " + @echo " Each makefile module can be included from within a user makefile, " + @echo " to expose the build rules documented in the comments at the top of" + @echo " each build module. " + @echo " " + @echo "USAGE: " + @echo " To execute a rule, define all variables indicated in the desired " + @echo " module as a required parameter before including the build module " + @echo " in your project makefile. Parameters marked as optional will " + @echo " assume a default value in the modules if not user-assigned. " + @echo " " + @echo " By default the target output shows both a friendly summary, as " + @echo " well as the actual invoked command. To suppress the output of the " + @echo " invoked commands and show only the friendly command output, run " + @echo " make with the \"-s\" switch added before the target(s). " + @echo "===================================================================" + @echo " " + @echo " Currently used build system modules in this application: " + @echo " " + @printf " %b" "$(PRINTABLE_LUFA_BUILD_MODULES:%= - %\n)" + @echo " " + @echo " " + @echo " Currently available build targets in this application: " + @echo " " + @printf " %b" "$(PRINTABLE_LUFA_BUILD_TARGETS:%= - %\n)" + @echo " " + @echo " " + @echo " Mandatory variables required by the selected build Modules: " + @echo " " + @printf " %b" "$(PRINTABLE_LUFA_MANDATORY_VARS:%= - %\n)" + @echo " " + @echo " " + @echo " Optional variables required by the selected build Modules: " + @echo " " + @printf " %b" "$(PRINTABLE_LUFA_OPTIONAL_VARS:%= - %\n)" + @echo " " + @echo " " + @echo " Variables provided by the selected build Modules: " + @echo " " + @printf " %b" "$(PRINTABLE_LUFA_PROVIDED_VARS:%= - %\n)" + @echo " " + @echo " " + @echo " Macros provided by the selected build Modules: " + @echo " " + @printf " %b" "$(PRINTABLE_LUFA_PROVIDED_MACROS:%= - %\n)" + @echo " " + @echo "===================================================================" + @echo " The LUFA BuildSystem 2.0 - Powered By Unicorns (tm) " + @echo "===================================================================" + +list_modules: + @echo Currently Used Build System Modules: $(PRINTABLE_LUFA_BUILD_MODULES) + +list_targets: + @echo Currently Available Build Targets: $(PRINTABLE_LUFA_BUILD_TARGETS) + +list_mandatory: + @echo Mandatory Variables for Included Modules: $(PRINTABLE_LUFA_MANDATORY_VARS) + +list_optional: + @echo Optional Variables for Included Modules: $(PRINTABLE_LUFA_OPTIONAL_VARS) + +list_provided: + @echo Variables Provided by the Included Modules: $(PRINTABLE_LUFA_PROVIDED_VARS) + +list_macros: + @echo Macros Provided by the Included Modules: $(PRINTABLE_LUFA_PROVIDED_MACROS) + +# Disable default in-built make rules (those that are needed are explicitly +# defined, and doing so has performance benefits when recursively building) +.SUFFIXES: + +# Phony build targets for this module +.PHONY: help list_modules list_targets list_mandatory list_optional list_provided list_macros diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_cppcheck.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_cppcheck.mk new file mode 100644 index 000000000..1e3604c7d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_cppcheck.mk @@ -0,0 +1,104 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += CPPCHECK +LUFA_BUILD_TARGETS += cppcheck cppcheck-config +LUFA_BUILD_MANDATORY_VARS += SRC +LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_TEMPLATE CPPCHECK_ENABLE \ + CPPCHECK_SUPPRESS CPPCHECK_FAIL_ON_WARNING CPPCHECK_QUIET CPPCHECK_FLAGS +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA CPPCheck Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to scan a project with the free "cppcheck" static +# analysis tool, to check for code errors at runtime (see http://cppcheck.sourceforge.net). +# ----------------------------------------------------------------------------- +# TARGETS: +# +# cppcheck - Scan the project with CPPCheck +# cppcheck-config - Use CPPCheck to look for missing include files +# +# MANDATORY PARAMETERS: +# +# SRC - List of source files to statically analyze +# +# OPTIONAL PARAMETERS: +# +# CPPCHECK_INCLUDES - Extra include paths to search for missing +# header files +# CPPCHECK_EXCLUDES - Source file paths to exclude checking (can be +# a path fragment if desired) +# CPPCHECK_MSG_TEMPLATE - Template for cppcheck error and warning output +# CPPCHECK_ENABLE - General cppcheck category checks to enable +# CPPCHECK_SUPPRESS - Specific cppcheck warnings to disable by ID +# CPPCHECK_FAIL_ON_WARNING - Set to Y to fail the build on cppcheck +# warnings, N to continue even if warnings occur +# CPPCHECK_QUIET - Enable cppcheck verbose or quiet output mode +# CPPCHECK_FLAGS - Additional flags to pass to cppcheck +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Default values of optionally user-supplied variables +CPPCHECK_INCLUDES ?= +CPPCHECK_EXCLUDES ?= +CPPCHECK_MSG_TEMPLATE ?= {file}:{line}: {severity} ({id}): {message} +CPPCHECK_ENABLE ?= all +CPPCHECK_SUPPRESS ?= variableScope missingInclude +CPPCHECK_FAIL_ON_WARNING ?= Y +CPPCHECK_QUIET ?= Y +CPPCHECK_FLAGS ?= + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, SRC) +$(call ERROR_IF_EMPTY, CPPCHECK_MSG_TEMPLATE) +$(call ERROR_IF_EMPTY, CPPCHECK_ENABLE) +$(call ERROR_IF_NONBOOL, CPPCHECK_FAIL_ON_WARNING) +$(call ERROR_IF_NONBOOL, CPPCHECK_QUIET) + +# Build a default argument list for cppcheck +BASE_CPPCHECK_FLAGS := --template="$(CPPCHECK_MSG_TEMPLATE)" $(CPPCHECK_INCLUDES:%=-I%) $(CPPCHECK_EXCLUDES:%=-i%) --inline-suppr --force --std=c99 + +# Sanity check parameters and construct additional command line arguments to cppcheck +ifeq ($(CPPCHECK_FAIL_ON_WARNING), Y) + BASE_CPPCHECK_FLAGS += --error-exitcode=1 +endif +ifeq ($(CPPCHECK_QUIET), Y) + BASE_CPPCHECK_FLAGS += --quiet +endif + +# Output Messages +MSG_CPPCHECK_CMD := ' [CPPCHECK]:' + +cppcheck-config: + @echo $(MSG_CPPCHECK_CMD) Checking cppcheck configuration check on source files + cppcheck $(BASE_CPPCHECK_FLAGS) --check-config $(CPPCHECK_FLAGS) $(SRC) + +cppcheck: + @echo $(MSG_CPPCHECK_CMD) Performing static analysis on source files + cppcheck $(BASE_CPPCHECK_FLAGS) --enable=$(CPPCHECK_ENABLE) $(CPPCHECK_SUPPRESS:%=--suppress=%) $(CPPCHECK_FLAGS) $(SRC) + +# Phony build targets for this module +.PHONY: cppcheck-config cppcheck diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_dfu.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_dfu.mk new file mode 100644 index 000000000..6bfe97942 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_dfu.mk @@ -0,0 +1,93 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += DFU +LUFA_BUILD_TARGETS += flip flip-ee dfu dfu-ee +LUFA_BUILD_MANDATORY_VARS += MCU TARGET +LUFA_BUILD_OPTIONAL_VARS += +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA DFU Bootloader Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to re-program a device currently running a DFU +# class bootloader with a project's FLASH and EEPROM files. +# ----------------------------------------------------------------------------- +# TARGETS: +# +# flip - Program FLASH into target via Atmel FLIP +# flip-ee - Program EEPROM into target via Atmel FLIP +# dfu - Program FLASH into target via dfu-programmer +# dfu-ee - Program EEPROM into target via dfu-programmer +# +# MANDATORY PARAMETERS: +# +# MCU - Microcontroller device model name +# TARGET - Application name +# +# OPTIONAL PARAMETERS: +# +# (None) +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Sanity-check values of mandatory user-supplied variables +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, MCU) +$(call ERROR_IF_EMPTY, TARGET) + +# Output Messages +MSG_COPY_CMD := ' [CP] :' +MSG_REMOVE_CMD := ' [RM] :' +MSG_DFU_CMD := ' [DFU] :' + +flip: $(TARGET).hex $(MAKEFILE_LIST) + @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\" + batchisp -hardware usb -device $(MCU) -operation erase f + batchisp -hardware usb -device $(MCU) -operation loadbuffer $< program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + +flip-ee: $(TARGET).eep $(MAKEFILE_LIST) + @echo $(MSG_DFU_CMD) Copying EEP file to temporary file \"$<.hex\" + cp $< $<.hex + @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\" + batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + @echo $(MSG_DFU_CMD) Removing temporary file \"$<.hex\" + rm $<.hex + +dfu: $(TARGET).hex $(MAKEFILE_LIST) + @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\" + dfu-programmer $(MCU) erase + dfu-programmer $(MCU) flash $< + dfu-programmer $(MCU) reset + +dfu-ee: $(TARGET).eep $(MAKEFILE_LIST) + @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\" + dfu-programmer $(MCU) eeprom-flash $< + dfu-programmer $(MCU) reset + +# Phony build targets for this module +.PHONY: flip flip-ee dfu dfu-ee diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_doxygen.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_doxygen.mk new file mode 100644 index 000000000..87427fd27 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_doxygen.mk @@ -0,0 +1,81 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += DOXYGEN +LUFA_BUILD_TARGETS += doxygen +LUFA_BUILD_MANDATORY_VARS += LUFA_PATH +LUFA_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRIDE_PARAMS +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA Doxygen Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to automatically build Doxygen documentation for +# a project (see www.doxygen.org). +# ----------------------------------------------------------------------------- +# TARGETS: +# +# doxygen - Build Doxygen Documentation +# +# MANDATORY PARAMETERS: +# +# LUFA_PATH - Path to the LUFA library core +# +# OPTIONAL PARAMETERS: +# +# DOXYGEN_CONF - Doxygen configuration filename +# DOXYGEN_FAIL_ON_WARNING - Set to Y to fail the build on Doxygen warnings, +# N to continue even if warnings occur +# DOXYGEN_OVERRIDE_PARAMS - Parameters to override in the doxygen +# configuration file +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Default values of optionally user-supplied variables +DOXYGEN_CONF ?= Doxygen.conf +DOXYGEN_FAIL_ON_WARNING ?= Y +DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, DOXYGEN_CONF) +$(call ERROR_IF_EMPTY, LUFA_PATH) +$(call ERROR_IF_NONBOOL, DOXYGEN_FAIL_ON_WARNING) + +# Output Messages +MSG_DOXYGEN_CMD := ' [DOXYGEN] :' + +# Determine Doxygen invocation command +BASE_DOXYGEN_CMD := ( cat $(DOXYGEN_CONF) $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen - +ifeq ($(DOXYGEN_FAIL_ON_WARNING), Y) + DOXYGEN_CMD := if ( $(BASE_DOXYGEN_CMD) 2>&1 | grep -v "warning: ignoring unsupported tag" ;); then exit 1; fi; +else + DOXYGEN_CMD := $(BASE_DOXYGEN_CMD) +endif + +doxygen: + @echo $(MSG_DOXYGEN_CMD) Configuration file \"$(DOXYGEN_CONF)\" with parameters \"$(DOXYGEN_OVERRIDE_PARAMS)\" + $(DOXYGEN_CMD) + +# Phony build targets for this module +.PHONY: doxygen diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_hid.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_hid.mk new file mode 100644 index 000000000..b8f6f2682 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_hid.mk @@ -0,0 +1,88 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += HID +LUFA_BUILD_TARGETS += hid hid-ee teensy teensy-ee +LUFA_BUILD_MANDATORY_VARS += MCU TARGET +LUFA_BUILD_OPTIONAL_VARS += +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA HID Bootloader Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of targets to re-program a device currently running a HID +# class bootloader with a project's FLASH files. +# ----------------------------------------------------------------------------- +# TARGETS: +# +# hid - Program FLASH into target via +# hid_bootloader_cli +# hid-ee - Program EEPROM into target via a temporary +# AVR application and hid_bootloader_cli +# teensy - Program FLASH into target via +# teensy_loader_cli +# teensy-ee - Program EEPROM into target via a temporary +# AVR application and teensy_loader_cli +# +# MANDATORY PARAMETERS: +# +# MCU - Microcontroller device model name +# TARGET - Application name +# +# OPTIONAL PARAMETERS: +# +# (None) +# +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Sanity-check values of mandatory user-supplied variables +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, MCU) +$(call ERROR_IF_EMPTY, TARGET) + +# Output Messages +MSG_HID_BOOTLOADER_CMD := ' [HID] :' +MSG_OBJCPY_CMD := ' [OBJCPY] :' +MSG_MAKE_CMD := ' [MAKE] :' + +hid: $(TARGET).hex $(MAKEFILE_LIST) + @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\" + hid_bootloader_cli -mmcu=$(MCU) -v $< + +hid-ee: $(TARGET).eep $(MAKEFILE_LIST) + @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\" + avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin + @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\" + make -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid + +teensy: $(TARGET).hex $(MAKEFILE_LIST) + @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\" + teensy_loader_cli -mmcu=$(MCU) -v $< + +teensy-ee: $(TARGET).hex $(MAKEFILE_LIST) + @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\" + avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin + @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\" + make -s -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid-teensy + +# Phony build targets for this module +.PHONY: hid hid-ee teensy teensy-ee diff --git a/protocol/lufa/LUFA-120730/LUFA/Build/lufa_sources.mk b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_sources.mk new file mode 100644 index 000000000..663c93024 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Build/lufa_sources.mk @@ -0,0 +1,116 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# + +LUFA_BUILD_MODULES += SOURCES +LUFA_BUILD_TARGETS += +LUFA_BUILD_MANDATORY_VARS += LUFA_PATH ARCH +LUFA_BUILD_OPTIONAL_VARS += +LUFA_BUILD_PROVIDED_VARS += LUFA_SRC_USB LUFA_SRC_USBCLASS LUFA_SRC_TEMPERATURE LUFA_SRC_SERIAL LUFA_SRC_TWI LUFA_SRC_PLATFORM +LUFA_BUILD_PROVIDED_MACROS += + +# ----------------------------------------------------------------------------- +# LUFA Sources Buildsystem Makefile Module. +# ----------------------------------------------------------------------------- +# DESCRIPTION: +# Provides a set of makefile variables for the various LUFA module sources. +# Once included, the sources required to use a given LUFA module will become +# available using the makefile variable names listed in the LUFA project +# documentation. +# ----------------------------------------------------------------------------- +# TARGETS: +# +# (None) +# +# MANDATORY PARAMETERS: +# +# LUFA_PATH - Path to the LUFA library core +# ARCH - Device architecture name +# +# OPTIONAL PARAMETERS: +# +# (None) +# +# PROVIDED VARIABLES: +# +# LUFA_SRC_USB - List of LUFA USB driver source files +# LUFA_SRC_USBCLASS - List of LUFA USB Class driver source files +# LUFA_SRC_TEMPERATURE - List of LUFA temperature sensor driver source +# files +# LUFA_SRC_SERIAL - List of LUFA Serial U(S)ART driver source files +# LUFA_SRC_TWI - List of LUFA TWI driver source files +# LUFA_SRC_PLATFORM - List of LUFA architecture specific platform +# management source files +# +# PROVIDED MACROS: +# +# (None) +# +# ----------------------------------------------------------------------------- + +SHELL = /bin/sh + +ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, LUFA_PATH) +$(call ERROR_IF_EMPTY, ARCH) + +# Allow LUFA_ROOT_PATH to be overridden elsewhere to support legacy LUFA makefiles +LUFA_ROOT_PATH ?= $(patsubst %/,%,$(LUFA_PATH)) + +# Construct LUFA module source variables +LUFA_SRC_USB := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/EndpointStream_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/PipeStream_$(ARCH).c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptors.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c +LUFA_SRC_USBCLASS := $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/AudioClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorageClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDISClassDevice.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AudioClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDCClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorageClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/PrinterClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDISClassHost.c \ + $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImageClassHost.c +LUFA_SRC_TEMPERATURE := $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c +LUFA_SRC_SERIAL := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c +LUFA_SRC_TWI := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c + +ifeq ($(ARCH), UC3) + LUFA_SRC_PLATFORM := $(LUFA_ROOT_PATH)/Platform/UC3/Exception.S \ + $(LUFA_ROOT_PATH)/Platform/UC3/InterruptManagement.c +else + LUFA_SRC_PLATFORM := +endif + +# Build a list of all available module sources +LUFA_SRC_ALL_FILES := $(LUFA_SRC_USB) \ + $(LUFA_SRC_USBCLASS) \ + $(LUFA_SRC_TEMPERATURE) \ + $(LUFA_SRC_SERIAL) \ + $(LUFA_SRC_TWI) \ + $(LUFA_SRC_PLATFORM) diff --git a/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Buttons.h new file mode 100644 index 000000000..ca4c7a5eb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Buttons.h @@ -0,0 +1,90 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief LUFA Custom Board Button Hardware Driver (Template) + * + * This is a stub driver header file, for implementing custom board + * layout hardware with compatible LUFA board specific drivers. If + * the library is configured to use the BOARD_USER board mode, this + * driver file should be completed and copied into the "/Board/" folder + * inside the application's folder. + * + * This stub is for the board-specific component of the LUFA Buttons driver, + * for the control of physical board-mounted GPIO pushbuttons. + */ + +#ifndef __BUTTONS_USER_H__ +#define __BUTTONS_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_BUTTONS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Button mask for the first button on the board. */ + #define BUTTONS_BUTTON1 // TODO: Add mask for first board button here + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + // TODO: Initialize the appropriate port pins as an inputs here, with pull-ups + } + + static inline void Buttons_Disable(void) + { + // TODO: Clear the appropriate port pins as high impedance inputs here + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + // TODO: Return current button status here, debounced if required + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Dataflash.h new file mode 100644 index 000000000..d397f77ed --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Dataflash.h @@ -0,0 +1,220 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief LUFA Custom Board Dataflash Hardware Driver (Template) + * + * This is a stub driver header file, for implementing custom board + * layout hardware with compatible LUFA board specific drivers. If + * the library is configured to use the BOARD_USER board mode, this + * driver file should be completed and copied into the "/Board/" folder + * inside the application's folder. + * + * This stub is for the board-specific component of the LUFA Dataflash + * driver. +*/ + +#ifndef __DATAFLASH_USER_H__ +#define __DATAFLASH_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_DATAFLASH_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define DATAFLASH_CHIPCS_MASK // TODO: Replace this with a mask of all the /CS pins of all Dataflashes + #define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs + #define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Constant indicating the total number of dataflash ICs mounted on the selected board. */ + #define DATAFLASH_TOTALCHIPS 1 // TODO: Replace with the number of Dataflashes on the board, max 2 + + /** Mask for no dataflash chip selected. */ + #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 // TODO: Replace with mask to hold /CS of first Dataflash low, and all others high + + /** Mask for the second dataflash chip selected. */ + #define DATAFLASH_CHIP2 // TODO: Replace with mask to hold /CS of second Dataflash low, and all others high + + /** Internal main memory page size for the board's dataflash ICs. */ + #define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs + + /** Total number of pages inside each of the board's dataflash ICs. */ + #define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs + + /* Inline Functions: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + // TODO + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + // TODO + } + + /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash. + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_ReceiveByte(void) + { + // TODO + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) + return; + + #if (DATAFLASH_TOTALCHIPS == 2) + if (PageAddress & 0x01) + Dataflash_SelectChip(DATAFLASH_CHIP2); + else + Dataflash_SelectChip(DATAFLASH_CHIP1); + #else + Dataflash_SelectChip(DATAFLASH_CHIP1); + #endif + } + + /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive + * a new command. + */ + static inline void Dataflash_ToggleSelectedChipCS(void) + { + uint8_t SelectedChipMask = Dataflash_GetSelectedChip(); + + Dataflash_DeselectChip(); + Dataflash_SelectChip(SelectedChipMask); + } + + /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main + * memory page program or main memory to buffer transfer. + */ + static inline void Dataflash_WaitWhileBusy(void) + { + Dataflash_ToggleSelectedChipCS(); + Dataflash_SendByte(DF_CMD_GETSTATUS); + while (!(Dataflash_ReceiveByte() & DF_STATUS_READY)); + Dataflash_ToggleSelectedChipCS(); + } + + /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with + * dataflash commands which require a complete 24-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte) + { + #if (DATAFLASH_TOTALCHIPS == 2) + PageAddress >>= 1; + #endif + + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Joystick.h new file mode 100644 index 000000000..31c79d9eb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/Joystick.h @@ -0,0 +1,102 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief LUFA Custom Board Joystick Hardware Driver (Template) + * + * This is a stub driver header file, for implementing custom board + * layout hardware with compatible LUFA board specific drivers. If + * the library is configured to use the BOARD_USER board mode, this + * driver file should be completed and copied into the "/Board/" folder + * inside the application's folder. + * + * This stub is for the board-specific component of the LUFA Joystick + * driver, for a digital four-way (plus button) joystick. +*/ + +#ifndef __JOYSTICK_USER_H__ +#define __JOYSTICK_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_JOYSTICK_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT // TODO: Add mask to indicate joystick left position here + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP // TODO: Add mask to indicate joystick up position here + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN // TODO: Add mask to indicate joystick down position here + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + // TODO: Initialize joystick port pins as inputs with pull-ups + } + + static inline void Joystick_Disable(void) + { + // TODO: Clear the joystick pins as high impedance inputs here + } + + static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Joystick_GetStatus(void) + { + // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/LEDs.h new file mode 100644 index 000000000..d48534632 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/DriverStubs/LEDs.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief LUFA Custom Board LED Hardware Driver (Template) + * + * This is a stub driver header file, for implementing custom board + * layout hardware with compatible LUFA board specific drivers. If + * the library is configured to use the BOARD_USER board mode, this + * driver file should be completed and copied into the "/Board/" folder + * inside the application's folder. + * + * This stub is for the board-specific component of the LUFA LEDs driver, + * for the LEDs (up to four) mounted on most development boards. +*/ + +#ifndef __LEDS_USER_H__ +#define __LEDS_USER_H__ + + /* Includes: */ + // TODO: Add any required includes here + +/* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_LEDS_H) + #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 // TODO: Add mask for first board LED here + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 // TODO: Add mask for second board LED here + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 // TODO: Add mask for third board LED here + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 // TODO: Add mask for fourth board LED here + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + // TODO: Add code to initialize LED port pins as outputs here + } + + static inline void LEDs_Disable(void) + { + // TODO: Clear the LED port pins as high impedance inputs here + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + // TODO: Add code to turn on LEDs given in the LEDMask mask here, leave others as-is + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + // TODO: Add code to turn off LEDs given in the LEDMask mask here, leave others as-is + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + // TODO: Add code to turn on only LEDs given in the LEDMask mask here, all others off + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + // TODO: Add code to set the Leds in the given LEDMask to the status given in ActiveMask here + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + // TODO: Add code to toggle the Leds in the given LEDMask, ignoring all others + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + // TODO: Add code to return the current LEDs status' here which can be masked against LED_LED* macros + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/LUFAConfig.h b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/LUFAConfig.h new file mode 100644 index 000000000..6c98d03a4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/LUFAConfig.h @@ -0,0 +1,167 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief LUFA Library Configuration Header File (Template) + * + * This is a header file which can be used to configure LUFA's + * compile time options, as an alternative to the compile time + * constants supplied through a makefile. To use this configuration + * header, copy this into your project's root directory and supply + * the \c USE_LUFA_CONFIG_HEADER token to the compiler so that it is + * defined in all compiled source files. + * + * For information on what each token does, refer to the LUFA + * manual section "Summary of Compile Tokens". + */ + +#ifndef __LUFA_CONFIG_H__ +#define __LUFA_CONFIG_H__ + + #if (ARCH == ARCH_AVR8) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ +// #define ORDERED_EP_CONFIG +// #define USE_STATIC_OPTIONS {Insert Value Here} +// #define USB_DEVICE_ONLY +// #define USB_HOST_ONLY +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS +// #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL +// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} +// #define FIXED_NUM_CONFIGURATIONS {Insert Value Here} +// #define CONTROL_ONLY_DEVICE +// #define INTERRUPT_CONTROL_ENDPOINT +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + + /* USB Host Mode Driver Related Tokens: */ +// #define HOST_STATE_AS_GPIOR {Insert Value Here} +// #define USB_HOST_TIMEOUT_MS {Insert Value Here} +// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} +// #define NO_AUTO_VBUS_MANAGEMENT +// #define INVERTED_VBUS_ENABLE_LINE + + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ +// #define USE_STATIC_OPTIONS {Insert Value Here} +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS +// #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL +// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} +// #define FIXED_NUM_CONFIGURATIONS {Insert Value Here} +// #define CONTROL_ONLY_DEVICE +// #define MAX_ENDPOINT_INDEX {Insert Value Here} +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + + #elif (ARCH == ARCH_UC3) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ +// #define ORDERED_EP_CONFIG +// #define USE_STATIC_OPTIONS {Insert Value Here} +// #define USB_DEVICE_ONLY +// #define USB_HOST_ONLY +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define NO_INTERNAL_SERIAL +// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here} +// #define FIXED_NUM_CONFIGURATIONS {Insert Value Here} +// #define CONTROL_ONLY_DEVICE +// #define INTERRUPT_CONTROL_ENDPOINT +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + + /* USB Host Mode Driver Related Tokens: */ +// #define USB_HOST_TIMEOUT_MS {Insert Value Here} +// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here} +// #define NO_AUTO_VBUS_MANAGEMENT +// #define INVERTED_VBUS_ENABLE_LINE + + #else + + #error Unsupported architecture for this LUFA configuration file. + + #endif +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/makefile_template b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/makefile_template new file mode 100644 index 000000000..ae6cfd3e2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/CodeTemplates/makefile_template @@ -0,0 +1,36 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# +# -------------------------------------- +# LUFA Project Makefile. +# -------------------------------------- + +MCU = at90usb1287 +ARCH = AVR8 +BOARD = USBKEY +F_CPU = 8000000 +F_USB = $(F_CPU) +OPTIMIZATION = s +TARGET = Target +SRC = $(TARGET).c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) $(LUFA_SRC_PLATFORM) +LUFA_PATH = ../../LUFA +CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig +LD_FLAGS = + +# Default target +all: + +# Include LUFA build script makefiles +include $(LUFA_PATH)/Build/lufa_core.mk +include $(LUFA_PATH)/Build/lufa_sources.mk +include $(LUFA_PATH)/Build/lufa_build.mk +include $(LUFA_PATH)/Build/lufa_cppcheck.mk +include $(LUFA_PATH)/Build/lufa_doxygen.mk +include $(LUFA_PATH)/Build/lufa_dfu.mk +include $(LUFA_PATH)/Build/lufa_hid.mk +include $(LUFA_PATH)/Build/lufa_avrdude.mk +include $(LUFA_PATH)/Build/lufa_atprogram.mk diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/ArchitectureSpecific.h b/protocol/lufa/LUFA-120730/LUFA/Common/ArchitectureSpecific.h new file mode 100644 index 000000000..1e09edf29 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/ArchitectureSpecific.h @@ -0,0 +1,177 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Architecture specific definitions relating to specific processor architectures. + * + * \copydetails Group_ArchitectureSpecific + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_ArchitectureSpecific Architecture Specific Definitions + * \brief Architecture specific definitions relating to specific processor architectures. + * + * Architecture specific macros, functions and other definitions, which relate to specific architectures. This + * definitions may or may not be available in some form on other architectures, and thus should be protected by + * preprocessor checks in portable code to prevent compile errors. + * + * @{ + */ + +#ifndef __LUFA_ARCHSPEC_H__ +#define __LUFA_ARCHSPEC_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA) || defined(__DOXYGEN__) + #if (ARCH == ARCH_AVR8) || defined(__DOXYGEN__) + /** Re-enables the AVR's JTAG bus in software, until a system reset. This will re-enable JTAG debugging + * interface after is has been disabled in software via \ref JTAG_DISABLE(). + * + * \note This macro is not available for all architectures. + */ + #define JTAG_ENABLE() MACROS{ \ + __asm__ __volatile__ ( \ + "in __tmp_reg__,__SREG__" "\n\t" \ + "cli" "\n\t" \ + "out %1, %0" "\n\t" \ + "out __SREG__, __tmp_reg__" "\n\t" \ + "out %1, %0" "\n\t" \ + : \ + : "r" (MCUCR & ~(1 << JTD)), \ + "M" (_SFR_IO_ADDR(MCUCR)) \ + : "r0"); \ + }MACROE + + /** Disables the AVR's JTAG bus in software, until a system reset. This will override the current JTAG + * status as set by the JTAGEN fuse, disabling JTAG debugging and reverting the JTAG pins back to GPIO + * mode. + * + * \note This macro is not available for all architectures. + */ + #define JTAG_DISABLE() MACROS{ \ + __asm__ __volatile__ ( \ + "in __tmp_reg__,__SREG__" "\n\t" \ + "cli" "\n\t" \ + "out %1, %0" "\n\t" \ + "out __SREG__, __tmp_reg__" "\n\t" \ + "out %1, %0" "\n\t" \ + : \ + : "r" (MCUCR | (1 << JTD)), \ + "M" (_SFR_IO_ADDR(MCUCR)) \ + : "r0"); \ + }MACROE + #endif + + /** Defines a volatile \c NOP statement which cannot be optimized out by the compiler, and thus can always + * be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer + * removes/reorders code to the point where break points cannot reliably be set. + * + * \note This macro is not available for all architectures. + */ + #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::) + + /** Defines an explicit JTAG break point in the resulting binary via the assembly \c BREAK statement. When + * a JTAG is used, this causes the program execution to halt when reached until manually resumed. + * + * \note This macro is not available for all architectures. + */ + #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("break" ::) + + /** Macro for testing condition "x" and breaking via \ref JTAG_DEBUG_BREAK() if the condition is false. + * + * \note This macro is not available for all architectures. + * + * \param[in] Condition Condition that will be evaluated. + */ + #define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE + + /** Macro for testing condition \c "x" and writing debug data to the stdout stream if \c false. The stdout stream + * must be pre-initialized before this macro is run and linked to an output device, such as the microcontroller's + * USART peripheral. + * + * The output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion {Condition} failed." + * + * \note This macro is not available for all architectures. + * + * \param[in] Condition Condition that will be evaluated, + */ + #define STDOUT_ASSERT(Condition) MACROS{ if (!(x)) { \ + printf_P(PSTR("%s: Function \"%s\", Line %d: " \ + "Assertion \"%s\" failed.\r\n"), \ + __FILE__, __func__, __LINE__, #Condition); } }MACROE + + #if !defined(pgm_read_ptr) || defined(__DOXYGEN__) + /** Reads a pointer out of PROGMEM space on the AVR8 architecture. This is currently a wrapper for the + * avr-libc \c pgm_read_ptr() macro with a \c void* cast, so that its value can be assigned directly + * to a pointer variable or used in pointer arithmetic without further casting in C. In a future + * avr-libc distribution this will be part of the standard API and will be implemented in a more formal + * manner. + * + * \note This macro is not available for all architectures. + * + * \param[in] Address Address of the pointer to read. + * + * \return Pointer retrieved from PROGMEM space. + */ + #define pgm_read_ptr(Address) (void*)pgm_read_word(Address) + #endif + #elif (ARCH == ARCH_UC3) + #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::) + #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("breakpoint" ::) + #define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE + #define STDOUT_ASSERT(Condition) MACROS{ if (!(x)) { \ + printf("%s: Function \"%s\", Line %d: " \ + "Assertion \"%s\" failed.\r\n"), \ + __FILE__, __func__, __LINE__, #Condition); } }MACROE + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/Architectures.h b/protocol/lufa/LUFA-120730/LUFA/Common/Architectures.h new file mode 100644 index 000000000..8941f7c0c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/Architectures.h @@ -0,0 +1,84 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Supported library architecture defines. + * + * \copydetails Group_Architectures + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_Architectures Hardware Architectures + * \brief Supported library architecture defines. + * + * Architecture macros for selecting the desired target microcontroller architecture. One of these values should be + * defined as the value of \c ARCH in the user project makefile via the \c -D compiler switch to GCC, to select the + * target architecture. + * + * The selected architecture should remain consistent with the makefile \c ARCH value, which is used to select the + * underlying driver source files for each architecture. + * + * @{ + */ + +#ifndef __LUFA_ARCHITECTURES_H__ +#define __LUFA_ARCHITECTURES_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Selects the Atmel 8-bit AVR (AT90USB* and ATMEGA*U* chips) architecture. */ + #define ARCH_AVR8 0 + + /** Selects the Atmel 32-bit UC3 AVR (AT32UC3* chips) architecture. */ + #define ARCH_UC3 1 + + /** Selects the Atmel XMEGA AVR (ATXMEGA*U chips) architecture. */ + #define ARCH_XMEGA 2 + + #if !defined(__DOXYGEN__) + #define ARCH_ ARCH_AVR8 + + #if !defined(ARCH) + #define ARCH ARCH_AVR8 + #endif + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/Attributes.h b/protocol/lufa/LUFA-120730/LUFA/Common/Attributes.h new file mode 100644 index 000000000..fce75d0ed --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/Attributes.h @@ -0,0 +1,150 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Special function/variable attribute macros. + * + * \copydetails Group_FuncVarAttributes + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_FuncVarAttributes Function/Variable Attributes + * \brief Special function/variable attribute macros. + * + * This module contains macros for applying specific attributes to functions and variables to control various + * optimizer and code generation features of the compiler. Attributes may be placed in the function prototype + * or variable declaration in any order, and multiple attributes can be specified for a single item via a space + * separated list. + * + * On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are + * critical to the code's function and thus must throw a compile error when used. + * + * @{ + */ + +#ifndef __LUFA_ATTR_H__ +#define __LUFA_ATTR_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (__GNUC__ >= 3) || defined(__DOXYGEN__) + /** Indicates to the compiler that the function can not ever return, so that any stack restoring or + * return code may be omitted by the compiler in the resulting binary. + */ + #define ATTR_NO_RETURN __attribute__ ((noreturn)) + + /** Indicates that the function returns a value which should not be ignored by the user code. When + * applied, any ignored return value from calling the function will produce a compiler warning. + */ + #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) + + /** Indicates that the specified parameters of the function are pointers which should never be \c NULL. + * When applied as a 1-based comma separated list the compiler will emit a warning if the specified + * parameters are known at compiler time to be \c NULL at the point of calling the function. + */ + #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__))) + + /** Removes any preamble or postamble from the function. When used, the function will not have any + * register or stack saving code. This should be used with caution, and when used the programmer + * is responsible for maintaining stack and register integrity. + */ + #define ATTR_NAKED __attribute__ ((naked)) + + /** Prevents the compiler from considering a specified function for in-lining. When applied, the given + * function will not be in-lined under any circumstances. + */ + #define ATTR_NO_INLINE __attribute__ ((noinline)) + + /** Forces the compiler to inline the specified function. When applied, the given function will be + * in-lined under all circumstances. + */ + #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline)) + + /** Indicates that the specified function is pure, in that it has no side-effects other than global + * or parameter variable access. + */ + #define ATTR_PURE __attribute__ ((pure)) + + /** Indicates that the specified function is constant, in that it has no side effects other than + * parameter access. + */ + #define ATTR_CONST __attribute__ ((const)) + + /** Marks a given function as deprecated, which produces a warning if the function is called. */ + #define ATTR_DEPRECATED __attribute__ ((deprecated)) + + /** Marks a function as a weak reference, which can be overridden by other functions with an + * identical name (in which case the weak reference is discarded at link time). + */ + #define ATTR_WEAK __attribute__ ((weak)) + #endif + + /** Forces the compiler to not automatically zero the given global variable on startup, so that the + * current RAM contents is retained. Under most conditions this value will be random due to the + * behavior of volatile memory once power is removed, but may be used in some specific circumstances, + * like the passing of values back after a system watchdog reset. + */ + #define ATTR_NO_INIT __attribute__ ((section (".noinit"))) + + /** Places the function in one of the initialization sections, which execute before the main function + * of the application. Refer to the avr-libc manual for more information on the initialization sections. + * + * \param[in] SectionIndex Initialization section number where the function should be placed. + */ + #define ATTR_INIT_SECTION(SectionIndex) __attribute__ ((used, naked, section (".init" #SectionIndex ))) + + /** Marks a function as an alias for another function. + * + * \param[in] Func Name of the function which the given function name should alias. + */ + #define ATTR_ALIAS(Func) __attribute__ ((alias( #Func ))) + + /** Marks a variable or struct element for packing into the smallest space available, omitting any + * alignment bytes usually added between fields to optimize field accesses. + */ + #define ATTR_PACKED __attribute__ ((packed)) + + /** Indicates the minimum alignment in bytes for a variable or struct element. + * + * \param[in] Bytes Minimum number of bytes the item should be aligned to. + */ + #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes))) +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/BoardTypes.h b/protocol/lufa/LUFA-120730/LUFA/Common/BoardTypes.h new file mode 100644 index 000000000..4c152dab2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/BoardTypes.h @@ -0,0 +1,231 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Supported pre-made board hardware defines. + * + * \copydetails Group_BoardTypes + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_BoardTypes Board Types + * \brief Supported pre-made board hardware defines. + * + * Board macros for indicating the chosen physical board hardware to the library. These macros should be used when + * defining the \c BOARD token to the chosen hardware via the \c -D switch in the project makefile. If a custom + * board is used, the \ref BOARD_NONE or \ref BOARD_USER values should be selected. + * + * @{ + */ + +#ifndef __LUFA_BOARDTYPES_H__ +#define __LUFA_BOARDTYPES_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Selects the user-defined board drivers, which should be placed in the user project's folder + * under a directory named \c /Board/. Each board driver should be named identically to the LUFA + * master board driver (i.e., driver in the \c LUFA/Drivers/Board directory) so that the library + * can correctly identify it. + */ + #define BOARD_USER 0 + + /** Disables board drivers when operation will not be adversely affected (e.g. LEDs) - use of board drivers + * such as the Joystick driver, where the removal would adversely affect the code's operation is still disallowed. */ + #define BOARD_NONE 1 + + /** Selects the USBKEY specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_USBKEY 2 + + /** Selects the STK525 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_STK525 3 + + /** Selects the STK526 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_STK526 4 + + /** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */ + #define BOARD_RZUSBSTICK 5 + + /** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */ + #define BOARD_ATAVRUSBRF01 6 + + /** Selects the BUMBLEB specific board drivers, using the officially recommended peripheral layout. */ + #define BOARD_BUMBLEB 7 + + /** Selects the XPLAIN (Revision 2 or newer) specific board drivers, including LED and Dataflash drivers. */ + #define BOARD_XPLAIN 8 + + /** Selects the XPLAIN (Revision 1) specific board drivers, including LED and Dataflash drivers. */ + #define BOARD_XPLAIN_REV1 9 + + /** Selects the EVK527 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */ + #define BOARD_EVK527 10 + + /** Selects the Teensy version 1.x specific board drivers, including the driver for the board LEDs. */ + #define BOARD_TEENSY 11 + + /** Selects the USBTINY MKII specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USBTINYMKII 12 + + /** Selects the Benito specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_BENITO 13 + + /** Selects the JM-DB-U2 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_JMDBU2 14 + + /** Selects the Olimex AVR-USB-162 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_OLIMEX162 15 + + /** Selects the UDIP specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_UDIP 16 + + /** Selects the BUI specific board drivers, including the driver for the board LEDs. */ + #define BOARD_BUI 17 + + /** Selects the Arduino Uno specific board drivers, including the driver for the board LEDs. */ + #define BOARD_UNO 18 + + /** Selects the Busware CUL V3 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_CULV3 19 + + /** Selects the Blackcat USB JTAG specific board drivers, including the driver for the board LEDs. */ + #define BOARD_BLACKCAT 20 + + /** Selects the Maximus specific board drivers, including the driver for the board LEDs. */ + #define BOARD_MAXIMUS 21 + + /** Selects the Minimus specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_MINIMUS 22 + + /** Selects the Adafruit U4 specific board drivers, including the Button driver. */ + #define BOARD_ADAFRUITU4 23 + + /** Selects the Microsin AVR-USB162 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_MICROSIN162 24 + + /** Selects the Kernel Concepts USBFOO specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USBFOO 25 + + /** Selects the Sparkfun ATMEGA8U2 specific board drivers, including the driver for the board LEDs. */ + #define BOARD_SPARKFUN8U2 26 + + /** Selects the Atmel EVK1101 specific board drivers, including the Button, Joystick and LED drivers. */ + #define BOARD_EVK1101 27 + + /** Selects the Busware TUL specific board drivers, including the Button and LED drivers. */ + #define BOARD_TUL 28 + + /** Selects the Atmel EVK1100 specific board drivers, including the Button, Joystick and LED drivers. */ + #define BOARD_EVK1100 29 + + /** Selects the Atmel EVK1104 specific board drivers, including the Button and LED drivers. */ + #define BOARD_EVK1104 30 + + /** Selects the Atmel XMEGA A3BU Xplained specific board drivers, including Dataflash, Button and LED drivers. */ + #define BOARD_A3BU_XPLAINED 31 + + /** Selects the Teensy version 2.x specific board drivers, including the driver for the board LEDs. */ + #define BOARD_TEENSY2 32 + + /** Selects the USB2AX version 1 and 2 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USB2AX 33 + + /** Selects the USB2AX version 3 specific board drivers, including the Button and LEDs drivers. */ + #define BOARD_USB2AX_V3 34 + + /** Selects the Micropendous 32U2 specific board drivers, including the Button and LED drivers. */ + #define BOARD_MICROPENDOUS_32U2 35 + + /** Selects the Micropendous A specific board drivers, including the driver for the board Button. */ + #define BOARD_MICROPENDOUS_A 36 + + /** Selects the Micropendous 1 specific board drivers, including the driver for the board Button. */ + #define BOARD_MICROPENDOUS_1 37 + + /** Selects the Micropendous 2 specific board drivers, including the driver for the board Button. */ + #define BOARD_MICROPENDOUS_2 38 + + /** Selects the Micropendous 3 specific board drivers, including the driver for the board Button. */ + #define BOARD_MICROPENDOUS_3 39 + + /** Selects the Micropendous 4 specific board drivers, including the driver for the board Button. */ + #define BOARD_MICROPENDOUS_4 40 + + /** Selects the Micropendous DIP specific board drivers, including the driver for the board Button. */ + #define BOARD_MICROPENDOUS_DIP 41 + + /** Selects the Micropendous (Arduino-like) revision 1 specific board drivers, including the Button and LED drivers. */ + #define BOARD_MICROPENDOUS_REV1 42 + + /** Selects the Micropendous (Arduino-like) revision 2 specific board drivers, including the Button and LED drivers. */ + #define BOARD_MICROPENDOUS_REV2 43 + + /** Selects the XMEGA B1 Xplained specific board drivers, including the Button and LED drivers. */ + #define BOARD_B1_XPLAINED 44 + + /** Selects the Bitwizard Multio specific board drivers, including the driver for the board LEDs. */ + #define BOARD_MULTIO 45 + + /** Selects the Bitwizard Big-Multio specific board drivers, including the driver for the board LEDs. */ + #define BOARD_BIGMULTIO 46 + + /** Selects the DorkbotPDX Duce specific board drivers, including the driver for the board LEDs. */ + #define BOARD_DUCE 47 + + /** Selects the Olimex AVR-USB-32U4 specific board drivers, including the Button and LED drivers. */ + #define BOARD_OLIMEX32U4 48 + + /** Selects the Olimex AVR-USB-T32U4 specific board drivers, including the Button and LED drivers. */ + #define BOARD_OLIMEXT32U4 49 + + /** Selects the Olimex AVR-ISP-MK2 specific board drivers, including the Button and LED drivers. */ + #define BOARD_OLIMEXISPMK2 50 + + + #if !defined(__DOXYGEN__) + #define BOARD_ BOARD_NONE + + #if !defined(BOARD) + #define BOARD BOARD_NONE + #endif + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/Common.h b/protocol/lufa/LUFA-120730/LUFA/Common/Common.h new file mode 100644 index 000000000..cf1f49b9d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/Common.h @@ -0,0 +1,381 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \dir + * \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. + */ + +/** \file + * \brief Common library convenience headers, macros and functions. + * + * \copydetails Group_Common + */ + +/** \defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h + * \brief Common library convenience headers, macros and functions. + * + * Common utility headers containing macros, functions, enums and types which are common to all + * aspects of the library. + * + * @{ + */ + +/** \defgroup Group_GlobalInt Global Interrupt Macros + * \brief Convenience macros for the management of interrupts globally within the device. + * + * Macros and functions to create and control global interrupts within the device. + */ + +#ifndef __LUFA_COMMON_H__ +#define __LUFA_COMMON_H__ + + /* Macros: */ + #define __INCLUDE_FROM_COMMON_H + + /* Includes: */ + #include + #include + #include + #include + + #include "Architectures.h" + #include "BoardTypes.h" + #include "ArchitectureSpecific.h" + #include "CompilerSpecific.h" + #include "Attributes.h" + + #if defined(USE_LUFA_CONFIG_HEADER) + #include "LUFAConfig.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Architecture specific utility includes: */ + #if defined(__DOXYGEN__) + /** Type define for an unsigned integer the same width as the selected architecture's machine register. + * This is distinct from the non-specific standard int data type, whose width is machine dependant but + * which may not reflect the actual machine register width on some targets (e.g. AVR8). + */ + typedef MACHINE_REG_t uint_reg_t; + #elif (ARCH == ARCH_AVR8) + #include + #include + #include + #include + #include + #include + #include + + typedef uint8_t uint_reg_t; + + #define ARCH_HAS_EEPROM_ADDRESS_SPACE + #define ARCH_HAS_FLASH_ADDRESS_SPACE + #define ARCH_HAS_MULTI_ADDRESS_SPACE + #define ARCH_LITTLE_ENDIAN + + #include "Endianness.h" + #elif (ARCH == ARCH_UC3) + #include + #include + + // === TODO: Find abstracted way to handle these === + #define PROGMEM + #define pgm_read_byte(x) *x + #define memcmp_P(...) memcmp(__VA_ARGS__) + #define memcpy_P(...) memcpy(__VA_ARGS__) + // ================================================= + + typedef uint32_t uint_reg_t; + + #define ARCH_BIG_ENDIAN + + #include "Endianness.h" + #elif (ARCH == ARCH_XMEGA) + #include + #include + #include + #include + #include + #include + + typedef uint8_t uint_reg_t; + + #define ARCH_HAS_EEPROM_ADDRESS_SPACE + #define ARCH_HAS_FLASH_ADDRESS_SPACE + #define ARCH_HAS_MULTI_ADDRESS_SPACE + #define ARCH_LITTLE_ENDIAN + + #include "Endianness.h" + #else + #error Unknown device architecture specified. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Macro for encasing other multi-statement macros. This should be used along with an opening brace + * before the start of any multi-statement macro, so that the macros contents as a whole are treated + * as a discrete block and not as a list of separate statements which may cause problems when used as + * a block (such as inline \c if statements). + */ + #define MACROS do + + /** Macro for encasing other multi-statement macros. This should be used along with a preceding closing + * brace at the end of any multi-statement macro, so that the macros contents as a whole are treated + * as a discrete block and not as a list of separate statements which may cause problems when used as + * a block (such as inline \c if statements). + */ + #define MACROE while (0) + + /** Convenience macro to determine the larger of two values. + * + * \attention This macro should only be used with operands that do not have side effects from being evaluated + * multiple times. + * + * \param[in] x First value to compare + * \param[in] y First value to compare + * + * \return The larger of the two input parameters + */ + #if !defined(MAX) || defined(__DOXYGEN__) + #define MAX(x, y) (((x) > (y)) ? (x) : (y)) + #endif + + /** Convenience macro to determine the smaller of two values. + * + * \attention This macro should only be used with operands that do not have side effects from being evaluated + * multiple times. + * + * \param[in] x First value to compare + * \param[in] y First value to compare + * + * \return The smaller of the two input parameters + */ + #if !defined(MIN) || defined(__DOXYGEN__) + #define MIN(x, y) (((x) < (y)) ? (x) : (y)) + #endif + + #if !defined(STRINGIFY) || defined(__DOXYGEN__) + /** Converts the given input into a string, via the C Preprocessor. This macro puts literal quotation + * marks around the input, converting the source into a string literal. + * + * \param[in] x Input to convert into a string literal. + * + * \return String version of the input. + */ + #define STRINGIFY(x) #x + + /** Converts the given input into a string after macro expansion, via the C Preprocessor. This macro puts + * literal quotation marks around the expanded input, converting the source into a string literal. + * + * \param[in] x Input to expand and convert into a string literal. + * + * \return String version of the expanded input. + */ + #define STRINGIFY_EXPANDED(x) STRINGIFY(x) + #endif + + #if !defined(ISR) || defined(__DOXYGEN__) + /** Macro for the definition of interrupt service routines, so that the compiler can insert the required + * prologue and epilogue code to properly manage the interrupt routine without affecting the main thread's + * state with unintentional side-effects. + * + * Interrupt handlers written using this macro may still need to be registered with the microcontroller's + * Interrupt Controller (if present) before they will properly handle incoming interrupt events. + * + * \note This macro is only supplied on some architectures, where the standard library does not include a valid + * definition. If an existing definition exists, the alternative definition here will be ignored. + * + * \ingroup Group_GlobalInt + * + * \param[in] Name Unique name of the interrupt service routine. + */ + #define ISR(Name, ...) void Name (void) __attribute__((__interrupt__)) __VA_ARGS__; void Name (void) + #endif + + /* Inline Functions: */ + /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1, + * etc. + * + * \param[in] Byte Byte of data whose bits are to be reversed. + * + * \return Input data with the individual bits reversed (mirrored). + */ + static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST; + static inline uint8_t BitReverse(uint8_t Byte) + { + Byte = (((Byte & 0xF0) >> 4) | ((Byte & 0x0F) << 4)); + Byte = (((Byte & 0xCC) >> 2) | ((Byte & 0x33) << 2)); + Byte = (((Byte & 0xAA) >> 1) | ((Byte & 0x55) << 1)); + + return Byte; + } + + /** Function to perform a blocking delay for a specified number of milliseconds. The actual delay will be + * at a minimum the specified number of milliseconds, however due to loop overhead and internal calculations + * may be slightly higher. + * + * \param[in] Milliseconds Number of milliseconds to delay + */ + static inline void Delay_MS(uint16_t Milliseconds) ATTR_ALWAYS_INLINE; + static inline void Delay_MS(uint16_t Milliseconds) + { + #if (ARCH == ARCH_AVR8) + if (GCC_IS_COMPILE_CONST(Milliseconds)) + { + _delay_ms(Milliseconds); + } + else + { + while (Milliseconds--) + _delay_ms(1); + } + #elif (ARCH == ARCH_UC3) + while (Milliseconds--) + { + __builtin_mtsr(AVR32_COUNT, 0); + while ((uint32_t)__builtin_mfsr(AVR32_COUNT) < (F_CPU / 1000)); + } + #elif (ARCH == ARCH_XMEGA) + if (GCC_IS_COMPILE_CONST(Milliseconds)) + { + _delay_ms(Milliseconds); + } + else + { + while (Milliseconds--) + _delay_ms(1); + } + #endif + } + + /** Retrieves a mask which contains the current state of the global interrupts for the device. This + * value can be stored before altering the global interrupt enable state, before restoring the + * flag(s) back to their previous values after a critical section using \ref SetGlobalInterruptMask(). + * + * \ingroup Group_GlobalInt + * + * \return Mask containing the current Global Interrupt Enable Mask bit(s). + */ + static inline uint_reg_t GetGlobalInterruptMask(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint_reg_t GetGlobalInterruptMask(void) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + return SREG; + #elif (ARCH == ARCH_UC3) + return __builtin_mfsr(AVR32_SR); + #elif (ARCH == ARCH_XMEGA) + return SREG; + #endif + } + + /** Sets the global interrupt enable state of the microcontroller to the mask passed into the function. + * This can be combined with \ref GetGlobalInterruptMask() to save and restore the Global Interrupt Enable + * Mask bit(s) of the device after a critical section has completed. + * + * \ingroup Group_GlobalInt + * + * \param[in] GlobalIntState Global Interrupt Enable Mask value to use + */ + static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) ATTR_ALWAYS_INLINE; + static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + SREG = GlobalIntState; + #elif (ARCH == ARCH_UC3) + if (GlobalIntState & AVR32_SR_GM) + __builtin_ssrf(AVR32_SR_GM_OFFSET); + else + __builtin_csrf(AVR32_SR_GM_OFFSET); + #elif (ARCH == ARCH_XMEGA) + SREG = GlobalIntState; + #endif + + GCC_MEMORY_BARRIER(); + } + + /** Enables global interrupt handling for the device, allowing interrupts to be handled. + * + * \ingroup Group_GlobalInt + */ + static inline void GlobalInterruptEnable(void) ATTR_ALWAYS_INLINE; + static inline void GlobalInterruptEnable(void) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + sei(); + #elif (ARCH == ARCH_UC3) + __builtin_csrf(AVR32_SR_GM_OFFSET); + #elif (ARCH == ARCH_XMEGA) + sei(); + #endif + + GCC_MEMORY_BARRIER(); + } + + /** Disabled global interrupt handling for the device, preventing interrupts from being handled. + * + * \ingroup Group_GlobalInt + */ + static inline void GlobalInterruptDisable(void) ATTR_ALWAYS_INLINE; + static inline void GlobalInterruptDisable(void) + { + GCC_MEMORY_BARRIER(); + + #if (ARCH == ARCH_AVR8) + cli(); + #elif (ARCH == ARCH_UC3) + __builtin_ssrf(AVR32_SR_GM_OFFSET); + #elif (ARCH == ARCH_XMEGA) + cli(); + #endif + + GCC_MEMORY_BARRIER(); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/CompilerSpecific.h b/protocol/lufa/LUFA-120730/LUFA/Common/CompilerSpecific.h new file mode 100644 index 000000000..22afe940b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/CompilerSpecific.h @@ -0,0 +1,97 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Compiler specific definitions for code optimization and correctness. + * + * \copydetails Group_CompilerSpecific + * + * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's + * functionality. + */ + +/** \ingroup Group_Common + * \defgroup Group_CompilerSpecific Compiler Specific Definitions + * \brief Compiler specific definitions for code optimization and correctness. + * + * Compiler specific definitions to expose certain compiler features which may increase the level of code optimization + * for a specific compiler, or correct certain issues that may be present such as memory barriers for use in conjunction + * with atomic variable access. + * + * Where possible, on alternative compilers, these macros will either have no effect, or default to returning a sane value + * so that they can be used in existing code without the need for extra compiler checks in the user application code. + * + * @{ + */ + +#ifndef __LUFA_COMPILERSPEC_H__ +#define __LUFA_COMPILERSPEC_H__ + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if defined(__GNUC__) || defined(__DOXYGEN__) + /** Forces GCC to use pointer indirection (via the device's pointer register pairs) when accessing the given + * struct pointer. In some cases GCC will emit non-optimal assembly code when accessing a structure through + * a pointer, resulting in a larger binary. When this macro is used on a (non \c const) structure pointer before + * use, it will force GCC to use pointer indirection on the elements rather than direct store and load + * instructions. + * + * \param[in, out] StructPtr Pointer to a structure which is to be forced into indirect access mode. + */ + #define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr)) + + /** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point. + * This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting + * assembly output in an unexpected manner on sections of code that are ordering-specific. + */ + #define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory"); + + /** Determines if the specified value can be determined at compile-time to be a constant value when compiling under GCC. + * + * \param[in] x Value to check compile-time constantness of. + * + * \return Boolean true if the given value is known to be a compile time constant, false otherwise. + */ + #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x) + #else + #define GCC_FORCE_POINTER_ACCESS(StructPtr) + #define GCC_MEMORY_BARRIER() + #define GCC_IS_COMPILE_CONST(x) 0 + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Common/Endianness.h b/protocol/lufa/LUFA-120730/LUFA/Common/Endianness.h new file mode 100644 index 000000000..d0812e4e3 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Common/Endianness.h @@ -0,0 +1,489 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endianness and Byte Ordering macros and functions. + * + * \copydetails Group_Endianness + */ + +/** \ingroup Group_Endianness + * \defgroup Group_ByteSwapping Byte Reordering + * \brief Macros and functions for forced byte reordering. + */ + +/** \ingroup Group_Endianness + * \defgroup Group_EndianConversion Endianness Conversion + * \brief Macros and functions for automatic endianness conversion. + */ + +/** \ingroup Group_Common + * \defgroup Group_Endianness Endianness and Byte Ordering + * \brief Convenience macros and functions relating to byte (re-)ordering + * + * Common library convenience macros and functions relating to byte (re-)ordering. + * + * @{ + */ + +#ifndef __LUFA_ENDIANNESS_H__ +#define __LUFA_ENDIANNESS_H__ + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_COMMON_H) + #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. + #endif + + #if !(defined(ARCH_BIG_ENDIAN) || defined(ARCH_LITTLE_ENDIAN)) + #error ARCH_BIG_ENDIAN or ARCH_LITTLE_ENDIAN not set for the specified architecture. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Swaps the byte ordering of a 16-bit value at compile-time. Do not use this macro for swapping byte orderings + * of dynamic values computed at runtime, use \ref SwapEndian_16() instead. The result of this macro can be used + * inside struct or other variable initializers outside of a function, something that is not possible with the + * inline function variant. + * + * \ingroup Group_ByteSwapping + * + * \param[in] x 16-bit value whose byte ordering is to be swapped. + * + * \return Input value with the byte ordering reversed. + */ + #define SWAPENDIAN_16(x) (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) + + /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings + * of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used + * inside struct or other variable initializers outside of a function, something that is not possible with the + * inline function variant. + * + * \ingroup Group_ByteSwapping + * + * \param[in] x 32-bit value whose byte ordering is to be swapped. + * + * \return Input value with the byte ordering reversed. + */ + #define SWAPENDIAN_32(x) (uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \ + (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL)) + + #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu) + #define le16_to_cpu(x) SwapEndian_16(x) + #define le32_to_cpu(x) SwapEndian_32(x) + #define be16_to_cpu(x) (x) + #define be32_to_cpu(x) (x) + #define cpu_to_le16(x) SwapEndian_16(x) + #define cpu_to_le32(x) SwapEndian_32(x) + #define cpu_to_be16(x) (x) + #define cpu_to_be32(x) (x) + #define LE16_TO_CPU(x) SWAPENDIAN_16(x) + #define LE32_TO_CPU(x) SWAPENDIAN_32(x) + #define BE16_TO_CPU(x) (x) + #define BE32_TO_CPU(x) (x) + #define CPU_TO_LE16(x) SWAPENDIAN_16(x) + #define CPU_TO_LE32(x) SWAPENDIAN_32(x) + #define CPU_TO_BE16(x) (x) + #define CPU_TO_BE32(x) (x) + #elif !defined(le16_to_cpu) + /** \name Run-time endianness conversion */ + //@{ + + /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref LE16_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define le16_to_cpu(x) (x) + + /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref LE32_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define le32_to_cpu(x) (x) + + /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref BE16_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define be16_to_cpu(x) SwapEndian_16(x) + + /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref BE32_TO_CPU instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define be32_to_cpu(x) SwapEndian_32(x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_LE16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_le16(x) (x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_LE32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_le32(x) (x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_BE16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_be16(x) SwapEndian_16(x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for run-time conversion of data - for compile-time endianness + * conversion, use \ref CPU_TO_BE32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define cpu_to_be32(x) SwapEndian_32(x) + + //@} + + /** \name Compile-time endianness conversion */ + //@{ + + /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run time endianness + * conversion, use \ref le16_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define LE16_TO_CPU(x) (x) + + /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run time endianness + * conversion, use \ref le32_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define LE32_TO_CPU(x) (x) + + /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref be16_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define BE16_TO_CPU(x) SWAPENDIAN_16(x) + + /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the + * Endianness of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref be32_to_cpu instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define BE32_TO_CPU(x) SWAPENDIAN_32(x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_le16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_LE16(x) (x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Little Endian format regardless of the currently selected CPU architecture. + * + * On little endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_le32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_LE32(x) (x) + + /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_be16 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_BE16(x) SWAPENDIAN_16(x) + + /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it + * is in Big Endian format regardless of the currently selected CPU architecture. + * + * On big endian architectures, this macro does nothing. + * + * \note This macro is designed for compile-time conversion of data - for run-time endianness + * conversion, use \ref cpu_to_be32 instead. + * + * \ingroup Group_EndianConversion + * + * \param[in] x Data to perform the endianness conversion on. + * + * \return Endian corrected version of the input value. + */ + #define CPU_TO_BE32(x) SWAPENDIAN_32(x) + + //! @} + #endif + + /* Inline Functions: */ + /** Function to reverse the byte ordering of the individual bytes in a 16 bit value. + * + * \ingroup Group_ByteSwapping + * + * \param[in] Word Word of data whose bytes are to be swapped. + * + * \return Input data with the individual bytes reversed. + */ + static inline uint16_t SwapEndian_16(const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST; + static inline uint16_t SwapEndian_16(const uint16_t Word) + { + if (GCC_IS_COMPILE_CONST(Word)) + return SWAPENDIAN_16(Word); + + uint8_t Temp; + + union + { + uint16_t Word; + uint8_t Bytes[2]; + } Data; + + Data.Word = Word; + + Temp = Data.Bytes[0]; + Data.Bytes[0] = Data.Bytes[1]; + Data.Bytes[1] = Temp; + + return Data.Word; + } + + /** Function to reverse the byte ordering of the individual bytes in a 32 bit value. + * + * \ingroup Group_ByteSwapping + * + * \param[in] DWord Double word of data whose bytes are to be swapped. + * + * \return Input data with the individual bytes reversed. + */ + static inline uint32_t SwapEndian_32(const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST; + static inline uint32_t SwapEndian_32(const uint32_t DWord) + { + if (GCC_IS_COMPILE_CONST(DWord)) + return SWAPENDIAN_32(DWord); + + uint8_t Temp; + + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.DWord = DWord; + + Temp = Data.Bytes[0]; + Data.Bytes[0] = Data.Bytes[3]; + Data.Bytes[3] = Temp; + + Temp = Data.Bytes[1]; + Data.Bytes[1] = Data.Bytes[2]; + Data.Bytes[2] = Temp; + + return Data.DWord; + } + + /** Function to reverse the byte ordering of the individual bytes in a n byte value. + * + * \ingroup Group_ByteSwapping + * + * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed. + * \param[in] Length Length of the data in bytes. + * + * \return Input data with the individual bytes reversed. + */ + static inline void SwapEndian_n(void* const Data, + uint8_t Length) ATTR_NON_NULL_PTR_ARG(1); + static inline void SwapEndian_n(void* const Data, + uint8_t Length) + { + uint8_t* CurrDataPos = (uint8_t*)Data; + + while (Length > 1) + { + uint8_t Temp = *CurrDataPos; + *CurrDataPos = *(CurrDataPos + Length - 1); + *(CurrDataPos + Length - 1) = Temp; + + CurrDataPos++; + Length -= 2; + } + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Doxygen.conf b/protocol/lufa/LUFA-120730/LUFA/Doxygen.conf new file mode 100644 index 000000000..89b2a3327 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Doxygen.conf @@ -0,0 +1,1809 @@ +# Doxyfile 1.8.1.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 sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "LUFA Library" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 000000 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = ./DoxygenPages/Images/LUFA_thumb.png + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = ./Documentation/ + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = NO + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = NO + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = YES + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = NO + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = NO + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = NO + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 15 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# 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. To 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 = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ./ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.h \ + *.txt + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# 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. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = Documentation/ \ + License.txt + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = _* \ + __* + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = ./ \ + CodeTemplates/ + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = ./ + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = NO + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = ./DoxygenPages/Style/Footer.htm + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = ./DoxygenPages/Style/Style.css + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 120 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = NO + +# If the HTML_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. + +HTML_DYNAMIC_SECTIONS = YES + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = com.lufa-lib.library.documentation + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = DeanCamera + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = ../LUFA.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = YES + +# 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. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 1 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 300 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. +# However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# 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 style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = __DOXYGEN__ \ + PROGMEM \ + EEMEM \ + ATTR_PACKED + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. 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. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +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 +# 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 the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = NO + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 15 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 2 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildSystem.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildSystem.txt new file mode 100644 index 000000000..c30a88bb4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildSystem.txt @@ -0,0 +1,846 @@ +/** \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_BuildSystem The LUFA Build System + * + * \section Sec_BuildSystemOverview Overview of the LUFA Build System + * The LUFA build system is an attempt at making a set of re-usable, modular build make files which + * can be referenced in a LUFA powered project, to minimise the amount of code required in an + * application makefile. The system is written in GNU Make, and each module is independant of + * one-another. + * + * For details on the prerequisites needed for Linux and Windows machines to be able to use the LUFA + * build system, see \ref Sec_Prerequisites. + * + * To use a LUFA build system module, simply add an include to your project makefile: + * \code + * include $(LUFA_PATH)/Build/lufa_core.mk + * \endcode + * + * And the associated build module targets will be added to your project's build makefile automatically. + * To call a build target, run make {TARGET_NAME} from the command line, substituting in + * the appropriate target name. + * + * \see \ref Sec_AppConfigParams for a copy of the sample LUFA project makefile. + * + * Each build module may have one or more mandatory parameters (GNU Make variables) which must + * be supplied in the project makefile for the module to work, and one or more optional parameters which + * may be defined and which will assume a sensible default if not. + * + * \section SSec_BuildSystemModules Available Modules + * + * The following modules are included in this LUFA release: + * + * \li \subpage Page_BuildModule_ATPROGRAM - Device Programming + * \li \subpage Page_BuildModule_AVRDUDE - Device Programming + * \li \subpage Page_BuildModule_BUILD - Compiling/Assembling/Linking + * \li \subpage Page_BuildModule_CORE - Core Build System Functions + * \li \subpage Page_BuildModule_CPPCHECK - Static Code Analysis + * \li \subpage Page_BuildModule_DFU - Device Programming + * \li \subpage Page_BuildModule_DOXYGEN - Automated Source Code Documentation + * \li \subpage Page_BuildModule_HID - Device Programming + * \li \subpage Page_BuildModule_SOURCES - LUFA Module Source Code Variables + */ + + /** \page Page_BuildModule_BUILD The BUILD build module + * + * The BUILD LUFA build system module, providing targets for the compilation, + * assembling and linking of an application from source code into binary files + * suitable for programming into a target device. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_build.mk + * \endcode + * + * \section SSec_BuildModule_BUILD_Requirements Requirements + * This module requires the the architecture appropriate binaries of the GCC compiler are available in your + * system's PATH variable. The GCC compiler and associated toolchain is distributed in Atmel AVR Studio + * 5.x and Atmel Studio 6.x installation directories, as well as in many third party distribution packages. + * + * \section SSec_BuildModule_BUILD_Targets Targets + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
sizeDisplay size of the compiled application FLASH and SRAM segments.
symbol-sizesDisplay a size-sorted list of symbols from the compiled application, in decimal bytes.
check-sourceDisplay a list of input SRC source files which cannot be found (if any).
libBuild and archive all source files into a library A binary file.
allBuild and link the application into ELF debug and HEX binary files.
elfBuild and link the application into an ELF debug file.
hexBuild and link the application and produce HEX and EEP binary files.
lssBuild and link the application and produce a LSS source code/assembly code mixed listing file.
cleanRemove all intermediatary files and binary output files.
mostlycleanRemove all intermediatary files but preserve any binary output files.
+ * + * \section SSec_BuildModule_BUILD_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
TARGETName of the application output file prefix (e.g. TestApplication).
ARCHArchitecture of the target processor (see \ref Page_DeviceSupport).
MCUName of the Atmel processor model (e.g. at90usb1287).
SRCList of relative or absolute paths to the application C (.c), C++ (.cpp) and Assembly (.S) source files.
F_USBSpeed in Hz of the input clock frequency to the target's USB controller.
LUFA_PATHPath to the LUFA library core, either relative or absolute (e.g. ../LUFA-000000/LUFA/).
+ * + * \section SSec_BuildModule_BUILD_OptionalParams Optional Parameters + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
BOARDLUFA board hardware drivers to use (see \ref Page_DeviceSupport).
OPTIMIZATIONOptimization level to use when compiling source files (see GCC manual).
C_STANDARDVersion of the C standard to apply when compiling C++ source files (see GCC manual).
CPP_STANDARDVersion of the C++ standard to apply when compiling C++ source files (see GCC manual).
DEBUG_FORMATFormat of the debug information to embed in the generated object files (see GCC manual).
DEBUG_LEVELLevel of the debugging information to embed in the generated object files (see GCC manual).
F_CPUSpeed of the processor CPU clock, in Hz.
C_FLAGSFlags to pass to the C compiler only, after the automatically generated flags.
CPP_FLAGSFlags to pass to the C++ compiler only, after the automatically generated flags.
ASM_FLAGSFlags to pass to the assembler only, after the automatically generated flags.
CC_FLAGSCommon flags to pass to the C/C++ compiler and assembler, after the automatically generated flags.
LD_FLAGSFlags to pass to the linker, after the automatically generated flags.
OBJDIRDirectory to place the generated object and dependency files. If set to "." the same folder as the source file will be used. + * \note When this option is enabled, all source filenames must be unique.
OBJECT_FILESList of additional object files that should be linked into the resulting binary.
+ * + * \section SSec_BuildModule_BUILD_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_BUILD_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + +/** \page Page_BuildModule_CORE The CORE build module + * + * The core LUFA build system module, providing common build system help and information targets. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_core.mk + * \endcode + * + * \section SSec_BuildModule_CORE_Requirements Requirements + * This module has no requirements outside a standard *nix shell like environment; the sh + * shell, GNU make and *nix CoreUtils (echo, printf, etc.). + * + * \section SSec_BuildModule_CORE_Targets Targets + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
helpDisplay build system help and configuration information.
list_targetsList all available build targets from the build system.
list_modulesList all available build modules from the build system.
list_mandatoryList all mandatory parameters required by the included modules.
list_optionalList all optional parameters required by the included modules.
list_providedList all variables provided by the included modules.
list_macrosList all macros provided by the included modules.
+ * + * \section SSec_BuildModule_CORE_MandatoryParams Mandatory Parameters + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_CORE_OptionalParams Optional Parameters + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_CORE_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_CORE_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + +/** \page Page_BuildModule_ATPROGRAM The ATPROGRAM build module + * + * The ATPROGRAM programming utility LUFA build system module, providing targets to reprogram an + * Atmel processor FLASH and EEPROM memories with a project's compiled binary output files. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_atprogram.mk + * \endcode + * + * \section SSec_BuildModule_ATPROGRAM_Requirements Requirements + * This module requires the atprogram.exe utility to be available in your system's PATH + * variable. The atprogram.exe utility is distributed in Atmel AVR Studio 5.x and Atmel Studio 6.x + * inside the application install folder's "\avrdbg" subdirectory. + * + * \section SSec_BuildModule_ATPROGRAM_Targets Targets + * + * + * + * + * + * + * + * + * + * + *
atprogramProgram the device FLASH memory with the application's executable data.
atprogram-eeProgram the device EEPROM memory with the application's EEPROM data.
+ * + * \section SSec_BuildModule_ATPROGRAM_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + * + * + * + * + *
MCUName of the Atmel processor model (e.g. at90usb1287).
TARGETName of the application output file prefix (e.g. TestApplication).
+ * + * \section SSec_BuildModule_ATPROGRAM_OptionalParams Optional Parameters + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
ATPROGRAM_PROGRAMMERName of the Atmel programmer or debugger tool to communicate with (e.g. jtagice3).
ATPROGRAM_INTERFACEName of the programming interface to use when programming the target (e.g. spi).
ATPROGRAM_PORTName of the communication port to use when when programming with a serially connected tool (e.g. COM2).
+ * + * \section SSec_BuildModule_ATPROGRAM_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_ATPROGRAM_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + +/** \page Page_BuildModule_AVRDUDE The AVRDUDE build module + * + * The AVRDUDE programming utility LUFA build system module, providing targets to reprogram an + * Atmel processor FLASH and EEPROM memories with a project's compiled binary output files. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_avrdude.mk + * \endcode + * + * \section SSec_BuildModule_AVRDUDE_Requirements Requirements + * This module requires the avrdude utility to be available in your system's PATH + * variable. The avrdude utility is distributed in the old WinAVR project releases for + * Windows (winavr.sourceforge.net) or can be installed on *nix systems via the project's + * source code (https://savannah.nongnu.org/projects/avrdude) or through the package manager. + * + * \section SSec_BuildModule_AVRDUDE_Targets Targets + * + * + * + * + * + * + * + * + * + * + *
avrdudeProgram the device FLASH memory with the application's executable data.
avrdudeProgram the device EEPROM memory with the application's EEPROM data.
+ * + * \section SSec_BuildModule_AVRDUDE_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + * + * + * + * + *
MCUName of the Atmel processor model (e.g. at90usb1287).
TARGETName of the application output file prefix (e.g. TestApplication).
+ * + * \section SSec_BuildModule_AVRDUDE_OptionalParams Optional Parameters + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AVRDUDE_PROGRAMMERName of the programmer or debugger tool to communicate with (e.g. jtagicemkii).
ATPROGRAM_PORTName of the communication port to use when when programming with the connected tool (e.g. COM2, /dev/ttyUSB0 or usb).
ATPROGRAM_FLAGSAdditional flags to pass to avrdude when programming, applied after the automatically generated flags.
+ * + * \section SSec_BuildModule_AVRDUDE_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_AVRDUDE_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + + /** \page Page_BuildModule_CPPCHECK The CPPCHECK build module + * + * The CPPCHECK programming utility LUFA build system module, providing targets to statically + * analyze C and C++ source code for errors and performance/style issues. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_cppcheck.mk + * \endcode + * + * \section SSec_BuildModule_CPPCHECK_Requirements Requirements + * This module requires the cppcheck utility to be available in your system's PATH + * variable. The cppcheck utility is distributed through the project's home page + * (http://cppcheck.sourceforge.net) for Windows, and can be installed on *nix systems via + * the project's source code or through the package manager. + * + * \section SSec_BuildModule_CPPCHECK_Targets Targets + * + * + * + * + * + * + * + * + * + * + *
cppcheckStatically analyze the project source code for issues.
cppcheck-configCheck the cppcheck configuration - scan source code and warn about missing header files and other issues.
+ * + * \section SSec_BuildModule_CPPCHECK_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + *
SRCList of source files to statically analyze.
+ * + * \section SSec_BuildModule_CPPCHECK_OptionalParams Optional Parameters + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
CPPCHECK_INCLUDESPath of extra directories to check when attemting to resolve C/C++ header file includes.
CPPCHECK_EXCLUDESPaths or path fragments to exclude when analyzing.
CPPCHECK_MSG_TEMPLATEOutput message template to use when printing errors, warnings and information (see cppcheck documentation).
CPPCHECK_ENABLEAnalysis rule categories to enable (see cppcheck documentation).
CPPCHECK_SUPPRESSSpecific analysis rules to suppress (see cppcheck documentation).
CPPCHECK_FAIL_ON_WARNINGSet to Y to fail the analysis job with an error exit code if warnings are found, N to continue without failing.
CPPCHECK_QUIETSet to Y to suppress all output except warnings and errors, N to show verbose output information.
CPPCHECK_FLAGSExtra flags to pass to cppcheck, after the automatically generated flags.
+ * + * \section SSec_BuildModule_CPPCHECK_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_CPPCHECK_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + + /** \page Page_BuildModule_DFU The DFU build module + * + * The DFU programming utility LUFA build system module, providing targets to reprogram an + * Atmel processor FLASH and EEPROM memories with a project's compiled binary output files. + * This module requires a DFU class bootloader to be running in the target, compatible with + * the DFU bootloader protocol as published by Atmel. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_dfu.mk + * \endcode + * + * \section SSec_BuildModule_DFU_Requirements Requirements + * This module requires either the batchisp utility from Atmel's FLIP utility, or the open + * source dfu-programmer utility (http://dfu-programmer.sourceforge.net/) to be + * available in your system's PATH variable. On *nix systems the dfu-programmer utility + * can be installed via the project's source code or through the package manager. + * + * \section SSec_BuildModule_DFU_Targets Targets + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
dfuProgram the device FLASH memory with the application's executable data using dfu-programmer.
dfu-eeProgram the device EEPROM memory with the application's EEPROM data using dfu-programmer.
flipProgram the device FLASH memory with the application's executable data using batchisp.
flip-eeProgram the device EEPROM memory with the application's EEPROM data using batchisp.
+ * + * \section SSec_BuildModule_DFU_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + * + * + * + * + *
MCUName of the Atmel processor model (e.g. at90usb1287).
TARGETName of the application output file prefix (e.g. TestApplication).
+ * + * \section SSec_BuildModule_DFU_OptionalParams Optional Parameters + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_DFU_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_DFU_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + + /** \page Page_BuildModule_DOXYGEN The DOXYGEN build module + * + * The DOXYGEN code documentation utility LUFA build system module, providing targets to generate + * project HTML and other format documentation from a set of source files that include special + * Doxygen comments. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_doxygen.mk + * \endcode + * + * \section SSec_BuildModule_DOXYGEN_Requirements Requirements + * This module requires the doxygen utility from the Doxygen website + * (http://www.stack.nl/~dimitri/doxygen/) to be available in your system's PATH + * variable. On *nix systems the doxygen utility can be installed via the project's source + * code or through the package manager. + * + * \section SSec_BuildModule_DOXYGEN_Targets Targets + * + * + * + * + * + * + *
doxygenGenerate project documentation.
+ * + * \section SSec_BuildModule_DOXYGEN_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + *
LUFA_PATHPath to the LUFA library core, either relative or absolute (e.g. ../LUFA-000000/LUFA/).
+ * + * \section SSec_BuildModule_DOXYGEN_OptionalParams Optional Parameters + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
DOXYGEN_CONFName and path of the base Doxygen configuration file for the project.
DOXYGEN_FAIL_ON_WARNINGSet to Y to fail the generation with an error exit code if warnings are found other than unsupported configuration parameters, N to continue without failing.
DOXYGEN_OVERRIDE_PARAMSExtra Doxygen configuration parameters to apply, overriding the corresponding config entry in the project's configuration file (e.g. QUIET=YES).
+ * + * \section SSec_BuildModule_DOXYGEN_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_DOXYGEN_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + + /** \page Page_BuildModule_HID The HID build module + * + * The HID programming utility LUFA build system module, providing targets to reprogram an + * Atmel processor's FLASH memory with a project's compiled binary output file. This module + * requires a HID class bootloader to be running in the target, using a protocol compatible + * with the PJRC "HalfKay" protocol (http://www.pjrc.com/teensy/halfkay_protocol.html). + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_hid.mk + * \endcode + * + * \section SSec_BuildModule_HID_Requirements Requirements + * This module requires either the hid_bootloader_cli utility from the included LUFA HID + * class bootloader API subdirectory, or the teensy_loader_cli utility from PJRC + * (http://www.pjrc.com/teensy/loader_cli.html) to be available in your system's PATH + * variable. + * + * \section SSec_BuildModule_HID_Targets Targets + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
hidProgram the device FLASH memory with the application's executable data using hid_bootloader_cli.
hid-eeProgram the device EEPROM memory with the application's EEPROM data using hid_bootloader_cli and + * a temporary AVR application programmed into the target's FLASH. + * \note This will erase the currently loaded application in the target.
teensyProgram the device FLASH memory with the application's executable data using teensy_loader_cli.
teensy-eeProgram the device EEPROM memory with the application's EEPROM data using teensy_loader_cli and + * a temporary AVR application programmed into the target's FLASH. + * \note This will erase the currently loaded application in the target.
+ * + * \section SSec_BuildModule_HID_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + * + * + * + * + *
MCUName of the Atmel processor model (e.g. at90usb1287).
TARGETName of the application output file prefix (e.g. TestApplication).
+ * + * \section SSec_BuildModule_HID_OptionalParams Optional Parameters + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_HID_ProvidedVariables Module Provided Variables + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_HID_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ + + /** \page Page_BuildModule_SOURCES The SOURCES build module + * + * The SOURCES LUFA build system module, providing variables listing the various LUFA source files + * required to be build by a project for a given LUFA module. This module gives a way to reference + * LUFA source files symbollically, so that changes to the library structure do not break the library + * makefile. + * + * To use this module in your application makefile, add the following code: + * \code + * include $(LUFA_PATH)/Build/lufa_sources.mk + * \endcode + * + * \section SSec_BuildModule_SOURCES_Requirements Requirements + * None. + * + * \section SSec_BuildModule_SOURCES_Targets Targets + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_SOURCES_MandatoryParams Mandatory Parameters + * + * + * + * + * + * + * + * + * + * + *
LUFA_PATHPath to the LUFA library core, either relative or absolute (e.g. ../LUFA-000000/LUFA/).
ARCHArchitecture of the target processor (see \ref Page_DeviceSupport).
+ * + * \section SSec_BuildModule_SOURCES_OptionalParams Optional Parameters + * + * + * + * + * + *
None
+ * + * \section SSec_BuildModule_SOURCES_ProvidedVariables Module Provided Variables + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
LUFA_SRC_USBList of LUFA USB driver source files.
LUFA_SRC_USBCLASSList of LUFA USB Class driver source files.
LUFA_SRC_TEMPERATUREList of LUFA temperature sensor driver source files.
LUFA_SRC_SERIALList of LUFA Serial U(S)ART driver source files.
LUFA_SRC_TWIList of LUFA TWI driver source files.
LUFA_SRC_PLATFORMList of LUFA architecture specific platform management source files.
+ * + * \section SSec_BuildModule_SOURCES_ProvidedMacros Module Provided Macros + * + * + * + * + * + *
None
+ */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildingLinkableLibraries.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/BuildingLinkableLibraries.txt new file mode 100644 index 000000000..ff5fdc523 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ChangeLog.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ChangeLog.txt new file mode 100644 index 000000000..51786b9be --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ChangeLog.txt @@ -0,0 +1,1444 @@ +/** \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_ChangeLog120730 Version 120730 + * New: + * - Core: + * - Added new, revamped modular build system with new makefile templates + * - Added support for the BitWizard Multio and Big-Multio boards + * - Added support for the DorkbotPDX Duce board + * - Added support for the Olimex AVR-USB-32U4 board + * - Added support for the Olimex AVR-USB-T32U4 board + * - Added support for the Olimex AVR-ISP-MK2 board + * - Added new Endpoint_ConfigureEndpointTable() function + * - Added new Pipe_ConfigurePipeTable() function + * - Added build test to verify correct compilation of all board drivers using all driver APIs + * - Added build test to verify correct compilation of all bootloaders using all supported devices + * - Added build test to verify that there are no detectable errors in the codebase via static analysis + * - Added new JTAG_ENABLE() macro for the AVR8 architecture + * - Library Applications: + * - Modified the CDC Host demos to set a default CDC Line Encoding on enumerated devices + * - Added Dataflash operational checks and aborts to all projects using the Dataflash to ensure it is working correctly before use + * - Added new SerialToLCD user project contributed by Simon Foster + * - Added new RESET_TOGGLES_LIBUSB_COMPAT compile time option to the AVRISP-MKII clone programmer project (thanks to Robert Spitzenpfeil) + * + * Changed: + * - Core: + * - Android Accessory Host property strings changed from a struct of pointer to an array to prevent unaligned access on greater than 8-bit architectures + * - Audio Device Class driver changed to also require the index of the Audio Control interface within the device, for SET/GET/CUR/MIN/MAX/RES property adjustments + * - Removed variable axis support from the HID_DESCRIPTOR_JOYSTICK() macro due to OS incompatibilities, replaced with fixed 3-axis joystick report structure + * - Removed the old pseudo-scheduler from the library as it was unused and deprecated since the 090810 release + * - Endpoint indexes are now specified as full endpoint addresses within the device in device mode, rather than a logical index + * - The Endpoint_ConfigureEndpoint() function no longer takes an endpoint direction as a parameter, as this is now deduced from the specified full endpoint + * address and type + * - The Endpoint_ConfigureEndpoint() function no longer takes a number of banks as a special mask; the number of banks is now specified as an integer parameter + * - Endpoints are now configured via instances of a new struct USB_Endpoint_Table_t in all device mode class drivers, rather than a list of endpoint parameters + * - Pipe indexes are now specified as full pipe addresses within the host in host mode, rather than a logical index + * - The Pipe_ConfigurePipe() function no longer takes an pipe token as a parameter, as this is now deduced from the specified full pipe address and type + * - The Pipe_ConfigurePipe() function no longer takes a number of banks as a special mask; the number of banks is now specified as an integer parameter + * - Pipes are now configured via instances of a new struct USB_Pipe_Table_t in all host mode class drivers, rather than a list of pipe parameters + * - Added support for various assert and debugging macros for the UC3 devices + * - Changed MIDI event structure MIDI_EventPacket_t to use a single field for the combined virtual cable index and command ID, to prevent bitfield packing issues + * on some architectures (thanks to Darren Gibbs) + * - Changed board LED driver implementations of LEDs_ToggleLEDs() for the AVR8 architecture to use the fast PIN register toggle alternative function for speed + * - Library Applications: + * - Raised the guard bits in the AVRISP-MKII clone project when in PDI and TPI to 32, to prevent communication errors on low quality connections to a target + * - Added additional bootloader API data to expose the bootloader start address and class to the DFU and CDC class bootloaders + * - Reverted AVRISP-MKII clone project watchdog based command timeout patch in favour of a hardware timer, to allow for use in devices with WDTRST fuse programmed + * - The library bootloaders will now correctly start the user application after a watchdog-based application start, even if the /HWB line is held low externally + * during the reset phase + * - Increased endpoint polling interval for all demos and projects to 5ms, as 1ms was causing some enumeration issues on some machines (thanks to Riku Salminen) + * + * Fixed: + * - Core: + * - Fixed possible enumeration error if the user application selects a pipe other than the default Control pipe between the Powered and Default states of + * the host state machine + * - Fixed incorrect call to the user callback CALLBACK_Audio_Device_GetSetInterfaceProperty() in the Audio Class device driver (thanks to Tiit Ratsep) + * - Fixed compile error for the UC3 architecture when INTERRUPT_CONTROL_ENDPOINT is specified (thanks to Andrus Aaslaid) + * - Fixed compile error if LEDs_Disable() is called and BOARD=NONE is set (thanks to Sam Lin) + * - Fixed inverted LED logic in the OLIMEX162 board LED driver + * - Fixed incorrect reponse to GET STATUS requests in device mode if NO_DEVICE_SELF_POWER or NO_DEVICE_REMOTE_WAKEUP tokens are defined (thanks to Georg Glock) + * - Fixed inverted LED logic in the USB2AX board LED driver + * - Fixed possible deadlock in the CDC device driver if the USB connection is dropped while the CDC_REQ_SetLineEncoding control request is being processed by + * the stack (thanks to Jonathan Hudgins) + * - Fixed broken MIDI host driver MIDI_Host_ReceiveEventPacket() function due to not unfreezing the MIDI data IN pipe before use (thanks to Michael Brown) + * - Fixed swapped Little Endian/Big Endian endpoint and pipe write code for the UC3 devices (thanks to Andrew Chu) + * - Fixed the JTAG_DISABLE() macro clearing all other bits in MCUSR when called + * - Fixed incorrect Micropendous board LED driver LEDs_SetAllLEDs() and LEDs_ChangeLEDs() function implementations (thanks to MitchJS) + * - Fixed endianess issues in the RNDIS host class driver for UC3 devices (thanks to Andrew Chu) + * - Library Applications: + * - Fixed error in the AVRISP-MKII programmer when ISP mode is used at 64KHz (thanks to Ben R. Porter) + * - Fixed AVRISP-MKII programmer project failing to compile for the U4 chips when VTARGET_ADC_CHANNEL is defined to an invalid channel and NO_VTARGET_DETECT is + * defined (thanks to Steven Morehouse) + * - Fixed AVRISP-MKII programmer project reset line polarity inverted when the generated EEP file is loaded into the USB AVR's EEPROM and avr-dude is used + * - Fixed CDC and DFU bootloaders failing to compile when the bootloader section size is 8KB or more (thanks to Georg Glock) + * - Fixed CDC and DFU bootloaders API function offsets incorrect on some devices (thanks to Rod DeMay) + * - Fixed incorrect DFU version number reported to the host in the DFU bootloader descriptors (thanks to Georg Glock) + * - Fixed incorrect version hundredths value encoding in VERSION_BCD() macro (thanks to Georg Glock) + * - Fixed invalid configuration descriptor in the low level KeyboardMouse device demo (thanks to Jun Wako) + * - Fixed CDC and DFU bootloaders API page erase and write function failures (thanks to Martin Lambert) + * + * \section Sec_ChangeLog120219 Version 120219 + * New: + * - Core: + * - Added support for the XMEGA A3BU Xplained board + * - Added support for the new B series XMEGA devices + * - Added support for version 2 of the Teensy boards (thanks to Christoph Redecker) + * - Added support for the USB2AX boards, hardware revision 1-3 + * - Added new Android Accessory Host class driver + * - Added new USB_Host_GetDescriptor(), USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions + * - Added new CALLBACK_Audio_Device_GetSetInterfaceProperty() callback to the Audio Device Class driver + * - Added new LEDs_Disable(), Buttons_Disable() and Joystick_Disable() functions to the board hardware drivers + * - Added support for the Micropendous family of boards (Arduino-like revisions 1 and 2, DIP, 32U2, A, 1, 2, 3 and 4) + * - Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.) + * - Added support for the Atmel XMEGA B1 Xplained board + * - Added Serial USART peripheral driver for the XMEGA architecture + * - Added Master Mode SPI USART peripheral driver for the XMEGA and AVR8 architectures + * - Added build test to verify correct compilation of as many modules as possible under as many architectures as possible under the C and C++ languages + * - Added build test to verify correct compilation of the USB driver when forced into single USB mode under as many architectures as possible + * - Library Applications: + * - Added User Application APIs to the CDC and DFU class bootloaders + * - Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs) + * - Added new Android Accessory Host demo (thanks to Opendous Inc.) + * + * Changed: + * - Core: + * - When automatic PLL management mode is enabled on the U4 series AVR8 chips, the PLL is now configured for 48MHz and not + * a divided 96MHz, to lower power consumption and to keep the system within the datasheet specs for 3.3V operation (thanks to Scott Vitale) + * - Added Class, ClassDevice, ClassHost and ClassCommon to the internal class driver source filenames to prevent ambiguities + * - Altered the Mass Storage Host class driver so that SCSI data STALLs from the attached device can be recovered from automatically without + * having to reset the Mass Storage interface + * - USB_CONFIG_ATTR_BUSPOWERED constant renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed (thanks to NXP Semiconductors) + * - Reordered board name definition indexes so that a mispelled BOARD compile option will default to BOARD_USER rather than BOARD_USBKEY + * - Altered the HID class driver to only try to construct at maximum one packet per USB frame, to reduce CPU usage + * - All USB Class Driver configuration struct values are now non-const, to allow for run-time modifications if required before configuring an instance + * - Library Applications: + * - Altered the Mass Storage Host LowLevel demo so that SCSI data STALLs from the attached device can be recovered from automatically without + * having to reset the Mass Storage interface + * - Updated the AVRISP-MKII Clone programmer project to be compatible with the latest version of AVR Studio (version 5.1) + * - Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent + * warnings in AVR Studio 5.1 when programming XMEGA devices + * - Allow serial strings to be generated on the older AVR8 devices which do not explicitly state they contain unique values in the datasheet, + * as this appears to be implemented in hardware + * + * Fixed: + * - Core: + * - Fixed ring buffer size limited to 255 elements, instead of the intended 65535 elements. + * - Fixed CDC class drivers not saving and sending all 16-bits of the control line states (thanks to Matthew Swabey) + * - Fixed race conditions in the CDC, HID and Mass Storage class drivers when processing some control requests + * - Fixed misspelled HID_KEYBOARD_MODIFIER_* macros in the HID class driver (thanks to Laszlo Monda) + * - Fixed broken AVR32 endpoint/pipe communications when ORDERED_EP_CONFIG compile time option is not enabled (thanks to Matthias Jahr) + * - Fixed broken compilation for the AVR32 devices if the NO_SOF_EVENTS compile time option was not enabled (thanks to Matthias Jahr) + * - Fixed compiler warning on GCC with \c -wundef compile flag is used (thanks to Georg Glock) + * - Fixed incorrect implementation of LEDs_ToggleLEDs() for the Adafruit-U4 board (thanks to Caroline Saliman) + * - Fixed broken compilation of LUFA under C++ compilers when the Serial peripheral module header file is included in a C++ source file + * - Fixed missing semicolon in the UC3 architecture host pipe functions + * - Fixed failed compilation for the XMEGA architecture if USB_DEVICE_ONLY us not specified + * - Fixed UC3 architecture ignoring the pipe size when Pipe_ConfigurePipe() is called + * - Library Applications: + * - Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair) + * - Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled + * - Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming session is exited + * - Fixed DFU class bootloader not resetting the LED pins as high impedance inputs when a software jump to the user applications is requested + * - Fixed AVRISP-MKII Clone timing out on long programming commands such as programming the EEPROM on an ATMEGA8 (thanks to Martin Kelling) + * - Fixed invalid PID value used in the TempDataLogger project host application (thanks to Anupam Pathak) + * + * \section Sec_ChangeLog111009 Version 111009 + * New: + * - Core: + * - Added USE_LUFA_CONFIG_HEADER compile time option to include a LUFAConfig.h header in the user director for LUFA configuration + * tokens as an alternative to tokens defined in the project makefile + * - Added new USB_Host_SetInterfaceAltSetting() convenience function for the selection of an interface's alternative setting + * - Added Audio class control request definitions + * - Added new CALLBACK_Audio_Device_GetSetEndpointProperty() callback to the Audio Device Class driver to allow for endpoint control manipulations + * such as data sample rates + * - Added support for the Audio class GET STATUS request in the Audio Device Class driver so that it is correctly ACKed when sent by the host + * - Added new EVENT_Audio_Device_StreamStartStop() event to the Audio Device Class driver to detect stream start/stop events + * - Added board driver support for the Busware TUL board + * - Added board hardware driver support for the EVK1100 board + * - Added board hardware driver support for the EVK1104 board + * - Added new Host mode Audio Class driver + * - Added new SPI_GetCurrentMode() function to the SPI peripheral driver + * - Added RingBuffer_GetFreeCount() function to the Ring Buffer driver + * - Added new HID_Host_SetIdlePeriod() function to the HID Host Class driver + * - Added new USB_Host_ConfigurationNumber global variable to indicate the selected configuration in an attached device + * - Added new USB_Host_GetDeviceStatus() function to the host standard request function set + * - Added AVR USB XMEGA architecture port (currently incomplete/experimental) + * - Added new STRINGIFY() and STRINGIFY_EXPANDED() convenience macros + * - Added new JTAG_DISABLE() macro for the AVR8 architecture + * - Added Device Qualifier standard descriptor structure definitions USB_StdDescriptor_DeviceQualifier_t and USB_Descriptor_DeviceQualifier_t + * - Library Applications: + * - Added RNDIS device mode to the Webserver project + * - Added new incomplete AndroidAccessoryHost Host LowLevel demo + * - Added new HIDReportViewer project + * - Added new MediaControl project + * - Added new AudioInputHost Host ClassDriver demo + * - Added new AudioOutputHost Host ClassDriver demo + * - Added new AudioInputHost Host LowLevel demo + * - Added new AudioOutputHost Host LowLevel demo + * - Added new "checksource" target to all library project makefiles + * - Added new VTARGET_USE_INTERNAL_REF configuration option to the AVRISP-MKII clone project (thanks to Volker Bosch) + * + * Changed: + * - Core: + * - Altered the definition of the USB_Audio_Descriptor_Format_t descriptor so that the user is now responsible for supplying + * the supported audio sampling rates, to allow for multiple audio interfaces with different numbers of supported rates and/or + * continuous sample rates + * - Pipe_BoundEndpointNumber() has been renamed to Pipe_GetBoundEndpointAddress(), and now returns the correct endpoint direction + * as part of the endpoint address + * - Renamed global state variables that are specific to a certain USB mode to clearly indicate which mode the variable relates to, + * by changing the USB_* prefix to USB_Device_* or USB_Host_* + * - Removed the HOST_STATE_WaitForDeviceRemoval and HOST_STATE_Suspended host state machine states, as these are no longer required + * - Altered the USB_Host_SetDeviceConfiguration() function to update the global Host state machine state and the new + * USB_Host_ConfigurationNumber global as required + * - Added endian correcting code to the library USB class drivers for multiple architecture support + * - Removed the ENDPOINT_DESCRIPTOR_DIR_* macros, replaced by ENDPOINT_DIR_* instead + * - Renamed the JTAG_DEBUG_ASSERT() macro to JTAG_ASSERT() + * - Added variable number of axis to HID_DESCRIPTOR_JOYSTICK() for multi-axis joysticks above just X and Y + * - Renamed USB_Host_ClearPipeStall() to USB_Host_ClearEndpointStall() as the function works on an endpoint address within the attached device, + * and not a Pipe within the host + * - The MS_Host_ResetMSInterface() now performs a full Mass Storage reset sequence to prevent data corruption in the event of a device + * lock up or timeout (thanks to David Lyons) + * - Added endian-correction to the CDC driver's Line Encoding control request handlers. + * - Library Applications: + * - Modified the Low Level and Class Driver AudioInput and AudioOutput demos to support multiple audio sample rates + * - Updated all host mode demos and projects to use the EVENT_USB_Host_DeviceEnumerationComplete() event callback for device configuration + * instead of manual host state machine manipulations in the main application task + * - Changed the reports in the GenericHID device demos to control the board LEDs, to reduce user confusion over the callback routines + * - Added reliability patches to the AVRISP-MKII Clone project's ISP and PDI/TPI protocols (thanks to Justin Mattair) + * + * Fixed: + * - Core: + * - Large number of documentation and code comment corrections (thanks to Andrey from Microsin.ru) + * - Fixed possibility of the AVR's SPI interface being pulled out of master mode if the /SS pin is a input and pulled low (thanks + * to Andrey from Microsin.ru) + * - Fixed compile error when FIXED_CONTROL_ENDPOINT_SIZE compile time option was disabled, and a USE_*_DESCRIPTORS compile time + * option was not enabled on the AVR8s + * - Fixed lack of C++ compatibility in some internal header files causing compile errors when using LUFA in C++ projects + * - Fixed error in the pipe unordered allocation algorithm for the AVR8 devices breaking compatibility with some devices + * - Fixed USB_USBTask not being called internally in stream transfers between packets when Partial Stream Transfers are used + * - Fixed swapped TWI_ADDRESS_READ and TWI_ADDRESS_WRITE values + * - Fixed TWI_ReadPacket() not releasing the TWI bus on read completion + * - Fixed optimization error in the HID Parser item value USB_SetHIDReportItemInfo() and USB_GetHIDReportItemInfo() routines if the report item was + * \c NULL (which should be allowable according to the API) + * - Fixed HID Parser CALLBACK_HIDParser_FilterHIDReportItem() callback function not being passed a cacheable report item pointer + * - Fixed HID Parser's largest report size bit count not including the size of the last parsed report item + * - Fixed HID host driver's largest HID report size count corrupt when the number of report bits exceeds 255 + * - Library Applications: + * - Fixed incorrect signature in the CDC and DFU class bootloaders for the ATMEGA8U2 + * - Fixed KeyboardHost and KeyboardHostWithParser demos displaying incorrect values when numerical keys were pressed + * - Fixed compile errors in the incomplete BluetoothHost demo application (thanks to Timo Lindfors) + * - Fixed incorrect Dataflash buffer use in the DataflashManager_WriteBlocks_RAM() function of several demos/projects (thanks to Jeremy Willden) + * - Fixed incorrect logging interval (always 500ms longer than requested) in the TempDataLogger project + * - Fixed incorrect buffer size check in the USBtoSerial project (thanks to Yuri A Nikiforov) + * - Fixed port state table corruption in the TCP layer of the RNDIS Ethernet device demos + * + * \section Sec_ChangeLog110528 Version 110528 + * New: + * - Core: + * - Added new ORDERED_EP_CONFIG compile time option to restrict endpoint/pipe configuration to ascending order + * in exchange for a smaller compiled program binary size + * - Added a new general RingBuff.h miscellaneous ring buffer library driver header + * - Added new GCC_FORCE_POINTER_ACCESS() macro to correct GCC's mishandling of struct pointer accesses + * - Added new GCC_MEMORY_BARRIER() macro to prevent instruction reordering across boundaries + * - Added basic driver example use code to the library documentation + * - Added new Endpoint_Null_Stream() and Pipe_Null_Stream() functions + * - Added new ADC_GET_CHANNEL_MASK() convenience macro + * - Added new HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors + * - Added new HID_DESCRIPTOR_MOUSE(), HID_DESCRIPTOR_KEYBOARD(), HID_DESCRIPTOR_JOYSTICK() and HID_DESCRIPTOR_VENDOR() macros + * for easy automatic creation of basic USB HID device reports + * - Added new MAX() and MIN() convenience macros + * - Added new Serial_SendData() function to the Serial driver + * - Added board driver support for the Sparkfun ATMEGA8U2 breakout board + * - Added TWI baud rate prescaler and bit length parameters to the TWI_Init() function (thanks to Thomas Herlinghaus) + * - Internal restructuring for eventual multiple architecture ports + * - Added AVR32 UC3 architecture port (currently incomplete/experimental) + * - Added new architecture independent functions to enable, disable, save and restore the Global Interrupt Enable flags + * - Added new RNDIS Device Class Driver packet send and receive functions + * - Library Applications: + * - Added ability to write protect Mass Storage disk write operations from the host OS + * - Added new MIDIToneGenerator project + * - Added new KeyboardMouseMultiReport Device ClassDriver demo + * - Added new VirtualSerialMassStorage Device ClassDriver demo + * - Added HID class bootloader, compatible with a modified version of the command line Teensy loader from PJRC.com + * - Added LED flashing to the CDC and DFU class bootloaders to indicate when they are running + * + * Changed: + * - Core: + * - Unordered Endpoint/Pipe configuration is now allowed once again by default via the previous reconfig workaround + * - Refactored Host mode Class Driver *_Host_ConfigurePipes() routines to be more space efficient when compiled + * - Added new *_ENUMERROR_PipeConfigurationFailed error codes for the *_Host_ConfigurePipes() routines + * - The USARTStream global is now public and documented in the SerialStream module, allowing for the serial USART + * stream to be accessed via its handle rather than via the implicit stdout and stdin streams + * - The FAST_STREAM_TRANSFERS compile time option has been removed due to lack of use and low cost/benefit ratio + * - Altered all endpoint/pipe stream transfers so that the new BytesProcessed parameter now points to a location + * where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction + * should be performed in one chunk) + * - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature + * - Changed over all project and demo HID report descriptors to use the new HID report item macros + * - Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/ + * - Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index + * - Removed the SerialStream driver, rolled functionality into the regular Serial peripheral driver via the new + * Serial_CreateStream() and Serial_CreateBlockingStream() functions + * - Renamed the low level Serial byte send/receive functions, to be consistent with the CDC class driver byte functions + * - Altered the behaviour of the serial byte reception function so that is is non-blocking, and now returns a negative + * value if no character is received (to remain consistent with the CDC class driver byte reception routines) + * - Renamed the PRNT_Host_SendString(), CDC_Host_SendString() and CDC_Device_SendString() functions to *_SendData(), and + * added new versions of the *_SendString() routines that expect a null terminated string instead + * - Renamed all driver termination *_ShutDown() functions to the more logical name *_Disable() + * - Reduced latency for executing the Start-Of-Frame events (if enabled in the user application) + * - Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called + * - Endpoint_ResetFIFO() renamed to Endpoint_ResetEndpoint(), to be consistent with the Pipe_ResetPipe() function name + * - Implemented on-demand PLL clock generation for the U4, U6 and U7 series USB AVRs when automatic PLL mode is specified + * - F_CLOCK changed to F_USB to be more descriptive, and applicable on future architecture ports + * - Renamed all low level Endpoint_Read_*, Endpoint_Write_* and Endpoint_Discard_* functions to use the number of bits instead of + * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures + * - Renamed all low level Pipe_Read_*, Pipe_Write_* and Pipe_Discard_* functions to use the number of bits instead of + * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures + * - Separated out board drivers by architecture in the library internals for better organisation + * - Library Applications: + * - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode + * via the Input Capture register, to reduce user confusion + * - Combined page and word ISP programming mode code in the AVRISP-MKII clone project to reduce compiled size and + * increase maintainability of the code + * - Changed over library projects to use the new general ring buffer library driver module + * - Added new high level TWI packet read/write commands, altered behaviour of the TWI_StartTransmission() function + * - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition + * - Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to reduce CPU usage and free timer 0 + * for other uses + * - Updated the software USART code in the XPLAIN Bridge application so that the incoming bits are sampled at their mid-point + * instead of starting point, to give maximum reliability (thanks to Anton Staaf) + * + * Fixed: + * - Core: + * - Fixed broken USBFOO board drivers due to missing BOARD_USBFOO define + * - Fixed HID host class driver incorrectly binding to HID devices that do not have an OUT endpoint + * - Fixed incorrect definition of the HID_KEYBOARD_SC_D constant in the HID class driver (thanks to Opendous Inc.) + * - Fixed incorrect definition of the HID_KEYBOARD_SC_RIGHT_ARROW constant in the HID class driver (thanks to Joby Taffey) + * - Fixed incorrect endpoint initialisation order in the several device demos (thanks to Rick Drolet) + * - Fixed inverted Minimus board LEDs + * - Fixed incorrect byte ordering in the Audio_Device_WriteSample24 function (thanks to WZab) + * - Fixed several functions in the Host mode Still Image Class driver returning an error code from the incorrect + * error code enum (thanks to Daniel Seibert) + * - Fixed ReportID not being removed from the feature/out report data array in the HID class driver when Report IDs are used + * - Fixed incorrect BUTTONS_BUTTON1 definition for the Minimus board + * - Fixed Still Image Host class driver exiting the descriptor search routine prematurely if the data pipes (but not event pipe) + * is found + * - Fixed missing call to Pipe_SetInfiniteINRequests() in the Pipe_ConfigurePipe() routine + * - Fixed Remote Wakeup broken on the AVRs due to the mechanism only operating when the SUSPI bit is set (thanks to Holger Steinhaus) + * - Fixed possible invalid program execution when in host mode if corrupt descriptor lengths are supplied by the attached device + * - Library Applications: + * - Fixed Benito project discarding incoming data from the USB virtual serial port when the USART is busy + * - Fixed broken DFU bootloader, added XPLAIN support for bootloader start when XCK jumpered to ground + * - Fixed broken HID_REQ_GetReport request handler in the Low Level GenericHID demo + * - Fixed possible lost data in the XPLAINBridge, USBtoSerial and Benito projects when the host exceeds the packet + * timeout period on received packets as set by USB_STREAM_TIMEOUT_MS (thanks to Justin Rajewski) + * - Fixed possible programming problem in the AVRISP-MKII clone project when programming specific patterns into a target + * memory space that is only byte (not page) addressable + * - Fixed errors in the incomplete Test and Measurement device demo preventing proper operation (thanks to Pavel Plotnikov) + * - Fixed programming errors in the AVRISP-MKII project when the programming packet is a round multiple of the endpoint bank + * size under avrdude (thanks to Steffan Woltjer) + * + * + * \section Sec_ChangeLog101122 Version 101122 + * New: + * - Core: + * - Added new SCSI_ASENSE_NOT_READY_TO_READY_CHANGE constant to the Mass Storage class driver, to indicate when a previously + * not ready removable medium has now become ready for the host's use (thanks to Martin Degelsegger) + * - Moved the Pipe and Endpoint stream related code to two new USB library core source files EndpointStream.c and PipeStream.c + * - Added new USB_Device_GetFrameNumber() and USB_Host_GetFrameNumber() functions to retrieve the current USB frame number + * - Added new USB_Host_EnableSOFEvents(), USB_Host_DisableSOFEvents() and EVENT_USB_Host_StartOfFrame() for the user application + * handling of USB Start of Frame events while in USB Host mode + * - Added new PRNT_Host_BytesReceived(), PRNT_Host_ReceiveByte(), PRNT_Host_SendByte() and PRNT_Host_Flush() functions to the + * Print Host Class driver + * - Added class specific descriptor alternative struct type defines with standard USB-IF element naming + * - Added new project makefile template to the library and moved board driver stub files into in a new "CodeTemplates" directory + * - Added board hardware driver support for the Adafruit U4 breakout board + * - Added board hardware driver support for the Arduino Uno development board + * - Added board hardware driver support for the Blackcat USB JTAG board (thanks to the PSGroove team) + * - Added board hardware driver support for the Busware BUI development board + * - Added board hardware driver support for the Busware CUL V3 868MHZ radio board (thanks to Dirk Tostmann) + * - Added board hardware driver support for the Kernel Concepts USBFOO development board + * - Added board hardware driver support for the Linnix UDIP development board + * - Added board hardware driver support for the Olimex AVR-USB-162 development board (thanks to Steve Fawcett) + * - Added board hardware driver support for the Maximus board (thanks to the PSGroove team) + * - Added board hardware driver support for the Microsin AVR-USB162 breakout board + * - Added board hardware driver support for the Minimus board (thanks to the PSGroove team) + * - Added new NO_CLASS_DRIVER_AUTOFLUSH compile time option to disable automatic flushing of interfaces when the USB management + * tasks for each driver is called + * - Added standard keyboard HID report scan-code defines (thanks to Laszlo Monda) + * - Added new Pipe_GetBusyBanks(), Endpoint_GetBusyBanks() and Endpoint_AbortPendingIN() functions + * - Library Applications: + * - Added default test tone generation mode to the Device mode AudioInput demos + * - Added new NO_BLOCK_SUPPORT, NO_EEPROM_BYTE_SUPPORT, NO_FLASH_BYTE_SUPPORT and NO_LOCK_BYTE_WRITE_SUPPORT compile time options to the + * CDC class bootloader + * - Added new XCK_RESCUE_CLOCK_ENABLE compile time option to the AVRISP-MKII clone programmer project (thanks to Tom Light) + * + * Changed: + * - Core: + * - Removed complicated logic for the Endpoint_ConfigureEndpoint() function to use inlined or function called versions + * depending of if the given bank size is a compile time constant, as the compiler does a better job of optimizing + * with basic code + * - Changed the signature of the CALLBACK_USB_GetDescriptor() callback function so that the descriptor pointer is const, to remove + * the need for extra casting inside the callback (thanks to Jonathan Kollasch) + * - Reduced HOST_DEVICE_SETTLE_DELAY_MS to 1000ms down from 1500ms to improve device compatibility while in USB Host mode + * - Removed the EVENT_USB_InitFailure() event, not specifying a USB mode correctly now defaults to UID selection mode + * - Renamed and moved class driver common constant definitions to make the naming scheme more uniform + * - Moved the USB mode specifier constants into a new enum, so that they are semantically related to one another + * - Renamed ENDPOINT_DOUBLEBANK_SUPPORTED() to ENDPOINT_BANKS_SUPPORTED() and changed it to return the maximum number of supported banks for + * the given endpoint + * - Better algorithm to extract and convert the internal device serial number into a string descriptor (if present) + * - All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be separately included + * - The MIDI class drivers now automatically flushes the MIDI interface when the MIDI class driver's USBTask() function is called + * - Renamed the EVENT_USB_Device_UnhandledControlRequest() event to EVENT_USB_Device_ControlRequest() as it is now fired before the library + * request handlers, not afterwards + * - Library Applications: + * - Changed over all device demos to use a clearer algorithm for the configuring of the application's endpoints + * - Added missing DataflashManager_CheckDataflashOperation() function to the MassStorageKeyboard demo, removed redundant + * SCSI_Codes.h file as these values are part of the MassStorage Class Driver + * - Added compile time error to the AVRISP-MKII project when built for the U4 chips, as the default VTARGET detection ADC channel + * does not exist on these chips (thanks to Marco) + * - Changed all Device mode LowLevel demos and Device Class drivers so that the control request is acknowledged and any data + * transferred as quickly as possible without any processing in between sections, so that long callbacks or event handlers will + * not break communications with the host by exceeding the maximum control request stage timeout period + * - Changed over all demos, drivers and internal functions to use the current frame number over the Start of Frame flag where possible + * to free up the Start of Frame flag for interrupt use in the user application + * - All project makefiles now correctly clean intermediate build files from assembly and C++ sources (thanks to Daniel Czigany) + * - Changed default value for the reset polarity parameter in the AVRISP-MKII project so that it defaults to active low drive + * - Changed configuration descriptor parser for all host mode projects and class drivers to ensure better compatibility with devices + * - All LowLevel demos changed to use the constants and types defined in the USB class drivers + * - Changed AudioInput and AudioOutput demos to reload the next sample via an interrupt rather than polling the sample timer + * - Rescue clock of the AVRISP-MKII moved to the AVR's OCR1A pin, so that the clock can be generated at all times + * - Changed ClassDriver MIDI demos to process all incoming events in a loop until the bank becomes empty rather than one at a time + * - Changed LowLevel MIDI demos to only clear the incoming event bank once it has become empty to support packed event packets + * + * Fixed: + * - Core: + * - Fixed USB_GetHIDReportItemInfo() function modifying the given report item's data when the report item does not exist + * within the supplied report of a multiple report HID device + * - Fixed critical pipe/endpoint memory allocation issue where the bank memory address space could be silently overlapped + * in the USB controller if the endpoints or pipes were allocated in anything other than ascending order (thanks to Martin Degelsegger) + * - Added LEDs_ToggleLEDs() function to several board LED drivers which were missing it (thanks to Andrei Krainev) + * - Fixed SET FEATURE and CLEAR FEATURE control requests directed at an unconfigured endpoint causing request timeouts + * - Fixed USB_Host_ClearPipeStall() incorrectly determining the endpoint direction from the currently selected pipe + * - Fixed JTAG_DEBUG_POINT() and JTAG_DEBUG_BREAK() macros not compiling under pure C99 standards mode + * - Fixed endpoint selection within the CALLBACK_HID_Device_CreateHIDReport() callback function causing broken GET REPORT requests + * - Fixed incorrect command name for EEPROM memory programming in the makefile dfu-ee target + * - Fixed incorrect LEDs_ChangeLEDs() function in the Benito board LED driver + * - Fixed incorrect USB_DeviceState value when unconfiguring the device without an address set + * - Fixed SPI driver not explicitly setting /SS and MISO pins as inputs when SPI_Init() is called + * - Fixed random enumeration failure while in device mode due to interrupts causing the Set Address request to exceed maximum timings + * - Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface was not configured + * - Fixed MIDI class driver send routines silently discarding packets if the endpoint or pipe is busy (thanks to Robin Green) + * - Library Applications: + * - Fixed MassStorage based demos and projects resetting the SCSI sense values before the command is executed, leading to + * missed SCSI sense values when the host retrieves the sense key (thanks to Martin Degelsegger) + * - Fixed USBtoSerial and Benito project SetLineEncoding calls failing if the USART is busy, due to the RX ISR delaying the control + * request handler + * - Fixed LowLevel PrinterHost demo not sending control requests to the attached printer with the correct printer interface wIndex value + * - Fixed incorrect signature reported in the CDC class bootloader for the ATMEGA32U2 + * - Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev) + * - Fixed broken FLASH/EEPROM programming in the AVRISP-MKII clone project when writing in non-paged mode and the polling byte cannot be used + * - Fixed ISR definition conflict in the XPLAIN bridge between the software UART and the AVRISP-MKII ISP modules + * - Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the send buffer becomes full + * - Fixed broken input in the MagStripe reader project due to an incorrect HID report descriptor + * - Fixed incorrect PollingIntervalMS values in the demo/project/bootloader endpoint descriptors (thanks to MCS Electronics) + * - Fixed AVRISP-MKII clone project not starting the target's program automatically after exiting TPI programming mode + * + * + * \section Sec_ChangeLog100807 Version 100807 + * New: + * - Added new ADC_DisableChannel() function (thanks to Mich Davis) + * - Added new VTARGET_REF_VOLTS and VTARGET_SCALE_FACTOR compile time defines to the AVRISP-MKII programmer project to set + * the VTARGET reference voltage and scale factor + * - Added new pgm_read_ptr() macro to Common.h for reading of pointers out of flash memory space + * - Added new SWAPENDIAN_16() and SWAPENDIAN_32() macros to Common.h for statically initialized variables at compile time + * - Added new Drivers/USB/LowLevel/Device.c file to house Device mode specific functions that are more complicated than simple macros + * - Added new AVRStudio 4 project files for all library demos, projects and bootloaders + * - Added ability to set the serial baud rate via the user's terminal in the XPLAINBridge project + * - Added new LUFA module variables for the different source modules in the core library makefile to simplify project makefiles + * - Added start of a new Test and Measurement class demo (thanks to Peter Lawrence) + * - Added new SPI_ORDER_* data order masks to the SPI peripheral driver + * - Added support to the AVRISP-MKII project for ISP speeds slower than 125KHz via a new software SPI driver + * - Added support for the new button/LED on the latest model USBTINY-MKII + * + * Changed: + * - The RingBuff library code has been replaced in the XPLAINBridge, Benito and USBtoSerial projects with an ultra lightweight + * ring buffer to help improve the reliability of the projects + * - The EEPROM stream read/write functions now use eeprom_update_byte() instead of eeprom_write_byte(), so that only + * changed bytes are written to EEPROM to preserve its lifespan + * - Changed over the AVRISP-MKII and TemperatureDataLogger projects to use eeprom_update_byte() when writing non-volatile + * parameters to EEPROM to preserve its lifespan + * - Removed unused line encoding data and control requests from the CDC Bootloader code, to save space + * - Renamed SERIAL_STREAM_ASSERT() macro to STDOUT_ASSERT() + * - The USB_Device_IsRemoteWakeupSent() and USB_Device_IsUSBSuspended() macros have been deleted, as they are now obsolete + * - Rewrote the implementation of the SwapEndian_16() and SwapEndian_32() functions so that they compile down in most instances to + * minimal loads and stores rather than complicated shifts + * - The software UART in the XPLAINBridge has been largely altered to try to improve upon its performance and reliability + * - The USBtoSerial and Benito projects now flushes received data via a flush timer, so that several bytes can be transmitted at once + * - Removed the automated checking of event names in the demo, project and bootloader makefiles due to inconsistencies between the + * behaviour of the command line tools used to perform the check on each platform + * - Internal USB driver source files renamed and moved to ease future possible architecture ports + * - All internal pseudo-function macros have been converted to true inline functions for type-safety and readability + * - Changed LED indicator masks for the AVRISP-MKII project, so that there are defined roles for each LED + * - Altered the CDC Device and Host Class drivers' receive byte routines, so that no data is indicated by the function returning a + * negative value (thanks to Andreas Paulin) + * - Added auto flushing of OUT data to the CDC Host Class driver's USBTask function to automatically flush the send pipe buffer + * + * Fixed: + * - Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs after programming or reading from + * the last page of FLASH (thanks to Gerard Sexton) + * - Fixed AVRISP project not sending a full erase-and-write EEPROM command to XMEGA targets when writing to the EEPROM + * instead of the split write-only command (thanks to Tim Margush) + * - Fixed RNDISEthernet demos crashing when calculating checksums for Ethernet/TCP packets of more than ~500 bytes due to + * an overflow in the checksum calculation loop (thanks to Kevin Malec) + * - Fixed XPLAINBridge project not correctly reading the XMEGA's supply voltage when reporting back to the host + * - Fixed incorrect signature for the ATMEGA32U2 in the DFU bootloader (thanks to Axel Rohde) + * - Fixed internal device serial not being accessible on the ATMEGAXXU2 AVRs (thanks to Axel Rohde) + * - Fixed void pointer arithmetic in ConfigDescriptor.h breaking C++ compatibility (thanks to Michael Hennebry) + * - Fixed broken PDI EEPROM Section Erase functionality in the AVRISP-MKII project + * - Fixed USB_Device_SendRemoteWakeup() not working when the USB clock was frozen during USB bus suspend (thanks to Brian Dickman) + * - Fixed occasional lockup of the AVRISP project due to the timeout extension code incorrectly extending the timeout in + * PDI and TPI programming modes infinitely + * - Fixed HID device class driver still using PrevReportINBuffer for GetReport control requests even when it has been + * set to NULL by the user application (thanks to Axel Rohde) + * - Fixed MIDI_Device_SendEventPacket() not correctly waiting for the endpoint to become ready (thanks to Robin Green) + * - Fixed Benito and USBtoSerial projects not turning off the USART before reconfiguring it, which could cause incorrect + * operation to occur (thanks to Bob Paddock) + * - Fixed Serial peripheral driver not turning off the USART before reconfiguring it, which would cause incorrect operation + * to occur (thanks to Bob Paddock) + * - Fixed software application start command broken in the DFU class bootloader when dfu-programmer is used due to application + * start address corruption + * + * + * \section Sec_ChangeLog100513 Version 100513 + * New: + * - Added incomplete MIDIToneGenerator project + * - Added new Relay Controller Board project (thanks to OBinou) + * - Added board hardware driver support for the Teensy, USBTINY MKII, Benito and JM-DB-U2 lines of third party USB AVR boards + * - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup + * - Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus + * is suspended before or during a transfer + * - Added new EVENT_CDC_Device_BreakSent() event and CDC_Host_SendBreak() function to the Device and Host CDC Class drivers + * - Added ReportType parameter to the HID device class driver CALLBACK_HID_Device_ProcessHIDReport() function so that FEATURE + * reports from the host to the device can be correctly processed + * - Added ReportType parameter to the HID host class driver HID_Host_SendReportByID() function so that FEATURE reports can be + * issued to the attached device + * + * Changed: + * - AVRISP programmer project now has a more robust timeout system + * - Added a timeout value to the TWI_StartTransmission() function, within which the addressed device must respond + * - Webserver project now uses the board LEDs to indicate the current IP configuration state + * - Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable the TELNET server if desired + * - Increased throughput of the USBtoSerial demo on systems that send multiple bytes per packet (thanks to Opendous Inc.) + * - Double bank CDC endpoints in the XPLAIN Bridge project, re-enable JTAG once the mode selection pin has been sampled. + * - Standardized the naming scheme given to configuration descriptor sub-elements in the Device mode demos, bootloaders + * and projects + * - All Class Driver Host mode demos now correctly set the board LEDs to READY once the enumeration process has completed + * - Added LIBUSB_FILTERDRV_COMPAT compile time option to the AVRISP programmer project to make the code compatible with Windows + * builds of avrdude at the expense of AVRStudio compatibility + * - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code + * - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready + * for them to be enabled (thanks to Andrei Krainev) + * - The Audio_Device_IsSampleReceived() and Audio_Device_IsReadyForNextSample() functions are now inline, to reduce overhead + * - Removed the cast to uint16_t on the set baud rate in the USBtoSerial project, so that the higher >1M baud rates can be + * selected (thanks to Steffan Woltjer) + * - Removed software PDI and TPI emulation from the AVRISP-MKII clone project as it was very buggy and slow - PDI and TPI must + * now be implemented via separate programming headers + * - The CDC class bootloader now uses a watchdog reset rather than a soft-reset when exited to ensure that all hardware is + * properly reset to their defaults + * - Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from + * timing out if another request is immediately fired and the device has a lengthy callback routine + * - The TeensyHID bootloader has been removed, per request from Paul at PJRC + * - The LIBUSB_FILTERDRV_COMPAT compile time option in the XPLAINBridge and AVRISP-MKII projects has been renamed + * LIBUSB_DRIVER_COMPAT, as it applies to all software on all platforms using the libUSB driver + * + * Fixed: + * - Fixed possible device lockup when INTERRUPT_CONTROL_ENDPOINT is enabled and the control endpoint is not properly + * selected when the ISR completes + * - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address + * boundary is crossed during programming or read back (thanks to Gerard Sexton) + * - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled + * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin + * - Fixed TWI_StartTransmission() corrupting the contents of the GPIOR0 register + * - Fixed TWI driver not aborting when faced with no response after attempting to address a device on the bus + * - Fixed ADC routines not correctly returning the last result when multiple channels were read + * - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the + * U4 series USB AVR parts + * - Fixed LowLevel MassStorage demo broken on the U2 series USB AVRs due to unsupported double-banked endpoint modes used + * - Fixed compilation error in the AudioInput demos when MICROPHONE_BIASED_TO_HALF_RAIL is defined (thanks to C. Scott Ananian) + * - Fixed incorrect definition of HID_ALIGN_DATA() causing incorrect HID report item data alignment + * - Fixed Still Image Host class driver not resetting the transaction ID when a new session is opened, fixed driver not sending + * a valid session ID to the device + * - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer + * - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host + * - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the + * user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski) + * - Fixed device state not being reset to DEVICE_STATE_Default if the host sets a 0x00 device address + * - Fixed device not stalling configuration requests before the device's address has been set + * - Fixed possibility of internal signature retrieval being corrupted if an interrupt occurs during a signature byte + * read (thanks to Andrei Krainev) + * - Fixed device state not being reset back to the default state if the host sets the address to 0 + * - Fixed Set Configuration requests not being stalled until the host has set the device's address + * - Fixed Host mode HID class driver not sending the correct report type when HID_Host_SendReportByID() was called and the + * HID_HOST_BOOT_PROTOCOL_ONLY compile time option is set + * - Fixed INTERRUPT_CONTROL_ENDPOINT compile time option preventing other interrupts from occurring while the control endpoint + * request is being processed, causing possible lockups if a USB interrupt occurs during a transfer + * - Remove incorrect Abstract Call Management class specific descriptor from the CDC demos, bootloaders and projects + * + * + * \section Sec_ChangeLog100219 Version 100219 + * + * New: + * - Added TPI programming support for 6-pin ATTINY devices to the AVRISP programmer project (thanks to Tom Light) + * - Added command timeout counter to the AVRISP project so that the device no longer freezes when incorrectly connected + * to a target + * - Added new TemperatureDataLogger application, a USB data logger which writes to the device's dataflash and appears to + * the host as a standard Mass Storage device when inserted + * - Added MIDI event packing support to the MIDI Device and Host mode Class drivers, allowing for multiple MIDI events to + * sent or received in packed form in a single USB packet + * - Added new MIDI send buffer flush routines to the MIDI Device and Host mode Class drivers, to flush packed events + * - Added master mode hardware TWI driver for easy TWI peripheral control + * - Added ADC MUX masks for the standard ADC input channels on all AVR models with an ADC, altered demos to use these masks + * as on some models, the channel number is not identical to its single-ended ADC MUX mask + * - New Webserver project, a RNDIS host USB webserver using the open source uIP TCP/IP network stack and FatFS library + * - New BOARD value option BOARD_NONE (equivalent to not specifying BOARD) which will remove all board hardware drivers which + * do not adversely affect the code operation (currently only the LEDs driver) + * - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) and LED report masks (KEYBOARD_LED_*) to the HID class driver and + * Keyboard demos + * - Added .5MHz recovery clock to the AVRISP programmer project when in ISP programming mode to correct mis-set fuses + * + * Changed: + * - Slowed down software USART carried PDI programming in the AVRISP project to prevent transmission errors + * - Renamed the AVRISP project folder to AVRISP-MKII to reduce confusion + * - Renamed the RESET_LINE_* makefile tokens in the AVRISP MKII Project to AUX_LINE_*, as they are not always used for target + * reset + * - Changed over the MassStorageKeyboard Class driver device demo to use Start of Frame events rather than a timer to keep track + * of elapsed milliseconds + * - Inlined currently unused (but standardized) maintenance functions in the Device and Host Class drivers to save space + * - The XPLAINBridge project now selects between a USB to Serial bridge and a PDI programmer on startup, reading the JTAG port's + * TDI pin to determine which mode to use + * - Removed the stream example code from the Low Level VirtualSerial demos, as they were buggy and only served to add clutter + * + * Fixed: + * - Fixed AVRISP project not able to enter programming mode when ISP protocol is used + * - Fixed AVRISP PDI race condition where the guard time between direction changes could be interpreted as a start bit + * - Fixed ADC_IsReadingComplete() returning an inverted result + * - Fixed blocking CDC streams not aborting when the host is disconnected + * - Fixed XPLAIN board Dataflash driver broken due to incorrect preprocessor commands + * - Fixed inverted XPLAIN LED driver output (LED turned on when it was supposed to be turned off, and vice-versa) + * - Fixed Class Driver struct interface numbers in the KeyboardMouse and VirtualSerialMouse demos (thanks to Renaud Cerrato) + * - Fixed invalid USB controller PLL prescaler values for the ATMEGAxxU2 controllers + * - Fixed lack of support for the ATMEGA32U2 in the DFU and CDC class bootloaders + * - Fixed Benito project not resetting the target AVR automatically when programming has completed + * - Fixed DFU bootloader programming not discarding the correct number of filler bytes from the host when non-aligned programming + * ranges are specified (thanks to Thomas Bleeker) + * - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two separate pipes, not one half-duplex pipe + * - Fixed Pipe_IsEndpointBound() not taking the endpoint's direction into account + * - Fixed EEPROM and FLASH ISP programming in the AVRISP project + * - Fixed incorrect values of USB_CONFIG_ATTR_SELFPOWERED and USB_CONFIG_ATTR_REMOTEWAKEUP tokens (thanks to Claus Christensen) + * - Fixed SerialStream driver blocking while waiting for characters to be received instead of returning EOF + * - Fixed SerialStream driver not setting stdin to the created serial stream (thanks to Mike Alexander) + * - Fixed USB_GetHIDReportSize() returning the number of bits in the specified report instead of bytes + * - Fixed AVRISP project not extending the command delay after each successful page/word/byte program + * - Fixed accuracy of the SERIAL_UBBRVAL() and SERIAL_2X_UBBRVAL() macros for higher baud rates (thanks to Renaud Cerrato) + * + * + * \section Sec_ChangeLog091223 Version 091223 + * + * New: + * - Added activity LED indicators to the AVRISP project to indicate when the device is busy processing a command + * - The USB target family and allowable USB mode tokens are now public and documented (USB_CAN_BE_*, USB_SERIES_*_AVR) + * - Added new XPLAIN USB to Serial Bridge project (thanks to John Steggall for initial proof-of-concept, David Prentice + * and Peter Danneger for revised software USART code) + * - Added new RNDIS Ethernet Host LowLevel demo + * - Added new RNDIS Ethernet Host Class Driver + * - Added new RNDIS Ethernet Host ClassDriver demo + * - Added CDC_Host_Flush() function to the CDC Host Class driver to flush sent data to the attached device + * - Added PDI programming support for XMEGA devices to the AVRISP programmer project (thanks to Justin Mattair) + * - Added support for the XPLAIN board Dataflash, with new XPLAIN_REV1 board target for the different dataflash used + * on the first revision boards compared to the one mounted on later revisions + * - Added new HID_ALIGN_DATA() macro to return the pre-retrieved value of a HID report item, left-aligned to a given datatype + * - Added new PreviousValue to the HID Report Parser report item structure, for easy monitoring of previous report item values + * - Added new EVK527 board target + * - Added new USB_Host_GetDeviceStringDescriptor() convenience function + * - Added new LEDNotification project to the library, to give a visual LED notification on new events from the host + * - Added new NO_DEVICE_REMOTE_WAKEUP and NO_DEVICE_SELF_POWER compile time options + * + * Changed: + * - Removed code in the Keyboard demos to send zeroed reports between two reports with differing numbers of key codes + * as this relied on non-standard OS driver behaviour to repeat key groups + * - The SCSI_Request_Sense_Response_t and SCSI_Inquiry_Response_t type defines are now part of the Mass Storage Class + * driver common defines, rather than being defined in the Host mode Class driver section only + * - The USB_MODE_HOST token is now defined even when host mode is not available + * - The CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new ReportType parameter to + * indicate the report type to generate + * - All Class Drivers now return false or the "DeviceDisconnected" error code of their respective error enums when a function + * is called when no host/device is connected where possible + * - The HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to HOST_SENDCONTROL_DeviceDisconnected to be in line + * with the rest of the library error codes + * - Make MIDI device demos also turn off the on board LEDs if MIDI Note On messages are sent with a velocity of zero, + * which some devices use instead of Note Off messages (thanks to Robin Green) + * - The CDC demos are now named "VirtualSerial" instead to indicate the demos' function rather than its implemented USB class, + * to reduce confusion and to be in line with the rest of the LUFA demos + * - The SImage_Host_SendBlockHeader() and SImage_Host_ReceiveBlockHeader() Still Image Host Class driver functions are now public + * + * Fixed: + * - Added missing CDC_Host_CreateBlockingStream() function code to the CDC Host Class driver + * - Fixed incorrect values for REPORT_ITEM_TYPE_* enum values causing corrupt data in the HID Host Parser + * - Fixed misnamed SI_Host_USBTask() and SI_Host_ConfigurePipes() functions + * - Fixed broken USB_GetNextDescriptor() function causing the descriptor to jump ahead double the expected amount + * - Fixed Pipe_IsEndpointBound() not masking the given Endpoint Address against PIPE_EPNUM_MASK + * - Fixed host state machine not enabling Auto VBUS mode when HOST_DEVICE_SETTLE_DELAY_MS is set to zero + * - Fixed misnamed Pipe_SetPipeToken() macro for setting a pipe's direction + * - Fixed CDCHost failing on devices with bidirectional endpoints + * - Fixed USB driver failing to define the PLL prescaler mask for the ATMEGA8U2 and ATMEGA16U2 + * - Fixed HID Parser not distributing the Usage Min and Usage Max values across an array of report items + * - Fixed Mass Storage Host Class driver and Low Level demo not clearing the error condition if an attached device returns a + * STALL to a GET MAX LUN request (thanks to Martin Luxen) + * - Fixed TeensyHID bootloader not properly shutting down the USB interface to trigger a disconnection on the host before resetting + * - Fixed MassStorageHost Class driver demo not having USB_STREAM_TIMEOUT_MS compile time option set properly to prevent slow + * devices from timing out the data pipes + * - Fixed the definition of the Endpoint_BytesInEndpoint() macro for the U4 series AVR parts + * - Fixed MIDI host Class driver MIDI_Host_SendEventPacket() routine not properly checking for Pipe ready before writing + * - Fixed use of deprecated struct initializers, removed library unused parameter warnings when compiled with -Wextra enabled + * - Fixed Still Image Host Class driver truncating the PIMA response code (thanks to Daniel Seibert) + * - Fixed USB_CurrentMode not being reset to USB_MODE_NONE when the USB interface is shut down and both Host and Device modes can be + * used (thanks to Daniel Levy) + * - Fixed TeensyHID bootloader not enumerating to the host correctly (thanks to Clint Fisher) + * - Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott) + * - Fixed STK525 Dataflash driver using incorrect bit-shifting for Dataflash addresses (thanks to Tim Mitchell) + * + * + * \section Sec_ChangeLog091122 Version 091122 + * + * New: + * - Added new Dual Role Keyboard/Mouse demo + * - Added new HID_HOST_BOOT_PROTOCOL_ONLY compile time token to reduce the size of the HID Host Class driver when + * Report protocol is not needed + * - Added new MIDI LowLevel and ClassDriver Host demo, add new MIDI Host Class driver + * - Added new CDC/Mouse ClassDriver device demo + * - Added new Joystick Host ClassDriver and LowLevel demos + * - Added new Printer Host mode Class driver + * - Added new Printer Host mode ClassDriver demo + * - Added optional support for double banked endpoints and pipes in the Device and Host mode Class drivers + * - Added new stream creation function to the CDC Class drivers, to easily make standard I/O streams from CDC Class driver instances + * + * Changed: + * - Removed mostly useless "TestApp" demo, as it was mainly useful only for checking for syntax errors in the library + * - MIDI device demos now receive MIDI events from the host and display note ON messages via the board LEDs + * - Cleanups to the Device mode Mass Storage demo application SCSI routines + * - Changed Audio Class driver sample read/write functions to be inline, to reduce the number of cycles needed to transfer + * samples to and from the device (allowing more time for sample processing and output) + * - Audio class Device mode demos now work at both 16MHz and 8MHz, rather than just at 8MHz + * - The previous USBtoSerial demo has been moved into the projects directory, as it was just a modified CDC demo + * - The Endpoint/Pipe functions now use the const qualifier on the input buffer + * - Changed the CALLBACK_HIDParser_FilterHIDReportItem() callback to pass a HID_ReportItem_t rather than just the current + * item's attributes, to expose more information on the item (including it's type, collection path, etc.) + * - Changed MouseHostWithParser demos to check that the report items have a Mouse usage collection as a parent at some point, + * to prevent Joysticks from enumerating with the demo + * - Corrected the name of the misnamed USB_GetDeviceConfigDescriptor() function to USB_Host_GetDeviceConfigDescriptor(). + * - Keyboard LowLevel/ClassDriver demos now support multiple simultaneous key presses (up to 6) per report + * + * Fixed: + * - Fixed PrinterHost demo returning invalid Device ID data when the attached device does not have a + * device ID (thanks to Andrei Krainev) + * - Changed LUFA_VERSION_INTEGER define to use BCD values, to make comparisons easier + * - Fixed issue in the HID Host class driver's HID_Host_SendReportByID() routine using the incorrect mode (control/pipe) + * to send report to the attached device + * - Fixed ClassDriver AudioOutput device demo not selecting an audio output mode + * - Fixed incorrect SampleFrequencyType value in the AudioInput and AudioOutput ClassDriver demos' descriptors + * - Fixed incorrect event name rule in demo/project/bootloader makefiles + * - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called + * - Corrected HID descriptor in the Joystick Device demos - buttons should be placed outside the pointer collection + * - Fixed HID report parser collection paths invalid due to misplaced semicolon in the free path item search loop + * - Fixed HID host Class driver report send/receive report broken when issued through the control pipe + * - Fixed HOST_STATE_AS_GPIOR compile time option being ignored when in host mode (thanks to David Lyons) + * - Fixed LowLevel Keyboard demo not saving the issues report only after it has been sent to the host + * - Fixed Endpoint_Write_Control_Stream_* functions not sending a terminating IN when given data Length is zero + * + * + * \section Sec_ChangeLog090924 Version 090924 + * + * New: + * - Added new host mode class drivers and matching demos to the library for rapid application development + * - Added flag to the HID report parser to indicate if a device has multiple reports + * - Added new EVENT_USB_Device_StartOfFrame() event, controlled by the new USB_Device_EnableSOFEvents() and + * USB_Device_DisableSOFEvents() macros to give bus-synchronized millisecond interrupts when in USB device mode + * - Added new Endpoint_SetEndpointDirection() macro for bidirectional endpoints + * - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer + * - Added ShutDown() functions for all hardware peripheral drivers, so that peripherals can be turned off after use + * - Added new CDC_Device_Flush() command to the device mode CDC Class driver to flush Device->Host data + * - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set + * - Added new callback to the HID report parser, so that the user application can filter only the items it is interested + * in to be stored into the HIDReportInfo structure to save RAM + * - Added support for the officially recommended external peripheral layout for the BUMBLEB board (thanks to Dave Fletcher) + * - Added new Pipe_IsFrozen() macro to determine if the currently selected pipe is frozen + * - Added new USB_GetHIDReportSize() function to the HID report parser to retrieve the size of a given report by its ID + * - Added new combined Mass Storage and Keyboard demo (thanks to Matthias Hullin) + * + * Changed: + * - SetIdle requests to the HID device driver with a 0 idle period (send changes only) now only affect the requested + * HID interface within the device, not all HID interfaces + * - Added explicit attribute masks to the device mode demos' descriptors + * - Added return values to the CDC and MIDI class driver transmit functions + * - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size + * - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability + * - Added new "Common" section to the class drivers, to hold all mode-independent definitions for clarity + * - Moved SCSI command/sense constants into the Mass Storage Class driver, instead of the user-code + * - Altered the SCSI commands in the LowLevel Mass Storage Host to save on FLASH space by reducing function calls + * - Changed the parameters and behaviour of the USB_GetDeviceConfigDescriptor() function so that it now performs size checks + * and data validations internally, to simplify user code + * - Changed HIDParser to only zero out important values in the Parsed HID Report Item Information structure to save cycles + * - The HID report parser now always processed FEATURE items - HID_ENABLE_FEATURE_PROCESSING token now has no effect + * - The HID report parser now always ignores constant-data items, HID_INCLUDE_CONSTANT_DATA_ITEMS token now has no effect + * - The Benito Programmer project now has its own unique VID/PID pair allocated from the Atmel donated LUFA VID/PID pool + * - Add in new invalid event hook check targets to project makefiles to produce compilation errors when invalid event names + * are used in a project + * - The HID Report Parser now gives information on the total length of each report within a HID interface + * - The USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate USB_Descriptor_* and + * USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so both may be used + * + * Fixed: + * - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the + * endpoint's bank + * - Fixed swapped parameters in the HID state memory copy call while processing a HID PUSH item in the HID report parser + * - Fixed memory corruption HID report parser when too many COLLECTION or PUSH items were processed + * - Fixed HID report parser not resetting the FEATURE item count when a REPORT ID item is encountered + * - Fixed USBtoSerial demos not reading in UDR1 when the USART receives data but the USB interface is not enumerated, + * causing continuous USART receive interrupts + * - Fixed misspelled event name in the Class driver USBtoSerial demo, preventing correct operation + * - Fixed invalid data being returned when a GetStatus request is issued in Device mode with an unhandled data recipient + * - Added hardware USART receive interrupt and software buffering to the Benito project to ensure received data is not + * missed or corrupted + * - Fixed Device mode HID Class driver always sending IN packets, even when nothing to report + * - Fixed Device mode HID Class driver not explicitly initializing the ReportSize parameter to zero before calling callback + * routine, so that ignored callbacks don't cause incorrect data to be sent + * - Fixed StillImageHost not correctly freezing and unfreezing data pipes while waiting for a response block header + * - Fixed error in the PrinterHost demo preventing the full page data from being sent to the attached device (thanks to John Andrews) + * - Fixed CDC based demos and projects' INF driver files under 64 bit versions of Windows (thanks to Ronny Hanson, Thomas Bleeker) + * - Re-add in missing flip, flip-ee, dfu and dfu-ee targets to project makefiles (thanks to Opendous Inc.) + * - Fix allowable F_CPU values comment in project makefiles to more accurately reflect the allowable values on the USB AVRs + * - Fixed DFU and CDC class bootloaders on the series 2 USB AVRs, corrected invalid signatures, added support for the new + * ATMEGAxx2 series 2 variant AVRs to the DFU bootloader + * - Fixed Low Level USBtoSerial demo not storing received characters (thanks to Michael Cooper) + * - Fixed MIDI Device Class driver not sending/receiving MIDI packets of the correct size (thanks to Thomas Bleeker) + * + * + * \section Sec_ChangeLog090810 Version 090810 + * + * New: + * - Added new device class drivers and matching demos to the library for rapid application development + * - Added new PrinterHost demo (thanks to John Andrews) + * - Added USB Missile Launcher project, submitted by Dave Fletcher + * - Added new Benito Arduino Programmer project + * - Added incomplete device and host mode demos for later enhancement + * - Updated MassStorage device block write routines to use ping-pong Dataflash buffering to increase throughput by around 30% + * - Error status LEDs shown when device endpoint configuration fails to complete in all demos and projects + * - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB + * host mode + * - Added new USB_Host_ClearPipeStall() convenience function to clear a stall condition on an attached device's endpoint + * - Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor + * - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers + * - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number, + * added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code + * - Added new DATAFLASH_CHIP_MASK() macro to the Dataflash driver, which returns the Dataflash select mask for the given chip index + * - Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking disabling of device communications until the + * device has been removed (for use when an error occurs or communications with the device have completed) + * - Added new FAST_STREAM_TRANSFERS compile time option for faster stream transfers via multiple bytes copied per stream loop + * - Added stdio stream demo code to the CDC device demos, to show how to create standard streams out of the virtual serial ports + * - Added new EEPROM and FLASH buffer versions of the Endpoint and Pipe stream functions + * - Added new USE_FLASH_DESCRIPTORS and FIXED_NUM_CONFIGURATIONS compile time options + * - Added support for the new ATMEGA32U2, ATMEGA16U2 and ATMEGA8U2 AVR models + * - Added new USB_DeviceState variable to keep track of the current Device mode USB state + * - Added new LEDs_ToggleLEDs() function to the LEDs driver + * - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions + * - Added new DEVICE_STATE_AS_GPIOR and HOST_STATE_AS_GPIOR compile time options + * - Added 404 Not Found errors to the webserver in the RNDIS demos to indicate invalid URLs + * + * Changed: + * - Deprecated pseudo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused) + * - The device-mode CALLBACK_USB_GetDescriptor() function now has an extra parameter so that the memory space in which the requested + * descriptor is located can be specified. This means that descriptors can now be located in multiple memory spaces within a device. + * - Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality + * - Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead + * - Extended USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch + * - Dataflash_WaitWhileBusy() now always ensures that the dataflash is ready for the next command immediately after returning, + * no need to call Dataflash_ToggleSelectedChipCS() afterwards + * - Low level API MIDI device demo no longer blocks if a note change event is sent while the endpoint is not ready + * - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors + * - Pipe stream functions now automatically set the correct pipe token, so that bidirectional pipes can be used + * - Pipe_ConfigurePipe() now automatically defaults IN pipes to accepting infinite IN requests, this can still be changed by calling + * the existing Pipe_SetFiniteINRequests() function + * - Changed F_USB entries in project makefiles to alias to F_CPU by default, as this is the most common case + * - Host mode demos now use sane terminal escape codes, so that text is always readable and events/program output is visually distinguished + * from one another using foreground colours + * - Internal per-device preprocessing conditions changed to per-device series rather than per-controller group for finer-grain + * internal control + * - Interrupts are no longer disabled during the processing of Control Requests on the default endpoint while in device mode + * - AudioOutput demos now always output to board LEDs, regardless of output mode (removed AUDIO_OUT_LEDS project option) + * - Removed SINGLE_DEVICE_CONFIGURATION compile time option in favor of the new FIXED_NUM_CONFIGURATIONS option so that the exact number + * of device configurations can be defined statically + * - Removed VBUS events, as they are already exposed to the user application via the regular device connection and disconnection events + * - Renamed and altered existing events to properly separate out Host and Device mode events + * - All demos switched over from GNU99 standards mode to C99 standards mode, to reduce the dependencies on GCC-only language extensions + * + * Fixed: + * - Changed bootloaders to use FLASHEND rather than the existence of RAMPZ to determine if far FLASH pointers are needed to fix + * bootloaders on some of the USB AVR devices where avr-libc erroneously defines RAMPZ + * - Fixes to MassStorageHost for better device compatibility (increase command timeout, change MassStore_WaitForDataReceived() + * to only unfreeze and check one data pipe at a time) to prevent incorrect device enumerations and freezes while transferring data + * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is + * cleared to prevent endpoint type corruption + * - Fixed issue opening CDC-ACM ports on hosts when the CDC device tries to send data before the host has set the line encoding + * - Fixed USB_OPT_MANUAL_PLL option being ignored during device disconnects on some models (thanks to Brian Dickman) + * - Fixed documentation mentioning Pipe_GetCurrentToken() function when correct function name is Pipe_GetPipeToken() + * - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.) + * - Fixed CDCHost demo unfreezing the pipes at the point of configuration, rather than use + * - Fixed MassStorage demo not clearing the reset flag when a Mass Storage Reset is issued while not processing a command + * - Fixed USB_Host_SendControlRequest() not re-suspending the USB bus when initial device ready-wait fails + * - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used + * - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected + * - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman) + * - Fixed GenericHID failing HID class tests due to incorrect Logical Minimum and Logical Maximum values (thanks to Soren Greiner) + * - Fixed incorrect PIPE_EPNUM_MASK mask causing pipe failures on devices with endpoint addresses of 8 and above (thanks to John Andrews) + * - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits + * - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered + * - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target + * - Fixed RNDIS demos freezing when more than one connection was attempted simultaneously, causing memory corruption + * - Fixed USBtoSerial demo receiving noise from the USART due to pull-up not being enabled + * + * + * \section Sec_ChangeLog090605 Version 090605 + * + * - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data + * - Fixed documentation showing incorrect USB mode support on the supported AVRs list + * - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" RNDIS request which was unhandled + * - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman) + * - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues + * - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman) + * - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token + * - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC + * interface is skipped + * - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype + * inside the library that is able to hold their defined value to save space + * - Removed DESCRIPTOR_ADDRESS() macro as it was largely superfluous and only served to obfuscate code + * - Rewritten event system to remove all macros, to make user code clearer + * - Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley) + * - Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code + * - Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code + * - USB_IsConnected is now cleared before the USB_Disconnect() event is fired in response to VBUS being removed + * - Fixed incorrect PID value being used in the USBtoSerial project (thanks to Phill) + * - Deleted StdDescriptors.c, renamed USB_GetDescriptor() to CALLBACK_USB_GetDescriptor, moved ConfigDescriptor.c/.h from the + * LUFA/Drivers/USB/Class/ directory to LUFA/Drivers/USB/HighLevel/ in preparation for the new USB class APIs + * - Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure + * - Removed Tx interrupt from the USBtoSerial demo; now sends characters via polling to ensure more time for the Rx interrupt + * - Fixed possible enumeration errors from spin-loops which may fail to exit if the USB connection is severed before the exit condition + * becomes true + * + * + * \section Sec_ChangeLog090510 Version 090510 + * + * - Added new GenericHIDHost demo + * - Corrections to the KeyboardHost and MouseHost demos' pipe handling to freeze and unfreeze the data pipes at the point of use + * - KeyboardHost, MouseHost and GenericHIDHost demos now save and restore the currently selected pipe inside the pipe ISR + * - Changed GenericHID device demo to use the LUFA scheduler, added INTERRUPT_DATA_ENDPOINT and INTERRUPT_CONTROL_ENDPOINT compile + * time options + * - All comments in the library, bootloaders, demos and projects have now been spell-checked and spelling mistakes/typos corrected + * - Added new PIMA_DATA_SIZE() define to the Still Image Host demo + * - Add call to MassStore_WaitForDataReceived() in MassStore_GetReturnedStatus() to ensure that the CSW has been received in the + * extended MSC timeout period before continuing, to prevent long processing delays from causing the MassStore_GetReturnedStatus() + * to early-abort (thanks to Dmitry Maksimov) + * - Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver directory to the HighLevel USB driver directory, + * where they are more suited + * - Removed all binary constants and replaced with decimal or hexadecimal constants so that unpatched GCC compilers can still build the + * code without having to be itself patched and recompiled first + * - Added preprocessor checks and documentation to the bootloaders giving information about missing SIGNATURE_x defines due to + * outdated avr-libc versions. + * - Added support to the CDCHost demo for devices with multiple CDC interfaces which are not the correct ACM type preceding the desired + * ACM CDC interface + * - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen) + * - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan Oakley) + * - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint + * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to match the CTC calculations in the AVR datasheet, + * and to fix instances where rounding caused the endpoint to underflow (thanks to Robin Theunis) + * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type + * pipes can be used with the function + * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes + * - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev) + * - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favor of new Endpoint_ClearIN(), Endpoint_ClearOUT(), + * Pipe_ClearIN() and Pipe_ClearOUT() macros (done to allow for the detection of packets of zero length) + * - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API + * - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been + * renamed to Endpoint_ClearSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the + * Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe + * bank management API + * - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel from Curetis AG) + * - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity + * - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity + * - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway + * - Renamed the main Drivers/AT90USBXXX directory to Drivers/Peripheral, renamed the Serial_Stream driver to SerialStream + * - Fixed CDC and USBtoSerial demos freezing where buffers were full while still transmitting or receiving (thanks to Peter Hand) + * - Removed "Host_" section of the function names in ConfigDescriptor.h, as most of the routines can now be used in device mode on the + * device descriptor + * - Renamed functions in the HID parser to have a "USB_" prefix and the acronym "HID" in the name + * - Fixed incorrect HID interface class and subclass values in the Mouse and KeyboardMouse demos (thanks to Brian Dickman) + * - Capitalized the "Descriptor_Search" and "Descriptor_Search_Comp" prefixes of the values in the DSearch_Return_ErrorCodes_t and + * DSearch_Comp_Return_ErrorCodes_t enums + * - Removed "ERROR" from the enum names in the endpoint and pipe stream error code enums + * - Renamed the USB_PowerOnErrorCodes_t enum to USB_InitErrorCodes_t, renamed the POWERON_ERROR_NoUSBModeSpecified enum value to + * USB_INITERROR_NoUSBModeSpecified + * - Renamed USB_PowerOnFail event to USB_InitFailure + * - Renamed OTG.h header functions to be more consistent with the rest of the library API + * - Changed over all deprecated GCC structure tag initializers to the standardized C99 format (thanks to Mike Alexander) + * - USB_HostRequest renamed to USB_ControlRequest, entire control request header is now read into USB_ControlRequest in Device mode + * rather than having the library pass only partially read header data to the application + * - The USB_UnhandledControlPacket event has had its parameters removed, in favor of accessing the new USB_ControlRequest structure + * - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent + * - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled) + * - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE + * - Endpoint configuration is now refined to give better output when all configurations have static inputs - removed the now useless + * STATIC_ENDPOINT_CONFIGURATION compile time token + * - Fixed SPI driver init function not clearing SPI2X bit when not needed + * - Fixed PREVENT ALLOW MEDIUM REMOVAL command issuing in the MassStorageHost demo using incorrect parameters (thanks to Mike Alex) + * - Fixed MassStorageHost demo broken due to an incorrect if statement test in MassStore_GetReturnedStatus() + * - Fixed reversed signature byte ordering in the CDC bootloader (thanks to Johannes Raschke) + * - Changed PIPE_CONTROLPIPE_DEFAULT_SIZE from 8 to 64 to try to prevent problems with faulty devices which do not respect the given + * wLength value when reading in the device descriptor + * - Fixed missing semicolon in the ATAVRUSBRF01 LED board driver code (thanks to Morten Lund) + * - Changed LED board driver code to define dummy LED masks for the first four board LEDs, so that user code can be compiled for boards + * with less than four LEDs without code modifications (thanks to Morten Lund) + * - Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button + * - Serial driver now correctly calculates the baud register value when in double speed mode + * - Init function of the Serial driver is now static inline to product smaller code for the common-case of static init values + * + * + * \section Sec_ChangeLog090401 Version 090401 + * + * - Fixed MagStripe project configuration descriptor containing an unused (blank) endpoint descriptor + * - Incorporated makefile changes by Denver Gingerich to retain compatibility with stock (non-WinAVR) AVR-GCC installations + * - Fixed makefile EEPROM programming targets programming FLASH data in addition to EEPROM data + * - LUFA devices now enumerate correctly with LUFA hosts + * - Fixed Configuration Descriptor search routine freezing when a comparator returned a failure + * - Removed HID report item serial dump in the MouseHostWithParser and KeyboardHostWithParser - useful only for debugging, and + * slowed down the enumeration of HID devices too much + * - Increased the number of bits per track which can be read in the MagStripe project to 8192 when compiled for the AT90USBXXX6/7 + * - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request + * - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission + * next time the device is attached to a host. + * - Added new F_USB compile time constant to the library and makefiles, to give the raw input clock (used to feed the PLL before any + * clock prescaling is performed) frequency, so that the PLL prescale mask can be determined + * - Changed stream wait timeout counter to be 16-bit, so that very long timeout periods can be set for correct communications with + * badly designed hosts or devices which greatly exceed the USB specification limits + * - Mass Storage Host demo now uses a USB_STREAM_TIMEOUT_MS of two seconds to maintain compatibility with poorly designed devices + * - Function attribute ATTR_ALWAYSINLINE renamed to ATTR_ALWAYS_INLINE to match other function attribute macro naming conventions + * - Added ATTR_ALWAYS_INLINE attribute to several key inlined library components, to ensure they are inlined in all circumstances + * - Removed SetSystemClockPrescaler() macro, the clock_prescale_set() avr-libc macro has been corrected in recent avr-libc versions + * - Fixed incorrect/missing control status stage transfers on demos, bootloaders and applications (thanks to Nate Lawson) + * - The NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded + * to also remove parts of the Get Status chapter 9 request to further reduce code usage + * - Makefile updated to include output giving the currently selected BOARD parameter value + * - Board Dataflash driver now allows for dataflash ICs which use different shifts for setting the current page/byte address (thanks + * to Kenneth Clubb) + * - Added DataflashManager_WriteBlocks_RAM() and DataflashManager_ReadBlocks_RAM() functions to the MassStorage demo, to allow for easy + * interfacing with a FAT library for dataflash file level access + * - Corrected CDC class bootloader to fix a few bugs, changed address counter to store x2 addresses for convenience + * - Fixed typos in the SPI driver SPI_SPEED_FCPU_DIV_64 and SPI_SPEED_FCPU_DIV_128 masks (thanks to Markus Zocholl) + * - Keyboard and Mouse device demos (normal, data interrupt and fully interrupt driven) combined into unified keyboard and mouse demos + * - Keyboard and Mouse host demos (normal and data interrupt driven) combined into unified keyboard and mouse demos + * - Removed AVRISP_Programmer project due to code quality concerns + * - Fixed CDC demo not sending an empty packet after each transfer to prevent the host from buffering incoming data + * - Fixed documentation typos and preprocessor checks relating to misspellings of the USE_RAM_DESCRIPTORS token (thanks to Ian Gregg) + * - Fixed USBTask.h not conditionally including HostChapter9.h only when USB_CAN_BE_HOST is defined (thanks to Ian Gregg) + * - Fixed incorrect ADC driver init register manipulation (thanks to Tobias) + * - Added new GenericHID device demo application + * - Fixed Still Image Host SImage_SendData() function not clearing the pipe bank after sending data + * + * + * \section Sec_ChangeLog090209 Version 090209 + * + * - PWM timer mode in AudioOut demo changed to Fast PWM for speed + * - Updated Magstripe project to work with the latest hardware revision + * - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups + * - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface (thanks to + * Nate Lawson) + * - Fixed serious data corruption issue in MassStorage demo dataflash write routine + * - Added new NO_CLEARSET_FEATURE_REQUEST compile time token + * - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled + * - Fixed USB_DeviceEnumerationComplete event firing after each configuration change, rather than once after the initial configuration + * - Added ENDPOINT_DOUBLEBANK_SUPPORTED() macros to Endpoint.h, altered ENDPOINT_MAX_SIZE() to allow user to specify endpoint + * - ENDPOINT_MAX_ENDPOINTS changed to ENDPOINT_TOTAL_ENDPOINTS, PIPE_MAX_PIPES changed to PIPE_TOTAL_PIPES + * - Endpoint and Pipe non-control stream functions now ensure endpoint or pipe is ready before reading or writing + * - Changed Teensy bootloader to use a watchdog reset when exiting rather than a software jump + * - Fixed integer promotion error in MassStorage and MassStorageHost demos, corrupting read/write transfers + * - SPI_SendByte is now SPI_TransferByte, added new SPI_SendByte and SPI_ReceiveByte functions for fast one-way transfer + * - MassStorage demo changed to use new fast one-way SPI transfers to increase throughput + * - MassStorage handling of Mass Storage Reset class request improved + * - Altered MassStorage demo dataflash block read code for speed + * - Added USB_IsSuspended global flag + * - Simplified internal Dual Mode (OTG) USB library code to reduce code size + * - Extended stream timeout period to 100ms from 50ms + * - Mass Storage Host demo commands now all return an error code from the Pipe_Stream_RW_ErrorCodes_t enum + * - Added SubErrorCode parameter to the USB_DeviceEnumerationFailed event + * - VBUS drop interrupt now disabled during the manual-to-auto VBUS delivery handoff + * - Simplified low level backend so that device/host mode initialization uses the same code paths + * - Added workaround for faulty Mass Storage devices which do not implement the required GET_MAX_LUN request + * - Removed buggy Telnet application from the RNDIS demo + * - Moved Mass Storage class requests in the Mass Storage Host demo to wrapper functions in MassStoreCommands.c + * - Fixed incorrect SCSI command size value in the Request Sense command in MassStoreCommands.c + * - Added SetProtocol request to HID class non-parser Mouse and Keyboard demos to force devices to use the correct Boot Protocol + * - Added new "dfu" and "flip" programming targets to project makefiles + * - HID_PARSE_Sucessful enum member typo corrected to HID_PARSE_Successful + * - Changed COLLECTION item structures in the HID descriptor parser to include the collection's Usage Page value + * - Serial driver now sets Tx line as output, enables pull-up on Rx line + * - Fixed smaller USB AVRs raising multiple connection and disconnection events when NO_LIMITED_CONTROLLER_CONNECT is disabled + * - Added HOST_DEVICE_SETTLE_DELAY_MS to give the host delay after a device is connected before it is enumerated + * - Fixed KeyboardHostWithParser demo linking against the wrong global variables + * - Completed doxygen documentation of remaining library bootloaders, demos and projects + * - Fixed incorrect bootloader start address in the TeensyHID bootloader + * - Added HWB button whole-disk ASCII dump functionality to MassStoreHost demo + * - Replaced printf_P(PSTR("%c"), {Variable}) calls with putchar() for speed and size savings + * - Serial driver now accepts baud rates over 16-bits in size, added double speed flag option + * - Fixed incorrect callback abort return value in Pipe.c + * - Added new flip-ee and dfu-ee makefile targets (courtesy of Opendous Inc.) + * - Removed reboot-on-disconnect code from the TeensyHID bootloader, caused problems on some systems + * - Fixed AudioOutput and AudioInput demos looping on the endpoint data, rather than processing a sample at a time and returning + * each time the task runs to allow for other tasks to execute + * - Added support for the Atmel ATAVRUSBRF01 board + * - Added AVRISP Programmer Project, courtesy of Opendous Inc. + * - Fixed CDC Host demo not searching through both CDC interfaces for endpoints + * - Fixed incorrect Product String descriptor length in the DFU class bootloader + * + * + * \section Sec_ChangeLog081224 Version 081224 + * + * - MyUSB name changed to LUFA, the Lightweight USB Framework for AVRs + * - Fixed Mass Storage Host demo's MassStore_SendCommand() delay in the incorrect place + * - Fixed USBtoSerial demo not calling ReconfigureUSART() after a change in the line encoding + * - Fixed infinite loop in host mode Host-to-Device control transfers with data stages + * - HID report parser now supports devices with multiple reports in one interface via Report IDs + * - Fixed RZUSBSTICK board LED driver header incorrect macro definition order causing compile errors + * - Calling USB_Init() when the USB interface is already configured now forces a complete interface reset + * and re-enumeration - fixes MyUSB DFU bootloader not switching to app code correctly when soft reset used + * - Fixed "No newline at end of file" warning when stream callbacks are enabled + * - DFU bootloader now uses fixed signature bytes per device, rather than reading them out dynamically for size + * - Added new FIXED_CONTROL_ENDPOINT_SIZE and USE_SINGLE_DEVICE_CONFIGURATION switches to statically define certain values to + * reduce compiled binary size + * - Added new NO_LIMITED_CONTROLLER_CONNECT switch to prevent the library from trying to determine bus connection + * state from the suspension and wake up events on the smaller USB AVRs + * - Added summary of all library compile time tokens to the documentation + * - Added overview of the LUFA scheduler to the documentation + * - Removed MANUAL_PLL_CONTROL compile time token, replaced with a mask for the USB_Init() Options parameter + * - CDC bootloader now uses the correct non-far or far versions of the pgm_* functions depending on if RAMPZ is defined + * - Doxygen documentation now contains documentation on all the projects, bootloaders and most demos included with the library + * - CDC bootloader now runs user application when USB disconnected rather than waiting for a hard reset + * - MouseHostWithParser and KeyboardHostWithParser now support multiple-report devices + * - RNDIS demo can now close connections correctly using the new TCP_APP_CLOSECONNECTION() macro - used in Webserver + * - Fixed the DFU bootloader, no longer freezes up when certain files are programmed into an AVR, made reading/writing faster + * - Fixed mouse/joystick up/down movements reversed - HID mouse X/Y coordinates use a left-handed coordinate system, not a normal + * right-handed system + * - Added stub code to the CDC and USBtoSerial demos showing how to read and set the RS-232 handshake lines - not currently used in + * the demos, but the example code and supporting defines are now in place + * - Interrupts are now disabled when processing a control request in device mode, to avoid exceeding the strict control request + * timing requirements. + * - All demos now use a central StatusUpdate() function rather than direct calls to the board LED functions, so that the demos can + * easily be altered to show different LED combinations (or do something else entirely) as the demo's status changes + * - Removed LED commands from the CDC bootloader, unused by most AVR910 programming software + * - Fixed RNDIS demo ICMP ping requests echoing back incorrect data + * - Added DHCP server code to RNDIS demo, allowing for hands-free auto configuration on any PC + * - Fixed DFU bootloader PID value for the ATMEGA16U4 AVR + * - Endpoint and Pipe configuration functions now return an error code indicating success or failure + * - USB Reset in device mode now resets and disables all device endpoints + * - Added intermediate states to the host mode state machine, reducing the USB task blocking time to no more than 1ms explicitly per + * invocation when in host mode + * - Added support for the ATMEGA32U6 microcontroller + * - Added STATIC_ENDPOINT_CONFIGURATION compile time option, enabled in the bootloaders to minimize space usage + * - Removed redundant code from the USB device GetStatus() chapter 9 processing routine + * - Added new TeensyHID bootloader, compatible with the Teensy HID protocol (http://www.pjrc.com/teensy/) + * - Versions are now numbered by release dates, rather than arbitrary major/minor revision numbers + * - USB_RemoteWakeupEnabled is now correctly set and cleared by SetFeature and ClearFeature requests from the host + * - Changed prototype of GetDescriptor, so that it now returns the descriptor size (or zero if the descriptor doesn't exist) + * rather than passing the size back to the caller through a parameter and returning a boolean + * + * + * \section Sec_ChangeLog153 Version 1.5.3 (081002) + * + * - 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 (080731) + * + * - 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 (080707) + * + * - 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 (080610) + * + * - 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 (090519) + * + * - 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 (090505) + * + * - 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 (080401) + * + * - 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 (080319) + * + * - 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 (080307) + * + * - 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 (080204) + * + * - 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_ChangeLog110 Version 1.1.0 (080125) + * + * - 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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompileTimeTokens.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompileTimeTokens.txt new file mode 100644 index 000000000..966ddd0fe --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompileTimeTokens.txt @@ -0,0 +1,223 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_TokenSummary Summary of Compile Tokens + * + * The following lists all the possible tokens which can be defined in a project makefile, and passed to the + * compiler via the -D switch, to alter the LUFA library code. These tokens may alter the library behaviour, + * or remove features unused by a given application in order to save flash space. + * + * \note If the \c USE_LUFA_CONFIG_HEADER token is defined, the library will include a header file named \c LUFAConfig.h located + * in the user directory where the below compile time tokens may be defined. This allows for an alternative to makefile + * defined tokens for configuring the library. + * + * \section Sec_SummaryNonUSBTokens Non USB Related Tokens + * This section describes compile tokens which affect non-USB sections of the LUFA library. + * + * - DISABLE_TERMINAL_CODES - (\ref Group_Terminal) - All Architectures \n + * If an application contains ANSI terminal control codes listed in TerminalCodes.h, it might be desired to remove them + * at compile time for use with a terminal which is non-ANSI control code aware, without modifying the source code. If + * this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from + * the source code at compile time. + * + * + * \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens + * This section describes compile tokens which affect USB class-specific drivers in the LUFA library. + * + * - HID_HOST_BOOT_PROTOCOL_ONLY - (\ref Group_USBClassHIDHost) - All Architectures \n + * By default, the USB HID Host class driver is designed to work with HID devices using either the Boot or Report HID + * communication protocols. On devices where the Report protocol is not used (i.e. in applications where only basic + * Mouse or Keyboard operation is desired, using boot compatible devices), the code responsible for the Report protocol + * mode can be removed to save space in the compiled application by defining this token. When defined, it is still necessary + * to explicitly put the attached device into Boot protocol mode via a call to \ref HID_Host_SetBootProtocol(). + * + * - HID_STATETABLE_STACK_DEPTH=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This + * allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous + * state table in a compact manner. This token may be defined to a non-zero 8-bit value to give the maximum depth of the state + * table stack. If not defined, this defaults to the value indicated in the HID.h file documentation. + * + * - HID_USAGE_STACK_DEPTH=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession + * when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with + * different usages in a compact manner. This token may be defined to a non-zero 8-bit value to set the maximum depth of the + * usage stack, indicating the maximum number of USAGE items which can be stored temporarily until the next INPUT, OUTPUT + * and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation. + * + * - HID_MAX_COLLECTIONS=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information + * is stored separately in the processed usage structure (and referred to by the data elements in the structure) to save space. + * This token may be defined to a non-zero 8-bit value to set the maximum number of COLLECTION items which can be processed by the + * parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file + * documentation. + * + * - HID_MAX_REPORTITEMS=x - (\ref Group_HIDParser) - All Architectures \n + * All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID + * device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which + * the report data should be interpreted by the host. This token may be defined to a non-zero 8-bit value to set the maximum number of + * data elements which can be stored in the processed HID report structure, including INPUT, OUTPUT and (if enabled) FEATURE items. + * If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed separately in the + * processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation. + * + * - HID_MAX_REPORT_IDS=x - (\ref Group_HIDParser) - All Architectures \n + * HID reports may contain several report IDs, to logically distinguish grouped device data from one another - for example, a combination + * keyboard and mouse might use report IDs to separate the keyboard reports from the mouse reports. In order to determine the size of each + * report, and thus know how many bytes must be read or written, the size of each report (IN, OUT and FEATURE) must be calculated and + * stored. This token may be defined to a non-zero 8-bit value to set the maximum number of report IDs in a device which can be processed + * and their sizes calculated/stored into the resultant processed report structure. If not defined, this defaults to the value indicated in + * the HID.h file documentation. + * + * - NO_CLASS_DRIVER_AUTOFLUSH - (\ref Group_USBClassDrivers) - All Architectures \n + * Many of the device and host mode class drivers automatically flush any data waiting to be written to an interface, when the corresponding + * USB management task is executed. This is usually desirable to ensure that any queued data is sent as soon as possible once and new data is + * constructed in the main program loop. However, if flushing is to be controlled manually by the user application via the *_Flush() commands, + * the compile time token may be defined in the application's makefile to disable automatic flushing during calls to the class driver USB + * management tasks. + * + * + * \section Sec_SummaryUSBTokens General USB Driver Related Tokens + * This section describes compile tokens which affect USB driver stack as a whole in the LUFA library. + * + * - ORDERED_EP_CONFIG - (\ref Group_EndpointManagement , \ref Group_PipeManagement) - AVR8, UC3 \n + * The USB AVRs do not allow for Endpoints and Pipes to be configured out of order; they must be configured in an ascending order to + * prevent data corruption issues. However, by default LUFA employs a workaround to allow for unordered Endpoint/Pipe initialization. This compile + * time token may be used to restrict the initialization order to ascending indexes only in exchange for a smaller compiled binary size. Use + * caution when applied to applications using the library USB Class drivers; the user application must ensure that all endpoints and pipes are + * allocated sequentially. + * + * - USE_STATIC_OPTIONS=x - (\ref Group_USBManagement) - All Architectures \n + * By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad + * voltage regulator is enabled, and the device speed when in device mode. By defining this token to a mask comprised of the USB options + * mask defines usually passed as the Options parameter to USB_Init(), the resulting compiled binary can be decreased in size by removing + * the dynamic options code, and replacing it with the statically set options. When defined, the USB_Init() function no longer accepts an + * Options parameter. + * + * - USB_DEVICE_ONLY - (\ref Group_USBManagement) - All Architectures \n + * For the USB AVR models supporting both device and host USB modes, the USB_Init() function contains a Mode parameter which specifies the + * mode the library should be initialized to. If only device mode is required, the code for USB host mode can be removed from the binary to + * save space. When defined, the USB_Init() function no longer accepts a Mode parameter. This define is irrelevant on smaller USB AVRs which + * do not support host mode. + * + * - USB_HOST_ONLY - (\ref Group_USBManagement) - All Architectures \n + * Same as USB_DEVICE_ONLY, except the library is fixed to USB host mode rather than USB device mode. Not available on some USB AVR models. + * + * - USB_STREAM_TIMEOUT_MS=x - (\ref Group_USBManagement) - All Architectures \n + * When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host + * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero 16-bit value to set the timeout + * period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead. + * + * - NO_LIMITED_CONTROLLER_CONNECT - (\ref Group_Events) - AVR8 Only \n + * On the smaller USB AVRs, the USB controller lacks VBUS events to determine the physical connection state of the USB bus to a host. In lieu of + * VBUS events, the library attempts to determine the connection state via the bus suspension and wake up events instead. This however may be + * slightly inaccurate due to the possibility of the host suspending the bus while the device is still connected. If accurate connection status is + * required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_DeviceState global + * can be accurately set and the \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events manually raised by the RAISE_EVENT macro. + * When defined, this token disables the library's auto-detection of the connection state by the aforementioned suspension and wake up events. + * + * - NO_SOF_EVENTS - (\ref Group_Events) - All Architectures \n + * By default, there exists a LUFA application event for the start of each USB frame while the USB bus is not suspended in either host or device mode. + * This event can be selectively enabled or disabled by calling the appropriate device or host mode function. When this compile time token is defined, + * the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed, + * reducing the compiled program's binary size. + * + * + * \section Sec_SummaryUSBDeviceTokens USB Device Mode Driver Related Tokens + * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Device mode. + * + * - USE_RAM_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n + * Define this token to indicate to the USB driver that all device descriptors are stored in RAM, rather than being located in any one + * of the AVR's memory spaces. RAM descriptors may be desirable in applications where the descriptors need to be modified at runtime. + * + * - USE_FLASH_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n + * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's FLASH memory rather than RAM. + * + * - USE_EEPROM_DESCRIPTORS - (\ref Group_StdDescriptors) - AVR8 Only \n + * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's EEPROM memory rather than RAM. + * + * - NO_INTERNAL_SERIAL - (\ref Group_StdDescriptors) - All Architectures \n + * Some AVR models contain a unique serial number which can be used as the device serial number, while in device mode. This allows + * the host to uniquely identify the device regardless of if it is moved between USB ports on the same computer, allowing allocated + * resources (such as drivers, COM Port number allocations) to be preserved. This is not needed in many apps, and so the code that + * performs this task can be disabled by defining this option and passing it to the compiler via the -D switch. + * + * - FIXED_CONTROL_ENDPOINT_SIZE=x - (\ref Group_EndpointManagement) - All Architectures \n + * By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor. + * Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if + * descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be + * defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled + * binary. + * + * - DEVICE_STATE_AS_GPIOR - (\ref Group_Device) - AVR8 Only \n + * One of the most frequently used global variables in the stack is the USB_DeviceState global, which indicates the current state of + * the Device State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token + * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR + * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except + * implicitly via the library APIs. + * + * - FIXED_NUM_CONFIGURATIONS=x - (\ref Group_Device) - All Architectures \n + * By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces + * the amount of configuration required to set up the library, and allows the value to change dynamically (if descriptors are stored in + * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this value may be fixed via this token in the project + * makefile to reduce the compiled size of the binary at the expense of flexibility. + * + * - CONTROL_ONLY_DEVICE - (\ref Group_Device) - All Architectures \n + * In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication + * is through control endpoint requests. Defining this token will remove several features related to the selection and control of device + * endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided. + * + * - MAX_ENDPOINT_INDEX - (\ref Group_Device) - XMEGA Only \n + * Defining this value to the highest index (not address - this excludes the direction flag) endpoint within the device will restrict the + * number of FIFOs created internally for the endpoint buffers, reducing the total RAM usage. + * + * - INTERRUPT_CONTROL_ENDPOINT - (\ref Group_USBManagement) - All Architectures \n + * Some applications prefer to not call the USB_USBTask() management task regularly while in device mode, as it can complicate code significantly. + * Instead, when device mode is used this token can be passed to the library via the -D switch to allow the library to manage the USB control + * endpoint entirely via USB controller interrupts asynchronously to the user application. When defined, USB_USBTask() does not need to be called + * when in USB device mode. + * + * - NO_DEVICE_REMOTE_WAKEUP - (\ref Group_Device) - All Architectures \n + * Many devices do not require the use of the Remote Wakeup features of USB, used to wake up the USB host when suspended. On these devices, + * the code required to manage device Remote Wakeup can be disabled by defining this token and passing it to the library via the -D switch. + * + * - NO_DEVICE_SELF_POWER - (\ref Group_Device) - All Architectures \n + * USB devices may be bus powered, self powered, or a combination of both. When a device can be both bus powered and self powered, the host may + * query the device to determine the current power source, via \ref USB_Device_CurrentlySelfPowered. For solely bus powered devices, this global + * and the code required to manage it may be disabled by passing this token to the library via the -D switch. + * + * + * \section Sec_SummaryUSBHostTokens USB Host Mode Driver Related Tokens + * + * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Host mode. + * + * - HOST_STATE_AS_GPIOR - (\ref Group_Host) - AVR8 Only \n + * One of the most frequently used global variables in the stack is the USB_HostState global, which indicates the current state of + * the Host State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token + * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR + * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except + * implicitly via the library APIs. + * + * - USB_HOST_TIMEOUT_MS=x - (\ref Group_Host) - All Architectures \n + * When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached + * device fails to respond within the timeout period. This token may be defined to a non-zero 16-bit value to set the timeout period for + * control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead. + * + * - HOST_DEVICE_SETTLE_DELAY_MS=x - (\ref Group_Host) - All Architectures \n + * Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or + * they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled + * back to a known idle state before communications occur with the device. This token may be defined to a 16-bit value to set the device + * settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead. + * + * - INVERTED_VBUS_ENABLE_LINE - (\ref Group_Host) - All Architectures \n + * If enabled, this will indicate that the USB target VBUS line polarity is inverted; i.e. it should be pulled low to enable VBUS to the + * target, and pulled high to stop the target VBUS generation. + * + * \attention On AVR8 architecture devices, this compile time option requires \c NO_AUTO_VBUS_MANAGEMENT to be set. + * + * - NO_AUTO_VBUS_MANAGEMENT - (\ref Group_Host) - All Architectures \n + * Disables the automatic management of VBUS to the target, i.e. automatic shut down in the even of an overcurrent situation. When enabled, VBUS + * is enabled while the USB controller is initialized in USB Host mode. + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompilingApps.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompilingApps.txt new file mode 100644 index 000000000..85912b56e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/CompilingApps.txt @@ -0,0 +1,50 @@ +/** \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. A standard "coreutils" package for your system is also required for command line + * compilation of LUFA based applications. + * + * \subsection SSec_PreqWindows Windows Prerequisites + * On Windows, you will need a copy of the latest Atmel Toolchain, either downloaded and installed as a standalone + * package, or installed as part of Atmel Studio. You will need to ensure that the "bin" directory of the toolchain + * is available in your system's PATH environment variable. + * + * In addition, you will need to install a ported version of the ZSH or BASH *nix shells, and a standard set of *nix + * utilities such as cut, find and sed. These can be found in the "basic" system package of the + * of the MinGW installer (http://www.mingw.org). Once installed, add the "msys\1.0\bin" of the MinGW installation + * folder is added to your system's PATH environment variable. + * + * The bootloaders currently also require the "bc" application, which can be installed from + * http://gnuwin32.sourceforge.net/downlinks/bc.php. Once installed add the "GnuWin32\bin" path of the GnuWin32 + * installation folder to your system's PATH environment variable. + * + * \subsection SSec_PreqLinux Linux Prerequisites + * On Linux systems you will need to install the latest Linux distribution of the standalone Atmel Toolchain from the + * Atmel website for general development, or use the latest avr-libc and avr-gcc packages for your chosen distribution's + * package manager. For full device support, the Atmel standalone package is recommended. + * + * \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. Compilation of projects 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 started 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. + * + * \see \ref Page_BuildSystem for information on the LUFA build system. + */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ConfiguringApps.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ConfiguringApps.txt new file mode 100644 index 000000000..f126e69bb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ConfiguringApps.txt @@ -0,0 +1,104 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \page Page_ConfiguringApps Configuring the Demos, Bootloaders and Projects + * + * If the target microcontroller model, architecture, clock speed, board or other settings are different from the current + * settings, they must be changed and the project recompiled from the source code before being programmed into the microcontroller. + * Most project configuration options are located in the makefile build script inside each LUFA application's folder, + * however some demo or application-specific configuration settings 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. + * + * \see \ref Page_BuildSystem for information on the LUFA build system. + * + * \section Sec_AppConfigParams The Default Application Template + * + * Below is a copy of the default LUFA application makefile, which can be used as a template for each application. + * + * \verbinclude makefile_template + * + * Inside each makefile, a number of configuration variables are listed with the syntax " = ". For + * each application, the important standard variables which should be altered are: + * + * - MCU, the target processor model + * - ARCH, the target microcontroller architecture + * - BOARD, the target board hardware + * - F_CPU, the target CPU master clock frequency, after any prescaling + * - F_USB, the target raw input clock to the USB module of the processor + * - OPTIMIZATION, the level of optimization to compile with + * - TARGET, the name of the target output binary and other files + * - SRC, the list of source files to compile/assemble/link + * - LUFA_PATH, the path to the LUFA library core source code + * - CC_FLAGS, the common command line flags to pass to the C/C++ compiler, assembler and linker + * - LD_FLAGS, the command line flags to pass to the linker + * + * These values should be changed to reflect the build hardware. + * + * \subsection SSec_MCU The MCU Parameter + * This parameter indicates the target microcontroller model for the compiled application. This should be set to the model of the target + * microcontroller (such as the AT90USB1287, or the ATMEGA32U4), in all lower-case (e.g. "at90usb1287"). Note that not all demos support all the + * microcontroller models and architectures, as they may make use of peripherals or modes only present in some devices. + * + * For supported processor models, see \ref Page_DeviceSupport. + * + * \subsection SSec_ARCH The ARCH Parameter + * This parameter indicates the target microcontroller architecture the library is to be compiled for. Different microcontroller + * architectures require different source files to be compiled into the final binary, and so this option must be set to the correct + * architecture for the selected platform. + * + * For supported processor architectures, see \ref Page_DeviceSupport. + * + * \subsection SSec_BOARD The BOARD Parameter + * This parameter indicates the target board hardware for the compiled application. Some LUFA library drivers are board-specific, + * such as the LED driver, and the library needs to know the layout of the target board. If you are using one of the board models listed + * on the main library page, change this parameter to the board name in all UPPER-case. + * + * If you are not using any board-specific drivers in the LUFA library, or you are using a custom board layout, change this to read + * "USER" (no quotes) instead of a standard board name. If the USER board type is selected and the application makes use of one or more + * board-specific hardware drivers inside the LUFA library, then the appropriate stub drives files should be copied from the \c /CodeTemplates/DriverStubs/ + * directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the + * custom board's hardware. + * + * For boards with built in hardware driver support within the LUFA library, see \ref Page_DeviceSupport. + * + * \subsection SSec_F_CPU The F_CPU Parameter + * This parameter indicates the target microcontroller's main CPU clock frequency, in Hz. This is used by many libraries (and applications) for + * timing related purposes, and should reflect the actual CPU speed after any prescaling or adjustments are performed. + * + * \subsection SSec_F_USB The F_USB Parameter + * This parameter indicates the raw input clock frequency to the USB module within the microcontroller in Hz. This may be very different on some platforms + * to the main CPU clock or other peripheral/bus clocks. + * + * \subsection SSec_OPTIMIZATION The OPTIMIZATION Parameter + * This parameter indicates the level of optimization to use when compiling the application. This will allow you to compile with an optimization level + * supported by GCC, from 0 (no optimization) to 3 (fastest runtime optimization) or s (smallest size). + * + * \subsection SSec_TARGET The TARGET Parameter + * This parameter indicates the application target name, which is used as the base filename for the build binary and debugging files. This will be the + * name of the output files once linked together into the final application, ready to load into the target. + * + * \subsection SSec_SRC The SRC Parameter + * This parameter indicates the source files used to compile the application, as a list of C (*.c), C++ (*.cpp) and Assembly (*.S) files. Note that + * all assembly files must end in a capital .S extension, as lowercase .s files are reserved for GCC intermediate files. + * + * \subsection SSec_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 core. This path may be relative or absolute, however note than even under Windows based systems the + * forward-slash (/) path seperator must be used. + * + * \subsection SSec_CC_FLAGS The CC_FLAGS Parameter + * This parameter lists the compiler flags passed to the C/C++ compiler, the assembler and the linker. These are used as-is directly to GCC and thus + * must match GCC's command line options as given in the GCC manual. This variable may be used to define tokens directly on the command line, enable or + * disable warnings, adjust the target-specific tuning parameters or other options. + * + * \subsection SSec_LD_FLAGS The LD_FLAGS Parameter + * This parameter lists the linker flags passed exclusively to the linker. These are used as-is directly to GCC and thus must match GCC's command line + * linker options as given in the GCC manual. This variable may be used to create or relocate custom data sections, or enable linker specific behaviors. + */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DevelopingWithLUFA.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DevelopingWithLUFA.txt new file mode 100644 index 000000000..becd58e54 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DevelopingWithLUFA.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_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_BuildSystem - The LUFA Buildsystem + * \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_ExportingLibrary - Exporting LUFA for IDE Use + * \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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DeviceSupport.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DeviceSupport.txt new file mode 100644 index 000000000..18e808f4d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DeviceSupport.txt @@ -0,0 +1,432 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_DeviceSupport Device and Hardware Support + * + * Atmel Microcontrollers: + * \li \subpage Page_AVR8Support - Atmel AVR8 Support + * \li \subpage Page_UC3Support - Atmel AVR32 UC3 Support + * \li \subpage Page_XMEGASupport - Atmel XMEGA Support + */ + +/** + * \page Page_AVR8Support Atmel 8-Bit AVR (AVR8) Support + * + * \section Sec_AVR8Support_Devices Supported Microcontroller Models + * + * Currently supported AVR8 models: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PartUSB Device ModeUSB Host Mode
AT90USB82YesNo
ATMEGA8U2YesNo
AT90USB162YesNo
ATMEGA16U2YesNo
ATMEGA16U4YesNo
ATMEGA32U2YesNo
ATMEGA32U4YesNo
ATMEGA32U6YesNo
AT90USB646YesNo
AT90USB647YesYes
AT90USB1286YesNo
AT90USB1287YesYes
+ * + * \section Sec_AVR8Support_Boards Supported Atmel Boards + * Currently supported Atmel AVR8 boards (see \ref Group_BoardTypes): + * - AT90USBKEY + * - ATAVRUSBRF01 + * - EVK527 + * - RZUSBSTICK + * - STK525 + * - STK526 + * - XPLAIN (Original green board, not the newer blue XPLAINED family boards) + * + * \section Sec_AVR8Support_ThirdParty Supported Third Party Models + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): + * - Adafruit U4 Breakout Board + * - Arduino Uno + * - Bitwizard Multio and Big-Multio + * - Busware BUI + * - Busware CUL V3 + * - Busware TUL + * - DorkbotPDX Duce + * - Fletchtronics Bumble-B (using manufacturer recommended peripheral layout) + * - Kernel Concepts USBFOO + * - Linnix UDIP + * - MattairTech JM-DB-U2 + * - Maximus USB + * - Micropendous Boards (Micropendous-32U2, Micropendous-1, Micropendous-2) + * - Microsin AVR-USB162 + * - Minimus USB + * - Olimex AVR-USB-162 + * - Olimex AVR-USB-32U4 + * - Olimex AVR-USB-T32U4 + * - Olimex AVR-ISP-MK2 + * - Paranoid Studio's US2AX (V1, V2 and V3 hardware revisions) + * - PJRC Teensy (1.x and 2.x versions) + * - Sparkfun U2 Breakout Board + * - TCNISO Blackcat USB JTAG + * - Tempusdictum Benito + * - Tom's USBTINY-MKII (all revisions and versions) + * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + +/** + * \page Page_UC3Support Atmel 32-Bit UC3 AVR (UC3) + * + * \warning The AVR32 UC3 device support is currently experimental, and is included for preview purposes only. + * + * \section Sec_UC3Support_Devices Supported Microcontroller Models + * + * Currently supported UC3 models: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PartUSB Device ModeUSB Host Mode
AT32UC3A064YesYes
AT32UC3A164YesYes
AT32UC3A364YesYes
AT32UC3A364SYesYes
AT32UC3A464YesYes
AT32UC3A464SYesYes
AT32UC3B064YesYes
AT32UC3B164YesYes
AT32UC3A0128YesYes
AT32UC3A1128YesYes
AT32UC3A3128YesYes
AT32UC3A3128SYesYes
AT32UC3A4128YesYes
AT32UC3A4128SYesYes
AT32UC3B0128YesYes
AT32UC3B1128YesYes
AT32UC3A0256YesYes
AT32UC3A1256YesYes
AT32UC3A3256YesYes
AT32UC3A3256SYesYes
AT32UC3A4256YesYes
AT32UC3A4256SYesYes
AT32UC3B0256YesYes
AT32UC3B1256YesYes
AT32UC3A0512YesYes
AT32UC3A1512YesYes
AT32UC3B0512YesYes
AT32UC3B1512YesYes
+ * + * \section Sec_UC3Support_Boards Supported Atmel Boards + * + * Currently supported Atmel UC3 boards (see \ref Group_BoardTypes): + * - EVK1100 + * - EVK1101 + * - EVK1104 + * + * \section Sec_UC3Support_ThirdParty Supported Third Party Models + * + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): + * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + +/** + * \page Page_XMEGASupport Atmel USB XMEGA AVR (XMEGA) + * + * \warning The XMEGA device support is currently experimental (incomplete and/or non-functional), and is included for preview purposes only. + * + * \section Sec_XMEGASupport_Devices Supported Microcontroller Models + * + * Currently supported XMEGA models: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
PartUSB Device ModeUSB Host Mode
ATXMEGA16A4UYesNo
ATXMEGA32A4UYesNo
ATXMEGA64A4UYesNo
ATXMEGA128A4UYesNo
ATXMEGA64A3UYesNo
ATXMEGA128A3UYesNo
ATXMEGA192A3UYesNo
ATXMEGA256A3UYesNo
ATXMEGA256A3BUYesNo
ATXMEGA128A1UYesNo
ATXMEGA64B3YesNo
ATXMEGA128B3YesNo
ATXMEGA64B1YesNo
ATXMEGA128B1YesNo
ATXMEGA64C3YesNo
ATXMEGA128C3YesNo
ATXMEGA192C3YesNo
ATXMEGA256C3YesNo
ATXMEGA384C3YesNo
ATXMEGA16C4YesNo
ATXMEGA32C4YesNo
+ * + * \section Sec_XMEGASupport_Boards Supported Atmel Boards + * Currently supported Atmel XMEGA boards (see \ref Group_BoardTypes): + * - XMEGA A3BU Xplained + * - XMEGA B1 Xplained + * + * \section Sec_XMEGASupport_ThirdParty Supported Third Party Models + * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names): + * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DirectorySummaries.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DirectorySummaries.txt new file mode 100644 index 000000000..b04224677 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/DirectorySummaries.txt @@ -0,0 +1,80 @@ +/** \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 Platform + * \brief Platform specific drivers. + * + * This folder contains platform specific drivers and defines for various supported architectures. These may or may + * not be used in a LUFA application, and are provided for convenience purposes. + * + * \dir Drivers + * \brief Library hardware and software drivers. + * + * This folder contains all the library hardware and software drivers for each supported board, architecture and + * microcontroller model. + * + * \dir Drivers/Misc + * \brief Miscellaneous driver files. + * + * This folder contains drivers for aspects other than the USB interface, board hardware or microcontroller peripherals. + * + * \dir Drivers/Peripheral + * \brief Microcontroller peripheral driver files. + * + * This folder contains drivers for various low level microcontroller peripherals, usually located on the microcontroller + * die within the same physical chip. + * + * \dir Drivers/USB + * \brief USB controller peripheral driver files. + * + * This folder contains the complete LUFA USB stack and controller files, including the core driver and stack, as well + * as the USB class driver implementations. + * + * \dir Drivers/USB/Core + * \brief Core USB driver files. + * + * This folder contains the core USB stack and controller driver files, to correctly implement USB functionality on the + * target architecture and microcontroller model. This + * + * \dir 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 Drivers/USB/Class/Device + * \brief USB Device Class helper driver files. + * + * Device mode drivers for the standard USB classes. + * + * \dir Drivers/USB/Class/Host + * \brief USB Host Class helper driver files. + * + * Host mode drivers for the standard USB classes. + * + * \dir 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 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 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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Donating.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Donating.txt new file mode 100644 index 000000000..7e947c2a2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/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 Images/Author.jpg "Dean Camera, LUFA Developer" + * + * I am a 23 year old Atmel Applications Engineer, living in Trondheim, Norway and working on LUFA in my spare time. + * 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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ExportingLibrary.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ExportingLibrary.txt new file mode 100644 index 000000000..65d7fc923 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ExportingLibrary.txt @@ -0,0 +1,106 @@ +/** \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_ExportingLibrary Exporting the Library for IDE Use + * + * While LUFA was designed to allow for easy compilation in a makefile driven environment, + * it is possible to export the library into a form suitable for drop-in use inside of an + * IDE. + * + * \section Sec_LibraryExport Exporting the Library + * An export of the library is at its most basic, a direct copy of the main "LUFA" source folder from the + * root download folder; this contains the library core which can be re-used within external projects. + * However, as many IDEs attempt to automatically compile all included source files, it is neccesary to + * exclude some directories and files from the library core export to allow for easier integration into + * an IDE project. + * + * \subsection SSec_ManualExport Manual Export + * To manually export the library core, copy over the main LUFA library folder from the LUFA root directory, + * renaming as desired. Within the library core folder, the following directories should be removed or + * excluded from your IDE import: + * - Documentation/ + * - DoxygenPages/ + * - CodeTemplates/ + * + * If required, files from the CodeTemplates/ subdirectory may be copied to your IDE project as needed. + * + * The resulting copy of the library may then be imported into your chosen IDE according to the instructions + * shown in \ref Sec_LibraryImport. + * + * \subsection SSec_AutomaticExport Automatic Export + * If desired, the steps indicated in \ref SSec_ManualExport may be automatically performed, by running the + * command make export_tar from the command line. This will generate two .tar files in the + * current directory, named LUFA_YYMMDD.tar and LUFA_YYMMDD_Code_Templates.tar (where + * "YYMMDD" is the version of the library being exported). The first archive contains the exported LUFA core + * with the non-required files removed, while the second contains an archived copy of the code template files + * for the current LUFA version. + * + * The resulting archived copy of the library may then be extracted to your chosen IDE project source directory + * and imported according to the instructions shown in \ref Sec_LibraryImport. + * + * \section Sec_LibraryImport Importing the Library + * An exported copy of the library may be imported wholesale into an IDE project, if the instructions detailed + * in \ref Sec_LibraryExport are followed. + * + * Specific instructions for importing an exported version of LUFA into various IDEs are listed below. + * + * \subsection SSec_AS56_Import Importing into AVRStudio 5/Atmel Studio 6 + * To import LUFA into a new or existing project, the following steps must be followed. + * + * \subsubsection SSSec_AS56_Import_Step1 Copy over the exported library + * Copy over the exported library archive created via the steps listed in \ref Sec_LibraryExport to your AS5/AS6 + * project directory. + * + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step1.png + * + * \subsubsection SSSec_AS56_Import_Step2 Extract exported library + * Extract out the contents of the archive to a new folder. This may be any name you wish, however keep in mind + * that this name will need to be referenced within your user application under most circumstances. It is + * suggested that this folder be named "LUFA", or "LUFA" followed by the version string for easy reference. + * + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step2.png + * + * \subsubsection SSSec_AS56_Import_Step3 Add the library files + * Open your AVRStudio 5/Atmel Studio 6 project. From the "Solution Explorer" pane, click the "Show All Files" + * button on the toolbar to display ghosted icons of files and folders located in the project source directory + * that are not currently added to the project. + * + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step3.png + * + * Right-click the ghosted version of the extracted LUFA export folder in the Solution Explorer pane, and + * choose the "Add to Project" option from the context menu. This will add the entire LUFA source tree to the + * current project. + * + * \subsubsection SSSec_AS56_Import_Step4 Open Project Toolchain Properties + * In the Solution Explorer pane, click the project node, and press the "Properties" button in the toolbar to + * open the Project Properties window. This window allows you to configure the various project global compiler, + * assembler and linker options. + * + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step4.png + * + * Click the "Toolchain" tab on the left side of the Project Properties window. + * + * \subsubsection SSSec_AS56_Import_Step5 Configure Project Toolchain Properties + * + * In the GNU C Compiler section, open the "Symbols" page. Click the "Add Item" button to the top-right of the + * "Defined Symbols" section to add new symbols. + * + * At a minimum, you will need to define the following symbols (for more information on these symbols, see + * \ref Page_ConfiguringApps): + * - ARCH + * - F_CPU + * - F_USB + * - BOARD + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step5_1.png + * + * Next, open the GNU C Compiler section's "Optimization" page. Ensure that the option to prepare functions for + * garbage collection is enabled. + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step5_2.png + * + * Finally, in the GNU C Linker section, open the "Optimization" page. Ensure that the option to garbage collect + * unused sections is selected. + * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step5_3.png + */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/FutureChanges.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/FutureChanges.txt new file mode 100644 index 000000000..9660a473a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/FutureChanges.txt @@ -0,0 +1,49 @@ +/** \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 + * -# Re-add interrupt Pipe/Endpoint support + * -# Update stream APIs to use DMA transfers on supported architectures + * -# Pull out third party libraries into a separate folder and reference them as required + * -# Add a LUFA_YIELD macro for integration into a third-party RTOS + * -# Abstract out Mass Storage byte send/receive to prevent low level API use in projects + * -# Fix HID report parser usage support for array types + * -# Make HOST_DEVICE_SETTLE_DELAY_MS a global variable that can be changed + * -# Add MANDATORY_EVENT_FUNCTIONS compile time option + * -# Add watchdog support to the library and apps/bootloaders + * - Testing/Verification + * -# Re-run USBIF test suite on all classes to formally verify operation + * -# Implement automated functional testing of all demos + * - Documentation/Support + * -# Add detailed overviews of how each demo works + * -# Add board overviews + * -# Write LUFA tutorials + * - Demos/Projects + * -# Device/Host USB bridge + * -# Finish incomplete demos and projects + * -# Add class driver support for Test and Measurement class + * -# Add class driver support for EEM class + * -# Add class driver support for ECM class + * -# Add class driver generic HID report host demo + * -# Implement flow control for USB to Serial project + * - Ports + * -# Port all demos to multiple architectures + * -# Finish USB XMEGA port + * -# Add AVR32 UC3C, UC3D and UC3L support + * -# Atmel ARM7 series microcontrollers + * -# Other (commercial) C compilers + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/GettingStarted.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/GettingStarted.txt new file mode 100644 index 000000000..b62a7cae1 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/GettingStarted.txt @@ -0,0 +1,25 @@ +/** \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. + * + * 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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Groups.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Groups.txt new file mode 100644 index 000000000..3a3509d3f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Groups.txt @@ -0,0 +1,38 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** \defgroup Group_BoardDrivers Board Drivers + * + * Functions, macros, variables, enums and types related to the control of physical board hardware. + */ + +/** \defgroup Group_PeripheralDrivers On-chip Peripheral Drivers + * + * Functions, macros, variables, enums and types related to the control of AVR subsystems. + */ + +/** \defgroup Group_MiscDrivers Miscellaneous Drivers + * + * Miscellaneous driver Functions, macros, variables, enums and types. + */ + +/** \defgroup Group_PlatformDrivers_AVR8 AVR8 + * \ingroup Group_PlatformDrivers + * + * Drivers relating to the AVR8 architecture platform, such as clock setup and interrupt management. + */ + +/** \defgroup Group_PlatformDrivers_XMEGA XMEGA + * \ingroup Group_PlatformDrivers + * + * Drivers relating to the XMEGA architecture platform, such as clock setup and interrupt management. + */ + +/** \defgroup Group_PlatformDrivers_UC3 UC3 + * \ingroup Group_PlatformDrivers + * + * Drivers relating to the UC3 architecture platform, such as clock setup and interrupt management. + */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step1.png b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step1.png new file mode 100644 index 0000000000000000000000000000000000000000..4f0c26f374ca20ea74c22fc47a66264cb8d1897a GIT binary patch literal 98201 zcmV)jK%u{hP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv0094gNklFL9_=| zlQ4OKOzt)(?dywu5R;mm{%*MQA$STLbL??PA9L(?jz0FtqmKFZQO6wqoudysk_lFD ziqo0OPt@sOmr_d*y2bUO zD}st~rQ&iZdMJMSM;?CUkw<)o5EI^%dHq z7gDLGKmGmrn}u2?DUh1v5ok#KLgy|$T7r;lW1}r-B$BGLXR7E^D7KUpNnNb zgpYKu^u}ZKsU}?b8z#*ssxzi%|TSPw`uUh`LWp4}7?a}QFpi6q=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R37aUkgK7`h6Hqx9JCKJCZMa@R0#)}itI68p7{qo6^90L0P?cXx zYC1#8ci(Q0X87B(^PV&4z7TOX&O0NPbfkWi+DtL!8x?Vb#9@2lvulIYC3LCV8VImN z?ct|fS0O^0%#?&Xkwp5_esnN;)$6@ZOyIbGSUjwsN+cqu{ z`@e#n4=tzrCY-4(G^t}~_VqmT|IuX_@uH937b~<9+hdE+%e;YcEqo?iR8r-wNoxV2 ztwWmP*Y65EJm;$&+Iz6O$=J&nU`tnT%fXf?J*sfhY8)v-o%dpKiE)Z}n0v0t5>tNF z`E}JrG>wzR_r1~_>WlmL*2#~_uTyZs+H!A_Ju>FA>WYtjsssQzU9BT#{tfjVmqE{u zC9lmd#g6lUs=z(#P<;w)}BFg#YFEG^SF^<22P YNg#YQXZJ!({000eE2zt(WnTsU57kNqO#lD@ literal 0 HcmV?d00001 diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step2.png b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step2.png new file mode 100644 index 0000000000000000000000000000000000000000..6e309ae4151a4e02a859aca3a48319dd43807a2b GIT binary patch literal 100532 zcmV)@K!LxBP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02*{fSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+qQF!XYv0094gNklG% z&d%(&J3F&8_GCwbfW-zUJdAB@V{Bs#HVB(+l1P$35=rDNl0e2J5d&c5J;Q!12P_9H2P_9H2P_9H2P_9H2P_9H2P_B1nFF`na?1k`Jg|82;`iTwf7Pm0 zC*l9sUw{4Sr=P}sPe1+irAwC{o$$|*iTWI#1fN4A_#8fT=2U>JoW)T#_mmrpBzct(^26NOj=(mQQKSy9$rV z%6xD{AKzP>&GUWOfL%ID#*U1oqhV&MEcD*X)#lM~FCdd`u^=2kM_hmX^`jXZzSq9; z$}3}A=i*zh8`}y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X$1e@kp#woqPHGYFaAsMc=9j_%>=&lz#bNgqgU>KyO%JFv0cBgc@1dTo|Nm*!?Zb@z*|^p+m+ z+IEuNXz9e?3!QT2k)) z4;T%nH0R!!nTLO=9;OxuA3i4mlu$+Szvb^9U~v28uR|JFuDy;(0R6f>U^HM}Gjg5f@Lx#-tI8?yPg-)>j(TITZ#du^u8q zLMMGDWc2LOQs5>{*A0__Q>nUgwpo|#c2w7v2|vCV|Zlz;p(2hJRCm(REUm9K3m zc|%=+ptBNdy1*u|nJ-|) zXG8Y9mLY$^GX78DkcT_ObjY~1G)q?Q-aYoauRHiqW1{>?KCcyrjSs~yn#1ff`%&1s zvM<->s9Hb0QQn)Ojp5^9=AlBl0m@uga!< z#=Bx*IFmK>>CBqo6z(EL53tMFBNH?F`^isn@DW<*xk{=jm?@@R$0bC`tV=J>2>;*Q_3xl%yWB^r&uT(4Y{= zvaH?nX`yiy-z5IU6@LjK%5k3)iWs*uxj9tt;D~vj`#dFMIW99;sdtHILgSS>IA~cz zq5(lp+*9ks$x=>p0%+ExTR-jjUqSc75Y`z0r22d0uROzbBFy5T2foLf0b28~lO71!?-`gtjeE>v zfq`t#U_@ij6Cs7K+cQN4qNAAkHU}P1dHib@{IKqm2A$)7Px8Na^1qMkf8WXf2A=;$ z*S!lm|6M}!aJ1U~5v_J~fddjSXRM+(T2bbA?Y#+JAMxnp)$(?o|_#<;i;da)o HhtK{GPaXat literal 0 HcmV?d00001 diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_2.png b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_2.png new file mode 100644 index 0000000000000000000000000000000000000000..078f4ec8d7b3b3920c1a65a7b0b52d8fbee3b7d9 GIT binary patch literal 28918 zcma&NbzD?m_xFt;Agz?72+}DjFoZ~p4mos5jdTy4f<=jR3=Koq(5-Y0(lexV4Itfc zkKgOMe(`#q=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- literal 0 HcmV?d00001 diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_3.png b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/AS5_AS6_Import/AS5_AS6_Import_Step5_3.png new file mode 100644 index 0000000000000000000000000000000000000000..8a8571bd86868ef9a1bfb12214138c17221c4bd8 GIT binary patch literal 23561 zcmb5WWmH^Qw*`s>x8Uv?T!IuX!QF!e2<}k01rNas3s!h=3jqR!CJ>)P?ytM=ci(v9z8?%mRh=zopS9MWYp%IZoQ{?<9yS#=5)u-gs>(AxBqS6KBqU@@ zOcca7LbZ=15&w|A^_1n2>c?qz5g#5o$Z5(UAvLDp{I*6ze8%!rG4V!1!tZ~ zv_*VL<)irAN8iKV$KM)ghooce!J{Uxki`VL4pJ(p;xt z$sCEMJ9fcu-)F|VjPE7@`~GuF5|_?bxC9(XXhldQ;V7hrMP()PF(Z*EI!M^E$Q(Z? z8Da^L5kDY48WhNG9#KV;%p zMZ-kLVIEb7es*~&iZoO+>;o;v!_6`%J&b;~x0zK>O7Ru{^736%<}E?RHX&K1A8 zrJ2IY<#9THS!c@cFsh=8>D}3*X@4HqRk4vJT>69hTy1NT$B zH$W;yudA!ubjf!Oi2H9W zmz4rB_pbO%YwCh(covm~JbfO+-P=AF_5Jc`6($gs8|yoy5&U=z5cK^xLg9BCO}_#1 zS$oDN#~goZ8pW73zoMTf!bNtf90AM#&|1JUNl96g;9?nxy@m!qvKUtljKgUdMCUq5 z>&dZaie;Ulnt39J+j$-ZVqPyv;PyQ;LLuWtQ49{jevve^3CnSwXB)xnNp&3z?cIf)!g4>o|PH6&bq8jVNO3<;9>iCZT23{Q+f9Un4DvHfzv-&fFU&-R(-NbtcZ zyCT@W`t66JUe4kCi^}HOOGV<1)#pZb+AARk;ADJpU8R~F{f{90)cV>@^@59x9nr*t z1DRJp1=%EuWl2d?FaT_@!`3xAG>8d~KaG^l*J6hG)m8UZPAkIXJ5@e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{V4lb-Co;ZY!zwHYS<`KKISF!l_!Dh@WLby%9qmtB7TGNVAvR2#jW>b@M zi*D`O{{TK){%rii{iL$ONXEA@M|f2ZZ!2WN0V%yWp67RO8Lcq z)sHOy00LjMmw_yFuZn&*HrFlXTx%CszC%OuMlRJZnh~~Pl?^EafS?W(4gp1ZnCAJY zyX$B9#O}g3YLBj;l0I0QMT|=0&f!^r{lqQYl1Y#^IVYwEImU8HMHR<(zpv}D+LE$o F|JfK#>ahR- literal 0 HcmV?d00001 diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/LUFA.png b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Images/LUFA.png new file mode 100644 index 0000000000000000000000000000000000000000..54fa1a66433491cb4b8cd9f5cdc6269f928f901c GIT binary patch literal 10296 zcmd^FWltPjw;kMy7pFY9YZ=^KibK&tq1X)W?poY!aCdi#yEC}M3{G(?QfS}a-*H#6 z&QA7+lPxPNImwCAP*cFhB*z2*0N6^3vReP*%s&pGBmFy#3Wllw1!QX}RVe_VF#+q< z3H3MthN zE7uDx(g`im3oF(ME7K0I(2c4w2rJf)s4$GKF^p?4N^CYtY%xh}`jXsclGbS+oE{Jq z^ewg;lu%`w&|sBRZH_`@P^$f{u2x_BI1G-6vaW>-9FUovV_I$={WYgYxeuUT-YTXJkzb}AcnE*p2N z7;~!}_bVUvs~q*Moph;RbgEzStcM0POgS~KxHT-gHLZBItT;EVxiznOw5<6yEqFIC zd$+6xw61uyuKBgC1$1nLgoZ{$#r#8Za&ksyW=>8{NM3VjK}%?HXLNB(R9RY9=;nXVz<{w_67$d;9x)M<&|F<{M@=TIM&pmbZJ? zb_*upMbigmQ+uV;du6kSl~eGlX?W%ALG28@dj6;mx>pZ9XqbgJLg9@Ihs{ezE%Wf! zg@e|mqo(DP*5#9qMOeq;LDw>@Yx%He1>U`K)VXrfy9Vo9JMQoAA0C?+9iN<>oEn{m zPR&B+pwPvorR9~im5r^~sg@N)8T0>$H|Jpcf@TqRj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B58)~2oCawGm>9(0 z)y9;ye43?o{4|_(F3L3tMcUUWnr@BazzyP|w&eM-4fI1LQNC_iB!uS+UP(}VG; z8L;0R#a@$xLs%kcpe>jJHtZ{IiAYg({A^K}S&W;YSS{O=b^XK7PZjqC=58npNa0Ae zlt!G1n0r(QiA~JQ2bhDor&YGUZ^}2lJoe_>lrwVEFC$WAXICe>r-8zd_L_Rn+=!-p z^hYETm%W9?p(CX&N6uDv{P5B+-{O|y`#pJe?|pTqw2{J@)mVWTQFBb;iB4t)6;^Xx zYWjCtP3z*7hNS>B*F6sv=zbiLCjS=Mz3nyiq^3E#?w$F@Q)z1Z2QPX}OZvR^7Zh)< vJukl!k*!rlms!_uFMNe_Z%KDziEjQs7wj~q(VKa+00000NkvXXu0mjf=ph;q literal 0 HcmV?d00001 diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/KnownIssues.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/KnownIssues.txt new file mode 100644 index 000000000..0d63a03d0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/KnownIssues.txt @@ -0,0 +1,44 @@ +/** \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_KnownIssues Known Issues + * The following are known issues present in each official LUFA release. This list should contain all known + * issues in the library. Most of these issues should be corrected in the future release - see + * \ref Page_FutureChanges for a list of planned changes in future releases. + * + * \section Sec_KnownIssues120730 Version 120730 + * - AVR8 Architecture + * - No known issues. + * - UC3 Architecture + * \warning The UC3 device support is currently experimental (incomplete and/or non-functional), and is included for preview purposes only. \n + * + * - No demos, bootloaders or projects have been ported for the UC3 devices in the current release, + * although the architecture is supported in the LUFA core library. + * - DMA transfers to and from the USB controller are not yet implemented for this release. + * - The UC3C, UC3D and UC3L sub-families of UC3 are not currently supported by the library due to their + * altered USB controller design. + * - The various \c CreateStream() functions for creating standard \c compatible virtual file + * streams are not available on the UC3 architecture, due to a lack of suitable library support. + * - XMEGA Architecture + * \warning The XMEGA device support is currently experimental (incomplete and/or non-functional), and is included for preview purposes only. + * + * - No demos, bootloaders or projects have been ported for the XMEGA devices in the current release, + * although the architecture is supported in the LUFA core library. + * - Endpoints of more than 64 bytes are not currently supported in this release. + * - Isochronous endpoints are not currently supported in this release. As a result, the audio class + * cannot be used on XMEGA devices. + * - Multiple-bank endpoints are not currently supported in this release. + * - Early revisions of the ATXMEGA128A1U are incompatible with LUFA, due to their various errata + * relating to the USB controller. + * - Architecture Independent + * - The HID parser fails for array type elements that have a MIN and MAX usage applied; each element + * in the array will receive a unique incrementing usage from the MIN value, up to MAX. + * - The LUFA library is not watchdog aware, and thus timeouts are possible if short periods are used + * and a lengthy USB operation is initiated. + * - Build System + * - No known issues. + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LUFAPoweredProjects.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LUFAPoweredProjects.txt new file mode 100644 index 000000000..c3bf3db9d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LUFAPoweredProjects.txt @@ -0,0 +1,181 @@ +/** \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. + * + * \li AVR-USB-162, a USBKEY-like development board for the AT90USB162: http://olimex.com/dev/avr-usb-162.html + * \li Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/wiki/benito + * \li Duce, the sucessor to the Benito #7: http://dorkbotpdx.org/wiki/duce + * \li JM-DB-U2, an ATMEGA32U2 development board: http://u2.mattair.net/index.html + * \li Micropendous, an open design/source set of AVR USB development boards: http://micropendous.org/ + * \li Microsin AVR-USB162 breakout board, a DIY AT90USB162 development board: http://microsin.ru/content/view/685/44/ + * \li Minimus USB, a board specially designed for PSGroove: http://www.minimususb.com/ + * \li Nanduino, a do-it-yourself AT90USB162 board: http://www.makestuff.eu/wordpress/?page_id=569 + * \li Sparkfun ATMEGA8U2 breakout board: http://www.sparkfun.com/products/10277 + * \li Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html + * \li U2DIL/U4DIL, a set of DIP layout USB AVR boards: http://www.reworld.eu/re/en/products/u2dil/ + * \li USB2AX, a tiny USB to serial converter board: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX + * \li 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. + * + * \li Accelerometer Game Joystick: http://www.crictor.co.il/he/episodes/joystick/ + * \li Arcade Controller: http://fletchtronics.net/arcade-controller-made-petunia + * \li Arcade Joystick: http://jamie.lentin.co.uk/embedded/arcade-joystick/ + * \li AttoBasic AVR BASIC interpreter: http://www.cappels.org/dproj/AttoBasic2_1/AttoBasic_2.1_with_USB_and_Arduino_support.html + * \li AVR USB Modem, a 3G Wireless Modem host: http://code.google.com/p/avrusbmodem/ + * \li Bicycle POV: http://www.code.google.com/p/bicycleledpov/ + * \li Bluetooth Explorerbot: http://code.google.com/p/bluetooth-explorerbot/ + * \li Bus Ninja, an AVR clone of the popular BusPirate project: http://blog.hodgepig.org/busninja/ + * \li CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig + * \li CD Driver Emulator Dongle for ISO Files: http://cdemu.blogspot.com/ + * \li ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/ + * \li Collection of alternative Arduino Uno firmwares: http://hunt.net.nz/users/darran/ + * \li Computer controlled LED matrix (Russian): http://we.easyelectronics.ru/AVR/nebolshoy-primer-s-lufa-hidapi.html + * \li CULFW, a 868MHz RF packet encoder/decoder: http://www.koeniglich.de/culfw/culfw.html + * \li Dashkey, a custom PC keyboard controller: http://geekhack.org/showwiki.php?title=Island:19096 + * \li DIY PS3 controller emulator: https://code.google.com/p/diyps3controller/ + * \li EMuSer, a USB-RS422 adapter for E-Mu samplers: http://www.emxp.net/EMuSer.htm + * \li Estick JTAG, an ARM JTAG debugger: http://code.google.com/p/estick-jtag/ + * \li "Fingerlicking Wingdinger" (WARNING: Bad language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/ + * \li Flyatar, a real-time fly tracking system: https://github.com/peterpolidoro/Flyatar + * \li FootJoy, a 22 button, 6-axis josystick with keyboard and mouse modes: https://bitbucket.org/sirbrialliance/foot-joy/ + * \li Gamecube controller to USB adapter: https://www.facebook.com/media/set/?set=a.10150202447076304.310536.688776303&l=df53851c50 + * \li Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master + * \li Generic HID Device Creator: http://generichid.sourceforge.net/ + * \li Generic HID Open Source Framework: http://www.waitingforfriday.com/index.php/USB_Generic_HID_Open_Source_Framework_for_Atmel_AVR_and_Windows + * \li Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/ + * \li GPS enabled lap timer for vehicles: http://www.assembla.com/code/ironlung/subversion/nodes/trunk/LapTimer + * \li Hardware Volume Control: https://github.com/davidk/hw-volume-control + * \li Hiduino, a USB-MIDI replacement firmware for the Arduino Uno: http://code.google.com/p/hiduino/ + * \li Ikea RGB LED USB modification: http://slashhome.se/p/projects/id/ikea_dioder_usb/#project + * \li IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html + * \li Jukebox panic button: http://thinkl33t.co.uk/the-panic-button + * \li LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm + * \li Linux Secure Storage Dongle: http://github.com/TomMD/teensy + * \li LUFA powered DDR dance mat (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:ddr_repair + * \li MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g + * \li MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster + * \li MIDI Theremin: http://baldwisdom.com/usb-midi-controller-theremin-style-on-arduino-uno/ + * \li MIDI interface hack of a toy Guitar: http://blog.x37v.info/2011/06/26/toy-guitar-hacked-midi-conroller + * \li MiniBloq, a graphical Ardunio programming environment : http://minibloq.org/ + * \li MiXley, a port of the Teacup 3D printer firmware for the USB AVRs: http://codaset.com/michielh/mixley + * \li Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3 + * \li Moco, a native Arduino Uno MIDI replacement firmware: http://web.mac.com/kuwatay/morecat_lab./MocoLUFA.html + * \li Motherboard BIOS flasher: http://www.coreboot.org/InSystemFlasher + * \li Multi-button Joystick (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:joystick + * \li Music Playing Alarm Clock (Tutorial): http://www.instructables.com/id/Music-Playing-Alarm-Clock/ + * \li Nehebkau, Laptop Controlled Keyboard and Mouse: http://www.frank-zhao.com/cache/nehebkau.php + * \li NeroJTAG, a JTAG dongle: https://github.com/makestuff/neroJtag + * \li NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm + * \li Nikon wireless camera remote control (Norwegian): http://hekta.org/~hpe1119/ + * \li Opendous-JTAG, an open source ARM JTAG debugger: http://code.google.com/p/opendous-jtag/ + * \li Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/ + * \li Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm + * \li PPM signal generator over USB: https://github.com/G33KatWork/USBPPM + * \li Programmable keyboard controller: http://41j.com/blog/2011/10/a-programmable-keyboard-controller/ + * \li Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/ + * \li PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove + * \li PS/2 to USB adapter: https://github.com/makestuff/p2ukbd + * \li Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ + * \li RFPirate, a RF experimentation platform: https://github.com/ebuller/RF-Pirate + * \li RF Transciever using the MRF49XA: http://alternet.us.com/?page_id=1494 + * \li SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/ + * \li SDR1, a Software Defined Radio firmware: https://code.google.com/p/sdr-mk1/ + * \li SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 + * \li Serial Line bus analyser: http://www.pjrc.com/teensy/projects/SerialAnalyzer.html + * \li SNES custom FLASH ROM: http://electrifiedfoolingmachine.co/?page_id=633 + * \li Smartcard Detective: https://code.google.com/p/smartcarddetective/ + * \li SmartportVHD Apple II Mass Storage adapter: http://pcedric3.free.fr/SmartportVHD/ + * \li Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/ + * \li Simple USB LED Controller: https://github.com/scottbez1/sulc + * \li Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/ + * \li Stylophone, with USB MIDI connectivity: http://www.waitingforfriday.com/index.php/Stylophone_Studio_5 + * \li Teensy SD Card .WAV file player: http://elasticsheep.com/2010/04/teensy2-usb-wav-player-part-1/ + * \li Touchscreen Input Device: http://capnstech.blogspot.com/2010/07/touchscreen-update.html + * \li UDFS, a BBC Micro USB disk filing system: https://github.com/makestuff/udfs + * \li Universal USB AVR Module: http://usbavr.bplaced.net/ + * \li USB2AX, a USB to Dynamixel network adapter: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX + * \li USB Infrared Receiver/Transmitter: http://vaton4.web2001.cz/ + * \li USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001 + * \li USB MIDI to DMX controller: http://github.com/hanshuebner/miDiMX + * \li USB powered Geiger Counter: http://uhrheber.wordpress.com/2011/04/28/a-usb-powered-geiger-counter-for-the-z2-and-other-computers/ + * \li Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/ + * \li Wireless MIDI Guitar system: http://www.ise.pw.edu.pl/~wzab/wireless_guitar_system/ + * \li Xnormidi, a C MIDI library: http://x37v.info/projects/xnormidi + * \li XUM1541, a Commodore 64 floppy drive to USB adapter: http://www.root.org/~nate/c64/xum1541/ + * \li Zeus, a touch screen computer for music manipulation: http://www.benbengler.com/developments_zeus.html + * + * \section Sec_LUFACommercialProjects Projects Using LUFA (Commercial) + * + * The following is a list of known commercial products using LUFA. Some of these are open source, although many are "black-box" + * solutions with no source code given. Those companies which have purchased a Commercial License to LUFA (see \ref Page_LicenseInfo) + * are not listed here unless specifically requested. + * + * \li Arduino Uno, the official Arduino board: http://www.arduino.cc + * \li ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en + * \li AsTeRICS assistive technologies project, HID actuator: http://www.asterics.eu + * \li Ceberus, a MadCatz Xbox 360 arcade stick modifier: http://www.phreakmods.com/products/cerberus + * \li CFFA3000, a CompactFlash interface for the Apple II: http://www.dreher.net/CFforAppleII + * \li Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/ + * \li FinchRobot, a robot designed for educational use: http://www.finchrobot.com/ + * \li HummingBird Kit, a robotics learning platform: http://www.hummingbirdkit.com/ + * \li Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR + * \li PIR-1, an IR control interface for consumer electronics: http://www.promixis.com/pir-1.php + * \li PIR-4, a USB Connected 4 port IR transmitter: http://promixis.com/pir-4.php + * \li KeyGlove, an alternative input system: http://www.keyglove.net/ + * \li Many of Busware's Products: http://www.busware.de/ + * \li MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/ + * \li Norduino, a wireless Arduino: http://norduino.robomotic.com/norduino-is-now-usb-hid/ + * \li Olimex AVR-ISP-MK2, an AVRISP-MKII Clone AVR Programmer: https://www.olimex.com/dev/avr-isp-mk2.html + * \li Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org + * \li RFI21.1EU UHF RFID reader: http://www.metra.cz/rfid/uhf-rfid-ctecky/rfi21-1eu-uhf-rfid-ctecka.htm + * \li SmartCardDetective, a Smart Card analysis tool: http://www.smartcarddetective.com/ + * \li USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php + * \li UDS18B20 USB Temperature sensor: http://toughlog.org/uds18b20/ + * \li VMeter, a USB MIDI touch strip controller: http://www.vmeter.net/ + * \li XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/ + * \li Zeptoprog, a multifunction AVR programmer: http://www.mattairtech.com/index.php/featured/zeptoprog.html + * + * \section Sec_LUFAPublications Publications Mentioning LUFA + * The following are published magazines which have either mentioned or featured the LUFA library. + * + * \li Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue + * \li Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue + * \li Elektor Magazine, "20 x Open Source" by Jens Nickel, March 2010 Issue + * \li Circuit Cellar Magazine, "Advanced USB Design Debugging" by Collin O'Flynn, August 2010 Issue + * + * \section Sec_LUFANotableMentions Other Notable Mentions of LUFA + * The following are non-magazine but notable mentions of the LUFA library. + * + * \li Adafruit "Ask an Engineer", 7th November 2010 + * \li Arduino 2010 Keynote speech + * \li The Amp Hour podcast blog #11 + * \li Blackhat 2011 conference, "Exploiting USB Devices with Arduino" + * + * \section Sec_PortsAndForks Non-Official LUFA Ports and Forks + * The following are unofficial forks of the LUFA codebase, which implement different features such as support for + * additional architectures. + * + * \li NXP's official "nxpusblib" LUFA fork, for LPC devices: http://www.lpcware.com/content/project/nxpusblib + * \li Kevin Mehall's LUFA port to the NXP LPC13xx: https://github.com/kevinmehall/LUFA-LPC13xx + * + */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LibraryResources.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LibraryResources.txt new file mode 100644 index 000000000..a85d59c16 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LibraryResources.txt @@ -0,0 +1,34 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_Resources Library Resources + * + * \section Sec_UnofficialResources Unofficial Resources + * Unofficial Russian LUFA documentation translation: http://microsin.ru/Download.cnt/doc/LUFA/ \n + * Tutorial for LUFA USB Control Transfers: http://www.avrbeginners.net/new/tutorials/usb-control-transfers-with-lufa/ + * + * \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 + * Support Mailing List: http://www.lufa-lib.org/support \n + * Author's Email: dean [at] fourwalledcubicle [dot] com \n + * + * \section Sec_InDevelopment Latest In-Development Source Code + * Issue Tracker: http://www.lufa-lib.org/tracker \n + * Public SVN Repository: http://www.lufa-lib.org/svn \n + * Public GIT Repository: 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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LicenseInfo.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/LicenseInfo.txt new file mode 100644 index 000000000..091ce9431 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/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/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MainPage.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MainPage.txt new file mode 100644 index 000000000..ce351ad3e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MainPage.txt @@ -0,0 +1,52 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \mainpage + * + * \image html Images/LUFA.png + *

+ * \n + * + * \n + * + * LUFA is donationware. For author and donation information, see \ref Page_Donating. + * + * LUFA is an open-source USB library for the USB-enabled AVR microcontrollers, released under the MIT license (see \ref Page_LicenseInfo). + * It supports a large number of USB AVR models and boards (see \ref Page_DeviceSupport). It is designed to provide an easy to use, + * feature rich framework for the development of USB peripherals and hosts. + * + * LUFA focuses on the microcontroller side of USB development only; it includes no PC host USB driver development facilities - other projects + * such as the Windows Driver Development Kit, Windows USB Device Mode Framework and libusb may be of interest for developing custom OS drivers. + * While custom USB devices can be made with LUFA using such tools, the included demos all use the inbuilt OS drivers for each USB class for + * simplicity. + * + * The library is currently in a stable release, suitable for download and incorporation into user projects for + * both host and device modes. For information about the project progression, see the blog link at \ref Page_Resources. + * + * LUFA is written specifically for the free AVR-GCC compiler, and uses several GCC-only extensions to make the + * library API more streamlined and robust. You can download AVR-GCC for free in a convenient windows package, + * from the the WinAVR website (see \ref Page_Resources). + * + * The only required AVR peripherals for LUFA is the USB controller itself and interrupts - LUFA does not require the use of the + * microcontroller's timers or other hardware, leaving more hardware to the application developer. + * + * Accompanying LUFA in the download package is a set of example demo applications, plus several Bootloaders of different classes + * and open source LUFA powered projects. + * + * Subsections: + * \li \subpage Page_LicenseInfo - Project source license and commercial use information + * \li \subpage Page_Donating - Donating to support this project + * \li \subpage Page_DeviceSupport - Current Device and Hardware Support + * \li \subpage Page_ChangeLog - Project Changelog + * \li \subpage Page_KnownIssues - Known Issues + * \li \subpage Page_FutureChanges - Planned Changes to the Library + * \li \subpage Page_GettingStarted - Getting started with LUFA + * \li \subpage Page_DevelopingWithLUFA - Developing with LUFA + * \li \subpage Page_LUFAPoweredProjects - Other Projects Using LUFA + * \li \subpage Page_Resources - LUFA and USB Related Resources + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MigrationInformation.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MigrationInformation.txt new file mode 100644 index 000000000..7a08ad23c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/MigrationInformation.txt @@ -0,0 +1,674 @@ +/** \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_Migration120730 Migrating from 120219 to 120730 + * Device Mode + * - The device mode Audio Class driver now requires an additional configuration parameter, the Audio Control interface index. Existing applications should + * be adjusted to specify the additional configuration parameter. + * - The HID_DESCRIPTOR_JOYSTICK() macro no longer takes a variable number of axis as a parameter, due to OS incompatibilities; this macro now uses a fixed + * 3 axis of data. User applications should update their calls to this macro and their report structures to suit a fixed 3-axis joystick report. If a user + * application requires more than 3 axis' of data, a custom report descriptor will need to be constructed by hand. + * - The \ref Endpoint_ConfigureEndpoint() function no longer takes in masks for the banks and direction; the number of banks is now an integer argument, and + * the direction is obtained from the full endpoint address within the device. Applications calling Endpoint_ConfigureEndpoint() should update their API + * call to use a full endpoint address (including ENDPOINT_DIR_IN or ENDPOINT_DIR_OUT direction in the MSB of the endpoint address) and an integer number + * of banks. + * - All endpoint functions now operate on full endpoint addresses within the device, rather than a directionless endpoint index. Applications should update + * their API calls to use full endpoint addresses when required within the device. + * - All device mode class drivers have been updated to use a new unified endpoint description structure for all endpoints; existing applications will need + * to update their class driver struct instantiation to match the new scheme (see \ref USB_Endpoint_Table_t). + * - The \c ENDPOINT_BANKS_SUPPORTED() and \c ENDPOINT_MAX_ENDPOINT_SIZE() macros have been removed, as these do not function correctly with the new addressing + * scheme for the endpoint APIs. Please refer to the target device's datasheet for the maximum bank size of each endpoint. + * - The MIDI class driver \ref MIDI_EventPacket_t event packet no longer contains seperate \c CableIndex and \c Command entries; these have been combined + * into a single \c Event element which can be contructed using the new macro \ref MIDI_EVENT(). Existing applications should use the new macro and structure + * element name. + * + * Host Mode + * - The Android Accessory Host class driver property strings are now a array of \c char* rather than a struct of named pointers. Existing applications + * should use C99 Designated Initializers with the property string indexes located in \ref AOA_Strings_t instead. + * - The \ref Pipe_ConfigurePipe() function no longer takes in masks for the banks and token; the number of banks is now an integer argument, and the token + * is now inferred from the full pipe address within the device, and the pipe type. Applications calling Pipe_ConfigurePipe() should update their API + * call to use a full pipe address (including PIPE_DIR_IN or PIPE_DIR_OUT direction in the MSB of the pipe address) and an integer number of banks. + * - All pipe functions now operate on full pipe addresses within the device, rather than a directionless pipe index. Applications should update their API + * calls to use full pipe addresses when required within the device. + * - All host mode class drivers have been updated to use a new unified pipe description structure for all pipes; existing applications will need to update + * their class driver struct instantiation to match the new scheme (see \ref USB_Pipe_Table_t). + * - The MIDI class driver \ref MIDI_EventPacket_t event packet no longer contains seperate \c CableIndex and \c Command entries; these have been combined + * into a single \c Event element which can be contructed using the new macro \ref MIDI_EVENT(). Existing applications should use the new macro and structure + * element name. + * - The library "LUFA/Drivers/USB/Core/ConfigDescriptor.c" source file has been renamed "LUFA/Drivers/USB/Core/ConfigDescriptors.c" as this was clashing with + * files in some low level host mode demo applications, preventing parallel project builds. If you are referencing the project source files directly instead + * of using the makefile module names, you will need to adjust your project makefile. + * + * \section Sec_Migration120219 Migrating from 111009 to 120219 + * USB Core + * - The HID_KEYBOARD_MODIFER_* macros in the HID class driver have been corrected to HID_KEYBOARD_MODIFIER_* (note the spelling of "modifier"). + * Existing applications should switch over to the correctly spelled macro names. + * - The names of the USB Device and USB Host class driver files have changed; a new "ClassDevice" and "ClassHost" postfix has been added to the + * respective class driver files. Projects referencing the class driver source files by filename rather than the LUFA_SRC_USBCLASS makefile + * variable should append these postfixes to the source file names. Projects including the USB class driver dispatch headers directly should either + * switch to including the main USB driver header instead, or use the updated header filenames. + * - The USB_CONFIG_ATTR_BUSPOWERED constant has been renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed. All devices must set this bit in + * the Configuration descriptor's attributes field. As all devices are assumed to be bus-powered unless stated otherwise with the + * USB_CONFIG_ATTR_SELFPOWERED flag a replacement constant for bus powered devices is not provided. + * + * Device Mode + * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetInterfaceProperty(). + * Existing applications must implement this new callback, however if no audio entities are defined in the audio device's descriptors, + * this function may be hard-coded to always return false for previous behaviour to be retained. + * + * \section Sec_Migration111009 Migrating from 110528 to 111009 + * Non-USB Library Components + * - The \c JTAG_DEBUG_ASSERT() macro has been renamed \ref JTAG_ASSERT() to be consistent with \ref STDOUT_ASSERT(). + * + * USB Core + * - By default, unordered Endpoint and Pipe configuration is now allowed once again, via the previous workaround of + * reconfiguring all Endpoints/Pipes in order each time a new Endpoint/Pipe is created. To minimize the compiled program + * size, the new \c ORDERED_EP_CONFIG compile time option may be defined in the project makefile to restrict the ordering + * in exchange for a smaller compiled binary size. + * - The previous \c F_CLOCK symbol, required in the project makefile, has been renamed to \c F_USB. This is due to the previous name + * being far too generic for use in future architecture ports, where multiple clock domains are used. + * + * Device Mode + * - The Endpoint stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter. + * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes + * processed in the current transaction can be stored. If the \c BytesProcessed parameter is non \c NULL, each time the endpoint + * bank becomes full and the packet is sent, the routine will exit with the new \ref ENDPOINT_RWSTREAM_IncompleteTransfer + * error code to allow the user application to determine when to send the next chunk of data. + * - The \ref CDC_Device_SendString() function now expects a null terminated string instead of an explicit length. Existing code + * should use the new \ref CDC_Device_SendData() function, or remove the length parameter from the function call. + * - The \c Endpoint_ResetFIFO() function has been renamed to \ref Endpoint_ResetEndpoint(), to make the API function names more + * consistent. Existing applications using the old function name should simply replace it with a call to the new function name. + * - The \c Endpoint_*_Byte() functions have been renamed Endpoint_*_8() to ensure they are correct across all architectures. Existing + * code using these functions should replace the previous function names with the new function names. + * - The \c Endpoint_*_Word() functions have been renamed Endpoint_*_16() to ensure they are correct across all architectures. Existing + * code using these functions should replace the previous function names with the new function names. + * - The \c Endpoint_*_DWord() functions have been renamed Endpoint_*_32() to ensure they are correct across all architectures. Existing + * code using these functions should replace the previous function names with the new function names. + * - The Device mode RNDIS class driver no longer stores the incoming and outgoing packets in the class driver instance; the user is + * now expected to manually define a storage location for the packet data. Packets must now be sent and received manually via a call + * to \ref RNDIS_Device_ReadPacket() and/or \ref RNDIS_Device_SendPacket(). + * - The definition of the Audio class \ref USB_Audio_Descriptor_Format_t has been altered, to remove the fixed singular + * audio sample rate in the descriptor definition, and to rename the \c SampleFrequencyType to the more appropriate + * \c TotalDiscreteSampleRates. Existing applications will need to add an array of \ref USB_Audio_SampleFreq_t elements + * immediately following any \ref USB_Audio_Descriptor_Format_t descriptors, and insert the appropriate sampling rates + * supported by the device, as well as rename the descriptor elements to match the updated element names. + * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetEndpointProperty(). + * Existing applications must implement this new callback, however if multiple sample rates or pitch control is not used, + * this function may be hard-coded to always return false for previous behaviour to be retained. + * - The \c USB_ConfigurationNumber, \c USB_RemoteWakeupEnabled and \c USB_CurrentlySelfPowered globals have been renamed to + * \ref USB_Device_ConfigurationNumber, \ref USB_Device_RemoteWakeupEnabled and \ref USB_Device_CurrentlySelfPowered to clearly indicate + * the USB mode they relate to. Existing applications using these variables should rename all references to the previous names. + * - The \c ENDPOINT_DESCRIPTOR_DIR_IN and \c ENDPOINT_DESCRIPTOR_DIR_OUT macros have now been replaced by \ref ENDPOINT_DIR_IN and + * \ref ENDPOINT_DIR_OUT to improve code clarity. + * - The \ref HID_DESCRIPTOR_JOYSTICK() macro now takes an additional (first) parameter indicating the number of axis in the joystick. + * + * Host Mode + * - The Pipe stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter. + * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes + * processed in the current transaction can be stored. If the BytesProcessed parameter is non \c NULL, each time the pipe + * bank becomes full and the packet is sent, the routine will exit with the new \ref PIPE_RWSTREAM_IncompleteTransfer + * error code to allow the user application to determine when to send the next chunk of data. + * - The \ref PRNT_Host_SendString() and \ref CDC_Host_SendString() functions now expect a null terminated string instead of an explicit + * length. Existing code should use the new \ref PRNT_Host_SendData() and \ref CDC_Host_SendData() functions, or remove the + * length parameter from the function call. + * - The \c Pipe_ClearErrorFlags() function has been removed, as the pipe error flags are now automatically cleared when the + * \ref Pipe_ClearError() function is called. + * - The \c Pipe_*_Byte() functions have been renamed Pipe_*_8() to ensure they are correct across all architectures. Existing code using + * these functions should replace the previous function names with the new function names. + * - The \c Pipe_*_Word() functions have been renamed Pipe_*_16() to ensure they are correct across all architectures. Existing code using + * these functions should replace the previous function names with the new function names. + * - The \c Pipe_*_DWord() functions have been renamed Pipe_*_32() to ensure they are correct across all architectures. Existing code using + * these functions should replace the previous function names with the new function names. + * - The \c USB_Host_ClearPipeStall() function has been renamed to USB_Host_ClearEndpointStall(), as it operates on a full endpoing address + * within the attached device and not a pipe within the host. Existing code using the old function name should update the function calls and + * check for correct usage. + * + * \section Sec_Migration101122 Migrating from 100807 to 101122 + * USB Core + * - A new USB driver source file, \c Drivers/USB/HighLevel/EndpointStream.c now exists. This source file should be added + * to all project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source + * variables. + * - A new USB driver source file, \c Drivers/USB/HighLevel/PipeStream.c now exists. This source file should be added to all + * project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables. + * - The \c EVENT_USB_InitFailure() event has been removed, as the \ref USB_Init() function will no longer fail; if not USB mode is + * specified, the controller will default to UID selection mode. + * - The USB mode specifier constants have been moved into a new enum and renamed. Existing projects should use the equivalent + * value in the new \ref USB_Modes_t enum. + * - All class driver headers are now included as part of the standard \c LUFA/Drivers/USB/USB.h master dispatch header, and should + * no longer be included separately. Class driver module source files must still be added as a separate module in the project's + * makefile if used. + * + * Device Mode + * - Endpoints MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application + * allocated endpoints in ascending order - or if your application uses the USB device mode class drivers, ensure that each instance's + * endpoint indexes are not overlapped with other interface's endpoints. + * - The signature for the \ref CALLBACK_USB_GetDescriptor() callback has changed, the \c void** \c const \c DescriptorAddress parameter is + * now \c const \c void** \c const \c DescriptorAddress. Existing applications should update their callback signatures to match this, and + * eliminate any casting of descriptor pointers to a non \c const pointer. + * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation + * for each class driver for the new class specific descriptor type names. + * - The \c ENDPOINT_DOUBLEBANK_SUPPORTED() macro is has been renamed \c ENDPOINT_BANKS_SUPPORTED() and now returns the total number of + * banks supported by the given endpoint. Existing code should switch to the new naming scheme, and test that the return value of the + * macro is equal to or greater than 2 to regain the previous functionality. + * - The \c EVENT_USB_Device_UnhandledControlRequest() event is now named \ref EVENT_USB_Device_ControlRequest() and fires before (not after) + * the internal library event handlers. Existing code should rename the event handlers in the user application to match the new event + * name, and should ensure that the new execution order does not affect the application's operation. + * + * Host Mode + * - Pipes MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application + * allocated pipes in ascending order - or if your application uses the USB host mode class drivers, ensure that each instance's + * pipe indexes are not overlapped with other interface's pipes. + * - The \c PRNT_Host_SendData() function has been renamed to \ref PRNT_Host_SendString(). Existing applications should simply + * replace all references to the obsolete function name with the new function name. + * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation + * for each class driver for the new class specific descriptor type names. + * - The Still Image Host class' function prefix has been changed from \c SImage_ to \c SI_, to remain consistent with the rest of the + * driver's enums, type defines and constants. + * + * \section Sec_Migration100807 Migrating from 100513 to 100807 + * + * Non-USB Library Components + * - The Dataflash board driver stub file has changed, as dataflash functions previously located in the internal + * Dataflash driver of the library have now been moved to the individual board files. Existing drivers can + * copy-paste the new functions from the board Dataflash stub driver. + * + * USB Core + * - A new USB driver source file, \c Drivers/USB/LowLevel/Device.c now exists. This source file should be added to all project + * makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables. + * - The \c Drivers/USB/LowLevel/DevChapter9.c source file has moved to \c Drivers/USB/HighLevel/DeviceStandardReq.c - this should + * be updated in all project makefiles, or the makefile should be updated to use the new module source variables. + * - The \c Drivers/USB/LowLevel/HostChapter9.h source file has moved to \c Drivers/USB/HighLevel/HostStandardReq.c - this should + * be updated in all project makefiles, or the makefile should be updated to use the new module source variables. + * - The \c Drivers/USB/LowLevel/LowLevel.c source file has moved to \c Drivers/LowLevel/USBController.c - this should be updated + * in all project makefiles, or the makefile should be updated to use the new module source variables. + * + * Device Mode + * - The \c USB_Device_IsRemoteWakeupSent() macro has been removed, as the remote wakeup request is now fully handled by the + * enhanced \ref USB_Device_SendRemoteWakeup() function. Existing code may now discard any checks to \c USB_Device_IsRemoteWakeupSent(). + * - The \c USB_Device_IsUSBSuspended() macro has been removed, as it is obsolete. Existing code should compare \ref USB_DeviceState + * to see if it the device is in the \ref DEVICE_STATE_Suspended state instead. + * - The \ref CDC_Device_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was + * received. This allows for more efficient coding, as a call to \ref CDC_Device_BytesReceived() is no longer needed if the exact + * number of queued bytes received is not needed. + * + * Host Mode + * - The \ref CDC_Host_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was + * received. This allows for more efficient coding, as a call to \ref CDC_Host_BytesReceived() is no longer needed if the exact + * number of queued bytes received is not needed. + * - The \ref CDC_Host_USBTask() now calls \ref CDC_Host_Flush() automatically, flushing any queued data to the attached device. Manual + * flushing of the interface is no longer needed if the flushes should be in sync with calls to \ref CDC_Host_USBTask(). + * + * \section Sec_Migration100513 Migrating from 100219 to 100513 + * + * Non-USB Library Components + * - The \ref TWI_StartTransmission() function now takes in a timeout period, expressed in milliseconds, within which the addressed + * device must respond or the function will abort. + * + * Device Mode + * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need + * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible + * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process + * functions correctly. + * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel. + * Projects must update their makefile SRC values accordingly. + * - The HID Device Class driver's function signature for the \ref CALLBACK_HID_Device_ProcessHIDReport() function has been changed, to + * allow for a new \c ReportType parameter. This new parameter must be added in all user applications using the Device mode HID Class + * Driver, but may be ignored unless Host-to-Device FEATURE HID reports are used. + * + * Host Mode + * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need + * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible + * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process + * functions correctly. + * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel. + * Projects must update their makefile \c SRC values accordingly. + * - The HID Host Class driver's function signature for the \ref HID_Host_SendReportByID() function has been changed, to allow for a new + * ReportType parameter. Existing calls to this function should substitute \c REPORT_ITEM_TYPE_Out as this parameter's value. + * + * \section Sec_Migration100219 Migrating from 091223 to 100219 + * + * Non-USB Library Components + * - Due to some ADC channels not being identical to their ADC MUX selection masks for single-ended conversions on some AVR models, + * the ADC driver now has explicit masks for each of the standard ADC channels (see \ref Group_ADC). These masks should be used + * when calling the ADC functions to ensure proper operation across all AVR models. Note that the \ref ADC_SetupChannel() function + * is an exception, and should always be called with a channel number rather than a channel mask. + * + * Host Mode + * - The MIDI Host Class driver send and receive routines now operate on packed events, where multiple MIDI events may be + * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send + * pipe bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually + * flush the queued event(s) to the device by calling \ref MIDI_Host_Flush(). + * - The \ref Pipe_IsEndpointBound() function now takes the endpoint's direction into account, by checking if the MSB of the endpoint's address + * is set to denote IN endpoints. If the previous functionality where the direction is to be discounted is required, mask the endpoint + * address against the \ref PIPE_EPNUM_MASK token before calling \ref Pipe_IsEndpointBound(). + * + * Device Mode + * - The MIDI Device Class driver send and receive routines now operate on packed events, where multiple MIDI events may be + * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send + * endpoint bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually + * flush the queued event(s) to the host by calling \ref MIDI_Device_Flush(). + * + * \section Sec_Migration091223 Migrating from 091122 to 091223 + * + * Host Mode + * - The Still Image Host Class driver \ref SI_Host_USBTask() and \ref SI_Host_ConfigurePipes() functions were misnamed, and are + * now named \c SImage_Host_USBTask() and \c SImage_Host_ConfigurePipes() respectively. + * - The \c HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to \ref HOST_SENDCONTROL_DeviceDisconnected to be in + * line with the rest of the library error codes. + * - The HID Parser item usages no longer contain separate minimum and maximum values, as this was a violation of the HID + * specification. Instead, the values are distributed evenly across each item as its usage value, to ensure that all items + * can be distinguished from one-another. + * + * Device Mode + * - The \ref CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new \c ReportType parameter to + * indicate the report type to generate. Existing applications may simply add and ignore this additional parameter. + * + * \section Sec_Migration091122 Migrating from 090924 to 091122 + * + * Host Mode + * - The \c HID_PARSE_UsageStackOverflow HID parser error constant is now named \ref HID_PARSE_UsageListOverflow + * - The \ref CALLBACK_HIDParser_FilterHIDReportItem() HID Parser callback now passes a complete \ref HID_ReportItem_t to the + * user application, instead of just its attributes. + * - The \c USB_GetDeviceConfigDescriptor() function was incorrectly named and is now called \ref USB_Host_GetDeviceConfigDescriptor(). + * + * \section Sec_Migration090924 Migrating from 090810 to 090924 + * + * Non-USB Library Components + * - The \c ADC_Off() function has been renamed to \c ADC_ShutDown() to be consistent with the rest of the library. + * - The \ref SPI_Init() routine's parameters have changed, so that the clock polarity and data sampling modes can be set. See + * the \ref SPI_Init() function documentation for more details + * - The \ref Dataflash_Init() routine no longer initializes the SPI bus - the SPI bus should be initialized manually via a + * call to \ref SPI_Init() before using the Dataflash driver + * + * Host Mode + * - The \c USB_GetDeviceConfigDescriptor() function's parameters and behaviour has changed; the user is required to + * preallocate the largest allowable buffer, and pass the size of the buffer to the function. This allows for a single + * call to the function to retrieve, size check and validate the Configuration Descriptor rather than having the user + * application perform these intermediary steps. + * - The HID report parser now requires a mandatory callback in the user code, to filter only the items the application + * is interested in into the processed HID report item structure to save RAM. See \ref CALLBACK_HIDParser_FilterHIDReportItem(). + * - The HID report parser now always parses FEATURE and always ignores constant-data items - the \c HID_ENABLE_FEATURE_PROCESSING + * and \c HID_INCLUDE_CONSTANT_DATA_ITEMS compile time tokens now have no effect. + * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_* + * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in + * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants. + * + * Device Mode + * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_* + * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in + * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants. + * + * \section Sec_Migration090810 Migrating from 090605 to 090810 + * + * All + * - The "Simple Scheduler" has been deprecated, as it was little more than an abstracted loop and caused much confusion. + * User applications using the scheduler should switch to regular loops instead. The scheduler code will be removed in a future + * release. + * - The "Dynamic Memory Block Allocator" has been removed, as it was unused in (and unrelated to) the LUFA library and never + * used in user applications. + * + * Non-USB Library Components + * - The \c ATTR_NOINLINE function attribute macro has been renamed to \ref ATTR_NO_INLINE to be in line with the rest of the function attribute + * macro names. + * + * Library Demos + * - Most demos now have a corresponding Class Driver implementation, which uses the new internal library class drivers for the standard + * USB classes. This allows for more rapid device and host development, and so should be used in preference to the low level APIs where + * possible so that fixes to the class drivers propagate to all applications which use them automatically with each new LUFA release. + * + * Host Mode + * - The \c HIDParser.c module has moved from \c LUFA/Drivers/USB/Class/ to \c LUFA/Drivers/USB/Class/Host/. + * - The \c USB_GetDeviceConfigDescriptor() function now requires the desired configuration index within the device as its first + * parameter, to add support for multi-configuration devices. Existing code should use a configuration index of 1 to indicate the + * first configuration descriptor within the device. + * - The non-standard "Ready" host state has been removed. Existing \ref HOST_STATE_Configured code should be moved to the end of + * the existing \ref HOST_STATE_Addressed state, and the existing HOST_STATE_Ready state code should be moved to the \ref HOST_STATE_Configured + * state. + * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_HostState explicitly to ensure the host is + * in the desired state instead. + * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode + * events. See the \ref Group_Events page for details on the new event names and firing conditions. + * + * Device Mode + * - The \ref CALLBACK_USB_GetDescriptor() function now takes an extra parameter to specify the descriptor's memory space so that + * descriptors in mixed memory spaces can be used. The previous functionality can be returned by defining the \c USE_FLASH_DESCRIPTORS + * token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter. + * - The \c USB_IsSuspended global has been removed - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead. + * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_DeviceState explicitly to ensure the device + * is in the desired state instead. + * - The VBUS events have been removed, as they are already exposed to the user via the \c USB_Connect and \c USB_Disconnect events. + * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode + * events. See the \ref Group_Events page for details on the new event names and firing conditions. + * + * \section Sec_Migration090605 Migrating from 090510 to 090605 + * + * Device Mode + * - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing + * projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can + * manage the control endpoint via interrupts automatically by compiling with the \c INTERRUPT_CONTROL_ENDPOINT token defined. + * - The \c DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory + * address. + * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See + * \ref Group_Events for new API details. + * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular + * function signatures of a function accepting no arguments and returning a \c uint8_t value. + * - The \c Event_DeviceError() event no longer exists, as its sole caller (unlinked \c USB_GetDescriptor() function) now produces a + * compilation error rather than a runtime error. The \c StdDescriptors.c file no longer exists as a result, and should be removed + * from project makefiles. + * - The \c USB_GetDescriptor() function has been renamed to \ref CALLBACK_USB_GetDescriptor() to be in line with the new \c CALLBACK_ + * function prefixes for functions which must be implemented in the user application. + * + * Host Mode + * - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing + * projects using interrupts on non-control pipes should switch to polling. + * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See + * \ref Group_Events for new API details. + * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular + * function signatures of a function accepting no arguments and returning a \c uint8_t value. + * - The \c DESCRIPTOR_COMPARATOR() macro has been removed. User applications should replace all instances of the macro with + * regular function signatures of a function accepting a void pointer to the descriptor to test, and returning a \c uint8_t value. + * + * \section Sec_Migration090510 Migrating from 090401 to 090510 + * + * All + * - The \c ButtLoadTag.h header has been removed, as it was never used for its intended purpose. Projects should either remove all + * \c BUTTLOADTAG() elements, or download and extract \c ButtLoadTag.h header from the ButtLoad project. + * - The \c Drivers/AT90USBXXX/ directory has been renamed to \c Drivers/Peripheral/. + * - The \c Serial_Stream driver has been renamed to \c SerialStream to remain consistent with the rest of the library naming scheme. + * - The HWB driver has changed to the \c Buttons driver. See the board Buttons driver documentation for the new API. + * + * Dual Role Mode + * - The \c USB_PowerOnFail event has been renamed to \c USB_InitFailure. + * - The functions in \c OTG.h have been renamed to remain more consistent with the library API. See the functions in \c OTG.h for more + * details. + * + * Device Mode + * - The \c Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the \ref Endpoint_ClearIN(), \ref Endpoint_ClearOUT() + * macros. See \c Endpoint.h documentation for more details on the new endpoint management macros. + * - The \c Endpoint_ReadWriteAllowed() macro has been renamed to \ref Endpoint_IsReadWriteAllowed() to be more consistent with the rest of + * the API naming scheme. + * - The \c Endpoint_IsSetupINReady() and \c Endpoint_IsSetupOUTReceived() macros have been renamed to \ref Endpoint_IsINReady() and + * \ref Endpoint_IsOUTReceived() respectively. + * - The \c Endpoint_IsSetupReceived() macro has been renamed to \ref Endpoint_IsSETUPReceived(). + * - The \c Endpoint_ClearSetupReceived() macro has been renamed to \ref Endpoint_ClearSETUP(). + * - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Endpoint_Read_Word()) have + * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions. + * - The \c USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of + * the Control Request header as all Control Request header data is now preloaded by the library and made available in the + * USB_ControlRequest structure. + * - The \c FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to \c CONTROL_ONLY_DEVICE. + * - The \c STATIC_ENDPOINT_CONFIGURATION is no longer applicable as the library will apply this optimization when appropriate automatically. + * - The values of the \ref Endpoint_Stream_RW_ErrorCodes_t and \ref Endpoint_ControlStream_RW_ErrorCodes_t enums have had the \c ERROR_ portion + * of their names removed. + * + * Host Mode + * - The \ref USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on + * other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called + * in existing projects where the Control pipe is to be operated on. + * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer + * need to manage this manually when calling the USB management task. + * - The \c Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT() macros. See + * Pipe.h documentation for more details on the new pipe management macros. + * - The \c Pipe_ReadWriteAllowed() macro has been renamed to \ref Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API + * naming scheme. + * - The \c Pipe_IsSetupINReceived() and \c Pipe_IsOutReady() macros have been renamed to \ref Pipe_IsINReceived() and \ref Pipe_IsOUTReady() + * respectively. + * - The new \ref Pipe_ClearSETUP() macro should be used to send SETUP transactions, rather than the previous \c Pipe_ClearSetupOUT() macro. + * - The \c Pipe_IsSetupSent() macro has been renamed to \ref Pipe_IsSETUPSent(). + * - The \c Pipe_ClearSetupSent() macro is no longer applicable and should be removed. + * - All pipe read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Pipe_Read_Word()) have + * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions. + * - The \c Host_IsResetBusDone() macro has been renamed to \c Host_IsBusResetComplete(). + * - The \c Pipe_Ignore_Word() and \c Pipe_Ignore_DWord() functions have been renamed to \c Pipe_Discard_Word() and \c Pipe_Discard_DWord() + * to remain consistent with the rest of the pipe API. + * - It is no longer needed to manually include the headers from \c LUFA/Drivers/USB/Class, as they are now included along with the rest + * of the USB headers when \c LUFA/Drivers/USB/USB.h is included. + * - Functions in the \c ConfigDescriptor.h header file no longer have \c Host_ as part of their names. + * - The \c ProcessHIDReport() has been renamed to \ref USB_ProcessHIDReport(), \c GetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo() + * and \c SetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo(). + * - The values of the \ref DSearch_Return_ErrorCodes_t and \ref DSearch_Comp_Return_ErrorCodes_t enums have had their respective \c Descriptor_Search + * and \c Descriptor_Search_Comp prefixes changed to all caps. + * - The \c USB_HostRequest global has been renamed to \ref USB_ControlRequest, and is used in Device mode also. The \c USB_Host_Request_Header_t + * structure type has been renamed to \ref USB_Request_Header_t. + * - The values of the \ref Pipe_Stream_RW_ErrorCodes_t enum have had the \c ERROR_ portion of their names removed. + * + * \section Sec_Migration090401 Migrating from 090209 to 090401 + * + * All + * - LUFA projects must now give the raw input clock frequency (before any prescaling) as a compile time constant \c F_USB, + * defined in the project makefile and passed to the compiler via the -D switch. + * - The makefile EEPROM programming targets for FLIP and dfu-programmer no longer program in the FLASH data in addition to the + * EEPROM data into the device. If both are to be programmed, both the EEPROM and FLASH programming targets must be called. + * - As the avr-libc macro has been corrected in recent avr-libc distributions, the \c SetSystemClockPrescaler() macro has been removed. + * Include \c and call \c clock_prescale_set(clock_div_1); instead on recent avr-libc distributions. + * + * Library Demos + * - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission. + * + * Non-USB Library Components + * - The \c ATTR_ALWAYSINLINE function attribute macro has been renamed to \ref ATTR_ALWAYS_INLINE. + * - Custom board Dataflash drivers now require the implementation of \ref Dataflash_SelectChipFromPage() and \ref Dataflash_SendAddressBytes(). + * + * Device Mode + * - The \c NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to \c FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded + * to also remove parts of the Get Status chapter 9 request to further reduce code usage. On all applications currently using the + * \c NO_CLEARSET_FEATURE_REQUEST compile time token, it can be replaced with the \c FEATURELESS_CONTROL_ONLY_DEVICE token with no further + * modifications required. + * + * \section Sec_Migration090209 Migrating from 081217 to 090209 + * + * Device Mode + * - The \c ENDPOINT_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c ENDPOINT_TOTAL_ENDPOINTS. + * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user + * makefile if desired to restore the previous 50ms timeout. + * + * Host Mode + * - The \c PIPE_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c PIPE_TOTAL_ENDPOINTS. + * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user + * makefile if desired to restore the previous 50ms timeout. + * - The \c USB_DeviceEnumerationFailed event now contains a second \c SubErrorCode parameter, giving the error code of the function + * which failed. + * - The \c HID_PARSE_Sucessful enum member constant name has been corrected to \ref HID_PARSE_Successful. + * + * Non-USB Library Components + * - The previous \c SPI_SendByte() functionality is now located in \ref SPI_TransferByte(). \ref SPI_SendByte() now discards the return byte + * for speed, to compliment the new \ref SPI_ReceiveByte() function. If bidirectional SPI transfers are required, calls to \ref SPI_SendByte() + * should be changed to \ref SPI_TransferByte(). + * - The serial driver now sets the Tx line as an output explicitly, and enables the pull-up of the Rx line. + * - The \ref Serial_Init() and \c SerialStream_Init() functions now take a second \c DoubleSpeed parameter, which indicates if the USART + * should be initialized in double speed mode - useful in some circumstances for attaining baud rates not usually possible at the given AVR + * clock speed. + * + * \section Sec_Migration171208 Migrating from V1.5.3 to 081217 + * + * All + * - The MyUSB project name has been changed to LUFA (Lightweight Framework for USB AVRs). All references to MyUSB, including macro names, + * have been changed to LUFA. + * + * Library Demos + * - The ReconfigureUSART() routine in the USBtoSerial demo was not being called after new line encoding + * parameters were set by the host. Projects built on the USBtoSerial code should update to the latest version. + * - The HID Parser now supports multiple report (on a single endpoint) HID devices. The MouseHostWithParser and + * KeyboardHostWithPaser demos use the updated API functions to function correctly on such devices. Projects + * built on either "WithParser" demo should update to the latest code. + * - The RNDIS demo TCP stack has been modified so that connections can be properly closed. It is still not + * recommended that the MyUSB RNDIS demo TCP/IP stack be used for anything other than demonstration purposes, + * as it is neither a full nor a standards compliant implementation. + * + * Non-USB Library Components + * - The Serial_IsCharReceived() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h. + * + * Device Mode + * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask + * to be used in the Options parameter of the USB_Init() function. + * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is + * currently initialized. + * - Interrupts are now disabled when processing control requests, to avoid problems with interrupts causing the library + * or user request processing code to exceed the strict USB timing requirements on control transfers. + * - The USB Reset event now resets and disables all device endpoints. If user code depends on endpoints remaining configured + * after a Reset event, it should be altered to explicitly re-initialize all user endpoints. + * - The prototype for the GetDescriptor function has been changed, as the return value was redundant. The function now + * returns the size of the descriptor, rather than passing it back via a parameter, or returns NO_DESCRIPTOR if the specified + * descriptor does not exist. + * - The NO_DESCRIPTOR_STRING macro has been renamed NO_DESCRIPTOR, and is now also used as a possible return value for the + * GetDescriptor function. + * + * Host Mode + * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask + * to be used in the Options parameter of the USB_Init() function. + * - The HID report parser now supports multiple Report IDs. The HID report parser GetReportItemInfo() and + * SetReportItemInfo() routines now return a boolean, set if the requested report item was located in the + * current report. If sending a report to a multi-report device, the first byte of the report is automatically + * set to the report ID of the given report item. + * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is + * currently initialized. + * + * \section Sec_Migration152 Migrating from V1.5.2 to V1.5.3 + * + * Library Demos + * - Previously, all demos contained a serial number string descriptor, filled with all zeros. A serial number + * string is required in Mass Storage devices, or devices which are to retain settings when moved between + * ports on a machine. As people were not changing the serial number value, this was causing conflicts and so + * the serial number descriptor has been removed from all but the Mass Storage demo, which requires it. + * - The AudioOut and AudioIn demos did not previously silence their endpoints when the host has deactivated + * them. Projects built upon either demo should upgrade to the latest code. + * - The FEATURE_ENDPOINT macro has been renamed FEATURE_ENDPOINT_HALT, and is now correctly documented. + * - The MassStoreHost demo contained errors which caused it to lock up randomly on certain devices. Projects built + * on the MassStoreDemo code should update to the latest version. + * - The Interrupt type endpoint in the CDC based demos previously had a polling interval of 0x02, which caused + * problems on some Linux systems. This has been changed to 0xFF, projects built on the CDC demos should upgrade + * to the latest code. + * - The HID keyboard and mouse demos were not previously boot mode compatible. To enable boot mode support, projects + * built on the keyboard or mouse demos (or derivatives) should upgrade to the latest code. + * - The Mass Storage demo was not previously standards compliant. Projects built on the Mass Storage demo should + * upgrade to the latest code. + * - The USART was not being reconfigured after the host sent new encoding settings in the USBtoSerial demo. This was + * previously discovered and fixed, but the change was lost. Projects built on the USBtoSerial demo should update + * to the latest code. + * + * Device Mode + * - The endpoint non-control stream functions now have a default timeout of 50ms between packets in the stream. + * If this timeout is exceeded, the function returns the new ENDPOINT_RWSTREAM_ERROR_Timeout error value. The + * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired + * timeout duration in ms. + * - Rather than returning fixed values, the flags indicating if the device has Remote Wakeup currently enabled + * and/or is self-powered are now accessed and set through the new USB_RemoteWakeupEnabled and + * USB_CurrentlySelfPowered macros. See the DevChapter9.h documentation for more details. + * - All endpoint stream functions now require an extra Callback function parameter. Existing code may be updated + * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing + * the token NO_STREAM_CALLBACKS to the compiler using the -D switch. + * + * Host Mode + * - The pipe non-control stream functions now have a default timeout of 50ms between packets in the stream. + * If this timeout is exceeded, the function returns the new PIPE_RWSTREAM_ERROR_Timeout error value. The + * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired + * timeout duration in ms. + * - CollectionPath_t has been renamed to HID_CollectionPath_t to be more in line with the other HID parser structures. + * - All pipe stream functions now require an extra Callback function parameter. Existing code may be updated + * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing + * the token NO_STREAM_CALLBACKS to the compiler using the -D switch. + * + * \section Sec_Migration151 Migrating from V1.5.1 to V1.5.2 + * + * Library Demos + * - The RNDIS demo application has been updated so that it is functional on Linux under earlier implementations + * of the RNDIS specification, which had non-standard behaviour. Projects built upon the demo should upgrade + * to the latest code. + * - The DFU class bootloader has had several bugs corrected in this release. It is recommended that where + * possible any existing devices upgrade to the latest bootloader code. + * + * \section Sec_Migration150 Migrating from V1.5.0 to V1.5.1 + * + * Library Demos + * - The USBtoSerial demo was broken in the 1.5.0 release, due to incorrect register polling in place of the + * global "Transmitting" flag. The change has been reverted in this release. Projects built upon the demo + * should upgrade to the latest code. + * - The HID class demos did not implement the mandatory GetReport HID class request. Projects built upon the HID + * demos should upgrade to the latest code. + * - The HID class demos incorrectly reported themselves as boot-protocol enabled HID devices in their descriptors. + * Projects built upon the HID demos should upgrade to the latest code. + * - The MIDI device demo had incorrect AudioStreaming interface descriptors. Projects built upon the MIDI demo + * should upgrade to the latest code. + * - The AudioOut demo did not correctly tristate the speaker pins when USB was disconnected, wasting power. + * Projects built upon the AudioOut demo should upgrade to the latest code. + * + * \section Sec_Migration141 Migrating from V1.4.1 to V1.5.0 + * + * Library Demos + * - Previous versions of the library demos had incorrectly encoded BCD version numbers in the descriptors. To + * avoid such mistakes in the future, the VERSION_BCD macro has been added to StdDescriptors.h. Existing + * projects should at least manually correct the BCD version numbers, or preferably update the descriptors to + * encode the version number in BCD format using the new macro. + * - The mandatory GetReport class-specific request was accidentally omitted from previous versions of the demos + * based on the Human Interface Device (HID) class. This has been corrected, and any user projects based on the + * HID demos should also be updated accordingly. + * - The CDC demos now correctly send an empty packet directly after a full packet, to end the transmission. + * Failure to do this on projects which always or frequently send full packets will cause buffering issues on + * the host OS. All CDC user projects are advised to update their transmission routines in the same manner as + * the library CDC demos. + * - The previous interrupt-driven Endpoint/Pipe demos did not properly save and restore the currently selected + * Endpoint/Pipe when the ISR fired. This has been corrected - user projects based on the interrupt driven + * demos should also update to properly save and restore the selected Endpoint/Pipe. + * + * Non-USB Library Components + * - The Atomic.h and ISRMacro.h header files in MyUSB/Common have been removed, as the library is now only + * compatible with avr-libc library versions newer than the time before the functionality of the deleted + * headers was available. + * + * Device Mode + * - The GetDescriptor function (see StdDescriptors.h) now has a new prototype, with altered parameter names and + * functions. Existing projects will need to update the GetDescriptor implementation to reflect the new API. + * The previously split Type and Index parameters are now passed as the original wValue parameter to the + * function, to make way for the USB specification wIndex parameter which is not the same as the + * previous Index parameter. + * - The USB_UnhandledControlPacket event (see Events.h) now has new parameter names, to be in line with the + * official USB specification. Existing code will need to be altered to use the new parameter names. + * - The USB_CreateEndpoints event (see Events.h) has been renamed to USB_ConfigurationChanged, which is more + * appropriate. It fires in an identical manner to the previously named event, thus the only change to be made + * is the event name itself in the user project. + * - The USB_Descriptor_Language_t structure no longer exists in StdDescriptors.h, as this was a + * pseudo-descriptor modeled on the string descriptor. It is replaced by the true USB_Descriptor_String_t type + * descriptor as indicated in the USB specification, thus all device code must be updated accordingly. + * - The names of several Endpoint macros have been changed to be more consistent with the rest of the library, + * with no implementation changes. This means that existing code can be altered to use the new macro names + * with no other considerations required. See Endpoint.h for the new macro names. + * - The previous version of the MassStorage demo had an incorrect value in the SCSI_Request_Sense_Response_t + * structure named SenseData in SCSI.c which caused some problems with some hosts. User projects based on this + * demo should correct the structure value to maintain compatibility across multiple OS platforms. + * - By default, the descriptor structures use the official USB specification names for the elements. Previous + * versions of the library used non-standard (but more verbose) names, which are still usable in the current + * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file + * documentation for more details. + * + * Host Mode + * - The USB_Host_Request_Header_t structure in HostChapter9.h (used for issuing control requests) has had its + * members renamed to the official USB specification names for requests. Existing code will need to be updated + * to use the new names. + * - The names of several Pipe macros have been changed to be more consistent with the rest of the library, + * with no implementation changes. This means that existing code can be altered to use the new macro names + * with no other considerations required. See Pipe.h for the new macro names. + * - By default, the descriptor structures use the official USB specification names for the elements. Previous + * versions of the library used non-standard (but more verbose) names, which are still usable in the current + * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file + * documentation for more details. + * - The names of the macros in Host.h for controlling the SOF generation have been renamed, see the Host.h + * module documentation for the new macro names. + * + * Dual Role Mode + * - The OTG.h header file has been corrected so that the macros now perform their stated functions. Any existing + * projects using custom headers to fix the broken OTG header should now be altered to once again use the OTG + * header inside the library. + * - The USB_DeviceEnumerationComplete event (see Events.h) now also fires in Device mode, when the host has + * finished enumerating the device. Projects relying on the event only firing in Host mode should be updated + * so that the event action only occurs when the USB_Mode global is set to USB_MODE_HOST. + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ProgrammingApps.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ProgrammingApps.txt new file mode 100644 index 000000000..6ff185676 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/ProgrammingApps.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_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, dW or PDI. 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. + * + * 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". + * + * \see \ref Page_BuildModule_DFU for information on the LUFA build system DFU module, for automatic DFU bootloader + * programming makefile targets. + */ diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/SoftwareBootloaderJump.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/SoftwareBootloaderJump.txt new file mode 100644 index 000000000..328466103 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/SoftwareBootloaderJump.txt @@ -0,0 +1,71 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_SoftwareBootloaderStart Entering the Bootloader via Software + * + * A common requirement of many applications is the ability to jump to the programmed bootloader of a chip + * on demand, via the code's firmware (i.e. not as a result of any physical user interaction with the + * hardware). This might be required because the device does not have any physical user input, or simply + * just to streamline the device upgrade process on the host PC. + * + * The following C code snippets may be used to enter the bootloader upon request by the user application. + * By using the watchdog to physically reset the controller, it is ensured that all system hardware is + * completely reset to their defaults before the bootloader is run. This is important; since bootloaders + * are written to occupy a very limited space, they usually make assumptions about the register states based + * on the default values after a hard-reset of the chip. + * + * \section Sec_SoftareBootAVR8 AVR8 Architecture + * The following software bootloader jump code is written for the AVR8 architecture. + * + * \code + * #include + * #include + * #include + * + * #include + * #include + * + * uint32_t Boot_Key ATTR_NO_INIT; + * + * #define MAGIC_BOOT_KEY 0xDC42ACCA + * #define BOOTLOADER_START_ADDRESS (FLASH_SIZE_BYTES - BOOTLOADER_SEC_SIZE_BYTES) + * + * void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3); + * void Bootloader_Jump_Check(void) + * { + * // If the reset source was the bootloader and the key is correct, clear it and jump to the bootloader + * if ((MCUSR & (1 << WDRF)) && (Boot_Key == MAGIC_BOOT_KEY)) + * { + * Boot_Key = 0; + * ((void (*)(void))BOOTLOADER_START_ADDRESS)(); + * } + * } + * + * void Jump_To_Bootloader(void) + * { + * // If USB is used, detach from the bus and reset it + * USB_Disable(); + * + * // Disable all interrupts + * cli(); + * + * // Wait two seconds for the USB detachment to register on the host + * Delay_MS(2000); + * + * // Set the bootloader key to the magic value and force a reset + * Boot_Key = MAGIC_BOOT_KEY; + * wdt_enable(WDTO_250MS); + * for (;;); + * } + * \endcode + * + * Note that the bootloader magic key can be any arbitrary value. The FLASH_SIZE_BYTES and + * BOOTLOADER_SEC_SIZE_BYTES tokens should be replaced with the total flash size of the AVR + * in bytes, and the allocated size of the bootloader section for the target AVR. + * + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Footer.htm b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Footer.htm new file mode 100644 index 000000000..c6de4e64d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Footer.htm @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Style.css b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Style.css new file mode 100644 index 000000000..b0b8464be --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/Style/Style.css @@ -0,0 +1,1123 @@ +@media print + { + #top + { + display:none; + } + + #side-nav + { + display:none; + } + + #nav-path + { + display:none; + } + + body + { + overflow:visible; + } + + h1,h2,h3,h4,h5,h6 + { + page-break-after:avoid; + } + + .summary + { + display:none; + } + + .memitem + { + page-break-inside:avoid; + } + + #doc-content + { + display:inline; + height:auto !important; + margin-left:0 !important; + overflow:inherit; + width:auto !important; + } + + .fragment + { + background-color: #FFFFFF !important; + } +} + +body,table,div,p,dl +{ + font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size:13px; + line-height:1.3; +} + +div.contents p +{ + padding-left:12px; +} + +div.contents table.memberdecls,.paramname +{ + font-family:Consolas, Monaco, courier, sans-serif; + font-size:105%; + padding-right:20px; +} + +.title +{ + font-size:150%; + font-weight:bold; + margin:10px 2px; +} + +h1 +{ + font-size:25px; + margin-bottom:10px; +} + +h2 +{ + color:#42657B; + font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size:17px; +} + +h3 +{ + font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size:15px; +} + +h4 +{ + font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size:13px; +} + +dt +{ + font-weight:bold; +} + +div.multicol +{ + -moz-column-count:3px; + -moz-column-gap:1em; + -webkit-column-count:3px; + -webkit-column-gap:1em; +} + +p.startli,p.startdd,p.starttd +{ + margin-top:2px; +} + +p.endli +{ + margin-bottom:0; +} + +p.enddd +{ + margin-bottom:4px; +} + +p.endtd +{ + margin-bottom:2px; +} + +caption +{ + font-weight:bold; +} + +span.legend +{ + font-size:70%; + text-align:center; +} + +h3.version +{ + font-size:90%; + text-align:center; +} + +div.qindex,div.navtab +{ + background-color:#EAEFF7; + border:1px solid #9EB3DC; + text-align:center; +} + +div.qindex,div.navpath +{ + line-height:140%; + width:100%; +} + +div.navtab +{ + margin-right:15px; +} + +a +{ + color:#355594; + font-weight:normal; + text-decoration:none; +} + +.contents a:visited +{ + color:#3D62AB; +} + +a:hover +{ + text-decoration:underline; +} + +a.qindex +{ + font-weight:bold; +} + +a.qindexHL +{ + background-color:#97ADD9; + border:1px double #7F9BD1; + color:#ffffff; + font-weight:bold; +} + +.contents a.qindexHL:visited +{ + color:#ffffff; +} + +a.el +{ + font-weight:bold; +} + +a.code,a.code:visited +{ + color:#4665A2; +} + +a.codeRef,a.codeRef:visited +{ + color:#4665A2; +} + +dl.el +{ + margin-left:-1cm; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 4px; + margin: 4px; + background-color: #FBFCFD; + border: 1px solid #C4CFE5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + min-height: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; +} + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +div.ah +{ + -moz-border-radius:.5em; + -moz-box-shadow:rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-border-radius:.5em; + -webkit-box-shadow:2px 2px 3px #999; + background-color:black; + background-image:0; + border:solid thin #333; + border-radius:0.5em; + box-shadow:2px 2px 3px #999; + color:#ffffff; + font-weight:bold; + margin-bottom:3px; + margin-top:3px; + padding:0.2em; +} + +div.groupHeader +{ + font-weight:bold; + margin-left:16px; + margin-top:12px; +} + +div.groupText +{ + font-style:italic; + margin-left:16px; +} + +body +{ + background-color:white; + color:black; + margin:0; +} + +div.contents +{ + margin-left:8px; + margin-right:8px; + margin-top:10px; +} + +td.indexkey +{ + background-color:#EAEFF7; + border:1px solid #C1CEE8; + font-weight:bold; + margin:2px 0; + padding:2px 10px; + vertical-align:top; + white-space:nowrap; +} + +td.indexvalue +{ + background-color:#EAEFF7; + border:1px solid #C1CEE8; + margin:2px 0; + padding:2px 10px; +} + +tr.memlist +{ + background-color:#EDF1F8; +} + +p.formulaDsp +{ + text-align:center; +} + +img.formulaInl +{ + vertical-align:middle; +} + +div.center +{ + margin-bottom:0; + margin-top:0; + padding:0; + text-align:center; +} + +div.center img +{ + border:0; +} + +address.footer +{ + padding-right:12px; + text-align:right; +} + +img.footer +{ + border:0; + vertical-align:middle; +} + +span.keyword +{ + color:#008000; +} + +span.keywordtype +{ + color:#604020; +} + +span.keywordflow +{ + color:#e08000; +} + +span.comment +{ + color:#008000; +} + +span.preprocessor +{ + color:#806020; +} + +span.stringliteral +{ + color:#002080; +} + +span.charliteral +{ + color:#008080; +} + +span.vhdldigit +{ + color:#ff00ff; +} + +span.vhdlchar +{ + color:#000000; +} + +span.vhdlkeyword +{ + color:#700070; +} + +span.vhdllogic +{ + color:#ff0000; +} + +blockquote +{ + background-color:#F6F8FC; + border-left:2px solid #97ADD9; + margin:0 24px 0 4px; + padding:0 12px 0 16px; +} + +td.tiny +{ + font-size:75%; +} + +.dirtab +{ + border:1px solid #9EB3DC; + border-collapse:collapse; + padding:4px; +} + +th.dirtab +{ + background:#EAEFF7; + font-weight:bold; +} + +hr +{ + border:none; + border-top:1px solid #4067B4; + height:0; +} + +hr.footer +{ + height:1px; +} + +table.memberdecls +{ + border-spacing:0; + padding:0; +} + +.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,.memTemplItemLeft,.memTemplItemRight,.memTemplParams +{ + background-color:#F9FAFC; + border:none; + margin:4px; + padding:1px 0 0 8px; +} + +.mdescLeft,.mdescRight +{ + color:#555; + padding:0 8px 4px; +} + +.memItemLeft,.memItemRight,.memTemplParams +{ + border-top:1px solid #C1CEE8; +} + +.memItemLeft,.memTemplItemLeft +{ + white-space:nowrap; +} + +.memItemRight +{ + width:100%; +} + +.memTemplParams +{ + color:#3D62AB; + white-space:nowrap; +} + +.memtemplate +{ + color:#3D62AB; + font-size:80%; + font-weight:normal; + margin-left:9px; +} + +.memnav +{ + background-color:#EAEFF7; + border:1px solid #9EB3DC; + margin:2px 15px 2px 2px; + padding:2px; + text-align:center; +} + +.mempage +{ + width:100%; +} + +.memitem +{ + margin-bottom:10px; + margin-right:5px; + padding:0; +} + +.memname +{ + font-weight:bold; + margin-left:6px; + white-space:nowrap; +} + +.memproto,dl.reflist dt +{ + -moz-border-radius-topleft:8px; + -moz-border-radius-topright:8px; + -moz-box-shadow:rgba(0, 0, 0, 0.15) 5px 5px 5px; + -webkit-border-top-left-radius:8px; + -webkit-border-top-right-radius:8px; + -webkit-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); + background-color:#E1E7F4; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + border-left:1px solid #A3B7DE; + border-right:1px solid #A3B7DE; + border-top:1px solid #A3B7DE; + border-top-left-radius:8px; + border-top-right-radius:8px; + box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); + color:#20335A; + font-weight:bold; + padding:6px 0; + text-shadow:0 1px 1px rgba(255, 255, 255, 0.9); +} + +.memdoc,dl.reflist dd +{ + -moz-border-radius-bottomleft:8px; + -moz-border-radius-bottomright:8px; + -moz-box-shadow:rgba(0, 0, 0, 0.15) 5px 5px 5px; + -webkit-border-bottom-left-radius:8px; + -webkit-border-bottom-right-radius:8px; + -webkit-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); + background-color:#FBFCFD; + background-image:0 color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F6F8FC), to(#EDF1F8)); + border-bottom:1px solid #A3B7DE; + border-bottom-left-radius:8px; + border-bottom-right-radius:8px; + border-left:1px solid #A3B7DE; + border-right:1px solid #A3B7DE; + border-top-width:0; + box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15); + padding:2px 5px; +} + +dl.reflist dt +{ + padding:5px; +} + +dl.reflist dd +{ + margin:0 0 10px; + padding:5px; +} + +.paramkey +{ + text-align:right; +} + +.paramtype +{ + white-space:nowrap; +} + +.paramname +{ + color:#602020; + white-space:nowrap; +} + +.paramname em +{ + font-style:normal; +} + +.params,.retval,.exception,.tparams +{ + border-spacing:6px 2px; +} + +.params .paramname,.retval .paramname +{ + font-weight:bold; + vertical-align:top; +} + +.params .paramtype +{ + font-style:italic; + vertical-align:top; +} + +.params .paramdir +{ + font-family:"courier new",courier,monospace; + vertical-align:top; +} + +.ftvtree +{ + font-family:sans-serif; + margin:0; +} + +.directory +{ + font-size:9pt; + font-weight:bold; + margin:5px; +} + +.directory h3 +{ + font-size:11pt; + margin:1em 0 0; +} + +.directory > h3 +{ + margin-top:0; +} + +.directory p +{ + margin:0; + white-space:nowrap; +} + +.directory div +{ + display:none; + margin:0; +} + +.directory img +{ + vertical-align:-30%; +} + +.directory-alt +{ + font-size:100%; + font-weight:bold; +} + +.directory-alt h3 +{ + font-size:11pt; + margin:1em 0 0; +} + +.directory-alt > h3 +{ + margin-top:0; +} + +.directory-alt p +{ + margin:0; + white-space:nowrap; +} + +.directory-alt div +{ + display:none; + margin:0; +} + +.directory-alt img +{ + vertical-align:-30%; +} + +div.dynheader +{ + margin-top:8px; +} + +address +{ + color:#253B67; + font-style:normal; +} + +table.doxtable +{ + border-collapse:collapse; + margin-bottom:4px; + margin-top:4px; +} + +table.doxtable td,table.doxtable th +{ + border:1px solid #273F6D; + padding:3px 7px 2px; +} + +table.doxtable th +{ + background-color:#304D86; + color:#FFFFFF; + font-size:110%; + padding-bottom:4px; + padding-top:5px; +} + +table.fieldtable +{ + -moz-border-radius:4px; + -moz-box-shadow:rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-border-radius:4px; + -webkit-box-shadow:2px 2px 2px rgba(0, 0, 0, 0.15); + border:1px solid #A3B7DE; + border-radius:4px; + border-spacing:0; + box-shadow:2px 2px 2px rgba(0, 0, 0, 0.15); + margin-bottom:10px; + width:100%; +} + +.fieldtable td,.fieldtable th +{ + padding:3px 7px 2px; +} + +.fieldtable td.fieldtype,.fieldtable td.fieldname +{ + border-bottom:1px solid #A3B7DE; + border-right:1px solid #A3B7DE; + vertical-align:top; + white-space:nowrap; +} + +.fieldtable td.fielddoc +{ + border-bottom:1px solid #A3B7DE; + width:100%; +} + +.fieldtable tr:last-child td +{ + border-bottom:none; +} + +.fieldtable th +{ + -moz-border-radius-topleft:4px; + -moz-border-radius-topright:4px; + -webkit-border-top-left-radius:4px; + -webkit-border-top-right-radius:4px; + background-color:#E1E7F4; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + border-bottom:1px solid #A3B7DE; + border-top-left-radius:4px; + border-top-right-radius:4px; + color:#20335A; + font-size:90%; + padding-bottom:4px; + padding-top:5px; + text-align:left; +} + +.tabsearch +{ + background-image:url('tab_b.png'); + font-size:13px; + height:36px; + left:10px; + overflow:hidden; + top:0; + z-index:101; +} + +.navpath ul +{ + background-image:url('tab_b.png'); + background-repeat:repeat-x; + border:solid 1px #BFCCE8; + color:#839ED2; + font-size:11px; + height:30px; + line-height:30px; + margin:0; + overflow:hidden; + padding:0; +} + +.navpath li +{ + background-image:url('bc_s.png'); + background-position:right; + background-repeat:no-repeat; + color:#2F4B83; + float:left; + list-style-type:none; + padding-left:10px; + padding-right:15px; +} + +.navpath li.navelem a +{ + display:block; + height:32px; + outline:none; + text-decoration:none; +} + +.navpath li.navelem a:hover +{ + color:#6081C5; +} + +.navpath li.footer +{ + background-image:none; + background-position:right; + background-repeat:no-repeat; + color:#2F4B83; + float:right; + font-size:8pt; + list-style-type:none; + padding-left:10px; + padding-right:15px; +} + +div.summary +{ + float:right; + font-size:8pt; + padding-right:5px; + text-align:right; + width:50%; +} + +div.summary a +{ + white-space:nowrap; +} + +div.ingroups +{ + font-size:8pt; + margin-left:5px; + padding-left:5px; + text-align:left; + width:50%; +} + +div.ingroups a +{ + white-space:nowrap; +} + +div.header +{ + background-color:#F9FAFC; + background-image:url('nav_h.png'); + background-repeat:repeat-x; + border-bottom:1px solid #C1CEE8; + margin:0; +} + +div.headertitle +{ + padding:5px 5px 5px 7px; +} + +dl +{ + padding:0 0 0 10px; +} + +dl.section +{ + border-left:4px solid; + padding:0 0 0 6px; +} + +dl.note +{ + border-color:#D0C000; +} + +dl.warning,dl.attention +{ + border-color:#FF0000; +} + +dl.pre,dl.post,dl.invariant +{ + border-color:#00D000; +} + +dl.deprecated +{ + border-color:#505050; +} + +dl.todo +{ + border-color:#00C0E0; +} + +dl.test +{ + border-color:#3030E0; +} + +dl.bug +{ + border-color:#C08050; +} + +dl.section dd +{ + margin-bottom:6px; +} + +#projectlogo +{ + border-collapse:separate; + text-align:center; + vertical-align:bottom; + padding-left: 20px; +} + +#projectlogo img +{ + border:0 none; +} + +#projectname +{ + font:280% Arial, sans-serif; + margin:0; + padding-left:20px; +} + +#projectbrief +{ + font:120% Tahoma, Arial, sans-serif; + margin:0; + padding:0; +} + +#projectnumber:before +{ + content:"Version "; +} + +#projectnumber +{ + font:50% Tahoma, Arial, sans-serif; + margin:0; + padding:0; +} + +#titlearea +{ + margin:0; + padding:0; + width:100%; + background-color:#E1E7F4; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + color:#20335A; + font-weight:bold; + text-shadow:0 1px 1px rgba(255, 255, 255, 0.9); +} + +.image +{ + text-align:center; +} + +.dotgraph +{ + text-align:center; +} + +.mscgraph +{ + text-align:center; +} + +.caption +{ + font-weight:bold; +} + +div.zoom +{ + border:1px solid #8AA3D4; +} + +dl.citelist +{ + margin-bottom:50px; +} + +dl.citelist dt +{ + color:#2C477C; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd +{ + margin:2px 0; + padding:5px 0; +} + +div.toc +{ + background-color:#F4F6FB; + border:1px solid #D6DFF0; + border-radius:7px 7px 7px 7px; + float:right; + height:auto; + margin:0 20px 10px 10px; + padding:14px 25px; + width:200px; +} + +div.toc li +{ + background:url("bdwn.png") no-repeat scroll 0 5px transparent; + font:10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top:5px; + padding-left:10px; + padding-top:2px; +} + +div.toc h3 +{ + border-bottom:0 none; + color:#3D62AB; + font:bold 12px/1.2 Arial,FreeSans,sans-serif; + margin:0; +} + +div.toc ul +{ + border:medium none; + list-style:none outside none; + padding:0; +} + +div.toc li.level1 +{ + margin-left:0; +} + +div.toc li.level2 +{ + margin-left:15px; +} + +div.toc li.level3 +{ + margin-left:30px; +} + +div.toc li.level4 +{ + margin-left:45px; +} diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/VIDAndPIDValues.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/VIDAndPIDValues.txt new file mode 100644 index 000000000..ae9c7d44b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/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 VID and PID Allocations + * The LUFA library uses VID/PID combinations generously donated by Atmel. The following VID/PID combinations + * are used within the LUFA demos, and thus may be re-used by derivations of each demo. Free PID values may be + * used by future LUFA demo projects. + * + * These VID/PID values should not be used in commercial designs under any circumstances. Private projects + * may use the following values freely, but must accept any collisions due to other LUFA derived private projects + * sharing identical values. It is suggested that private projects using interfaces compatible with existing + * demos share the same VID/PID value. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
+ * VID + * + * PID + * + * Usage + *
+ * 0x03EB + * + * 0x2040 + * + * Test VID/PID (See below) + *
+ * 0x03EB + * + * 0x2041 + * + * Mouse Demo Application + *
+ * 0x03EB + * + * 0x2042 + * + * Keyboard Demo Application + *
+ * 0x03EB + * + * 0x2043 + * + * Joystick Demo Application + *
+ * 0x03EB + * + * 0x2044 + * + * CDC Demo Application + *
+ * 0x03EB + * + * 0x2045 + * + * Mass Storage Demo Application + *
+ * 0x03EB + * + * 0x2046 + * + * Audio Output Demo Application + *
+ * 0x03EB + * + * 0x2047 + * + * Audio Input Demo Application + *
+ * 0x03EB + * + * 0x2048 + * + * MIDI Demo Application + *
+ * 0x03EB + * + * 0x2049 + * + * MagStripe Project + *
+ * 0x03EB + * + * 0x204A + * + * CDC Bootloader + *
+ * 0x03EB + * + * 0x204B + * + * USB to Serial Demo Application + *
+ * 0x03EB + * + * 0x204C + * + * RNDIS Demo Application + *
+ * 0x03EB + * + * 0x204D + * + * Combined Keyboard and Mouse Demo Application + *
+ * 0x03EB + * + * 0x204E + * + * Dual CDC Demo Application + *
+ * 0x03EB + * + * 0x204F + * + * Generic HID Demo Application + *
+ * 0x03EB + * + * 0x2060 + * + * Benito Programmer Project + *
+ * 0x03EB + * + * 0x2061 + * + * Combined Mass Storage and Keyboard Demo + *
+ * 0x03EB + * + * 0x2062 + * + * Combined CDC and Mouse Demo + *
+ * 0x03EB + * + * 0x2063 + * + * Mass Storage/HID Interface Datalogger Project + *
+ * 0x03EB + * + * 0x2064 + * + * Interfaceless Control-Only LUFA Devices + *
+ * 0x03EB + * + * 0x2065 + * + * Test and Measurement Demo + *
+ * 0x03EB + * + * 0x2066 + * + * Multiple Report Keyboard/Mouse HID Demo + *
+ * 0x03EB + * + * 0x2067 + * + * HID Class Bootloader + *
+ * 0x03EB + * + * 0x2068 + * + * Virtual Serial/Mass Storage Demo + *
+ * 0x03EB + * + * 0x2069 + * + * Webserver Project + *
+ * 0x03EB + * + * 0x206A + * + * Media Control Project + *
+ * 0x03EB + * + * 0x206B + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206C + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206D + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206E + * + * Currently Unallocated + *
+ * 0x03EB + * + * 0x206F + * + * Currently Unallocated + *
+ * + * \section Sec_Test_VIDPID The Test VID/PID Combination + * For use in testing of LUFA powered devices during development only, by non-commercial entities. + * All devices must accept collisions on this VID/PID range (from other in-development LUFA devices) + * to be resolved by using a unique release number in the Device Descriptor. No devices using this + * VID/PID combination may be released to the general public. + */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/WritingBoardDrivers.txt b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/WritingBoardDrivers.txt new file mode 100644 index 000000000..1b3326907 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/DoxygenPages/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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h new file mode 100644 index 000000000..c18054f82 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ADAFRUITU4/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Adafruit U4 Breakout board. + * \copydetails Group_LEDs_ADAFRUITU4 + * + * \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 + * \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). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTE.6
+ * + * @{ + */ + +#ifndef __LEDS_ADAFRUITU4_H__ +#define __LEDS_ADAFRUITU4_H__ + + /* Includes: */ + #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_Disable(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) + { + PINE = LEDMask; + } + + 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h new file mode 100644 index 000000000..3470890b6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel ATAVRUSBRF01. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the Atmel ATAVRUSBRF01. + * + * Board specific Buttons driver header for the Atmel ATAVRUSBRF01. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_ATAVRUSBRF01_H__ +#define __BUTTONS_ATAVRUSBRF01_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h new file mode 100644 index 000000000..17b427155 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/ATAVRUSBRF01/LEDs.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel ATAVRUSBRF01. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Atmel ATAVRUSBRF01. + * + * Board specific LED driver header for the Atmel ATAVRUSBRF01. + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenRX LEDHighPORTD.0
LEDS_LED2RedTX LEDHighPORTD.1
+ * + * @{ + */ + +#ifndef __LEDS_ATAVRUSBRF01_H__ +#define __LEDS_ATAVRUSBRF01_H__ + + /* Includes: */ + #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 << 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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/Buttons.h new file mode 100644 index 000000000..cecaca07e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Tempusdictum Benito. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the Tempusdictum Benito. + * + * Board specific Buttons driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_BENITO_H__ +#define __BUTTONS_BENITO_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h new file mode 100644 index 000000000..dc3d85df2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BENITO/LEDs.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Tempusdictum Benito. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Tempusdictum Benito. + * + * Board specific LED driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito). + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenTX LEDLowPORTC.7
LEDS_LED2RedRX LEDLowPORTC.6
+ * + * @{ + */ + +#ifndef __LEDS_BENITO_H__ +#define __LEDS_BENITO_H__ + + /* Includes: */ + #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 << 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_Disable(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) + { + PINC = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h new file mode 100644 index 000000000..d003680da --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BIGMULTIO/LEDs.h @@ -0,0 +1,161 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Bitwizard Big-Multio. + * \copydetails Group_LEDs_BIGMULTIO + * + * \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_BIGMULTIO BIGMULTIO + * \brief Board specific LED driver header for the Bitwizard Big-Multio. + * + * Board specific LED driver header for the Bitwizard Big-Multio (http://www.bitwizard.nl/wiki/index.php/Usbbigmultio). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1UnknownLED0HighPORTF.6
LEDS_LED2UnknownLED1HighPORTF.7
LEDS_LED3UnknownLED2HighPORTE.2
+ * + * @{ + */ + +#ifndef __LEDS_BIGMULTIO_H__ +#define __LEDS_BIGMULTIO_H__ + + /* Includes: */ + #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_PORTF_LEDS (LEDS_LED1 | LEDS_LED2) + #define LEDS_PORTE_LEDS LEDS_LED3 + #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 second LED on the board. */ + #define LEDS_LED3 (1 << 2) + + /** 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) + { + DDRF |= LEDS_PORTF_LEDS; + DDRE |= LEDS_PORTE_LEDS; + + PORTF &= ~LEDS_PORTF_LEDS; + PORTE &= ~LEDS_PORTE_LEDS; + } + + static inline void LEDs_Disable(void) + { + DDRF &= ~LEDS_PORTF_LEDS; + DDRE &= ~LEDS_PORTE_LEDS; + + PORTF &= ~LEDS_PORTF_LEDS; + PORTE &= ~LEDS_PORTE_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTF |= (LEDMask & LEDS_PORTF_LEDS); + PORTE |= (LEDMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTF &= ~(LEDMask & LEDS_PORTF_LEDS); + PORTE &= ~(LEDMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTF = (PORTF & ~LEDS_PORTF_LEDS) | (LEDMask & LEDS_PORTF_LEDS); + PORTE = (PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTF = (PORTF & ~(LEDMask & LEDS_PORTF_LEDS)) | (ActiveMask & LEDS_PORTF_LEDS); + PORTE = (PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PINF = (LEDMask & LEDS_PORTF_LEDS); + PINE = (LEDMask & LEDS_PORTE_LEDS); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return ((PORTF & LEDS_PORTF_LEDS) | (PORTE & LEDS_PORTE_LEDS)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h new file mode 100644 index 000000000..778bc321e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BLACKCAT/LEDs.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the BLACKCAT USB JTAG. + * \copydetails Group_LEDs_BLACKCAT + * + * \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 + * \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). + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1UnknownLED0HighPORTD.6
LEDS_LED2UnknownLED1HighPORTD.3
+ * + * @{ + */ + +#ifndef __LEDS_BLACKCAT_H__ +#define __LEDS_BLACKCAT_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUI/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUI/LEDs.h new file mode 100644 index 000000000..cc0c01c8b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUI/LEDs.h @@ -0,0 +1,143 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Busware BUI. + * \copydetails Group_LEDs_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 + * \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). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1RedRGB LEDHighPORTC.2
LEDS_LED2GreenRGB LEDHighPORTC.3
LEDS_LED3BlueRGB LEDHighPORTC.4
+ * + * @{ + */ + +#ifndef __LEDS_BUI_H__ +#define __LEDS_BUI_H__ + + /* Includes: */ + #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 << 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; + PORTC &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(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) + { + PINC = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h new file mode 100644 index 000000000..96d1eee6d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Buttons.h @@ -0,0 +1,105 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Fletchtronics BUMBLEB. + * \copydetails Group_Buttons_BUMBLEB + * + * \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 + * \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. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_BUMBLEB_H__ +#define __BUTTONS_BUMBLEB_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Joystick.h new file mode 100644 index 000000000..92c7a2e72 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/Joystick.h @@ -0,0 +1,123 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Fletchtronics BUMBLEB. + * \copydetails Group_Joystick_BUMBLEB + * + * \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 + * \brief Board specific joystick driver header for the Fletchtronics 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. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
PORTD.2PORTD.3PORTD.0PORTD.1PORTD.4
+ * + * @{ + */ + +#ifndef __JOYSTICK_BUMBLEB_H__ +#define __JOYSTICK_BUMBLEB_H__ + + /* Includes: */ + #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 void Joystick_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h new file mode 100644 index 000000000..dff069785 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/BUMBLEB/LEDs.h @@ -0,0 +1,149 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Fletchtronics BUMBLEB. + * \copydetails Group_LEDs_BUMBLEB + * + * \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 + * \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. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1N/AUser SuppliedHighPORTB.4
LEDS_LED2N/AUser SuppliedHighPORTB.5
LEDS_LED3N/AUser SuppliedHighPORTB.6
LEDS_LED4N/AUser SuppliedHighPORTB.7
+ * + * @{ + */ + +#ifndef __LEDS_BUMBLEB_H__ +#define __LEDS_BUMBLEB_H__ + + /* Includes: */ + #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_Disable(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) + { + PINB = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/Buttons.h new file mode 100644 index 000000000..6f6933b0d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Busware CULV3. + * \copydetails Group_LEDs_CULV3 + * + * \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/LEDs.h. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_CULV3 CULV3 + * \brief Board specific Buttons driver header for the Busware CULV3. + * + * Board specific Buttons driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_CULV3_H__ +#define __BUTTONS_CULV3_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/LEDs.h new file mode 100644 index 000000000..86700d147 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/CULV3/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Busware CUL V3. + * \copydetails Group_LEDs_CULV3 + * + * \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 + * \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). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1YellowGeneral IndicatorHighPORTE.6
+ * + * @{ + */ + +#ifndef __LEDS_CULV3_H__ +#define __LEDS_CULV3_H__ + + /* Includes: */ + #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_Disable(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) + { + PINE = LEDMask; + } + + 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/DUCE/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/DUCE/LEDs.h new file mode 100644 index 000000000..0d31b481c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/DUCE/LEDs.h @@ -0,0 +1,147 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the DorkbotPDX Duce. + * \copydetails Group_LEDs_DUCE + * + * \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_DUCE DUCE + * \brief Board specific LED driver header for the DorkbotPDX Duce. + * + * Board specific LED driver header for the DorkbotPDX Duce (http://dorkbotpdx.org/wiki/duce). + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1RedBicolor Indicator 1HighPORTC.4
LEDS_LED2GreenBicolor Indicator 1HighPORTC.5
LEDS_LED3RedBicolor Indicator 2HighPORTC.6
LEDS_LED4GreenBicolor Indicator 2HighPORTC.7
+ * + * @{ + */ + +#ifndef __LEDS_DUCE_H__ +#define __LEDS_DUCE_H__ + + /* Includes: */ + #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) + { + DDRC |= LEDS_ALL_LEDS; + PORTC &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(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) + { + PINC = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Buttons.h new file mode 100644 index 000000000..82cb204eb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel EVK527. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the Atmel EVK527. + * + * Board specific Buttons driver header for the Atmel EVK527. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_EVK527_H__ +#define __BUTTONS_EVK527_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h new file mode 100644 index 000000000..53af74186 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Dataflash.h @@ -0,0 +1,220 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the Atmel EVK527. + * \copydetails Group_Dataflash_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 + * \brief Board specific Dataflash driver header for the Atmel EVK527. + * + * Board specific Dataflash driver header for the Atmel EVK527. + * + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB321C (4MB)PORTE.6SPI0
+ * + * @{ + */ + +#ifndef __DATAFLASH_EVK527_H__ +#define __DATAFLASH_EVK527_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB321C.h" + #include "../../../Peripheral/SPI.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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SPI_TransferByte(Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + 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(); + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Joystick.h new file mode 100644 index 000000000..266b14907 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/Joystick.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Atmel EVK527. + * \copydetails Group_Joystick_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 + * \brief Board specific joystick driver header for the Atmel EVK527. + * + * Board specific joystick driver header for the Atmel EVK527. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
PORTF.4PORTF.5PORTF.7PORTC.6PORTF.6
+ * + * @{ + */ + +#ifndef __JOYSTICK_EVK527_H__ +#define __JOYSTICK_EVK527_H__ + + /* Includes: */ + #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) + + #define JOY_PORTC_MASK_SHIFT 3 + #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) >> JOY_PORTC_MASK_SHIFT) + + /** 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 void Joystick_Disable(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) >> JOY_PORTC_MASK_SHIFT)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/LEDs.h new file mode 100644 index 000000000..58483a9ba --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/EVK527/LEDs.h @@ -0,0 +1,143 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel EVK527. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Atmel EVK527. + * + * Board specific LED driver header for the Atmel EVK527. + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.5
LEDS_LED2GreenGeneral IndicatorHighPORTD.6
LEDS_LED3GreenGeneral IndicatorHighPORTD.7
+ * + * @{ + */ + +#ifndef __LEDS_EVK527_H__ +#define __LEDS_EVK527_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h new file mode 100644 index 000000000..67783ca2b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Mattairtech JM-DB-U2. + * \copydetails Group_Buttons_JMDBU2 + * + * \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 + * \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). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_JMDBU2_H__ +#define __BUTTONS_JMDBU2_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h new file mode 100644 index 000000000..d64cdad6d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/JMDBU2/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Mattairtech JM-DB-U2. + * \copydetails Group_LEDs_JMDBU2 + * + * \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 + * \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). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.4
+ * + * @{ + */ + +#ifndef __LEDS_JMDBU2_H__ +#define __LEDS_JMDBU2_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h new file mode 100644 index 000000000..932bfa14a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MAXIMUS/LEDs.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Maximus. + * \copydetails Group_LEDs_MAXIMUS + * + * \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 + * \brief Board specific LED driver header for the Maximus. + * + * Board specific LED driver header for the Maximus (http://www.avrusb.com/). + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenLGHighPORTB.6
LEDS_LED2RedLRHighPORTB.7
+ * + * @{ + */ + +#ifndef __LEDS_MAXIMUS_H__ +#define __LEDS_MAXIMUS_H__ + + /* Includes: */ + #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_Disable(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) + { + PINB = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Buttons.h new file mode 100644 index 000000000..36a7bebe9 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/Buttons.h @@ -0,0 +1,208 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Micropendous series boards. + * \copydetails Group_Buttons_MICROPENDOUS_32U2 + * + * \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_MICROPENDOUS_A MICROPENDOUS_A + * \brief Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_1 MICROPENDOUS_1 + * \brief Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_2 MICROPENDOUS_2 + * \brief Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_3 MICROPENDOUS_3 + * \brief Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_4 MICROPENDOUS_4 + * \brief Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_DIP MICROPENDOUS_DIP + * \brief Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1 + * \brief Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2 + * \brief Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous). + * + * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2 + * \brief Board specific Buttons driver header for the Micropendous 32U2. + * + * \note There are multiple supported Micropendous boards, compile with BOARD = MICROPENDOUS_{VERSION}. + * + * Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2). + * + * BOARD_MICROPENDOUS_1 and BOARD_MICROPENDOUS_32U2: + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * Other Revisions: + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_MICROPENDOUS_H__ +#define __BUTTONS_MICROPENDOUS_H__ + + /* Includes: */ + #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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + #if (BOARD == BOARD_MICROPENDOUS_32U2) + #define _BOARD_BUTTON1_MASK (1 << 7) + #define _BOARD_BUTTON_PORTLETTER D + #elif (BOARD == BOARD_MICROPENDOUS_A) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #elif (BOARD == BOARD_MICROPENDOUS_1) + #define _BOARD_BUTTON1_MASK (1 << 7) + #define _BOARD_BUTTON_PORTLETTER D + #elif (BOARD == BOARD_MICROPENDOUS_2) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #elif (BOARD == BOARD_MICROPENDOUS_3) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #elif (BOARD == BOARD_MICROPENDOUS_4) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #elif (BOARD == BOARD_MICROPENDOUS_DIP) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #elif (BOARD == BOARD_MICROPENDOUS_REV1) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #elif (BOARD == BOARD_MICROPENDOUS_REV2) + #define _BOARD_BUTTON1_MASK (1 << 2) + #define _BOARD_BUTTON_PORTLETTER E + #endif + + #define _BOARD_BUTTON_CONCAT2(Reg, Letter) Reg ## Letter + #define _BOARD_BUTTON_CONCAT(Reg, Letter) _BOARD_BUTTON_CONCAT2(Reg, Letter) + + #define _BOARD_BUTTON_PORT _BOARD_BUTTON_CONCAT(PORT, _BOARD_BUTTON_PORTLETTER) + #define _BOARD_BUTTON_PIN _BOARD_BUTTON_CONCAT(PIN, _BOARD_BUTTON_PORTLETTER) + #define _BOARD_BUTTON_DDR _BOARD_BUTTON_CONCAT(DDR, _BOARD_BUTTON_PORTLETTER) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Button mask for the first button on the board. */ + #define BUTTONS_BUTTON1 _BOARD_BUTTON1_MASK + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1; + _BOARD_BUTTON_PORT |= BUTTONS_BUTTON1; + } + + static inline void Buttons_Disable(void) + { + _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1; + _BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h new file mode 100644 index 000000000..eeb337711 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h @@ -0,0 +1,177 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Micropendous-32U2. + * \copydetails Group_LEDs_MICROPENDOUS_32U2 + * + * \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_MICROPENDOUS_REV1 MICROPENDOUS_REV1 + * \brief Board specific LED driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous). + * + * See \ref Group_LEDs_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_LEDs + * \defgroup Group_LEDs_MICROPENDOUS_REV2 MICROPENDOUS_REV2 + * \brief Board specific LED driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous). + * + * See \ref Group_LEDs_MICROPENDOUS_32U2 for more details. + */ + +/** \ingroup Group_LEDs + * \defgroup Group_LEDs_MICROPENDOUS_32U2 MICROPENDOUS_32U2 + * \brief Board specific LED driver header for the Micropendous-32U2. + * + * Board specific LED driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2). + * + * BOARD_MICROPENDOUS_32U2: + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.6
+ * + * Other Revisions: + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTB.1
+ * + * @{ + */ + +#ifndef __LEDS_MICROPENDOUS_H__ +#define __LEDS_MICROPENDOUS_H__ + + /* Includes: */ + #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__) + #if (BOARD == BOARD_MICROPENDOUS_32U2) + #define _BOARD_LED1_MASK (1 << 6) + #define _BOARD_LED_PORTLETTER D + #elif (BOARD == BOARD_MICROPENDOUS_REV1) + #define _BOARD_LED1_MASK (1 << 1) + #define _BOARD_LED_PORTLETTER B + #elif (BOARD == BOARD_MICROPENDOUS_REV2) + #define _BOARD_LED1_MASK (1 << 1) + #define _BOARD_LED_PORTLETTER B + #endif + + #define _BOARD_LED_CONCAT2(Reg, Letter) Reg ## Letter + #define _BOARD_LED_CONCAT(Reg, Letter) _BOARD_LED_CONCAT2(Reg, Letter) + + #define _BOARD_LED_PORT _BOARD_LED_CONCAT(PORT, _BOARD_LED_PORTLETTER) + #define _BOARD_LED_PIN _BOARD_LED_CONCAT(PIN, _BOARD_LED_PORTLETTER) + #define _BOARD_LED_DDR _BOARD_LED_CONCAT(DDR, _BOARD_LED_PORTLETTER) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 _BOARD_LED1_MASK + + /** 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) + { + _BOARD_LED_DDR |= LEDS_ALL_LEDS; + _BOARD_LED_PORT &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(void) + { + _BOARD_LED_DDR &= ~LEDS_ALL_LEDS; + _BOARD_LED_PORT &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + _BOARD_LED_PORT |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + _BOARD_LED_PORT &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + _BOARD_LED_PIN = LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (_BOARD_LED_PORT & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/Buttons.h new file mode 100644 index 000000000..01366a71a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Microsin AVR-USB162 board. + * \copydetails Group_Buttons_MICROSIN162 + * + * \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 + * \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/). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_MICROSIN162_H__ +#define __BUTTONS_MICROSIN162_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/LEDs.h new file mode 100644 index 000000000..350703643 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MICROSIN162/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Microsin AVR-USB162 board. + * \copydetails Group_LEDs_MICROSIN162 + * + * \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 + * \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/). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorLowPORTD.4
+ * + * @{ + */ + +#ifndef __LEDS_MICROSIN162_H__ +#define __LEDS_MICROSIN162_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h new file mode 100644 index 000000000..3f1b592d3 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the MINIMUS. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the MINIMUS. + * + * Board specific Buttons driver header for the MINIMUS. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_MINIMUS_H__ +#define __BUTTONS_MINIMUS_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h new file mode 100644 index 000000000..4889722bd --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MINIMUS/LEDs.h @@ -0,0 +1,143 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the MINIMUS. + * \copydetails Group_LEDs_MINIMUS + * + * \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 + * \brief Board specific LED driver header for the MINIMUS. + * + * Board specific LED driver header for the Minimus USB (http://www.minimususb.com/). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1RedGeneral IndicatorLowPORTD.5
LEDS_LED2GreenGeneral IndicatorLowPORTD.6
LEDS_LED3BlueGeneral IndicatorLowPORTD.7
+ * + * @{ + */ + +#ifndef __LEDS_MINIMUS_H__ +#define __LEDS_MINIMUS_H__ + + /* Includes: */ + #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 the 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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h new file mode 100644 index 000000000..9da569271 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/MULTIO/LEDs.h @@ -0,0 +1,161 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Bitwizard Multio. + * \copydetails Group_LEDs_MULTIO + * + * \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_MULTIO MULTIO + * \brief Board specific LED driver header for the Bitwizard Multio. + * + * Board specific LED driver header for the Bitwizard Multio (http://www.bitwizard.nl/wiki/index.php/USB-multio). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.0
LEDS_LED2GreenGeneral IndicatorHighPORTC.2
LEDS_LED3GreenGeneral IndicatorHighPORTD.7
+ * + * @{ + */ + +#ifndef __LEDS_MULTIO_H__ +#define __LEDS_MULTIO_H__ + + /* Includes: */ + #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_LED3) + #define LEDS_PORTC_LEDS LEDS_LED2 + #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 << 2) + + /** LED mask for the second 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_PORTD_LEDS; + DDRC |= LEDS_PORTC_LEDS; + + PORTD &= ~LEDS_PORTD_LEDS; + PORTC &= ~LEDS_PORTC_LEDS; + } + + static inline void LEDs_Disable(void) + { + DDRD &= ~LEDS_PORTD_LEDS; + DDRC &= ~LEDS_PORTC_LEDS; + + PORTD &= ~LEDS_PORTD_LEDS; + PORTC &= ~LEDS_PORTC_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTD |= (LEDMask & LEDS_PORTD_LEDS); + PORTC |= (LEDMask & LEDS_PORTC_LEDS); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTD &= ~(LEDMask & LEDS_PORTD_LEDS); + PORTC &= ~(LEDMask & LEDS_PORTC_LEDS); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTD = (PORTD & ~LEDS_PORTD_LEDS) | (LEDMask & LEDS_PORTD_LEDS); + PORTC = (PORTC & ~LEDS_PORTC_LEDS) | (LEDMask & LEDS_PORTC_LEDS); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTD = (PORTD & ~(LEDMask & LEDS_PORTD_LEDS)) | (ActiveMask & LEDS_PORTD_LEDS); + PORTC = (PORTC & ~(LEDMask & LEDS_PORTC_LEDS)) | (ActiveMask & LEDS_PORTC_LEDS); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PIND = (LEDMask & LEDS_PORTD_LEDS); + PINC = (LEDMask & LEDS_PORTC_LEDS); + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return ((PORTD & LEDS_PORTD_LEDS) | (PORTC & LEDS_PORTC_LEDS)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/Buttons.h new file mode 100644 index 000000000..9f02729cc --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board. + * \copydetails Group_Buttons_OLIMEX162 + * + * \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 + * \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). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_OLIMEX162_H__ +#define __BUTTONS_OLIMEX162_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h new file mode 100644 index 000000000..0e35eae4a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX162/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Olimex AVR-USB-162. + * \copydetails Group_LEDs_OLIMEX162 + * + * \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 + * \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). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1YellowGeneral IndicatorHighPORTD.4
+ * + * @{ + */ + +#ifndef __LEDS_OLIMEX162_H__ +#define __LEDS_OLIMEX162_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/Buttons.h new file mode 100644 index 000000000..4ae89acee --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board. + * \copydetails Group_Buttons_OLIMEX32U4 + * + * \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_OLIMEX32U4 OLIMEX32U4 + * \brief Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board. + * + * Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board (http://www.olimex.com/dev/olimexino-32u4.html). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_OLIMEX32U4_H__ +#define __BUTTONS_OLIMEX32U4_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h new file mode 100644 index 000000000..38dde2c74 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEX32U4/LEDs.h @@ -0,0 +1,179 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Olimex AVR-USB-32U4. + * \copydetails Group_LEDs_OLIMEX32U4 + * + * \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_OLIMEX32U4 OLIMEX32U4 + * \brief Board specific LED driver header for the Olimex AVR-USB-32U4. + * + * Board specific LED driver header for the Olimex AVR-USB-32U4 (http://www.olimex.com/dev/olimexino-32u4.html). + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenTXHighPORTD.5
LEDS_LED2YellowRXHighPORTB.0
LEDS_LED3GreenGeneral Indicator (Default Unconnected)HighPORTE.6
LEDS_LED4YellowGeneral Indicator (Default Unconnected)HighPORTB.5
+ * + * @{ + */ + +#ifndef __LEDS_OLIMEX32U4_H__ +#define __LEDS_OLIMEX32U4_H__ + + /* Includes: */ + #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_LED2 | LEDS_LED4) + #define LEDS_PORTD_LEDS (LEDS_LED1) + #define LEDS_PORTE_LEDS (LEDS_LED3) + + #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 << 5) >> LEDS_PORTD_MASK_SHIFT) + + /** 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 << 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) + { + DDRB |= LEDS_PORTB_LEDS; + PORTB &= ~LEDS_PORTB_LEDS; + DDRD |= (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT); + PORTD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT); + DDRE |= LEDS_PORTE_LEDS; + PORTE &= ~LEDS_PORTE_LEDS; + } + + static inline void LEDs_Disable(void) + { + DDRB &= ~LEDS_PORTB_LEDS; + PORTB &= ~LEDS_PORTB_LEDS; + DDRD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT); + PORTD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT); + DDRE &= ~LEDS_PORTE_LEDS; + PORTE &= ~LEDS_PORTE_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTB |= (LEDMask & LEDS_PORTB_LEDS); + PORTD |= ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + PORTE |= (LEDMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTB &= ~(LEDMask & LEDS_PORTB_LEDS); + PORTD &= ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + PORTE &= ~(LEDMask & LEDS_PORTE_LEDS); + } + + 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)); + PORTE = ((PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS)); + } + + 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)); + PORTE = ((PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS)); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PINB = (LEDMask & LEDS_PORTB_LEDS); + PIND = ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT); + PINE = (LEDMask & LEDS_PORTE_LEDS); + } + + 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)) >> LEDS_PORTD_MASK_SHIFT) | + (PORTE & LEDS_PORTE_LEDS)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h new file mode 100644 index 000000000..70b2467bb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Olimex AVR-ISP-MK2 Development Board. + * \copydetails Group_Buttons_OLIMEXISPMK2 + * + * \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_OLIMEXISPMK2 OLIMEXISPMK2 + * \brief Board specific Buttons driver header for the Olimex AVR-ISP-MK2. + * + * Board specific Buttons driver header for the Olimex AVR-ISP-MK2 Development Board (https://www.olimex.com/dev/avr-isp-mk2.html). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_OLIMEXISPMK2_H__ +#define __BUTTONS_OLIMEXISPMK2_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h new file mode 100644 index 000000000..a1b8825da --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXISPMK2/LEDs.h @@ -0,0 +1,143 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Olimex AVR-ISP-MK2 Development Board. + * \copydetails Group_LEDs_OLIMEXISPMK2 + * + * \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_OLIMEXISPMK2 OLIMEXISPMK2 + * \brief Board specific LED driver header for the Olimex AVR-ISP-MK2. + * + * Board specific LED driver header for the Olimex AVR-ISP-MK2 Development Board (https://www.olimex.com/dev/avr-isp-mk2.html). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1YellowTarget PowerHighPORTB.5
LEDS_LED2RedActivityHighPORTB.6
LEDS_LED3GreenReadyHighPORTB.7
+ * + * @{ + */ + +#ifndef __LEDS_OLIMEXISPMK2_H__ +#define __LEDS_OLIMEXISPMK2_H__ + + /* Includes: */ + #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) + { + DDRB |= LEDS_ALL_LEDS; + PORTB &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(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) + { + PINB = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h new file mode 100644 index 000000000..c779c5578 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Olimex AVR-USB-T32U4 Development Board. + * \copydetails Group_Buttons_OLIMEXT32U4 + * + * \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_OLIMEXT32U4 OLIMEXT32U4 + * \brief Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board. + * + * Board specific Buttons driver header for the Olimex AVR-USB-T32U4 Development Board (http://www.olimex.com/dev/avr-t32u4.html). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_OLIMEXT32U4_H__ +#define __BUTTONS_OLIMEXT32U4_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h new file mode 100644 index 000000000..b3e4c701d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/OLIMEXT32U4/LEDs.h @@ -0,0 +1,169 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Olimex AVR-USB-T32U4. + * \copydetails Group_LEDs_OLIMEXT32U4 + * + * \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_OLIMEXT32U4 OLIMEXT32U4 + * \brief Board specific LED driver header for the Olimex AVR-USB-T32U4. + * + * Board specific LED driver header for the Olimex AVR-USB-T32U4 (http://www.olimex.com/dev/avr-t32u4.html). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenTXHighPORTD.5
LEDS_LED2YellowRXHighPORTB.0
LEDS_LED3N/AGeneral Indicator (Not Mounted)HighPORTE.6
+ * + * @{ + */ + +#ifndef __LEDS_OLIMEXT32U4_H__ +#define __LEDS_OLIMEXT32U4_H__ + + /* Includes: */ + #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_LED2) + #define LEDS_PORTD_LEDS (LEDS_LED1) + #define LEDS_PORTE_LEDS (LEDS_LED3) + #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 << 0) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1 << 6) + + /** 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_PORTB_LEDS; + PORTB &= ~LEDS_PORTB_LEDS; + DDRD |= LEDS_PORTD_LEDS; + PORTD &= ~LEDS_PORTD_LEDS; + DDRE |= LEDS_PORTE_LEDS; + PORTE &= ~LEDS_PORTE_LEDS; + } + + static inline void LEDs_Disable(void) + { + DDRB &= ~LEDS_PORTB_LEDS; + PORTB &= ~LEDS_PORTB_LEDS; + DDRD &= ~LEDS_PORTD_LEDS; + PORTD &= ~LEDS_PORTD_LEDS; + DDRE &= ~LEDS_PORTE_LEDS; + PORTE &= ~LEDS_PORTE_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTB |= (LEDMask & LEDS_PORTB_LEDS); + PORTD |= (LEDMask & LEDS_PORTD_LEDS); + PORTE |= (LEDMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTB &= ~(LEDMask & LEDS_PORTB_LEDS); + PORTD &= ~(LEDMask & LEDS_PORTD_LEDS); + PORTE &= ~(LEDMask & LEDS_PORTE_LEDS); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTB = ((PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS)); + PORTD = ((PORTD & ~LEDS_PORTD_LEDS) | (LEDMask & LEDS_PORTD_LEDS)); + PORTE = ((PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS)); + } + + 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)) | (ActiveMask & LEDS_PORTD_LEDS)); + PORTE = ((PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS)); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PINB = (LEDMask & LEDS_PORTB_LEDS); + PIND = (LEDMask & LEDS_PORTD_LEDS); + PINE = (LEDMask & LEDS_PORTE_LEDS); + } + + 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) | (PORTE & LEDS_PORTE_LEDS)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h new file mode 100644 index 000000000..a440b6f00 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/RZUSBSTICK/LEDs.h @@ -0,0 +1,175 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel RZUSBSTICK. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Atmel RZUSBSTICK. + * + * Board specific LED driver header for the Atmel RZUSBSTICK. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1BlueGeneral IndicatorHighPORTD.7
LEDS_LED1RedGeneral IndicatorLowPORTD.5
LEDS_LED1GreenGeneral IndicatorLowPORTE.6
LEDS_LED1YellowGeneral IndicatorLowPORTE.7
+ * + * @{ + */ + +#ifndef __LEDS_RZUSBSTICK_H__ +#define __LEDS_RZUSBSTICK_H__ + + /* Includes: */ + #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_Disable(void) + { + DDRD &= ~LEDS_PORTD_LEDS; + PORTD &= ~LEDS_PORTD_LEDS; + + 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) + { + PIND = (LEDMask & LEDS_PORTD_LEDS); + PINE = ((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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h new file mode 100644 index 000000000..39267055e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/SPARKFUN8U2/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Sparkfun ATMEGA8U2 breakout board. + * \copydetails Group_LEDs_SPARKFUN8U2 + * + * \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_SPARKFUN8U2 SPARKFUN8U2 + * \brief Board specific LED driver header for the Sparkfun ATMEGA8U2 breakout board. + * + * Board specific LED driver header for the Sparkfun ATMEGA8U2 breakout board (http://www.sparkfun.com/products/10277). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorLowPORTB.4
+ * + * @{ + */ + +#ifndef __LEDS_SPARKFUN8U2_H__ +#define __LEDS_SPARKFUN8U2_H__ + + /* Includes: */ + #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) + { + DDRB |= LEDS_ALL_LEDS; + PORTB |= LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(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) + { + PINB = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Buttons.h new file mode 100644 index 000000000..dcca4d021 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel STK525. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the Atmel STK525. + * + * Board specific Buttons driver header for the Atmel STK525. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_STK525_H__ +#define __BUTTONS_STK525_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h new file mode 100644 index 000000000..1e24c5263 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Dataflash.h @@ -0,0 +1,220 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the Atmel STK525. + * \copydetails Group_Dataflash_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 + * \brief Board specific Dataflash driver header for the Atmel STK525. + * + * Board specific Dataflash driver header for the Atmel STK525. + * + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB321C (4MB)PORTB.4SPI0
+ * + * @{ + */ + +#ifndef __DATAFLASH_STK525_H__ +#define __DATAFLASH_STK525_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB321C.h" + #include "../../../Peripheral/SPI.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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SPI_TransferByte(Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + 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(); + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + Dataflash_SendByte(PageAddress >> 6); + Dataflash_SendByte((PageAddress << 2) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Joystick.h new file mode 100644 index 000000000..dfa86acaa --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/Joystick.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Atmel STK525. + * \copydetails Group_Joystick_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 + * \brief Board specific joystick driver header for the Atmel STK525. + * + * Board specific joystick driver header for the Atmel STK525. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
PORTB.6PORTB.7PORTE.4PORTE.5PORTB.5
+ * + * @{ + */ + +#ifndef __JOYSTICK_STK525_H__ +#define __JOYSTICK_STK525_H__ + + /* Includes: */ + #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)) + + #define JOY_PORTE_MASK_SHIFT 1 + #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) >> JOY_PORTE_MASK_SHIFT) + + /** 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) >> JOY_PORTE_MASK_SHIFT) + + /** 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 void Joystick_Disable(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) >> JOY_PORTE_MASK_SHIFT)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/LEDs.h new file mode 100644 index 000000000..48ac4860c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK525/LEDs.h @@ -0,0 +1,147 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel STK525. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Atmel STK525. + * + * Board specific LED driver header for the Atmel STK525. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.4
LEDS_LED2GreenGeneral IndicatorHighPORTD.5
LEDS_LED3GreenGeneral IndicatorHighPORTD.6
LEDS_LED4GreenGeneral IndicatorHighPORTD.7
+ * + * @{ + */ + +#ifndef __LEDS_STK525_H__ +#define __LEDS_STK525_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Buttons.h new file mode 100644 index 000000000..ec5a7e0e6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel STK526. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the Atmel STK526. + * + * Board specific Buttons driver header for the Atmel STK526. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_STK526_H__ +#define __BUTTONS_STK526_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h new file mode 100644 index 000000000..07d44b146 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Dataflash.h @@ -0,0 +1,220 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the Atmel STK525. + * \copydetails Group_Dataflash_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 + * \defgroup Group_Dataflash_STK526 STK526 + * \brief Board specific Dataflash driver header for the Atmel STK525. + * + * Board specific Dataflash driver header for the Atmel STK525. + * + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTC.2SPI0
+ * + * @{ + */ + +#ifndef __DATAFLASH_STK526_H__ +#define __DATAFLASH_STK526_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB642D.h" + #include "../../../Peripheral/SPI.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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SPI_TransferByte(Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + 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(); + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Joystick.h new file mode 100644 index 000000000..bc5f489ed --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/Joystick.h @@ -0,0 +1,123 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Atmel STK526. + * \copydetails Group_Joystick_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 + * \brief Board specific joystick driver header for the Atmel STK526. + * + * Board specific joystick driver header for the Atmel STK526. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
PORTB.4PORTB.5PORTB.6PORTB.7PORTB.0
+ * + * @{ + */ + +#ifndef __JOYSTICK_STK526_H__ +#define __JOYSTICK_STK526_H__ + + /* Includes: */ + #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 void Joystick_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/LEDs.h new file mode 100644 index 000000000..d9bb3b99b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/STK526/LEDs.h @@ -0,0 +1,147 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel STK526. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Atmel STK526. + * + * Board specific LED driver header for the Atmel STK526. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.1
LEDS_LED2GreenGeneral IndicatorHighPORTD.0
LEDS_LED3GreenGeneral IndicatorHighPORTD.5
LEDS_LED4GreenGeneral IndicatorHighPORTD.4
+ * + * @{ + */ + +#ifndef __LEDS_STK526_H__ +#define __LEDS_STK526_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h new file mode 100644 index 000000000..8f0cfafb2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TEENSY/LEDs.h @@ -0,0 +1,176 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the PJRC Teensy 1.x/2.x boards. + * \copydetails Group_LEDs_TEENSY + * + * \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_TEENSY2 TEENSY2 + * \brief Board specific LED driver header for the PJRC Teensy 2 boards. + * + * See \ref Group_LEDs_TEENSY for more details. + */ + +/** \ingroup Group_LEDs + * \defgroup Group_LEDs_TEENSY TEENSY + * \brief Board specific LED driver header for the PJRC Teensy 1.x/2.x boards. + * + * \note For version 2 Teensy boards, compile with BOARD = TEENSY2. + * + * Board specific LED driver header for the PJRC Teensy boards (http://www.pjrc.com/teensy/index.html). + * + * TEENSY: + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.6
+ * + * TEENSY2: + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorLowPORTD.6
+ * + * @{ + */ + +#ifndef __LEDS_TEENSY_H__ +#define __LEDS_TEENSY_H__ + + /* Includes: */ + #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; + + #if (BOARD == BOARD_TEENSY2) + PORTD &= ~LEDS_ALL_LEDS; + #else + PORTD |= LEDS_ALL_LEDS; + #endif + } + + static inline void LEDs_Disable(void) + { + DDRD &= ~LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_TEENSY2) + PORTD |= LEDMask; + #else + PORTD &= ~LEDMask; + #endif + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_TEENSY2) + PORTD &= ~LEDMask; + #else + PORTD |= LEDMask; + #endif + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_TEENSY2) + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + #else + PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); + #endif + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + #if (BOARD == BOARD_TEENSY2) + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + #else + PORTD = ((PORTD | LEDMask) & ~ActiveMask); + #endif + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PIND = LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + #if (BOARD == BOARD_TEENSY2) + return (PORTD & LEDS_ALL_LEDS); + #else + return (~PORTD & LEDS_ALL_LEDS); + #endif + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/Buttons.h new file mode 100644 index 000000000..a8e104128 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the TUL. + * \copydetails Group_Buttons_TUL + * + * \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_TUL TUL + * \brief Board specific Buttons driver header for the TUL. + * + * Board specific Buttons driver header for the Busware TUL (http://www.busware.de/tiki-index.php?page=TUL). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_TUL_H__ +#define __BUTTONS_TUL_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/LEDs.h new file mode 100644 index 000000000..494396bfc --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/TUL/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Busware TUL. + * \copydetails Group_LEDs_TUL + * + * \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_TUL TUL + * \brief Board specific LED driver header for the Busware TUL. + * + * Board specific LED driver header for the Busware TUL (http://www.busware.de/tiki-index.php?page=TUL). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTF.0
+ * + * @{ + */ + +#ifndef __LEDS_TUL_H__ +#define __LEDS_TUL_H__ + + /* Includes: */ + #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 << 0) + + /** 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) + { + DDRF |= LEDS_ALL_LEDS; + PORTF &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(void) + { + DDRF &= ~LEDS_ALL_LEDS; + PORTF &= ~LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTF |= LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTF &= ~LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTF = ((PORTF & ~LEDS_ALL_LEDS) | LEDMask); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + PORTF = ((PORTF & ~LEDMask) | ActiveMask); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PINF = LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTF & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/Buttons.h new file mode 100644 index 000000000..3e0bede07 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the UDIP. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the UDIP. + * + * Board specific Buttons driver header for the Linnix UDIP (http://linnix.com/udip/). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_UDIP_H__ +#define __BUTTONS_UDIP_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/LEDs.h new file mode 100644 index 000000000..1cff6fc69 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UDIP/LEDs.h @@ -0,0 +1,163 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Linnix UDIP. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Linnix UDIP. + * + * Board specific LED driver header for the Linnix UDIP (http://linnix.com/udip/). + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenBicolor Indicator 1HighPORTB.6
LEDS_LED2RedBicolor Indicator 1HighPORTB.5
LEDS_LED3GreenBicolor Indicator 2HighPORTD.5
LEDS_LED4RedBicolor Indicator 2HighPORTD.4
+ * + * @{ + */ + +#ifndef __LEDS_UDIP_H__ +#define __LEDS_UDIP_H__ + + /* Includes: */ + #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_Disable(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) + { + PINB = (LEDMask & LEDS_PORTB_LEDS); + PIND = ((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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UNO/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UNO/LEDs.h new file mode 100644 index 000000000..c7e09d4cb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/UNO/LEDs.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Arduino Uno. + * \copydetails Group_LEDs_UNO + * + * \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 + * \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). + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1YellowRXLowPORTD.4
LEDS_LED2YellowTXLowPORTD.5
+ * + * @{ + */ + +#ifndef __LEDS_UNO_H__ +#define __LEDS_UNO_H__ + + /* Includes: */ + #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 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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h new file mode 100644 index 000000000..3775e5c84 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/Buttons.h @@ -0,0 +1,113 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Paranoid Studio USB2AX. + * \copydetails Group_Buttons_USB2AX + * + * \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_USB2AX_V3 USB2AX_V3 + * \brief Board specific Button driver header for the Paranoid Studio USB2AX revision 3. + * + * See \ref Group_Buttons_USB2AX for more details. + */ + +/** \ingroup Group_Buttons + * \defgroup Group_Buttons_USB2AX USB2AX + * \brief Board specific Buttons driver header for the Paranoid Studio USB2AX. + * + * \note For version 3 USB2AX boards, compile with BOARD = USB2AX_V3. + * + * Board specific Buttons driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_USB2AX_H__ +#define __BUTTONS_USB2AX_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h new file mode 100644 index 000000000..b8d2db01d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USB2AX/LEDs.h @@ -0,0 +1,196 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Paranoid Studio USB2AX. + * \copydetails Group_LEDs_USB2AX + * + * \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_USB2AX_V3 USB2AX_V3 + * \brief Board specific LED driver header for the Paranoid Studio USB2AX revision 3. + * + * See \ref Group_LEDs_USB2AX for more details. + */ + +/** \ingroup Group_LEDs + * \defgroup Group_LEDs_USB2AX USB2AX + * \brief Board specific LED driver header for the Paranoid Studio USB2AX. + * + * \note For version 3 USB2AX boards, compile with BOARD = USB2AX_V3. + * + * Board specific LED driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX). + * + * USB2AX: + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTC.6
+ * + * USB2AX_V3: + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorHighPORTD.1
+ * + * @{ + */ + +#ifndef __LEDS_USB2AX_H__ +#define __LEDS_USB2AX_H__ + + /* Includes: */ + #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: */ + #if (BOARD == BOARD_USB2AX) + #define USB2AX_LEDS_LED1 (1 << 6) + #else + #define USB2AX_LEDS_LED1 (1 << 1) + #endif + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 USB2AX_LEDS_LED1 + + /** 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) + { + #if (BOARD == BOARD_USB2AX) + DDRC |= LEDS_ALL_LEDS; + PORTC &= ~LEDS_ALL_LEDS; + #else + DDRD |= LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + #endif + } + + static inline void LEDs_Disable(void) + { + #if (BOARD == BOARD_USB2AX) + DDRC &= ~LEDS_ALL_LEDS; + PORTC &= ~LEDS_ALL_LEDS; + #else + DDRD &= ~LEDS_ALL_LEDS; + PORTD &= ~LEDS_ALL_LEDS; + #endif + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_USB2AX) + PORTC |= LEDMask; + #else + PORTD |= LEDMask; + #endif + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_USB2AX) + PORTC &= ~LEDMask; + #else + PORTD &= ~LEDMask; + #endif + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_USB2AX) + PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask); + #else + PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); + #endif + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, + const uint8_t ActiveMask) + { + #if (BOARD == BOARD_USB2AX) + PORTC = ((PORTC & ~LEDMask) | ActiveMask); + #else + PORTD = ((PORTD & ~LEDMask) | ActiveMask); + #endif + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + #if (BOARD == BOARD_USB2AX) + PINC = LEDMask; + #else + PIND = LEDMask; + #endif + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + #if (BOARD == BOARD_USB2AX) + return (PORTC & LEDS_ALL_LEDS); + #else + return (PORTD & LEDS_ALL_LEDS); + #endif + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h new file mode 100644 index 000000000..876939cb7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Kernel Concepts USBFOO. + * \copydetails Group_Buttons_USBFOO + * + * \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 + * \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). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_USBFOO_H__ +#define __BUTTONS_USBFOO_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h new file mode 100644 index 000000000..7d093df18 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBFOO/LEDs.h @@ -0,0 +1,135 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Kernel Concepts USBFOO. + * \copydetails Group_LEDs_USBFOO + * + * \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 + * \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). + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorLowPORTD.4
+ * + * @{ + */ + +#ifndef __LEDS_USBFOO_H__ +#define __LEDS_USBFOO_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h new file mode 100644 index 000000000..63a3ae274 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel USBKEY. + * \copydetails Group_Buttons_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 + * \brief Board specific Buttons driver header for the Atmel USBKEY. + * + * Board specific Buttons driver header for the Atmel USBKEY. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTE.2
+ * + * @{ + */ + +#ifndef __BUTTONS_USBKEY_H__ +#define __BUTTONS_USBKEY_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h new file mode 100644 index 000000000..c47cfa9c2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Dataflash.h @@ -0,0 +1,229 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the Atmel USBKEY. + * \copydetails Group_Dataflash_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 + * \brief Board specific Dataflash driver header for the Atmel USBKEY. + * + * Board specific Dataflash driver header for the Atmel USBKEY board. + * + * + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTE.0SPI0
DATAFLASH_CHIP2AT45DB642D (8MB)PORTE.1SPI0
+ * + * @{ + */ + +#ifndef __DATAFLASH_USBKEY_H__ +#define __DATAFLASH_USBKEY_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB642D.h" + #include "../../../Peripheral/SPI.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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SPI_TransferByte(Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + 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(); + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) + return; + + if (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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + PageAddress >>= 1; + + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h new file mode 100644 index 000000000..9e9320ea0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/Joystick.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Atmel USBKEY. + * \copydetails Group_Joystick_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 + * \brief Board specific joystick driver header for the Atmel USBKEY. + * + * Board specific joystick driver header for the Atmel USBKEY. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
PORTB.6PORTB.7PORTE.4PORTE.5PORTB.5
+ * + * @{ + */ + +#ifndef __JOYSTICK_USBKEY_H__ +#define __JOYSTICK_USBKEY_H__ + + /* Includes: */ + #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)) + + #define JOY_PORTE_MASK_SHIFT 1 + #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) >> JOY_PORTE_MASK_SHIFT) + + /** 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) >> JOY_PORTE_MASK_SHIFT) + + /** 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 void Joystick_Disable(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) >> JOY_PORTE_MASK_SHIFT)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h new file mode 100644 index 000000000..77cab1ecf --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBKEY/LEDs.h @@ -0,0 +1,147 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel USBKEY. + * \copydetails Group_LEDs_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 + * \brief Board specific LED driver header for the Atmel USBKEY. + * + * Board specific LED driver header for the Atmel USBKEY. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1RedBicolor Indicator 1LowPORTD.4
LEDS_LED2GreenBicolor Indicator 1LowPORTD.5
LEDS_LED3RedBicolor Indicator 2LowPORTD.6
LEDS_LED4GreenBicolor Indicator 2LowPORTD.7
+ * + * @{ + */ + +#ifndef __LEDS_USBKEY_H__ +#define __LEDS_USBKEY_H__ + + /* Includes: */ + #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_Disable(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) + { + PIND = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/Buttons.h new file mode 100644 index 000000000..29e73b7b5 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/Buttons.h @@ -0,0 +1,103 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for Tom's USBTINY MKII. + * \copydetails Group_Buttons_USBTINYMKII + * + * \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 + * \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/). + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1HWB ButtonLowPORTD.7
+ * + * @{ + */ + +#ifndef __BUTTONS_USBTINYMKII_H__ +#define __BUTTONS_USBTINYMKII_H__ + + /* Includes: */ + #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 void Buttons_Disable(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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/LEDs.h new file mode 100644 index 000000000..0e6192ee3 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/USBTINYMKII/LEDs.h @@ -0,0 +1,143 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for Tom's USBTINY MKII. + * \copydetails Group_LEDs_USBTINYMKII + * + * \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 + * \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/). + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1RedBicolor Indicator 1HighPORTB.6
LEDS_LED2GreenBicolor Indicator 1HighPORTB.7
LEDS_LED3RedTarget PowerHighPORTB.5
+ * + * @{ + */ + +#ifndef __LEDS_USBTINYMKII_H__ +#define __LEDS_USBTINYMKII_H__ + + /* Includes: */ + #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 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_Disable(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) + { + PINB = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h new file mode 100644 index 000000000..ef428b0dc --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/Dataflash.h @@ -0,0 +1,243 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the original Atmel XPLAIN. + * \copydetails Group_Dataflash_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_REV1 XPLAIN_REV1 + * \brief Board specific Dataflash driver header for the original Atmel XPLAIN, revision 1. + * + * See \ref Group_Dataflash_XPLAIN for more details. + */ + +/** \ingroup Group_Dataflash + * \defgroup Group_Dataflash_XPLAIN XPLAIN + * \brief Board specific Dataflash driver header for the original Atmel XPLAIN. + * + * \note For the first revision XPLAIN board, compile with BOARD = BOARD_XPLAIN_REV1. + * + * Board specific Dataflash driver header for the Atmel XPLAIN. + * + * Revision 1 Boards: + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB041D (512KB)PORTB.5SPI0
+ * + * Other Board Revisions: + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTB.5SPI0
+ * + * @{ + */ + +#ifndef __DATAFLASH_XPLAIN_H__ +#define __DATAFLASH_XPLAIN_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + #include "../../../Misc/AT45DB642D.h" + #include "../../../Peripheral/SPI.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) || defined(__DOXYGEN__)) + /** 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 + #else + #define DATAFLASH_PAGE_SIZE 256 + + #define DATAFLASH_PAGES 2048 + #endif + + /* Inline Functions: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SPI_TransferByte(Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + 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(); + } + + /** Determines the currently selected dataflash chip. + * + * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected + * or a DATAFLASH_CHIPn mask (where n is the chip number). + */ + static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Dataflash_GetSelectedChip(void) + { + return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); + } + + /** Selects the given dataflash chip. + * + * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is + * the chip number). + */ + static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SelectChip(const uint8_t ChipMask) + { + DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= DATAFLASH_PAGES) + 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h new file mode 100644 index 000000000..c7d74591d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/AVR8/XPLAIN/LEDs.h @@ -0,0 +1,142 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the original Atmel XPLAIN. + * \copydetails Group_LEDs_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_REV1 XPLAIN_REV1 + * \brief Board specific LED driver header for the original Atmel XPLAIN, revision 1. + * + * See \ref Group_LEDs_XPLAIN for more details. + */ + +/** \ingroup Group_LEDs + * \defgroup Group_LEDs_XPLAIN XPLAIN + * \brief Board specific LED driver header for the original Atmel XPLAIN. + * + * Board specific LED driver header for the Atmel XPLAIN. + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenGeneral IndicatorLowPORTB.6
+ * + * @{ + */ + +#ifndef __LEDS_XPLAIN_H__ +#define __LEDS_XPLAIN_H__ + + /* Includes: */ + #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_Disable(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) + { + PINB = 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Buttons.h new file mode 100644 index 000000000..c5c09bedb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Buttons.h @@ -0,0 +1,178 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Digital button board hardware driver. + * + * This file is the master dispatch header file for the board-specific Buttons driver, for boards containing + * physical pushbuttons connected to the microcontroller'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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Buttons.h file in the user project + * directory. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * \defgroup Group_Buttons Buttons Driver - LUFA/Drivers/Board/Buttons.h + * \brief Digital button board hardware driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Buttons.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the button driver before first use + * Buttons_Init(); + * + * printf("Waiting for button press...\r\n"); + * + * // Loop until a board button has been pressed + * uint8_t ButtonPress; + * while (!(ButtonPress = Buttons_GetStatus())) {}; + * + * // Display which button was pressed (assuming two board buttons) + * printf("Button pressed: %s\r\n", (ButtonPress == BUTTONS_BUTTON1) ? "Button 1" : "Button 2"); + * \endcode + * + * @{ + */ + +#ifndef __BUTTONS_H__ +#define __BUTTONS_H__ + + /* Macros: */ + #define __INCLUDE_FROM_BUTTONS_H + + /* 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 "AVR8/USBKEY/Buttons.h" + #elif (BOARD == BOARD_STK525) + #include "AVR8/STK525/Buttons.h" + #elif (BOARD == BOARD_STK526) + #include "AVR8/STK526/Buttons.h" + #elif (BOARD == BOARD_ATAVRUSBRF01) + #include "AVR8/ATAVRUSBRF01/Buttons.h" + #elif (BOARD == BOARD_BUMBLEB) + #include "AVR8/BUMBLEB/Buttons.h" + #elif (BOARD == BOARD_EVK527) + #include "AVR8/EVK527/Buttons.h" + #elif (BOARD == BOARD_USBTINYMKII) + #include "AVR8/USBTINYMKII/Buttons.h" + #elif (BOARD == BOARD_BENITO) + #include "AVR8/BENITO/Buttons.h" + #elif (BOARD == BOARD_JMDBU2) + #include "AVR8/JMDBU2/Buttons.h" + #elif (BOARD == BOARD_OLIMEX162) + #include "AVR8/OLIMEX162/Buttons.h" + #elif (BOARD == BOARD_USBFOO) + #include "AVR8/USBFOO/Buttons.h" + #elif (BOARD == BOARD_UDIP) + #include "AVR8/UDIP/Buttons.h" + #elif (BOARD == BOARD_CULV3) + #include "AVR8/CULV3/Buttons.h" + #elif (BOARD == BOARD_MINIMUS) + #include "AVR8/MINIMUS/Buttons.h" + #elif (BOARD == BOARD_MICROSIN162) + #include "AVR8/MICROSIN162/Buttons.h" + #elif (BOARD == BOARD_EVK1101) + #include "UC3/EVK1101/Buttons.h" + #elif (BOARD == BOARD_TUL) + #include "AVR8/TUL/Buttons.h" + #elif (BOARD == BOARD_EVK1100) + #include "UC3/EVK1100/Buttons.h" + #elif (BOARD == BOARD_EVK1104) + #include "UC3/EVK1104/Buttons.h" + #elif (BOARD == BOARD_A3BU_XPLAINED) + #include "XMEGA/A3BU_XPLAINED/Buttons.h" + #elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3)) + #include "AVR8/USB2AX/Buttons.h" + #elif ((BOARD == BOARD_MICROPENDOUS_32U2) || (BOARD == BOARD_MICROPENDOUS_A) || \ + (BOARD == BOARD_MICROPENDOUS_1) || (BOARD == BOARD_MICROPENDOUS_2) || \ + (BOARD == BOARD_MICROPENDOUS_3) || (BOARD == BOARD_MICROPENDOUS_4) || \ + (BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \ + (BOARD == BOARD_MICROPENDOUS_DIP)) + #include "AVR8/MICROPENDOUS/Buttons.h" + #elif (BOARD == BOARD_B1_XPLAINED) + #include "XMEGA/B1_XPLAINED/Buttons.h" + #elif (BOARD == BOARD_OLIMEX32U4) + #include "AVR8/OLIMEX32U4/Buttons.h" + #elif (BOARD == BOARD_OLIMEXT32U4) + #include "AVR8/OLIMEXT32U4/Buttons.h" + #elif (BOARD == BOARD_OLIMEXISPMK2) + #include "AVR8/OLIMEXISPMK2/Buttons.h" + #else + #include "Board/Buttons.h" + #endif + + /* Pseudo-Functions for Doxygen: */ + #if defined(__DOXYGEN__) + /** Initializes 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); + + /** Disables the buttons driver, releasing the I/O pins back to their default high-impedance input mode. */ + static inline void Buttons_Disable(void); + + /** Returns a mask indicating which board buttons are currently pressed. + * + * \return Mask indicating which board buttons are currently pressed. + */ + static inline uint_reg_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Dataflash.h new file mode 100644 index 000000000..944ea5ffe --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Dataflash.h @@ -0,0 +1,252 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the board dataflash IC driver. + * \brief Atmel Dataflash storage IC board hardware driver. + * + * This file is the master dispatch header file for the board-specific Atmel dataflash driver, for boards containing + * Atmel 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Dataflash.h file in the user project + * directory. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * \defgroup Group_Dataflash Dataflash Driver - LUFA/Drivers/Board/Dataflash.h + * \brief Atmel Dataflash storage IC board hardware driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Dataflash.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the SPI and board Dataflash drivers before first use + * SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | + * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); + * Dataflash_Init(); + * + * uint8_t WriteBuffer[DATAFLASH_PAGE_SIZE]; + * uint8_t ReadBuffer[DATAFLASH_PAGE_SIZE]; + * + * // Fill page write buffer with a repeating pattern + * for (uint16_t i = 0; i < DATAFLASH_PAGE_SIZE; i++) + * WriteBuffer[i] = (i & 0xFF); + * + * // Must select the chip of interest first before operating on it + * Dataflash_SelectChip(DATAFLASH_CHIP1); + * + * // Write to the Dataflash's first internal memory buffer + * printf("Writing data to first dataflash buffer:\r\n"); + * Dataflash_SendByte(DF_CMD_BUFF1WRITE); + * Dataflash_SendAddressBytes(0, 0); + * + * for (uint16_t i = 0; i < DATAFLASH_PAGE_SIZE; i++) + * Dataflash_SendByte(WriteBuffer[i]); + * + * // Commit the Dataflash's first memory buffer to the non-volatile FLASH memory + * printf("Committing page to non-volatile memory page index 5:\r\n"); + * Dataflash_SendByte(DF_CMD_BUFF1TOMAINMEMWITHERASE); + * Dataflash_SendAddressBytes(5, 0); + * Dataflash_WaitWhileBusy(); + * + * // Read the page from non-volatile FLASH memory into the Dataflash's second memory buffer + * printf("Reading data into second dataflash buffer:\r\n"); + * Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF2); + * Dataflash_SendAddressBytes(5, 0); + * Dataflash_WaitWhileBusy(); + * + * // Read the Dataflash's second internal memory buffer + * Dataflash_SendByte(DF_CMD_BUFF2READ); + * Dataflash_SendAddressBytes(0, 0); + * + * for (uint16_t i = 0; i < DATAFLASH_PAGE_SIZE; i++) + * ReadBuffer[i] = Dataflash_ReceiveByte(); + * + * // Deselect the chip after use + * Dataflash_DeselectChip(); + * \endcode + * + * @{ + */ + +#ifndef __DATAFLASH_H__ +#define __DATAFLASH_H__ + + /* Macros: */ + #define __INCLUDE_FROM_DATAFLASH_H + + /* Includes: */ + #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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * + * \note The microcontroller's physical interface driver connected to the Dataflash IC must be initialized before + * any of the dataflash commands are used. This is usually a SPI hardware port, but on some devices/boards may + * be a USART operating in SPI Master mode. + */ + 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 \c 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 \c 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 \ref DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress); + + /** 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte); + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + + /** 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; + + /* Includes: */ + #if (BOARD == BOARD_NONE) + #error The Board Dataflash driver cannot be used if the makefile BOARD option is not set. + #elif (BOARD == BOARD_USBKEY) + #include "AVR8/USBKEY/Dataflash.h" + #elif (BOARD == BOARD_STK525) + #include "AVR8/STK525/Dataflash.h" + #elif (BOARD == BOARD_STK526) + #include "AVR8/STK526/Dataflash.h" + #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) + #include "AVR8/XPLAIN/Dataflash.h" + #elif (BOARD == BOARD_EVK527) + #include "AVR8/EVK527/Dataflash.h" + #elif (BOARD == BOARD_A3BU_XPLAINED) + #include "XMEGA/A3BU_XPLAINED/Dataflash.h" + #elif (BOARD == BOARD_B1_XPLAINED) + #include "XMEGA/B1_XPLAINED/Dataflash.h" + #else + #include "Board/Dataflash.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Joystick.h new file mode 100644 index 000000000..640939a93 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Joystick.h @@ -0,0 +1,144 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Digital joystick board hardware driver. + * + * This file is the master dispatch header file for the board-specific Joystick driver, for boards containing a + * digital 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Joystick.h file in the user project + * directory. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * \defgroup Group_Joystick Joystick Driver - LUFA/Drivers/Board/Joystick.h + * \brief Digital joystick board hardware driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Joystick.h file in the user project + * directory. Otherwise, it will include the appropriate built in board driver header file. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the board Joystick driver before first use + * Joystick_Init(); + * + * printf("Waiting for joystick movement...\r\n"); + * + * // Loop until a the joystick has been moved + * uint8_t JoystickMovement; + * while (!(JoystickMovement = Joystick_GetStatus())) {}; + * + * // Display which direction the joystick was moved in + * printf("Joystick moved:\r\n"); + * + * if (JoystickMovement & (JOY_UP | JOY_DOWN)) + * printf("%s ", (JoystickMovement & JOY_UP) ? "Up" : "Down"); + * + * if (JoystickMovement & (JOY_LEFT | JOY_RIGHT)) + * printf("%s ", (JoystickMovement & JOY_LEFT) ? "Left" : "Right"); + * + * if (JoystickMovement & JOY_PRESS) + * printf("Pressed"); + * \endcode + * + * @{ + */ + +#ifndef __JOYSTICK_H__ +#define __JOYSTICK_H__ + + /* Macros: */ + #define __INCLUDE_FROM_JOYSTICK_H + + /* 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 "AVR8/USBKEY/Joystick.h" + #elif (BOARD == BOARD_STK525) + #include "AVR8/STK525/Joystick.h" + #elif (BOARD == BOARD_STK526) + #include "AVR8/STK526/Joystick.h" + #elif (BOARD == BOARD_BUMBLEB) + #include "AVR8/BUMBLEB/Joystick.h" + #elif (BOARD == BOARD_EVK527) + #include "AVR8/EVK527/Joystick.h" + #elif (BOARD == BOARD_EVK1101) + #include "UC3/EVK1101/Joystick.h" + #elif (BOARD == BOARD_EVK1100) + #include "UC3/EVK1100/Joystick.h" + #else + #include "Board/Joystick.h" + #endif + + /* Pseudo-Functions for Doxygen: */ + #if defined(__DOXYGEN__) + /** Initializes 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); + + /** Disables the joystick driver, releasing the I/O pins back to their default high-impedance input mode. */ + static inline void Joystick_Disable(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 uint_reg_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/LEDs.h new file mode 100644 index 000000000..96438d0da --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/LEDs.h @@ -0,0 +1,274 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief LED board hardware 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/LEDs.h file in the user project + * directory. + * + * For possible \c BOARD makefile values, see \ref Group_BoardTypes. + */ + +/** \ingroup Group_BoardDrivers + * \defgroup Group_LEDs LEDs Driver - LUFA/Drivers/Board/LEDs.h + * \brief LED board hardware driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription 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 \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/LEDs.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 \c BOARD_NONE, this driver is silently disabled. + * + * For possible \c 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 behavior 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. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the board LED driver before first use + * LEDs_Init(); + * + * // Turn on each of the four LEDs in turn + * LEDs_SetAllLEDs(LEDS_LED1); + * Delay_MS(500); + * LEDs_SetAllLEDs(LEDS_LED2); + * Delay_MS(500); + * LEDs_SetAllLEDs(LEDS_LED3); + * Delay_MS(500); + * LEDs_SetAllLEDs(LEDS_LED4); + * Delay_MS(500); + * + * // Turn on all LEDs + * LEDs_SetAllLEDs(LEDS_ALL_LEDS); + * Delay_MS(1000); + * + * // Turn on LED 1, turn off LED 2, leaving LEDs 3 and 4 in their current state + * LEDs_ChangeLEDs((LEDS_LED1 | LEDS_LED2), LEDS_LED1); + * \endcode + * + * @{ + */ + +#ifndef __LEDS_H__ +#define __LEDS_H__ + + /* Macros: */ + #define __INCLUDE_FROM_LEDS_H + + /* Includes: */ + #include "../../Common/Common.h" + + #if (BOARD == BOARD_NONE) + static inline void LEDs_Init(void) {}; + static inline void LEDs_Disable(void) {}; + static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask) {}; + static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask) {}; + static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask) {}; + static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask, const uint_reg_t ActiveMask) {}; + static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask) {}; + static inline uint_reg_t LEDs_GetLEDs(void) { return 0; } + #elif (BOARD == BOARD_USBKEY) + #include "AVR8/USBKEY/LEDs.h" + #elif (BOARD == BOARD_STK525) + #include "AVR8/STK525/LEDs.h" + #elif (BOARD == BOARD_STK526) + #include "AVR8/STK526/LEDs.h" + #elif (BOARD == BOARD_RZUSBSTICK) + #include "AVR8/RZUSBSTICK/LEDs.h" + #elif (BOARD == BOARD_ATAVRUSBRF01) + #include "AVR8/ATAVRUSBRF01/LEDs.h" + #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1)) + #include "AVR8/XPLAIN/LEDs.h" + #elif (BOARD == BOARD_BUMBLEB) + #include "AVR8/BUMBLEB/LEDs.h" + #elif (BOARD == BOARD_EVK527) + #include "AVR8/EVK527/LEDs.h" + #elif ((BOARD == BOARD_TEENSY) || (BOARD == BOARD_TEENSY2)) + #include "AVR8/TEENSY/LEDs.h" + #elif (BOARD == BOARD_USBTINYMKII) + #include "AVR8/USBTINYMKII/LEDs.h" + #elif (BOARD == BOARD_BENITO) + #include "AVR8/BENITO/LEDs.h" + #elif (BOARD == BOARD_JMDBU2) + #include "AVR8/JMDBU2/LEDs.h" + #elif (BOARD == BOARD_OLIMEX162) + #include "AVR8/OLIMEX162/LEDs.h" + #elif (BOARD == BOARD_USBFOO) + #include "AVR8/USBFOO/LEDs.h" + #elif (BOARD == BOARD_UDIP) + #include "AVR8/UDIP/LEDs.h" + #elif (BOARD == BOARD_BUI) + #include "AVR8/BUI/LEDs.h" + #elif (BOARD == BOARD_UNO) + #include "AVR8/UNO/LEDs.h" + #elif (BOARD == BOARD_CULV3) + #include "AVR8/CULV3/LEDs.h" + #elif (BOARD == BOARD_BLACKCAT) + #include "AVR8/BLACKCAT/LEDs.h" + #elif (BOARD == BOARD_MAXIMUS) + #include "AVR8/MAXIMUS/LEDs.h" + #elif (BOARD == BOARD_MINIMUS) + #include "AVR8/MINIMUS/LEDs.h" + #elif (BOARD == BOARD_ADAFRUITU4) + #include "AVR8/ADAFRUITU4/LEDs.h" + #elif (BOARD == BOARD_MICROSIN162) + #include "AVR8/MICROSIN162/LEDs.h" + #elif (BOARD == BOARD_SPARKFUN8U2) + #include "AVR8/SPARKFUN8U2/LEDs.h" + #elif (BOARD == BOARD_EVK1101) + #include "UC3/EVK1101/LEDs.h" + #elif (BOARD == BOARD_TUL) + #include "AVR8/TUL/LEDs.h" + #elif (BOARD == BOARD_EVK1100) + #include "UC3/EVK1100/LEDs.h" + #elif (BOARD == BOARD_EVK1104) + #include "UC3/EVK1104/LEDs.h" + #elif (BOARD == BOARD_A3BU_XPLAINED) + #include "XMEGA/A3BU_XPLAINED/LEDs.h" + #elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3)) + #include "AVR8/USB2AX/LEDs.h" + #elif ((BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \ + (BOARD == BOARD_MICROPENDOUS_32U2)) + #include "AVR8/MICROPENDOUS/LEDs.h" + #elif (BOARD == BOARD_B1_XPLAINED) + #include "XMEGA/B1_XPLAINED/LEDs.h" + #elif (BOARD == BOARD_MULTIO) + #include "AVR8/MULTIO/LEDs.h" + #elif (BOARD == BOARD_BIGMULTIO) + #include "AVR8/BIGMULTIO/LEDs.h" + #elif (BOARD == BOARD_DUCE) + #include "AVR8/DUCE/LEDs.h" + #elif (BOARD == BOARD_OLIMEX32U4) + #include "AVR8/OLIMEX32U4/LEDs.h" + #elif (BOARD == BOARD_OLIMEXT32U4) + #include "AVR8/OLIMEXT32U4/LEDs.h" + #elif (BOARD == BOARD_OLIMEXISPMK2) + #include "AVR8/OLIMEXISPMK2/LEDs.h" + #else + #include "Board/LEDs.h" + #endif + + /* Preprocessor Checks: */ + #if !defined(__DOXYGEN__) + #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 + #endif + + /* Pseudo-Functions for Doxygen: */ + #if defined(__DOXYGEN__) + /** Initializes 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); + + /** Disables the board LED driver, releasing the I/O pins back to their default high-impedance input mode. */ + static inline void LEDs_Disable(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 uint_reg_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 uint_reg_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 uint_reg_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 uint_reg_t LEDMask, + const uint_reg_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 uint_reg_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 uint_reg_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.c new file mode 100644 index 000000000..94843115f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.c @@ -0,0 +1,66 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_TEMPERATURE_C +#include "Temperature.h" + +#if defined(TEMPERATURE_SENSOR_DRIVER_COMPATIBLE) + +static const uint16_t PROGMEM Temperature_Lookup[TEMP_TABLE_SIZE] = +{ + 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_DEGREES); + } + + return TEMP_MAX_TEMP; +} + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.h new file mode 100644 index 000000000..ed3aa7bd8 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/Temperature.h @@ -0,0 +1,147 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief NTC Temperature Sensor board hardware 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 + * \brief NTC Temperature Sensor board hardware driver. + * + * \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 Sec_ModDescription 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. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the ADC and board temperature sensor drivers before first use + * ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128); + * Temperature_Init(); + * + * // Display converted temperature in degrees Celsius + * printf("Current Temperature: %d Degrees\r\n", Temperature_GetTemperature()); + * \endcode + * + * @{ + */ + +#ifndef __TEMPERATURE_H__ +#define __TEMPERATURE_H__ + + /* Includes: */ + #include "../../Common/Common.h" + + /* Preprocessor Checks: */ + #if ((BOARD == BOARD_USBKEY) || (BOARD == BOARD_STK525) || \ + (BOARD == BOARD_STK526) || (BOARD == BOARD_EVK527)) + #define TEMPERATURE_SENSOR_DRIVER_COMPATIBLE + #endif + + #if !defined(__INCLUDE_FROM_TEMPERATURE_C) && !defined(TEMPERATURE_SENSOR_DRIVER_COMPATIBLE) + #error The selected board does not contain a compatible temperature sensor. + #endif + + #if defined(TEMPERATURE_SENSOR_DRIVER_COMPATIBLE) + + /* Includes: */ + #include "../Peripheral/ADC.h" + + /* 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 + + /** Size of the temperature sensor lookup table, in lookup values */ + #define TEMP_TABLE_SIZE 120 + + /** Minimum returnable temperature from the \ref Temperature_GetTemperature() function. */ + #define TEMP_MIN_TEMP TEMP_TABLE_OFFSET_DEGREES + + /** Maximum returnable temperature from the \ref Temperature_GetTemperature() function. */ + #define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET_DEGREES) + + /* Inline Functions: */ + /** Initializes 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_OFFSET_DEGREES -21 + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Buttons.h new file mode 100644 index 000000000..f0f596e84 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Buttons.h @@ -0,0 +1,117 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel EVK1100. + * \copydetails Group_Buttons_EVK1100 + * + * \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_EVK1100 EVK1100 + * \brief Board specific Buttons driver header for the Atmel EVK1100. + * + * Board specific Buttons driver header for the Atmel EVK1100. + * + * + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1SW0 ButtonLowGPIO88
BUTTONS_BUTTON2SW1 ButtonLowGPIO85
BUTTONS_BUTTON3SW2 ButtonLowGPIO82
+ * + * @{ + */ + +#ifndef __BUTTONS_EVK1100_H__ +#define __BUTTONS_EVK1100_H__ + + /* Includes: */ + #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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define BUTTONS_PORT 2 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask of the first button on the board */ + #define BUTTONS_BUTTON1 (1UL << 24) + + /** Mask of the second button on the board */ + #define BUTTONS_BUTTON2 (1UL << 21) + + /** Mask of the third button on the board */ + #define BUTTONS_BUTTON3 (1UL << 18) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + } + + static inline void Buttons_Disable(void) + { + AVR32_GPIO.port[BUTTONS_PORT].gperc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + AVR32_GPIO.port[BUTTONS_PORT].puerc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + } + + static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t Buttons_GetStatus(void) + { + return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2))); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Joystick.h new file mode 100644 index 000000000..adc6aea62 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/Joystick.h @@ -0,0 +1,122 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Atmel EVK1100. + * \copydetails Group_Joystick_EVK1100 + * + * \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_EVK1100 EVK1100 + * \brief Board specific joystick driver header for the Atmel EVK1100. + * + * Board specific joystick driver header for the Atmel EVK1100. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
GPIO25GPIO26GPIO28GPIO27GPIO20
+ * + * @{ + */ + +#ifndef __JOYSTICK_EVK1100_H__ +#define __JOYSTICK_EVK1100_H__ + + /* Includes: */ + #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_PORT 0 + #define JOY_MASK ((1UL << 28) | (1UL << 27) | (1UL << 26) | (1UL << 25) | (1UL << 20)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1UL << 25) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1UL << 26) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT (1UL << 28) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN (1UL << 27) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1UL << 20) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + AVR32_GPIO.port[JOY_PORT].gpers = JOY_MASK; + AVR32_GPIO.port[JOY_PORT].gpers = JOY_MASK; + }; + + static inline void Joystick_Disable(void) + { + AVR32_GPIO.port[JOY_PORT].gperc = JOY_MASK; + AVR32_GPIO.port[JOY_PORT].gperc = JOY_MASK; + }; + + static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t Joystick_GetStatus(void) + { + return (uint32_t)(~(AVR32_GPIO.port[JOY_PORT].pvr & JOY_MASK)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/LEDs.h new file mode 100644 index 000000000..3e5ab8516 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1100/LEDs.h @@ -0,0 +1,173 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel EVK1100. + * \copydetails Group_LEDs_EVK1100 + * + * \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_EVK1100 EVK1100 + * \brief Board specific LED driver header for the Atmel EVK1100. + * + * Board specific LED driver header for the Atmel EVK1100. + * + * + * + * + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenLED0 LEDLowGPIO51
LEDS_LED2GreenLED1 LEDLowGPIO52
LEDS_LED3GreenLED2 LEDLowGPIO53
LEDS_LED4GreenLED3 LEDLowGPIO54
LEDS_LED5GreenLED4 LEDLowGPIO59
LEDS_LED6GreenLED5 LEDLowGPIO60
LEDS_LED7GreenLED6 LEDLowGPIO61
LEDS_LED8GreenLED7 LEDLowGPIO62
+ * + * @{ + */ + +#ifndef __LEDS_EVK1100_H__ +#define __LEDS_EVK1100_H__ + + /* Includes: */ + #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_PORT 1 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1UL << 19) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1UL << 20) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1UL << 21) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1UL << 22) + + /** LED mask for the fifth LED on the board. */ + #define LEDS_LED5 (1UL << 27) + + /** LED mask for the sixth LED on the board. */ + #define LEDS_LED6 (1UL << 28) + + /** LED mask for the seventh LED on the board. */ + #define LEDS_LED7 (1UL << 29) + + /** LED mask for the eighth LED on the board. */ + #define LEDS_LED8 (1UL << 30) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4 \ + LEDS_LED5 | LEDS_LED6 | LEDS_LED7 | LEDS_LED8) + + /** 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) + { + AVR32_GPIO.port[LEDS_PORT].gpers = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].oders = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(void) + { + AVR32_GPIO.port[LEDS_PORT].gperc = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].oderc = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].ovrc = LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask; + } + + static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask; + AVR32_GPIO.port[LEDS_PORT].ovrc = ActiveMask; + } + + static inline void LEDs_ToggleLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrt = LEDMask; + } + + static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t LEDs_GetLEDs(void) + { + return (~AVR32_GPIO.port[LEDS_PORT].ovr & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Buttons.h new file mode 100644 index 000000000..40f8aecf3 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Buttons.h @@ -0,0 +1,113 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel EVK1101. + * \copydetails Group_Buttons_EVK1101 + * + * \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_EVK1101 EVK1101 + * \brief Board specific Buttons driver header for the Atmel EVK1101. + * + * Board specific Buttons driver header for the Atmel EVK1101. + * + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1SW0 ButtonLowGPIO34
BUTTONS_BUTTON2SW1 ButtonLowGPIO35
+ * + * @{ + */ + +#ifndef __BUTTONS_EVK1101_H__ +#define __BUTTONS_EVK1101_H__ + + /* Includes: */ + #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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define BUTTONS_PORT 1 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask of the first button on the board */ + #define BUTTONS_BUTTON1 (1UL << 2) + + /** Mask of the second button on the board */ + #define BUTTONS_BUTTON2 (1UL << 3) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + } + + static inline void Buttons_Disable(void) + { + AVR32_GPIO.port[BUTTONS_PORT].gperc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + AVR32_GPIO.port[BUTTONS_PORT].puerc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + } + + static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t Buttons_GetStatus(void) + { + return (~(AVR32_GPIO.port[BUTTONS_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2))); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Joystick.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Joystick.h new file mode 100644 index 000000000..d61c52e33 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/Joystick.h @@ -0,0 +1,131 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific joystick driver header for the Atmel EVK1101. + * \copydetails Group_Joystick_EVK1101 + * + * \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_EVK1101 EVK1101 + * \brief Board specific joystick driver header for the Atmel EVK1101. + * + * Board specific joystick driver header for the Atmel EVK1101. + * + * + * + * + *
Left Port PinUp Port PinRight Port PinDown Port PinPress Port Pin
GPIO38GPIO39GPIO41GPIO40GPIO13
+ * + * @{ + */ + +#ifndef __JOYSTICK_EVK1101_H__ +#define __JOYSTICK_EVK1101_H__ + + /* Includes: */ + #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_MOVE_PORT 1 + #define JOY_MOVE_MASK ((1UL << 6) | (1UL << 7) | (1UL << 8) | (1UL << 9)) + #define JOY_PRESS_PORT 0 + #define JOY_PRESS_MASK (1UL << 13) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the joystick being pushed in the left direction. */ + #define JOY_LEFT (1UL << 6) + + /** Mask for the joystick being pushed in the upward direction. */ + #define JOY_UP (1UL << 7) + + /** Mask for the joystick being pushed in the right direction. */ + #define JOY_RIGHT (1UL << 9) + + /** Mask for the joystick being pushed in the downward direction. */ + #define JOY_DOWN (1UL << 8) + + /** Mask for the joystick being pushed inward. */ + #define JOY_PRESS (1UL << 13) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Joystick_Init(void) + { + AVR32_GPIO.port[JOY_MOVE_PORT].gpers = JOY_MOVE_MASK; + AVR32_GPIO.port[JOY_PRESS_PORT].gpers = JOY_PRESS_MASK; + + AVR32_GPIO.port[JOY_MOVE_PORT].puers = JOY_MOVE_MASK; + AVR32_GPIO.port[JOY_PRESS_PORT].puers = JOY_PRESS_MASK; + }; + + static inline void Joystick_Disable(void) + { + AVR32_GPIO.port[JOY_MOVE_PORT].gperc = JOY_MOVE_MASK; + AVR32_GPIO.port[JOY_PRESS_PORT].gperc = JOY_PRESS_MASK; + + AVR32_GPIO.port[JOY_MOVE_PORT].puerc = JOY_MOVE_MASK; + AVR32_GPIO.port[JOY_PRESS_PORT].puerc = JOY_PRESS_MASK; + }; + + static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t Joystick_GetStatus(void) + { + return (uint32_t)(~((AVR32_GPIO.port[JOY_MOVE_PORT].pvr & JOY_MOVE_MASK) | + (AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK))); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/LEDs.h new file mode 100644 index 000000000..1f1960d1f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1101/LEDs.h @@ -0,0 +1,156 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel EVK1101. + * \copydetails Group_LEDs_EVK1101 + * + * \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_EVK1101 EVK1101 + * \brief Board specific LED driver header for the Atmel EVK1101. + * + * Board specific LED driver header for the Atmel EVK1101. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenLED0 LEDLowGPIO7
LEDS_LED2GreenLED1 LEDLowGPIO8
LEDS_LED3GreenLED2 LEDLowGPIO21
LEDS_LED4GreenLED3 LEDLowGPIO22
+ * + * @{ + */ + +#ifndef __LEDS_EVK1101_H__ +#define __LEDS_EVK1101_H__ + + /* Includes: */ + #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_PORT 0 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1UL << 7) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1UL << 8) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1UL << 21) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1UL << 22) + + /** LED mask for all the LEDs on the board. */ + #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) + + /** 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) + { + AVR32_GPIO.port[LEDS_PORT].gpers = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].oders = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS; + } + + static inline void LEDs_Disable(void) + { + AVR32_GPIO.port[LEDS_PORT].gperc = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].oderc = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].ovrc = LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS; + AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask; + } + + static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask; + AVR32_GPIO.port[LEDS_PORT].ovrc = ActiveMask; + } + + static inline void LEDs_ToggleLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[LEDS_PORT].ovrt = LEDMask; + } + + static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t LEDs_GetLEDs(void) + { + return (~AVR32_GPIO.port[LEDS_PORT].ovr & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/Buttons.h new file mode 100644 index 000000000..1c6bdd0d4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/Buttons.h @@ -0,0 +1,109 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel EVK1104. + * \copydetails Group_Buttons_EVK1104 + * + * \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_EVK1104 EVK1104 + * \brief Board specific Buttons driver header for the Atmel EVK1104. + * + * Board specific Buttons driver header for the Atmel EVK1104. + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1SW0 ButtonLowGPIO42
+ * + * @{ + */ + +#ifndef __BUTTONS_EVK1104_H__ +#define __BUTTONS_EVK1104_H__ + + /* Includes: */ + #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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define BUTTONS_PORT 1 + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask of the first button on the board */ + #define BUTTONS_BUTTON1 (1UL << 10) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + } + + static inline void Buttons_Disable(void) + { + AVR32_GPIO.port[BUTTONS_PORT].gperc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + AVR32_GPIO.port[BUTTONS_PORT].puerc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); + } + + static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t Buttons_GetStatus(void) + { + return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2))); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/LEDs.h new file mode 100644 index 000000000..145955174 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/UC3/EVK1104/LEDs.h @@ -0,0 +1,174 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel EVK1104. + * \copydetails Group_LEDs_EVK1104 + * + * \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_EVK1104 EVK1104 + * \brief Board specific LED driver header for the Atmel EVK1104. + * + * Board specific LED driver header for the Atmel EVK1104. + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1GreenLED0 LEDLowGPIO67
LEDS_LED2GreenLED1 LEDLowGPIO101
LEDS_LED3GreenLED2 LEDLowGPIO102
LEDS_LED4GreenLED3 LEDLowGPIO105
+ * + * @{ + */ + +#ifndef __LEDS_EVK1104_H__ +#define __LEDS_EVK1104_H__ + + /* Includes: */ + #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_LEDMASK2 (1UL << 3) + #define LEDS_LEDMASK3 ((1UL << 9) | (1UL << 6) | (1UL << 5)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** LED mask for the first LED on the board. */ + #define LEDS_LED1 (1UL << 3) + + /** LED mask for the second LED on the board. */ + #define LEDS_LED2 (1UL << 5) + + /** LED mask for the third LED on the board. */ + #define LEDS_LED3 (1UL << 9) + + /** LED mask for the fourth LED on the board. */ + #define LEDS_LED4 (1UL << 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 the none of the board LEDs */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + AVR32_GPIO.port[2].gpers = LEDS_LEDMASK2; + AVR32_GPIO.port[2].oders = LEDS_LEDMASK2; + AVR32_GPIO.port[2].ovrs = LEDS_LEDMASK2; + + AVR32_GPIO.port[3].gpers = LEDS_LEDMASK3; + AVR32_GPIO.port[3].oders = LEDS_LEDMASK3; + AVR32_GPIO.port[3].ovrs = LEDS_LEDMASK3; + } + + static inline void LEDs_Disable(void) + { + AVR32_GPIO.port[2].gperc = LEDS_LEDMASK2; + AVR32_GPIO.port[2].oderc = LEDS_LEDMASK2; + AVR32_GPIO.port[2].ovrc = LEDS_LEDMASK2; + + AVR32_GPIO.port[3].gperc = LEDS_LEDMASK3; + AVR32_GPIO.port[3].oderc = LEDS_LEDMASK3; + AVR32_GPIO.port[3].ovrc = LEDS_LEDMASK3; + } + + static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[2].ovrc = (LEDMask & LEDS_LEDMASK2); + AVR32_GPIO.port[3].ovrc = (LEDMask & LEDS_LEDMASK3); + } + + static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[2].ovrs = (LEDMask & LEDS_LEDMASK2); + AVR32_GPIO.port[3].ovrs = (LEDMask & LEDS_LEDMASK3); + } + + static inline void LEDs_SetAllLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[2].ovrs = LEDS_LEDMASK2; + AVR32_GPIO.port[2].ovrc = (LEDMask & LEDS_LEDMASK2); + + AVR32_GPIO.port[3].ovrs = LEDS_LEDMASK3; + AVR32_GPIO.port[3].ovrc = (LEDMask & LEDS_LEDMASK3); + } + + static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask) + { + AVR32_GPIO.port[2].ovrs = (LEDMask & LEDS_LEDMASK2); + AVR32_GPIO.port[2].ovrc = (ActiveMask & LEDS_LEDMASK2); + + AVR32_GPIO.port[3].ovrs = (LEDMask & LEDS_LEDMASK3); + AVR32_GPIO.port[3].ovrc = (ActiveMask & LEDS_LEDMASK3); + } + + static inline void LEDs_ToggleLEDs(const uint32_t LEDMask) + { + AVR32_GPIO.port[2].ovrt = (LEDMask & LEDS_LEDMASK2); + AVR32_GPIO.port[3].ovrt = (LEDMask & LEDS_LEDMASK3); + } + + static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint32_t LEDs_GetLEDs(void) + { + return ((~AVR32_GPIO.port[2].ovr & LEDS_LEDMASK2) | (~AVR32_GPIO.port[3].ovr & LEDS_LEDMASK3)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Buttons.h new file mode 100644 index 000000000..ebe24a74f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Buttons.h @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained. + * \copydetails Group_Buttons_A3BU_XPLAINED + * + * \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_A3BU_XPLAINED A3BU_XPLAINED + * \brief Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained. + * + * Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained. + * + * + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1SW0 ButtonLowPORTE.5
BUTTONS_BUTTON2SW1 ButtonLowPORTF.1
BUTTONS_BUTTON3SW2 ButtonLowPORTF.2
+ * + * @{ + */ + +#ifndef __BUTTONS_A3BU_XPLAINED_H__ +#define __BUTTONS_A3BU_XPLAINED_H__ + + /* Includes: */ + #include + + /* 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 << 5) + + /** Button mask for the second button on the board. */ + #define BUTTONS_BUTTON2 (1 << 1) + + /** Button mask for the third button on the board. */ + #define BUTTONS_BUTTON3 (1 << 2) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + PORTE.OUTCLR = BUTTONS_BUTTON1; + PORTE.PIN5CTRL = (PORT_OPC_PULLUP_gc | PORT_INVEN_bm); + + PORTF.OUTCLR = (BUTTONS_BUTTON2 | BUTTONS_BUTTON3); + PORTF.PIN1CTRL = (PORT_OPC_PULLUP_gc | PORT_INVEN_bm); + PORTF.PIN2CTRL = (PORT_OPC_PULLUP_gc | PORT_INVEN_bm); + } + + static inline void Buttons_Disable(void) + { + PORTE.OUTCLR = BUTTONS_BUTTON1; + PORTE.PIN5CTRL = 0; + + PORTF.OUTCLR = (BUTTONS_BUTTON2 | BUTTONS_BUTTON3); + PORTF.PIN1CTRL = 0; + PORTF.PIN2CTRL = 0; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return ((PORTE_IN & BUTTONS_BUTTON1) | (PORTF_IN & (BUTTONS_BUTTON2 | BUTTONS_BUTTON3))); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h new file mode 100644 index 000000000..34f8ce121 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/Dataflash.h @@ -0,0 +1,222 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained. + * \copydetails Group_Dataflash_B1_XPLAINED + * + * \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_B1_XPLAINED B1_XPLAINED + * \brief Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained. + * + * Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained board. + * + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTF.4USARTD0 (In SPI Mode)
+ * + * @{ + */ + +#ifndef __DATAFLASH_B1_XPLAINED_H__ +#define __DATAFLASH_B1_XPLAINED_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB642D.h" + #include "../../../Peripheral/SerialSPI.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_PORT PORTF + #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 0 + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 (1 << 4) + + /** 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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_PORT.DIRSET = DATAFLASH_CHIPCS_MASK; + + PORTCFG.MPCMASK = DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SerialSPI_TransferByte(&USARTD0, Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + SerialSPI_SendByte(&USARTD0, 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 SerialSPI_ReceiveByte(&USARTD0); + } + + /** 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.OUT & 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.OUTCLR = DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT.OUTSET = ChipMask; + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) + return; + + 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h new file mode 100644 index 000000000..f930844c8 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/A3BU_XPLAINED/LEDs.h @@ -0,0 +1,144 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel XMEGA A3BU Xplained. + * \copydetails Group_LEDs_A3BU_XPLAINED + * + * \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_A3BU_XPLAINED A3BU_XPLAINED + * \brief Board specific LED driver header for the Atmel XMEGA A3BU Xplained. + * + * Board specific LED driver header for the Atmel XMEGA A3BU Xplained. + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1YellowLED0 LEDLowPORTR.0
LEDS_LED2YellowLED1 LEDLowPORTR.1
+ * + * @{ + */ + +#ifndef __LEDS_A3BU_XPLAINED_H__ +#define __LEDS_A3BU_XPLAINED_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 << 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) + { + PORTR.DIRSET = LEDS_ALL_LEDS; + PORTR.OUTCLR = LEDS_ALL_LEDS; + + PORTCFG.MPCMASK = LEDS_ALL_LEDS; + PORTR.PIN0CTRL = PORT_INVEN_bm; + } + + static inline void LEDs_Disable(void) + { + PORTR.DIRCLR = LEDS_ALL_LEDS; + PORTR.OUTCLR = LEDS_ALL_LEDS; + + PORTCFG.MPCMASK = 0; + PORTR.PIN0CTRL = LEDS_ALL_LEDS; + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTR_OUTSET = LEDMask; + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTR_OUTCLR = LEDMask; + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTR_OUT = (PORTR.OUT & ~LEDS_ALL_LEDS) | LEDMask; + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + PORTR_OUT = (PORTR.OUT & ~LEDMask) | ActiveMask; + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTR_OUTTGL = LEDMask; + } + + static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t LEDs_GetLEDs(void) + { + return (PORTR_OUT & LEDS_ALL_LEDS); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h new file mode 100644 index 000000000..ae5445a1f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Buttons.h @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Buttons driver header for the Atmel XMEGA B1 Xplained. + * \copydetails Group_Buttons_B1_XPLAINED + * + * \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_B1_XPLAINED B1_XPLAINED + * \brief Board specific Buttons driver header for the Atmel XMEGA B1 Xplained. + * + * Board specific Buttons driver header for the Atmel XMEGA B1 Xplained. + * + * + * + * + * + * + * + *
NameInfoActive LevelPort Pin
BUTTONS_BUTTON1Touch CS0 ButtonLowPORTE.0
BUTTONS_BUTTON2Touch CS1 ButtonLowPORTE.1
BUTTONS_BUTTON3Touch CS2 ButtonLowPORTE.2
BUTTONS_BUTTON4Touch CS3 ButtonLowPORTE.3
+ * + * @{ + */ + +#ifndef __BUTTONS_B1_XPLAINED_H__ +#define __BUTTONS_B1_XPLAINED_H__ + + /* Includes: */ + #include + + /* 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 << 0) + + /** Button mask for the second button on the board. */ + #define BUTTONS_BUTTON2 (1 << 1) + + /** Button mask for the third button on the board. */ + #define BUTTONS_BUTTON3 (1 << 2) + + /** Button mask for the fourth button on the board. */ + #define BUTTONS_BUTTON4 (1 << 3) + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void Buttons_Init(void) + { + PORTE.OUTSET = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4); + + PORTCFG.MPCMASK = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4); + PORTE.PIN0CTRL = (PORT_INVEN_bm | PORT_OPC_PULLUP_gc); + } + + static inline void Buttons_Disable(void) + { + PORTE.OUTCLR = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4); + + PORTCFG.MPCMASK = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4); + PORTE.PIN0CTRL = 0; + } + + static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Buttons_GetStatus(void) + { + return (PORTE_IN & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4)); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h new file mode 100644 index 000000000..2f58c4840 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/Dataflash.h @@ -0,0 +1,224 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained. + * \copydetails Group_Dataflash_A3BU_XPLAINED + * + * \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_A3BU_XPLAINED A3BU_XPLAINED + * \brief Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained. + * + * Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained board. + * + * + * + * + *
NameInfoSelect PinSPI Port
DATAFLASH_CHIP1AT45DB642D (8MB)PORTD.2USARTC0 (In SPI Mode, Remapped)
+ * + * @{ + */ + +#ifndef __DATAFLASH_A3BU_XPLAINED_H__ +#define __DATAFLASH_A3BU_XPLAINED_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../../../Misc/AT45DB642D.h" + #include "../../../Peripheral/SerialSPI.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_PORT PORTD + #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 0 + + /** Mask for the first dataflash chip selected. */ + #define DATAFLASH_CHIP1 (1 << 2) + + /** 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: */ + /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. + * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. + */ + static inline void Dataflash_Init(void) + { + DATAFLASH_CHIPCS_PORT.DIRSET = DATAFLASH_CHIPCS_MASK; + + PORTCFG.MPCMASK = DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm; + + PORTC.REMAP |= PORT_USART0_bm; + } + + /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + * + * \return Last response byte from the dataflash + */ + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) + { + return SerialSPI_TransferByte(&USARTC0, Byte); + } + + /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash. + * + * \param[in] Byte Byte of data to send to the dataflash + */ + static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void Dataflash_SendByte(const uint8_t Byte) + { + SerialSPI_SendByte(&USARTC0, 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 SerialSPI_ReceiveByte(&USARTC0); + } + + /** 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.OUT & 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.OUTCLR = DATAFLASH_CHIPCS_MASK; + DATAFLASH_CHIPCS_PORT.OUTSET = (ChipMask & DATAFLASH_CHIPCS_MASK); + } + + /** Deselects the current dataflash chip, so that no dataflash is selected. */ + static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; + static inline void Dataflash_DeselectChip(void) + { + Dataflash_SelectChip(DATAFLASH_NO_CHIP); + } + + /** Selects a dataflash IC from the given page number, which should range from 0 to + * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one + * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside + * the total number of pages contained in the boards dataflash ICs, all dataflash ICs + * are deselected. + * + * \param[in] PageAddress Address of the page to manipulate, ranging from + * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). + */ + static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) + { + Dataflash_DeselectChip(); + + if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) + return; + + 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-bit address. + * + * \param[in] PageAddress Page address within the selected dataflash IC + * \param[in] BufferByte Address within the dataflash's buffer + */ + static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, + const uint16_t BufferByte) + { + Dataflash_SendByte(PageAddress >> 5); + Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); + Dataflash_SendByte(BufferByte); + } + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h new file mode 100644 index 000000000..b4b743214 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Board/XMEGA/B1_XPLAINED/LEDs.h @@ -0,0 +1,182 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Board specific LED driver header for the Atmel XMEGA B1 Xplained. + * \copydetails Group_LEDs_B1_XPLAINED + * + * \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_B1_XPLAINED B1_XPLAINED + * \brief Board specific LED driver header for the Atmel XMEGA B1 Xplained. + * + * Board specific LED driver header for the Atmel XMEGA B1 Xplained. + * + * + * + * + * + * + * + * + *
NameColorInfoActive LevelPort Pin
LEDS_LED1YellowLED0 LEDHighPORTB.4
LEDS_LED2YellowLED1 LEDHighPORTB.5
LEDS_LED3YellowLED2 LEDHighPORTB.6
LEDS_LED4YellowLED3 LEDHighPORTB.7
LEDS_LED5GreenUSB LEDLowPORTE.4
+ * + * @{ + */ + +#ifndef __LEDS_B1_XPLAINED_H__ +#define __LEDS_B1_XPLAINED_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 + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define LEDS_PORTB_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) + #define LEDS_PORTE_LEDS LEDS_LED5 + + #define LEDS_PORTE_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 << 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 the fifth LED on the board. */ + #define LEDS_LED5 ((1 << 4) >> 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 | LEDS_LED5) + + /** LED mask for none of the board LEDs. */ + #define LEDS_NO_LEDS 0 + + /* Inline Functions: */ + #if !defined(__DOXYGEN__) + static inline void LEDs_Init(void) + { + PORTB.DIRSET = LEDS_PORTB_LEDS; + PORTB.OUTCLR = LEDS_PORTB_LEDS; + + PORTCFG.MPCMASK = LEDS_PORTB_LEDS; + PORTB.PIN0CTRL = PORT_INVEN_bm; + + PORTE.DIRSET = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + PORTE.OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_Disable(void) + { + PORTB.DIRCLR = LEDS_PORTB_LEDS; + PORTB.OUTCLR = LEDS_PORTB_LEDS; + + PORTCFG.MPCMASK = 0; + PORTB.PIN0CTRL = LEDS_PORTB_LEDS; + + PORTE.DIRCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + PORTE.OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) + { + PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS); + PORTE_OUTSET = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) + { + PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS); + PORTE_OUTCLR = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) + { + PORTB_OUTCLR = LEDS_PORTB_LEDS; + PORTE_OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT); + + PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS); + PORTE_OUTSET = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) + { + PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS); + PORTE_OUTCLR = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + + PORTB_OUTSET = (ActiveMask & LEDS_PORTB_LEDS); + PORTE_OUTSET = ((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT); + } + + static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) + { + PORTB_OUTTGL = (LEDMask & LEDS_PORTB_LEDS); + PORTE_OUTTGL = ((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 ((PORTB_OUT & LEDS_PORTB_LEDS) | (PORTE_OUT & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT))); + } + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB321C.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB321C.h new file mode 100644 index 000000000..5c6780f33 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB321C.h @@ -0,0 +1,100 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Command constants for the Atmel AT45DB321C Dataflash. + * \copydetails Group_AT45DB321C + */ + +/** \ingroup Group_MiscDrivers + * \defgroup Group_AT45DB321C Atmel AT45DB321C Dataflash Commands + * \brief Command constants for the Atmel AT45DB321C Dataflash. + * + * Dataflash command constants for the Atmel AT45DB321C Dataflash IC. + * + * @{ + */ + +#ifndef __AT45DB321C_CMDS_H__ +#define __AT45DB321C_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) + //@} + + /** \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 + //@} + + /** Manufacturer code for Atmel Corporation, returned by Atmel Dataflash ICs in response to the \c DF_CMD_READMANUFACTURERDEVICEINFO command. */ + #define DF_MANUFACTURER_ATMEL 0x1F + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB642D.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB642D.h new file mode 100644 index 000000000..cbd15d63f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/AT45DB642D.h @@ -0,0 +1,116 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Command constants for the Atmel AT45DB642D Dataflash. + * \copydetails Group_AT45DB642D + */ + +/** \ingroup Group_MiscDrivers + * \defgroup Group_AT45DB642D Atmel AT45DB642D Dataflash Commands + * \brief Command constants for the Atmel AT45DB642D Dataflash. + * + * Dataflash command constants for the Atmel AT45DB642D Dataflash IC. + * + * @{ + */ + +#ifndef __AT45DB642D_CMDS_H__ +#define __AT45DB642D_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) + //@} + + /** \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_BINARYPAGESIZEMODEON ((char[]){0x3D, 0x2A, 0x80, 0xA6}) + #define DF_CMD_BINARYPAGESIZEMODEON_BYTE1 0x3D + #define DF_CMD_BINARYPAGESIZEMODEON_BYTE2 0x2A + #define DF_CMD_BINARYPAGESIZEMODEON_BYTE3 0x80 + #define DF_CMD_BINARYPAGESIZEMODEON_BYTE4 0xA6 + + #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F + //@} + + /** Manufacturer code for Atmel Corporation, returned by Atmel Dataflash ICs in response to the \c DF_CMD_READMANUFACTURERDEVICEINFO command. */ + #define DF_MANUFACTURER_ATMEL 0x1F + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/RingBuffer.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/RingBuffer.h new file mode 100644 index 000000000..6d0f60ffa --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/RingBuffer.h @@ -0,0 +1,303 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Lightweight ring (circular) buffer, for fast insertion/deletion of bytes. + * + * Lightweight ring buffer, for fast insertion/deletion. Multiple buffers can be created of + * different sizes to suit different needs. + * + * Note that for each buffer, insertion and removal operations may occur at the same time (via + * a multi-threaded ISR based system) however the same kind of operation (two or more insertions + * or deletions) must not overlap. If there is possibility of two or more of the same kind of + * operating occurring at the same point in time, atomic (mutex) locking should be used. + */ + +/** \ingroup Group_MiscDrivers + * \defgroup Group_RingBuff Generic Byte Ring Buffer - LUFA/Drivers/Misc/RingBuffer.h + * \brief Lightweight ring buffer, for fast insertion/deletion of bytes. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Lightweight ring buffer, for fast insertion/deletion. Multiple buffers can be created of + * different sizes to suit different needs. + * + * Note that for each buffer, insertion and removal operations may occur at the same time (via + * a multi-threaded ISR based system) however the same kind of operation (two or more insertions + * or deletions) must not overlap. If there is possibility of two or more of the same kind of + * operating occurring at the same point in time, atomic (mutex) locking should be used. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Create the buffer structure and its underlying storage array + * RingBuffer_t Buffer; + * uint8_t BufferData[128]; + * + * // Initialize the buffer with the created storage array + * RingBuffer_InitBuffer(&Buffer, BufferData, sizeof(BufferData)); + * + * // Insert some data into the buffer + * RingBuffer_Insert(Buffer, 'H'); + * RingBuffer_Insert(Buffer, 'E'); + * RingBuffer_Insert(Buffer, 'L'); + * RingBuffer_Insert(Buffer, 'L'); + * RingBuffer_Insert(Buffer, 'O'); + * + * // Cache the number of stored bytes in the buffer + * uint16_t BufferCount = RingBuffer_GetCount(&Buffer); + * + * // Printer stored data length + * printf("Buffer Length: %d, Buffer Data: \r\n", BufferCount); + * + * // Print contents of the buffer one character at a time + * while (BufferCount--) + * putc(RingBuffer_Remove(&Buffer)); + * \endcode + * + * @{ + */ + +#ifndef __RING_BUFFER_H__ +#define __RING_BUFFER_H__ + + /* Includes: */ + #include "../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Type Defines: */ + /** \brief Ring Buffer Management Structure. + * + * Type define for a new ring buffer object. Buffers should be initialized via a call to + * \ref RingBuffer_InitBuffer() before use. + */ + typedef struct + { + uint8_t* In; /**< Current storage location in the circular buffer. */ + uint8_t* Out; /**< Current retrieval location in the circular buffer. */ + uint8_t* Start; /**< Pointer to the start of the buffer's underlying storage array. */ + uint8_t* End; /**< Pointer to the end of the buffer's underlying storage array. */ + uint16_t Size; /**< Size of the buffer's underlying storage array. */ + uint16_t Count; /**< Number of bytes currently stored in the buffer. */ + } RingBuffer_t; + + /* Inline Functions: */ + /** Initializes a ring buffer ready for use. Buffers must be initialized via this function + * before any operations are called upon them. Already initialized buffers may be reset + * by re-initializing them using this function. + * + * \param[out] Buffer Pointer to a ring buffer structure to initialize. + * \param[out] DataPtr Pointer to a global array that will hold the data stored into the ring buffer. + * \param[out] Size Maximum number of bytes that can be stored in the underlying data array. + */ + static inline void RingBuffer_InitBuffer(RingBuffer_t* Buffer, uint8_t* const DataPtr, const uint16_t Size) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + static inline void RingBuffer_InitBuffer(RingBuffer_t* Buffer, uint8_t* const DataPtr, const uint16_t Size) + { + GCC_FORCE_POINTER_ACCESS(Buffer); + + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + Buffer->In = DataPtr; + Buffer->Out = DataPtr; + Buffer->Start = &DataPtr[0]; + Buffer->End = &DataPtr[Size]; + Buffer->Size = Size; + Buffer->Count = 0; + + SetGlobalInterruptMask(CurrentGlobalInt); + } + + /** Retrieves the current number of bytes stored in a particular buffer. This value is computed + * by entering an atomic lock on the buffer, so that the buffer cannot be modified while the + * computation takes place. This value should be cached when reading out the contents of the buffer, + * so that as small a time as possible is spent in an atomic lock. + * + * \note The value returned by this function is guaranteed to only be the minimum number of bytes + * stored in the given buffer; this value may change as other threads write new data, thus + * the returned number should be used only to determine how many successive reads may safely + * be performed on the buffer. + * + * \param[in] Buffer Pointer to a ring buffer structure whose count is to be computed. + * + * \return Number of bytes currently stored in the buffer. + */ + static inline uint16_t RingBuffer_GetCount(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static inline uint16_t RingBuffer_GetCount(RingBuffer_t* const Buffer) + { + uint16_t Count; + + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + Count = Buffer->Count; + + SetGlobalInterruptMask(CurrentGlobalInt); + return Count; + } + + /** Retrieves the free space in a particular buffer. This value is computed by entering an atomic lock + * on the buffer, so that the buffer cannot be modified while the computation takes place. + * + * \note The value returned by this function is guaranteed to only be the maximum number of bytes + * free in the given buffer; this value may change as other threads write new data, thus + * the returned number should be used only to determine how many successive writes may safely + * be performed on the buffer when there is a single writer thread. + * + * \param[in] Buffer Pointer to a ring buffer structure whose free count is to be computed. + * + * \return Number of free bytes in the buffer. + */ + static inline uint16_t RingBuffer_GetFreeCount(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static inline uint16_t RingBuffer_GetFreeCount(RingBuffer_t* const Buffer) + { + return (Buffer->Size - RingBuffer_GetCount(Buffer)); + } + + /** Atomically determines if the specified ring buffer contains any data. This should + * be tested before removing data from the buffer, to ensure that the buffer does not + * underflow. + * + * If the data is to be removed in a loop, store the total number of bytes stored in the + * buffer (via a call to the \ref RingBuffer_GetCount() function) in a temporary variable + * to reduce the time spent in atomicity locks. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into. + * + * \return Boolean \c true if the buffer contains no free space, false otherwise. + */ + static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer) + { + return (RingBuffer_GetCount(Buffer) == 0); + } + + /** Atomically determines if the specified ring buffer contains any free space. This should + * be tested before storing data to the buffer, to ensure that no data is lost due to a + * buffer overrun. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into. + * + * \return Boolean \c true if the buffer contains no free space, false otherwise. + */ + static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer) + { + return (RingBuffer_GetCount(Buffer) == Buffer->Size); + } + + /** Inserts an element into the ring buffer. + * + * \warning Only one execution thread (main program thread or an ISR) may insert into a single buffer + * otherwise data corruption may occur. Insertion and removal may occur from different execution + * threads. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to insert into. + * \param[in] Data Data element to insert into the buffer. + */ + static inline void RingBuffer_Insert(RingBuffer_t* Buffer, const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); + static inline void RingBuffer_Insert(RingBuffer_t* Buffer, const uint8_t Data) + { + GCC_FORCE_POINTER_ACCESS(Buffer); + + *Buffer->In = Data; + + if (++Buffer->In == Buffer->End) + Buffer->In = Buffer->Start; + + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + Buffer->Count++; + + SetGlobalInterruptMask(CurrentGlobalInt); + } + + /** Removes an element from the ring buffer. + * + * \warning Only one execution thread (main program thread or an ISR) may remove from a single buffer + * otherwise data corruption may occur. Insertion and removal may occur from different execution + * threads. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from. + * + * \return Next data element stored in the buffer. + */ + static inline uint8_t RingBuffer_Remove(RingBuffer_t* Buffer) ATTR_NON_NULL_PTR_ARG(1); + static inline uint8_t RingBuffer_Remove(RingBuffer_t* Buffer) + { + GCC_FORCE_POINTER_ACCESS(Buffer); + + uint8_t Data = *Buffer->Out; + + if (++Buffer->Out == Buffer->End) + Buffer->Out = Buffer->Start; + + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + Buffer->Count--; + + SetGlobalInterruptMask(CurrentGlobalInt); + + return Data; + } + + /** Returns the next element stored in the ring buffer, without removing it. + * + * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from. + * + * \return Next data element stored in the buffer. + */ + static inline uint8_t RingBuffer_Peek(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static inline uint8_t RingBuffer_Peek(RingBuffer_t* const Buffer) + { + return *Buffer->Out; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/TerminalCodes.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/TerminalCodes.h new file mode 100644 index 000000000..2f71a84b2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Misc/TerminalCodes.h @@ -0,0 +1,231 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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 + * \brief ANSI terminal special escape code macros. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Escape code macros for ANSI compliant text terminals. + * + * \note If desired, the macro \c 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). + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * printf("Normal String, " + * ESC_BOLD_ON "Bold String, " + * ESC_UNDERLINE_ON "Bold and Underlined String" + * ESC_RESET ESC_FG_BLUE ESC_BG_YELLOW "Normal Blue-on-Yellow 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 \c ESC_* mask. + */ + #define ANSI_ESCAPE_SEQUENCE(EscapeSeq) "\33[" EscapeSeq + #else + #define ANSI_ESCAPE_SEQUENCE(EscapeSeq) + #endif + + /** \name Text Display Modifier Control 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/ADC.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/ADC.h new file mode 100644 index 000000000..ebce11b33 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/ADC.h @@ -0,0 +1,75 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Hardware Analogue-to-Digital converter driver. + * + * This file is the master dispatch header file for the device-specific ADC driver, for microcontrollers + * containing an ADC. + * + * User code should include this file, which will in turn include the correct ADC driver header file for the + * currently selected architecture and microcontroller model. + */ + +/** \ingroup Group_PeripheralDrivers + * \defgroup Group_ADC ADC Driver - LUFA/Drivers/Peripheral/ADC.h + * \brief Hardware Analogue-to-Digital converter driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Hardware ADC driver. This module provides an easy to use driver for the hardware ADC + * present on many microcontrollers, for the conversion of analogue signals into the + * digital domain. + * + * \note The exact API for this driver may vary depending on the target used - see + * individual target module documentation for the API specific to your target processor. + */ + +#ifndef __ADC_H__ +#define __ADC_H__ + + /* Macros: */ + #define __INCLUDE_FROM_ADC_H + + /* Includes: */ + #include "../../Common/Common.h" + + /* Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/ADC_AVR8.h" + #else + #error The ADC peripheral driver is not currently available for your selected architecture. + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h new file mode 100644 index 000000000..c002f79f7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/ADC_AVR8.h @@ -0,0 +1,456 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief ADC Peripheral Driver (AVR8) + * + * 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_AVR8 ADC Peripheral Driver (AVR8) + * + * \section Sec_ModDescription Module Description + * 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. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the ADC driver before first use + * ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32); + * + * // Must setup the ADC channel to read beforehand + * ADC_SetupChannel(1); + * + * // Perform a single conversion of the ADC channel 1 + * ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1); + * printf("Conversion Result: %d\r\n", ADC_GetResult()); + * + * // Start reading ADC channel 1 in free running (continuous conversion) mode + * ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1); + * for (;;) + * { + * while (!(ADC_IsReadingComplete())) {}; + * printf("Conversion Result: %d\r\n", ADC_GetResult()); + * } + * \endcode + * + * @{ + */ + +#ifndef __ADC_AVR8_H__ +#define __ADC_AVR8_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_ADC_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/ADC.h instead. + #endif + + #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ + defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ + defined(__AVR_ATmega32U6__)) + #error The ADC peripheral driver is not currently available for your selected microcontroller model. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define _ADC_GET_MUX_MASK2(y) ADC_CHANNEL ## y + #define _ADC_GET_MUX_MASK(y) _ADC_GET_MUX_MASK2(y) + #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 + * \ref 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 + * \ref 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) + + #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 + + /** MUX mask define for the internal 1.1V band-gap channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */ + #define ADC_1100MV_BANDGAP (0x1E << MUX0) + + /** Retrieves the ADC MUX mask for the given ADC channel number. + * + * \attention This macro will only work correctly on channel numbers that are compile-time + * constants defined by the preprocessor. + * + * \param[in] Channel Index of the ADC channel whose MUX mask is to be retrieved. + */ + #define ADC_GET_CHANNEL_MASK(Channel) _ADC_GET_MUX_MASK(Channel) + //@} + + /* 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. + * + * \warning The channel number must be specified as an integer, and not a \c ADC_CHANNEL* 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. + * + * \warning The channel number must be specified as an integer, and not a \c ADC_CHANNEL* 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. + * + * \return Converted ADC result for the given ADC channel. + */ + 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(); + } + + /** Initializes 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(const uint8_t Mode) ATTR_ALWAYS_INLINE; + static inline void ADC_Init(const 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_Disable(void) ATTR_ALWAYS_INLINE; + static inline void ADC_Disable(void) + { + ADCSRA = 0; + } + + /** Indicates if the ADC is currently enabled. + * + * \return Boolean \c true if the ADC subsystem is currently enabled, \c 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h new file mode 100644 index 000000000..dde3ec5a7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SPI_AVR8.h @@ -0,0 +1,256 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief SPI Peripheral Driver (AVR8) + * + * On-chip SPI driver for the 8-bit AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI driver + * dispatch header located in LUFA/Drivers/Peripheral/SPI.h. + */ + +/** \ingroup Group_SPI + * \defgroup Group_SPI_AVR8 SPI Peripheral Driver (AVR8) + * + * \section Sec_ModDescription Module Description + * Driver for the hardware SPI port available on most 8-bit AVR microcontroller models. This + * module provides an easy to use driver for the setup and transfer of data over the + * AVR's SPI port. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI driver + * dispatch header located in LUFA/Drivers/Peripheral/SPI.h. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the SPI driver before first use + * SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | + * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); + * + * // Send several bytes, ignoring the returned data + * SPI_SendByte(0x01); + * SPI_SendByte(0x02); + * SPI_SendByte(0x03); + * + * // Receive several bytes, sending a dummy 0x00 byte each time + * uint8_t Byte1 = SPI_ReceiveByte(); + * uint8_t Byte2 = SPI_ReceiveByte(); + * uint8_t Byte3 = SPI_ReceiveByte(); + * + * // Send a byte, and store the received byte from the same transaction + * uint8_t ResponseByte = SPI_TransferByte(0xDC); + * \endcode + * + * @{ + */ + +#ifndef __SPI_AVR8_H__ +#define __SPI_AVR8_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SPI_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/SPI.h instead. + #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 \ref SPI_Init(). Divides the system clock by a factor of 2. */ + #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 4. */ + #define SPI_SPEED_FCPU_DIV_4 0 + + /** SPI prescaler mask for \ref 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 \ref SPI_Init(). Divides the system clock by a factor of 16. */ + #define SPI_SPEED_FCPU_DIV_16 (1 << SPR0) + + /** SPI prescaler mask for \ref 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 \ref 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 \ref 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 \ref SPI_Init(). Indicates that the SCK should lead on the rising edge. */ + #define SPI_SCK_LEAD_RISING (0 << CPOL) + + /** SPI clock polarity mask for \ref 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 \ref SPI_Init(). Indicates that the data should sampled on the leading edge. */ + #define SPI_SAMPLE_LEADING (0 << CPHA) + + /** SPI data sample mode mask for \ref 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 \ref SPI_Init(). Indicates that data should be shifted out MSB first. */ + #define SPI_ORDER_MSB_FIRST (0 << DORD) + + /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out LSB first. */ + #define SPI_ORDER_LSB_FIRST (1 << DORD) + //@} + + /** \name SPI Mode Configuration Masks */ + //@{ + /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */ + #define SPI_MODE_SLAVE (0 << MSTR) + + /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */ + #define SPI_MODE_MASTER (1 << MSTR) + //@} + + /* Inline Functions: */ + /** Initializes 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 \c SPI_SPEED_*, + * \c SPI_SCK_*, \c SPI_SAMPLE_*, \c SPI_ORDER_* and \c SPI_MODE_* masks. + */ + static inline void SPI_Init(const uint8_t SPIOptions) + { + /* Prevent high rise times on PB.0 (/SS) from forcing a change to SPI slave mode */ + DDRB |= (1 << 0); + PORTB |= (1 << 0); + + DDRB |= ((1 << 1) | (1 << 2)); + DDRB &= ~(1 << 3); + PORTB |= (1 << 3); + + if (SPIOptions & SPI_USE_DOUBLESPEED) + SPSR |= (1 << SPI2X); + else + SPSR &= ~(1 << SPI2X); + + /* Switch /SS to input mode after configuration to allow for forced mode changes */ + DDRB &= ~(1 << 0); + + SPCR = ((1 << SPE) | SPIOptions); + } + + /** Turns off the SPI driver, disabling and returning used hardware to their default configuration. */ + static inline void SPI_Disable(void) + { + DDRB &= ~((1 << 1) | (1 << 2)); + PORTB &= ~((1 << 0) | (1 << 3)); + + SPCR = 0; + SPSR = 0; + } + + /** Retrieves the currently selected SPI mode, once the SPI interface has been configured. + * + * \return \ref SPI_MODE_MASTER if the interface is currently in SPI Master mode, \ref SPI_MODE_SLAVE otherwise + */ + static inline uint8_t SPI_GetCurrentMode(void) ATTR_ALWAYS_INLINE; + static inline uint8_t SPI_GetCurrentMode(void) + { + return (SPCR & SPI_MODE_MASTER); + } + + /** 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/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SerialSPI_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SerialSPI_AVR8.h new file mode 100644 index 000000000..9a122f501 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/SerialSPI_AVR8.h @@ -0,0 +1,200 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master SPI Mode Serial USART Peripheral Driver (XMEGA) + * + * On-chip Master SPI mode USART driver for the XMEGA AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI Master + * Mode USART driver dispatch header located in LUFA/Drivers/Peripheral/Serial.h. + */ + +/** \ingroup Group_SerialSPI + * \defgroup Group_SerialSPI_AVR8 Master SPI Mode Serial USART Peripheral Driver (AVR8) + * + * \section Sec_ModDescription Module Description + * On-chip serial USART driver for the 8-bit AVR8 microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI Master + * driver dispatch header located in LUFA/Drivers/Peripheral/SerialSPI.h. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the Master SPI mode USART driver before first use, with 1Mbit baud + * SerialSPI_Init((USART_SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING | SPI_ORDER_MSB_FIRST), 1000000); + * + * // Send several bytes, ignoring the returned data + * SerialSPI_SendByte(0x01); + * SerialSPI_SendByte(0x02); + * SerialSPI_SendByte(0x03); + * + * // Receive several bytes, sending a dummy 0x00 byte each time + * uint8_t Byte1 = SerialSPI_ReceiveByte(); + * uint8_t Byte2 = SerialSPI_ReceiveByte(); + * uint8_t Byte3 = SerialSPI_ReceiveByte(); + * + * // Send a byte, and store the received byte from the same transaction + * uint8_t ResponseByte = SerialSPI_TransferByte(0xDC); + * \endcode + * + * @{ + */ + +#ifndef __SERIAL_SPI_AVR8_H__ +#define __SERIAL_SPI_AVR8_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SERIAL_SPI_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + #define SERIAL_SPI_UBBRVAL(Baud) ((Baud < (F_CPU / 2)) ? ((F_CPU / (2 * Baud)) - 1) : 0) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name SPI SCK Polarity Configuration Masks */ + //@{ + /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the rising edge. */ + #define USART_SPI_SCK_LEAD_RISING (0 << UCPOL) + + /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the falling edge. */ + #define USART_SPI_SCK_LEAD_FALLING (1 << UCPOL) + //@} + + /** \name SPI Sample Edge Configuration Masks */ + //@{ + /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should sampled on the leading edge. */ + #define USART_SPI_SAMPLE_LEADING (0 << UPCHA) + + /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge. */ + #define USART_SPI_SAMPLE_TRAILING (1 << UPCHA) + //@} + + /** \name SPI Data Ordering Configuration Masks */ + //@{ + /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out MSB first. */ + #define USART_SPI_ORDER_MSB_FIRST (0 << UDORD) + + /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out LSB first. */ + #define USART_SPI_ORDER_LSB_FIRST (1 << UDORD) + //@} + + /* Inline Functions: */ + /** Initialize the USART module in Master SPI mode. + * + * \param[in] SPIOptions USART SPI Options, a mask consisting of one of each of the \c USART_SPI_SCK_*, + * \c USART_SPI_SAMPLE_* and \c USART_SPI_ORDER_* masks. + * \param[in] BaudRate SPI baud rate, in bits per second. + */ + static inline void SerialSPI_Init(const uint8_t SPIOptions, + const uint32_t BaudRate) + { + UBRR1 = SERIAL_SPI_UBBRVAL(BaudRate); + + UCSR1C = ((1 << UMSEL11) | (1 << UMSEL10) | SPIOptions); + 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 SerialSPI_Disable(void) + { + UCSR1B = 0; + UCSR1A = 0; + UCSR1C = 0; + + UBRR1 = 0; + + DDRD &= ~(1 << 3); + PORTD &= ~(1 << 2); + } + + /** Sends and receives a byte through the USART SPI interface, blocking until the transfer is complete. + * + * \param[in] DataByte Byte to send through the USART SPI interface. + * + * \return Response byte from the attached SPI device. + */ + static inline uint8_t SerialSPI_TransferByte(const uint8_t DataByte) + { + UDR1 = DataByte; + while (!(UCSR1A & (1 << TXC1))); + UCSR1A = (1 << TXC1); + return UDR1; + } + + /** Sends a byte through the USART SPI interface, blocking until the transfer is complete. The response + * byte sent to from the attached SPI device is ignored. + * + * \param[in] DataByte Byte to send through the USART SPI interface. + */ + static inline void SerialSPI_SendByte(const uint8_t DataByte) + { + SerialSPI_TransferByte(DataByte); + } + + /** Sends a dummy byte through the USART 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 SerialSPI_ReceiveByte(void) + { + return SerialSPI_TransferByte(0); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.c new file mode 100644 index 000000000..a1f64b022 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.c @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_SERIAL_C +#include "../Serial.h" + +FILE USARTSerialStream; + +int Serial_putchar(char DataByte, + FILE *Stream) +{ + (void)Stream; + + Serial_SendByte(DataByte); + return 0; +} + +int Serial_getchar(FILE *Stream) +{ + (void)Stream; + + if (!(Serial_IsCharReceived())) + return _FDEV_EOF; + + return Serial_ReceiveByte(); +} + +int Serial_getchar_Blocking(FILE *Stream) +{ + (void)Stream; + + while (!(Serial_IsCharReceived())); + return Serial_ReceiveByte(); +} + +void Serial_SendString_P(const char* FlashStringPtr) +{ + uint8_t CurrByte; + + while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00) + { + Serial_SendByte(CurrByte); + FlashStringPtr++; + } +} + +void Serial_SendString(const char* StringPtr) +{ + uint8_t CurrByte; + + while ((CurrByte = *StringPtr) != 0x00) + { + Serial_SendByte(CurrByte); + StringPtr++; + } +} + +void Serial_SendData(const uint8_t* Buffer, + uint16_t Length) +{ + while (Length--) + Serial_SendByte(*(Buffer++)); +} + +void Serial_CreateStream(FILE* Stream) +{ + if (!(Stream)) + { + Stream = &USARTSerialStream; + stdin = Stream; + stdout = Stream; + } + + *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW); +} + +void Serial_CreateBlockingStream(FILE* Stream) +{ + if (!(Stream)) + { + Stream = &USARTSerialStream; + stdin = Stream; + stdout = Stream; + } + + *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW); +} + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.h new file mode 100644 index 000000000..8416082f5 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/Serial_AVR8.h @@ -0,0 +1,239 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Serial USART Peripheral Driver (AVR8) + * + * On-chip serial USART driver for the 8-bit AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the USART driver + * dispatch header located in LUFA/Drivers/Peripheral/Serial.h. + */ + +/** \ingroup Group_Serial + * \defgroup Group_Serial_AVR8 Serial USART Peripheral Driver (AVR8) + * + * \section Sec_ModDescription Module Description + * On-chip serial USART driver for the 8-bit AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the USART driver + * dispatch header located in LUFA/Drivers/Peripheral/Serial.h. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the serial USART driver before first use, with 9600 baud (and no double-speed mode) + * Serial_Init(9600, false); + * + * // Send a string through the USART + * Serial_TxString("Test String\r\n"); + * + * // Receive a byte through the USART + * uint8_t DataByte = Serial_RxByte(); + * \endcode + * + * @{ + */ + +#ifndef __SERIAL_AVR8_H__ +#define __SERIAL_AVR8_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "../../Misc/TerminalCodes.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SERIAL_H) && !defined(__INCLUDE_FROM_SERIAL_C) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* External Variables: */ + extern FILE USARTSerialStream; + + /* Function Prototypes: */ + int Serial_putchar(char DataByte, + FILE *Stream); + int Serial_getchar(FILE *Stream); + int Serial_getchar_Blocking(FILE *Stream); + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is + * not set. + * + * \param[in] Baud Target serial UART baud rate. + * + * \return Closest UBRR register value for the given UART frequency. + */ + #define SERIAL_UBBRVAL(Baud) ((((F_CPU / 16) + (Baud / 2)) / (Baud)) - 1) + + /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is + * set. + * + * \param[in] Baud Target serial UART baud rate. + * + * \return Closest UBRR register value for the given UART frequency. + */ + #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_SendString_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_SendString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1); + + /** Transmits a given buffer located in SRAM memory through the USART. + * + * \param[in] Buffer Pointer to a buffer containing the data to send. + * \param[in] Length Length of the data to send, in bytes. + */ + void Serial_SendData(const uint8_t* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Creates a standard character stream from the USART so that it can be used with all the regular functions + * in the avr-libc \c library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created + * stream is bidirectional and can be used for both input and output functions. + * + * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single + * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may + * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own + * line buffering. + * + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout + * and \c stdin will be configured to use the USART. + * + * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used. + */ + void Serial_CreateStream(FILE* Stream); + + /** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates + * the transfer. + * + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout + * and \c stdin will be configured to use the USART. + * + * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used. + */ + void Serial_CreateBlockingStream(FILE* Stream); + + /* 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_Disable(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 \c true if a character has been received, \c 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_SendByte(const char DataByte) ATTR_ALWAYS_INLINE; + static inline void Serial_SendByte(const char DataByte) + { + while (!(UCSR1A & (1 << UDRE1))); + UDR1 = DataByte; + } + + /** Receives the next byte from the USART. + * + * \return Next byte received from the USART, or a negative value if no byte has been received. + */ + static inline int16_t Serial_ReceiveByte(void) ATTR_ALWAYS_INLINE; + static inline int16_t Serial_ReceiveByte(void) + { + if (!(Serial_IsCharReceived())) + return -1; + + return UDR1; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c new file mode 100644 index 000000000..3cc3f0b6d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.c @@ -0,0 +1,207 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) && defined(TWCR) + +#define __INCLUDE_FROM_TWI_C +#include "../TWI.h" + +uint8_t 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 TWI_ERROR_BusFault; + } + } + + _delay_us(10); + } + + if (!(TimeoutRemaining)) + { + TWCR = (1 << TWEN); + return TWI_ERROR_BusCaptureTimeout; + } + + TWDR = SlaveAddress; + TWCR = ((1 << TWINT) | (1 << TWEN)); + + TimeoutRemaining = (TimeoutMS * 100); + while (TimeoutRemaining--) + { + if (TWCR & (1 << TWINT)) + break; + + _delay_us(10); + } + + if (!(TimeoutRemaining)) + return TWI_ERROR_SlaveResponseTimeout; + + switch (TWSR & TW_STATUS_MASK) + { + case TW_MT_SLA_ACK: + case TW_MR_SLA_ACK: + return TWI_ERROR_NoError; + default: + TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN)); + return TWI_ERROR_SlaveNotReady; + } + } +} + +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); +} + +bool TWI_ReceiveByte(uint8_t* const Byte, + const bool LastByte) +{ + uint8_t TWCRMask; + + if (LastByte) + TWCRMask = ((1 << TWINT) | (1 << TWEN)); + else + TWCRMask = ((1 << TWINT) | (1 << TWEN) | (1 << TWEA)); + + TWCR = TWCRMask; + while (!(TWCR & (1 << TWINT))); + *Byte = TWDR; + + uint8_t Status = (TWSR & TW_STATUS_MASK); + + return ((LastByte) ? (Status == TW_MR_DATA_NACK) : (Status == TW_MR_DATA_ACK)); +} + +uint8_t TWI_ReadPacket(const uint8_t SlaveAddress, + const uint8_t TimeoutMS, + const uint8_t* InternalAddress, + uint8_t InternalAddressLen, + uint8_t* Buffer, + uint8_t Length) +{ + uint8_t ErrorCode; + + if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_WRITE, + TimeoutMS)) == TWI_ERROR_NoError) + { + while (InternalAddressLen--) + { + if (!(TWI_SendByte(*(InternalAddress++)))) + { + ErrorCode = TWI_ERROR_SlaveNAK; + break; + } + } + + if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_READ, + TimeoutMS)) == TWI_ERROR_NoError) + { + while (Length--) + { + if (!(TWI_ReceiveByte(Buffer++, (Length == 0)))) + { + ErrorCode = TWI_ERROR_SlaveNAK; + break; + } + } + + TWI_StopTransmission(); + } + } + + return ErrorCode; +} + +uint8_t TWI_WritePacket(const uint8_t SlaveAddress, + const uint8_t TimeoutMS, + const uint8_t* InternalAddress, + uint8_t InternalAddressLen, + const uint8_t* Buffer, + uint8_t Length) +{ + uint8_t ErrorCode; + + if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_WRITE, + TimeoutMS)) == TWI_ERROR_NoError) + { + while (InternalAddressLen--) + { + if (!(TWI_SendByte(*(InternalAddress++)))) + { + ErrorCode = TWI_ERROR_SlaveNAK; + break; + } + } + + while (Length--) + { + if (!(TWI_SendByte(*(Buffer++)))) + { + ErrorCode = TWI_ERROR_SlaveNAK; + break; + } + } + + TWI_StopTransmission(); + } + + return ErrorCode; +} + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h new file mode 100644 index 000000000..92c7389a6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/AVR8/TWI_AVR8.h @@ -0,0 +1,304 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief TWI Peripheral Driver (AVR8) + * + * On-chip TWI driver for the 8-bit AVR microcontrollers. + * + * \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_AVR8 TWI Peripheral Driver (AVR8) + * + * \section Sec_ModDescription Module Description + * Master mode TWI driver for the 8-bit AVR microcontrollers which contain a hardware TWI module. + * + * \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. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * Low Level API Example: + * \code + * // Initialize the TWI driver before first use at 200KHz + * TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 200000)); + * + * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout + * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10) == TWI_ERROR_NoError) + * { + * TWI_SendByte(0xDC); + * + * TWI_SendByte(0x01); + * TWI_SendByte(0x02); + * TWI_SendByte(0x03); + * + * // Must stop transmission afterwards to release the bus + * TWI_StopTransmission(); + * } + * + * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout + * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10) == TWI_ERROR_NoError) + * { + * TWI_SendByte(0xDC); + * TWI_StopTransmission(); + * + * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_READ, 10) == TWI_ERROR_NoError) + * { + * uint8_t Byte1, Byte2, Byte3; + * + * // Read three bytes, acknowledge after the third byte is received + * TWI_ReceiveByte(&Byte1, false); + * TWI_ReceiveByte(&Byte2, false); + * TWI_ReceiveByte(&Byte3, true); + * + * // Must stop transmission afterwards to release the bus + * TWI_StopTransmission(); + * } + * } + * \endcode + * + * High Level API Example: + * \code + * // Initialize the TWI driver before first use at 200KHz + * TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 200000)); + * + * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout + * uint8_t InternalWriteAddress = 0xDC; + * uint8_t WritePacket[3] = {0x01, 0x02, 0x03}; + * + * TWI_WritePacket(0xA0, 10, &InternalWriteAddress, sizeof(InternalWriteAddress), + * &WritePacket, sizeof(WritePacket); + * + * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout + * uint8_t InternalReadAddress = 0xDC; + * uint8_t ReadPacket[3]; + * + * TWI_ReadPacket(0xA0, 10, &InternalReadAddress, sizeof(InternalReadAddress), + * &ReadPacket, sizeof(ReadPacket); + * \endcode + * + * @{ + */ + +#ifndef __TWI_AVR8_H__ +#define __TWI_AVR8_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_TWI_H) && !defined(__INCLUDE_FROM_TWI_C) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/TWI.h instead. + #endif + + #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ + defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ + defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ + defined(__AVR_ATmega32U6__)) + #error The TWI peripheral driver is not currently available for your selected microcontroller model. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** TWI slave device address mask for a read session. Mask with a slave device base address to obtain + * the correct TWI bus address for the slave device when reading data from it. + */ + #define TWI_ADDRESS_READ 0x01 + + /** TWI slave device address mask for a write session. Mask with a slave device base address to obtain + * the correct TWI bus address for the slave device when writing data to it. + */ + #define TWI_ADDRESS_WRITE 0x00 + + /** Mask to retrieve the base address for a TWI device, which can then be ORed with \ref TWI_ADDRESS_READ + * or \ref TWI_ADDRESS_WRITE to obtain the device's read and write address respectively. + */ + #define TWI_DEVICE_ADDRESS_MASK 0xFE + + /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 1. */ + #define TWI_BIT_PRESCALE_1 ((0 << TWPS1) | (0 << TWPS0)) + + /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 4. */ + #define TWI_BIT_PRESCALE_4 ((0 << TWPS1) | (1 << TWPS0)) + + /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 16. */ + #define TWI_BIT_PRESCALE_16 ((1 << TWPS1) | (0 << TWPS0)) + + /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 64. */ + #define TWI_BIT_PRESCALE_64 ((1 << TWPS1) | (1 << TWPS0)) + + /** Calculates the length of each bit on the TWI bus for a given target frequency. This may be used with + * the \ref TWI_Init() function to convert a bus frequency to a number of clocks for the \c BitLength + * parameter. + * + * \param[in] Prescale Prescaler set on the TWI bus. + * \param[in] Frequency Desired TWI bus frequency in Hz. + * + * \return Bit length in clocks for the given TWI bus frequency at the given prescaler value. + */ + #define TWI_BITLENGTH_FROM_FREQ(Prescale, Frequency) ((((F_CPU / (Prescale)) / (Frequency)) - 16) / 2) + + /* Enums: */ + /** Enum for the possible return codes of the TWI transfer start routine and other dependant TWI functions. */ + enum TWI_ErrorCodes_t + { + TWI_ERROR_NoError = 0, /**< Indicates that the command completed successfully. */ + TWI_ERROR_BusFault = 1, /**< A TWI bus fault occurred while attempting to capture the bus. */ + TWI_ERROR_BusCaptureTimeout = 2, /**< A timeout occurred whilst waiting for the bus to be ready. */ + TWI_ERROR_SlaveResponseTimeout = 3, /**< No ACK received at the nominated slave address within the timeout period. */ + TWI_ERROR_SlaveNotReady = 4, /**< Slave NAKed the TWI bus START condition. */ + TWI_ERROR_SlaveNAK = 5, /**< Slave NAKed whilst attempting to send data to the device. */ + }; + + /* Inline Functions: */ + /** Initializes the TWI hardware into master mode, ready for data transmission and reception. This must be + * before any other TWI operations. + * + * The generated SCL frequency will be according to the formula
F_CPU / (16 + 2 * BitLength + 4 ^ Prescale)
. + * + * \attention The value of the \c BitLength parameter should not be set below 10 or invalid bus conditions may + * occur, as indicated in the AVR8 microcontroller datasheet. + * + * \param[in] Prescale Prescaler to use when determining the bus frequency, a \c TWI_BIT_PRESCALE_* value. + * \param[in] BitLength Length of the bits sent on the bus. + */ + static inline void TWI_Init(const uint8_t Prescale, const uint8_t BitLength) ATTR_ALWAYS_INLINE; + static inline void TWI_Init(const uint8_t Prescale, const uint8_t BitLength) + { + TWCR |= (1 << TWEN); + TWSR = Prescale; + TWBR = BitLength; + } + + /** 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_Disable(void) ATTR_ALWAYS_INLINE; + static inline void TWI_Disable(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)); + } + + /* 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 A value from the \ref TWI_ErrorCodes_t enum. + */ + uint8_t TWI_StartTransmission(const uint8_t SlaveAddress, + const uint8_t TimeoutMS); + + /** 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 \c true if the recipient ACKed the byte, \c false otherwise + */ + bool TWI_SendByte(const uint8_t Byte); + + /** 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 \c true if the byte reception successfully completed, \c false otherwise. + */ + bool TWI_ReceiveByte(uint8_t* const Byte, + const bool LastByte) ATTR_NON_NULL_PTR_ARG(1); + + /** High level function to perform a complete packet transfer over the TWI bus to the specified + * device. + * + * \param[in] SlaveAddress Base address of the TWI slave device to communicate with. + * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds. + * \param[in] InternalAddress Pointer to a location where the internal slave read start address is stored. + * \param[in] InternalAddressLen Size of the internal device address, in bytes. + * \param[in] Buffer Pointer to a buffer where the read packet data is to be stored. + * \param[in] Length Size of the packet to read, in bytes. + * + * \return A value from the \ref TWI_ErrorCodes_t enum. + */ + uint8_t TWI_ReadPacket(const uint8_t SlaveAddress, + const uint8_t TimeoutMS, + const uint8_t* InternalAddress, + uint8_t InternalAddressLen, + uint8_t* Buffer, + uint8_t Length) ATTR_NON_NULL_PTR_ARG(3); + + /** High level function to perform a complete packet transfer over the TWI bus from the specified + * device. + * + * \param[in] SlaveAddress Base address of the TWI slave device to communicate with + * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds + * \param[in] InternalAddress Pointer to a location where the internal slave write start address is stored + * \param[in] InternalAddressLen Size of the internal device address, in bytes + * \param[in] Buffer Pointer to a buffer where the packet data to send is stored + * \param[in] Length Size of the packet to send, in bytes + * + * \return A value from the \ref TWI_ErrorCodes_t enum. + */ + uint8_t TWI_WritePacket(const uint8_t SlaveAddress, + const uint8_t TimeoutMS, + const uint8_t* InternalAddress, + uint8_t InternalAddressLen, + const uint8_t* Buffer, + uint8_t Length) ATTR_NON_NULL_PTR_ARG(3); + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SPI.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SPI.h new file mode 100644 index 000000000..1fab22b68 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SPI.h @@ -0,0 +1,76 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Hardware Serial Peripheral Interface driver. + * + * This file is the master dispatch header file for the device-specific SPI driver, for microcontrollers + * containing a hardware SPI. + * + * User code should include this file, which will in turn include the correct SPI driver header file for the + * currently selected architecture and microcontroller model. + */ + +/** \ingroup Group_PeripheralDrivers + * \defgroup Group_SPI SPI Driver - LUFA/Drivers/Peripheral/SPI.h + * \brief Hardware Serial Peripheral Interface driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Hardware SPI driver. This module provides an easy to use driver for the setup and transfer of data over + * the selected architecture and microcontroller model's SPI port. + * + * \note The exact API for this driver may vary depending on the target used - see + * individual target module documentation for the API specific to your target processor. + */ + +#ifndef __SPI_H__ +#define __SPI_H__ + + /* Macros: */ + #define __INCLUDE_FROM_SPI_H + + /* Includes: */ + #include "../../Common/Common.h" + + /* Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/SPI_AVR8.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/SPI_XMEGA.h" + #else + #error The SPI peripheral driver is not currently available for your selected architecture. + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/Serial.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/Serial.h new file mode 100644 index 000000000..0db13ba47 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/Serial.h @@ -0,0 +1,76 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Hardware Serial USART driver. + * + * This file is the master dispatch header file for the device-specific USART driver, for microcontrollers + * containing a hardware USART. + * + * User code should include this file, which will in turn include the correct ADC driver header file for the + * currently selected architecture and microcontroller model. + */ + +/** \ingroup Group_PeripheralDrivers + * \defgroup Group_Serial Serial USART Driver - LUFA/Drivers/Peripheral/Serial.h + * \brief Hardware Serial USART driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/Peripheral/ARCH/Serial_ARCH.c (Makefile source module name: LUFA_SRC_SERIAL) + * + * \section Sec_ModDescription Module Description + * Hardware serial USART driver. This module provides an easy to use driver for the setup and transfer + * of data over the selected architecture and microcontroller model's USART port. + * + * \note The exact API for this driver may vary depending on the target used - see + * individual target module documentation for the API specific to your target processor. + */ + +#ifndef __SERIAL_H__ +#define __SERIAL_H__ + + /* Macros: */ + #define __INCLUDE_FROM_SERIAL_H + + /* Includes: */ + #include "../../Common/Common.h" + + /* Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Serial_AVR8.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/Serial_XMEGA.h" + #else + #error The Serial peripheral driver is not currently available for your selected architecture. + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SerialSPI.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SerialSPI.h new file mode 100644 index 000000000..f5eede842 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/SerialSPI.h @@ -0,0 +1,76 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Hardware SPI Master Mode Serial USART driver. + * + * This file is the master dispatch header file for the device-specific SPI Master Mode USART driver, for + * microcontrollers containing a hardware USART capable of operating in a Master SPI mode. + * + * User code should include this file, which will in turn include the correct ADC driver header file for the + * currently selected architecture and microcontroller model. + */ + +/** \ingroup Group_PeripheralDrivers + * \defgroup Group_SerialSPI Master SPI Mode Serial USART Driver - LUFA/Drivers/Peripheral/SerialSPI.h + * \brief Hardware SPI Master Mode Serial USART driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Hardware SPI Master Mode serial USART driver. This module provides an easy to use driver for the setup and transfer + * of data over the selected architecture and microcontroller model's USART port, using a SPI framing format. + * + * \note The exact API for this driver may vary depending on the target used - see + * individual target module documentation for the API specific to your target processor. + */ + +#ifndef __SERIAL_SPI_H__ +#define __SERIAL_SPI_H__ + + /* Macros: */ + #define __INCLUDE_FROM_SERIAL_SPI_H + + /* Includes: */ + #include "../../Common/Common.h" + + /* Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/SerialSPI_AVR8.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/SerialSPI_XMEGA.h" + #else + #error The Serial SPI Master Mode peripheral driver is not currently available for your selected architecture. + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/TWI.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/TWI.h new file mode 100644 index 000000000..34012fda6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/TWI.h @@ -0,0 +1,74 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Hardware Two Wire Interface (I2C) driver. + * + * This file is the master dispatch header file for the device-specific SPI driver, for microcontrollers + * containing a hardware TWI. + * + * User code should include this file, which will in turn include the correct TWI driver header file for the + * currently selected architecture and microcontroller model. + */ + +/** \ingroup Group_PeripheralDrivers + * \defgroup Group_TWI TWI Driver - LUFA/Drivers/Peripheral/TWI.h + * \brief Hardware Two Wire Interface (I2C) driver. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/Peripheral/ARCH/TWI_ARCH.c (Makefile source module name: LUFA_SRC_TWI) + * + * \section Sec_ModDescription Module Description + * Hardware TWI driver. This module provides an easy to use driver for the setup and transfer of data over + * the selected architecture and microcontroller model's TWI bus port. + * + * \note The exact API for this driver may vary depending on the target used - see + * individual target module documentation for the API specific to your target processor. + */ + +#ifndef __TWI_H__ +#define __TWI_H__ + + /* Macros: */ + #define __INCLUDE_FROM_TWI_H + + /* Includes: */ + #include "../../Common/Common.h" + + /* Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/TWI_AVR8.h" + #else + #error The TWI peripheral driver is not currently available for your selected architecture. + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h new file mode 100644 index 000000000..25fb73d16 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SPI_XMEGA.h @@ -0,0 +1,248 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief SPI Peripheral Driver (XMEGA) + * + * On-chip SPI driver for the XMEGA microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI driver + * dispatch header located in LUFA/Drivers/Peripheral/SPI.h. + */ + +/** \ingroup Group_SPI + * \defgroup Group_SPI_XMEGA SPI Peripheral Driver (XMEGA) + * + * \section Sec_ModDescription Module Description + * Driver for the hardware SPI port(s) available on XMEGA AVR microcontroller models. This + * module provides an easy to use driver for the setup and transfer of data over the AVR's + * SPI ports. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI driver + * dispatch header located in LUFA/Drivers/Peripheral/SPI.h. + * + * \code + * // Initialize the SPI driver before first use + * SPI_Init(&SPIC, + * SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | + * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); + * + * // Send several bytes, ignoring the returned data + * SPI_SendByte(&SPIC, 0x01); + * SPI_SendByte(&SPIC, 0x02); + * SPI_SendByte(&SPIC, 0x03); + * + * // Receive several bytes, sending a dummy 0x00 byte each time + * uint8_t Byte1 = SPI_ReceiveByte(&SPIC); + * uint8_t Byte2 = SPI_ReceiveByte(&SPIC); + * uint8_t Byte3 = SPI_ReceiveByte(&SPIC); + * + * // Send a byte, and store the received byte from the same transaction + * uint8_t ResponseByte = SPI_TransferByte(&SPIC, 0xDC); + * \endcode + * + * @{ + */ + +#ifndef __SPI_XMEGA_H__ +#define __SPI_XMEGA_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SPI_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/SPI.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define SPI_USE_DOUBLESPEED SPI_CLK2X_bm + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name SPI Prescaler Configuration Masks */ + //@{ + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 2. */ + #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 4. */ + #define SPI_SPEED_FCPU_DIV_4 0 + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 8. */ + #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPI_PRESCALER_gp)) + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 16. */ + #define SPI_SPEED_FCPU_DIV_16 (1 << SPI_PRESCALER_gp) + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 32. */ + #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (2 << SPI_PRESCALER_gp)) + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 64. */ + #define SPI_SPEED_FCPU_DIV_64 (2 << SPI_PRESCALER_gp) + + /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 128. */ + #define SPI_SPEED_FCPU_DIV_128 (3 << SPI_PRESCALER_gp) + //@} + + /** \name SPI SCK Polarity Configuration Masks */ + //@{ + /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the rising edge. */ + #define SPI_SCK_LEAD_RISING 0 + + /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the falling edge. */ + #define SPI_SCK_LEAD_FALLING SPI_MODE1_bm + //@} + + /** \name SPI Sample Edge Configuration Masks */ + //@{ + /** SPI data sample mode mask for \ref SPI_Init(). Indicates that the data should sampled on the leading edge. */ + #define SPI_SAMPLE_LEADING 0 + + /** SPI data sample mode mask for \ref SPI_Init(). Indicates that the data should be sampled on the trailing edge. */ + #define SPI_SAMPLE_TRAILING SPI_MODE0_bm + //@} + + /** \name SPI Data Ordering Configuration Masks */ + //@{ + /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out MSB first. */ + #define SPI_ORDER_MSB_FIRST 0 + + /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out LSB first. */ + #define SPI_ORDER_LSB_FIRST SPI_DORD_bm + //@} + + /** \name SPI Mode Configuration Masks */ + //@{ + /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */ + #define SPI_MODE_SLAVE 0 + + /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */ + #define SPI_MODE_MASTER SPI_MASTER_bm + //@} + + /* Inline Functions: */ + /** Initializes the SPI subsystem, ready for transfers. Must be called before calling any other + * SPI routines. + * + * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device. + * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the \c SPI_SPEED_*, + * \c SPI_SCK_*, \c SPI_SAMPLE_*, \c SPI_ORDER_* and \c SPI_MODE_* masks. + */ + static inline void SPI_Init(SPI_t* const SPI, + const uint8_t SPIOptions) + { + SPI->CTRL = (SPIOptions | SPI_ENABLE_bm); + } + + /** Turns off the SPI driver, disabling and returning used hardware to their default configuration. + * + * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device. + */ + static inline void SPI_Disable(SPI_t* const SPI) + { + SPI->CTRL &= ~SPI_ENABLE_bm; + } + + /** Retrieves the currently selected SPI mode, once the SPI interface has been configured. + * + * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device. + * + * \return \ref SPI_MODE_MASTER if the interface is currently in SPI Master mode, \ref SPI_MODE_SLAVE otherwise + */ + static inline uint8_t SPI_GetCurrentMode(SPI_t* const SPI) ATTR_ALWAYS_INLINE; + static inline uint8_t SPI_GetCurrentMode(SPI_t* const SPI) + { + return (SPI->CTRL & SPI_MASTER_bm); + } + + /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete. + * + * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device. + * \param[in] Byte Byte to send through the SPI interface. + * + * \return Response byte from the attached SPI device. + */ + static inline uint8_t SPI_TransferByte(SPI_t* const SPI, + const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline uint8_t SPI_TransferByte(SPI_t* const SPI, + const uint8_t Byte) + { + SPI->DATA = Byte; + while (!(SPI->STATUS & SPI_IF_bm)); + return SPI->DATA; + } + + /** 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,out] SPI Pointer to the base of the SPI peripheral within the device. + * \param[in] Byte Byte to send through the SPI interface. + */ + static inline void SPI_SendByte(SPI_t* const SPI, + const uint8_t Byte) ATTR_ALWAYS_INLINE; + static inline void SPI_SendByte(SPI_t* const SPI, + const uint8_t Byte) + { + SPI->DATA = Byte; + while (!(SPI->STATUS & SPI_IF_bm)); + } + + /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response + * byte from the attached SPI device is returned. + * + * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device. + * + * \return The response byte from the attached SPI device. + */ + static inline uint8_t SPI_ReceiveByte(SPI_t* const SPI) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t SPI_ReceiveByte(SPI_t* const SPI) + { + SPI->DATA = 0; + while (!(SPI->STATUS & SPI_IF_bm)); + return SPI->DATA; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SerialSPI_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SerialSPI_XMEGA.h new file mode 100644 index 000000000..6d0ea1115 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/SerialSPI_XMEGA.h @@ -0,0 +1,203 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master SPI Mode Serial USART Peripheral Driver (XMEGA) + * + * On-chip Master SPI mode USART driver for the XMEGA AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the SPI Master + * Mode USART driver dispatch header located in LUFA/Drivers/Peripheral/Serial.h. + */ + +/** \ingroup Group_SerialSPI + * \defgroup Group_SerialSPI_XMEGA Master SPI Mode Serial USART Peripheral Driver (XMEGA) + * + * \section Sec_ModDescription Module Description + * On-chip serial USART driver for the XMEGA AVR microcontrollers. + * + * \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/SerialSPI.h. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the Master SPI mode USART driver before first use, with 1Mbit baud + * SerialSPI_Init(&USARTD0, (USART_SPI_SCK_LEAD_RISING | USART_SPI_SAMPLE_LEADING | USART_SPI_ORDER_MSB_FIRST), 1000000); + * + * // Send several bytes, ignoring the returned data + * SerialSPI_SendByte(&USARTD0, 0x01); + * SerialSPI_SendByte(&USARTD0, 0x02); + * SerialSPI_SendByte(&USARTD0, 0x03); + * + * // Receive several bytes, sending a dummy 0x00 byte each time + * uint8_t Byte1 = SerialSPI_ReceiveByte(&USARTD); + * uint8_t Byte2 = SerialSPI_ReceiveByte(&USARTD); + * uint8_t Byte3 = SerialSPI_ReceiveByte(&USARTD); + * + * // Send a byte, and store the received byte from the same transaction + * uint8_t ResponseByte = SerialSPI_TransferByte(&USARTD0, 0xDC); + * \endcode + * + * @{ + */ + +#ifndef __SERIAL_SPI_XMEGA_H__ +#define __SERIAL_SPI_XMEGA_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SERIAL_SPI_H) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + #define SERIAL_SPI_UBBRVAL(Baud) ((Baud < (F_CPU / 2)) ? ((F_CPU / (2 * Baud)) - 1) : 0) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name SPI SCK Polarity Configuration Masks */ + //@{ + /** SPI clock polarity mask for \ref SerialSPI_Init(). Indicates that the SCK should lead on the rising edge. */ + #define USART_SPI_SCK_LEAD_RISING 0 + //@} + + /** \name SPI Sample Edge Configuration Masks */ + //@{ + /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should sampled on the leading edge. */ + #define USART_SPI_SAMPLE_LEADING 0 + + /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge. */ + #define USART_SPI_SAMPLE_TRAILING USART_UPCHA_bm + //@} + + /** \name SPI Data Ordering Configuration Masks */ + //@{ + /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out MSB first. */ + #define USART_SPI_ORDER_MSB_FIRST 0 + + /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out LSB first. */ + #define USART_SPI_ORDER_LSB_FIRST USART_UDORD_bm + //@} + + /* Inline Functions: */ + /** Initialize the USART module in Master SPI mode. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] SPIOptions USART SPI Options, a mask consisting of one of each of the \c USART_SPI_SCK_*, + * \c USART_SPI_SAMPLE_* and \c USART_SPI_ORDER_* masks. + * \param[in] BaudRate SPI baud rate, in bits per second. + */ + static inline void SerialSPI_Init(USART_t* const USART, + const uint8_t SPIOptions, + const uint32_t BaudRate) + { + uint16_t BaudValue = SERIAL_SPI_UBBRVAL(BaudRate); + + USART->BAUDCTRLB = (BaudValue >> 8); + USART->BAUDCTRLA = (BaudValue & 0xFF); + + USART->CTRLC = (USART_CMODE_MSPI_gc | SPIOptions); + USART->CTRLB = (USART_RXEN_bm | USART_TXEN_bm); + } + + /** Turns off the USART driver, disabling and returning used hardware to their default configuration. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + */ + static inline void SerialSPI_Disable(USART_t* const USART) + { + USART->CTRLA = 0; + USART->CTRLB = 0; + USART->CTRLC = 0; + } + + /** Sends and receives a byte through the USART SPI interface, blocking until the transfer is complete. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] DataByte Byte to send through the USART SPI interface. + * + * \return Response byte from the attached SPI device. + */ + static inline uint8_t SerialSPI_TransferByte(USART_t* const USART, + const uint8_t DataByte) + { + USART->DATA = DataByte; + while (!(USART->STATUS & USART_TXCIF_bm)); + USART->STATUS = USART_TXCIF_bm; + return USART->DATA; + } + + /** Sends a byte through the USART SPI interface, blocking until the transfer is complete. The response + * byte sent to from the attached SPI device is ignored. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] DataByte Byte to send through the USART SPI interface. + */ + static inline void SerialSPI_SendByte(USART_t* const USART, + const uint8_t DataByte) + { + SerialSPI_TransferByte(USART, DataByte); + } + + /** Sends a dummy byte through the USART SPI interface, blocking until the transfer is complete. The response + * byte from the attached SPI device is returned. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * + * \return The response byte from the attached SPI device. + */ + static inline uint8_t SerialSPI_ReceiveByte(USART_t* const USART) + { + return SerialSPI_TransferByte(USART, 0); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.c new file mode 100644 index 000000000..51a4d049e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.c @@ -0,0 +1,122 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_SERIAL_C +#include "../Serial.h" + +FILE USARTSerialStream; + +int Serial_putchar(char DataByte, + FILE *Stream) +{ + USART_t* USART = fdev_get_udata(Stream); + + Serial_SendByte(USART, DataByte); + return 0; +} + +int Serial_getchar(FILE *Stream) +{ + USART_t* USART = fdev_get_udata(Stream); + + if (!(Serial_IsCharReceived(USART))) + return _FDEV_EOF; + + return Serial_ReceiveByte(USART); +} + +int Serial_getchar_Blocking(FILE *Stream) +{ + USART_t* USART = fdev_get_udata(Stream); + + while (!(Serial_IsCharReceived(USART))); + return Serial_ReceiveByte(USART); +} + +void Serial_SendString_P(USART_t* const USART, + const char* FlashStringPtr) +{ + uint8_t CurrByte; + + while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00) + { + Serial_SendByte(USART, CurrByte); + FlashStringPtr++; + } +} + +void Serial_SendString(USART_t* const USART, + const char* StringPtr) +{ + uint8_t CurrByte; + + while ((CurrByte = *StringPtr) != 0x00) + { + Serial_SendByte(USART, CurrByte); + StringPtr++; + } +} + +void Serial_SendData(USART_t* const USART, + const uint8_t* Buffer, + uint16_t Length) +{ + while (Length--) + Serial_SendByte(USART, *(Buffer++)); +} + +void Serial_CreateStream(FILE* Stream) +{ + if (!(Stream)) + { + Stream = &USARTSerialStream; + stdin = Stream; + stdout = Stream; + } + + *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW); +} + +void Serial_CreateBlockingStream(FILE* Stream) +{ + if (!(Stream)) + { + Stream = &USARTSerialStream; + stdin = Stream; + stdout = Stream; + } + + *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW); +} + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.h new file mode 100644 index 000000000..35b60d150 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/Peripheral/XMEGA/Serial_XMEGA.h @@ -0,0 +1,252 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Serial USART Peripheral Driver (XMEGA) + * + * On-chip serial USART driver for the XMEGA AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the USART driver + * dispatch header located in LUFA/Drivers/Peripheral/Serial.h. + */ + +/** \ingroup Group_Serial + * \defgroup Group_Serial_XMEGA Serial USART Peripheral Driver (XMEGA) + * + * \section Sec_ModDescription Module Description + * On-chip serial USART driver for the XMEGA AVR microcontrollers. + * + * \note This file should not be included directly. It is automatically included as needed by the USART driver + * dispatch header located in LUFA/Drivers/Peripheral/Serial.h. + * + * \section Sec_ExampleUsage Example Usage + * The following snippet is an example of how this module may be used within a typical + * application. + * + * \code + * // Initialize the serial USART driver before first use, with 9600 baud (and no double-speed mode) + * Serial_Init(&USARTD0, 9600, false); + * + * // Send a string through the USART + * Serial_TxString(&USARTD0, "Test String\r\n"); + * + * // Receive a byte through the USART + * uint8_t DataByte = Serial_RxByte(&USARTD0); + * \endcode + * + * @{ + */ + +#ifndef __SERIAL_XMEGA_H__ +#define __SERIAL_XMEGA_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "../../Misc/TerminalCodes.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_SERIAL_H) && !defined(__INCLUDE_FROM_SERIAL_C) + #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* External Variables: */ + extern FILE USARTSerialStream; + + /* Function Prototypes: */ + int Serial_putchar(char DataByte, + FILE *Stream); + int Serial_getchar(FILE *Stream); + int Serial_getchar_Blocking(FILE *Stream); + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is + * not set. + * + * \param[in] Baud Target serial UART baud rate. + * + * \return Closest UBRR register value for the given UART frequency. + */ + #define SERIAL_UBBRVAL(Baud) ((((F_CPU / 16) + (Baud / 2)) / (Baud)) - 1) + + /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is + * set. + * + * \param[in] Baud Target serial UART baud rate. + * + * \return Closest UBRR register value for the given UART frequency. + */ + #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,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] FlashStringPtr Pointer to a string located in program space. + */ + void Serial_SendString_P(USART_t* const USART, + const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1); + + /** Transmits a given string located in SRAM memory through the USART. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] StringPtr Pointer to a string located in SRAM space. + */ + void Serial_SendString(USART_t* const USART, + const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1); + + /** Transmits a given buffer located in SRAM memory through the USART. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] Buffer Pointer to a buffer containing the data to send. + * \param[in] Length Length of the data to send, in bytes. + */ + void Serial_SendData(USART_t* const USART, + const uint8_t* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Creates a standard character stream from the USART so that it can be used with all the regular functions + * in the avr-libc \c library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created + * stream is bidirectional and can be used for both input and output functions. + * + * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single + * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may + * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own + * line buffering. + * + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout + * and \c stdin will be configured to use the USART. + * + * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used. + */ + void Serial_CreateStream(FILE* Stream); + + /** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates + * the transfer. + * + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout + * and \c stdin will be configured to use the USART. + * + * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used. + */ + void Serial_CreateBlockingStream(FILE* Stream); + + /* 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,out] USART Pointer to the base of the USART peripheral within the device. + * \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(USART_t* const USART, + const uint32_t BaudRate, + const bool DoubleSpeed) + { + uint16_t BaudValue = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate)); + + USART->BAUDCTRLB = (BaudValue >> 8); + USART->BAUDCTRLA = (BaudValue & 0xFF); + + USART->CTRLC = (USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc | USART_CHSIZE_8BIT_gc); + USART->CTRLB = (USART_RXEN_bm | USART_TXEN_bm | (DoubleSpeed ? USART_CLK2X_bm : 0)); + } + + /** Turns off the USART driver, disabling and returning used hardware to their default configuration. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + */ + static inline void Serial_Disable(USART_t* const USART) + { + USART->CTRLA = 0; + USART->CTRLB = 0; + USART->CTRLC = 0; + } + + /** Indicates whether a character has been received through the USART. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * + * \return Boolean \c true if a character has been received, \c false otherwise. + */ + static inline bool Serial_IsCharReceived(USART_t* const USART) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Serial_IsCharReceived(USART_t* const USART) + { + return ((USART->STATUS & USART_RXCIF_bm) ? true : false); + } + + /** Transmits a given byte through the USART. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * \param[in] DataByte Byte to transmit through the USART. + */ + static inline void Serial_SendByte(USART_t* const USART, + const char DataByte) ATTR_ALWAYS_INLINE; + static inline void Serial_SendByte(USART_t* const USART, + const char DataByte) + { + while (!(USART->STATUS & USART_DREIF_bm)); + USART->DATA = DataByte; + } + + /** Receives the next byte from the USART. + * + * \param[in,out] USART Pointer to the base of the USART peripheral within the device. + * + * \return Next byte received from the USART, or a negative value if no byte has been received. + */ + static inline int16_t Serial_ReceiveByte(USART_t* const USART) ATTR_ALWAYS_INLINE; + static inline int16_t Serial_ReceiveByte(USART_t* const USART) + { + if (!(Serial_IsCharReceived(USART))) + return -1; + + USART->STATUS = USART_RXCIF_bm; + return USART->DATA; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AndroidAccessoryClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AndroidAccessoryClass.h new file mode 100644 index 000000000..2f2fa5bc7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AndroidAccessoryClass.h @@ -0,0 +1,76 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB Android Open Accessory Class driver. + * + * Master include file for the library USB Android Open Accessory 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_USBClassAOA Android Open Accessory 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/AndroidAccessoryClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * Android Open Accessory Class Driver module. This module contains an internal implementation of the USB Android Open Accessory + * Class, for Host USB mode. User applications can use this class driver instead of implementing the Android Open Accessory 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 + * Host using the USB Android Open Accessory Class. + * + * @{ + */ + +#ifndef _AOA_CLASS_H_ +#define _AOA_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_AOA_DRIVER + + /* Includes: */ + #include "../Core/USBMode.h" + + #if defined(USB_CAN_BE_HOST) + #include "Host/AndroidAccessoryClassHost.h" + #endif + +#endif + +/** @} */ + + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AudioClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AudioClass.h new file mode 100644 index 000000000..91aa22f3b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/AudioClass.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB Audio 1.0 Class driver. + * + * Master include file for the library USB Audio 1.0 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 1.0 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/AudioClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/AudioClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * Audio 1.0 Class Driver module. This module contains an internal implementation of the USB Audio 1.0 Class, for both + * Device and Host USB modes. User applications can use this class driver instead of implementing the Audio 1.0 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 1.0 Class. + * + * @{ + */ + +#ifndef _AUDIO_CLASS_H_ +#define _AUDIO_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_AUDIO_DRIVER + + /* Includes: */ + #include "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/AudioClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/AudioClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/CDCClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/CDCClass.h new file mode 100644 index 000000000..6bfd38488 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/CDCClass.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB CDC-ACM Class driver. + * + * Master include file for the library USB CDC Class driver, for both host and device modes, where available. + * + * This file should be included in all user projects making use of this optional class driver, instead of + * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. + */ + +/** \ingroup Group_USBClassDrivers + * \defgroup Group_USBClassCDC CDC-ACM (Virtual Serial) Class Driver + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/CDCClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * CDC Class Driver module. This module contains an internal implementation of the USB CDC-ACM class Virtual Serial + * Ports, for both Device and Host USB modes. User applications can use this class driver instead of implementing the + * CDC class manually via the low-level LUFA APIs. + * + * This module is designed to simplify the user code by exposing only the required interface needed to interface with + * Hosts or Devices using the USB CDC Class. + * + * @{ + */ + +#ifndef _CDC_CLASS_H_ +#define _CDC_CLASS_H_ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + #define __INCLUDE_FROM_CDC_DRIVER + + /* Includes: */ + #include "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/CDCClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/CDCClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h new file mode 100644 index 000000000..db97f4888 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AndroidAccessoryClassCommon.h @@ -0,0 +1,128 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB Android Open Accessory Class driver. + * + * Common definitions and declarations for the library USB Android Open Accessory 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_USBClassAOA + * \defgroup Group_USBClassAOACommon Common Class Definitions + * + * \section Sec_ModDescription Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * Android Open Accessory Class. + * + * @{ + */ + +#ifndef _AOA_CLASS_COMMON_H_ +#define _AOA_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../Core/StdDescriptors.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_AOA_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory mode. */ + #define ANDROID_ACCESSORY_PRODUCT_ID 0x2D00 + + /** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory and Android Debug mode. */ + #define ANDROID_ACCESSORY_ADB_PRODUCT_ID 0x2D01 + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the + * Android Open Accessory class. + */ + enum AOA_Descriptor_ClassSubclassProtocol_t + { + AOA_CSCP_AOADataClass = 0xFF, /**< Descriptor Class value indicating that the device or interface + * belongs to the AOA data class. + */ + AOA_CSCP_AOADataSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device or interface + * belongs to AOA data subclass. + */ + AOA_CSCP_AOADataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the AOA data class protocol. + */ + }; + + /** Enum for the Android Open Accessory class specific control requests that can be issued by the USB bus host. */ + enum AOA_ClassRequests_t + { + AOA_REQ_GetAccessoryProtocol = 0x33, /**< Android Open Accessory control request to retrieve the device's supported Accessory Protocol version. */ + AOA_REQ_SendString = 0x34, /**< Android Open Accessory control request to set an accessory property string in the device. */ + AOA_REQ_StartAccessoryMode = 0x35, /**< Android Open Accessory control request to switch the device into Accessory mode. */ + }; + + /** Enum for the possible Android Open Accessory property string indexes. */ + enum AOA_Strings_t + { + AOA_STRING_Manufacturer = 0, /**< Index of the Manufacturer property string. */ + AOA_STRING_Model = 1, /**< Index of the Model Name property string. */ + AOA_STRING_Description = 2, /**< Index of the Description property string. */ + AOA_STRING_Version = 3, /**< Index of the Version Number property string. */ + AOA_STRING_URI = 4, /**< Index of the URI Information property string. */ + AOA_STRING_Serial = 5, /**< Index of the Serial Number property string. */ + + #if !defined(__DOXYGEN__) + AOA_STRING_TOTAL_STRINGS + #endif + }; + + /** Enum for the possible Android Open Accessory protocol versions. */ + enum AOA_Protocols_t + { + AOA_PROTOCOL_AccessoryV1 = 0x0001, /**< Android Open Accessory version 1. */ + }; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h new file mode 100644 index 000000000..f33fef68a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/AudioClassCommon.h @@ -0,0 +1,774 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB 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 Sec_ModDescription 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 "../../Core/StdDescriptors.h" + + /* 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: */ + /** \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) {.Byte1 = ((uint32_t)freq & 0xFF), .Byte2 = (((uint32_t)freq >> 8) & 0xFF), .Byte3 = (((uint32_t)freq >> 16) & 0xFF)} + + /** 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) + + /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint + * allows for sampling frequency adjustments to be made via control requests directed at the endpoint. + */ + #define AUDIO_EP_SAMPLE_FREQ_CONTROL (1 << 0) + + /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint + * allows for pitch adjustments to be made via control requests directed at the endpoint. + */ + #define AUDIO_EP_PITCH_CONTROL (1 << 1) + + /* 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. */ + }; + + /** Enum for the Audio class specific control requests that can be issued by the USB bus host. */ + enum Audio_ClassRequests_t + { + AUDIO_REQ_SetCurrent = 0x01, /**< Audio class-specific request to set the current value of a parameter within the device. */ + AUDIO_REQ_SetMinimum = 0x02, /**< Audio class-specific request to set the minimum value of a parameter within the device. */ + AUDIO_REQ_SetMaximum = 0x03, /**< Audio class-specific request to set the maximum value of a parameter within the device. */ + AUDIO_REQ_SetResolution = 0x04, /**< Audio class-specific request to set the resolution value of a parameter within the device. */ + AUDIO_REQ_SetMemory = 0x05, /**< Audio class-specific request to set the memory value of a parameter within the device. */ + AUDIO_REQ_GetCurrent = 0x81, /**< Audio class-specific request to get the current value of a parameter within the device. */ + AUDIO_REQ_GetMinimum = 0x82, /**< Audio class-specific request to get the minimum value of a parameter within the device. */ + AUDIO_REQ_GetMaximum = 0x83, /**< Audio class-specific request to get the maximum value of a parameter within the device. */ + AUDIO_REQ_GetResolution = 0x84, /**< Audio class-specific request to get the resolution value of a parameter within the device. */ + AUDIO_REQ_GetMemory = 0x85, /**< Audio class-specific request to get the memory value of a parameter within the device. */ + AUDIO_REQ_GetStatus = 0xFF, /**< Audio class-specific request to get the device status. */ + }; + + /** Enum for Audio class specific Endpoint control modifiers which can be set and retrieved by a USB host, if the corresponding + * endpoint control is indicated to be supported in the Endpoint's Audio-class specific endpoint descriptor. + */ + enum Audio_EndpointControls_t + { + AUDIO_EPCONTROL_SamplingFreq = 0x01, /**< Sampling frequency adjustment of the endpoint. */ + AUDIO_EPCONTROL_Pitch = 0x02, /**< Pitch adjustment of the endpoint. */ + }; + + /* 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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 \c 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; /**< \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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 \c 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; /**< \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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 \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< 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 \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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 \c ChannelControls 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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 \c ChannelControls 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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. */ + } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AS_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. + * + * \attention This descriptor must be followed by one or more \ref USB_Audio_SampleFreq_t elements containing + * the continuous or discrete sample frequencies. + * + * \see \ref USB_Audio_StdDescriptor_Format_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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 TotalDiscreteSampleRates; /**< Total number of discrete sample frequencies supported by the device. When + * zero, this must be followed by the lower and upper continuous sampling + * frequencies supported by the device; otherwise, this must be followed + * by the given number of discrete sampling frequencies supported. + */ + } ATTR_PACKED USB_Audio_Descriptor_Format_t; + + /** \brief 24-Bit Audio Frequency Structure. + * + * Type define for a 24bit audio sample frequency structure. As GCC does not contain a built in 24-bit datatype, + * this this structure is used to build up the value instead. Fill this structure with the \ref AUDIO_SAMPLE_FREQ() macro. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t Byte1; /**< Lowest 8 bits of the 24-bit value. */ + uint8_t Byte2; /**< Middle 8 bits of the 24-bit value. */ + uint8_t Byte3; /**< Upper 8 bits of the 24-bit value. */ + } ATTR_PACKED USB_Audio_SampleFreq_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. + * + * \attention This descriptor must be followed by one or more 24-bit integer elements containing the continuous + * or discrete sample frequencies. + * + * \see \ref USB_Audio_Descriptor_Format_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< 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. When + * zero, this must be followed by the lower and upper continuous sampling + * frequencies supported by the device; otherwise, this must be followed + * by the given number of discrete sampling frequencies supported. + */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + 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). */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a + * value given by the specific class. + */ + uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current + * configuration, including direction mask. + */ + uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (\c EP_TYPE_*) + * and attributes (\c 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). */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors, + * a value from the \ref Audio_CSEndpoint_SubTypes_t enum. + */ + + uint8_t Attributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */ + + 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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 \ref AUDIO_EP_FULL_PACKETS_ONLY. */ + + 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. */ + } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Spc_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h new file mode 100644 index 000000000..f14a766cd --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/CDCClassCommon.h @@ -0,0 +1,386 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB CDC Class driver. + * + * Common definitions and declarations for the library USB CDC Class driver. + * + * \note This file should not be included directly. It is automatically included as needed by the USB module driver + * dispatch header located in LUFA/Drivers/USB.h. + */ + +/** \ingroup Group_USBClassCDC + * \defgroup Group_USBClassCDCCommon Common Class Definitions + * + * \section Sec_ModDescription Module Description + * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB + * CDC Class. + * + * @{ + */ + +#ifndef _CDC_CLASS_COMMON_H_ +#define _CDC_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../Core/StdDescriptors.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_CDC_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Macros: */ + /** \name Virtual Control Line Masks */ + //@{ + /** Mask for the DTR handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request + * from the host, to indicate that the DTR line state should be high. + */ + #define CDC_CONTROL_LINE_OUT_DTR (1 << 0) + + /** Mask for the RTS handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request + * from the host, to indicate that the RTS line state should be high. + */ + #define CDC_CONTROL_LINE_OUT_RTS (1 << 1) + + /** Mask for the DCD handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the DCD line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_DCD (1 << 0) + + /** Mask for the DSR handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the DSR line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_DSR (1 << 1) + + /** Mask for the BREAK handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the BREAK line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_BREAK (1 << 2) + + /** Mask for the RING handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification + * from the device to the host, to indicate that the RING line state is currently high. + */ + #define CDC_CONTROL_LINE_IN_RING (1 << 3) + + /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, + * to indicate that a framing error has occurred on the virtual serial port. + */ + #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4) + + /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, + * to indicate that a parity error has occurred on the virtual serial port. + */ + #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5) + + /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host, + * to indicate that a data overrun error has occurred on the virtual serial port. + */ + #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6) + //@} + + /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a + * uniform structure but variable sized data payloads, thus cannot be represented accurately by + * a single typedef struct. A macro is used instead so that functional descriptors can be created + * easily by specifying the size of the payload. This allows \c sizeof() to work correctly. + * + * \param[in] DataSize Size in bytes of the CDC functional descriptor's data payload. + */ + #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \ + struct \ + { \ + USB_Descriptor_Header_t Header; \ + uint8_t SubType; \ + uint8_t Data[DataSize]; \ + } + + /* Enums: */ + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CDC + * device class. + */ + enum CDC_Descriptor_ClassSubclassProtocol_t + { + CDC_CSCP_CDCClass = 0x02, /**< Descriptor Class value indicating that the device or interface + * belongs to the CDC class. + */ + CDC_CSCP_NoSpecificSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface + * belongs to no specific subclass of the CDC class. + */ + CDC_CSCP_ACMSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or interface + * belongs to the Abstract Control Model CDC subclass. + */ + CDC_CSCP_ATCommandProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface + * belongs to the AT Command protocol of the CDC class. + */ + CDC_CSCP_NoSpecificProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface + * belongs to no specific protocol of the CDC class. + */ + CDC_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device or interface + * belongs to a vendor-specific protocol of the CDC class. + */ + CDC_CSCP_CDCDataClass = 0x0A, /**< Descriptor Class value indicating that the device or interface + * belongs to the CDC Data class. + */ + CDC_CSCP_NoDataSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface + * belongs to no specific subclass of the CDC data class. + */ + CDC_CSCP_NoDataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface + * belongs to no specific protocol of the CDC data class. + */ + }; + + /** Enum for the CDC class specific control requests that can be issued by the USB bus host. */ + enum CDC_ClassRequests_t + { + CDC_REQ_SendEncapsulatedCommand = 0x00, /**< CDC class-specific request to send an encapsulated command to the device. */ + CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */ + CDC_REQ_SetLineEncoding = 0x20, /**< CDC class-specific request to set the current virtual serial port configuration settings. */ + CDC_REQ_GetLineEncoding = 0x21, /**< CDC class-specific request to get the current virtual serial port configuration settings. */ + CDC_REQ_SetControlLineState = 0x22, /**< CDC class-specific request to set the current virtual serial port handshake line states. */ + CDC_REQ_SendBreak = 0x23, /**< CDC class-specific request to send a break to the receiver via the carrier channel. */ + }; + + /** Enum for the CDC class specific notification requests that can be issued by a CDC device to a host. */ + enum CDC_ClassNotifications_t + { + CDC_NOTIF_SerialState = 0x20, /**< Notification type constant for a change in the virtual serial port + * handshake line states, for use with a \ref USB_Request_Header_t + * notification structure when sent to the host via the CDC notification + * endpoint. + */ + }; + + /** Enum for the CDC class specific interface descriptor subtypes. */ + enum CDC_DescriptorSubtypes_t + { + CDC_DSUBTYPE_CSInterface_Header = 0x00, /**< CDC class-specific Header functional descriptor. */ + CDC_DSUBTYPE_CSInterface_CallManagement = 0x01, /**< CDC class-specific Call Management functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ACM = 0x02, /**< CDC class-specific Abstract Control Model functional descriptor. */ + CDC_DSUBTYPE_CSInterface_DirectLine = 0x03, /**< CDC class-specific Direct Line functional descriptor. */ + CDC_DSUBTYPE_CSInterface_TelephoneRinger = 0x04, /**< CDC class-specific Telephone Ringer functional descriptor. */ + CDC_DSUBTYPE_CSInterface_TelephoneCall = 0x05, /**< CDC class-specific Telephone Call functional descriptor. */ + CDC_DSUBTYPE_CSInterface_Union = 0x06, /**< CDC class-specific Union functional descriptor. */ + CDC_DSUBTYPE_CSInterface_CountrySelection = 0x07, /**< CDC class-specific Country Selection functional descriptor. */ + CDC_DSUBTYPE_CSInterface_TelephoneOpModes = 0x08, /**< CDC class-specific Telephone Operation Modes functional descriptor. */ + CDC_DSUBTYPE_CSInterface_USBTerminal = 0x09, /**< CDC class-specific USB Terminal functional descriptor. */ + CDC_DSUBTYPE_CSInterface_NetworkChannel = 0x0A, /**< CDC class-specific Network Channel functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ProtocolUnit = 0x0B, /**< CDC class-specific Protocol Unit functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ExtensionUnit = 0x0C, /**< CDC class-specific Extension Unit functional descriptor. */ + CDC_DSUBTYPE_CSInterface_MultiChannel = 0x0D, /**< CDC class-specific Multi-Channel Management functional descriptor. */ + CDC_DSUBTYPE_CSInterface_CAPI = 0x0E, /**< CDC class-specific Common ISDN API functional descriptor. */ + CDC_DSUBTYPE_CSInterface_Ethernet = 0x0F, /**< CDC class-specific Ethernet functional descriptor. */ + CDC_DSUBTYPE_CSInterface_ATM = 0x10, /**< CDC class-specific Asynchronous Transfer Mode functional descriptor. */ + }; + + /** Enum for the possible line encoding formats of a virtual serial port. */ + enum CDC_LineEncodingFormats_t + { + CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit. */ + CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits. */ + CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits. */ + }; + + /** Enum for the possible line encoding parity settings of a virtual serial port. */ + enum CDC_LineEncodingParity_t + { + CDC_PARITY_None = 0, /**< No parity bit mode on each frame. */ + CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame. */ + CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame. */ + CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame. */ + CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame. */ + }; + + /* Type Defines: */ + /** \brief CDC class-specific Functional Header Descriptor (LUFA naming conventions). + * + * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device + * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. + * See the CDC class specification for more details. + * + * \see \ref USB_CDC_StdDescriptor_FunctionalHeader_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Header. + */ + uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device, + * encoded in BCD format. + */ + } ATTR_PACKED USB_CDC_Descriptor_FunctionalHeader_t; + + /** \brief CDC class-specific Functional Header Descriptor (USB-IF naming conventions). + * + * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device + * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration. + * See the CDC class specification for more details. + * + * \see \ref USB_CDC_Descriptor_FunctionalHeader_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Header. + */ + uint16_t bcdCDC; /**< Version number of the CDC specification implemented by the device, encoded in BCD format. */ + } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalHeader_t; + + /** \brief CDC class-specific Functional ACM Descriptor (LUFA naming conventions). + * + * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface + * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. + * + * \see \ref USB_CDC_StdDescriptor_FunctionalACM_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_ACM. + */ + uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, + * this should be set to a fixed value of 0x06 - for other capabilities, refer + * to the CDC ACM specification. + */ + } ATTR_PACKED USB_CDC_Descriptor_FunctionalACM_t; + + /** \brief CDC class-specific Functional ACM Descriptor (USB-IF naming conventions). + * + * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface + * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details. + * + * \see \ref USB_CDC_Descriptor_FunctionalACM_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_ACM. + */ + uint8_t bmCapabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices, + * this should be set to a fixed value of 0x06 - for other capabilities, refer + * to the CDC ACM specification. + */ + } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalACM_t; + + /** \brief CDC class-specific Functional Union Descriptor (LUFA naming conventions). + * + * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific + * CDC control and data interfaces are related. See the CDC class specification for more details. + * + * \see \ref USB_CDC_StdDescriptor_FunctionalUnion_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Union. + */ + uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */ + uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */ + } ATTR_PACKED USB_CDC_Descriptor_FunctionalUnion_t; + + /** \brief CDC class-specific Functional Union Descriptor (USB-IF naming conventions). + * + * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific + * CDC control and data interfaces are related. See the CDC class specification for more details. + * + * \see \ref USB_CDC_Descriptor_FunctionalUnion_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors, + * must be \ref CDC_DSUBTYPE_CSInterface_Union. + */ + uint8_t bMasterInterface; /**< Interface number of the CDC Control interface. */ + uint8_t bSlaveInterface0; /**< Interface number of the CDC Data interface. */ + } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalUnion_t; + + /** \brief CDC Virtual Serial Port Line Encoding Settings Structure. + * + * Type define for a CDC Line Encoding structure, used to hold the various encoding parameters for a virtual + * serial port. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second. */ + uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the + * \ref CDC_LineEncodingFormats_t enum. + */ + uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the + * \ref CDC_LineEncodingParity_t enum. + */ + uint8_t DataBits; /**< Bits of data per character of the virtual serial port. */ + } ATTR_PACKED CDC_LineEncoding_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h new file mode 100644 index 000000000..bc5cb4652 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDClassCommon.h @@ -0,0 +1,655 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB 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 Sec_ModDescription 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 "../../Core/StdDescriptors.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 + + /* 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_MODIFIER_LEFTCTRL (1 << 0) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_LEFTSHIFT (1 << 1) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_LEFTALT (1 << 2) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_LEFTGUI (1 << 3) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_RIGHTCTRL (1 << 4) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_RIGHTSHIFT (1 << 5) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_RIGHTALT (1 << 6) + + /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ + #define HID_KEYBOARD_MODIFIER_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 Scan-codes */ + //@{ + #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 0x07 + #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 0x4F + #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_POWER 0x66 + #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 0x89 + #define HID_KEYBOARD_SC_INTERNATIONAL4 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 + //@} + + /** \name Common HID Device Report Descriptors */ + //@{ + /** \hideinitializer + * A list of HID report item array elements that describe a typical HID USB Joystick. The resulting report + * descriptor is structured according to the following layout: + * + * \code + * struct + * { + * intA_t X; // Signed X axis value + * intA_t Y; // Signed Y axis value + * intA_t Z; // Signed Z axis value + * uintB_t Buttons; // Pressed buttons bitmask + * } Joystick_Report; + * \endcode + * + * Where \c uintA_t is a type large enough to hold the ranges of the signed \c MinAxisVal and \c MaxAxisVal values, + * and \c intB_t is a type large enough to hold one bit per button. + * + * \param[in] MinAxisVal Minimum logical axis value (16-bit). + * \param[in] MaxAxisVal Maximum logical axis value (16-bit). + * \param[in] MinPhysicalVal Minimum physical axis value, for movement resolution calculations (16-bit). + * \param[in] MaxPhysicalVal Maximum physical axis value, for movement resolution calculations (16-bit). + * \param[in] Buttons Total number of buttons in the device (8-bit). + */ + #define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \ + HID_RI_USAGE_PAGE(8, 0x01), \ + HID_RI_USAGE(8, 0x04), \ + HID_RI_COLLECTION(8, 0x01), \ + HID_RI_USAGE(8, 0x01), \ + HID_RI_COLLECTION(8, 0x00), \ + HID_RI_USAGE(8, 0x30), \ + HID_RI_USAGE(8, 0x31), \ + HID_RI_USAGE(8, 0x32), \ + HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \ + HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \ + HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \ + HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \ + HID_RI_REPORT_COUNT(8, 3), \ + HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ + HID_RI_END_COLLECTION(0), \ + HID_RI_USAGE_PAGE(8, 0x09), \ + HID_RI_USAGE_MINIMUM(8, 0x01), \ + HID_RI_USAGE_MAXIMUM(8, Buttons), \ + HID_RI_LOGICAL_MINIMUM(8, 0x00), \ + HID_RI_LOGICAL_MAXIMUM(8, 0x01), \ + HID_RI_REPORT_SIZE(8, 0x01), \ + HID_RI_REPORT_COUNT(8, Buttons), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ + HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \ + HID_RI_REPORT_COUNT(8, 0x01), \ + HID_RI_INPUT(8, HID_IOF_CONSTANT), \ + HID_RI_END_COLLECTION(0) + + /** \hideinitializer + * A list of HID report item array elements that describe a typical HID USB keyboard. The resulting report descriptor + * is compatible with \ref USB_KeyboardReport_Data_t when \c MaxKeys is equal to 6. For other values, the report will + * be structured according to the following layout: + * + * \code + * struct + * { + * uint8_t Modifier; // Keyboard modifier byte indicating pressed modifier keys (\c HID_KEYBOARD_MODIFER_* masks) + * uint8_t Reserved; // Reserved for OEM use, always set to 0. + * uint8_t KeyCode[MaxKeys]; // Length determined by the number of keys that can be reported + * } Keyboard_Report; + * \endcode + * + * \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (8-bit). + */ + #define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \ + HID_RI_USAGE_PAGE(8, 0x01), \ + HID_RI_USAGE(8, 0x06), \ + HID_RI_COLLECTION(8, 0x01), \ + HID_RI_USAGE_PAGE(8, 0x07), \ + HID_RI_USAGE_MINIMUM(8, 0xE0), \ + HID_RI_USAGE_MAXIMUM(8, 0xE7), \ + HID_RI_LOGICAL_MINIMUM(8, 0x00), \ + HID_RI_LOGICAL_MAXIMUM(8, 0x01), \ + HID_RI_REPORT_SIZE(8, 0x01), \ + HID_RI_REPORT_COUNT(8, 0x08), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ + HID_RI_REPORT_COUNT(8, 0x01), \ + HID_RI_REPORT_SIZE(8, 0x08), \ + HID_RI_INPUT(8, HID_IOF_CONSTANT), \ + HID_RI_USAGE_PAGE(8, 0x08), \ + HID_RI_USAGE_MINIMUM(8, 0x01), \ + HID_RI_USAGE_MAXIMUM(8, 0x05), \ + HID_RI_REPORT_COUNT(8, 0x05), \ + HID_RI_REPORT_SIZE(8, 0x01), \ + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \ + HID_RI_REPORT_COUNT(8, 0x01), \ + HID_RI_REPORT_SIZE(8, 0x03), \ + HID_RI_OUTPUT(8, HID_IOF_CONSTANT), \ + HID_RI_LOGICAL_MINIMUM(8, 0x00), \ + HID_RI_LOGICAL_MAXIMUM(8, 0x65), \ + HID_RI_USAGE_PAGE(8, 0x07), \ + HID_RI_USAGE_MINIMUM(8, 0x00), \ + HID_RI_USAGE_MAXIMUM(8, 0x65), \ + HID_RI_REPORT_COUNT(8, MaxKeys), \ + HID_RI_REPORT_SIZE(8, 0x08), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), \ + HID_RI_END_COLLECTION(0) + + /** \hideinitializer + * A list of HID report item array elements that describe a typical HID USB mouse. The resulting report descriptor + * is compatible with \ref USB_MouseReport_Data_t if the \c MinAxisVal and \c MaxAxisVal values fit within a \c int8_t range + * and the number of Buttons is less than 8. For other values, the report is structured according to the following layout: + * + * \code + * struct + * { + * uintA_t Buttons; // Pressed buttons bitmask + * intB_t X; // X axis value + * intB_t Y; // Y axis value + * } Mouse_Report; + * \endcode + * + * Where \c intA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the + * ranges of the signed \c MinAxisVal and \c MaxAxisVal values. + * + * \param[in] MinAxisVal Minimum X/Y logical axis value (16-bit). + * \param[in] MaxAxisVal Maximum X/Y logical axis value (16-bit). + * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations (16-bit). + * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations (16-bit). + * \param[in] Buttons Total number of buttons in the device (8-bit). + * \param[in] AbsoluteCoords Boolean \c true to use absolute X/Y coordinates (e.g. touchscreen). + */ + #define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \ + HID_RI_USAGE_PAGE(8, 0x01), \ + HID_RI_USAGE(8, 0x02), \ + HID_RI_COLLECTION(8, 0x01), \ + HID_RI_USAGE(8, 0x01), \ + HID_RI_COLLECTION(8, 0x00), \ + HID_RI_USAGE_PAGE(8, 0x09), \ + HID_RI_USAGE_MINIMUM(8, 0x01), \ + HID_RI_USAGE_MAXIMUM(8, Buttons), \ + HID_RI_LOGICAL_MINIMUM(8, 0x00), \ + HID_RI_LOGICAL_MAXIMUM(8, 0x01), \ + HID_RI_REPORT_COUNT(8, Buttons), \ + HID_RI_REPORT_SIZE(8, 0x01), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ + HID_RI_REPORT_COUNT(8, 0x01), \ + HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \ + HID_RI_INPUT(8, HID_IOF_CONSTANT), \ + HID_RI_USAGE_PAGE(8, 0x01), \ + HID_RI_USAGE(8, 0x30), \ + HID_RI_USAGE(8, 0x31), \ + HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \ + HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \ + HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \ + HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \ + HID_RI_REPORT_COUNT(8, 0x02), \ + HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \ + HID_RI_END_COLLECTION(0), \ + HID_RI_END_COLLECTION(0) + + /** \hideinitializer + * A list of HID report item array elements that describe a typical Vendor Defined byte array HID report descriptor, + * used for transporting arbitrary data between the USB host and device via HID reports. The resulting report should be + * a \c uint8_t byte array of the specified length in both Device to Host (IN) and Host to Device (OUT) directions. + * + * \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF. + * \param[in] CollectionUsage Vendor Usage for the encompassing report IN and OUT collection, ranging from 0x00 to 0xFF. + * \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF. + * \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF. + * \param[in] NumBytes Length of the data IN and OUT reports. + */ + #define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \ + HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \ + HID_RI_USAGE(8, CollectionUsage), \ + HID_RI_COLLECTION(8, 0x01), \ + HID_RI_USAGE(8, DataINUsage), \ + HID_RI_LOGICAL_MINIMUM(8, 0x00), \ + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \ + HID_RI_REPORT_SIZE(8, 0x08), \ + HID_RI_REPORT_COUNT(8, NumBytes), \ + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \ + HID_RI_USAGE(8, DataOUTUsage), \ + HID_RI_LOGICAL_MINIMUM(8, 0x00), \ + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \ + HID_RI_REPORT_SIZE(8, 0x08), \ + HID_RI_REPORT_COUNT(8, NumBytes), \ + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \ + HID_RI_END_COLLECTION(0) + //@} + + /* 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + + 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint16_t 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. */ + } ATTR_PACKED 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. */ + } ATTR_PACKED 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 + * \c 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. */ + } ATTR_PACKED 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; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.c new file mode 100644 index 000000000..f57d97b56 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.c @@ -0,0 +1,363 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#define __INCLUDE_FROM_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 & HID_RI_DATA_SIZE_MASK) + { + case HID_RI_DATA_BITS_32: + ReportItemData = (((uint32_t)ReportData[3] << 24) | ((uint32_t)ReportData[2] << 16) | + ((uint16_t)ReportData[1] << 8) | ReportData[0]); + ReportSize -= 4; + ReportData += 4; + break; + case HID_RI_DATA_BITS_16: + ReportItemData = (((uint16_t)ReportData[1] << 8) | (ReportData[0])); + ReportSize -= 2; + ReportData += 2; + break; + case HID_RI_DATA_BITS_8: + ReportItemData = ReportData[0]; + ReportSize -= 1; + ReportData += 1; + break; + } + + switch (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK)) + { + case HID_RI_PUSH(0): + if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1]) + return HID_PARSE_HIDStackOverflow; + + memcpy((CurrStateTable + 1), + CurrStateTable, + sizeof(HID_ReportItem_t)); + + CurrStateTable++; + break; + case HID_RI_POP(0): + if (CurrStateTable == &StateTable[0]) + return HID_PARSE_HIDStackUnderflow; + + CurrStateTable--; + break; + case HID_RI_USAGE_PAGE(0): + if ((HIDReportItem & HID_RI_DATA_SIZE_MASK) == HID_RI_DATA_BITS_32) + CurrStateTable->Attributes.Usage.Page = (ReportItemData >> 16); + + CurrStateTable->Attributes.Usage.Page = ReportItemData; + break; + case HID_RI_LOGICAL_MINIMUM(0): + CurrStateTable->Attributes.Logical.Minimum = ReportItemData; + break; + case HID_RI_LOGICAL_MAXIMUM(0): + CurrStateTable->Attributes.Logical.Maximum = ReportItemData; + break; + case HID_RI_PHYSICAL_MINIMUM(0): + CurrStateTable->Attributes.Physical.Minimum = ReportItemData; + break; + case HID_RI_PHYSICAL_MAXIMUM(0): + CurrStateTable->Attributes.Physical.Maximum = ReportItemData; + break; + case HID_RI_UNIT_EXPONENT(0): + CurrStateTable->Attributes.Unit.Exponent = ReportItemData; + break; + case HID_RI_UNIT(0): + CurrStateTable->Attributes.Unit.Type = ReportItemData; + break; + case HID_RI_REPORT_SIZE(0): + CurrStateTable->Attributes.BitSize = ReportItemData; + break; + case HID_RI_REPORT_COUNT(0): + CurrStateTable->ReportCount = ReportItemData; + break; + case HID_RI_REPORT_ID(0): + 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 HID_RI_USAGE(0): + if (UsageListSize == HID_USAGE_STACK_DEPTH) + return HID_PARSE_UsageListOverflow; + + UsageList[UsageListSize++] = ReportItemData; + break; + case HID_RI_USAGE_MINIMUM(0): + UsageMinMax.Minimum = ReportItemData; + break; + case HID_RI_USAGE_MAXIMUM(0): + UsageMinMax.Maximum = ReportItemData; + break; + case HID_RI_COLLECTION(0): + 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 HID_RI_END_COLLECTION(0): + if (CurrCollectionPath == NULL) + return HID_PARSE_UnexpectedEndCollection; + + CurrCollectionPath = CurrCollectionPath->Parent; + break; + case HID_RI_INPUT(0): + case HID_RI_OUTPUT(0): + case HID_RI_FEATURE(0): + 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 ItemTypeTag = (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK)); + + if (ItemTypeTag == HID_RI_INPUT(0)) + NewReportItem.ItemType = HID_REPORT_ITEM_In; + else if (ItemTypeTag == HID_RI_OUTPUT(0)) + 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; + + ParserData->LargestReportSizeBits = MAX(ParserData->LargestReportSizeBits, CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]); + + if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS) + return HID_PARSE_InsufficientReportItems; + + memcpy(&ParserData->ReportItems[ParserData->TotalReportItems], + &NewReportItem, sizeof(HID_ReportItem_t)); + + if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem)) + ParserData->TotalReportItems++; + } + + break; + } + + if ((HIDReportItem & HID_RI_TYPE_MASK) == HID_RI_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) +{ + if (ReportItem == NULL) + return false; + + 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) +{ + if (ReportItem == NULL) + return; + + 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 / 8) + ((ReportSizeBits % 8) ? 1 : 0); + } + + return 0; +} + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.h new file mode 100644 index 000000000..dd14bea43 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDParser.h @@ -0,0 +1,364 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB 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 + * \brief USB Human Interface Device (HID) Class report descriptor 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 Sec_ModDescription Module Description + * Human Interface Device (HID) class report descriptor parser. This module implements a parser than is + * capable of processing a complete HID report descriptor, and outputting a flat structure containing the + * contents of the report in an a more friendly format. The parsed data may then be further processed and used + * within an application to process sent and received HID reports to and from an attached HID device. + * + * A HID report descriptor consists of a set of HID report items, which describe the function and layout + * of data exchanged between a HID device and a host, including both the physical encoding of each item + * (such as a button, key press or joystick axis) in the sent and received data packets - known as "reports" - + * as well as other information about each item such as the usages, data range, physical location and other + * characteristics. In this way a HID device can retain a high degree of flexibility in its capabilities, as it + * is not forced to comply with a given report layout or feature-set. + * + * This module also contains routines for the processing of data in an actual HID report, using the parsed report + * descriptor data as a guide for the encoding. + * + * @{ + */ + +#ifndef __HIDPARSER_H__ +#define __HIDPARSER_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + #include "HIDReportData.h" + #include "HIDClassCommon.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 \c 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 \c 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 \c 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 \c 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 \c 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 HID_CollectionPath + { + uint8_t Type; /**< Collection type (e.g. "Generic Desktop"). */ + HID_Usage_t Usage; /**< Collection usage. */ + struct HID_CollectionPath* Parent; /**< Reference to parent collection, or \c 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 \ref HID_ReportItemTypes_t. */ + uint16_t ItemFlags; /**< Item data flags, a mask of \c HID_IOF_* constants. */ + 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 \c 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 \c Value + * to its \c 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 \c true if the item to retrieve was located in the given report, \c false otherwise. + */ + bool USB_GetHIDReportItemInfo(const uint8_t* ReportData, + HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1); + + /** Retrieves the given report item's value out of the \c 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 \c Value element to its \c 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); + + /** Retrieves the size of a given HID report in bytes from its 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 determined. + * \param[in] ReportType Type of the report whose size is to be determined, a value from the + * \ref HID_ReportItemTypes_t enum. + * + * \return Size of the report in bytes, or \c 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 + * \ref 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. + * + * Report item pointers passed to this callback function may be cached by the user application for later use + * when processing report items. This provides faster report processing in the user application than would + * a search of the entire parsed report item table for each received or sent report. + * + * \param[in] CurrentItem Pointer to the current report item for user checking. + * + * \return Boolean \c true if the item should be stored into the \ref HID_ReportInfo_t structure, \c 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDReportData.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDReportData.h new file mode 100644 index 000000000..719739a5f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/HIDReportData.h @@ -0,0 +1,126 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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_HIDReportItemConst HID Report Descriptor Item Constants + * + * General HID constant definitions for HID Report Descriptor elements. + * + * @{ + */ + +#ifndef __HIDREPORTDATA_H__ +#define __HIDREPORTDATA_H__ + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define HID_RI_DATA_SIZE_MASK 0x03 + #define HID_RI_TYPE_MASK 0x0C + #define HID_RI_TAG_MASK 0xF0 + + #define HID_RI_TYPE_MAIN 0x00 + #define HID_RI_TYPE_GLOBAL 0x04 + #define HID_RI_TYPE_LOCAL 0x08 + + #define HID_RI_DATA_BITS_0 0x00 + #define HID_RI_DATA_BITS_8 0x01 + #define HID_RI_DATA_BITS_16 0x02 + #define HID_RI_DATA_BITS_32 0x03 + #define HID_RI_DATA_BITS(DataBits) HID_RI_DATA_BITS_ ## DataBits + + #define _HID_RI_ENCODE_0(Data) + #define _HID_RI_ENCODE_8(Data) , (Data & 0xFF) + #define _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_8(Data) _HID_RI_ENCODE_8(Data >> 8) + #define _HID_RI_ENCODE_32(Data) _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_16(Data >> 16) + #define _HID_RI_ENCODE(DataBits, ...) _HID_RI_ENCODE_ ## DataBits(__VA_ARGS__) + + #define _HID_RI_ENTRY(Type, Tag, DataBits, ...) (Type | Tag | HID_RI_DATA_BITS(DataBits)) _HID_RI_ENCODE(DataBits, (__VA_ARGS__)) + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name HID Input, Output and Feature Report Descriptor Item Flags */ + //@{ + #define HID_IOF_CONSTANT (1 << 0) + #define HID_IOF_DATA (0 << 0) + #define HID_IOF_VARIABLE (1 << 1) + #define HID_IOF_ARRAY (0 << 1) + #define HID_IOF_RELATIVE (1 << 2) + #define HID_IOF_ABSOLUTE (0 << 2) + #define HID_IOF_WRAP (1 << 3) + #define HID_IOF_NO_WRAP (0 << 3) + #define HID_IOF_NON_LINEAR (1 << 4) + #define HID_IOF_LINEAR (0 << 4) + #define HID_IOF_NO_PREFERRED_STATE (1 << 5) + #define HID_IOF_PREFERRED_STATE (0 << 5) + #define HID_IOF_NULLSTATE (1 << 6) + #define HID_IOF_NO_NULL_POSITION (0 << 6) + #define HID_IOF_VOLATILE (1 << 7) + #define HID_IOF_NON_VOLATILE (0 << 7) + #define HID_IOF_BUFFERED_BYTES (1 << 8) + #define HID_IOF_BITFIELD (0 << 8) + //@} + + /** \name HID Report Descriptor Item Macros */ + //@{ + #define HID_RI_INPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x80, DataBits, __VA_ARGS__) + #define HID_RI_OUTPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x90, DataBits, __VA_ARGS__) + #define HID_RI_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xA0, DataBits, __VA_ARGS__) + #define HID_RI_FEATURE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xB0, DataBits, __VA_ARGS__) + #define HID_RI_END_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xC0, DataBits, __VA_ARGS__) + #define HID_RI_USAGE_PAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x00, DataBits, __VA_ARGS__) + #define HID_RI_LOGICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x10, DataBits, __VA_ARGS__) + #define HID_RI_LOGICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x20, DataBits, __VA_ARGS__) + #define HID_RI_PHYSICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x30, DataBits, __VA_ARGS__) + #define HID_RI_PHYSICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x40, DataBits, __VA_ARGS__) + #define HID_RI_UNIT_EXPONENT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x50, DataBits, __VA_ARGS__) + #define HID_RI_UNIT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x60, DataBits, __VA_ARGS__) + #define HID_RI_REPORT_SIZE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x70, DataBits, __VA_ARGS__) + #define HID_RI_REPORT_ID(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x80, DataBits, __VA_ARGS__) + #define HID_RI_REPORT_COUNT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x90, DataBits, __VA_ARGS__) + #define HID_RI_PUSH(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xA0, DataBits, __VA_ARGS__) + #define HID_RI_POP(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xB0, DataBits, __VA_ARGS__) + #define HID_RI_USAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x00, DataBits, __VA_ARGS__) + #define HID_RI_USAGE_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x10, DataBits, __VA_ARGS__) + #define HID_RI_USAGE_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x20, DataBits, __VA_ARGS__) + //@} + +/** @} */ + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h new file mode 100644 index 000000000..e0b77eca8 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MIDIClassCommon.h @@ -0,0 +1,320 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB 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 Sec_ModDescription 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 "../../Core/StdDescriptors.h" + #include "AudioClassCommon.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 + + /* 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. + * + * \return Constructed MIDI channel ID. + */ + #define MIDI_CHANNEL(channel) ((channel) - 1) + + /** Constructs a MIDI event ID from a given MIDI command and a virtual MIDI cable index. This can then be + * used to create and decode \ref MIDI_EventPacket_t MIDI event packets. + * + * \param[in] virtualcable Index of the virtual MIDI cable the event relates to + * \param[in] command MIDI command to send through the virtual MIDI cable + * + * \return Constructed MIDI event ID. + */ + #define MIDI_EVENT(virtualcable, command) ((virtualcable << 4) | (command >> 4)) + + /* 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t JackType; /**< Type of jack, one of the \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t bJackType; /**< Type of jack, one of the \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t JackType; /**< Type of jack, one of the \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */ + + uint8_t bJackType; /**< Type of jack, one of the \c 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */ + uint8_t Subtype; /**< Sub type value used to distinguish between 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + + uint8_t 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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */ + + 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. */ + } ATTR_PACKED MIDI_EventPacket_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h new file mode 100644 index 000000000..38167f64e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/MassStorageClassCommon.h @@ -0,0 +1,365 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \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 Sec_ModDescription 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 "../../Core/StdDescriptors.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 + + /* 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 error 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t Signature; /**< Command block signature, must be \ref MS_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. */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t Signature; /**< Status block signature, must be \ref MS_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. */ + } ATTR_PACKED 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 SenseKey : 4; + unsigned Reserved : 1; + unsigned ILI : 1; + unsigned EOM : 1; + unsigned 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]; + } ATTR_PACKED 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 DeviceType : 5; + unsigned PeripheralQualifier : 3; + + unsigned Reserved : 7; + unsigned Removable : 1; + + uint8_t Version; + + unsigned ResponseDataFormat : 4; + unsigned Reserved2 : 1; + unsigned NormACA : 1; + unsigned TrmTsk : 1; + unsigned AERC : 1; + + uint8_t AdditionalLength; + uint8_t Reserved3[2]; + + unsigned SoftReset : 1; + unsigned CmdQue : 1; + unsigned Reserved4 : 1; + unsigned Linked : 1; + unsigned Sync : 1; + unsigned WideBus16Bit : 1; + unsigned WideBus32Bit : 1; + unsigned RelAddr : 1; + + uint8_t VendorID[8]; + uint8_t ProductID[16]; + uint8_t RevisionID[4]; + } ATTR_PACKED SCSI_Inquiry_Response_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h new file mode 100644 index 000000000..eea39297c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/PrinterClassCommon.h @@ -0,0 +1,119 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB 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 Sec_ModDescription 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 "../../Core/StdDescriptors.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 + + /* 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h new file mode 100644 index 000000000..bc4112189 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/RNDISClassCommon.h @@ -0,0 +1,414 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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 Sec_ModDescription 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 "../../Core/StdDescriptors.h" + #include "CDCClassCommon.h" + + /* 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: */ + /** Additional error code for RNDIS functions when a device returns a logical command failure. */ + #define RNDIS_ERROR_LOGICAL_CMD_FAILED 0x80 + + /** 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 + //@} + + /** \name RNDIS Media Types */ + //@{ + #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 */ + } ATTR_PACKED MAC_Address_t; + + /** \brief RNDIS Common Message Header Structure. + * + * Type define for a RNDIS message header, sent before RNDIS messages. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; /**< RNDIS message type, a \c REMOTE_NDIS_*_MSG constant */ + uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */ + } ATTR_PACKED 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + 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; + } ATTR_PACKED RNDIS_Packet_Message_t; + + /** \brief RNDIS Initialization Message Structure. + * + * Type define for a RNDIS Initialize command message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + + uint32_t MajorVersion; + uint32_t MinorVersion; + uint32_t MaxTransferSize; + } ATTR_PACKED RNDIS_Initialize_Message_t; + + /** \brief RNDIS Initialize Complete Message Structure. + * + * Type define for a RNDIS Initialize Complete response message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + 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; + } ATTR_PACKED RNDIS_Initialize_Complete_t; + + /** \brief RNDIS Keep Alive Message Structure. + * + * Type define for a RNDIS Keep Alive command message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + } ATTR_PACKED RNDIS_KeepAlive_Message_t; + + /** \brief RNDIS Keep Alive Complete Message Structure. + * + * Type define for a RNDIS Keep Alive Complete response message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + } ATTR_PACKED RNDIS_KeepAlive_Complete_t; + + /** \brief RNDIS Reset Complete Message Structure. + * + * Type define for a RNDIS Reset Complete response message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t Status; + + uint32_t AddressingReset; + } ATTR_PACKED RNDIS_Reset_Complete_t; + + /** \brief RNDIS OID Property Set Message Structure. + * + * Type define for a RNDIS OID Property Set command message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + + uint32_t Oid; + uint32_t InformationBufferLength; + uint32_t InformationBufferOffset; + uint32_t DeviceVcHandle; + } ATTR_PACKED RNDIS_Set_Message_t; + + /** \brief RNDIS OID Property Set Complete Message Structure. + * + * Type define for a RNDIS OID Property Set Complete response message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + } ATTR_PACKED RNDIS_Set_Complete_t; + + /** \brief RNDIS OID Property Query Message Structure. + * + * Type define for a RNDIS OID Property Query command message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + + uint32_t Oid; + uint32_t InformationBufferLength; + uint32_t InformationBufferOffset; + uint32_t DeviceVcHandle; + } ATTR_PACKED RNDIS_Query_Message_t; + + /** \brief RNDIS OID Property Query Complete Message Structure. + * + * Type define for a RNDIS OID Property Query Complete response message. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint32_t MessageType; + uint32_t MessageLength; + uint32_t RequestId; + uint32_t Status; + + uint32_t InformationBufferLength; + uint32_t InformationBufferOffset; + } ATTR_PACKED RNDIS_Query_Complete_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h new file mode 100644 index 000000000..a3388e2e7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Common/StillImageClassCommon.h @@ -0,0 +1,161 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common definitions and declarations for the library USB 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 Sec_ModDescription 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 "../../Core/StdDescriptors.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 + + /* 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 \c 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. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + 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). */ + } ATTR_PACKED PIMA_Container_t; + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c new file mode 100644 index 000000000..3fb350a11 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.c @@ -0,0 +1,198 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_AUDIO_DRIVER +#define __INCLUDE_FROM_AUDIO_DEVICE_C +#include "AudioClassDevice.h" + +void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) + { + uint8_t InterfaceIndex = (USB_ControlRequest.wIndex & 0xFF); + + if ((InterfaceIndex != AudioInterfaceInfo->Config.ControlInterfaceNumber) && + (InterfaceIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber)) + { + return; + } + } + else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) + { + uint8_t EndpointAddress = (USB_ControlRequest.wIndex & 0xFF); + + if ((EndpointAddress != AudioInterfaceInfo->Config.DataINEndpoint.Address) && + (EndpointAddress != AudioInterfaceInfo->Config.DataOUTEndpoint.Address)) + { + 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); + EVENT_Audio_Device_StreamStartStop(AudioInterfaceInfo); + } + + break; + case AUDIO_REQ_GetStatus: + if ((USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) || + (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT))) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + } + + break; + case AUDIO_REQ_SetCurrent: + case AUDIO_REQ_SetMinimum: + case AUDIO_REQ_SetMaximum: + case AUDIO_REQ_SetResolution: + if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) + { + uint8_t EndpointProperty = USB_ControlRequest.bRequest; + uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex; + uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8); + + if (CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress, + EndpointControl, NULL, NULL)) + { + uint16_t ValueLength = USB_ControlRequest.wLength; + uint8_t Value[ValueLength]; + + Endpoint_ClearSETUP(); + Endpoint_Read_Control_Stream_LE(Value, ValueLength); + Endpoint_ClearIN(); + + CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress, + EndpointControl, &ValueLength, Value); + } + } + else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) + { + uint8_t Property = USB_ControlRequest.bRequest; + uint8_t Entity = (USB_ControlRequest.wIndex >> 8); + uint16_t Parameter = USB_ControlRequest.wValue; + + if (CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity, + Parameter, NULL, NULL)) + { + uint16_t ValueLength = USB_ControlRequest.wLength; + uint8_t Value[ValueLength]; + + Endpoint_ClearSETUP(); + Endpoint_Read_Control_Stream_LE(Value, ValueLength); + Endpoint_ClearIN(); + + CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity, + Parameter, &ValueLength, Value); + } + } + + break; + case AUDIO_REQ_GetCurrent: + case AUDIO_REQ_GetMinimum: + case AUDIO_REQ_GetMaximum: + case AUDIO_REQ_GetResolution: + if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT) + { + uint8_t EndpointProperty = USB_ControlRequest.bRequest; + uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex; + uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8); + uint16_t ValueLength = USB_ControlRequest.wLength; + uint8_t Value[ValueLength]; + + if (CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress, + EndpointControl, &ValueLength, Value)) + { + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(Value, ValueLength); + Endpoint_ClearOUT(); + } + } + else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE) + { + uint8_t Property = USB_ControlRequest.bRequest; + uint8_t Entity = (USB_ControlRequest.wIndex >> 8); + uint16_t Parameter = USB_ControlRequest.wValue; + uint16_t ValueLength = USB_ControlRequest.wLength; + uint8_t Value[ValueLength]; + + if (CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity, + Parameter, &ValueLength, Value)) + { + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(Value, ValueLength); + Endpoint_ClearOUT(); + } + } + + break; + } +} + +bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) +{ + memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State)); + + AudioInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_ISOCHRONOUS; + AudioInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_ISOCHRONOUS; + + if (!(Endpoint_ConfigureEndpointTable(&AudioInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&AudioInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; + + return true; +} + +// cppcheck-suppress unusedFunction +void Audio_Device_Event_Stub(void) +{ + +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h new file mode 100644 index 000000000..09a832808 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/AudioClassDevice.h @@ -0,0 +1,396 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB 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 1.0 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/AudioClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/AudioClassCommon.h" + + /* 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 + + /* 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 + * \c AudioInterfaceInfo parameter. This stores each Audio interface's configuration and state information. + */ + typedef struct + { + struct + { + uint8_t ControlInterfaceNumber; /**< Index of the Audio Control interface within the device this + * structure controls. + */ + uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this + * structure controls. + */ + + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + } 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. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c 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); + + /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented + * in the user application to handle property manipulations on streaming audio endpoints. + * + * When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for + * the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations + * to indicate the size of the retrieved data. + * + * \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value + * of the \c DataLength parameter. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * \param[in] EndpointProperty Property of the endpoint to get or set, a value from \ref Audio_ClassRequests_t. + * \param[in] EndpointAddress Address of the streaming endpoint whose property is being referenced. + * \param[in] EndpointControl Parameter of the endpoint to get or set, a value from \ref Audio_EndpointControls_t. + * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum + * length of the retrieved data. When NULL, the function should return whether the given property + * and parameter is valid for the requested endpoint without reading or modifying the Data buffer. + * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where + * the retrieved data is to be stored for GET operations. + * + * \return Boolean \c true if the property GET/SET was successful, \c false otherwise + */ + bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const uint8_t EndpointProperty, + const uint8_t EndpointAddress, + const uint8_t EndpointControl, + uint16_t* const DataLength, + uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1); + + /** Audio class driver callback for the setting and retrieval of streaming interface properties. This callback must be implemented + * in the user application to handle property manipulations on streaming audio interfaces. + * + * When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for + * the given entity and should return as fast as possible. When non-NULL, this value may be altered for GET operations + * to indicate the size of the retrieved data. + * + * \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value + * of the \c DataLength parameter. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * \param[in] Property Property of the interface to get or set, a value from \ref Audio_ClassRequests_t. + * \param[in] EntityAddress Address of the audio entity whose property is being referenced. + * \param[in] Parameter Parameter of the entity to get or set, specific to each type of entity (see USB Audio specification). + * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum + * length of the retrieved data. When NULL, the function should return whether the given property + * and parameter is valid for the requested endpoint without reading or modifying the Data buffer. + * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where + * the retrieved data is to be stored for GET operations. + * + * \return Boolean \c true if the property GET/SET was successful, \c false otherwise + */ + bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, + const uint8_t Property, + const uint8_t EntityAddress, + const uint16_t Parameter, + uint16_t* const DataLength, + uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1); + + /** Audio class driver event for an Audio Stream start/stop change. This event fires each time the device receives a stream enable or + * disable control request from the host, to start and stop the audio stream. The current state of the stream can be determined by the + * State.InterfaceEnabled value inside the Audio interface structure passed as a parameter. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + */ + void EVENT_Audio_Device_StreamStartStop(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo); + + /* 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 \c true if the given Audio interface has a sample to be read, \c 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.DataOUTEndpoint.Address); + 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 \c true if the given Audio interface is ready to accept the next sample, \c 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.DataINEndpoint.Address); + 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 + * 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 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_8(); + + 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_16_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_8() << 16) | Endpoint_Read_16_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_8(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size) + 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_16_LE(Sample); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size) + 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_16_LE(Sample); + Endpoint_Write_8(Sample >> 16); + + if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size) + Endpoint_ClearIN(); + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_AUDIO_DEVICE_C) + void Audio_Device_Event_Stub(void) ATTR_CONST; + + void EVENT_Audio_Device_StreamStartStop(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) + ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(Audio_Device_Event_Stub); + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c new file mode 100644 index 000000000..e77aa280b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.c @@ -0,0 +1,339 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_CDC_DRIVER +#define __INCLUDE_FROM_CDC_DEVICE_C +#include "CDCClassDevice.h" + +void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if (!(Endpoint_IsSETUPReceived())) + return; + + if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber) + return; + + switch (USB_ControlRequest.bRequest) + { + case CDC_REQ_GetLineEncoding: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + + while (!(Endpoint_IsINReady())); + + Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); + Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); + Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); + Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits); + + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + + break; + case CDC_REQ_SetLineEncoding: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); + CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8(); + CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8(); + CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8(); + + Endpoint_ClearOUT(); + Endpoint_ClearStatusStage(); + + EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo); + } + + break; + case CDC_REQ_SetControlLineState: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue; + + EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo); + } + + break; + case CDC_REQ_SendBreak: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue); + } + + break; + } +} + +bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State)); + + CDCInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + CDCInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + CDCInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT; + + if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.NotificationEndpoint, 1))) + return false; + + return true; +} + +void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return; + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + CDC_Device_Flush(CDCInterfaceInfo); + #endif +} + +uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const String) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); + return Endpoint_Write_Stream_LE(String, strlen(String), NULL); +} + +uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const Buffer, + const uint16_t Length) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); + return Endpoint_Write_Stream_LE(Buffer, Length, NULL); +} + +uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Data) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); + + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) + return ErrorCode; + } + + Endpoint_Write_8(Data); + return ENDPOINT_READYWAIT_NoError; +} + +uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return ENDPOINT_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address); + + 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.DataOUTEndpoint.Address); + + 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.DataOUTEndpoint.Address); + + if (Endpoint_IsOUTReceived()) + { + if (Endpoint_BytesInEndpoint()) + ReceivedByte = Endpoint_Read_8(); + + if (!(Endpoint_BytesInEndpoint())) + Endpoint_ClearOUT(); + } + + return ReceivedByte; +} + +void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS)) + return; + + Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpoint.Address); + + USB_Request_Header_t Notification = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = CDC_NOTIF_SerialState, + .wValue = CPU_TO_LE16(0), + .wIndex = CPU_TO_LE16(0), + .wLength = CPU_TO_LE16(sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost)), + }; + + Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL); + Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost, + sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost), + NULL); + Endpoint_ClearIN(); +} + +#if defined(FDEV_SETUP_STREAM) +void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar, _FDEV_SETUP_RW); + fdev_set_udata(Stream, CDCInterfaceInfo); +} + +void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar_Blocking, _FDEV_SETUP_RW); + fdev_set_udata(Stream, CDCInterfaceInfo); +} + +static int CDC_Device_putchar(char c, + FILE* Stream) +{ + return CDC_Device_SendByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0; +} + +static int CDC_Device_getchar(FILE* Stream) +{ + int16_t ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); + + if (ReceivedByte < 0) + return _FDEV_EOF; + + return ReceivedByte; +} + +static int CDC_Device_getchar_Blocking(FILE* Stream) +{ + int16_t ReceivedByte; + + while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return _FDEV_EOF; + + CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream)); + USB_USBTask(); + } + + return ReceivedByte; +} +#endif + +// cppcheck-suppress unusedFunction +void CDC_Device_Event_Stub(void) +{ + +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h new file mode 100644 index 000000000..a4528d1dd --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/CDCClassDevice.h @@ -0,0 +1,352 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB CDC Class driver. + * + * Device mode driver for the library USB CDC Class driver. + * + * \note This file should not be included directly. It is automatically included as needed by the USB module driver + * dispatch header located in LUFA/Drivers/USB.h. + */ + +/** \ingroup Group_USBClassCDC + * \defgroup Group_USBClassCDCDevice CDC Class Device Mode Driver + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * Device Mode USB Class driver framework interface, for the CDC USB Class driver. + * + * \note There are several major drawbacks to the CDC-ACM standard USB class, however + * it is very standardized and thus usually available as a built-in driver on + * most platforms, and so is a better choice than a proprietary serial class. + * + * One major issue with CDC-ACM is that it requires two Interface descriptors, + * which will upset most hosts when part of a multi-function "Composite" USB + * device. This is because each interface will be loaded into a separate driver + * instance, causing the two interfaces be become unlinked. To prevent this, you + * should use the "Interface Association Descriptor" addendum to the USB 2.0 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. It is thus highly recommended + * that the virtual serial line DTR (Data Terminal Ready) signal be used where possible + * to determine if a host application is ready for data. + * + * @{ + */ + +#ifndef _CDC_CLASS_DEVICE_H_ +#define _CDC_CLASS_DEVICE_H_ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/CDCClassCommon.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_CDC_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief CDC Class Device Mode Configuration and State Structure. + * + * Class state structure. An instance of this structure should be made for each CDC interface + * within the user application, and passed to each of the CDC class driver functions as the + * CDCInterfaceInfo parameter. This stores each CDC interface's configuration and state information. + */ + typedef struct + { + struct + { + uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device. */ + + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + USB_Endpoint_Table_t NotificationEndpoint; /**< Notification IN Endpoint configuration table. */ + } Config; /**< Config data for the USB class interface within the device. All elements in this section + * must be set or the interface will fail to enumerate and operate correctly. + */ + struct + { + struct + { + uint16_t HostToDevice; /**< Control line states from the host to device, as a set of \c CDC_CONTROL_LINE_OUT_* + * masks. This value is updated each time \ref CDC_Device_USBTask() is called. + */ + uint16_t DeviceToHost; /**< Control line states from the device to host, as a set of \c CDC_CONTROL_LINE_IN_* + * masks - to notify the host of changes to these values, call the + * \ref CDC_Device_SendControlLineStateChange() function. + */ + } ControlLineStates; /**< Current states of the virtual serial port's control lines between the device and host. */ + + CDC_LineEncoding_t LineEncoding; /** Line encoding used in the virtual serial port, for the device's information. + * This is generally only used if the virtual serial port data is to be + * reconstructed on a physical UART. + */ + } State; /**< State data for the USB class interface within the device. All elements in this section + * are reset to their defaults when the interface is enumerated. + */ + } USB_ClassInfo_CDC_Device_t; + + /* Function Prototypes: */ + /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library + * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing + * the given CDC interface is selected. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise. + */ + bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Processes incoming control requests from the host, that are directed to the given CDC class interface. This should be + * linked to the library \ref EVENT_USB_Device_ControlRequest() event. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** General management task for a given CDC class interface, required for the correct operation of the interface. This should + * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a + * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the + * user program by declaring a handler function with the same name and parameters listed here. The new line encoding + * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a + * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the + * user program by declaring a handler function with the same name and parameters listed here. The new control line states + * are available in the \c ControlLineStates.HostToDevice value inside the CDC interface structure passed as a parameter, set as + * a mask of \c CDC_CONTROL_LINE_OUT_* masks. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** CDC class driver event for a send break request sent to the device from the host. This is generally used to separate + * data or to indicate a special condition to the receiving device. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] Duration Duration of the break that has been sent by the host, in milliseconds. + */ + void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a given data buffer to the attached USB host, if connected. If a host is not connected when the function is + * called, the string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank + * becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows + * for multiple bytes to be packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] Buffer Pointer to a buffer containing the data to send to the device. + * \param[in] Length Length of the data to send to the host. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const Buffer, + const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given null terminated string to the attached USB host, if connected. If a host is not connected when + * the function is called, the string is discarded. Bytes will be queued for transmission to the host until either + * the endpoint bank becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to + * the host. This allows for multiple bytes to be packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] String Pointer to the null terminated string to send to the host. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the + * byte is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the + * \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be + * packed into a single endpoint packet, increasing data throughput. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in] Data Byte of data to send to the host. + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); + + /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. This indicates the number + * of bytes in the OUT endpoint bank only, and thus the number of calls to \ref CDC_Device_ReceiveByte() which are guaranteed to + * succeed immediately. If multiple bytes are to be received, they should be buffered by the user application, as the endpoint + * bank will not be released back to the USB controller until all bytes are read. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Total number of buffered bytes received from the host. + */ + uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function + * returns a negative value. The \ref CDC_Device_BytesReceived() function may be queried in advance to determine how many + * bytes are currently buffered in the CDC interface's data receive endpoint bank, and thus how many repeated calls to this + * function which are guaranteed to succeed. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return Next received byte from the host, or a negative value if no data received. + */ + int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial + * control lines (DCD, DSR, etc.) have changed states, or to give BREAK notifications to the host. Line states persist + * until they are cleared via a second notification. This should be called each time the CDC class driver's + * \c ControlLineStates.DeviceToHost value is updated to push the new states to the USB host. + * + * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or + * the call will fail. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + */ + void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + #if defined(FDEV_SETUP_STREAM) || defined(__DOXYGEN__) + /** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular + * functions in the standard library that accept a \c FILE stream as a destination (e.g. \c fprintf()). The created + * stream is bidirectional and can be used for both input and output functions. + * + * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single + * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may + * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own + * line buffering. + * + * \note The created stream can be given as \c stdout if desired to direct the standard output from all functions + * to the given CDC interface. + * \n\n + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates + * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications. + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_CDC_DEVICE_C) + #if defined(FDEV_SETUP_STREAM) + static int CDC_Device_putchar(char c, + FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); + static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + #endif + + void CDC_Device_Event_Stub(void) ATTR_CONST; + + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) + ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub); + void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) + ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub); + void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, + const uint8_t Duration) ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) + ATTR_ALIAS(CDC_Device_Event_Stub); + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c new file mode 100644 index 000000000..a56747b08 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.c @@ -0,0 +1,200 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_HID_DRIVER +#define __INCLUDE_FROM_HID_DEVICE_C +#include "HIDClassDevice.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[ReportID ? 1 : 0], ReportSize - (ReportID ? 1 : 0)); + } + + break; + case HID_REQ_GetProtocol: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(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(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(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; + + HIDInterfaceInfo->Config.ReportINEndpoint.Type = EP_TYPE_INTERRUPT; + + if (!(Endpoint_ConfigureEndpointTable(&HIDInterfaceInfo->Config.ReportINEndpoint, 1))) + return false; + + return true; +} + +void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + if (HIDInterfaceInfo->State.PrevFrameNum == USB_Device_GetFrameNumber()) + return; + + Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpoint.Address); + + 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.ReportINEndpoint.Address); + + if (ReportID) + Endpoint_Write_8(ReportID); + + Endpoint_Write_Stream_LE(ReportINData, ReportINSize, NULL); + + Endpoint_ClearIN(); + } + + HIDInterfaceInfo->State.PrevFrameNum = USB_Device_GetFrameNumber(); + } +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h new file mode 100644 index 000000000..ea2125772 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/HIDClassDevice.h @@ -0,0 +1,210 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB 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/HIDClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/HIDClassCommon.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 + + /* 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 + * \c 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 + { + struct + { + uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device. */ + + USB_Endpoint_Table_t ReportINEndpoint; /**< Data IN HID report endpoint configuration table. */ + + 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 \c 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 \c 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 \c 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 PrevFrameNum; /**< Frame number of the previous HID report packet opportunity. */ + 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. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c 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 \c 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), \c 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c new file mode 100644 index 000000000..3ff339c06 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c @@ -0,0 +1,125 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_MIDI_DRIVER +#define __INCLUDE_FROM_MIDI_DEVICE_C +#include "MIDIClassDevice.h" + +bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) +{ + memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State)); + + MIDIInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + MIDIInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + + if (!(Endpoint_ConfigureEndpointTable(&MIDIInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&MIDIInterfaceInfo->Config.DataOUTEndpoint, 1))) + 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.DataINEndpoint.Address); + + if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL)) != 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.DataINEndpoint.Address); + + 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.DataOUTEndpoint.Address); + + if (!(Endpoint_IsReadWriteAllowed())) + return false; + + Endpoint_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL); + + if (!(Endpoint_IsReadWriteAllowed())) + Endpoint_ClearOUT(); + + return true; +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h new file mode 100644 index 000000000..c5b01be5d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MIDIClassDevice.h @@ -0,0 +1,175 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB 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/MIDIClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/MIDIClassCommon.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 + + /* 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 + * \c MIDIInterfaceInfo parameter. This stores each MIDI interface's configuration and state information. + */ + typedef struct + { + struct + { + uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls. */ + + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + } 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 RESERVED; // 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. + * + * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c 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 behavior, 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 \c true if a MIDI event packet was received, \c 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c new file mode 100644 index 000000000..735437e46 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c @@ -0,0 +1,215 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_MS_DRIVER +#define __INCLUDE_FROM_MASSSTORAGE_DEVICE_C +#include "MassStorageClassDevice.h" + +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(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(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)); + + MSInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + MSInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + + if (!(Endpoint_ConfigureEndpointTable(&MSInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&MSInterfaceInfo->Config.DataOUTEndpoint, 1))) + 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.DataOUTEndpoint.Address); + + if (Endpoint_IsOUTReceived()) + { + if (MS_Device_ReadInCommandBlock(MSInterfaceInfo)) + { + if (MSInterfaceInfo->State.CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN) + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); + + bool SCSICommandResult = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo); + + MSInterfaceInfo->State.CommandStatus.Status = (SCSICommandResult) ? MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail; + MSInterfaceInfo->State.CommandStatus.Signature = CPU_TO_LE32(MS_CSW_SIGNATURE); + MSInterfaceInfo->State.CommandStatus.Tag = MSInterfaceInfo->State.CommandBlock.Tag; + MSInterfaceInfo->State.CommandStatus.DataTransferResidue = MSInterfaceInfo->State.CommandBlock.DataTransferLength; + + if (!(SCSICommandResult) && (le32_to_cpu(MSInterfaceInfo->State.CommandStatus.DataTransferResidue))) + Endpoint_StallTransaction(); + + MS_Device_ReturnCommandStatus(MSInterfaceInfo); + } + } + + if (MSInterfaceInfo->State.IsMassStoreReset) + { + Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); + Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); + + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); + Endpoint_ClearStall(); + Endpoint_ResetDataToggle(); + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); + Endpoint_ClearStall(); + Endpoint_ResetDataToggle(); + + MSInterfaceInfo->State.IsMassStoreReset = false; + } +} + +static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + uint16_t BytesProcessed; + + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); + + BytesProcessed = 0; + while (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock, + (sizeof(MS_CommandBlockWrapper_t) - 16), &BytesProcessed) == + ENDPOINT_RWSTREAM_IncompleteTransfer) + { + if (MSInterfaceInfo->State.IsMassStoreReset) + return false; + } + + if ((MSInterfaceInfo->State.CommandBlock.Signature != CPU_TO_LE32(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.DataINEndpoint.Address); + Endpoint_StallTransaction(); + + return false; + } + + BytesProcessed = 0; + while (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock.SCSICommandData, + MSInterfaceInfo->State.CommandBlock.SCSICommandLength, &BytesProcessed) == + ENDPOINT_RWSTREAM_IncompleteTransfer) + { + if (MSInterfaceInfo->State.IsMassStoreReset) + return false; + } + + Endpoint_ClearOUT(); + + return true; +} + +static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) +{ + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address); + + while (Endpoint_IsStalled()) + { + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (MSInterfaceInfo->State.IsMassStoreReset) + return; + } + + Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address); + + while (Endpoint_IsStalled()) + { + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (MSInterfaceInfo->State.IsMassStoreReset) + return; + } + + uint16_t BytesProcessed = 0; + while (Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus, + sizeof(MS_CommandStatusWrapper_t), &BytesProcessed) == + ENDPOINT_RWSTREAM_IncompleteTransfer) + { + if (MSInterfaceInfo->State.IsMassStoreReset) + return; + } + + Endpoint_ClearIN(); +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h new file mode 100644 index 000000000..b9bc832e1 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.h @@ -0,0 +1,161 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB 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/MassStorageClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/MassStorageClassCommon.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 + + /* 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 + * \c MSInterfaceInfo parameter. This stores each Mass Storage interface's configuration and state information. + */ + typedef struct + { + struct + { + uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device. */ + + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + + 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. + * + * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c 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 \c true if the SCSI command was successfully processed, \c 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); + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c new file mode 100644 index 000000000..80aa723c1 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c @@ -0,0 +1,502 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_RNDIS_DRIVER +#define __INCLUDE_FROM_RNDIS_DEVICE_C +#include "RNDISClassDevice.h" + +static const uint32_t PROGMEM AdapterSupportedOIDList[] = + { + CPU_TO_LE32(OID_GEN_SUPPORTED_LIST), + CPU_TO_LE32(OID_GEN_PHYSICAL_MEDIUM), + CPU_TO_LE32(OID_GEN_HARDWARE_STATUS), + CPU_TO_LE32(OID_GEN_MEDIA_SUPPORTED), + CPU_TO_LE32(OID_GEN_MEDIA_IN_USE), + CPU_TO_LE32(OID_GEN_MAXIMUM_FRAME_SIZE), + CPU_TO_LE32(OID_GEN_MAXIMUM_TOTAL_SIZE), + CPU_TO_LE32(OID_GEN_LINK_SPEED), + CPU_TO_LE32(OID_GEN_TRANSMIT_BLOCK_SIZE), + CPU_TO_LE32(OID_GEN_RECEIVE_BLOCK_SIZE), + CPU_TO_LE32(OID_GEN_VENDOR_ID), + CPU_TO_LE32(OID_GEN_VENDOR_DESCRIPTION), + CPU_TO_LE32(OID_GEN_CURRENT_PACKET_FILTER), + CPU_TO_LE32(OID_GEN_MAXIMUM_TOTAL_SIZE), + CPU_TO_LE32(OID_GEN_MEDIA_CONNECT_STATUS), + CPU_TO_LE32(OID_GEN_XMIT_OK), + CPU_TO_LE32(OID_GEN_RCV_OK), + CPU_TO_LE32(OID_GEN_XMIT_ERROR), + CPU_TO_LE32(OID_GEN_RCV_ERROR), + CPU_TO_LE32(OID_GEN_RCV_NO_BUFFER), + CPU_TO_LE32(OID_802_3_PERMANENT_ADDRESS), + CPU_TO_LE32(OID_802_3_CURRENT_ADDRESS), + CPU_TO_LE32(OID_802_3_MULTICAST_LIST), + CPU_TO_LE32(OID_802_3_MAXIMUM_LIST_SIZE), + CPU_TO_LE32(OID_802_3_RCV_ERROR_ALIGNMENT), + CPU_TO_LE32(OID_802_3_XMIT_ONE_COLLISION), + CPU_TO_LE32(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 = CPU_TO_LE32(1); + } + + Endpoint_ClearSETUP(); + Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, le32_to_cpu(MessageHeader->MessageLength)); + Endpoint_ClearOUT(); + + MessageHeader->MessageLength = CPU_TO_LE32(0); + } + + break; + } +} + +bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State)); + + RNDISInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK; + RNDISInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK; + RNDISInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT; + + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataINEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataOUTEndpoint, 1))) + return false; + + if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.NotificationEndpoint, 1))) + return false; + + return true; +} + +void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpoint.Address); + + 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 = CPU_TO_LE16(0), + .wIndex = CPU_TO_LE16(0), + .wLength = CPU_TO_LE16(0), + }; + + Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL); + + Endpoint_ClearIN(); + + RNDISInterfaceInfo->State.ResponseReady = 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 (le32_to_cpu(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 = CPU_TO_LE32(REMOTE_NDIS_INITIALIZE_CMPLT); + INITIALIZE_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Initialize_Complete_t)); + INITIALIZE_Response->RequestId = INITIALIZE_Message->RequestId; + INITIALIZE_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS); + + INITIALIZE_Response->MajorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MAJOR); + INITIALIZE_Response->MinorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MINOR); + INITIALIZE_Response->DeviceFlags = CPU_TO_LE32(REMOTE_NDIS_DF_CONNECTIONLESS); + INITIALIZE_Response->Medium = CPU_TO_LE32(REMOTE_NDIS_MEDIUM_802_3); + INITIALIZE_Response->MaxPacketsPerTransfer = CPU_TO_LE32(1); + INITIALIZE_Response->MaxTransferSize = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) + ETHERNET_FRAME_SIZE_MAX); + INITIALIZE_Response->PacketAlignmentFactor = CPU_TO_LE32(0); + INITIALIZE_Response->AFListOffset = CPU_TO_LE32(0); + INITIALIZE_Response->AFListSize = CPU_TO_LE32(0); + + RNDISInterfaceInfo->State.CurrRNDISState = RNDIS_Initialized; + break; + case REMOTE_NDIS_HALT_MSG: + RNDISInterfaceInfo->State.ResponseReady = false; + + MessageHeader->MessageLength = CPU_TO_LE32(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 = CPU_TO_LE32(QUERY_Message->Oid); + + void* QueryData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + + le32_to_cpu(QUERY_Message->InformationBufferOffset)]; + void* ResponseData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)]; + uint16_t ResponseSize; + + QUERY_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_QUERY_CMPLT); + + if (RNDIS_Device_ProcessNDISQuery(RNDISInterfaceInfo, Query_Oid, QueryData, le32_to_cpu(QUERY_Message->InformationBufferLength), + ResponseData, &ResponseSize)) + { + QUERY_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS); + QUERY_Response->MessageLength = cpu_to_le32(sizeof(RNDIS_Query_Complete_t) + ResponseSize); + + QUERY_Response->InformationBufferLength = CPU_TO_LE32(ResponseSize); + QUERY_Response->InformationBufferOffset = CPU_TO_LE32(sizeof(RNDIS_Query_Complete_t) - sizeof(RNDIS_Message_Header_t)); + } + else + { + QUERY_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_NOT_SUPPORTED); + QUERY_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Query_Complete_t)); + + QUERY_Response->InformationBufferLength = CPU_TO_LE32(0); + QUERY_Response->InformationBufferOffset = CPU_TO_LE32(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 = le32_to_cpu(SET_Message->Oid); + + SET_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_SET_CMPLT); + SET_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Set_Complete_t)); + SET_Response->RequestId = SET_Message->RequestId; + + void* SetData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + + le32_to_cpu(SET_Message->InformationBufferOffset)]; + + SET_Response->Status = RNDIS_Device_ProcessNDISSet(RNDISInterfaceInfo, SET_Oid, SetData, + le32_to_cpu(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 = CPU_TO_LE32(REMOTE_NDIS_RESET_CMPLT); + RESET_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Reset_Complete_t)); + RESET_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS); + RESET_Response->AddressingReset = CPU_TO_LE32(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 = CPU_TO_LE32(REMOTE_NDIS_KEEPALIVE_CMPLT); + KEEPALIVE_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_KeepAlive_Complete_t)); + KEEPALIVE_Response->RequestId = KEEPALIVE_Message->RequestId; + KEEPALIVE_Response->Status = CPU_TO_LE32(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) = CPU_TO_LE32(0); + + return true; + case OID_GEN_HARDWARE_STATUS: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = CPU_TO_LE32(NDIS_HardwareStatus_Ready); + + return true; + case OID_GEN_MEDIA_SUPPORTED: + case OID_GEN_MEDIA_IN_USE: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = CPU_TO_LE32(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) = CPU_TO_LE32(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) = CPU_TO_LE32(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) = CPU_TO_LE32(REMOTE_NDIS_MEDIA_STATE_CONNECTED); + + return true; + case OID_GEN_LINK_SPEED: + *ResponseSize = sizeof(uint32_t); + + /* Indicate 10Mb/s link speed */ + *((uint32_t*)ResponseData) = CPU_TO_LE32(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) = CPU_TO_LE32(1); + + return true; + case OID_GEN_CURRENT_PACKET_FILTER: + *ResponseSize = sizeof(uint32_t); + + *((uint32_t*)ResponseData) = cpu_to_le32(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) = CPU_TO_LE32(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) = CPU_TO_LE32(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 = le32_to_cpu(*((uint32_t*)SetData)); + RNDISInterfaceInfo->State.CurrRNDISState = (RNDISInterfaceInfo->State.CurrPacketFilter) ? RNDIS_Data_Initialized : RNDIS_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; + } +} + +bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || + (RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized)) + { + return false; + } + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address); + return Endpoint_IsOUTReceived(); +} + +uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + void* Buffer, + uint16_t* const PacketLength) +{ + if ((USB_DeviceState != DEVICE_STATE_Configured) || + (RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized)) + { + return ENDPOINT_RWSTREAM_DeviceDisconnected; + } + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address); + + *PacketLength = 0; + + if (!(Endpoint_IsOUTReceived())) + return ENDPOINT_RWSTREAM_NoError; + + RNDIS_Packet_Message_t RNDISPacketHeader; + Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NULL); + + if (le32_to_cpu(RNDISPacketHeader.DataLength) > ETHERNET_FRAME_SIZE_MAX) + { + Endpoint_StallTransaction(); + + return RNDIS_ERROR_LOGICAL_CMD_FAILED; + } + + *PacketLength = (uint16_t)le32_to_cpu(RNDISPacketHeader.DataLength); + + Endpoint_Read_Stream_LE(Buffer, *PacketLength, NULL); + Endpoint_ClearOUT(); + + return ENDPOINT_RWSTREAM_NoError; +} + +uint8_t RNDIS_Device_SendPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t PacketLength) +{ + uint8_t ErrorCode; + + if ((USB_DeviceState != DEVICE_STATE_Configured) || + (RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized)) + { + return ENDPOINT_RWSTREAM_DeviceDisconnected; + } + + Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpoint.Address); + + if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError) + return ErrorCode; + + RNDIS_Packet_Message_t RNDISPacketHeader; + + memset(&RNDISPacketHeader, 0, sizeof(RNDIS_Packet_Message_t)); + + RNDISPacketHeader.MessageType = CPU_TO_LE32(REMOTE_NDIS_PACKET_MSG); + RNDISPacketHeader.MessageLength = cpu_to_le32(sizeof(RNDIS_Packet_Message_t) + PacketLength); + RNDISPacketHeader.DataOffset = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)); + RNDISPacketHeader.DataLength = cpu_to_le32(PacketLength); + + Endpoint_Write_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NULL); + Endpoint_Write_Stream_LE(Buffer, PacketLength, NULL); + Endpoint_ClearIN(); + + return ENDPOINT_RWSTREAM_NoError; +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h new file mode 100644 index 000000000..4d1a4cff8 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Device/RNDISClassDevice.h @@ -0,0 +1,203 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Device mode driver for the library USB 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/RNDISClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/RNDISClassCommon.h" + + /* 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 + + /* 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 + * \c RNDISInterfaceInfo parameter. This stores each RNDIS interface's configuration and state information. + */ + typedef struct + { + struct + { + uint8_t ControlInterfaceNumber; /**< Interface number of the RNDIS control interface within the device. */ + + USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */ + USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */ + USB_Endpoint_Table_t NotificationEndpoint; /**< Notification IN Endpoint configuration table. */ + + 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. */ + } 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 RNDIS interface is selected. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state. + * + * \return Boolean \c true if the endpoints were successfully configured, \c 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 RNDIS 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); + + /** Determines if a packet is currently waiting for the device to read in and process. + * + * \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] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class configuration and state. + * + * \return Boolean \c true if a packet is waiting to be read in by the host, \c false otherwise. + */ + bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo); + + /** 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 device in the nominated buffer. + * + * \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] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class 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 Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + void* Buffer, + uint16_t* const PacketLength); + + /** 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 Device state machine is in the \ref DEVICE_STATE_Configured state or the + * call will fail. + * + * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class 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 Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t RNDIS_Device_SendPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo, + void* Buffer, + const uint16_t PacketLength); + + /* 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/HIDClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/HIDClass.h new file mode 100644 index 000000000..288559c75 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/HIDClass.h @@ -0,0 +1,81 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB 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/HIDClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/HIDClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/HIDParser.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Sec_ModDescription 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 "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/HIDClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/HIDClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c new file mode 100644 index 000000000..67a1352b3 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c @@ -0,0 +1,422 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_AOA_DRIVER +#define __INCLUDE_FROM_ANDROIDACCESSORY_HOST_C +#include "AndroidAccessoryClassHost.h" + +bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const USB_Descriptor_Device_t* const DeviceDescriptor, + bool* const NeedModeSwitch) +{ + (void)AOAInterfaceInfo; + + if (DeviceDescriptor->Header.Type != DTYPE_Device) + return false; + + *NeedModeSwitch = ((DeviceDescriptor->ProductID != ANDROID_ACCESSORY_PRODUCT_ID) && + (DeviceDescriptor->ProductID != ANDROID_ACCESSORY_ADB_PRODUCT_ID)); + + return true; +} + +uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Interface_t* AOAInterface = NULL; + + memset(&AOAInterfaceInfo->State, 0x00, sizeof(AOAInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return AOA_ENUMERROR_InvalidConfigDescriptor; + + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_AOA_Host_NextAndroidAccessoryInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return AOA_ENUMERROR_NoCompatibleInterfaceFound; + } + + AOAInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + while (!(DataINEndpoint) || !(DataOUTEndpoint)) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_AOA_Host_NextInterfaceBulkEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + return AOA_ENUMERROR_NoCompatibleInterfaceFound; + } + + USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); + + if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + AOAInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + AOAInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + AOAInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + AOAInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + AOAInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + AOAInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + AOAInterfaceInfo->State.IsActive = true; + AOAInterfaceInfo->State.InterfaceNumber = AOAInterface->InterfaceNumber; + + return AOA_ENUMERROR_NoError; +} + +static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(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 == AOA_CSCP_AOADataClass) && + (Interface->SubClass == AOA_CSCP_AOADataSubclass) && + (Interface->Protocol == AOA_CSCP_AOADataProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(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 AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return; + + #if !defined(NO_CLASS_DRIVER_AUTOFLUSH) + AOA_Host_Flush(AOAInterfaceInfo); + #endif +} + +uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) +{ + uint8_t ErrorCode; + + uint16_t AccessoryProtocol; + if ((ErrorCode = AOA_Host_GetAccessoryProtocol(&AccessoryProtocol)) != HOST_WAITERROR_Successful) + return ErrorCode; + + if (AccessoryProtocol != CPU_TO_LE16(AOA_PROTOCOL_AccessoryV1)) + return AOA_ERROR_LOGICAL_CMD_FAILED; + + for (uint8_t PropertyIndex = 0; PropertyIndex < AOA_STRING_TOTAL_STRINGS; PropertyIndex++) + { + if ((ErrorCode = AOA_Host_SendPropertyString(AOAInterfaceInfo, PropertyIndex)) != HOST_WAITERROR_Successful) + return ErrorCode; + } + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE), + .bRequest = AOA_REQ_StartAccessoryMode, + .wValue = 0, + .wIndex = 0, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(NULL); +} + +static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE), + .bRequest = AOA_REQ_GetAccessoryProtocol, + .wValue = 0, + .wIndex = 0, + .wLength = sizeof(uint16_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest(Protocol); +} + +static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const uint8_t StringIndex) +{ + const char* String = AOAInterfaceInfo->Config.PropertyStrings[StringIndex]; + + if (String == NULL) + String = ""; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE), + .bRequest = AOA_REQ_SendString, + .wValue = 0, + .wIndex = StringIndex, + .wLength = (strlen(String) + 1), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + return USB_Host_SendControlRequest((char*)String); +} + +uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const uint8_t* const Buffer, + const uint16_t Length) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address); + + Pipe_Unfreeze(); + ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL); + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const char* const String) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address); + + Pipe_Unfreeze(); + ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL); + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const uint8_t Data) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + } + + Pipe_Write_8(Data); + Pipe_Freeze(); + + return PIPE_READYWAIT_NoError; +} + +uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return 0; + + Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address); + 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 AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return -1; + + int16_t ReceivedByte = -1; + + Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + ReceivedByte = Pipe_Read_8(); + + if (!(Pipe_BytesInPipe())) + Pipe_ClearIN(); + } + + Pipe_Freeze(); + + return ReceivedByte; +} + +uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address); + 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; +} + +#if defined(FDEV_SETUP_STREAM) +void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar, _FDEV_SETUP_RW); + fdev_set_udata(Stream, AOAInterfaceInfo); +} + +void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + FILE* const Stream) +{ + *Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar_Blocking, _FDEV_SETUP_RW); + fdev_set_udata(Stream, AOAInterfaceInfo); +} + +static int AOA_Host_putchar(char c, + FILE* Stream) +{ + return AOA_Host_SendByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0; +} + +static int AOA_Host_getchar(FILE* Stream) +{ + int16_t ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream)); + + if (ReceivedByte < 0) + return _FDEV_EOF; + + return ReceivedByte; +} + +static int AOA_Host_getchar_Blocking(FILE* Stream) +{ + int16_t ReceivedByte; + + while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0) + { + if (USB_HostState == HOST_STATE_Unattached) + return _FDEV_EOF; + + AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream)); + USB_USBTask(); + } + + return ReceivedByte; +} +#endif + +#endif + + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.h new file mode 100644 index 000000000..f55cd340a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.h @@ -0,0 +1,314 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Host mode driver for the library USB Android Open Accessory Class driver. + * + * Host mode driver for the library USB Android Open Accessory 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_USBClassAOA + * \defgroup Group_USBClassAndroidAccessoryHost Android Open Accessory 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/AndroidAccessoryClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * Host Mode USB Class driver framework interface, for the Android Open Accessory USB Class driver. + * + * @{ + */ + +#ifndef __AOA_CLASS_HOST_H__ +#define __AOA_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/AndroidAccessoryClassCommon.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_AOA_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Error code for some Android Open Accessory Host functions, indicating a logical (and not hardware) error. */ + #define AOA_ERROR_LOGICAL_CMD_FAILED 0x80 + + /* Type Defines: */ + /** \brief Android Open Accessory 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 Android Open Accessory class driver functions as the \c AOAInterfaceInfo + * parameter. This stores each Android Open Accessory interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + + char* PropertyStrings[AOA_STRING_TOTAL_STRINGS]; /**< Android Accessory property strings, sent to identify the accessory when the + * Android device is switched into Open Accessory mode. */ + } 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 AOA_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t InterfaceNumber; /**< Interface index of the AOA interface within the attached 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_AOA_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref AOA_Host_ConfigurePipes() function. */ + enum AOA_Host_EnumerationFailure_ErrorCodes_t + { + AOA_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + AOA_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + AOA_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Android Open Accessory interface was not found in the device's Configuration Descriptor. */ + AOA_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* Function Prototypes: */ + /** General management task for a given Android Open Accessory 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] AOAInterfaceInfo Pointer to a structure containing an Android Open Accessory Class host configuration and state. + */ + void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Validates a device descriptor, to check if the device is a valid Android device, and if it is currently in Android Open Accessory mode. + * + * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state. + * \param[in] DeviceDescriptor Pointer a buffer containing the attached device's Device Descriptor. + * \param[out] NeedModeSwitch Pointer to a boolean where the mode switch requirement of the attached device is to be stored. + * + * \return Boolean \c true if the attached device is a valid Android device, \c false otherwise. + */ + bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const USB_Descriptor_Device_t* const DeviceDescriptor, + bool* const NeedModeSwitch) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3); + + /** Host interface configuration routine, to configure a given Android Open Accessory host interface instance using the Configuration + * Descriptor read from an attached USB device. This function automatically updates the given Android Open Accessory 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. + * + * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA 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 AOA_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Starts Accessory Mode in the attached Android device. This function will validate the device's Android Open Accessory protocol + * version, send the configured property strings, and request a switch to Android Open Accessory mode. + * + * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum, or \ref AOA_ERROR_LOGICAL_CMD_FAILED if a logical error occurred.. + */ + uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a given data buffer to the attached USB device, if connected. If a device is not connected when the function is + * called, the data will be discarded. Bytes will be queued for transmission to the device until either the pipe bank + * becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. 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] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state. + * \param[in] Buffer Pointer to a buffer containing the data to send to the device. + * \param[in] Length Length of the data to send to the device. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const uint8_t* const Buffer, + const uint16_t Length); + + /** Sends a given null-terminated 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 AOA_Host_Flush() function is called to flush the pending data to the device. 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] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state. + * \param[in] String Pointer to the null terminated string to send to the device. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const char* const String) 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 AOA_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] AOAInterfaceInfo Pointer to a structure containing a AOA 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 AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1); + + /** Determines the number of bytes received by the AOA 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 AOA_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] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state. + * + * \return Total number of buffered bytes received from the device. + */ + uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) 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 AOA_Host_BytesReceived() function may be queried in advance to determine how many bytes + * are currently buffered in the AOA 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] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state. + * + * \return Next received byte from the device, or a negative value if no data received. + */ + int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) 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] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state. + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1); + + /** Creates a standard character stream for the given AOA Device instance so that it can be used with all the regular + * functions in the standard \c library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created + * stream is bidirectional and can be used for both input and output functions. + * + * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single + * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may + * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own + * line buffering. + * + * \note The created stream can be given as \c stdout if desired to direct the standard output from all \c functions + * to the given AOA interface. + * \n\n + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + FILE* const Stream); + + /** Identical to \ref AOA_Host_CreateStream(), except that reads are blocking until the calling stream function terminates + * the transfer. While blocking, the USB and AOA service tasks are called repeatedly to maintain USB communications. + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + FILE* const Stream); + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_ANDROIDACCESSORY_HOST_C) + #if defined(FDEV_SETUP_STREAM) + static int AOA_Host_putchar(char c, + FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); + static int AOA_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + static int AOA_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); + #endif + + static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol) ATTR_NON_NULL_PTR_ARG(1); + static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo, + const uint8_t StringIndex) ATTR_NON_NULL_PTR_ARG(1); + + static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.c new file mode 100644 index 000000000..1e869e830 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.c @@ -0,0 +1,223 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_AUDIO_DRIVER +#define __INCLUDE_FROM_AUDIO_HOST_C +#include "AudioClassHost.h" + +uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) +{ + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; + USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; + USB_Descriptor_Interface_t* AudioControlInterface = NULL; + USB_Descriptor_Interface_t* AudioStreamingInterface = NULL; + + memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State)); + + if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration) + return AUDIO_ENUMERROR_InvalidConfigDescriptor; + + while ((AudioInterfaceInfo->Config.DataINPipe.Address && !(DataINEndpoint)) || + (AudioInterfaceInfo->Config.DataOUTPipe.Address && !(DataOUTEndpoint))) + { + if (!(AudioControlInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (!(AudioControlInterface) || + USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_Audio_Host_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_Audio_Host_NextAudioControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return AUDIO_ENUMERROR_NoCompatibleInterfaceFound; + } + + AudioControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t); + + if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, + DCOMP_Audio_Host_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found) + { + return AUDIO_ENUMERROR_NoCompatibleInterfaceFound; + } + } + + AudioStreamingInterface = 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_DIR_MASK) == ENDPOINT_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + AudioInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + AudioInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + AudioInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_ISOCHRONOUS; + AudioInterfaceInfo->Config.DataINPipe.Banks = 2; + + AudioInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + AudioInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + AudioInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_ISOCHRONOUS; + AudioInterfaceInfo->Config.DataOUTPipe.Banks = 2; + + if (!(Pipe_ConfigurePipeTable(&AudioInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&AudioInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + AudioInterfaceInfo->State.ControlInterfaceNumber = AudioControlInterface->InterfaceNumber; + AudioInterfaceInfo->State.StreamingInterfaceNumber = AudioStreamingInterface->InterfaceNumber; + AudioInterfaceInfo->State.EnabledStreamingAltIndex = AudioStreamingInterface->AlternateSetting; + AudioInterfaceInfo->State.IsActive = true; + + return AUDIO_ENUMERROR_NoError; +} + +static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(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 == AUDIO_CSCP_AudioClass) && + (Interface->SubClass == AUDIO_CSCP_ControlSubclass) && + (Interface->Protocol == AUDIO_CSCP_ControlProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(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 == AUDIO_CSCP_AudioClass) && + (Interface->SubClass == AUDIO_CSCP_AudioStreamingSubclass) && + (Interface->Protocol == AUDIO_CSCP_StreamingProtocol)) + { + return DESCRIPTOR_SEARCH_Found; + } + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(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); + + if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_ISOCHRONOUS) + return DESCRIPTOR_SEARCH_Found; + } + else if (Header->Type == DTYPE_Interface) + { + return DESCRIPTOR_SEARCH_Fail; + } + + return DESCRIPTOR_SEARCH_NotFound; +} + +uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const bool EnableStreaming) +{ + if (!(AudioInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + return USB_Host_SetInterfaceAltSetting(AudioInterfaceInfo->State.StreamingInterfaceNumber, + EnableStreaming ? AudioInterfaceInfo->State.EnabledStreamingAltIndex : 0); +} + +uint8_t Audio_Host_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const uint8_t DataPipeIndex, + const uint8_t EndpointProperty, + const uint8_t EndpointControl, + const uint16_t DataLength, + void* const Data) +{ + if (!(AudioInterfaceInfo->State.IsActive)) + return HOST_SENDCONTROL_DeviceDisconnected; + + uint8_t RequestType; + uint8_t EndpointAddress; + + if (EndpointProperty & 0x80) + RequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT); + else + RequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT); + + Pipe_SelectPipe(DataPipeIndex); + EndpointAddress = Pipe_GetBoundEndpointAddress(); + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = RequestType, + .bRequest = EndpointProperty, + .wValue = ((uint16_t)EndpointControl << 8), + .wIndex = EndpointAddress, + .wLength = DataLength, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Data); +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.h new file mode 100644 index 000000000..6cb78a621 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/AudioClassHost.h @@ -0,0 +1,411 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Host mode driver for the library USB Audio 1.0 Class driver. + * + * Host 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_USBClassAudioHost Audio 1.0 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/AudioClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription Module Description + * Host Mode USB Class driver framework interface, for the Audio 1.0 USB Class driver. + * + * @{ + */ + +#ifndef __AUDIO_CLASS_HOST_H__ +#define __AUDIO_CLASS_HOST_H__ + + /* Includes: */ + #include "../../USB.h" + #include "../Common/AudioClassCommon.h" + + /* 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 + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief Audio 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 Audio class driver functions as the \c AudioInterfaceInfo parameter. This + * stores each Audio interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + } 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 Audio_Host_ConfigurePipes() is called and the Host state machine is in the + * Configured state. + */ + uint8_t ControlInterfaceNumber; /**< Interface index of the Audio Control interface within the attached device. */ + uint8_t StreamingInterfaceNumber; /**< Interface index of the Audio Streaming interface within the attached device. */ + + uint8_t EnabledStreamingAltIndex; /**< Alternative setting index of the Audio Streaming interface when the stream is enabled. */ + } 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_Audio_Host_t; + + /* Enums: */ + /** Enum for the possible error codes returned by the \ref Audio_Host_ConfigurePipes() function. */ + enum AUDIO_Host_EnumerationFailure_ErrorCodes_t + { + AUDIO_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */ + AUDIO_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */ + AUDIO_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible AUDIO interface was not found in the device's Configuration Descriptor. */ + AUDIO_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* Function Prototypes: */ + /** Host interface configuration routine, to configure a given Audio host interface instance using the Configuration + * Descriptor read from an attached USB device. This function automatically updates the given Audio 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. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio 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 AUDIO_Host_EnumerationFailure_ErrorCodes_t enum. + */ + uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + uint16_t ConfigDescriptorSize, + void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** Starts or stops the audio streaming for the given configured Audio Host interface, allowing for audio samples to be + * send and/or received. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state. + * \param[in] EnableStreaming Boolean true to enable streaming of the specified interface, false to disable + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const bool EnableStreaming) ATTR_NON_NULL_PTR_ARG(1); + + /** Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given + * class instance. + * + * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state. + * \param[in] DataPipeIndex Index of the data pipe whose bound endpoint is to be altered. + * \param[in] EndpointProperty Property of the endpoint to get or set, a value from \ref Audio_ClassRequests_t. + * \param[in] EndpointControl Parameter of the endpoint to get or set, a value from \ref Audio_EndpointControls_t. + * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum + * length of the retrieved data. + * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where + * the retrieved data is to be stored for GET operations. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t Audio_Host_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const uint8_t DataPipeIndex, + const uint8_t EndpointProperty, + const uint8_t EndpointControl, + const uint16_t DataLength, + void* const Data) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6); + + /* Inline Functions: */ + /** General management task for a given Audio 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] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state. + */ + static inline void Audio_Host_USBTask(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Host_USBTask(USB_ClassInfo_Audio_Host_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 + * IN pipe ready for reading. + * + * \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] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean \c true if the given Audio interface has a sample to be read, \c false otherwise. + */ + static inline bool Audio_Host_IsSampleReceived(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline bool Audio_Host_IsSampleReceived(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + { + if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive)) + return false; + + bool SampleReceived = false; + + Pipe_SelectPipe(AudioInterfaceInfo->Config.DataINPipe.Address); + Pipe_Unfreeze(); + SampleReceived = Pipe_IsINReceived(); + Pipe_Freeze(); + + return SampleReceived; + } + + /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects + * the streaming OUT pipe ready for writing. + * + * \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] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state. + * + * \return Boolean \c true if the given Audio interface is ready to accept the next sample, \c false otherwise. + */ + static inline bool Audio_Host_IsReadyForNextSample(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline bool Audio_Host_IsReadyForNextSample(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + { + if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive)) + return false; + + Pipe_SelectPipe(AudioInterfaceInfo->Config.DataOUTPipe.Address); + return Pipe_IsOUTReady(); + } + + /** 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_Host_IsSampleReceived() function to ensure + * that the correct pipe 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_Host_ReadSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline int8_t Audio_Host_ReadSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + { + int8_t Sample; + + (void)AudioInterfaceInfo; + + Sample = Pipe_Read_8(); + + if (!(Pipe_BytesInPipe())) + { + Pipe_Unfreeze(); + Pipe_ClearIN(); + Pipe_Freeze(); + } + + 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_Host_IsSampleReceived() function to ensure + * that the correct pipe 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_Host_ReadSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline int16_t Audio_Host_ReadSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + { + int16_t Sample; + + (void)AudioInterfaceInfo; + + Sample = (int16_t)Pipe_Read_16_LE(); + + if (!(Pipe_BytesInPipe())) + { + Pipe_Unfreeze(); + Pipe_ClearIN(); + Pipe_Freeze(); + } + + 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_Host_IsSampleReceived() function to ensure + * that the correct pipe 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_Host_ReadSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline int32_t Audio_Host_ReadSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo) + { + int32_t Sample; + + (void)AudioInterfaceInfo; + + Sample = (((uint32_t)Pipe_Read_8() << 16) | Pipe_Read_16_LE()); + + if (!(Pipe_BytesInPipe())) + { + Pipe_Unfreeze(); + Pipe_ClearIN(); + Pipe_Freeze(); + } + + 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_Host_IsReadyForNextSample() function to + * ensure that the correct pipe 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_Host_WriteSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const int8_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Host_WriteSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const int8_t Sample) + { + (void)AudioInterfaceInfo; + + Pipe_Write_8(Sample); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_Unfreeze(); + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + Pipe_Freeze(); + } + } + + /** 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_Host_IsReadyForNextSample() function to + * ensure that the correct pipe 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_Host_WriteSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const int16_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Host_WriteSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const int16_t Sample) + { + (void)AudioInterfaceInfo; + + Pipe_Write_16_LE(Sample); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_Unfreeze(); + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + Pipe_Freeze(); + } + } + + /** 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_Host_IsReadyForNextSample() function to + * ensure that the correct pipe 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_Host_WriteSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const int32_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + static inline void Audio_Host_WriteSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, + const int32_t Sample) + { + (void)AudioInterfaceInfo; + + Pipe_Write_16_LE(Sample); + Pipe_Write_8(Sample >> 16); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_Unfreeze(); + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + Pipe_Freeze(); + } + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_AUDIO_HOST_C) + static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(void* CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(void* CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.c new file mode 100644 index 000000000..dd48da1d8 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.c @@ -0,0 +1,478 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_CDC_DRIVER +#define __INCLUDE_FROM_CDC_HOST_C +#include "CDCClassHost.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_DIR_MASK) == ENDPOINT_DIR_IN) + { + if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) + NotificationEndpoint = EndpointData; + else + DataINEndpoint = EndpointData; + } + else + { + DataOUTEndpoint = EndpointData; + } + } + + CDCInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + CDCInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + CDCInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + CDCInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + CDCInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + CDCInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + CDCInterfaceInfo->Config.NotificationPipe.Size = le16_to_cpu(NotificationEndpoint->EndpointSize); + CDCInterfaceInfo->Config.NotificationPipe.EndpointAddress = NotificationEndpoint->EndpointAddress; + CDCInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.NotificationPipe, 1))) + return false; + + 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.NotificationPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + USB_Request_Header_t Notification; + Pipe_Read_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL); + + 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), + NULL); + + 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_SendData(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const uint8_t* const Buffer, + const uint16_t Length) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address); + + Pipe_Unfreeze(); + ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL); + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const char* const String) +{ + if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive)) + return PIPE_READYWAIT_DeviceDisconnected; + + uint8_t ErrorCode; + + Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address); + + Pipe_Unfreeze(); + ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL); + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + } + + Pipe_Write_8(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.DataINPipe.Address); + 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.DataINPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + ReceivedByte = Pipe_Read_8(); + + 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.DataOUTPipe.Address); + 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; +} + +#if defined(FDEV_SETUP_STREAM) +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; +} +#endif + +// cppcheck-suppress unusedFunction +void CDC_Host_Event_Stub(void) +{ + +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.h new file mode 100644 index 000000000..f5faab935 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/CDCClassHost.h @@ -0,0 +1,351 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/CDCClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/CDCClassCommon.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_CDC_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** \brief CDC Class 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 \c CDCInterfaceInfo parameter. This + * stores each CDC interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + USB_Pipe_Table_t NotificationPipe; /**< Notification IN Pipe configuration table. */ + } 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. */ + + struct + { + uint16_t HostToDevice; /**< Control line states from the host to device, as a set of \c CDC_CONTROL_LINE_OUT_* + * masks - to notify the device of changes to these values, call the + * \ref CDC_Host_SendControlLineStateChange() function. + */ + uint16_t DeviceToHost; /**< Control line states from the device to host, as a set of \c 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. */ + CDC_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* 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. + * + * \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] ConfigDescriptorData 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* ConfigDescriptorData) 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 \c 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 \c 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 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 data buffer to the attached USB device, if connected. If a device is not connected when the function is + * called, the data will be 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 device. 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] Buffer Pointer to a buffer containing the data to send to the device. + * \param[in] Length Length of the data to send to the device. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t CDC_Host_SendData(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + const uint8_t* const Buffer, + const uint16_t Length); + + /** Sends a given null-terminated 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 device. 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] String Pointer to the null terminated 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 String) 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); + + #if defined(FDEV_SETUP_STREAM) || defined(__DOXYGEN__) + /** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular + * functions in the standard \c library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created + * stream is bidirectional and can be used for both input and output functions. + * + * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single + * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may + * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own + * line buffering. + * + * \note The created stream can be given as \c stdout if desired to direct the standard output from all \c functions + * to the given CDC interface. + * \n\n + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + FILE* const Stream); + + /** Identical to \ref 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. + * + * \note This function is not available on all microcontroller architectures. + * + * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. + * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. + */ + void CDC_Host_CreateBlockingStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, + FILE* const Stream); + #endif + + /** 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 \c ControlLineStates.DeviceToHost value inside the CDC host interface structure passed as a parameter, set as + * a mask of \c 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) + #if defined(FDEV_SETUP_STREAM) + 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); + #endif + + void CDC_Host_Event_Stub(void) ATTR_CONST; + + 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_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.c new file mode 100644 index 000000000..ae2395bc7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.c @@ -0,0 +1,396 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HID_DRIVER +#define __INCLUDE_FROM_HID_HOST_C +#include "HIDClassHost.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_NextHIDDescriptor) != 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_DIR_MASK) == ENDPOINT_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + HIDInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + HIDInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + HIDInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_INTERRUPT; + + HIDInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + HIDInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + HIDInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber; + HIDInterfaceInfo->State.HIDReportSize = LE16_TO_CPU(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_NextHIDDescriptor(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.DataINPipe.Address); + 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_8(); + *(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, NULL)) != 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (ReportID) + Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NULL); + + if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NULL)) != 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.DataINPipe.Address); + Pipe_Unfreeze(); + + ReportReceived = Pipe_IsINReceived(); + + Pipe_Freeze(); + + return ReportReceived; +} + +uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) +{ + uint8_t ErrorCode; + + if (!(HIDInterfaceInfo->State.SupportsBootProtocol)) + return HID_ERROR_LOGICAL; + + 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 ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + HIDInterfaceInfo->State.LargestReportSize = 8; + HIDInterfaceInfo->State.UsingBootProtocol = true; + + return HOST_SENDCONTROL_Successful; +} + +uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + const uint16_t MS) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), + .bRequest = HID_REQ_SetIdle, + .wValue = ((MS << 6) & 0xFF00), + .wIndex = HIDInterfaceInfo->State.InterfaceNumber, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +#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; + } + + uint16_t LargestReportSizeBits = HIDInterfaceInfo->Config.HIDParserData->LargestReportSizeBits; + HIDInterfaceInfo->State.LargestReportSize = (LargestReportSizeBits >> 3) + ((LargestReportSizeBits & 0x07) != 0); + + return 0; +} +#endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.h new file mode 100644 index 000000000..5d617b92f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/HIDClassHost.h @@ -0,0 +1,313 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/HIDClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/HIDClassCommon.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 + + /* 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 \c HIDInterfaceInfo parameter. This + * stores each HID interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + + 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 \c 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. */ + + 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. */ + HID_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* 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. + * + * \attention 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] ConfigDescriptorData 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* ConfigDescriptorData) 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. + * + * \attention 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 \c 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 \c 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 \c true if a report has been received, \c 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 \c 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); + + /** Sets the idle period for the attached HID device to the specified interval. The HID idle period determines the rate + * at which the device should send a report, when no state changes have occurred; i.e. on HID keyboards, this sets the + * hardware key repeat interval. + * + * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state. + * \param[in] MS Idle period as a multiple of four milliseconds, zero to disable hardware repeats + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. + */ + uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo, + const uint16_t MS) 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. + * + * \attention 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. + * + * \note When the \c 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) ATTR_NON_NULL_PTR_ARG(1); + 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_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_HID_Host_NextHIDDescriptor(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c new file mode 100644 index 000000000..29a6696db --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.c @@ -0,0 +1,231 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_MIDI_DRIVER +#define __INCLUDE_FROM_MIDI_HOST_C +#include "MIDIClassHost.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_DIR_MASK) == ENDPOINT_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + MIDIInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + MIDIInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + MIDIInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + MIDIInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + MIDIInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + MIDIInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + if (!(Pipe_ConfigurePipeTable(&MIDIInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&MIDIInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_BytesInPipe()) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + { + Pipe_Freeze(); + return ErrorCode; + } + } + + Pipe_Freeze(); + + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL)) != PIPE_RWSTREAM_NoError) + { + Pipe_Freeze(); + return ErrorCode; + } + + if (!(Pipe_IsReadWriteAllowed())) + Pipe_ClearOUT(); + + Pipe_Freeze(); + + 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; + + bool DataReady = false; + + Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataINPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + { + Pipe_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL); + DataReady = true; + } + + if (!(Pipe_BytesInPipe())) + Pipe_ClearIN(); + } + + Pipe_Freeze(); + + return DataReady; +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.h new file mode 100644 index 000000000..15b9e4fc1 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MIDIClassHost.h @@ -0,0 +1,190 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/MIDIClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/MIDIClassCommon.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 + + /* 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 \c MIDIInterfaceInfo parameter. This + * stores each MIDI interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + } 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. */ + } 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. */ + MIDI_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* 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. + * + * \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] ConfigDescriptorData 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* ConfigDescriptorData) 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 behavior, 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 \c true if a MIDI event packet was received, \c 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_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c new file mode 100644 index 000000000..91e2ef022 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c @@ -0,0 +1,579 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_MS_DRIVER +#define __INCLUDE_FROM_MASSSTORAGE_HOST_C +#include "MassStorageClassHost.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_DIR_MASK) == ENDPOINT_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + MSInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + MSInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + MSInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + MSInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + MSInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + MSInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + if (!(Pipe_ConfigurePipeTable(&MSInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&MSInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + 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; + + if (++MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF) + MSInterfaceInfo->State.TransactionTag = 1; + + SCSICommandBlock->Signature = CPU_TO_LE32(MS_CBW_SIGNATURE); + SCSICommandBlock->Tag = cpu_to_le32(MSInterfaceInfo->State.TransactionTag); + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(SCSICommandBlock, sizeof(MS_CommandBlockWrapper_t), + NULL)) != PIPE_RWSTREAM_NoError) + { + return ErrorCode; + } + + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + + Pipe_Freeze(); + + if (BufferPtr != NULL) + { + ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, SCSICommandBlock, (void*)BufferPtr); + + if ((ErrorCode != PIPE_RWSTREAM_NoError) && (ErrorCode != PIPE_RWSTREAM_PipeStalled)) + { + Pipe_Freeze(); + return ErrorCode; + } + } + + MS_CommandStatusWrapper_t SCSIStatusBlock; + return MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSIStatusBlock); +} + +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.DataINPipe.Address); + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); + return PIPE_RWSTREAM_PipeStalled; + } + + Pipe_Freeze(); + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); + return PIPE_RWSTREAM_PipeStalled; + } + + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + }; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address); + Pipe_Freeze(); + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address); + 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 = le32_to_cpu(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.DataINPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem, NULL)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearIN(); + } + else + { + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem, NULL)) != 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.DataINPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(MS_CommandStatusWrapper_t), + NULL)) != 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) +{ + uint8_t ErrorCode; + + 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); + + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address); + + if ((ErrorCode = USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress())) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address); + + if ((ErrorCode = USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress())) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + return HOST_SENDCONTROL_Successful; +} + +uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, + uint8_t* const MaxLUNIndex) +{ + uint8_t ErrorCode; + + 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_SetupStalled) + { + *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; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = CPU_TO_LE32(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) + } + }; + + return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData); +} + +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; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = CPU_TO_LE32(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) + } + }; + + return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL); +} + +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 = CPU_TO_LE32(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) + } + }; + + if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + DeviceCapacity->Blocks = BE32_TO_CPU(DeviceCapacity->Blocks); + DeviceCapacity->BlockSize = BE32_TO_CPU(DeviceCapacity->BlockSize); + + 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; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = CPU_TO_LE32(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) + } + }; + + return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData); +} + +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; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = CPU_TO_LE32(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) + } + }; + + return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL); +} + +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; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = cpu_to_le32((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) + } + }; + + return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer); +} + +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; + + MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) + { + .DataTransferLength = cpu_to_le32((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) + } + }; + + return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer); +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.h new file mode 100644 index 000000000..2e7843184 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/MassStorageClassHost.h @@ -0,0 +1,335 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/MassStorageClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/MassStorageClassCommon.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 + + /* 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 \c MSInterfaceInfo parameter. This + * stores each Mass Storage interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + } 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. */ + + 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 for the possible error codes returned by the \ref MS_Host_ConfigurePipes() function. */ + 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. */ + MS_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* 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. + * + * \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] DeviceConfigDescriptor 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* DeviceConfigDescriptor) 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. This should be called after a failed SCSI request to + * ensure the attached Mass Storage device is ready to receive the next 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 \c true if the device should be locked from removal, \c 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) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE; + 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 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); + + static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c new file mode 100644 index 000000000..1ecf19115 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.c @@ -0,0 +1,400 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_PRINTER_DRIVER +#define __INCLUDE_FROM_PRINTER_HOST_C +#include "PrinterClassHost.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_DIR_MASK) == ENDPOINT_DIR_IN) + DataINEndpoint = EndpointData; + else + DataOUTEndpoint = EndpointData; + } + + PRNTInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + PRNTInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + PRNTInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + PRNTInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + PRNTInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + PRNTInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + if (!(Pipe_ConfigurePipeTable(&PRNTInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&PRNTInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + 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; + + if ((ErrorCode = USB_Host_SetInterfaceAltSetting(PRNTInterfaceInfo->State.InterfaceNumber, + PRNTInterfaceInfo->State.AlternateSetting)) != 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.DataOUTPipe.Address); + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError) + return ErrorCode; + } + + Pipe_Write_8(Data); + Pipe_Freeze(); + + return PIPE_READYWAIT_NoError; +} + +uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + const char* const String) +{ + uint8_t ErrorCode; + + if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive)) + return PIPE_RWSTREAM_DeviceDisconnected; + + Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + Pipe_ClearOUT(); + + ErrorCode = Pipe_WaitUntilReady(); + + Pipe_Freeze(); + + return ErrorCode; +} + +uint8_t PRNT_Host_SendData(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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL)) != 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.DataINPipe.Address); + 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.DataINPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsINReceived()) + { + if (Pipe_BytesInPipe()) + ReceivedByte = Pipe_Read_8(); + + 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; + 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 = be16_to_cpu(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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.h new file mode 100644 index 000000000..64494b1f6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/PrinterClassHost.h @@ -0,0 +1,285 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/PrinterClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/PrinterClassCommon.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 + + /* 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 \c PRNTInterfaceInfo parameter. This + * stores each Printer interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + } 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. */ + } 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 for the possible error codes returned by the \ref PRNT_Host_ConfigurePipes() function. */ + 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. */ + PRNT_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* Function Prototypes: */ + /** 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. + * + * \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] ConfigDescriptorData 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* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3); + + /** 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); + + /** 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 + * \c 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 null terminated string to the attached printer's input endpoint. + * + * \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] String Pointer to a null terminated string to send. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo, + const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** 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_SendData(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_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c new file mode 100644 index 000000000..1e23f8e7c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.c @@ -0,0 +1,476 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_RNDIS_DRIVER +#define __INCLUDE_FROM_RNDIS_HOST_C +#include "RNDISClassHost.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_DIR_MASK) == ENDPOINT_DIR_IN) + { + if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) + NotificationEndpoint = EndpointData; + else + DataINEndpoint = EndpointData; + } + else + { + DataOUTEndpoint = EndpointData; + } + } + + RNDISInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + RNDISInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + RNDISInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + RNDISInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + RNDISInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + RNDISInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + RNDISInterfaceInfo->Config.NotificationPipe.Size = le16_to_cpu(NotificationEndpoint->EndpointSize); + RNDISInterfaceInfo->Config.NotificationPipe.EndpointAddress = NotificationEndpoint->EndpointAddress; + RNDISInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.NotificationPipe, 1))) + return false; + + 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 = CPU_TO_LE32(REMOTE_NDIS_KEEPALIVE_MSG); + KeepAliveMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_KeepAlive_Message_t)); + KeepAliveMessage.RequestId = cpu_to_le32(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 = CPU_TO_LE32(REMOTE_NDIS_INITIALIZE_MSG); + InitMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Initialize_Message_t)); + InitMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++); + + InitMessage.MajorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MAJOR); + InitMessage.MinorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MINOR); + InitMessage.MaxTransferSize = cpu_to_le32(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 != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS)) + return RNDIS_ERROR_LOGICAL_CMD_FAILED; + + RNDISInterfaceInfo->State.DeviceMaxPacketSize = le32_to_cpu(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 = CPU_TO_LE32(REMOTE_NDIS_SET_MSG); + SetMessageData.SetMessage.MessageLength = cpu_to_le32(sizeof(RNDIS_Set_Message_t) + Length); + SetMessageData.SetMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++); + + SetMessageData.SetMessage.Oid = cpu_to_le32(Oid); + SetMessageData.SetMessage.InformationBufferLength = cpu_to_le32(Length); + SetMessageData.SetMessage.InformationBufferOffset = CPU_TO_LE32(sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t)); + SetMessageData.SetMessage.DeviceVcHandle = CPU_TO_LE32(0); + + memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length); + + if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &SetMessageData, + (sizeof(RNDIS_Set_Message_t) + Length))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &SetMessageResponse, + sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful) + { + return ErrorCode; + } + + if (SetMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS)) + return RNDIS_ERROR_LOGICAL_CMD_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 = CPU_TO_LE32(REMOTE_NDIS_QUERY_MSG); + QueryMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Query_Message_t)); + QueryMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++); + + QueryMessage.Oid = cpu_to_le32(Oid); + QueryMessage.InformationBufferLength = CPU_TO_LE32(0); + QueryMessage.InformationBufferOffset = CPU_TO_LE32(0); + QueryMessage.DeviceVcHandle = CPU_TO_LE32(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 != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS)) + return RNDIS_ERROR_LOGICAL_CMD_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.DataINPipe.Address); + + 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.DataINPipe.Address); + 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), + NULL)) != PIPE_RWSTREAM_NoError) + { + return ErrorCode; + } + + *PacketLength = (uint16_t)le32_to_cpu(DeviceMessage.DataLength); + + Pipe_Discard_Stream(le32_to_cpu(DeviceMessage.DataOffset) - + (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)), + NULL); + + Pipe_Read_Stream_LE(Buffer, *PacketLength, NULL); + + 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 = CPU_TO_LE32(REMOTE_NDIS_PACKET_MSG); + DeviceMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) + PacketLength); + DeviceMessage.DataOffset = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)); + DeviceMessage.DataLength = cpu_to_le32(PacketLength); + + Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t), + NULL)) != PIPE_RWSTREAM_NoError) + { + return ErrorCode; + } + + Pipe_Write_Stream_LE(Buffer, PacketLength, NULL); + Pipe_ClearOUT(); + + Pipe_Freeze(); + + return PIPE_RWSTREAM_NoError; +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.h new file mode 100644 index 000000000..bac6d5c2e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/RNDISClassHost.h @@ -0,0 +1,270 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/RNDISClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/RNDISClassCommon.h" + + /* 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 + + /* 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 \c RNDISInterfaceInfo parameter. This + * stores each RNDIS interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + USB_Pipe_Table_t NotificationPipe; /**< Notification IN Pipe configuration table. */ + + 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. */ + + 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. */ + RNDIS_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* 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. + * + * \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] ConfigDescriptorData 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* ConfigDescriptorData) 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_ERROR_LOGICAL_CMD_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); + + /** Initializes 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_ERROR_LOGICAL_CMD_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_ERROR_LOGICAL_CMD_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_ERROR_LOGICAL_CMD_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 \c true if a packet is waiting to be read in by the host, \c 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) ATTR_ALWAYS_INLINE; + 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_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c new file mode 100644 index 000000000..a6137b191 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.c @@ -0,0 +1,436 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../../Core/USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_SI_DRIVER +#define __INCLUDE_FROM_STILLIMAGE_HOST_C +#include "StillImageClassHost.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) || !(EventsEndpoint)) + { + 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_DIR_MASK) == ENDPOINT_DIR_IN) + { + if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) + EventsEndpoint = EndpointData; + else + DataINEndpoint = EndpointData; + } + else + { + DataOUTEndpoint = EndpointData; + } + } + + SIInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize); + SIInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress; + SIInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK; + + SIInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize); + SIInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress; + SIInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK; + + SIInterfaceInfo->Config.EventsPipe.Size = le16_to_cpu(EventsEndpoint->EndpointSize); + SIInterfaceInfo->Config.EventsPipe.EndpointAddress = EventsEndpoint->EndpointAddress; + SIInterfaceInfo->Config.EventsPipe.Type = EP_TYPE_INTERRUPT; + + if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataINPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataOUTPipe, 1))) + return false; + + if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.EventsPipe, 1))) + return false; + + 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 = cpu_to_le32(SIInterfaceInfo->State.TransactionID++); + + Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL)) != 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, NULL)) != 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.DataINPipe.Address); + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); + return PIPE_RWSTREAM_PipeStalled; + } + + Pipe_Freeze(); + Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address); + Pipe_Unfreeze(); + + if (Pipe_IsStalled()) + { + USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress()); + return PIPE_RWSTREAM_PipeStalled; + } + + if (USB_HostState == HOST_STATE_Unattached) + return PIPE_RWSTREAM_DeviceDisconnected; + } + + Pipe_Read_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL); + + if (PIMAHeader->Type == CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) + { + uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0)); + + if (ParamBytes) + Pipe_Read_Stream_LE(&PIMAHeader->Params, ParamBytes, NULL); + + 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.DataOUTPipe.Address); + Pipe_Unfreeze(); + + ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes, NULL); + + 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.DataINPipe.Address); + Pipe_Unfreeze(); + + ErrorCode = Pipe_Read_Stream_LE(Buffer, Bytes, NULL); + + 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.EventsPipe.Address); + 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.EventsPipe.Address); + Pipe_Unfreeze(); + + ErrorCode = Pipe_Read_Stream_LE(PIMAHeader, sizeof(PIMA_Container_t), NULL); + + 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 PIPE_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + SIInterfaceInfo->State.TransactionID = 0; + SIInterfaceInfo->State.IsSessionOpen = false; + + PIMA_Container_t PIMABlock = (PIMA_Container_t) + { + .DataLength = CPU_TO_LE32(PIMA_COMMAND_SIZE(1)), + .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock), + .Code = CPU_TO_LE16(0x1002), + .Params = {CPU_TO_LE32(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 != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(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 PIPE_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + PIMA_Container_t PIMABlock = (PIMA_Container_t) + { + .DataLength = CPU_TO_LE32(PIMA_COMMAND_SIZE(1)), + .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock), + .Code = CPU_TO_LE16(0x1003), + .Params = {CPU_TO_LE32(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 != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(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 PIPE_RWSTREAM_DeviceDisconnected; + + uint8_t ErrorCode; + + PIMA_Container_t PIMABlock = (PIMA_Container_t) + { + .DataLength = cpu_to_le32(PIMA_COMMAND_SIZE(TotalParams)), + .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock), + .Code = cpu_to_le16(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 PIPE_RWSTREAM_DeviceDisconnected; + + if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) + return ErrorCode; + + if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001))) + return SI_ERROR_LOGICAL_CMD_FAILED; + + return PIPE_RWSTREAM_NoError; +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.h new file mode 100644 index 000000000..acfbd7d61 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/Host/StillImageClassHost.h @@ -0,0 +1,317 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief 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/StillImageClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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/StillImageClassCommon.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 + + /* 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 \c SIInterfaceInfo parameter. This + * stores each Still Image interface's configuration and state information. + */ + typedef struct + { + struct + { + USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */ + USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */ + USB_Pipe_Table_t EventsPipe; /**< Event notification IN Pipe configuration table. */ + } 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 Still Image interface within the attached device. */ + + 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. + */ + SI_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */ + }; + + /* 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. + * + * \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 from 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 Still Image 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 \c true if an event is waiting to be read, \c 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) ATTR_ALWAYS_INLINE; + 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_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + static uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MIDIClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MIDIClass.h new file mode 100644 index 000000000..e3b8e2f5e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MIDIClass.h @@ -0,0 +1,83 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB 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/MIDIClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/MIDIClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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 "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/MIDIClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/MIDIClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MassStorageClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MassStorageClass.h new file mode 100644 index 000000000..a5af1496b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/MassStorageClass.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB 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/MassStorageClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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 "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/MassStorageClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/MassStorageClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/PrinterClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/PrinterClass.h new file mode 100644 index 000000000..181d6931e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/PrinterClass.h @@ -0,0 +1,77 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB 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/PrinterClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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 "../Core/USBMode.h" + + #if defined(USB_CAN_BE_HOST) + #include "Host/PrinterClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/RNDISClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/RNDISClass.h new file mode 100644 index 000000000..e270629e2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/RNDISClass.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB 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/RNDISClassDevice.c (Makefile source module name: LUFA_SRC_USBCLASS) + * - LUFA/Drivers/USB/Class/Host/RNDISClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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 "../Core/USBMode.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "Device/RNDISClassDevice.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "Host/RNDISClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/StillImageClass.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/StillImageClass.h new file mode 100644 index 000000000..e8c28b441 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Class/StillImageClass.h @@ -0,0 +1,75 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB 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/StillImageClassHost.c (Makefile source module name: LUFA_SRC_USBCLASS) + * + * \section Sec_ModDescription 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 "../Core/USBMode.h" + + #if defined(USB_CAN_BE_HOST) + #include "Host/StillImageClassHost.h" + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c new file mode 100644 index 000000000..09d6f3775 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c @@ -0,0 +1,57 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Device.h" + +void USB_Device_SendRemoteWakeup(void) +{ + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + USB_CLK_Unfreeze(); + + UDCON |= (1 << RMWKUP); + while (UDCON & (1 << RMWKUP)); +} + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h new file mode 100644 index 000000000..318ff8720 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -0,0 +1,264 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Device definitions for the AVR8 microcontrollers. + * \copydetails Group_Device_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Device + * \defgroup Group_Device_AVR8 Device Management (AVR8) + * \brief USB Device definitions for the AVR8 microcontrollers. + * + * Architecture specific USB Device definitions for the Atmel 8-bit AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBDEVICE_AVR8_H__ +#define __USBDEVICE_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBController.h" + #include "../StdDescriptors.h" + #include "../USBInterrupt.h" + #include "../Endpoint.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)) + #error USE_FLASH_DESCRIPTORS and USE_RAM_DESCRIPTORS are mutually exclusive. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Device Mode Option Masks */ + //@{ + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) + /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the + * USB interface should be initialized in low speed (1.5Mb/s) mode. + * + * \note Low Speed mode is not available on all USB AVR models. + * \n + * + * \note Restrictions apply on the number, size and type of endpoints which can be used + * when running in low speed mode - please refer to the USB 2.0 specification. + */ + #define USB_DEVICE_OPT_LOWSPEED (1 << 0) + #endif + + /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the + * USB interface should be initialized in full speed (12Mb/s) mode. + */ + #define USB_DEVICE_OPT_FULLSPEED (0 << 0) + //@} + + #if (!defined(NO_INTERNAL_SERIAL) && \ + (defined(USB_SERIES_7_AVR) || defined(USB_SERIES_6_AVR) || \ + defined(USB_SERIES_4_AVR) || defined(USB_SERIES_2_AVR) || \ + defined(__DOXYGEN__))) + /** String descriptor index for the device's unique serial number string descriptor within the device. + * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port + * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain + * a unique serial number internally, and setting the device descriptors serial number string index to this value + * will cause it to use the internal serial number. + * + * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial + * number for the device. + */ + #define USE_INTERNAL_SERIAL 0xDC + + /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_LENGTH_BITS 80 + + /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_START_ADDRESS 0x0E + #else + #define USE_INTERNAL_SERIAL NO_DESCRIPTOR + + #define INTERNAL_SERIAL_LENGTH_BITS 0 + #define INTERNAL_SERIAL_START_ADDRESS 0 + #endif + + /* Function Prototypes: */ + /** Sends a Remote Wakeup request to the host. This signals to the host that the device should + * be taken out of suspended mode, and communications should resume. + * + * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the + * host computer when the host has suspended all USB devices to enter a low power state. + * + * \attention This function should only be used if the device has indicated to the host that it + * supports the Remote Wakeup feature in the device descriptors, and should only be + * issued if the host is currently allowing remote wakeup events from the device (i.e., + * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP + * compile time option is used, this function is unavailable. + * \n\n + * + * \attention The USB clock must be running for this function to operate. If the stack is initialized with + * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running + * before attempting to call this function. + * + * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors. + */ + void USB_Device_SendRemoteWakeup(void); + + /* Inline Functions: */ + /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint16_t USB_Device_GetFrameNumber(void) + { + return UDFNUM; + } + + #if !defined(NO_SOF_EVENTS) + /** Enables the device mode Start Of Frame events. When enabled, this causes the + * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, + * at the start of each USB frame when enumerated in device mode. + * + * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_EnableSOFEvents(void) + { + USB_INT_Enable(USB_INT_SOFI); + } + + /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the + * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode. + * + * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_DisableSOFEvents(void) + { + USB_INT_Disable(USB_INT_SOFI); + } + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Inline Functions: */ + #if defined(USB_DEVICE_OPT_LOWSPEED) + static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetLowSpeed(void) + { + UDCON |= (1 << LSM); + } + + static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetFullSpeed(void) + { + UDCON &= ~(1 << LSM); + } + #endif + + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) + { + uint8_t Temp = (UDADDR & (1 << ADDEN)) | (Address & 0x7F); + + UDADDR = Temp; + UDADDR = Temp | (1 << ADDEN); + } + + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_Device_IsAddressSet(void) + { + return (UDADDR & (1 << ADDEN)); + } + + #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1); + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) + { + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; + + for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) + { + uint8_t SerialByte = boot_signature_byte_get(SigReadAddress); + + if (SerialCharNum & 0x01) + { + SerialByte >>= 4; + SigReadAddress++; + } + + SerialByte &= 0x0F; + + UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte)); + } + + SetGlobalInterruptMask(CurrentGlobalInt); + } + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c new file mode 100644 index 000000000..7563ed35a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c @@ -0,0 +1,275 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "EndpointStream_AVR8.h" + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" +#endif + +#endif + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_Control_R.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_Control_R.c" +#endif + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h new file mode 100644 index 000000000..77c9c82fe --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.h @@ -0,0 +1,648 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endpoint data stream transmission and reception management for the AVR8 microcontrollers. + * \copydetails Group_EndpointStreamRW_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointStreamRW + * \defgroup Group_EndpointStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8) + * \brief Endpoint data stream transmission and reception management for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to endpoints. + * + * @{ + */ + +#ifndef __ENDPOINT_STREAM_AVR8_H__ +#define __ENDPOINT_STREAM_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the currently selected endpoint's bank, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of bytes to discard via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending + * full packets to the host as needed. The last packet is not automatically sent once the + * remaining bytes have been written; the user is responsible for manually sending the last + * packet to the host via the \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of zero bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the status OUT packet + * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the status OUT packet + * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for EEPROM source/destination data */ + //@{ + + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE(). + * + * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE(). + * + * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for PROGMEM source/destination data */ + //@{ + + /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c new file mode 100644 index 000000000..0002a256d --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c @@ -0,0 +1,201 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Endpoint.h" + +#if !defined(FIXED_CONTROL_ENDPOINT_SIZE) +uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; +#endif + +bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, + const uint8_t Entries) +{ + for (uint8_t i = 0; i < Entries; i++) + { + if (!(Table[i].Address)) + continue; + + if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks))) + return false; + } + + return true; +} + +bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, + const uint8_t UECFG0XData, + const uint8_t UECFG1XData) +{ +#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG) + Endpoint_SelectEndpoint(Number); + Endpoint_EnableEndpoint(); + + UECFG1X = 0; + UECFG0X = UECFG0XData; + UECFG1X = UECFG1XData; + + return Endpoint_IsConfigured(); +#else + for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + uint8_t UECFG0XTemp; + uint8_t UECFG1XTemp; + uint8_t UEIENXTemp; + + Endpoint_SelectEndpoint(EPNum); + + if (EPNum == Number) + { + UECFG0XTemp = UECFG0XData; + UECFG1XTemp = UECFG1XData; + UEIENXTemp = 0; + } + else + { + UECFG0XTemp = UECFG0X; + UECFG1XTemp = UECFG1X; + UEIENXTemp = UEIENX; + } + + if (!(UECFG1XTemp & (1 << ALLOC))) + continue; + + Endpoint_DisableEndpoint(); + UECFG1X &= ~(1 << ALLOC); + + Endpoint_EnableEndpoint(); + UECFG0X = UECFG0XTemp; + UECFG1X = UECFG1XTemp; + UEIENX = UEIENXTemp; + + if (!(Endpoint_IsConfigured())) + return false; + } + + Endpoint_SelectEndpoint(Number); + return true; +#endif +} + +void Endpoint_ClearEndpoints(void) +{ + UEINT = 0; + + for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + Endpoint_SelectEndpoint(EPNum); + UEIENX = 0; + UEINTX = 0; + UECFG1X = 0; + Endpoint_DisableEndpoint(); + } +} + +void Endpoint_ClearStatusStage(void) +{ + if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST) + { + while (!(Endpoint_IsOUTReceived())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + Endpoint_ClearOUT(); + } + else + { + while (!(Endpoint_IsINReady())) + { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + + Endpoint_ClearIN(); + } +} + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_WaitUntilReady(void) +{ + #if (USB_STREAM_TIMEOUT_MS < 0xFF) + uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #else + uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #endif + + uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber(); + + for (;;) + { + if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN) + { + if (Endpoint_IsINReady()) + return ENDPOINT_READYWAIT_NoError; + } + else + { + if (Endpoint_IsOUTReceived()) + return ENDPOINT_READYWAIT_NoError; + } + + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_READYWAIT_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_READYWAIT_BusSuspended; + else if (Endpoint_IsStalled()) + return ENDPOINT_READYWAIT_EndpointStalled; + + uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return ENDPOINT_READYWAIT_Timeout; + } + } +} +#endif + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h new file mode 100644 index 000000000..08944babc --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h @@ -0,0 +1,819 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Endpoint definitions for the AVR8 microcontrollers. + * \copydetails Group_EndpointManagement_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointRW_AVR8 Endpoint Data Reading and Writing (AVR8) + * \brief Endpoint data read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. + */ + +/** \ingroup Group_EndpointPrimitiveRW + * \defgroup Group_EndpointPrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8) + * \brief Endpoint primitive read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to endpoints. + */ + +/** \ingroup Group_EndpointPacketManagement + * \defgroup Group_EndpointPacketManagement_AVR8 Endpoint Packet Management (AVR8) + * \brief Endpoint packet management definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointManagement_AVR8 Endpoint Management (AVR8) + * \brief Endpoint management definitions for the Atmel AVR8 architecture. + * + * Functions, macros and enums related to endpoint management when in USB Device mode. This + * module contains the endpoint management macros, as well as endpoint interrupt and data + * send/receive functions for various data types. + * + * @{ + */ + +#ifndef __ENDPOINT_AVR8_H__ +#define __ENDPOINT_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* 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: */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size + * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined. + */ + #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 + #endif + + #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__) + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + #define ENDPOINT_TOTAL_ENDPOINTS 7 + #else + /** 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 5 + #endif + #else + #define ENDPOINT_TOTAL_ENDPOINTS 1 + #endif + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function. + * + * \ingroup Group_EndpointRW_AVR8 + */ + enum Endpoint_WaitUntilReady_ErrorCodes_t + { + ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */ + ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream + * transfer by the host or device. + */ + ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while + * waiting for the endpoint to become ready. + */ + ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + }; + + /* Inline Functions: */ + /** Configures the specified endpoint address with the given endpoint type, bank size and number of hardware + * banks. Once configured, the endpoint may be read from or written to, depending on its direction. + * + * \param[in] Address Endpoint address to configure. + * + * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types + * are available on Low Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] 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. + * + * \attention When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints must be configured in + * ascending order, or bank corruption will occur. + * + * \note Different endpoints may have different maximum packet sizes based on the endpoint's index - please + * refer to the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint. + * \n\n + * + * \note The default control endpoint should not be manually configured by the user application, as + * it is automatically configured by the library internally. + * \n\n + * + * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint + * which failed to reconfigure correctly will be selected. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, + const uint8_t Type, + const uint16_t Size, + const uint8_t Banks) ATTR_ALWAYS_INLINE; + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, + const uint8_t Type, + const uint16_t Size, + const uint8_t Banks) + { + uint8_t Number = (Address & ENDPOINT_EPNUM_MASK); + + if (Number >= ENDPOINT_TOTAL_ENDPOINTS) + return false; + + return Endpoint_ConfigureEndpoint_Prv(Number, + ((Type << EPTYPE0) | ((Address & ENDPOINT_DIR_IN) ? (1 << EPDIR) : 0)), + ((1 << ALLOC) | ((Banks > 1) ? (1 << EPBK0) : 0) | Endpoint_BytesToEPSizeMask(Size))); + } + + /** Indicates the number of bytes currently stored in the current endpoint's selected bank. + * + * \ingroup Group_EndpointRW_AVR8 + * + * \return Total number of bytes in the currently selected Endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_BytesInEndpoint(void) + { + #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) && !defined(__AVR_ATmega32U6__) + return UEBCX; + #elif defined(USB_SERIES_4_AVR) || defined(__AVR_ATmega32U6__) + return (((uint16_t)UEBCHX << 8) | UEBCLX); + #elif defined(USB_SERIES_2_AVR) + return UEBCLX; + #endif + } + + /** Determines the currently selected endpoint's direction. + * + * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_GetEndpointDirection(void) + { + return (UECFG0X & (1 << EPDIR)) ? ENDPOINT_DIR_IN : ENDPOINT_DIR_OUT; + } + + /** Get the endpoint address of the currently selected endpoint. This is typically used to save + * the currently selected endpoint 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) | Endpoint_GetEndpointDirection()); + #else + return ENDPOINT_CONTROLEP; + #endif + } + + /** Selects the given endpoint address. + * + * Any endpoint operations which do not require the endpoint address to be indicated will operate on + * the currently selected endpoint. + * + * \param[in] Address Endpoint address to select. + */ + static inline void Endpoint_SelectEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Endpoint_SelectEndpoint(const uint8_t Address) + { + #if !defined(CONTROL_ONLY_DEVICE) + UENUM = (Address & ENDPOINT_EPNUM_MASK); + #endif + } + + /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's + * data In and Out pointers to the bank's contents. + * + * \param[in] Address Endpoint address whose FIFO buffers are to be reset. + */ + static inline void Endpoint_ResetEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetEndpoint(const uint8_t Address) + { + UERST = (1 << (Address & ENDPOINT_EPNUM_MASK)); + UERST = 0; + } + + /** Enables the currently selected endpoint so that data can be sent and received through it to + * and from a host. + * + * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint(). + */ + static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_EnableEndpoint(void) + { + UECONX |= (1 << EPEN); + } + + /** Disables the currently selected endpoint so that data cannot be sent and received through it + * to and from a host. + */ + static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_DisableEndpoint(void) + { + UECONX &= ~(1 << EPEN); + } + + /** Determines if the currently selected endpoint is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise. + */ + static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsEnabled(void) + { + return ((UECONX & (1 << EPEN)) ? true : false); + } + + /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for + * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the + * \ref Endpoint_ClearOUT() command. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Total number of busy banks in the selected endpoint. + */ + static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Endpoint_GetBusyBanks(void) + { + return (UESTA0X & (0x03 << NBUSYBK0)); + } + + /** Aborts all pending IN transactions on the currently selected endpoint, once the bank + * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function + * will terminate all queued transactions, resetting the endpoint banks ready for a new + * packet. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_AbortPendingIN(void) + { + while (Endpoint_GetBusyBanks() != 0) + { + UEINTX |= (1 << RXOUTI); + while (UEINTX & (1 << RXOUTI)); + } + } + + /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint + * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN + * direction). This function will return false if an error has occurred in the endpoint, if the endpoint + * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN + * direction and the endpoint bank is full. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending + * on its direction. + */ + static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsReadWriteAllowed(void) + { + return ((UEINTX & (1 << RWAL)) ? true : false); + } + + /** Determines if the currently selected endpoint is configured. + * + * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise. + */ + static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsConfigured(void) + { + return ((UESTA0X & (1 << CFGOK)) ? true : false); + } + + /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their + * interrupt duration has elapsed. Which endpoints have interrupted can be determined by + * masking the return value against (1 << {Endpoint Number}). + * + * \return Mask whose bits indicate which endpoints have interrupted. + */ + static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_GetEndpointInterrupts(void) + { + return UEINT; + } + + /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type + * endpoints). + * + * \param[in] Address Address of the endpoint whose interrupt flag should be tested. + * + * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise. + */ + static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address) + { + return ((Endpoint_GetEndpointInterrupts() & (1 << (Address & ENDPOINT_EPNUM_MASK))) ? true : false); + } + + /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise. + */ + static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsINReady(void) + { + return ((UEINTX & (1 << TXINI)) ? true : false); + } + + /** Determines if the selected OUT endpoint has received new packet from the host. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise. + */ + static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsOUTReceived(void) + { + return ((UEINTX & (1 << RXOUTI)) ? true : false); + } + + /** Determines if the current CONTROL type endpoint has received a SETUP packet. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise. + */ + static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsSETUPReceived(void) + { + return ((UEINTX & (1 << RXSTPI)) ? true : false); + } + + /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the + * endpoint for the next packet. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \note This is not applicable for non CONTROL type endpoints. + */ + static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearSETUP(void) + { + UEINTX &= ~(1 << RXSTPI); + } + + /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the + * next packet and switching to the alternative endpoint bank if double banked. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearIN(void) + { + #if !defined(CONTROL_ONLY_DEVICE) + UEINTX &= ~((1 << TXINI) | (1 << FIFOCON)); + #else + UEINTX &= ~(1 << TXINI); + #endif + } + + /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint + * for the next packet and switching to the alternative endpoint bank if double banked. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearOUT(void) + { + #if !defined(CONTROL_ONLY_DEVICE) + UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON)); + #else + UEINTX &= ~(1 << RXOUTI); + #endif + } + + /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the + * indicated endpoint and that the current transfer sequence should be aborted. This provides a + * way for devices to indicate invalid commands to the host so that the current transfer can be + * aborted and the host can begin its own recovery sequence. + * + * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro + * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected + * endpoint. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_StallTransaction(void) + { + UECONX |= (1 << STALLRQ); + } + + /** Clears the STALL condition on the currently selected endpoint. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + */ + static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearStall(void) + { + UECONX |= (1 << STALLRQC); + } + + /** Determines if the currently selected endpoint is stalled, false otherwise. + * + * \ingroup Group_EndpointPacketManagement_AVR8 + * + * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. + */ + static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsStalled(void) + { + return ((UECONX & (1 << STALLRQ)) ? true : false); + } + + /** Resets the data toggle of the currently selected endpoint. */ + static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetDataToggle(void) + { + UECONX |= (1 << RSTDT); + } + + /** Sets the direction of the currently selected endpoint. + * + * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) ATTR_ALWAYS_INLINE; + static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) + { + UECFG0X = ((UECFG0X & ~(1 << EPDIR)) | (DirectionMask ? (1 << EPDIR) : 0)); + } + + /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next byte in the currently selected endpoint's FIFO buffer. + */ + static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_Read_8(void) + { + return UEDATX; + } + + /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_8(const uint8_t Data) + { + UEDATX = Data; + } + + /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + */ + static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_8(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + + (void)Dummy; + } + + /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_LE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; + + return Data.Value; + } + + /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_BE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; + + return Data.Value; + } + + /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_LE(const uint16_t Data) + { + UEDATX = (Data & 0xFF); + UEDATX = (Data >> 8); + } + + /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_BE(const uint16_t Data) + { + UEDATX = (Data >> 8); + UEDATX = (Data & 0xFF); + } + + /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + */ + static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_16(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + Dummy = UEDATX; + + (void)Dummy; + } + + /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_LE(void) + { + union + { + uint32_t Value; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[0] = UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[2] = UEDATX; + Data.Bytes[3] = UEDATX; + + return Data.Value; + } + + /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_BE(void) + { + union + { + uint32_t Value; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[3] = UEDATX; + Data.Bytes[2] = UEDATX; + Data.Bytes[1] = UEDATX; + Data.Bytes[0] = UEDATX; + + return Data.Value; + } + + /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_LE(const uint32_t Data) + { + UEDATX = (Data & 0xFF); + UEDATX = (Data >> 8); + UEDATX = (Data >> 16); + UEDATX = (Data >> 24); + } + + /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_BE(const uint32_t Data) + { + UEDATX = (Data >> 24); + UEDATX = (Data >> 16); + UEDATX = (Data >> 8); + UEDATX = (Data & 0xFF); + } + + /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_AVR8 + */ + static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_32(void) + { + uint8_t Dummy; + + Dummy = UEDATX; + Dummy = UEDATX; + Dummy = UEDATX; + Dummy = UEDATX; + + (void)Dummy; + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control endpoint located at address + * 0 in the device. This value is set to the value indicated in the device descriptor in the user + * project once the USB interface is initialized into device mode. + * + * If space is an issue, it is possible to fix this to a static value by defining the control + * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile + * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically + * read from the descriptors at runtime and instead fixed to the given value. When used, it is + * important that the descriptor control endpoint size value matches the size given as the + * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token + * be used in the device descriptors to ensure this. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + extern uint8_t USB_Device_ControlEndpointSize; + #else + #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE + #endif + + /* Function Prototypes: */ + /** Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple + * endpoints at the same time. + * + * \note Endpoints with a zero address will be ignored, thus this function cannot be used to configure the + * control endpoint. + * + * \param[in] Table Pointer to a table of endpoint descriptions. + * \param[in] Entries Number of entries in the endpoint table to configure. + * + * \return Boolean \c true if all endpoints configured successfully, \c false otherwise. + */ + bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, + const uint8_t Entries); + + /** 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. + * + * \note This routine should not be called on non CONTROL type endpoints. + */ + void Endpoint_ClearStatusStage(void); + + /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data + * to be read or written to it. + * + * \note This routine should not be called on CONTROL type endpoints. + * + * \ingroup Group_EndpointRW_AVR8 + * + * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t Endpoint_WaitUntilReady(void); + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c new file mode 100644 index 000000000..d93268337 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -0,0 +1,294 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HOST_C +#include "../Host.h" + +void USB_Host_ProcessNextHostState(void) +{ + uint8_t ErrorCode = HOST_ENUMERROR_NoError; + uint8_t SubErrorCode = HOST_ENUMERROR_NoError; + + static uint16_t WaitMSRemaining; + static uint8_t PostWaitState; + + switch (USB_HostState) + { + case HOST_STATE_WaitForDevice: + if (WaitMSRemaining) + { + if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + { + USB_HostState = PostWaitState; + ErrorCode = HOST_ENUMERROR_WaitStage; + break; + } + + if (!(--WaitMSRemaining)) + USB_HostState = PostWaitState; + } + + break; + case HOST_STATE_Powered: + WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS; + + USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle; + break; + case HOST_STATE_Powered_WaitForDeviceSettle: + if (WaitMSRemaining--) + { + Delay_MS(1); + break; + } + else + { + USB_Host_VBUS_Manual_Off(); + + USB_OTGPAD_On(); + USB_Host_VBUS_Auto_Enable(); + USB_Host_VBUS_Auto_On(); + + #if defined(NO_AUTO_VBUS_MANAGEMENT) + USB_Host_VBUS_Manual_Enable(); + USB_Host_VBUS_Manual_On(); + #endif + + USB_HostState = HOST_STATE_Powered_WaitForConnect; + } + + break; + case HOST_STATE_Powered_WaitForConnect: + if (USB_INT_HasOccurred(USB_INT_DCONNI)) + { + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Clear(USB_INT_DDISCI); + + USB_INT_Clear(USB_INT_VBERRI); + USB_INT_Enable(USB_INT_VBERRI); + + USB_Host_ResumeBus(); + Pipe_ClearPipes(); + + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset); + } + + break; + case HOST_STATE_Powered_DoReset: + USB_Host_ResetDevice(); + + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe); + break; + case HOST_STATE_Powered_ConfigPipe: + if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, PIPE_CONTROLPIPE_DEFAULT_SIZE, 1))) + { + 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]; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful) + { + ErrorCode = HOST_ENUMERROR_ControlError; + break; + } + + USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; + + USB_Host_ResetDevice(); + + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset); + break; + case HOST_STATE_Default_PostReset: + if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, USB_Host_ControlPipeSize, 1))) + { + ErrorCode = HOST_ENUMERROR_PipeConfigError; + SubErrorCode = 0; + break; + } + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_SetAddress, + .wValue = USB_HOST_DEVICEADDRESS, + .wIndex = 0, + .wLength = 0, + }; + + if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + { + ErrorCode = HOST_ENUMERROR_ControlError; + break; + } + + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet); + break; + case HOST_STATE_Default_PostAddressSet: + USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS); + + USB_HostState = HOST_STATE_Addressed; + + EVENT_USB_Host_DeviceEnumerationComplete(); + break; + } + + if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached)) + { + EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode); + + USB_Host_VBUS_Auto_Off(); + + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } +} + +uint8_t USB_Host_WaitMS(uint8_t MS) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + uint8_t ErrorCode = HOST_WAITERROR_Successful; + bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); + + USB_INT_Disable(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_HSOFI); + + USB_Host_ResumeBus(); + + while (MS) + { + if (USB_INT_HasOccurred(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + MS--; + } + + if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host)) + { + ErrorCode = HOST_WAITERROR_DeviceDisconnect; + + break; + } + + if (Pipe_IsError()) + { + Pipe_ClearError(); + ErrorCode = HOST_WAITERROR_PipeError; + + break; + } + + if (Pipe_IsStalled()) + { + Pipe_ClearStall(); + ErrorCode = HOST_WAITERROR_SetupStalled; + + break; + } + } + + if (BusSuspended) + USB_Host_SuspendBus(); + + if (HSOFIEnabled) + USB_INT_Enable(USB_INT_HSOFI); + + return ErrorCode; +} + +static void USB_Host_ResetDevice(void) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + + USB_INT_Disable(USB_INT_DDISCI); + + USB_Host_ResetBus(); + while (!(USB_Host_IsBusResetComplete())); + USB_Host_ResumeBus(); + + USB_Host_ConfigurationNumber = 0; + + bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); + + USB_INT_Disable(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_HSOFI); + + for (uint8_t MSRem = 10; MSRem != 0; MSRem--) + { + /* Workaround for powerless-pull-up devices. After a USB bus reset, + all disconnection interrupts are suppressed while a USB frame is + looked for - if it is found within 10ms, the device is still + present. */ + + if (USB_INT_HasOccurred(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_DDISCI); + break; + } + + Delay_MS(1); + } + + if (HSOFIEnabled) + USB_INT_Enable(USB_INT_HSOFI); + + if (BusSuspended) + USB_Host_SuspendBus(); + + USB_INT_Enable(USB_INT_DDISCI); +} + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h new file mode 100644 index 000000000..f8d92f81f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h @@ -0,0 +1,372 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Host definitions for the AVR8 microcontrollers. + * \copydetails Group_Host_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Host + * \defgroup Group_Host_AVR8 Host Management (AVR8) + * \brief USB Host definitions for the AVR8 microcontrollers. + * + * Architecture specific USB Host definitions for the Atmel 8-bit AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBHOST_AVR8_H__ +#define __USBHOST_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../StdDescriptors.h" + #include "../Pipe.h" + #include "../USBInterrupt.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if defined(INVERTED_VBUS_ENABLE_LINE) && !defined(NO_AUTO_VBUS_MANAGEMENT) + #error The INVERTED_VBUS_ENABLE_LINE compile option requires NO_AUTO_VBUS_MANAGEMENT for the AVR8 architecture. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates the fixed USB device address which any attached device is enumerated to when in + * host mode. As only one USB device may be attached to the AVR in host mode at any one time + * and that the address used is not important (other than the fact that it is non-zero), a + * fixed value is specified by the library. + */ + #define USB_HOST_DEVICEADDRESS 1 + + #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__) + /** Constant for the delay in milliseconds after a device is connected before the library + * will start the enumeration process. Some devices require a delay of up to 5 seconds + * after connection before the enumeration process can start or incorrect operation will + * occur. + * + * The default delay value may be overridden in the user project makefile by defining the + * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the + * compiler using the -D switch. + */ + #define HOST_DEVICE_SETTLE_DELAY_MS 1000 + #endif + + /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event. + * + * \see \ref Group_Events for more information on this event. + */ + enum USB_Host_ErrorCodes_t + { + HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This + * error may be the result of an attached device drawing + * too much current from the VBUS line, or due to the + * AVR's power source being unable to supply sufficient + * current. + */ + }; + + /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event. + * + * \see \ref Group_Events for more information on this event. + */ + enum USB_Host_EnumerationErrorCodes_t + { + HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid + * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed() + * event. + */ + HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed + * to complete successfully, due to a timeout or other + * error. + */ + HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines + * indicating the attachment of a device. + */ + HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to + * complete successfully. + */ + HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to + * configure correctly. + */ + }; + + /* Inline Functions: */ + /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t USB_Host_GetFrameNumber(void) + { + return UHFNUM; + } + + #if !defined(NO_SOF_EVENTS) + /** Enables the host mode Start Of Frame events. When enabled, this causes the + * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, + * at the start of each USB frame when a device is enumerated while in host mode. + * + * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_EnableSOFEvents(void) + { + USB_INT_Enable(USB_INT_HSOFI); + } + + /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the + * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode. + * + * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_DisableSOFEvents(void) + { + USB_INT_Disable(USB_INT_HSOFI); + } + #endif + + /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host. + * USB bus resets leave the default control pipe configured (if already configured). + * + * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be + * woken up automatically and the bus resumed after the reset has been correctly issued. + */ + static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ResetBus(void) + { + UHCON |= (1 << RESET); + } + + /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has + * completed. + * + * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise. + */ + static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsBusResetComplete(void) + { + return ((UHCON & (1 << RESET)) ? false : true); + } + + /** Resumes USB communications with an attached and enumerated device, by resuming the transmission + * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the + * host and attached device may occur. + */ + static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ResumeBus(void) + { + UHCON |= (1 << SOFEN); + } + + /** Suspends the USB bus, preventing any communications from occurring between the host and attached + * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame + * messages to the device. + * + * \attention While the USB bus is suspended, all USB interrupt sources are also disabled; this means that + * some events (such as device disconnections) will not fire until the bus is resumed. + */ + static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_SuspendBus(void) + { + UHCON &= ~(1 << SOFEN); + } + + /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro, + * false otherwise. While suspended, no USB communications can occur until the bus is resumed, + * except for the Remote Wakeup event from the device if supported. + * + * \return Boolean \c true if the bus is currently suspended, \c false otherwise. + */ + static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsBusSuspended(void) + { + return ((UHCON & (1 << SOFEN)) ? false : true); + } + + /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or + * false if the attached device is enumerated in Low Speed mode (1.5Mb/s). + * + * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise. + */ + static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsDeviceFullSpeed(void) + { + return ((USBSTA & (1 << SPEED)) ? true : false); + } + + /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting + * that the host resume the USB bus and wake up the device, false otherwise. + * + * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise. + */ + static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsRemoteWakeupSent(void) + { + return ((UHINT & (1 << RXRSMI)) ? true : false); + } + + /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */ + static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ClearRemoteWakeupSent(void) + { + UHINT &= ~(1 << RXRSMI); + } + + /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to + * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to + * be resumed. + */ + static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_ResumeFromWakeupRequest(void) + { + UHCON |= (1 << RESUME); + } + + /** Determines if a resume from Remote Wakeup request is currently being sent to an attached + * device. + * + * \return Boolean \c true if no resume request is currently being sent, \c false otherwise. + */ + static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) + { + return ((UHCON & (1 << RESUME)) ? false : true); + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_HostMode_On(void) + { + USBCON |= (1 << HOST); + } + + static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_HostMode_Off(void) + { + USBCON &= ~(1 << HOST); + } + + static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_Enable(void) + { + OTGCON &= ~(1 << VBUSHWC); + UHWCON |= (1 << UVCONE); + } + + static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_Enable(void) + { + OTGCON |= (1 << VBUSHWC); + UHWCON &= ~(1 << UVCONE); + + DDRE |= (1 << 7); + } + + static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_On(void) + { + OTGCON |= (1 << VBUSREQ); + } + + static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_On(void) + { + #if defined(INVERTED_VBUS_ENABLE_LINE) + PORTE &= ~(1 << 7); + #else + PORTE |= (1 << 7); + #endif + } + + static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_Off(void) + { + OTGCON |= (1 << VBUSRQC); + } + + static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_Off(void) + { + #if defined(INVERTED_VBUS_ENABLE_LINE) + PORTE |= (1 << 7); + #else + PORTE &= ~(1 << 7); + #endif + } + + static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Host_SetDeviceAddress(const uint8_t Address) + { + UHADDR = (Address & 0x7F); + } + + /* Enums: */ + enum USB_Host_WaitMSErrorCodes_t + { + HOST_WAITERROR_Successful = 0, + HOST_WAITERROR_DeviceDisconnect = 1, + HOST_WAITERROR_PipeError = 2, + HOST_WAITERROR_SetupStalled = 3, + }; + + /* Function Prototypes: */ + void USB_Host_ProcessNextHostState(void); + uint8_t USB_Host_WaitMS(uint8_t MS); + + #if defined(__INCLUDE_FROM_HOST_C) + static void USB_Host_ResetDevice(void); + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h new file mode 100644 index 000000000..5296beb6a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h @@ -0,0 +1,159 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB OTG definitions for the AVR8 microcontrollers. + * \copydetails Group_OTG_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_OTG + * \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8) + * \brief USB OTG definitions for the AVR8 microcontrollers. + * + * Architecture specific USB OTG definitions for the Atmel 8-bit AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBOTG_AVR8_H__ +#define __USBOTG_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices. + * + * \see \ref USB_OTG_Device_InitiateSRP(). + */ + #define USB_OTG_SRP_VBUS (1 << SRPSEL) + + /** Mask for the Data + pulsing method of SRP, supported by some OTG devices. + * + * \see \ref USB_OTG_Device_InitiateSRP(). + */ + #define USB_OTG_STP_DATA 0 + + /* Inline Functions: */ + /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device + * that the device wishes to change device/host roles. + */ + static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Device_RequestHNP(void) + { + OTGCON |= (1 << HNPREQ); + } + + /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other + * connected device. + */ + static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Device_CancelHNPRequest(void) + { + OTGCON &= ~(1 << HNPREQ); + } + + /** Determines if the device is currently sending a HNP to an attached host. + * + * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise + */ + static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_OTG_Device_IsSendingHNP(void) + { + return ((OTGCON & (1 << HNPREQ)) ? true : false); + } + + /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB + * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in + * host mode indicates that VBUS should be applied and a session started. + * + * There are two different methods of sending a SRP - either pulses on the VBUS line, or by + * pulsing the Data + line via the internal pull-up resistor. + * + * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or + * \ref USB_OTG_STP_DATA. + */ + static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) + { + OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ))); + } + + /** Accepts a HNP from a connected device, indicating that both devices should exchange + * device/host roles. + */ + static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Host_AcceptHNP(void) + { + OTGCON |= (1 << HNPREQ); + } + + /** Rejects a HNP from a connected device, indicating that both devices should remain in their + * current device/host roles. + */ + static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTG_Host_RejectHNP(void) + { + OTGCON &= ~(1 << HNPREQ); + } + + /** Indicates if the connected device is currently sending a HNP request. + * + * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise. + */ + static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_OTG_Host_IsHNPReceived(void) + { + return ((OTGCON & (1 << HNPREQ)) ? true : false); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c new file mode 100644 index 000000000..e71a7bd32 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c @@ -0,0 +1,221 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "PipeStream_AVR8.h" + +uint8_t Pipe_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + Pipe_SetPipeToken(PIPE_TOKEN_IN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +uint8_t Pipe_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + Pipe_SetPipeToken(PIPE_TOKEN_OUT); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + USB_USBTask(); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr)) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8()) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8()) +#include "Template/Template_Pipe_RW.c" + +#endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h new file mode 100644 index 000000000..8307ab497 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.h @@ -0,0 +1,442 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Pipe data stream transmission and reception management for the AVR8 microcontrollers + * \copydetails Group_PipeStreamRW_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeStreamRW + * \defgroup Group_PipeStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8) + * \brief Pipe data stream transmission and reception management for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to pipes. + * + * @{ + */ + +#ifndef __PIPE_STREAM_AVR8_H__ +#define __PIPE_STREAM_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host + * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the + * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or + * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer + * will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data + * to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with + * the total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to + * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed + * value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Length Number of bytes to discard via the currently selected pipe. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be processed at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device + * as needed. The last packet is not automatically sent once the remaining bytes has been written; the + * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or + * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer + * will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data + * to process (and after the current packet transmission has been initiated) the BytesProcessed location will be + * updated with the total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to + * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed + * value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Length Number of zero bytes to write via the currently selected pipe. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be processed at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the pipe from the given buffer in little endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the pipe bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the pipe from the given buffer in big endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the pipe into the given buffer in little endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the pipe bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the pipe into the given buffer in big endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for EEPROM source/destination data */ + //@{ + + /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_EStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_EStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_EStream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_EStream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for PROGMEM source/destination data */ + //@{ + + /** FLASH buffer source version of \ref Pipe_Write_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_PStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Pipe_Write_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_PStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c new file mode 100644 index 000000000..bf3ff003c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c @@ -0,0 +1,210 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "../Pipe.h" + +uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + +bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table, + const uint8_t Entries) +{ + for (uint8_t i = 0; i < Entries; i++) + { + if (!(Table[i].Address)) + continue; + + if (!(Pipe_ConfigurePipe(Table[i].Address, Table[i].Type, Table[i].EndpointAddress, Table[i].Size, Table[i].Banks))) + { + return false; + } + } + + return true; +} + +bool Pipe_ConfigurePipe(const uint8_t Address, + const uint8_t Type, + const uint8_t EndpointAddress, + const uint16_t Size, + const uint8_t Banks) +{ + uint8_t Number = (Address & PIPE_EPNUM_MASK); + uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT; + + if (Number >= PIPE_TOTAL_PIPES) + return false; + + if (Type == EP_TYPE_CONTROL) + Token = PIPE_TOKEN_SETUP; + +#if defined(ORDERED_EP_CONFIG) + Pipe_SelectPipe(Number); + Pipe_EnablePipe(); + + UPCFG1X = 0; + + UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointAddress & PIPE_EPNUM_MASK) << PEPNUM0)); + UPCFG1X = ((1 << ALLOC) | ((Banks > 1) ? (1 << EPBK0) : 0) | Pipe_BytesToEPSizeMask(Size)); + + Pipe_SetInfiniteINRequests(); + + return Pipe_IsConfigured(); +#else + for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++) + { + uint8_t UPCFG0XTemp; + uint8_t UPCFG1XTemp; + uint8_t UPCFG2XTemp; + uint8_t UPIENXTemp; + + Pipe_SelectPipe(PNum); + + if (PNum == Number) + { + UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointAddress & PIPE_EPNUM_MASK) << PEPNUM0)); + UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size)); + UPCFG2XTemp = 0; + UPIENXTemp = 0; + } + else + { + UPCFG0XTemp = UPCFG0X; + UPCFG1XTemp = UPCFG1X; + UPCFG2XTemp = UPCFG2X; + UPIENXTemp = UPIENX; + } + + if (!(UPCFG1XTemp & (1 << ALLOC))) + continue; + + Pipe_DisablePipe(); + UPCFG1X &= ~(1 << ALLOC); + + Pipe_EnablePipe(); + UPCFG0X = UPCFG0XTemp; + UPCFG1X = UPCFG1XTemp; + UPCFG2X = UPCFG2XTemp; + UPIENX = UPIENXTemp; + + Pipe_SetInfiniteINRequests(); + + if (!(Pipe_IsConfigured())) + return false; + } + + Pipe_SelectPipe(Number); + return true; +#endif +} + +void Pipe_ClearPipes(void) +{ + UPINT = 0; + + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + UPIENX = 0; + UPINTX = 0; + UPCFG1X = 0; + Pipe_DisablePipe(); + } +} + +bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) +{ + uint8_t PrevPipeNumber = Pipe_GetCurrentPipe(); + + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + + if (!(Pipe_IsConfigured())) + continue; + + if (Pipe_GetBoundEndpointAddress() == EndpointAddress) + return true; + } + + Pipe_SelectPipe(PrevPipeNumber); + return false; +} + +uint8_t Pipe_WaitUntilReady(void) +{ + #if (USB_STREAM_TIMEOUT_MS < 0xFF) + uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #else + uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #endif + + uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber(); + + for (;;) + { + if (Pipe_GetPipeToken() == PIPE_TOKEN_IN) + { + if (Pipe_IsINReceived()) + return PIPE_READYWAIT_NoError; + } + else + { + if (Pipe_IsOUTReady()) + return PIPE_READYWAIT_NoError; + } + + if (Pipe_IsStalled()) + return PIPE_READYWAIT_PipeStalled; + else if (USB_HostState == HOST_STATE_Unattached) + return PIPE_READYWAIT_DeviceDisconnected; + + uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return PIPE_READYWAIT_Timeout; + } + } +} + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h new file mode 100644 index 000000000..24c7b36cb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h @@ -0,0 +1,921 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Pipe definitions for the AVR8 microcontrollers. + * \copydetails Group_PipeManagement_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipeRW_AVR8 Pipe Data Reading and Writing (AVR8) + * \brief Pipe data read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. + */ + +/** \ingroup Group_PipePrimitiveRW + * \defgroup Group_PipePrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8) + * \brief Pipe primitive data read/write definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to pipes. + */ + +/** \ingroup Group_PipePacketManagement + * \defgroup Group_PipePacketManagement_AVR8 Pipe Packet Management (AVR8) + * \brief Pipe packet management definitions for the Atmel AVR8 architecture. + * + * Functions, macros, variables, enums and types related to packet management of pipes. + */ + +/** \ingroup Group_PipeControlReq + * \defgroup Group_PipeControlReq_AVR8 Pipe Control Request Management (AVR8) + * \brief Pipe control request management definitions for the Atmel AVR8 architecture. + * + * Module for host mode request processing. This module allows for the transmission of standard, class and + * vendor control requests to the default control endpoint of an attached device while in host mode. + * + * \see Chapter 9 of the USB 2.0 specification. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeManagement_AVR8 Pipe Management (AVR8) + * \brief Pipe management definitions for the Atmel AVR8 architecture. + * + * This module contains functions, macros and enums related to pipe management when in USB Host mode. This + * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions + * for various data types. + * + * @{ + */ + +#ifndef __PIPE_AVR8_H__ +#define __PIPE_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name Pipe Error Flag Masks */ + //@{ + /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_OVERFLOW (1 << 6) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_CRC16 (1 << 4) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */ + #define PIPE_ERRORFLAG_TIMEOUT (1 << 3) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */ + #define PIPE_ERRORFLAG_PID (1 << 2) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */ + #define PIPE_ERRORFLAG_DATAPID (1 << 1) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */ + #define PIPE_ERRORFLAG_DATATGL (1 << 0) + //@} + + /** \name Pipe Token Masks */ + //@{ + /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). 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_SetPipeToken() and \ref Pipe_GetPipeToken(). 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_SetPipeToken() and \ref Pipe_GetPipeToken(). 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) + //@} + + /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value + * in the device descriptor of the attached device. + */ + #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64 + + /** Total number of pipes (including the default control pipe at address 0) which may be used in + * the device. Different USB AVR models support different amounts of pipes, this value reflects + * the maximum number of pipes for the currently selected AVR model. + */ + #define PIPE_TOTAL_PIPES 7 + + /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR + * model supports the largest bank size possible on the device; different pipe numbers support + * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the + * currently selected USB AVR model. + */ + #define PIPE_MAX_SIZE 256 + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function. + * + * \ingroup Group_PipeRW_AVR8 + */ + enum Pipe_WaitUntilReady_ErrorCodes_t + { + PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */ + PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */ + PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */ + PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + }; + + /* Inline Functions: */ + /** Indicates the number of bytes currently stored in the current pipes's selected bank. + * + * \ingroup Group_PipeRW_AVR8 + * + * \return Total number of bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_BytesInPipe(void) + { + return UPBCX; + } + + /** Determines the currently selected pipe's direction. + * + * \return The currently selected pipe's direction, as a \c PIPE_DIR_* mask. + */ + static inline uint8_t Pipe_GetPipeDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeDirection(void) + { + return (UPCFG0X & (1 << EPDIR)) ? PIPE_DIR_IN : PIPE_DIR_OUT; + } + + /** Returns the pipe address of the currently selected pipe. This is typically used to save the + * currently selected pipe address 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) | Pipe_GetPipeDirection()); + } + + /** Selects the given pipe address. Any pipe operations which do not require the pipe address to be + * indicated will operate on the currently selected pipe. + * + * \param[in] Address Address of the pipe to select. + */ + static inline void Pipe_SelectPipe(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Pipe_SelectPipe(const uint8_t Address) + { + UPNUM = (Address & PIPE_PIPENUM_MASK); + } + + /** Resets the desired pipe, including the pipe banks and flags. + * + * \param[in] Address Address of the pipe to reset. + */ + static inline void Pipe_ResetPipe(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Pipe_ResetPipe(const uint8_t Address) + { + UPRST = (1 << (Address & PIPE_PIPENUM_MASK)); + UPRST = 0; + } + + /** Enables the currently selected pipe so that data can be sent and received through it to and from + * an attached device. + * + * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe(). + */ + static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_EnablePipe(void) + { + UPCONX |= (1 << PEN); + } + + /** Disables the currently selected pipe so that data cannot be sent and received through it to and + * from an attached device. + */ + static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_DisablePipe(void) + { + UPCONX &= ~(1 << PEN); + } + + /** Determines if the currently selected pipe is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise. + */ + static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsEnabled(void) + { + return ((UPCONX & (1 << PEN)) ? true : false); + } + + /** Gets the current pipe token, indicating the pipe's data direction and type. + * + * \return The current pipe token, as a \c PIPE_TOKEN_* mask. + */ + static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeToken(void) + { + return (UPCFG0X & (0x03 << PTOKEN0)); + } + + /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_* + * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during + * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices + * which have two endpoints of opposite direction sharing the same endpoint address within the device. + * + * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask. + */ + static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetPipeToken(const uint8_t Token) + { + UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token); + } + + /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */ + static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetInfiniteINRequests(void) + { + UPCONX |= (1 << INMODE); + } + + /** Configures the currently selected pipe to only allow the specified number of IN requests to be + * accepted by the pipe before it is automatically frozen. + * + * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing. + */ + static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) + { + UPCONX &= ~(1 << INMODE); + UPINRQX = TotalINRequests; + } + + /** Determines if the currently selected pipe is configured. + * + * \return Boolean \c true if the selected pipe is configured, \c false otherwise. + */ + static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsConfigured(void) + { + return ((UPSTAX & (1 << CFGOK)) ? true : false); + } + + /** Retrieves the endpoint address of the endpoint within the attached device that the currently selected + * pipe is bound to. + * + * \return Endpoint address the currently selected pipe is bound to. + */ + static inline uint8_t Pipe_GetBoundEndpointAddress(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetBoundEndpointAddress(void) + { + uint8_t UPCFG0X_Temp = UPCFG0X; + + return (((UPCFG0X_Temp >> PEPNUM0) & PIPE_EPNUM_MASK) | ((UPCFG0X_Temp & PEPNUM1) ? ENDPOINT_DIR_OUT : ENDPOINT_DIR_IN)); + } + + /** 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 address has interrupted (valid only for INTERRUPT type + * pipes). + * + * \param[in] Address Address of the pipe whose interrupt flag should be tested. + * + * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise. + */ + static inline bool Pipe_HasPipeInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_HasPipeInterrupted(const uint8_t Address) + { + return ((UPINT & (1 << (Address & PIPE_PIPENUM_MASK))) ? true : false); + } + + /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */ + static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Unfreeze(void) + { + UPCONX &= ~(1 << PFREEZE); + } + + /** Freezes the selected pipe, preventing it from communicating with an attached device. */ + static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Freeze(void) + { + UPCONX |= (1 << PFREEZE); + } + + /** Determines if the currently selected pipe is frozen, and not able to accept data. + * + * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise. + */ + static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsFrozen(void) + { + return ((UPCONX & (1 << PFREEZE)) ? true : false); + } + + /** Clears the error flags for the currently selected pipe. */ + static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearError(void) + { + UPERRX = 0; + UPINTX &= ~(1 << PERRI); + } + + /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that + * some sort of hardware error has occurred on the pipe. + * + * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag. + * + * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise. + */ + static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsError(void) + { + return ((UPINTX & (1 << PERRI)) ? true : false); + } + + /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This + * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred. + * + * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe. + */ + static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetErrorFlags(void) + { + return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | + PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID | + PIPE_ERRORFLAG_DATATGL)) | + (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW))); + } + + /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for + * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the + * \ref Pipe_ClearIN() command. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Total number of busy banks in the selected pipe. + */ + static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetBusyBanks(void) + { + return (UPSTAX & (0x03 << NBUSYBK0)); + } + + /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe + * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT + * direction). This function will return false if an error has occurred in the pipe, or if the pipe + * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT + * direction and the pipe bank is full. + * + * \note This function is not valid on CONTROL type pipes. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the currently selected pipe may be read from or written to, depending + * on its direction. + */ + static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsReadWriteAllowed(void) + { + return ((UPINTX & (1 << RWAL)) ? true : false); + } + + /** Determines if a packet has been received on the currently selected IN pipe from the attached device. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise. + */ + static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsINReceived(void) + { + return ((UPINTX & (1 << RXINI)) ? true : false); + } + + /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise. + */ + static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsOUTReady(void) + { + return ((UPINTX & (1 << TXOUTI)) ? true : false); + } + + /** Determines if no SETUP request is currently being sent to the attached device on the selected + * CONTROL type pipe. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise. + */ + static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsSETUPSent(void) + { + return ((UPINTX & (1 << TXSTPI)) ? true : false); + } + + /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet. + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearSETUP(void) + { + UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON)); + } + + /** Acknowledges the reception of a setup IN request from the attached device on the currently selected + * pipe, freeing the bank ready for the next packet. + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearIN(void) + { + UPINTX &= ~((1 << RXINI) | (1 << FIFOCON)); + } + + /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing + * the bank ready for the next packet. + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearOUT(void) + { + UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON)); + } + + /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on + * the currently selected pipe. This occurs when the host sends a packet to the device, but the device + * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been + * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet + * can be re-sent. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise. + */ + static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsNAKReceived(void) + { + return ((UPINTX & (1 << NAKEDI)) ? true : false); + } + + /** Clears the NAK condition on the currently selected pipe. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \see \ref Pipe_IsNAKReceived() for more details. + */ + static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearNAKReceived(void) + { + UPINTX &= ~(1 << NAKEDI); + } + + /** Determines if the currently selected pipe has had the STALL condition set by the attached device. + * + * \ingroup Group_PipePacketManagement_AVR8 + * + * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise. + */ + static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsStalled(void) + { + return ((UPINTX & (1 << RXSTALLI)) ? true : false); + } + + /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the + * STALL condition itself (this must be done via a ClearFeature control request to the device). + * + * \ingroup Group_PipePacketManagement_AVR8 + */ + static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearStall(void) + { + UPINTX &= ~(1 << RXSTALLI); + } + + /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next byte in the currently selected pipe's FIFO buffer. + */ + static inline uint8_t Pipe_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_Read_8(void) + { + return UPDATX; + } + + /** Writes one byte to the currently selected pipe's bank, for IN direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write into the the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_8(const uint8_t Data) + { + UPDATX = Data; + } + + /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + */ + static inline void Pipe_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_8(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + + (void)Dummy; + } + + /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_16_LE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; + + return Data.Value; + } + + /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next two bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_16_BE(void) + { + union + { + uint16_t Value; + uint8_t Bytes[2]; + } Data; + + Data.Bytes[1] = UPDATX; + Data.Bytes[0] = UPDATX; + + return Data.Value; + } + + /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_16_LE(const uint16_t Data) + { + UPDATX = (Data & 0xFF); + UPDATX = (Data >> 8); + } + + /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_16_BE(const uint16_t Data) + { + UPDATX = (Data >> 8); + UPDATX = (Data & 0xFF); + } + + /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + */ + static inline void Pipe_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_16(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + Dummy = UPDATX; + + (void)Dummy; + } + + /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_32_LE(void) + { + union + { + uint32_t Value; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[0] = UPDATX; + Data.Bytes[1] = UPDATX; + Data.Bytes[2] = UPDATX; + Data.Bytes[3] = UPDATX; + + return Data.Value; + } + + /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \return Next four bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_32_BE(void) + { + union + { + uint32_t DWord; + uint8_t Bytes[4]; + } Data; + + Data.Bytes[3] = UPDATX; + Data.Bytes[2] = UPDATX; + Data.Bytes[1] = UPDATX; + Data.Bytes[0] = UPDATX; + + return Data.DWord; + } + + /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_32_LE(const uint32_t Data) + { + UPDATX = (Data & 0xFF); + UPDATX = (Data >> 8); + UPDATX = (Data >> 16); + UPDATX = (Data >> 24); + } + + /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_32_BE(const uint32_t Data) + { + UPDATX = (Data >> 24); + UPDATX = (Data >> 16); + UPDATX = (Data >> 8); + UPDATX = (Data & 0xFF); + } + + /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_AVR8 + */ + static inline void Pipe_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_32(void) + { + uint8_t Dummy; + + Dummy = UPDATX; + Dummy = UPDATX; + Dummy = UPDATX; + Dummy = UPDATX; + + (void)Dummy; + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control pipe located at address + * 0 in the device. This value is set to the value indicated in the attached device's device + * descriptor once the USB interface is initialized into host mode and a device is attached + * to the USB bus. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + extern uint8_t USB_Host_ControlPipeSize; + + /* Function Prototypes: */ + /** Configures a table of pipe descriptions, in sequence. This function can be used to configure multiple + * pipes at the same time. + * + * \note Pipe with a zero address will be ignored, thus this function cannot be used to configure the + * control pipe. + * + * \param[in] Table Pointer to a table of pipe descriptions. + * \param[in] Entries Number of entries in the pipe table to configure. + * + * \return Boolean \c true if all pipes configured successfully, \c false otherwise. + */ + bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table, + const uint8_t Entries); + + /** Configures the specified pipe address with the given pipe type, endpoint address within the attached device, bank size + * and number of hardware banks. + * + * 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] Address Pipe address to configure. + * + * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low + * Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] EndpointAddress Endpoint address 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. + * + * \attention When the \c ORDERED_EP_CONFIG compile time option is used, Pipes must be configured in ascending order, + * or bank corruption will occur. + * + * \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's + * index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe. + * \n\n + * + * \note The default control pipe should not be manually configured by the user application, as it is + * automatically configured by the library internally. + * \n\n + * + * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which + * failed to reconfigure correctly will be selected. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + bool Pipe_ConfigurePipe(const uint8_t Address, + const uint8_t Type, + const uint8_t EndpointAddress, + const uint16_t Size, + const uint8_t Banks); + + /** Spin-loops until the currently selected non-control pipe is ready for the next packet of data to be read + * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect). + * + * \ingroup Group_PipeRW_AVR8 + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t Pipe_WaitUntilReady(void); + + /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given + * endpoint is found, it is automatically selected. + * + * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check. + * + * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found, + * \c false otherwise. + */ + bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #if !defined(ENDPOINT_CONTROLEP) + #define ENDPOINT_CONTROLEP 0 + #endif + + /* Inline Functions: */ + static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) + { + uint8_t MaskVal = 0; + uint16_t CheckBytes = 8; + + while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE)) + { + MaskVal++; + CheckBytes <<= 1; + } + + return (MaskVal << EPSIZE0); + } + + /* Function Prototypes: */ + void Pipe_ClearPipes(void); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c new file mode 100644 index 000000000..ab69536b0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_R.c @@ -0,0 +1,85 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + + if (!(Length)) + Endpoint_ClearOUT(); + + while (Length) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + + if (Endpoint_IsOUTReceived()) + { + while (Length && Endpoint_BytesInEndpoint()) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + } + + Endpoint_ClearOUT(); + } + } + + while (!(Endpoint_IsINReady())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c new file mode 100644 index 000000000..c2d171db0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_Control_W.c @@ -0,0 +1,94 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + bool LastPacketFull = false; + + if (Length > USB_ControlRequest.wLength) + Length = USB_ControlRequest.wLength; + else if (!(Length)) + Endpoint_ClearIN(); + + while (Length || LastPacketFull) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + else if (Endpoint_IsOUTReceived()) + break; + + if (Endpoint_IsINReady()) + { + uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); + + while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInEndpoint++; + } + + LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); + Endpoint_ClearIN(); + } + } + + while (!(Endpoint_IsOUTReceived())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c new file mode 100644 index 000000000..02ad97867 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Endpoint_RW.c @@ -0,0 +1,90 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_ENDPOINT(); + + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_ENDPOINT +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c new file mode 100644 index 000000000..05846bb61 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/Template/Template_Pipe_RW.c @@ -0,0 +1,89 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + Pipe_SetPipeToken(TEMPLATE_TOKEN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_PIPE(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TOKEN +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_PIPE +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c new file mode 100644 index 000000000..37b106ab6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c @@ -0,0 +1,265 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#define __INCLUDE_FROM_USB_CONTROLLER_C +#include "../USBController.h" + +#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) +volatile uint8_t USB_CurrentMode = USB_MODE_None; +#endif + +#if !defined(USE_STATIC_OPTIONS) +volatile uint8_t USB_Options; +#endif + +void USB_Init( + #if defined(USB_CAN_BE_BOTH) + const uint8_t Mode + #endif + + #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) + , + #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) + void + #endif + + #if !defined(USE_STATIC_OPTIONS) + const uint8_t Options + #endif + ) +{ + #if !defined(USE_STATIC_OPTIONS) + USB_Options = Options; + #endif + + if (!(USB_Options & USB_OPT_REG_DISABLED)) + USB_REG_On(); + else + USB_REG_Off(); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_4_AVR) + PLLFRQ = (1 << PDIV2); + #endif + } + + #if defined(USB_CAN_BE_BOTH) + if (Mode == USB_MODE_UID) + { + UHWCON |= (1 << UIDE); + USB_INT_Enable(USB_INT_IDTI); + USB_CurrentMode = USB_GetUSBModeFromUID(); + } + else + { + UHWCON &= ~(1 << UIDE); + USB_CurrentMode = Mode; + } + #endif + + USB_IsInitialized = true; + + USB_ResetInterface(); +} + +void USB_Disable(void) +{ + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Detach(); + USB_Controller_Disable(); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + + USB_REG_Off(); + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + USB_OTGPAD_Off(); + #endif + + #if defined(USB_CAN_BE_BOTH) + USB_CurrentMode = USB_MODE_None; + #endif + + USB_IsInitialized = false; +} + +void USB_ResetInterface(void) +{ + #if defined(USB_CAN_BE_BOTH) + bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0); + #endif + + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Controller_Reset(); + + #if defined(USB_CAN_BE_BOTH) + if (UIDModeSelectEnabled) + USB_INT_Enable(USB_INT_IDTI); + #endif + + USB_CLK_Unfreeze(); + + if (USB_CurrentMode == USB_MODE_Device) + { + #if defined(USB_CAN_BE_DEVICE) + #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + UHWCON |= (1 << UIMOD); + #endif + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_SERIES_2_AVR) + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + #else + USB_PLL_Off(); + #endif + } + + USB_Init_Device(); + #endif + } + else if (USB_CurrentMode == USB_MODE_Host) + { + #if defined(USB_CAN_BE_HOST) + UHWCON &= ~(1 << UIMOD); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + #if defined(USB_CAN_BE_HOST) + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + #endif + } + + USB_Init_Host(); + #endif + } + + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + USB_OTGPAD_On(); + #endif +} + +#if defined(USB_CAN_BE_DEVICE) +static void USB_Init_Device(void) +{ + USB_DeviceState = DEVICE_STATE_Unattached; + USB_Device_ConfigurationNumber = 0; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + USB_Device_RemoteWakeupEnabled = false; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + USB_Device_CurrentlySelfPowered = false; + #endif + + #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) + USB_Descriptor_Device_t* DeviceDescriptorPtr; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + uint8_t DescriptorAddressSpace; + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR) + { + if (DescriptorAddressSpace == MEMSPACE_FLASH) + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else if (DescriptorAddressSpace == MEMSPACE_EEPROM) + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + } + #else + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) + { + #if defined(USE_RAM_DESCRIPTORS) + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + #elif defined(USE_EEPROM_DESCRIPTORS) + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #else + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #endif + } + #endif + #endif + + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + if (USB_Options & USB_DEVICE_OPT_LOWSPEED) + USB_Device_SetLowSpeed(); + else + USB_Device_SetFullSpeed(); + + USB_INT_Enable(USB_INT_VBUSTI); + #endif + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + USB_Device_ControlEndpointSize, 1); + + USB_INT_Clear(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_EORSTI); + + USB_Attach(); +} +#endif + +#if defined(USB_CAN_BE_HOST) +static void USB_Init_Host(void) +{ + USB_HostState = HOST_STATE_Unattached; + USB_Host_ConfigurationNumber = 0; + USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + + USB_Host_HostMode_On(); + + USB_Host_VBUS_Auto_Off(); + USB_Host_VBUS_Manual_Enable(); + USB_Host_VBUS_Manual_On(); + + USB_INT_Enable(USB_INT_SRPI); + USB_INT_Enable(USB_INT_BCERRI); + + USB_Attach(); +} +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h new file mode 100644 index 000000000..e479d7a1a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.h @@ -0,0 +1,436 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller definitions for the AVR8 microcontrollers. + * \copydetails Group_USBManagement_AVR8 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USBManagement + * \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8) + * \brief USB Controller definitions for the AVR8 microcontrollers. + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_AVR8_H__ +#define __USBCONTROLLER_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../Events.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "../Host.h" + #include "../OTG.h" + #include "../Pipe.h" + #include "../HostStandardReq.h" + #include "../PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "../Device.h" + #include "../Endpoint.h" + #include "../DeviceStandardReq.h" + #include "../EndpointStream.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks and Defines: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if !defined(F_USB) + #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile. + #endif + + #if (F_USB == 8000000) + #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \ + defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \ + defined(__AVR_ATmega32U2__)) + #define USB_PLL_PSC 0 + #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) + #define USB_PLL_PSC 0 + #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__)) + #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0)) + #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) + #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0)) + #endif + #elif (F_USB == 16000000) + #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \ + defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \ + defined(__AVR_ATmega32U2__)) + #define USB_PLL_PSC (1 << PLLP0) + #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) + #define USB_PLL_PSC (1 << PINDIV) + #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__)) + #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1)) + #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__)) + #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0)) + #endif + #endif + + #if !defined(USB_PLL_PSC) + #error No PLL prescale value available for chosen F_USB value and AVR model. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Controller Option Masks */ + //@{ + /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad + * regulator should be disabled and the AVR's VCC level used for the data pads. + * + * \note See USB AVR data sheet for more information on the internal pad regulator. + */ + #define USB_OPT_REG_DISABLED (1 << 1) + + /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad + * regulator should be enabled to regulate the data pin voltages from the VBUS level down to a level within + * the range allowable by the USB standard. + * + * \note See USB AVR data sheet for more information on the internal pad regulator. + */ + #define USB_OPT_REG_ENABLED (0 << 1) + + /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application + * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock + * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations. + */ + #define USB_OPT_MANUAL_PLL (1 << 2) + + /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should + * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock + * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations. + */ + #define USB_OPT_AUTO_PLL (0 << 2) + //@} + + #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__) + /** Constant for the maximum software timeout period of the USB data stream transfer functions + * (both control and standard) when in either device or host mode. If the next packet of a stream + * is not received or acknowledged within this time period, the stream function will fail. + * + * This value may be overridden in the user project makefile as the value of the + * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch. + */ + #define USB_STREAM_TIMEOUT_MS 100 + #endif + + /* Inline Functions: */ + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) + /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power). + * + * \note This function is not available on some AVR models which do not support hardware VBUS monitoring. + * + * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise. + */ + static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_VBUS_GetStatus(void) + { + return ((USBSTA & (1 << VBUS)) ? true : false); + } + #endif + + /** Detaches the device from the USB bus. This has the effect of removing the device from any + * attached host, ceasing USB communications. If no host is present, this prevents any host from + * enumerating the device once attached until \ref USB_Attach() is called. + */ + static inline void USB_Detach(void) ATTR_ALWAYS_INLINE; + static inline void USB_Detach(void) + { + UDCON |= (1 << DETACH); + } + + /** Attaches the device to the USB bus. This announces the device's presence to any attached + * USB host, starting the enumeration process. If no host is present, attaching the device + * will allow for enumeration once a host is connected to the device. + * + * This is inexplicably also required for proper operation while in host mode, to enable the + * attachment of a device to the host. This is despite the bit being located in the device-mode + * register and despite the datasheet making no mention of its requirement in host mode. + */ + static inline void USB_Attach(void) ATTR_ALWAYS_INLINE; + static inline void USB_Attach(void) + { + UDCON &= ~(1 << DETACH); + } + + /* Function Prototypes: */ + /** Main function to initialize and start the USB interface. Once active, the USB interface will + * allow for device connection to a host when in device mode, or for device enumeration while in + * host mode. + * + * As the USB library relies on interrupts for the device and host mode enumeration processes, + * the user must enable global interrupts before or shortly after this function is called. In + * device mode, interrupts must be enabled within 500ms of this function being called to ensure + * that the host does not time out whilst enumerating the device. In host mode, interrupts may be + * enabled at the application's leisure however enumeration will not begin of an attached device + * until after this has occurred. + * + * Calling this function when the USB interface is already initialized will cause a complete USB + * interface reset and re-enumeration. + * + * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value + * from the \ref USB_Modes_t enum. + * + * \param[in] Options Mask indicating the options which should be used when initializing the USB + * interface to control the USB interface's behavior. This should be comprised of + * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the + * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device + * mode speed. + * + * \note To reduce the FLASH requirements of the library if only device or host mode is required, + * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY + * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler + * via the -D switch. If the mode is statically set, this parameter does not exist in the + * function prototype. + * \n\n + * + * \note To reduce the FLASH requirements of the library if only fixed settings are required, + * the options may be set statically in the same manner as the mode (see the Mode parameter of + * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token, + * defined to the appropriate options masks. When the options are statically set, this + * parameter does not exist in the function prototype. + * \n\n + * + * \note The mode parameter does not exist on devices where only one mode is possible, such as USB + * AVR models which only implement the USB device mode in hardware. + * + * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks. + */ + void USB_Init( + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + const uint8_t Mode + #endif + + #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__) + , + #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) + void + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + const uint8_t Options + #endif + ); + + /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO + * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface + * is restarted with the \ref USB_Init() function. + */ + void USB_Disable(void); + + /** Resets the interface, when already initialized. This will re-enumerate the device if already connected + * to a host, or re-enumerate an already attached device when in host mode. + */ + void USB_ResetInterface(void); + + /* Global Variables: */ + #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__) + /** Indicates the mode that the USB interface is currently initialized to, a value from the + * \ref USB_Modes_t enum. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \note When the controller is initialized into UID auto-detection mode, this variable will hold the + * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller + * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time + * options, or a limitation of the USB controller in the chosen device model) this will evaluate to + * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the + * USB interface is not initialized. + */ + extern volatile uint8_t USB_CurrentMode; + #elif defined(USB_HOST_ONLY) + #define USB_CurrentMode USB_MODE_Host + #elif defined(USB_DEVICE_ONLY) + #define USB_CurrentMode USB_MODE_Device + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init() + * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + extern volatile uint8_t USB_Options; + #elif defined(USE_STATIC_OPTIONS) + #define USB_Options USE_STATIC_OPTIONS + #endif + + /* Enums: */ + /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the + * user application via \ref USB_CurrentMode. + */ + enum USB_Modes_t + { + USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */ + USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */ + USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */ + USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the + * USB connector. + */ + }; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_USB_CONTROLLER_C) + #if defined(USB_CAN_BE_DEVICE) + static void USB_Init_Device(void); + #endif + + #if defined(USB_CAN_BE_HOST) + static void USB_Init_Host(void); + #endif + #endif + + /* Inline Functions: */ + static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_PLL_On(void) + { + PLLCSR = USB_PLL_PSC; + PLLCSR = (USB_PLL_PSC | (1 << PLLE)); + } + + static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_PLL_Off(void) + { + PLLCSR = 0; + } + + static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_PLL_IsReady(void) + { + return ((PLLCSR & (1 << PLOCK)) ? true : false); + } + + static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_REG_On(void) + { + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + UHWCON |= (1 << UVREGE); + #else + REGCR &= ~(1 << REGDIS); + #endif + } + + static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_REG_Off(void) + { + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + UHWCON &= ~(1 << UVREGE); + #else + REGCR |= (1 << REGDIS); + #endif + } + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTGPAD_On(void) + { + USBCON |= (1 << OTGPADE); + } + + static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTGPAD_Off(void) + { + USBCON &= ~(1 << OTGPADE); + } + #endif + + static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE; + static inline void USB_CLK_Freeze(void) + { + USBCON |= (1 << FRZCLK); + } + + static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE; + static inline void USB_CLK_Unfreeze(void) + { + USBCON &= ~(1 << FRZCLK); + } + + static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Enable(void) + { + USBCON |= (1 << USBE); + } + + static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Disable(void) + { + USBCON &= ~(1 << USBE); + } + + static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Reset(void) + { + USBCON &= ~(1 << USBE); + USBCON |= (1 << USBE); + } + + #if defined(USB_CAN_BE_BOTH) + static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t USB_GetUSBModeFromUID(void) + { + if (USBSTA & (1 << ID)) + return USB_MODE_Device; + else + return USB_MODE_Host; + } + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c new file mode 100644 index 000000000..3bff19f2e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c @@ -0,0 +1,279 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_AVR8) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBInterrupt.h" + +void USB_INT_DisableAllInterrupts(void) +{ + #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); + #elif defined(USB_SERIES_4_AVR) + USBCON &= ~(1 << VBUSTE); + #endif + + #if defined(USB_CAN_BE_BOTH) + OTGIEN = 0; + #endif + + #if defined(USB_CAN_BE_HOST) + UHIEN = 0; + #endif + + #if defined(USB_CAN_BE_DEVICE) + UDIEN = 0; + #endif +} + +void USB_INT_ClearAllInterrupts(void) +{ + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + USBINT = 0; + #endif + + #if defined(USB_CAN_BE_BOTH) + OTGINT = 0; + #endif + + #if defined(USB_CAN_BE_HOST) + UHINT = 0; + #endif + + #if defined(USB_CAN_BE_DEVICE) + UDINT = 0; + #endif +} + +ISR(USB_GEN_vect, ISR_BLOCK) +{ + #if defined(USB_CAN_BE_DEVICE) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) + { + USB_INT_Clear(USB_INT_SOFI); + + EVENT_USB_Device_StartOfFrame(); + } + #endif + + #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) + if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI)) + { + USB_INT_Clear(USB_INT_VBUSTI); + + if (USB_VBUS_GetStatus()) + { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + USB_DeviceState = DEVICE_STATE_Powered; + EVENT_USB_Device_Connect(); + } + else + { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + + USB_DeviceState = DEVICE_STATE_Unattached; + EVENT_USB_Device_Disconnect(); + } + } + #endif + + if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI)) + { + USB_INT_Disable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_WAKEUPI); + + USB_CLK_Freeze(); + + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + USB_PLL_Off(); + + #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) + USB_DeviceState = DEVICE_STATE_Unattached; + EVENT_USB_Device_Disconnect(); + #else + USB_DeviceState = DEVICE_STATE_Suspended; + EVENT_USB_Device_Suspend(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI)) + { + if (!(USB_Options & USB_OPT_MANUAL_PLL)) + { + USB_PLL_On(); + while (!(USB_PLL_IsReady())); + } + + USB_CLK_Unfreeze(); + + USB_INT_Clear(USB_INT_WAKEUPI); + + USB_INT_Disable(USB_INT_WAKEUPI); + USB_INT_Enable(USB_INT_SUSPI); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT) + EVENT_USB_Device_Connect(); + #else + EVENT_USB_Device_WakeUp(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) + { + USB_INT_Clear(USB_INT_EORSTI); + + USB_DeviceState = DEVICE_STATE_Default; + USB_Device_ConfigurationNumber = 0; + + USB_INT_Clear(USB_INT_SUSPI); + USB_INT_Disable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_WAKEUPI); + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + USB_Device_ControlEndpointSize, 1); + + #if defined(INTERRUPT_CONTROL_ENDPOINT) + USB_INT_Enable(USB_INT_RXSTPI); + #endif + + EVENT_USB_Device_Reset(); + } + #endif + + #if defined(USB_CAN_BE_HOST) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + + EVENT_USB_Host_StartOfFrame(); + } + #endif + + if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI)) + { + USB_INT_Clear(USB_INT_DDISCI); + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Disable(USB_INT_DDISCI); + + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } + + if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI)) + { + USB_INT_Clear(USB_INT_VBERRI); + + USB_Host_VBUS_Manual_Off(); + USB_Host_VBUS_Auto_Off(); + + EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip); + EVENT_USB_Host_DeviceUnattached(); + + USB_HostState = HOST_STATE_Unattached; + } + + if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI)) + { + USB_INT_Clear(USB_INT_SRPI); + USB_INT_Disable(USB_INT_SRPI); + + EVENT_USB_Host_DeviceAttached(); + + USB_INT_Enable(USB_INT_DDISCI); + + USB_HostState = HOST_STATE_Powered; + } + + if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI)) + { + USB_INT_Clear(USB_INT_BCERRI); + + EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0); + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } + #endif + + #if defined(USB_CAN_BE_BOTH) + if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI)) + { + USB_INT_Clear(USB_INT_IDTI); + + if (USB_DeviceState != DEVICE_STATE_Unattached) + EVENT_USB_Device_Disconnect(); + + if (USB_HostState != HOST_STATE_Unattached) + EVENT_USB_Host_DeviceUnattached(); + + USB_CurrentMode = USB_GetUSBModeFromUID(); + USB_ResetInterface(); + + EVENT_USB_UIDChange(); + } + #endif +} + +#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE) +ISR(USB_COM_vect, ISR_BLOCK) +{ + uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Disable(USB_INT_RXSTPI); + + GlobalInterruptEnable(); + + USB_Device_ProcessControlRequest(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Enable(USB_INT_RXSTPI); + Endpoint_SelectEndpoint(PrevSelectedEndpoint); +} +#endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h new file mode 100644 index 000000000..9e9210ec2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h @@ -0,0 +1,369 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller Interrupt definitions for the AVR8 microcontrollers. + * + * This file contains definitions required for the correct handling of low level USB service routine interrupts + * from the USB controller. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBINTERRUPT_AVR8_H__ +#define __USBINTERRUPT_AVR8_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Enums: */ + enum USB_Interrupts_t + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)) + USB_INT_VBUSTI = 0, + #endif + #if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)) + USB_INT_IDTI = 1, + #endif + #if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)) + USB_INT_WAKEUPI = 2, + USB_INT_SUSPI = 3, + USB_INT_EORSTI = 4, + USB_INT_SOFI = 5, + USB_INT_RXSTPI = 6, + #endif + #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)) + USB_INT_HSOFI = 7, + USB_INT_DCONNI = 8, + USB_INT_DDISCI = 9, + USB_INT_RSTI = 10, + USB_INT_BCERRI = 11, + USB_INT_VBERRI = 12, + USB_INT_SRPI = 13, + #endif + }; + + /* Inline Functions: */ + static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Enable(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + USBCON |= (1 << VBUSTE); + break; + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + USBCON |= (1 << IDTE); + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + UDIEN |= (1 << WAKEUPE); + break; + case USB_INT_SUSPI: + UDIEN |= (1 << SUSPE); + break; + case USB_INT_EORSTI: + UDIEN |= (1 << EORSTE); + break; + case USB_INT_SOFI: + UDIEN |= (1 << SOFE); + break; + case USB_INT_RXSTPI: + UEIENX |= (1 << RXSTPE); + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + UHIEN |= (1 << HSOFE); + break; + case USB_INT_DCONNI: + UHIEN |= (1 << DCONNE); + break; + case USB_INT_DDISCI: + UHIEN |= (1 << DDISCE); + break; + case USB_INT_RSTI: + UHIEN |= (1 << RSTE); + break; + case USB_INT_BCERRI: + OTGIEN |= (1 << BCERRE); + break; + case USB_INT_VBERRI: + OTGIEN |= (1 << VBERRE); + break; + case USB_INT_SRPI: + OTGIEN |= (1 << SRPE); + break; + #endif + } + } + + static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Disable(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + USBCON &= ~(1 << VBUSTE); + break; + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + USBCON &= ~(1 << IDTE); + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + UDIEN &= ~(1 << WAKEUPE); + break; + case USB_INT_SUSPI: + UDIEN &= ~(1 << SUSPE); + break; + case USB_INT_EORSTI: + UDIEN &= ~(1 << EORSTE); + break; + case USB_INT_SOFI: + UDIEN &= ~(1 << SOFE); + break; + case USB_INT_RXSTPI: + UEIENX &= ~(1 << RXSTPE); + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + UHIEN &= ~(1 << HSOFE); + break; + case USB_INT_DCONNI: + UHIEN &= ~(1 << DCONNE); + break; + case USB_INT_DDISCI: + UHIEN &= ~(1 << DDISCE); + break; + case USB_INT_RSTI: + UHIEN &= ~(1 << RSTE); + break; + case USB_INT_BCERRI: + OTGIEN &= ~(1 << BCERRE); + break; + case USB_INT_VBERRI: + OTGIEN &= ~(1 << VBERRE); + break; + case USB_INT_SRPI: + OTGIEN &= ~(1 << SRPE); + break; + #endif + } + } + + static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Clear(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + USBINT &= ~(1 << VBUSTI); + break; + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + USBINT &= ~(1 << IDTI); + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + UDINT &= ~(1 << WAKEUPI); + break; + case USB_INT_SUSPI: + UDINT &= ~(1 << SUSPI); + break; + case USB_INT_EORSTI: + UDINT &= ~(1 << EORSTI); + break; + case USB_INT_SOFI: + UDINT &= ~(1 << SOFI); + break; + case USB_INT_RXSTPI: + UEINTX &= ~(1 << RXSTPI); + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + UHINT &= ~(1 << HSOFI); + break; + case USB_INT_DCONNI: + UHINT &= ~(1 << DCONNI); + break; + case USB_INT_DDISCI: + UHINT &= ~(1 << DDISCI); + break; + case USB_INT_RSTI: + UHINT &= ~(1 << RSTI); + break; + case USB_INT_BCERRI: + OTGINT &= ~(1 << BCERRI); + break; + case USB_INT_VBERRI: + OTGINT &= ~(1 << VBERRI); + break; + case USB_INT_SRPI: + OTGINT &= ~(1 << SRPI); + break; + #endif + } + } + + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + return (USBCON & (1 << VBUSTE)); + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + return (USBCON & (1 << IDTE)); + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + return (UDIEN & (1 << WAKEUPE)); + case USB_INT_SUSPI: + return (UDIEN & (1 << SUSPE)); + case USB_INT_EORSTI: + return (UDIEN & (1 << EORSTE)); + case USB_INT_SOFI: + return (UDIEN & (1 << SOFE)); + case USB_INT_RXSTPI: + return (UEIENX & (1 << RXSTPE)); + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + return (UHIEN & (1 << HSOFE)); + case USB_INT_DCONNI: + return (UHIEN & (1 << DCONNE)); + case USB_INT_DDISCI: + return (UHIEN & (1 << DDISCE)); + case USB_INT_RSTI: + return (UHIEN & (1 << RSTE)); + case USB_INT_BCERRI: + return (OTGIEN & (1 << BCERRE)); + case USB_INT_VBERRI: + return (OTGIEN & (1 << VBERRE)); + case USB_INT_SRPI: + return (OTGIEN & (1 << SRPE)); + #endif + } + + return false; + } + + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) + { + switch (Interrupt) + { + #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) + case USB_INT_VBUSTI: + return (USBINT & (1 << VBUSTI)); + #endif + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + return (USBINT & (1 << IDTI)); + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + return (UDINT & (1 << WAKEUPI)); + case USB_INT_SUSPI: + return (UDINT & (1 << SUSPI)); + case USB_INT_EORSTI: + return (UDINT & (1 << EORSTI)); + case USB_INT_SOFI: + return (UDINT & (1 << SOFI)); + case USB_INT_RXSTPI: + return (UEINTX & (1 << RXSTPI)); + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + return (UHINT & (1 << HSOFI)); + case USB_INT_DCONNI: + return (UHINT & (1 << DCONNI)); + case USB_INT_DDISCI: + return (UHINT & (1 << DDISCI)); + case USB_INT_RSTI: + return (UHINT & (1 << RSTI)); + case USB_INT_BCERRI: + return (OTGINT & (1 << BCERRI)); + case USB_INT_VBERRI: + return (OTGINT & (1 << VBERRI)); + case USB_INT_SRPI: + return (OTGINT & (1 << SRPI)); + #endif + } + + return false; + } + + /* Includes: */ + #include "../USBMode.h" + #include "../Events.h" + #include "../USBController.h" + + /* Function Prototypes: */ + void USB_INT_ClearAllInterrupts(void); + void USB_INT_DisableAllInterrupts(void); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.c new file mode 100644 index 000000000..71cced874 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.c @@ -0,0 +1,146 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "ConfigDescriptors.h" + +#if defined(USB_CAN_BE_HOST) +uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber, + uint16_t* const ConfigSizePtr, + void* const BufferPtr, + const uint16_t BufferSize) +{ + uint8_t ErrorCode; + uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)]; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetDescriptor, + .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)), + .wIndex = 0, + .wLength = sizeof(USB_Descriptor_Configuration_Header_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + *ConfigSizePtr = le16_to_cpu(DESCRIPTOR_PCAST(ConfigHeader, USB_Descriptor_Configuration_Header_t)->TotalConfigurationSize); + + if (*ConfigSizePtr > BufferSize) + return HOST_GETCONFIG_BuffOverflow; + + USB_ControlRequest.wLength = *ConfigSizePtr; + + if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful) + return ErrorCode; + + if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration) + return HOST_GETCONFIG_InvalidData; + + return HOST_GETCONFIG_Successful; +} +#endif + +void USB_GetNextDescriptorOfType(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type) +{ + while (*BytesRem) + { + USB_GetNextDescriptor(BytesRem, CurrConfigLoc); + + if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type) + return; + } +} + +void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t BeforeType) +{ + while (*BytesRem) + { + USB_GetNextDescriptor(BytesRem, CurrConfigLoc); + + if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type) + { + return; + } + else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType) + { + *BytesRem = 0; + return; + } + } +} + +void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t AfterType) +{ + USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType); + + if (*BytesRem) + USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type); +} + +uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, + void** const CurrConfigLoc, + ConfigComparatorPtr_t const ComparatorRoutine) +{ + uint8_t ErrorCode; + + while (*BytesRem) + { + uint8_t* PrevDescLoc = *CurrConfigLoc; + uint16_t PrevBytesRem = *BytesRem; + + USB_GetNextDescriptor(BytesRem, CurrConfigLoc); + + if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound) + { + if (ErrorCode == DESCRIPTOR_SEARCH_Fail) + { + *CurrConfigLoc = PrevDescLoc; + *BytesRem = PrevBytesRem; + } + + return ErrorCode; + } + } + + return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor; +} + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.h new file mode 100644 index 000000000..0de598230 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/ConfigDescriptors.h @@ -0,0 +1,286 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Configuration Descriptor definitions. + * \copydetails Group_ConfigDescriptorParser + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_StdDescriptors + * \defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser + * \brief USB Configuration Descriptor definitions. + * + * This section of the library gives a friendly API which can be used in host applications to easily + * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor + * data can be extracted and used as needed. + * + * @{ + */ + +#ifndef __CONFIGDESCRIPTOR_H__ +#define __CONFIGDESCRIPTOR_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "HostStandardReq.h" + #include "StdDescriptors.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given + * descriptor type. + * + * Usage Example: + * \code + * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header + * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor, + * USB_Descriptor_Configuration_Header_t); + * + * // Can now access elements of the configuration header struct using the -> indirection operator + * \endcode + */ + #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr)) + + /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor + * type (as an actual struct instance rather than a pointer to a struct). + * + * Usage Example: + * \code + * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header + * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor, + * USB_Descriptor_Configuration_Header_t); + * + * // Can now access elements of the configuration header struct using the . operator + * \endcode + */ + #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type)) + + /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor. + * This value's meaning depends on the descriptor's placement in the descriptor, but standard type + * values can be accessed in the \ref USB_DescriptorTypes_t enum. + */ + #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Type + + /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */ + #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Size + + /* Type Defines: */ + /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array + * of type void, returning a uint8_t value). + * + * \see \ref USB_GetNextDescriptorComp function for more details. + */ + typedef uint8_t (* ConfigComparatorPtr_t)(void*); + + /* Enums: */ + /** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */ + enum USB_Host_GetConfigDescriptor_ErrorCodes_t + { + HOST_GETCONFIG_Successful = 0, /**< No error occurred while retrieving the configuration descriptor. */ + HOST_GETCONFIG_DeviceDisconnect = 1, /**< The attached device was disconnected while retrieving the configuration + * descriptor. + */ + HOST_GETCONFIG_PipeError = 2, /**< An error occurred in the pipe while sending the request. */ + HOST_GETCONFIG_SetupStalled = 3, /**< The attached device stalled the request to retrieve the configuration + * descriptor. + */ + HOST_GETCONFIG_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */ + HOST_GETCONFIG_BuffOverflow = 5, /**< The device's configuration descriptor is too large to fit into the allocated + * buffer. + */ + HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data. */ + }; + + /** Enum for return values of a descriptor comparator function. */ + enum DSearch_Return_ErrorCodes_t + { + DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */ + DESCRIPTOR_SEARCH_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */ + DESCRIPTOR_SEARCH_NotFound = 2, /**< Current descriptor does not match comparator criteria. */ + }; + + /** Enum for return values of \ref USB_GetNextDescriptorComp(). */ + enum DSearch_Comp_Return_ErrorCodes_t + { + DESCRIPTOR_SEARCH_COMP_Found = 0, /**< Configuration descriptor now points to descriptor which matches + * search criteria of the given comparator function. */ + DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned \ref DESCRIPTOR_SEARCH_Fail. */ + DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */ + }; + + /* Function Prototypes: */ + /** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer, + * including validity and size checking to prevent a buffer overflow. + * + * \param[in] ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for + * single configuration devices). + * \param[in,out] ConfigSizePtr Pointer to a location for storing the retrieved configuration descriptor size. + * \param[out] BufferPtr Pointer to the buffer for storing the configuration descriptor data. + * \param[out] BufferSize Size of the allocated buffer where the configuration descriptor is to be stored. + * + * \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum. + */ + uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber, + uint16_t* const ConfigSizePtr, + void* const BufferPtr, + const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3); + + /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value. + * The bytes remaining value is automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + * \param[in] Type Descriptor type value to search for. + */ + void USB_GetNextDescriptorOfType(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value, + * which must come before a descriptor of the second given type value. If the BeforeType type + * descriptor is reached first, the number of bytes remaining to process is set to zero and the + * function exits. The bytes remaining value is automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + * \param[in] Type Descriptor type value to search for. + * \param[in] BeforeType Descriptor type value which must not be reached before the given Type descriptor. + */ + void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t BeforeType) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value, + * which must come after a descriptor of the second given type value. The bytes remaining value is + * automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + * \param[in] Type Descriptor type value to search for. + * \param[in] AfterType Descriptor type value which must be reached before the given Type descriptor. + */ + void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, + void** const CurrConfigLoc, + const uint8_t Type, + const uint8_t AfterType) + ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + + /** Searches for the next descriptor in the given configuration descriptor using a pre-made comparator + * function. The routine updates the position and remaining configuration descriptor bytes values + * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back + * so that the next descriptor search invocation will start from the descriptor which first caused the + * original search to fail. This behavior allows for one comparator to be used immediately after another + * has failed, starting the second search from the descriptor which failed the first. + * + * Comparator functions should be standard functions which accept a pointer to the header of the current + * descriptor inside the configuration descriptor which is being compared, and should return a value from + * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value. + * + * \note This function is available in USB Host mode only. + * + * \param[in,out] BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current position in the configuration descriptor. + * \param[in] ComparatorRoutine Name of the comparator search function to use on the configuration descriptor. + * + * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum. + * + * Usage Example: + * \code + * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype + * + * uint8_t EndpointSearcher(void* CurrentDescriptor) + * { + * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) + * return DESCRIPTOR_SEARCH_Found; + * else + * return DESCRIPTOR_SEARCH_NotFound; + * } + * + * //... + * + * // After retrieving configuration descriptor: + * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &CurrentConfigLoc, EndpointSearcher) == + * Descriptor_Search_Comp_Found) + * { + * // Do something with the endpoint descriptor + * } + * \endcode + */ + uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, + void** const CurrConfigLoc, + ConfigComparatorPtr_t const ComparatorRoutine); + + /* Inline Functions: */ + /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then + points to the next sub-descriptor. The bytes remaining value is automatically decremented. + * + * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor. + * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor. + */ + static inline void USB_GetNextDescriptor(uint16_t* const BytesRem, + void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2); + static inline void USB_GetNextDescriptor(uint16_t* const BytesRem, + void** CurrConfigLoc) + { + uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size; + + if (*BytesRem < CurrDescriptorSize) + CurrDescriptorSize = *BytesRem; + + *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize); + *BytesRem -= CurrDescriptorSize; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Device.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Device.h new file mode 100644 index 000000000..995b9208e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Device.h @@ -0,0 +1,159 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Device definitions for all architectures. + * \copydetails Group_Device + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_Device Device Management + * \brief USB Device management definitions for USB device mode. + * + * USB Device mode related definitions common to all architectures. This module contains definitions which + * are used when the USB controller is initialized in device mode. + * + * @{ + */ + +#ifndef __USBDEVICE_H__ +#define __USBDEVICE_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "StdDescriptors.h" + #include "USBInterrupt.h" + #include "Endpoint.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the various states of the USB Device state machine. Only some states are + * implemented in the LUFA library - other states are left to the user to implement. + * + * For information on each possible USB device state, refer to the USB 2.0 specification. + * + * \see \ref USB_DeviceState, which stores the current device state machine state. + */ + enum USB_Device_States_t + { + DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates + * that the device is not currently connected to a host. + */ + DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates + * that the device is connected to a host, but enumeration has not + * yet begun. + */ + DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates + * that the device's USB bus has been reset by the host and it is + * now waiting for the host to begin the enumeration process. + */ + DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates + * that the device has been addressed by the USB Host, but is not + * yet configured. + */ + DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates + * that the device has been enumerated by the host and is ready + * for USB communications to begin. + */ + DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates + * that the USB bus has been suspended by the host, and the device + * should power down to a minimal power level until the bus is + * resumed. + */ + }; + + /* Function Prototypes: */ + /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value, + * index and language ID. This function MUST be overridden in the user application (added with full, identical + * prototype and name so that the library can call it to retrieve descriptor data. + * + * \param[in] wValue The type of the descriptor to retrieve in the upper byte, and the index in the + * lower byte (when more than one descriptor of the given type exists, such as the + * case of string descriptors). The type may be one of the standard types defined + * in the DescriptorTypes_t enum, or may be a class-specific descriptor type value. + * \param[in] wIndex The language ID of the string to return if the \c wValue type indicates + * \ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a + * class-specific standards. + * \param[out] DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to + * the address of the descriptor. + * \param[out] DescriptorMemorySpace A value from the \ref USB_DescriptorMemorySpaces_t enum to indicate the memory + * space in which the descriptor is stored. This parameter does not exist when one + * of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which + * use a unified address space. + * + * \note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute. + * If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to + * allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the + * \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D + * switch. + * + * \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise. + */ + uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + const void** const DescriptorAddress + #if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + , uint8_t* const DescriptorMemorySpace + #endif + ) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Device_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Device_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/Device_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.c new file mode 100644 index 000000000..c4ae64712 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.c @@ -0,0 +1,378 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#define __INCLUDE_FROM_DEVICESTDREQ_C +#include "DeviceStandardReq.h" + +uint8_t USB_Device_ConfigurationNumber; + +#if !defined(NO_DEVICE_SELF_POWER) +bool USB_Device_CurrentlySelfPowered; +#endif + +#if !defined(NO_DEVICE_REMOTE_WAKEUP) +bool USB_Device_RemoteWakeupEnabled; +#endif + +void USB_Device_ProcessControlRequest(void) +{ + #if defined(ARCH_BIG_ENDIAN) + USB_ControlRequest.bmRequestType = Endpoint_Read_8(); + USB_ControlRequest.bRequest = Endpoint_Read_8(); + USB_ControlRequest.wValue = Endpoint_Read_16_LE(); + USB_ControlRequest.wIndex = Endpoint_Read_16_LE(); + USB_ControlRequest.wLength = Endpoint_Read_16_LE(); + #else + uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest; + + for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++) + *(RequestHeader++) = Endpoint_Read_8(); + #endif + + EVENT_USB_Device_ControlRequest(); + + if (Endpoint_IsSETUPReceived()) + { + uint8_t bmRequestType = USB_ControlRequest.bmRequestType; + + switch (USB_ControlRequest.bRequest) + { + case REQ_GetStatus: + if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT))) + { + USB_Device_GetStatus(); + } + + break; + case REQ_ClearFeature: + case REQ_SetFeature: + if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))) + { + USB_Device_ClearSetFeature(); + } + + break; + case REQ_SetAddress: + if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_SetAddress(); + + break; + case REQ_GetDescriptor: + if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) || + (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE))) + { + USB_Device_GetDescriptor(); + } + + break; + case REQ_GetConfiguration: + if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_GetConfiguration(); + + break; + case REQ_SetConfiguration: + if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) + USB_Device_SetConfiguration(); + + break; + } + } + + if (Endpoint_IsSETUPReceived()) + { + Endpoint_StallTransaction(); + Endpoint_ClearSETUP(); + } +} + +static void USB_Device_SetAddress(void) +{ + uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F); + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + Endpoint_ClearSETUP(); + + Endpoint_ClearStatusStage(); + + while (!(Endpoint_IsINReady())); + + USB_Device_SetDeviceAddress(DeviceAddress); + USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; + + SetGlobalInterruptMask(CurrentGlobalInt); +} + +static void USB_Device_SetConfiguration(void) +{ + #if defined(FIXED_NUM_CONFIGURATIONS) + if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS) + return; + #else + USB_Descriptor_Device_t* DevDescriptorPtr; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) + #if defined(USE_FLASH_DESCRIPTORS) + #define MemoryAddressSpace MEMSPACE_FLASH + #elif defined(USE_EEPROM_DESCRIPTORS) + #define MemoryAddressSpace MEMSPACE_EEPROM + #elif defined(USE_SRAM_DESCRIPTORS) + #define MemoryAddressSpace MEMSPACE_SRAM + #else + uint8_t MemoryAddressSpace; + #endif + #endif + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + , &MemoryAddressSpace + #endif + ) == NO_DESCRIPTOR) + { + return; + } + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) + if (MemoryAddressSpace == MEMSPACE_FLASH) + { + if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) + return; + } + else if (MemoryAddressSpace == MEMSPACE_EEPROM) + { + if (((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations))) + return; + } + else + { + if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) + return; + } + #else + if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations) + return; + #endif + #endif + + Endpoint_ClearSETUP(); + + USB_Device_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue; + + Endpoint_ClearStatusStage(); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + EVENT_USB_Device_ConfigurationChanged(); +} + +static void USB_Device_GetConfiguration(void) +{ + Endpoint_ClearSETUP(); + + Endpoint_Write_8(USB_Device_ConfigurationNumber); + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); +} + +#if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) +static void USB_Device_GetInternalSerialDescriptor(void) +{ + struct + { + USB_Descriptor_Header_t Header; + uint16_t UnicodeString[INTERNAL_SERIAL_LENGTH_BITS / 4]; + } SignatureDescriptor; + + SignatureDescriptor.Header.Type = DTYPE_String; + SignatureDescriptor.Header.Size = USB_STRING_LEN(INTERNAL_SERIAL_LENGTH_BITS / 4); + + USB_Device_GetSerialString(SignatureDescriptor.UnicodeString); + + Endpoint_ClearSETUP(); + + Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor)); + Endpoint_ClearOUT(); +} +#endif + +static void USB_Device_GetDescriptor(void) +{ + const void* DescriptorPointer; + uint16_t DescriptorSize; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + uint8_t DescriptorAddressSpace; + #endif + + #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL)) + { + USB_Device_GetInternalSerialDescriptor(); + return; + } + #endif + + if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, + &DescriptorPointer + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + , &DescriptorAddressSpace + #endif + )) == NO_DESCRIPTOR) + { + return; + } + + Endpoint_ClearSETUP(); + + #if defined(USE_RAM_DESCRIPTORS) || !defined(ARCH_HAS_MULTI_ADDRESS_SPACE) + Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); + #elif defined(USE_EEPROM_DESCRIPTORS) + Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); + #elif defined(USE_FLASH_DESCRIPTORS) + Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); + #else + if (DescriptorAddressSpace == MEMSPACE_FLASH) + Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); + else if (DescriptorAddressSpace == MEMSPACE_EEPROM) + Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize); + else + Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); + #endif + + Endpoint_ClearOUT(); +} + +static void USB_Device_GetStatus(void) +{ + uint8_t CurrentStatus = 0; + + switch (USB_ControlRequest.bmRequestType) + { + case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE): + #if !defined(NO_DEVICE_SELF_POWER) + if (USB_Device_CurrentlySelfPowered) + CurrentStatus |= FEATURE_SELFPOWERED_ENABLED; + #endif + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + if (USB_Device_RemoteWakeupEnabled) + CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED; + #endif + break; + case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT): + #if !defined(CONTROL_ONLY_DEVICE) + Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); + + CurrentStatus = Endpoint_IsStalled(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + #endif + + break; + default: + return; + } + + Endpoint_ClearSETUP(); + + Endpoint_Write_16_LE(CurrentStatus); + Endpoint_ClearIN(); + + Endpoint_ClearStatusStage(); +} + +static void USB_Device_ClearSetFeature(void) +{ + switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) + { + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + case REQREC_DEVICE: + if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_DeviceRemoteWakeup) + USB_Device_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature); + else + return; + + break; + #endif + #if !defined(CONTROL_ONLY_DEVICE) + case REQREC_ENDPOINT: + if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_EndpointHalt) + { + uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK); + + if (EndpointIndex == ENDPOINT_CONTROLEP) + return; + + Endpoint_SelectEndpoint(EndpointIndex); + + if (Endpoint_IsEnabled()) + { + if (USB_ControlRequest.bRequest == REQ_SetFeature) + { + Endpoint_StallTransaction(); + } + else + { + Endpoint_ClearStall(); + Endpoint_ResetEndpoint(EndpointIndex); + Endpoint_ResetDataToggle(); + } + } + } + + break; + #endif + default: + return; + } + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + Endpoint_ClearSETUP(); + + Endpoint_ClearStatusStage(); +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.h new file mode 100644 index 000000000..dfaa1662e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/DeviceStandardReq.h @@ -0,0 +1,158 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB device standard request management. + * + * This file contains the function prototypes necessary for the processing of incoming standard control requests + * when the library is in USB device mode. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __DEVICESTDREQ_H__ +#define __DEVICESTDREQ_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "StdDescriptors.h" + #include "Events.h" + #include "StdRequestType.h" + #include "USBTask.h" + #include "USBController.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__) + /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the + * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS + * compile time options are used, to indicate in which memory space the descriptor is stored. + * + * \ingroup Group_Device + */ + enum USB_DescriptorMemorySpaces_t + { + #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__) + MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory. */ + #endif + #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__) + MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */ + #endif + MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory. */ + }; + #endif + + /* Global Variables: */ + /** Indicates the currently set configuration number of the device. USB devices may have several + * different configurations which the host can select between; this indicates the currently selected + * value, or 0 if no configuration has been selected. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \ingroup Group_Device + */ + extern uint8_t USB_Device_ConfigurationNumber; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this + * flag is cleared, the device should not issue remote wakeup events to the host. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported, + * this global and the underlying management code can be disabled by defining the + * \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via + * the -D switch. + * + * \ingroup Group_Device + */ + extern bool USB_Device_RemoteWakeupEnabled; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + /** Indicates if the device is currently being powered by its own power supply, rather than being + * powered by the host's USB supply. This flag should remain cleared if the device does not + * support self powered mode, as indicated in the device descriptors. + * + * \ingroup Group_Device + */ + extern bool USB_Device_CurrentlySelfPowered; + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) + #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS) + #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive. + #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) + #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS) + #error Only one of the USE_*_DESCRIPTORS modes should be selected. + #endif + + /* Function Prototypes: */ + void USB_Device_ProcessControlRequest(void); + + #if defined(__INCLUDE_FROM_DEVICESTDREQ_C) + static void USB_Device_SetAddress(void); + static void USB_Device_SetConfiguration(void); + static void USB_Device_GetConfiguration(void); + static void USB_Device_GetDescriptor(void); + static void USB_Device_GetStatus(void); + static void USB_Device_ClearSetFeature(void); + + #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + static void USB_Device_GetInternalSerialDescriptor(void); + #endif + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Endpoint.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Endpoint.h new file mode 100644 index 000000000..a6ca64dd2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Endpoint.h @@ -0,0 +1,130 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Endpoint definitions for all architectures. + * \copydetails Group_EndpointManagement + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointRW Endpoint Data Reading and Writing + * \brief Endpoint data read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointPrimitiveRW Read/Write of Primitive Data Types + * \brief Endpoint data primitive read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to endpoints. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointPacketManagement Endpoint Packet Management + * \brief USB Endpoint package management definitions. + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_USB + * \defgroup Group_EndpointManagement Endpoint Management + * \brief Endpoint management definitions. + * + * Functions, macros and enums related to endpoint management when in USB Device mode. This + * module contains the endpoint management macros, as well as endpoint interrupt and data + * send/receive functions for various data types. + * + * @{ + */ + +#ifndef __ENDPOINT_H__ +#define __ENDPOINT_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** Type define for a endpoint table entry, used to configure endpoints in groups via + * \ref Endpoint_ConfigureEndpointTable(). + */ + typedef struct + { + uint8_t Address; /**< Address of the endpoint to configure, or zero if the table entry is to be unused. */ + uint16_t Size; /**< Size of the endpoint bank, in bytes. */ + uint8_t Type; /**< Type of the endpoint, a \c EP_TYPE_* mask. */ + uint8_t Banks; /**< Number of hardware banks to use for the endpoint. */ + } USB_Endpoint_Table_t; + + /* Macros: */ + /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's + * numerical address in the device. + */ + #define ENDPOINT_EPNUM_MASK 0x0F + + /** Endpoint address for the default control endpoint, which always resides in address 0. This is + * defined for convenience to give more readable code when used with the endpoint macros. + */ + #define ENDPOINT_CONTROLEP 0 + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Endpoint_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Endpoint_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/Endpoint_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/EndpointStream.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/EndpointStream.h new file mode 100644 index 000000000..89df381ae --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/EndpointStream.h @@ -0,0 +1,124 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endpoint data stream transmission and reception management. + * \copydetails Group_EndpointStreamRW + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams + * \brief Endpoint data stream transmission and reception management. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to endpoints. + * + * @{ + */ + +#ifndef __ENDPOINT_STREAM_H__ +#define __ENDPOINT_STREAM_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */ + enum Endpoint_Stream_RW_ErrorCodes_t + { + ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */ + ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream + * transfer by the host or device. + */ + ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during + * the transfer. + */ + ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before + * the complete contents of the current stream could be + * transferred. The endpoint stream function should be called + * again to process the next chunk of data in the transfer. + */ + }; + + /** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */ + enum Endpoint_ControlStream_RW_ErrorCodes_t + { + ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */ + ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */ + ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during + * the transfer. + */ + ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and + * no USB endpoint traffic can occur until the bus + * has resumed. + */ + }; + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/EndpointStream_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/EndpointStream_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/EndpointStream_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.c new file mode 100644 index 000000000..5f5043060 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.c @@ -0,0 +1,40 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_EVENTS_C +#define __INCLUDE_FROM_USB_DRIVER +#include "Events.h" + +// cppcheck-suppress unusedFunction +void USB_Event_Stub(void) +{ + +} + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.h new file mode 100644 index 000000000..33db543d4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Events.h @@ -0,0 +1,366 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Event management definitions. + * \copydetails Group_Events + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_Events USB Events + * \brief USB Event management definitions. + * + * This module contains macros and functions relating to the management of library events, which are small + * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from + * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler + * should be written to be as small and fast as possible to prevent possible problems. + * + * Events can be hooked by the user application by declaring a handler function with the same name and parameters + * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an + * internal empty stub function. + * + * Each event must only have one associated event handler, but can be raised by multiple sources by calling the + * event handler function (with any required event parameters). + * + * @{ + */ + +#ifndef __USBEVENTS_H__ +#define __USBEVENTS_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Pseudo-Functions for Doxygen: */ + #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__) + /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role + * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires + * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect + * event has fired (if disconnected before the role change). + * + * \note This event only exists on microcontrollers that support dual role USB modes. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY tokens have been supplied + * to the compiler (see \ref Group_USBManagement documentation). + */ + void EVENT_USB_UIDChange(void); + + /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB + * interface is in host mode. + * + * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); + + /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and + * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before + * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB + * management task to reduce CPU consumption. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * + * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Host_DeviceAttached(void); + + /** Event for USB device removal. This event fires when a the USB interface is in host mode, and + * a USB device has been removed the USB interface whether or not it has been enumerated. This + * can be used to programmatically stop the USB management task to reduce CPU consumption. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * + * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Host_DeviceUnattached(void); + + /** Event for USB device enumeration failure. This event fires when a the USB interface is + * in host mode, and an attached USB device has failed to enumerate completely. + * + * \param[in] ErrorCode Error code indicating the failure reason, a value in + * \ref USB_Host_EnumerationErrorCodes_t. + * + * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the + * ErrorCode parameter indicates a control error, this will give the error + * code returned by the \ref USB_Host_SendControlRequest() function. + * + * \note This event only exists on microcontrollers that supports USB host mode. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, + const uint8_t SubErrorCode); + + /** Event for USB device enumeration completion. This event fires when a the USB interface is + * in host mode and an attached USB device has been completely enumerated and is ready to be + * controlled by the user application. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * 1 second) when a transaction is waiting to be processed by the device will prevent break communications + * and cause the host to reset the USB bus. + */ + void EVENT_USB_Host_DeviceEnumerationComplete(void); + + /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB + * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate + * millisecond timer source when the USB bus is not suspended while in host mode. + * + * This event is time-critical; it is run once per millisecond and thus long handlers will significantly + * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. + * + * \note This event is not normally active - it must be manually enabled and disabled via the + * \ref USB_Host_EnableSOFEvents() and \ref USB_Host_DisableSOFEvents() commands after enumeration of + * a USB device. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_StartOfFrame(void); + + /** Event for USB device connection. This event fires when the microcontroller is in USB Device mode + * and the device is connected to a USB host, beginning the enumeration process measured by a rising + * level on the microcontroller's VBUS sense pin. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * two seconds) will prevent the device from enumerating correctly. + * + * \attention This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers + * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. + * + * \note For the microcontrollers with limited USB controller functionality, VBUS sensing is not available. + * this means that the current connection state is derived from the bus suspension and wake up events by default, + * which is not always accurate (host may suspend the bus while still connected). If the actual connection state + * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behavior turned off by + * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection + * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. + * \n\n + * + * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Device_Connect(void); + + /** Event for USB device disconnection. This event fires when the microcontroller is in USB Device mode and the device is + * disconnected from a host, measured by a falling level on the microcontroller's VBUS sense pin. + * + * \attention This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers + * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. + * + * \note For the microcontrollers with limited USB controllers, VBUS sense is not available to the USB controller. + * this means that the current connection state is derived from the bus suspension and wake up events by default, + * which is not always accurate (host may suspend the bus while still connected). If the actual connection state + * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behavior turned off by + * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection + * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. + * \n\n + * + * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. + */ + void EVENT_USB_Device_Disconnect(void); + + /** Event for control requests. This event fires when a the USB host issues a control request + * to the mandatory device control endpoint (of address 0). This may either be a standard + * request that the library may have a handler code for internally, or a class specific request + * issued to the device which must be handled appropriately. If a request is not processed in the + * user application via this event, it will be passed to the library for processing internally + * if a suitable handler exists. + * + * This event is time-critical; each packet within the request transaction must be acknowledged or + * sent within 50ms or the host will abort the transfer. + * + * The library internally handles all standard control requests with the exceptions of SYNC FRAME, + * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left + * for the user to process via this event if desired. If not handled in the user application or by + * the library internally, unknown requests are automatically STALLed. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note Requests should be handled in the same manner as described in the USB 2.0 Specification, + * or appropriate class specification. In all instances, the library has already read the + * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used + * by the application to determine how to handle the issued request. + */ + void EVENT_USB_Device_ControlRequest(void); + + /** Event for USB configuration number changed. This event fires when a the USB host changes the + * selected configuration number while in device mode. This event should be hooked in device + * applications to create the endpoints and configure the device for the selected configuration. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * one second) will prevent the device from enumerating correctly. + * + * This event fires after the value of \ref USB_Device_ConfigurationNumber has been changed. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Device_ConfigurationChanged(void); + + /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its + * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move + * the device over to a low power state until the host wakes up the device. If the USB interface is + * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the + * USB PLL before the event is fired to save power. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities + * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see + * \ref EVENT_USB_Device_Disconnect. + * + * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event. + */ + void EVENT_USB_Device_Suspend(void); + + /** Event for USB wake up. This event fires when a the USB interface is suspended while in device + * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally + * hooked to pull the user application out of a low power state and back into normal operating + * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library + * will automatically restart the USB PLL before the event is fired. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + * \n\n + * + * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities + * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see + * \ref EVENT_USB_Device_Disconnect. + * + * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event. + */ + void EVENT_USB_Device_WakeUp(void); + + /** Event for USB interface reset. This event fires when the USB interface is in device mode, and + * a the USB host requests that the device reset its interface. This event fires after the control + * endpoint has been automatically configured by the library. + * + * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around + * two seconds) will prevent the device from enumerating correctly. + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Device_Reset(void); + + /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB + * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate + * millisecond timer source when the USB bus is enumerated in device mode to a USB host. + * + * This event is time-critical; it is run once per millisecond and thus long handlers will significantly + * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. + * + * \pre This event is not normally active - it must be manually enabled and disabled via the + * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration. + * \n\n + * + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Device_StartOfFrame(void); + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_EVENTS_C) + void USB_Event_Stub(void) ATTR_CONST; + + #if defined(USB_CAN_BE_BOTH) + void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + #endif + + #if defined(USB_CAN_BE_HOST) + void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, + const uint8_t SubErrorCode) + ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + #endif + + #if defined(USB_CAN_BE_DEVICE) + void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_ControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + #endif + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Host.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Host.h new file mode 100644 index 000000000..bf2225f31 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Host.h @@ -0,0 +1,139 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Host definitions for all architectures. + * \copydetails Group_Host + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_Host Host Management + * \brief USB Host management definitions for USB host mode. + * + * USB Host mode related macros and enums. This module contains macros and enums which are used when + * the USB controller is initialized in host mode. + * + * @{ + */ + +#ifndef __USBHOST_H__ +#define __USBHOST_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the various states of the USB Host state machine. + * + * For information on each possible USB host state, refer to the USB 2.0 specification. + * Several of the USB host states are broken up further into multiple smaller sub-states, + * so that they can be internally implemented inside the library in an efficient manner. + * + * \see \ref USB_HostState, which stores the current host state machine state. + */ + enum USB_Host_States_t + { + HOST_STATE_WaitForDevice = 0, /**< This state indicates that the stack is waiting for an interval + * to elapse before continuing with the next step of the device + * enumeration process. + */ + HOST_STATE_Unattached = 1, /**< This state indicates that the host state machine is waiting for + * a device to be attached so that it can start the enumeration process. + */ + HOST_STATE_Powered = 2, /**< This state indicates that a device has been attached, and the + * library's internals are being configured to begin the enumeration + * process. + */ + HOST_STATE_Powered_WaitForDeviceSettle = 3, /**< This state indicates that the stack is waiting for the initial + * settling period to elapse before beginning the enumeration process. + */ + HOST_STATE_Powered_WaitForConnect = 4, /**< This state indicates that the stack is waiting for a connection event + * from the USB controller to indicate a valid USB device has been attached + * to the bus and is ready to be enumerated. + */ + HOST_STATE_Powered_DoReset = 5, /**< This state indicates that a valid USB device has been attached, and that + * it will now be reset to ensure it is ready for enumeration. + */ + HOST_STATE_Powered_ConfigPipe = 6, /**< This state indicates that the attached device is currently powered and + * reset, and that the control pipe is now being configured by the stack. + */ + HOST_STATE_Default = 7, /**< This state indicates that the stack is currently retrieving the control + * endpoint's size from the device, so that the control pipe can be altered + * to match. + */ + HOST_STATE_Default_PostReset = 8, /**< This state indicates that the control pipe is being reconfigured to match + * the retrieved control endpoint size from the device, and the device's USB + * bus address is being set. + */ + HOST_STATE_Default_PostAddressSet = 9, /**< This state indicates that the device's address has now been set, and the + * stack is has now completed the device enumeration process. This state causes + * the stack to change the current USB device address to that set for the + * connected device, before progressing to the \ref HOST_STATE_Addressed state + * ready for use in the user application. + */ + HOST_STATE_Addressed = 10, /**< Indicates that the device has been enumerated and addressed, and is now waiting + * for the user application to configure the device ready for use. + */ + HOST_STATE_Configured = 11, /**< Indicates that the device has been configured into a valid device configuration, + * ready for general use by the user application. + */ + }; + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Host_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Host_UC3.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.c new file mode 100644 index 000000000..3242822f7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.c @@ -0,0 +1,322 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HOSTSTDREQ_C +#include "HostStandardReq.h" + +uint8_t USB_Host_ConfigurationNumber; + +static uint8_t USB_Host_SendControlRequest_PRV(void* const BufferPtr) +{ + uint8_t* DataStream = (uint8_t*)BufferPtr; + uint8_t ReturnStatus = HOST_SENDCONTROL_Successful; + uint16_t DataLen = USB_ControlRequest.wLength; + + USB_Host_ResumeBus(); + + if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + return ReturnStatus; + + Pipe_SetPipeToken(PIPE_TOKEN_SETUP); + Pipe_ClearError(); + + Pipe_Unfreeze(); + + #if defined(ARCH_BIG_ENDIAN) + Pipe_Write_8(USB_ControlRequest.bmRequestType); + Pipe_Write_8(USB_ControlRequest.bRequest); + Pipe_Write_16_LE(USB_ControlRequest.wValue); + Pipe_Write_16_LE(USB_ControlRequest.wIndex); + Pipe_Write_16_LE(USB_ControlRequest.wLength); + #else + uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest; + + for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Request_Header_t); HeaderByte++) + Pipe_Write_8(*(HeaderStream++)); + #endif + + Pipe_ClearSETUP(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful) + return ReturnStatus; + + Pipe_Freeze(); + + if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + return ReturnStatus; + + 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) + return ReturnStatus; + + if (!(Pipe_BytesInPipe())) + DataLen = 0; + + while (Pipe_BytesInPipe() && DataLen) + { + *(DataStream++) = Pipe_Read_8(); + DataLen--; + } + + Pipe_Freeze(); + Pipe_ClearIN(); + } + } + + Pipe_SetPipeToken(PIPE_TOKEN_OUT); + Pipe_Unfreeze(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + return ReturnStatus; + + Pipe_ClearOUT(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + return ReturnStatus; + } + 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) + return ReturnStatus; + + while (DataLen && (Pipe_BytesInPipe() < USB_Host_ControlPipeSize)) + { + Pipe_Write_8(*(DataStream++)); + DataLen--; + } + + Pipe_ClearOUT(); + } + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful) + return ReturnStatus; + + Pipe_Freeze(); + } + + Pipe_SetPipeToken(PIPE_TOKEN_IN); + Pipe_Unfreeze(); + + if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful) + return ReturnStatus; + + Pipe_ClearIN(); + } + + return ReturnStatus; +} + +static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType) +{ + #if (USB_HOST_TIMEOUT_MS < 0xFF) + uint8_t TimeoutCounter = USB_HOST_TIMEOUT_MS; + #else + uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS; + #endif + + while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSETUPSent()) || + ((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsINReceived()) || + ((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsOUTReady()))) + { + uint8_t ErrorCode; + + if ((ErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + return ErrorCode; + + if (!(TimeoutCounter--)) + return HOST_SENDCONTROL_SoftwareTimeOut; + } + + return HOST_SENDCONTROL_Successful; +} + +uint8_t USB_Host_SendControlRequest(void* const BufferPtr) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + uint8_t ReturnStatus = USB_Host_SendControlRequest_PRV(BufferPtr); + + Pipe_Freeze(); + + if (BusSuspended) + USB_Host_SuspendBus(); + + Pipe_ResetPipe(PIPE_CONTROLPIPE); + + return ReturnStatus; +} + +uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber) +{ + uint8_t ErrorCode; + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_SetConfiguration, + .wValue = ConfigNumber, + .wIndex = 0, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) == HOST_SENDCONTROL_Successful) + { + USB_Host_ConfigurationNumber = ConfigNumber; + USB_HostState = (ConfigNumber) ? HOST_STATE_Configured : HOST_STATE_Addressed; + } + + return ErrorCode; +} + +uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetConfiguration, + .wValue = 0, + .wIndex = 0, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(ConfigNumber); +} + +uint8_t USB_Host_GetDescriptor(const uint8_t Type, + const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetDescriptor, + .wValue = (((uint16_t)Type << 8) | Index), + .wIndex = 0, + .wLength = BufferLength, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(Buffer); +} + +uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_GetStatus, + .wValue = 0, + .wIndex = 0, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(FeatureStatus); +} + +uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT), + .bRequest = REQ_ClearFeature, + .wValue = FEATURE_SEL_EndpointHalt, + .wIndex = EndpointAddress, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, + const uint8_t AltSetting) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_SetInterface, + .wValue = AltSetting, + .wIndex = InterfaceIndex, + .wLength = 0, + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(NULL); +} + +uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, + uint8_t* const AltSetting) +{ + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), + .bRequest = REQ_GetInterface, + .wValue = 0, + .wIndex = InterfaceIndex, + .wLength = sizeof(uint8_t), + }; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + return USB_Host_SendControlRequest(AltSetting); +} + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.h new file mode 100644 index 000000000..cdfb35470 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/HostStandardReq.h @@ -0,0 +1,292 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB host standard request management. + * + * This file contains the function prototypes necessary for the issuing of outgoing standard control requests + * when the library is in USB host mode. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __HOSTSTDREQ_H__ +#define __HOSTSTDREQ_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "StdRequestType.h" + #include "USBController.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__) + /** Constant for the maximum software timeout period of sent USB control transactions to an attached + * device. If a device fails to respond to a sent control request within this period, the + * library will return a timeout error code. + * + * This value may be overridden in the user project makefile as the value of the + * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch. + */ + #define USB_HOST_TIMEOUT_MS 1000 + #endif + + /* Enums: */ + /** Enum for the \ref USB_Host_SendControlRequest() return code, indicating the reason for the error + * if the transfer of the request is unsuccessful. + * + * \ingroup Group_PipeControlReq + */ + enum USB_Host_SendControlErrorCodes_t + { + HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */ + HOST_SENDCONTROL_DeviceDisconnected = 1, /**< The attached device was disconnected during the + * request transfer. + */ + HOST_SENDCONTROL_PipeError = 2, /**< An error occurred in the pipe while sending the request. */ + HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually + * indicating that the request is unsupported on the device. + */ + HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */ + }; + + /* Global Variables: */ + /** Indicates the currently set configuration number of the attached device. This indicates the currently + * selected configuration value if one has been set successfully, or 0 if no configuration has been selected. + * + * To set a device configuration, call the \ref USB_Host_SetDeviceConfiguration() function. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \ingroup Group_Host + */ + extern uint8_t USB_Host_ConfigurationNumber; + + /* Function Prototypes: */ + /** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device, + * and transfers the data stored in the buffer to the device, or from the device to the buffer + * as requested. The transfer is made on the currently selected pipe. + * + * \ingroup Group_PipeControlReq + * + * \param[in] BufferPtr Pointer to the start of the data buffer if the request has a data stage, or + * \c NULL if the request transfers no data to or from the device. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SendControlRequest(void* const BufferPtr); + + /** Sends a SET CONFIGURATION standard request to the attached device, with the given configuration index. + * + * This routine will automatically update the \ref USB_HostState and \ref USB_Host_ConfigurationNumber + * state variables according to the given function parameters and the result of the request. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] ConfigNumber Configuration index to send to the device. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber); + + /** Sends a GET CONFIGURATION standard request to the attached device, to retrieve the currently selected + * device configuration index. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] ConfigNumber Pointer to a location where the retrieved configuration index should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) ATTR_NON_NULL_PTR_ARG(1); + + /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the descriptor of the + * specified type and index. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] Type Type of descriptor to retrieve, a value from the \ref USB_DescriptorTypes_t enum. + * \param[in] Index Index of the descriptor to retrieve. + * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is to be stored. + * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDescriptor(const uint8_t Type, + const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(3); + + /** Retrieves the current feature status of the attached device, via a GET STATUS standard request. The + * retrieved feature status can then be examined by masking the retrieved value with the various + * \c FEATURE_* masks for bus/self power information and remote wakeup support. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] FeatureStatus Location where the retrieved feature status should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) ATTR_NON_NULL_PTR_ARG(1); + + /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] EndpointAddress Address of the endpoint to clear, including the endpoint's direction. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress); + + /** Selects a given alternative setting for the specified interface, via a SET INTERFACE standard request to + * the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. + * \param[in] AltSetting Index of the interface's alternative setting which is to be selected. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex, + const uint8_t AltSetting); + + + /** Retrieves the current alternative setting for the specified interface, via a GET INTERFACE standard request to + * the attached device. + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered. + * \param[out] AltSetting Pointer to a location where the retrieved alternative setting value should be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex, + uint8_t* const AltSetting) ATTR_NON_NULL_PTR_ARG(2); + + /* Inline Functions: */ + /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the device descriptor. + * This can be used to easily retrieve information about the device such as its VID, PID and power + * requirements. This is a convenience wrapper for \ref USB_Host_GetDescriptor(). + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where + * the read data is to be stored. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) ATTR_NON_NULL_PTR_ARG(1); + static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) + { + return USB_Host_GetDescriptor(DTYPE_Device, 0, DeviceDescriptorPtr, sizeof(USB_Descriptor_Device_t)); + } + + /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the string descriptor + * of the specified index. This can be used to easily retrieve string descriptors from the device by + * index, after the index is obtained from the Device or Configuration descriptors. This is a convenience + * wrapper for \ref USB_Host_GetDescriptor(). + * + * \note After this routine returns, the control pipe will be selected. + * + * \ingroup Group_PipeControlReq + * + * \param[in] Index Index of the string descriptor to retrieve. + * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is + * to be stored. + * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer. + * + * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result. + */ + static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(2); + static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index, + void* const Buffer, + const uint8_t BufferLength) + { + return USB_Host_GetDescriptor(DTYPE_String, Index, Buffer, BufferLength); + } + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Enums: */ + enum USB_WaitForTypes_t + { + USB_HOST_WAITFOR_SetupSent, + USB_HOST_WAITFOR_InReceived, + USB_HOST_WAITFOR_OutReady, + }; + + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_HOSTSTDREQ_C) + static uint8_t USB_Host_SendControlRequest_PRV(void* const BufferPtr); + 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/OTG.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/OTG.h new file mode 100644 index 000000000..ccd7cc1be --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/OTG.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB OTG definitions for all architectures. + * \copydetails Group_OTG + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_OTG USB On The Go (OTG) Management + * \brief USB OTG management definitions. + * + * This module contains macros for embedded USB hosts with dual role On The Go capabilities, for managing role + * exchange. OTG is a way for two USB dual role devices to talk to one another directly without fixed device/host + * roles. + * + * @{ + */ + +#ifndef __USBOTG_H__ +#define __USBOTG_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/OTG_AVR8.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Pipe.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Pipe.h new file mode 100644 index 000000000..ce2be5492 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/Pipe.h @@ -0,0 +1,144 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Pipe definitions for all architectures. + * \copydetails Group_PipeManagement + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeRW Pipe Data Reading and Writing + * \brief Pipe data read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types + * \brief Pipe data primitive read/write definitions. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to pipes. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipePacketManagement Pipe Packet Management + * \brief Pipe packet management definitions. + * + * Functions, macros, variables, enums and types related to packet management of pipes. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeControlReq Pipe Control Request Management + * \brief Pipe control request definitions. + * + * Module for host mode request processing. This module allows for the transmission of standard, class and + * vendor control requests to the default control endpoint of an attached device while in host mode. + * + * \see Chapter 9 of the USB 2.0 specification. + */ + +/** \ingroup Group_USB + * \defgroup Group_PipeManagement Pipe Management + * \brief Pipe management definitions. + * + * This module contains functions, macros and enums related to pipe management when in USB Host mode. This + * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions + * for various data types. + * + * @{ + */ + +#ifndef __PIPE_H__ +#define __PIPE_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Type Defines: */ + /** Type define for a pipe table entry, used to configure pipes in groups via + * \ref Pipe_ConfigurePipeTable(). + */ + typedef struct + { + uint8_t Address; /**< Address of the pipe to configure, or zero if the table entry is to be unused. */ + uint16_t Size; /**< Size of the pipe bank, in bytes. */ + uint8_t EndpointAddress; /** Address of the endpoint in the connected device. */ + uint8_t Type; /**< Type of the endpoint, a \c EP_TYPE_* mask. */ + uint8_t Banks; /**< Number of hardware banks to use for the pipe. */ + } USB_Pipe_Table_t; + + /* Macros: */ + /** Pipe address for the default control pipe, which always resides in address 0. This is + * defined for convenience to give more readable code when used with the pipe macros. + */ + #define PIPE_CONTROLPIPE 0 + + /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address + * in the device. + */ + #define PIPE_PIPENUM_MASK 0x0F + + /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's + * numerical address in the attached device. + */ + #define PIPE_EPNUM_MASK 0x0F + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/Pipe_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/Pipe_UC3.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/PipeStream.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/PipeStream.h new file mode 100644 index 000000000..002d6ff1e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/PipeStream.h @@ -0,0 +1,100 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Pipe data stream transmission and reception management. + * \copydetails Group_PipeStreamRW + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams + * \brief Pipe data stream transmission and reception management. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to pipes. + * + * @{ + */ + +#ifndef __PIPE_STREAM_H__ +#define __PIPE_STREAM_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Enums: */ + /** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */ + enum Pipe_Stream_RW_ErrorCodes_t + { + PIPE_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */ + PIPE_RWSTREAM_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */ + PIPE_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during + * the transfer. + */ + PIPE_RWSTREAM_Timeout = 3, /**< The device failed to accept or send the next packet + * within the software timeout period set by the + * \ref USB_STREAM_TIMEOUT_MS macro. + */ + PIPE_RWSTREAM_IncompleteTransfer = 4, /**< Indicates that the pipe bank became full/empty before the + * complete contents of the stream could be transferred. + */ + }; + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/PipeStream_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/PipeStream_UC3.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdDescriptors.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdDescriptors.h new file mode 100644 index 000000000..012399e96 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdDescriptors.h @@ -0,0 +1,739 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common standard USB Descriptor definitions for all architectures. + * \copydetails Group_StdDescriptors + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_StdDescriptors USB Descriptors + * \brief Standard USB Descriptor definitions. + * + * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains + * structures and macros for the easy creation of standard USB descriptors in USB device projects. + * + * @{ + */ + +#ifndef __USBDESCRIPTORS_H__ +#define __USBDESCRIPTORS_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "Events.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors + * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified + * descriptor does not exist. + */ + #define NO_DESCRIPTOR 0 + + /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. + * + * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected. + */ + #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1) + + /** Macro to calculate the Unicode length of a string with a given number of Unicode characters. + * Should be used in string descriptor's headers for giving the string descriptor's byte length. + * + * \param[in] UnicodeChars Number of Unicode characters in the string text. + */ + #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1)) + + /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded + * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the + * standard device descriptor. + * + * \note This value is automatically converted into Little Endian, suitable for direct use inside device + * descriptors on all architectures without endianness conversion macros. + * + * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number. + */ + #define VERSION_BCD(x) CPU_TO_LE16((VERSION_TENS(x) << 12) | (VERSION_ONES(x) << 8) | \ + (VERSION_TENTHS(x) << 4) | (VERSION_HUNDREDTHS(x) << 0) ) + + /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors + * to indicate that the English language is supported by the device in its string descriptors. + */ + #define LANGUAGE_ID_ENG 0x0409 + + /** \name USB Configuration Descriptor Attribute Masks */ + //@{ + /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all + * devices for historical purposes. + */ + #define USB_CONFIG_ATTR_RESERVED 0x80 + + /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t + * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power + * from the device's own power source. + */ + #define USB_CONFIG_ATTR_SELFPOWERED 0x40 + + /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t + * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the + * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon + * request. + */ + #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20 + //@} + + /** \name Endpoint Descriptor Attribute Masks */ + //@{ + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is not synchronized. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_NO_SYNC (0 << 2) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is asynchronous. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_ASYNC (1 << 2) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is adaptive. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_ADAPTIVE (2 << 2) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is synchronized. + * + * \see The USB specification for more details on the possible Endpoint attributes. + */ + #define ENDPOINT_ATTR_SYNC (3 << 2) + //@} + + /** \name Endpoint Descriptor Usage Masks */ + //@{ + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is used for data transfers. + * + * \see The USB specification for more details on the possible Endpoint usage attributes. + */ + #define ENDPOINT_USAGE_DATA (0 << 4) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is used for feedback. + * + * \see The USB specification for more details on the possible Endpoint usage attributes. + */ + #define ENDPOINT_USAGE_FEEDBACK (1 << 4) + + /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's + * \c Attributes value to indicate that the specified endpoint is used for implicit feedback. + * + * \see The USB specification for more details on the possible Endpoint usage attributes. + */ + #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4) + //@} + + /* Enums: */ + /** Enum for the possible standard descriptor types, as given in each descriptor's header. */ + enum USB_DescriptorTypes_t + { + DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */ + DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */ + DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */ + DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */ + DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */ + DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */ + DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */ + DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */ + DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */ + DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */ + DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */ + }; + + /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */ + enum USB_Descriptor_ClassSubclassProtocol_t + { + USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong + * to a particular class at the device level. + */ + USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong + * to a particular subclass at the device level. + */ + USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong + * to a particular protocol at the device level. + */ + USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs + * to a vendor specific class. + */ + USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs + * to a vendor specific subclass. + */ + USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs + * to a vendor specific protocol. + */ + USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the + * Interface Association Descriptor class. + */ + USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the + * Interface Association Descriptor subclass. + */ + USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the + * Interface Association Descriptor protocol. + */ + }; + + /* Type Defines: */ + /** \brief Standard USB Descriptor Header (LUFA naming conventions). + * + * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure + * uses LUFA-specific element names to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t Size; /**< Size of the descriptor, in bytes. */ + uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + } ATTR_PACKED USB_Descriptor_Header_t; + + /** \brief Standard USB Descriptor Header (USB-IF naming conventions). + * + * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure + * uses the relevant standard's given element names to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + } ATTR_PACKED USB_StdDescriptor_Header_t; + + /** \brief Standard USB Device Descriptor (LUFA naming conventions). + * + * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each + * element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint16_t USBSpecification; /**< BCD of the supported USB specification. */ + uint8_t Class; /**< USB device class. */ + uint8_t SubClass; /**< USB device subclass. */ + uint8_t Protocol; /**< USB device protocol. */ + + uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */ + + uint16_t VendorID; /**< Vendor ID for the USB product. */ + uint16_t ProductID; /**< Unique product ID for the USB product. */ + uint16_t ReleaseNumber; /**< Product release (version) number. */ + + uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The + * host will request this string via a separate + * control request for the string descriptor. + * + * \note If no string supplied, use \ref NO_DESCRIPTOR. + */ + uint8_t ProductStrIndex; /**< String index for the product name/details. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal + * serial number, in uppercase Unicode ASCII. + * + * \note On some microcontroller models, there is an embedded serial number + * in the chip which can be used for the device serial number. + * To use this serial number, set this to USE_INTERNAL_SERIAL. + * On unsupported devices, this will evaluate to 0 and will cause + * the host to generate a pseudo-unique value for the device upon + * insertion. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t NumberOfConfigurations; /**< Total number of configurations supported by + * the device. + */ + } ATTR_PACKED USB_Descriptor_Device_t; + + /** \brief Standard USB Device Descriptor (USB-IF naming conventions). + * + * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint16_t bcdUSB; /**< BCD of the supported USB specification. */ + uint8_t bDeviceClass; /**< USB device class. */ + uint8_t bDeviceSubClass; /**< USB device subclass. */ + uint8_t bDeviceProtocol; /**< USB device protocol. */ + uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */ + uint16_t idVendor; /**< Vendor ID for the USB product. */ + uint16_t idProduct; /**< Unique product ID for the USB product. */ + uint16_t bcdDevice; /**< Product release (version) number. */ + uint8_t iManufacturer; /**< String index for the manufacturer's name. The + * host will request this string via a separate + * control request for the string descriptor. + * + * \note If no string supplied, use \ref NO_DESCRIPTOR. + */ + uint8_t iProduct; /**< String index for the product name/details. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal + * serial number, in uppercase Unicode ASCII. + * + * \note On some microcontroller models, there is an embedded serial number + * in the chip which can be used for the device serial number. + * To use this serial number, set this to USE_INTERNAL_SERIAL. + * On unsupported devices, this will evaluate to 0 and will cause + * the host to generate a pseudo-unique value for the device upon + * insertion. + * + * \see ManufacturerStrIndex structure entry. + */ + uint8_t bNumConfigurations; /**< Total number of configurations supported by + * the device. + */ + } ATTR_PACKED USB_StdDescriptor_Device_t; + + /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions). + * + * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint16_t USBSpecification; /**< BCD of the supported USB specification. */ + uint8_t Class; /**< USB device class. */ + uint8_t SubClass; /**< USB device subclass. */ + uint8_t Protocol; /**< USB device protocol. */ + + uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */ + uint8_t NumberOfConfigurations; /**< Total number of configurations supported by + * the device. + */ + uint8_t Reserved; /**< Reserved for future use, must be 0. */ + } ATTR_PACKED USB_Descriptor_DeviceQualifier_t; + + /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions). + * + * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint16_t bcdUSB; /**< BCD of the supported USB specification. */ + uint8_t bDeviceClass; /**< USB device class. */ + uint8_t bDeviceSubClass; /**< USB device subclass. */ + uint8_t bDeviceProtocol; /**< USB device protocol. */ + uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */ + uint8_t bNumConfigurations; /**< Total number of configurations supported by + * the device. + */ + uint8_t bReserved; /**< Reserved for future use, must be 0. */ + } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t; + + /** \brief Standard USB Configuration Descriptor (LUFA naming conventions). + * + * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header, + * and all sub descriptors inside the configuration. + */ + uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */ + + uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */ + uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */ + + uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. + * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. + */ + + uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the + * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() + * macro. + */ + } ATTR_PACKED USB_Descriptor_Configuration_Header_t; + + /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions). + * + * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint16_t wTotalLength; /**< Size of the configuration descriptor header, + * and all sub descriptors inside the configuration. + */ + uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */ + uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */ + uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */ + uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks. + * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum. + */ + uint8_t bMaxPower; /**< Maximum power consumption of the device while in the + * current configuration, calculated by the \ref USB_CONFIG_POWER_MA() + * macro. + */ + } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t; + + /** \brief Standard USB Interface Descriptor (LUFA naming conventions). + * + * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */ + uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same + * interface number can have multiple alternate settings + * with different endpoint configurations, which can be + * selected by the host. + */ + uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */ + + uint8_t Class; /**< Interface class ID. */ + uint8_t SubClass; /**< Interface subclass ID. */ + uint8_t Protocol; /**< Interface protocol ID. */ + + uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */ + } ATTR_PACKED USB_Descriptor_Interface_t; + + /** \brief Standard USB Interface Descriptor (USB-IF naming conventions). + * + * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names + * to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */ + uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same + * interface number can have multiple alternate settings + * with different endpoint configurations, which can be + * selected by the host. + */ + uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */ + uint8_t bInterfaceClass; /**< Interface class ID. */ + uint8_t bInterfaceSubClass; /**< Interface subclass ID. */ + uint8_t bInterfaceProtocol; /**< Interface protocol ID. */ + uint8_t iInterface; /**< Index of the string descriptor describing the + * interface. + */ + } ATTR_PACKED USB_StdDescriptor_Interface_t; + + /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions). + * + * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at + * http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf. It allows composite + * devices with multiple interfaces related to the same function to have the multiple interfaces bound + * together at the point of enumeration, loading one generic driver for all the interfaces in the single + * function. Read the ECN for more information. + * + * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */ + uint8_t TotalInterfaces; /**< Total number of associated interfaces. */ + + uint8_t Class; /**< Interface class ID. */ + uint8_t SubClass; /**< Interface subclass ID. */ + uint8_t Protocol; /**< Interface protocol ID. */ + + uint8_t IADStrIndex; /**< Index of the string descriptor describing the + * interface association. + */ + } ATTR_PACKED USB_Descriptor_Interface_Association_t; + + /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions). + * + * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given + * element names to ensure compatibility with the standard. + * + * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at + * http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf. It allows composite + * devices with multiple interfaces related to the same function to have the multiple interfaces bound + * together at the point of enumeration, loading one generic driver for all the interfaces in the single + * function. Read the ECN for more information. + * + * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value + * given by the specific class. + */ + uint8_t bFirstInterface; /**< Index of the first associated interface. */ + uint8_t bInterfaceCount; /**< Total number of associated interfaces. */ + uint8_t bFunctionClass; /**< Interface class ID. */ + uint8_t bFunctionSubClass; /**< Interface subclass ID. */ + uint8_t bFunctionProtocol; /**< Interface protocol ID. */ + uint8_t iFunction; /**< Index of the string descriptor describing the + * interface association. + */ + } ATTR_PACKED USB_StdDescriptor_Interface_Association_t; + + /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions). + * + * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names + * to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current + * configuration, including direction mask. + */ + uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) + * and attributes (ENDPOINT_ATTR_*) masks. + */ + uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet + * size that the endpoint can receive at a time. + */ + uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT + * or ISOCHRONOUS type. + */ + } ATTR_PACKED USB_Descriptor_Endpoint_t; + + /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions). + * + * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given + * element names to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a + * value given by the specific class. + */ + uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current + * configuration, including direction mask. + */ + uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*) + * and attributes (ENDPOINT_ATTR_*) masks. + */ + uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size + * that the endpoint can receive at a time. + */ + uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or + * ISOCHRONOUS type. + */ + } ATTR_PACKED USB_StdDescriptor_Endpoint_t; + + /** \brief Standard USB String Descriptor (LUFA naming conventions). + * + * Type define for a standard string descriptor. Unlike other standard descriptors, the length + * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() + * macro rather than by the size of the descriptor structure, as the length is not fixed. + * + * This structure should also be used for string index 0, which contains the supported language IDs for + * the device as an array. + * + * This structure uses LUFA-specific element names to make each element's purpose clearer. + * + * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */ + + #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__)) + wchar_t UnicodeString[]; + #else + uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively, + * string language IDs). If normal ASCII characters are + * to be used, they must be added as an array of characters + * rather than a normal C string so that they are widened to + * Unicode size. + * + * Under GCC, strings prefixed with the "L" character (before + * the opening string quotation mark) are considered to be + * Unicode strings, and may be used instead of an explicit + * array of ASCII characters on little endian devices with + * UTF-16-LE \c wchar_t encoding. + */ + #endif + } ATTR_PACKED USB_Descriptor_String_t; + + /** \brief Standard USB String Descriptor (USB-IF naming conventions). + * + * Type define for a standard string descriptor. Unlike other standard descriptors, the length + * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN() + * macro rather than by the size of the descriptor structure, as the length is not fixed. + * + * This structure should also be used for string index 0, which contains the supported language IDs for + * the device as an array. + * + * This structure uses the relevant standard's given element names to ensure compatibility with the standard. + * + * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific + * element names. + * + * \note Regardless of CPU architecture, these values should be stored as little endian. + */ + typedef struct + { + uint8_t bLength; /**< Size of the descriptor, in bytes. */ + uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t + * or a value given by the specific class. + */ + uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs). + * If normal ASCII characters are to be used, they must be added as an array + * of characters rather than a normal C string so that they are widened to + * Unicode size. + * + * Under GCC, strings prefixed with the "L" character (before the opening string + * quotation mark) are considered to be Unicode strings, and may be used instead + * of an explicit array of ASCII characters. + */ + } ATTR_PACKED USB_StdDescriptor_String_t; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define VERSION_TENS(x) (int)((int)(x) / 10) + #define VERSION_ONES(x) (int)((int)(x) % 10) + #define VERSION_TENTHS(x) (int)(((x * 1) - ((int)(x * 1))) * 10) + #define VERSION_HUNDREDTHS(x) (int)(((x * 10) - ((int)(x * 10))) * 10) + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdRequestType.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdRequestType.h new file mode 100644 index 000000000..a841f8f3a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/StdRequestType.h @@ -0,0 +1,258 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB control endpoint request definitions. + * \copydetails Group_StdRequest + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_StdRequest Standard USB Requests + * \brief USB control endpoint request definitions. + * + * This module contains definitions for the various control request parameters, so that the request + * details (such as data direction, request recipient, etc.) can be extracted via masking. + * + * @{ + */ + +#ifndef __STDREQTYPE_H__ +#define __STDREQTYPE_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device + * or Device to Host). The result of this mask should then be compared to the request direction masks. + * + * \see \c REQDIR_* macros for masks indicating the request data direction. + */ + #define CONTROL_REQTYPE_DIRECTION 0x80 + + /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor + * Specific). The result of this mask should then be compared to the request type masks. + * + * \see \c REQTYPE_* macros for masks indicating the request type. + */ + #define CONTROL_REQTYPE_TYPE 0x60 + + /** Mask for the request type parameter, to indicate the recipient of the request (Device, Interface + * Endpoint or Other). The result of this mask should then be compared to the request recipient + * masks. + * + * \see \c REQREC_* macros for masks indicating the request recipient. + */ + #define CONTROL_REQTYPE_RECIPIENT 0x1F + + /** \name Control Request Data Direction Masks */ + //@{ + /** Request data direction mask, indicating that the request data will flow from host to device. + * + * \see \ref CONTROL_REQTYPE_DIRECTION macro. + */ + #define REQDIR_HOSTTODEVICE (0 << 7) + + /** Request data direction mask, indicating that the request data will flow from device to host. + * + * \see \ref CONTROL_REQTYPE_DIRECTION macro. + */ + #define REQDIR_DEVICETOHOST (1 << 7) + //@} + + /** \name Control Request Type Masks */ + //@{ + /** Request type mask, indicating that the request is a standard request. + * + * \see \ref CONTROL_REQTYPE_TYPE macro. + */ + #define REQTYPE_STANDARD (0 << 5) + + /** Request type mask, indicating that the request is a class-specific request. + * + * \see \ref CONTROL_REQTYPE_TYPE macro. + */ + #define REQTYPE_CLASS (1 << 5) + + /** Request type mask, indicating that the request is a vendor specific request. + * + * \see \ref CONTROL_REQTYPE_TYPE macro. + */ + #define REQTYPE_VENDOR (2 << 5) + //@} + + /** \name Control Request Recipient Masks */ + //@{ + /** Request recipient mask, indicating that the request is to be issued to the device as a whole. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_DEVICE (0 << 0) + + /** Request recipient mask, indicating that the request is to be issued to an interface in the + * currently selected configuration. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_INTERFACE (1 << 0) + + /** Request recipient mask, indicating that the request is to be issued to an endpoint in the + * currently selected configuration. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_ENDPOINT (2 << 0) + + /** Request recipient mask, indicating that the request is to be issued to an unspecified element + * in the currently selected configuration. + * + * \see \ref CONTROL_REQTYPE_RECIPIENT macro. + */ + #define REQREC_OTHER (3 << 0) + //@} + + /* Type Defines: */ + /** \brief Standard USB Control Request + * + * Type define for a standard USB control request. + * + * \see The USB 2.0 specification for more information on standard control requests. + */ + typedef struct + { + uint8_t bmRequestType; /**< Type of the request. */ + uint8_t bRequest; /**< Request command code. */ + uint16_t wValue; /**< wValue parameter of the request. */ + uint16_t wIndex; /**< wIndex parameter of the request. */ + uint16_t wLength; /**< Length of the data to transfer in bytes. */ + } ATTR_PACKED USB_Request_Header_t; + + /* Enums: */ + /** Enumeration for the various standard request commands. These commands are applicable when the + * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always + * handled regardless of the request type value). + * + * \see Chapter 9 of the USB 2.0 Specification. + */ + enum USB_Control_Request_t + { + REQ_GetStatus = 0, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_ClearFeature = 1, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetFeature = 3, /**< Implemented in the library for device and endpoint recipients. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_GetDescriptor = 6, /**< Implemented in the library for device and interface recipients. Passed to the + * user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed + * to the user application for other recipients via the + * \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application + * via the \ref EVENT_USB_Device_ControlRequest() event when received in + * device mode. */ + }; + + /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface + * and endpoint recipients. + */ + enum USB_Feature_Selectors_t + { + FEATURE_SEL_EndpointHalt = 0x00, /**< Feature selector for Clear Feature or Set Feature commands. When + * used in a Set Feature or Clear Feature request this indicates that an + * endpoint (whose address is given elsewhere in the request) should have + * its stall condition changed. + */ + FEATURE_SEL_DeviceRemoteWakeup = 0x01, /**< Feature selector for Device level Remote Wakeup enable set or clear. + * This feature can be controlled by the host on devices which indicate + * remote wakeup support in their descriptors to selectively disable or + * enable remote wakeup. + */ + FEATURE_SEL_TestMode = 0x02, /**< Feature selector for Test Mode features, used to test the USB controller + * to check for incorrect operation. + */ + }; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define FEATURE_SELFPOWERED_ENABLED (1 << 0) + #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1) + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.c new file mode 100644 index 000000000..b7c186e80 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.c @@ -0,0 +1,51 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Device.h" + +void USB_Device_SendRemoteWakeup(void) +{ + USB_CLK_Unfreeze(); + + AVR32_USBB.UDCON.rmwkup = true; + while (AVR32_USBB.UDCON.rmwkup); +} + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.h new file mode 100644 index 000000000..7139d51f0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Device_UC3.h @@ -0,0 +1,260 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Device definitions for the AVR32 UC3 microcontrollers. + * \copydetails Group_Device_UC3 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Device + * \defgroup Group_Device_UC3 Device Management (UC3) + * \brief USB Device definitions for the AVR32 UC3 microcontrollers. + * + * Architecture specific USB Device definitions for the Atmel 32-bit UC3 AVR microcontrollers. + * + * @{ + */ + +#ifndef __USBDEVICE_UC3_H__ +#define __USBDEVICE_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBController.h" + #include "../StdDescriptors.h" + #include "../USBInterrupt.h" + #include "../Endpoint.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Device Mode Option Masks */ + //@{ + /** 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 Restrictions apply on the number, size and type of endpoints which can be used + * when running in low speed mode - please refer to the USB 2.0 specification. + */ + #define USB_DEVICE_OPT_LOWSPEED (1 << 0) + + /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the + * USB interface should be initialized in full speed (12Mb/s) mode. + */ + #define USB_DEVICE_OPT_FULLSPEED (0 << 0) + + #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__) + /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the + * USB interface should be initialized in high speed (480Mb/s) mode. + */ + #define USB_DEVICE_OPT_HIGHSPEED (1 << 1) + #endif + //@} + + #if (!defined(NO_INTERNAL_SERIAL) && \ + (defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || \ + defined(__DOXYGEN__))) + /** String descriptor index for the device's unique serial number string descriptor within the device. + * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port + * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain + * a unique serial number internally, and setting the device descriptors serial number string index to this value + * will cause it to use the internal serial number. + * + * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial + * number for the device. + */ + #define USE_INTERNAL_SERIAL 0xDC + + /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_LENGTH_BITS 120 + + /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_START_ADDRESS 0x80800204 + #else + #define USE_INTERNAL_SERIAL NO_DESCRIPTOR + + #define INTERNAL_SERIAL_LENGTH_BITS 0 + #define INTERNAL_SERIAL_START_ADDRESS 0 + #endif + + /* Function Prototypes: */ + /** Sends a Remote Wakeup request to the host. This signals to the host that the device should + * be taken out of suspended mode, and communications should resume. + * + * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the + * host computer when the host has suspended all USB devices to enter a low power state. + * + * \note This function should only be used if the device has indicated to the host that it + * supports the Remote Wakeup feature in the device descriptors, and should only be + * issued if the host is currently allowing remote wakeup events from the device (i.e., + * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP + * compile time option is used, this function is unavailable. + * + * \note The USB clock must be running for this function to operate. If the stack is initialized with + * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running + * before attempting to call this function. + * + * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors. + */ + void USB_Device_SendRemoteWakeup(void); + + /* Inline Functions: */ + /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint16_t USB_Device_GetFrameNumber(void) + { + return AVR32_USBB.UDFNUM.fnum; + } + + #if !defined(NO_SOF_EVENTS) + /** Enables the device mode Start Of Frame events. When enabled, this causes the + * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus, + * at the start of each USB frame when enumerated in device mode. + * + * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_EnableSOFEvents(void) + { + USB_INT_Enable(USB_INT_SOFI); + } + + /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the + * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode. + * + * \note Not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_DisableSOFEvents(void) + { + USB_INT_Disable(USB_INT_SOFI); + } + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Inline Functions: */ + static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetLowSpeed(void) + { + AVR32_USBB.UDCON.ls = true; + } + + static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetFullSpeed(void) + { + AVR32_USBB.UDCON.ls = false; + #if defined(USB_DEVICE_OPT_HIGHSPEED) + AVR32_USBB.UDCON.spdconf = 3; + #endif + } + + #if defined(USB_DEVICE_OPT_HIGHSPEED) + static inline void USB_Device_SetHighSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetHighSpeed(void) + { + AVR32_USBB.UDCON.ls = false; + AVR32_USBB.UDCON.spdconf = 0; + } + #endif + + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) + { + AVR32_USBB.UDCON.uadd = Address; + AVR32_USBB.UDCON.adden = (Address ? true : false); + } + + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_Device_IsAddressSet(void) + { + return AVR32_USBB.UDCON.adden; + } + + #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR) + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1); + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) + { + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + uint8_t* SigReadAddress = (uint8_t*)INTERNAL_SERIAL_START_ADDRESS; + + for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) + { + uint8_t SerialByte = *SigReadAddress; + + if (SerialCharNum & 0x01) + { + SerialByte >>= 4; + SigReadAddress++; + } + + SerialByte &= 0x0F; + + UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte)); + } + + SetGlobalInterruptMask(CurrentGlobalInt); + } + #endif + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c new file mode 100644 index 000000000..cc4206cae --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.c @@ -0,0 +1,235 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "EndpointStream_UC3.h" + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" +#endif + +#endif + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.h new file mode 100644 index 000000000..b360b4da4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/EndpointStream_UC3.h @@ -0,0 +1,434 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endpoint data stream transmission and reception management for the AVR32 UC3 microcontrollers. + * \copydetails Group_EndpointStreamRW_UC3 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointStreamRW + * \defgroup Group_EndpointStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3) + * \brief Endpoint data stream transmission and reception management for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to endpoints. + * + * @{ + */ + +#ifndef __ENDPOINT_STREAM_UC3_H__ +#define __ENDPOINT_STREAM_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the currently selected endpoint's bank, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of bytes to discard via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending + * full packets to the host as needed. The last packet is not automatically sent once the + * remaining bytes have been written; the user is responsible for manually sending the last + * packet to the host via the \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of zero bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the status OUT packet + * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the status OUT packet + * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c new file mode 100644 index 000000000..235ddde59 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c @@ -0,0 +1,196 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Endpoint.h" + +#if !defined(FIXED_CONTROL_ENDPOINT_SIZE) +uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; +#endif + +volatile uint32_t USB_Endpoint_SelectedEndpoint = ENDPOINT_CONTROLEP; +volatile uint8_t* USB_Endpoint_FIFOPos[ENDPOINT_TOTAL_ENDPOINTS]; + +bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, + const uint8_t Entries) +{ + for (uint8_t i = 0; i < Entries; i++) + { + if (!(Table[i].Address)) + continue; + + if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks))) + { + return false; + } + } + + return true; +} + +bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, + const uint32_t UECFG0Data) +{ + USB_Endpoint_FIFOPos[Number] = &AVR32_USBB_SLAVE[Number * ENDPOINT_HSB_ADDRESS_SPACE_SIZE]; + +#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG) + Endpoint_SelectEndpoint(Number); + Endpoint_EnableEndpoint(); + + (&AVR32_USBB.uecfg0)[Number] = 0; + (&AVR32_USBB.uecfg0)[Number] = UECFG0Data; + + return Endpoint_IsConfigured(); +#else + for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + uint32_t UECFG0Temp; + + Endpoint_SelectEndpoint(EPNum); + + if (EPNum == Number) + { + UECFG0Temp = UECFG0Data; + } + else + { + UECFG0Temp = (&AVR32_USBB.uecfg0)[EPNum]; + } + + if (!(UECFG0Temp & AVR32_USBB_ALLOC_MASK)) + continue; + + Endpoint_DisableEndpoint(); + (&AVR32_USBB.uecfg0)[EPNum] &= ~AVR32_USBB_ALLOC_MASK; + + Endpoint_EnableEndpoint(); + (&AVR32_USBB.uecfg0)[EPNum] = UECFG0Temp; + + if (!(Endpoint_IsConfigured())) + return false; + } + + Endpoint_SelectEndpoint(Number); + return true; +#endif +} + +void Endpoint_ClearEndpoints(void) +{ + for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + Endpoint_SelectEndpoint(EPNum); + (&AVR32_USBB.uecfg0)[EPNum] = 0; + (&AVR32_USBB.uecon0clr)[EPNum] = -1; + USB_Endpoint_FIFOPos[EPNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000]; + 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 + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h new file mode 100644 index 000000000..356c9c3cb --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h @@ -0,0 +1,795 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Endpoint definitions for the AVR32 UC3 microcontrollers. + * \copydetails Group_EndpointManagement_UC3 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointRW_UC3 Endpoint Data Reading and Writing (UC3) + * \brief Endpoint data read/write definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. + */ + +/** \ingroup Group_EndpointPrimitiveRW + * \defgroup Group_EndpointPrimitiveRW_UC3 Read/Write of Primitive Data Types (UC3) + * \brief Endpoint primitive read/write definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to endpoints. + */ + +/** \ingroup Group_EndpointPacketManagement + * \defgroup Group_EndpointPacketManagement_UC3 Endpoint Packet Management (UC3) + * \brief Endpoint packet management definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointManagement_UC3 Endpoint Management (UC3) + * \brief Endpoint management definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros and enums related to endpoint management when in USB Device mode. This + * module contains the endpoint management macros, as well as endpoint interrupt and data + * send/receive functions for various data types. + * + * @{ + */ + +#ifndef __ENDPOINT_UC3_H__ +#define __ENDPOINT_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define ENDPOINT_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL) + + /* Inline Functions: */ + static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST + ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) + { + uint8_t MaskVal = 0; + uint16_t CheckBytes = 8; + + while (CheckBytes < Bytes) + { + MaskVal++; + CheckBytes <<= 1; + } + + return (MaskVal << AVR32_USBB_EPSIZE_OFFSET); + } + + /* Function Prototypes: */ + void Endpoint_ClearEndpoints(void); + bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, + const uint32_t UECFGXData); + + /* External Variables: */ + extern volatile uint32_t USB_Endpoint_SelectedEndpoint; + extern volatile uint8_t* USB_Endpoint_FIFOPos[]; + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size + * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined. + */ + #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 + #endif + + #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__) + #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) + #define ENDPOINT_TOTAL_ENDPOINTS 8 + #else + /** Total number of endpoints (including the default control endpoint at address 0) which may + * be used in the device. Different 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 7 + #endif + #else + #define ENDPOINT_TOTAL_ENDPOINTS 1 + #endif + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function. + * + * \ingroup Group_EndpointRW_UC3 + */ + 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 address 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] Address Endpoint address to configure. + * + * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types + * are available on Low Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] 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 hardware banks to use for the endpoint being configured. + * + * \attention When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints must be configured in + * ascending order, or bank corruption will occur. + * + * \note Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to + * the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint. + * \n\n + * + * \note The default control endpoint should not be manually configured by the user application, as + * it is automatically configured by the library internally. + * \n\n + * + * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint + * which failed to reconfigure correctly will be selected. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, + const uint8_t Type, + const uint16_t Size, + const uint8_t Banks) ATTR_ALWAYS_INLINE; + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, + const uint8_t Type, + const uint16_t Size, + const uint8_t Banks) + { + uint8_t Number = (Address & ENDPOINT_EPNUM_MASK); + + if (Number >= ENDPOINT_TOTAL_ENDPOINTS) + return false; + + return Endpoint_ConfigureEndpoint_Prv(Number, + (AVR32_USBB_ALLOC_MASK | + ((uint32_t)Type << AVR32_USBB_EPTYPE_OFFSET) | + ((Address & ENDPOINT_DIR_IN) ? AVR32_USBB_UECFG0_EPDIR_MASK : 0) | + ((Banks > 1) ? AVR32_USBB_UECFG0_EPBK_SINGLE : AVR32_USBB_UECFG0_EPBK_DOUBLE) | + Endpoint_BytesToEPSizeMask(Size))); + } + + /** Indicates the number of bytes currently stored in the current endpoint's selected bank. + * + * \ingroup Group_EndpointRW_UC3 + * + * \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) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].byct; + } + + /** Determines the currently selected endpoint's direction. + * + * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline uint32_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_GetEndpointDirection(void) + { + return ((&AVR32_USBB.UECFG0)[USB_Endpoint_SelectedEndpoint].epdir ? ENDPOINT_DIR_IN : ENDPOINT_DIR_OUT); + } + + /** Get the endpoint address of the currently selected endpoint. This is typically used to save + * the currently selected endpoint 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) + { + return (USB_Endpoint_SelectedEndpoint | Endpoint_GetEndpointDirection()); + } + + /** Selects the given endpoint address. + * + * Any endpoint operations which do not require the endpoint address to be indicated will operate on + * the currently selected endpoint. + * + * \param[in] Address Endpoint address to select. + */ + static inline void Endpoint_SelectEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Endpoint_SelectEndpoint(const uint8_t Address) + { + USB_Endpoint_SelectedEndpoint = (Address & ENDPOINT_EPNUM_MASK); + } + + /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's + * data In and Out pointers to the bank's contents. + * + * \param[in] Address Endpoint number whose FIFO buffers are to be reset. + */ + static inline void Endpoint_ResetEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetEndpoint(const uint8_t Address) + { + uint32_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK); + + AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << EndpointNumber); + AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << EndpointNumber); + USB_Endpoint_FIFOPos[EndpointNumber] = &AVR32_USBB_SLAVE[EndpointNumber * ENDPOINT_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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) + { + AVR32_USBB.uerst |= (AVR32_USBB_EPEN0_MASK << USB_Endpoint_SelectedEndpoint); + } + + /** 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) + { + AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_MASK << USB_Endpoint_SelectedEndpoint); + } + + /** Determines if the currently selected endpoint is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise. + */ + static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsEnabled(void) + { + return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_MASK << USB_Endpoint_SelectedEndpoint)) ? true : false); + } + + /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for + * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the + * \ref Endpoint_ClearOUT() command. + * + * \ingroup Group_EndpointPacketManagement_UC3 + * + * \return Total number of busy banks in the selected endpoint. + */ + static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint8_t Endpoint_GetBusyBanks(void) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].nbusybk; + } + + /** 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_UC3 + */ + static inline void Endpoint_AbortPendingIN(void) + { + while (Endpoint_GetBusyBanks() != 0) + { + (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].killbks = true; + while ((&AVR32_USBB.UECON0)[USB_Endpoint_SelectedEndpoint].killbk); + } + } + + /** 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_UC3 + * + * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending + * on its direction. + */ + static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsReadWriteAllowed(void) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rwall; + } + + /** Determines if the currently selected endpoint is configured. + * + * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise. + */ + static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsConfigured(void) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].cfgok; + } + + /** 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 uint32_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_GetEndpointInterrupts(void) + { + return ((AVR32_USBB.udint & (AVR32_USBB_EP6INT_MASK | AVR32_USBB_EP5INT_MASK | + AVR32_USBB_EP4INT_MASK | AVR32_USBB_EP3INT_MASK | + AVR32_USBB_EP2INT_MASK | AVR32_USBB_EP1INT_MASK | + AVR32_USBB_EP0INT_MASK)) >> AVR32_USBB_EP0INT_OFFSET); + } + + /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type + * endpoints). + * + * \param[in] Address Address of the endpoint whose interrupt flag should be tested. + * + * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise. + */ + static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address) + { + return ((Endpoint_GetEndpointInterrupts() & (AVR32_USBB_EP0INT_MASK << (Address & ENDPOINT_EPNUM_MASK))) ? true : false); + } + + /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host. + * + * \ingroup Group_EndpointPacketManagement_UC3 + * + * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise. + */ + static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsINReady(void) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].txini; + } + + /** Determines if the selected OUT endpoint has received new packet from the host. + * + * \ingroup Group_EndpointPacketManagement_UC3 + * + * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise. + */ + static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsOUTReceived(void) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rxouti; + } + + /** Determines if the current CONTROL type endpoint has received a SETUP packet. + * + * \ingroup Group_EndpointPacketManagement_UC3 + * + * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise. + */ + static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsSETUPReceived(void) + { + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rxstpi; + } + + /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the + * endpoint for the next packet. + * + * \ingroup Group_EndpointPacketManagement_UC3 + * + * \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) + { + (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].rxstpic = true; + USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_Endpoint_SelectedEndpoint * ENDPOINT_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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_UC3 + */ + static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearIN(void) + { + (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].txinic = true; + (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].fifoconc = true; + USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_Endpoint_SelectedEndpoint * ENDPOINT_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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_UC3 + */ + static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearOUT(void) + { + (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].rxoutic = true; + (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].fifoconc = true; + USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_Endpoint_SelectedEndpoint * ENDPOINT_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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_UC3 + */ + static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_StallTransaction(void) + { + (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].stallrqs = true; + } + + /** Clears the STALL condition on the currently selected endpoint. + * + * \ingroup Group_EndpointPacketManagement_UC3 + */ + static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearStall(void) + { + (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].stallrqc = true; + } + + /** Determines if the currently selected endpoint is stalled, false otherwise. + * + * \ingroup Group_EndpointPacketManagement_UC3 + * + * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. + */ + static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsStalled(void) + { + return (&AVR32_USBB.UECON0)[USB_Endpoint_SelectedEndpoint].stallrq; + } + + /** Resets the data toggle of the currently selected endpoint. */ + static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetDataToggle(void) + { + (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].rstdts = true; + } + + /** Sets the direction of the currently selected endpoint. + * + * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask) ATTR_ALWAYS_INLINE; + static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask) + { + (&AVR32_USBB.UECFG0)[USB_Endpoint_SelectedEndpoint].epdir = (DirectionMask == ENDPOINT_DIR_IN); + } + + /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \return Next byte in the currently selected endpoint's FIFO buffer. + */ + static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_Read_8(void) + { + return *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + } + + /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_8(const uint8_t Data) + { + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = Data; + } + + /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + */ + static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_8(void) + { + uint8_t Dummy; + + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + (void)Dummy; + } + + /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_LE(void) + { + uint16_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint16_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + return ((Byte1 << 8) | Byte0); + } + + /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_BE(void) + { + uint16_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint16_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + return ((Byte0 << 8) | Byte1); + } + + /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_LE(const uint16_t Data) + { + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8); + } + + /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_BE(const uint16_t Data) + { + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF); + } + + /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + */ + static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_16(void) + { + uint8_t Dummy; + + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + (void)Dummy; + } + + /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_LE(void) + { + uint32_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint32_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint32_t Byte2 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint32_t Byte3 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0); + } + + /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_BE(void) + { + uint32_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint32_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint32_t Byte2 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + uint32_t Byte3 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3); + } + + /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_LE(const uint32_t Data) + { + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 16); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 24); + } + + /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_BE(const uint32_t Data) + { + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 24); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 16); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8); + *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF); + } + + /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_UC3 + */ + static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_32(void) + { + uint8_t Dummy; + + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++); + + (void)Dummy; + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control endpoint located at address + * 0 in the device. This value is set to the value indicated in the device descriptor in the user + * project once the USB interface is initialized into device mode. + * + * If space is an issue, it is possible to fix this to a static value by defining the control + * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile + * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically + * read from the descriptors at runtime and instead fixed to the given value. When used, it is + * important that the descriptor control endpoint size value matches the size given as the + * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token + * be used in the device descriptors to ensure this. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + extern uint8_t USB_Device_ControlEndpointSize; + #else + #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE + #endif + + /* Function Prototypes: */ + /** Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple + * endpoints at the same time. + * + * \note Endpoints with a zero address will be ignored, thus this function cannot be used to configure the + * control endpoint. + * + * \param[in] Table Pointer to a table of endpoint descriptions. + * \param[in] Entries Number of entries in the endpoint table to configure. + * + * \return Boolean \c true if all endpoints configured successfully, \c false otherwise. + */ + bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, + const uint8_t Entries); + + /** 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. + * + * \note This routine should not be called on non CONTROL type endpoints. + */ + 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_UC3 + * + * \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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.c new file mode 100644 index 000000000..24e2136e4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.c @@ -0,0 +1,294 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#define __INCLUDE_FROM_HOST_C +#include "../Host.h" + +void USB_Host_ProcessNextHostState(void) +{ + uint8_t ErrorCode = HOST_ENUMERROR_NoError; + uint8_t SubErrorCode = HOST_ENUMERROR_NoError; + + static uint16_t WaitMSRemaining; + static uint8_t PostWaitState; + + switch (USB_HostState) + { + case HOST_STATE_WaitForDevice: + if (WaitMSRemaining) + { + if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful) + { + USB_HostState = PostWaitState; + ErrorCode = HOST_ENUMERROR_WaitStage; + break; + } + + if (!(--WaitMSRemaining)) + USB_HostState = PostWaitState; + } + + break; + case HOST_STATE_Powered: + WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS; + + USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle; + break; + case HOST_STATE_Powered_WaitForDeviceSettle: + if (WaitMSRemaining--) + { + Delay_MS(1); + break; + } + else + { + USB_Host_VBUS_Manual_Off(); + + USB_OTGPAD_On(); + USB_Host_VBUS_Auto_Enable(); + USB_Host_VBUS_Auto_On(); + + #if defined(NO_AUTO_VBUS_MANAGEMENT) + USB_Host_VBUS_Manual_Enable(); + USB_Host_VBUS_Manual_On(); + #endif + + USB_HostState = HOST_STATE_Powered_WaitForConnect; + } + + break; + case HOST_STATE_Powered_WaitForConnect: + if (USB_INT_HasOccurred(USB_INT_DCONNI)) + { + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Clear(USB_INT_DDISCI); + + USB_INT_Clear(USB_INT_VBERRI); + USB_INT_Enable(USB_INT_VBERRI); + + USB_Host_ResumeBus(); + Pipe_ClearPipes(); + + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset); + } + + break; + case HOST_STATE_Powered_DoReset: + USB_Host_ResetDevice(); + + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe); + break; + case HOST_STATE_Powered_ConfigPipe: + if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, PIPE_CONTROLPIPE_DEFAULT_SIZE, 1))) + { + 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]; + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful) + { + ErrorCode = HOST_ENUMERROR_ControlError; + break; + } + + USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)]; + + USB_Host_ResetDevice(); + + HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset); + break; + case HOST_STATE_Default_PostReset: + if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, USB_Host_ControlPipeSize, 1))) + { + ErrorCode = HOST_ENUMERROR_PipeConfigError; + SubErrorCode = 0; + break; + } + + USB_ControlRequest = (USB_Request_Header_t) + { + .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE), + .bRequest = REQ_SetAddress, + .wValue = USB_HOST_DEVICEADDRESS, + .wIndex = 0, + .wLength = 0, + }; + + if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) + { + ErrorCode = HOST_ENUMERROR_ControlError; + break; + } + + HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet); + break; + case HOST_STATE_Default_PostAddressSet: + USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS); + + USB_HostState = HOST_STATE_Addressed; + + EVENT_USB_Host_DeviceEnumerationComplete(); + break; + } + + if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached)) + { + EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode); + + USB_Host_VBUS_Auto_Off(); + + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } +} + +uint8_t USB_Host_WaitMS(uint8_t MS) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + uint8_t ErrorCode = HOST_WAITERROR_Successful; + bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); + + USB_INT_Disable(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_HSOFI); + + USB_Host_ResumeBus(); + + while (MS) + { + if (USB_INT_HasOccurred(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + MS--; + } + + if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host)) + { + ErrorCode = HOST_WAITERROR_DeviceDisconnect; + + break; + } + + if (Pipe_IsError()) + { + Pipe_ClearError(); + ErrorCode = HOST_WAITERROR_PipeError; + + break; + } + + if (Pipe_IsStalled()) + { + Pipe_ClearStall(); + ErrorCode = HOST_WAITERROR_SetupStalled; + + break; + } + } + + if (BusSuspended) + USB_Host_SuspendBus(); + + if (HSOFIEnabled) + USB_INT_Enable(USB_INT_HSOFI); + + return ErrorCode; +} + +static void USB_Host_ResetDevice(void) +{ + bool BusSuspended = USB_Host_IsBusSuspended(); + + USB_INT_Disable(USB_INT_DDISCI); + + USB_Host_ResetBus(); + while (!(USB_Host_IsBusResetComplete())); + USB_Host_ResumeBus(); + + USB_Host_ConfigurationNumber = 0; + + bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI); + + USB_INT_Disable(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_HSOFI); + + for (uint8_t MSRem = 10; MSRem != 0; MSRem--) + { + /* Workaround for powerless-pull-up devices. After a USB bus reset, + all disconnection interrupts are suppressed while a USB frame is + looked for - if it is found within 10ms, the device is still + present. */ + + if (USB_INT_HasOccurred(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + USB_INT_Clear(USB_INT_DDISCI); + break; + } + + Delay_MS(1); + } + + if (HSOFIEnabled) + USB_INT_Enable(USB_INT_HSOFI); + + if (BusSuspended) + USB_Host_SuspendBus(); + + USB_INT_Enable(USB_INT_DDISCI); +} + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.h new file mode 100644 index 000000000..07559cd3f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Host_UC3.h @@ -0,0 +1,363 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Host definitions for the AVR32 UC3B microcontrollers. + * \copydetails Group_Host_UC3B + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Host + * \defgroup Group_Host_UC3B Host Management (UC3B) + * \brief USB Host definitions for the AVR32 UC3B microcontrollers. + * + * Architecture specific USB Host definitions for the Atmel 32-bit AVR UC3B microcontrollers. + * + * @{ + */ + +#ifndef __USBHOST_UC3B_H__ +#define __USBHOST_UC3B_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../StdDescriptors.h" + #include "../Pipe.h" + #include "../USBInterrupt.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates the fixed USB device address which any attached device is enumerated to when in + * host mode. As only one USB device may be attached to the AVR in host mode at any one time + * and that the address used is not important (other than the fact that it is non-zero), a + * fixed value is specified by the library. + */ + #define USB_HOST_DEVICEADDRESS 1 + + #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__) + /** Constant for the delay in milliseconds after a device is connected before the library + * will start the enumeration process. Some devices require a delay of up to 5 seconds + * after connection before the enumeration process can start or incorrect operation will + * occur. + * + * The default delay value may be overridden in the user project makefile by defining the + * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the + * compiler using the -D switch. + */ + #define HOST_DEVICE_SETTLE_DELAY_MS 1000 + #endif + + /* Enums: */ + /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event. + * + * \see \ref Group_Events for more information on this event. + */ + enum USB_Host_ErrorCodes_t + { + HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This + * error may be the result of an attached device drawing + * too much current from the VBUS line, or due to the + * AVR's power source being unable to supply sufficient + * current. + */ + }; + + /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event. + * + * \see \ref Group_Events for more information on this event. + */ + enum USB_Host_EnumerationErrorCodes_t + { + HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid + * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed() + * event. + */ + HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed + * to complete successfully, due to a timeout or other + * error. + */ + HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines + * indicating the attachment of a device. + */ + HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to + * complete successfully. + */ + HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to + * configure correctly. + */ + }; + + /* Inline Functions: */ + /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t USB_Host_GetFrameNumber(void) + { + return AVR32_USBB_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 This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_EnableSOFEvents(void) + { + USB_INT_Enable(USB_INT_HSOFI); + } + + /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the + * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode. + * + * \note This function is not available when the \c 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) + { + AVR32_USBB.UHCON.reset = true; + } + + /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has + * completed. + * + * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise. + */ + static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsBusResetComplete(void) + { + return AVR32_USBB.UHCON.reset; + } + + /** 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) + { + AVR32_USBB.UHCON.sofe = true; + } + + /** Suspends the USB bus, preventing any communications from occurring between the host and attached + * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame + * messages to the device. + * + * \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that + * some events (such as device disconnections) will not fire until the bus is resumed. + */ + static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_SuspendBus(void) + { + AVR32_USBB.UHCON.sofe = false; + } + + /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro, + * false otherwise. While suspended, no USB communications can occur until the bus is resumed, + * except for the Remote Wakeup event from the device if supported. + * + * \return Boolean \c true if the bus is currently suspended, \c false otherwise. + */ + static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsBusSuspended(void) + { + return AVR32_USBB.UHCON.sofe; + } + + /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or + * false if the attached device is enumerated in Low Speed mode (1.5Mb/s). + * + * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise. + */ + static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsDeviceFullSpeed(void) + { + return (AVR32_USBB.USBSTA.speed == AVR32_USBB_SPEED_FULL); + } + + /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting + * that the host resume the USB bus and wake up the device, false otherwise. + * + * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise. + */ + static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsRemoteWakeupSent(void) + { + return AVR32_USBB.UHINT.rxrsmi; + } + + /** 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) + { + AVR32_USBB.UHINTCLR.rxrsmic = true; + } + + /** 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) + { + AVR32_USBB.UHCON.resume = true; + } + + /** Determines if a resume from Remote Wakeup request is currently being sent to an attached + * device. + * + * \return Boolean \c true if no resume request is currently being sent, \c false otherwise. + */ + static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) + { + return AVR32_USBB.UHCON.resume; + } + + /* 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) + { + // Not required for UC3B + } + + static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_HostMode_Off(void) + { + // Not required for UC3B + } + + static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_Enable(void) + { + AVR32_USBB.USBCON.vbushwc = false; + } + + static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_Enable(void) + { + AVR32_USBB.USBCON.vbushwc = true; + } + + static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_On(void) + { + AVR32_USBB.USBSTASET.vbusrqs = true; + } + + static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_On(void) + { + AVR32_USBB.USBSTASET.vbusrqs = true; + } + + static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Auto_Off(void) + { + AVR32_USBB.USBSTACLR.vbusrqc = true; + } + + static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_Host_VBUS_Manual_Off(void) + { + AVR32_USBB.USBSTACLR.vbusrqc = true; + } + + static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Host_SetDeviceAddress(const uint8_t Address) + { + AVR32_USBB.UHADDR1.uhaddr_p0 = Address; + AVR32_USBB.UHADDR1.uhaddr_p1 = Address; + AVR32_USBB.UHADDR1.uhaddr_p2 = Address; + AVR32_USBB.UHADDR1.uhaddr_p3 = Address; + AVR32_USBB.UHADDR2.uhaddr_p4 = Address; + AVR32_USBB.UHADDR2.uhaddr_p5 = Address; + AVR32_USBB.UHADDR2.uhaddr_p6 = Address; + } + + /* 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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.c new file mode 100644 index 000000000..20c8bf1e6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.c @@ -0,0 +1,166 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "PipeStream_UC3.h" + +uint8_t Pipe_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + Pipe_SetPipeToken(PIPE_TOKEN_IN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +uint8_t Pipe_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + Pipe_SetPipeToken(PIPE_TOKEN_OUT); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + USB_USBTask(); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + Pipe_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_TOKEN PIPE_TOKEN_OUT +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr) +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() +#include "Template/Template_Pipe_RW.c" + +#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_TOKEN PIPE_TOKEN_IN +#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8() +#include "Template/Template_Pipe_RW.c" + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.h new file mode 100644 index 000000000..34c82ad29 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/PipeStream_UC3.h @@ -0,0 +1,352 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Pipe data stream transmission and reception management for the AVR32 UC3 microcontrollers. + * \copydetails Group_PipeStreamRW_UC3 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeStreamRW + * \defgroup Group_PipeStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3) + * \brief Pipe data stream transmission and reception management for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to pipes. + * + * @{ + */ + +#ifndef __PIPE_STREAM_UC3_H__ +#define __PIPE_STREAM_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host + * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the + * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or + * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer + * will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data + * to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with + * the total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to + * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed + * value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Length Number of bytes to discard via the currently selected pipe. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be processed at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device + * as needed. The last packet is not automatically sent once the remaining bytes has been written; the + * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or + * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer + * will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data + * to process (and after the current packet transmission has been initiated) the BytesProcessed location will be + * updated with the total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to + * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed + * value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Length Number of zero bytes to write via the currently selected pipe. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be processed at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the pipe from the given buffer in little endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the pipe bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the pipe from the given buffer in big endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the pipe into the given buffer in little endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the pipe bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != PIPE_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the pipe into the given buffer in big endian, + * sending full packets to the device as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is + * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers. + * + * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without + * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken(). + * + * \param[out] Buffer Pointer to the source data buffer to write to. + * \param[in] Length Number of bytes to read for the currently selected pipe to read from. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should + * updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Pipe_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c new file mode 100644 index 000000000..6128869b0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c @@ -0,0 +1,209 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#include "../Pipe.h" + +uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + +volatile uint32_t USB_Pipe_SelectedPipe = PIPE_CONTROLPIPE; +volatile uint8_t* USB_Pipe_FIFOPos[PIPE_TOTAL_PIPES]; + +bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table, + const uint8_t Entries) +{ + for (uint8_t i = 0; i < Entries; i++) + { + if (!(Table[i].Address)) + continue; + + if (!(Pipe_ConfigurePipe(Table[i].Address, Table[i].Type, Table[i].EndpointAddress, Table[i].Size, Table[i].Banks))) + { + return false; + } + } + + return true; +} + +bool Pipe_ConfigurePipe(const uint8_t Address, + const uint8_t Type, + const uint8_t EndpointAddress, + const uint16_t Size, + const uint8_t Banks) +{ + uint8_t Number = (Address & PIPE_EPNUM_MASK); + uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT; + + if (Number >= PIPE_TOTAL_PIPES) + return false; + + if (Type == EP_TYPE_CONTROL) + Token = PIPE_TOKEN_SETUP; + + USB_Pipe_FIFOPos[Number] = &AVR32_USBB_SLAVE[Number * PIPE_HSB_ADDRESS_SPACE_SIZE]; + +#if defined(ORDERED_EP_CONFIG) + Pipe_SelectPipe(Number); + Pipe_EnablePipe(); + + (&AVR32_USBB.upcfg0)[Number] = 0; + (&AVR32_USBB.upcfg0)[Number] = (AVR32_USBB_ALLOC_MASK | + ((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) | + ((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) | + ((Banks > 1) ? AVR32_USBB_PBK_MASK : 0) | + Pipe_BytesToEPSizeMask(Size) | + ((uint32_t)Number << AVR32_USBB_PEPNUM_OFFSET)); + + Pipe_SetInfiniteINRequests(); + + return Pipe_IsConfigured(); +#else + for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++) + { + uint32_t UPCFG0Temp; + + Pipe_SelectPipe(PNum); + + if (PNum == Number) + { + UPCFG0Temp = (AVR32_USBB_ALLOC_MASK | + ((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) | + ((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) | + ((Banks > 1) ? AVR32_USBB_PBK_MASK : 0) | + Pipe_BytesToEPSizeMask(Size) | + ((EndpointAddress & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET)); + } + else + { + UPCFG0Temp = (&AVR32_USBB.upcfg0)[PNum]; + } + + if (!(UPCFG0Temp & AVR32_USBB_ALLOC_MASK)) + continue; + + Pipe_DisablePipe(); + (&AVR32_USBB.upcfg0)[PNum] &= ~AVR32_USBB_ALLOC_MASK; + + Pipe_EnablePipe(); + (&AVR32_USBB.upcfg0)[PNum] = UPCFG0Temp; + + Pipe_SetInfiniteINRequests(); + + if (!(Pipe_IsConfigured())) + return false; + } + + Pipe_SelectPipe(Number); + return true; +#endif +} + +void Pipe_ClearPipes(void) +{ + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + (&AVR32_USBB.upcfg0)[PNum] = 0; + (&AVR32_USBB.upcon0clr)[PNum] = -1; + USB_Pipe_FIFOPos[PNum] = &AVR32_USBB_SLAVE[PNum * 0x10000]; + Pipe_DisablePipe(); + } +} + +bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) +{ + uint8_t PrevPipeNumber = Pipe_GetCurrentPipe(); + + for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) + { + Pipe_SelectPipe(PNum); + + if (!(Pipe_IsConfigured())) + continue; + + if (Pipe_GetBoundEndpointAddress() == EndpointAddress) + return true; + } + + Pipe_SelectPipe(PrevPipeNumber); + return false; +} + +uint8_t Pipe_WaitUntilReady(void) +{ + #if (USB_STREAM_TIMEOUT_MS < 0xFF) + uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #else + uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #endif + + uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber(); + + for (;;) + { + if (Pipe_GetPipeToken() == PIPE_TOKEN_IN) + { + if (Pipe_IsINReceived()) + return PIPE_READYWAIT_NoError; + } + else + { + if (Pipe_IsOUTReady()) + return PIPE_READYWAIT_NoError; + } + + if (Pipe_IsStalled()) + return PIPE_READYWAIT_PipeStalled; + else if (USB_HostState == HOST_STATE_Unattached) + return PIPE_READYWAIT_DeviceDisconnected; + + uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); + + if (CurrentFrameNumber != PreviousFrameNumber) + { + PreviousFrameNumber = CurrentFrameNumber; + + if (!(TimeoutMSRem--)) + return PIPE_READYWAIT_Timeout; + } + } +} + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h new file mode 100644 index 000000000..6de574e9c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h @@ -0,0 +1,924 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Pipe definitions for the AVR32 UC3 microcontrollers. + * \copydetails Group_PipeManagement_UC3 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_PipeRW + * \defgroup Group_PipeRW_UC3 Pipe Data Reading and Writing (UC3) + * \brief Pipe data read/write definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to pipes. + */ + +/** \ingroup Group_PipePrimitiveRW + * \defgroup Group_PipePrimitiveRW_UC3 Read/Write of Primitive Data Types (UC3) + * \brief Pipe primitive data read/write definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to pipes. + */ + +/** \ingroup Group_PipePacketManagement + * \defgroup Group_PipePacketManagement_UC3 Pipe Packet Management (UC3) + * \brief Pipe packet management definitions for the Atmel AVR32 UC3 architecture. + * + * Functions, macros, variables, enums and types related to packet management of pipes. + */ + +/** \ingroup Group_PipeControlReq + * \defgroup Group_PipeControlReq_UC3 Pipe Control Request Management (UC3) + * \brief Pipe control request management definitions for the Atmel AVR32 UC3 architecture. + * + * Module for host mode request processing. This module allows for the transmission of standard, class and + * vendor control requests to the default control endpoint of an attached device while in host mode. + * + * \see Chapter 9 of the USB 2.0 specification. + */ + +/** \ingroup Group_PipeManagement + * \defgroup Group_PipeManagement_UC3 Pipe Management (UC3) + * \brief Pipe management definitions for the Atmel AVR32 UC3 architecture. + * + * This module contains functions, macros and enums related to pipe management when in USB Host mode. This + * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions + * for various data types. + * + * @{ + */ + +#ifndef __PIPE_UC3_H__ +#define __PIPE_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #define PIPE_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL) + + /* External Variables: */ + extern volatile uint32_t USB_Pipe_SelectedPipe; + extern volatile uint8_t* USB_Pipe_FIFOPos[]; + #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 (AVR32_USBB_UPSTA0_OVERFI_MASK << 8) + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */ + #define PIPE_ERRORFLAG_CRC16 AVR32_USBB_UPERR0_CRC16_MASK + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */ + #define PIPE_ERRORFLAG_TIMEOUT AVR32_USBB_UPERR0_TIMEOUT_MASK + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */ + #define PIPE_ERRORFLAG_PID AVR32_USBB_UPERR0_PID_MASK + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */ + #define PIPE_ERRORFLAG_DATAPID AVR32_USBB_UPERR0_DATAPID_MASK + + /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */ + #define PIPE_ERRORFLAG_DATATGL AVR32_USBB_UPERR0_DATATGL_MASK + //@} + + /** \name Pipe Token Masks */ + //@{ + /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). 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 AVR32_USBB_UPCFG0_PTOKEN_SETUP + + /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). 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 AVR32_USBB_UPCFG0_PTOKEN_IN + + /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). 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 AVR32_USBB_UPCFG0_PTOKEN_OUT + //@} + + /** 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 + + #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__) + /** Total number of pipes (including the default control pipe at address 0) which may be used in + * the device. + */ + #define PIPE_TOTAL_PIPES 8 + #else + #define PIPE_TOTAL_PIPES 7 + #endif + + /** 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 UC3 AVR model. + */ + #define PIPE_MAX_SIZE 256 + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function. + * + * \ingroup Group_PipeRW_UC3 + */ + 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. + * + * \ingroup Group_PipeRW_UC3 + * + * \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 (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].pbyct; + } + + /** Determines the currently selected pipe's direction. + * + * \return The currently selected pipe's direction, as a \c PIPE_DIR_* mask. + */ + static inline uint8_t Pipe_GetPipeDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeDirection(void) + { + return (((&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].ptoken == PIPE_TOKEN_OUT) ? PIPE_DIR_OUT : PIPE_DIR_IN); + } + + /** 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 (USB_Pipe_SelectedPipe | Pipe_GetPipeDirection()); + } + + /** Selects the given pipe address. Any pipe operations which do not require the pipe address to be + * indicated will operate on the currently selected pipe. + * + * \param[in] Address Address of the pipe to select. + */ + static inline void Pipe_SelectPipe(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Pipe_SelectPipe(const uint8_t Address) + { + USB_Pipe_SelectedPipe = (Address & PIPE_EPNUM_MASK); + } + + /** Resets the desired pipe, including the pipe banks and flags. + * + * \param[in] Address Index of the pipe to reset. + */ + static inline void Pipe_ResetPipe(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Pipe_ResetPipe(const uint8_t Address) + { + uint32_t PipeNumber = (Address & PIPE_EPNUM_MASK); + + AVR32_USBB.uprst |= (AVR32_USBB_PRST0_MASK << PipeNumber); + AVR32_USBB.uprst &= ~(AVR32_USBB_PRST0_MASK << PipeNumber); + USB_Pipe_FIFOPos[PipeNumber] = &AVR32_USBB_SLAVE[PipeNumber * PIPE_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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) + { + AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << USB_Pipe_SelectedPipe); + } + + /** 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) + { + AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << USB_Pipe_SelectedPipe); + } + + /** Determines if the currently selected pipe is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise. + */ + static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsEnabled(void) + { + return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << USB_Pipe_SelectedPipe)) ? true : false); + } + + /** Gets the current pipe token, indicating the pipe's data direction and type. + * + * \return The current pipe token, as a \c PIPE_TOKEN_* mask. + */ + static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeToken(void) + { + return (&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].ptoken; + } + + /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_* + * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during + * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices + * which have two endpoints of opposite direction sharing the same endpoint address within the device. + * + * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask. + */ + static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE; + static inline void Pipe_SetPipeToken(const uint8_t Token) + { + (&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].ptoken = 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) + { + (&AVR32_USBB.UPINRQ0)[USB_Pipe_SelectedPipe].inmode = true; + } + + /** 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) + { + (&AVR32_USBB.UPINRQ0)[USB_Pipe_SelectedPipe].inmode = false; + (&AVR32_USBB.UPINRQ0)[USB_Pipe_SelectedPipe].inrq = TotalINRequests; + } + + /** Determines if the currently selected pipe is configured. + * + * \return Boolean \c true if the selected pipe is configured, \c false otherwise. + */ + static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsConfigured(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].cfgok; + } + + /** Retrieves the endpoint address of the endpoint within the attached device that the currently selected + * pipe is bound to. + * + * \return Endpoint address the currently selected pipe is bound to. + */ + static inline uint8_t Pipe_GetBoundEndpointAddress(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetBoundEndpointAddress(void) + { + return ((&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].pepnum | + ((Pipe_GetPipeToken() == PIPE_TOKEN_IN) ? PIPE_DIR_IN : PIPE_DIR_OUT)); + } + + /** 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) + { + (&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].intfrq = 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 ((AVR32_USBB.uhint & (AVR32_USBB_P6INT_MASK | AVR32_USBB_P5INT_MASK | + AVR32_USBB_P4INT_MASK | AVR32_USBB_P3INT_MASK | + AVR32_USBB_P2INT_MASK | AVR32_USBB_P1INT_MASK | + AVR32_USBB_P0INT_MASK)) >> AVR32_USBB_P0INT_OFFSET); + } + + /** Determines if the specified pipe address has interrupted (valid only for INTERRUPT type + * pipes). + * + * \param[in] Address Address of the pipe whose interrupt flag should be tested. + * + * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise. + */ + static inline bool Pipe_HasPipeInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_HasPipeInterrupted(const uint8_t Address) + { + return ((AVR32_USBB.uhint & (AVR32_USBB_P0INTES_MASK << (Address & PIPE_EPNUM_MASK))) ? 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) + { + (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].pfreezec = true; + } + + /** 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) + { + (&AVR32_USBB.UPCON0SET)[USB_Pipe_SelectedPipe].pfreezes = true; + } + + /** Determines if the currently selected pipe is frozen, and not able to accept data. + * + * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise. + */ + static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsFrozen(void) + { + return (((&AVR32_USBB.UPCON0)[USB_Pipe_SelectedPipe].pfreeze) ? true : false); + } + + /** Clears the error flags for the currently selected pipe. */ + static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearError(void) + { + (&AVR32_USBB.uperr0)[USB_Pipe_SelectedPipe] = 0; + (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].overfic = true; + } + + /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that + * some sort of hardware error has occurred on the pipe. + * + * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag. + * + * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise. + */ + static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsError(void) + { + return (((&AVR32_USBB.upsta0)[USB_Pipe_SelectedPipe] & + (AVR32_USBB_PERRI_MASK | AVR32_USBB_OVERFI_MASK)) ? true : false); + } + + /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This + * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred. + * + * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe. + */ + static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetErrorFlags(void) + { + + return (((&AVR32_USBB.uperr0)[USB_Pipe_SelectedPipe] & + (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT | + PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID | + PIPE_ERRORFLAG_DATATGL)) | + (((&AVR32_USBB.upsta0)[USB_Pipe_SelectedPipe] << 8) & + PIPE_ERRORFLAG_OVERFLOW)); + } + + /** 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_UC3 + * + * \return Total number of busy banks in the selected pipe. + */ + static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetBusyBanks(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].nbusybk; + } + + /** 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_UC3 + * + * \return Boolean \c true if the currently selected pipe may be read from or written to, depending + * on its direction. + */ + static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsReadWriteAllowed(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].rwall; + } + + /** Determines if a packet has been received on the currently selected IN pipe from the attached device. + * + * \ingroup Group_PipePacketManagement_UC3 + * + * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise. + */ + static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsINReceived(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].rxini; + } + + /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device. + * + * \ingroup Group_PipePacketManagement_UC3 + * + * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise. + */ + static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsOUTReady(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].txouti; + } + + /** Determines if no SETUP request is currently being sent to the attached device on the selected + * CONTROL type pipe. + * + * \ingroup Group_PipePacketManagement_UC3 + * + * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise. + */ + static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsSETUPSent(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].txstpi; + } + + /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet. + * + * \ingroup Group_PipePacketManagement_UC3 + */ + static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearSETUP(void) + { + (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].txstpic = true; + (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].fifoconc = true; + USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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_UC3 + */ + static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearIN(void) + { + (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].rxinic = true; + (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].fifoconc = true; + USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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_UC3 + */ + static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearOUT(void) + { + (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].txoutic = true; + (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].fifoconc = true; + USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE]; + } + + /** 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_UC3 + * + * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise. + */ + static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsNAKReceived(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].nakedi; + } + + /** Clears the NAK condition on the currently selected pipe. + * + * \ingroup Group_PipePacketManagement_UC3 + * + * \see \ref Pipe_IsNAKReceived() for more details. + */ + static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearNAKReceived(void) + { + (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].nakedic = true; + } + + /** Determines if the currently selected pipe has had the STALL condition set by the attached device. + * + * \ingroup Group_PipePacketManagement_UC3 + * + * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise. + */ + static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Pipe_IsStalled(void) + { + return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].rxstalldi; + } + + /** 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_UC3 + */ + static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_ClearStall(void) + { + (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].rxstalldic = true; + USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE]; + } + + /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \return Next byte in the currently selected pipe's FIFO buffer. + */ + static inline uint8_t Pipe_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_Read_8(void) + { + return *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + } + + /** Writes one byte to the currently selected pipe's bank, for IN direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \param[in] Data Data to write into the the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_8(const uint8_t Data) + { + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = Data; + } + + /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + */ + static inline void Pipe_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_8(void) + { + uint8_t Dummy; + + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + (void)Dummy; + } + + /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \return Next two bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_16_LE(void) + { + uint16_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint16_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + return ((Byte1 << 8) | Byte0); + } + + /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \return Next two bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint16_t Pipe_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Pipe_Read_16_BE(void) + { + uint16_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint16_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + return ((Byte0 << 8) | Byte1); + } + + /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_16_LE(const uint16_t Data) + { + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8); + } + + /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_16_BE(const uint16_t Data) + { + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF); + } + + /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + */ + static inline void Pipe_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_16(void) + { + uint8_t Dummy; + + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + (void)Dummy; + } + + /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \return Next four bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_32_LE(void) + { + uint32_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint32_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint32_t Byte2 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint32_t Byte3 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0); + } + + /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \return Next four bytes in the currently selected pipe's FIFO buffer. + */ + static inline uint32_t Pipe_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Pipe_Read_32_BE(void) + { + uint32_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint32_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint32_t Byte2 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + uint32_t Byte3 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3); + } + + /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_32_LE(const uint32_t Data) + { + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 16); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 24); + } + + /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN + * direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + * + * \param[in] Data Data to write to the currently selected pipe's FIFO buffer. + */ + static inline void Pipe_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Pipe_Write_32_BE(const uint32_t Data) + { + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 24); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 16); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8); + *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF); + } + + /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. + * + * \ingroup Group_PipePrimitiveRW_UC3 + */ + static inline void Pipe_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Pipe_Discard_32(void) + { + uint8_t Dummy; + + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++); + + (void)Dummy; + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control pipe located at address + * 0 in the device. This value is set to the value indicated in the attached device's device + * descriptor once the USB interface is initialized into host mode and a device is attached + * to the USB bus. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + extern uint8_t USB_Host_ControlPipeSize; + + /* Function Prototypes: */ + /** Configures a table of pipe descriptions, in sequence. This function can be used to configure multiple + * pipes at the same time. + * + * \note Pipe with a zero address will be ignored, thus this function cannot be used to configure the + * control pipe. + * + * \param[in] Table Pointer to a table of pipe descriptions. + * \param[in] Entries Number of entries in the pipe table to configure. + * + * \return Boolean \c true if all pipes configured successfully, \c false otherwise. + */ + bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table, + const uint8_t Entries); + + /** Configures the specified pipe address with the given pipe type, endpoint address within the attached device, bank size + * and number of hardware banks. + * + * 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] Address Pipe address to configure. + * + * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low + * Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] EndpointAddress Endpoint address 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. + * + * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes must be configured in ascending order, + * or bank corruption will occur. + * \n\n + * + * \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's + * index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe. + * \n\n + * + * \note The default control pipe should not be manually configured by the user application, as it is + * automatically configured by the library internally. + * \n\n + * + * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which + * failed to reconfigure correctly will be selected. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + bool Pipe_ConfigurePipe(const uint8_t Address, + const uint8_t Type, + const uint8_t EndpointAddress, + const uint16_t Size, + const uint8_t Banks); + + /** Spin-loops until the currently selected non-control pipe is ready for the next packet of data to be read + * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect). + * + * \ingroup Group_PipeRW_UC3 + * + * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum. + */ + uint8_t Pipe_WaitUntilReady(void); + + /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given + * endpoint is found, it is automatically selected. + * + * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check. + * + * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found, + * \c false otherwise. + */ + bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Macros: */ + #if !defined(ENDPOINT_CONTROLEP) + #define ENDPOINT_CONTROLEP 0 + #endif + + /* Inline Functions: */ + static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) + { + uint8_t MaskVal = 0; + uint16_t CheckBytes = 8; + + while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE)) + { + MaskVal++; + CheckBytes <<= 1; + } + + return (MaskVal << AVR32_USBB_PSIZE_OFFSET); + } + + /* Function Prototypes: */ + void Pipe_ClearPipes(void); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_R.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_R.c new file mode 100644 index 000000000..ab69536b0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_R.c @@ -0,0 +1,85 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + + if (!(Length)) + Endpoint_ClearOUT(); + + while (Length) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + + if (Endpoint_IsOUTReceived()) + { + while (Length && Endpoint_BytesInEndpoint()) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + } + + Endpoint_ClearOUT(); + } + } + + while (!(Endpoint_IsINReady())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c new file mode 100644 index 000000000..c2d171db0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_Control_W.c @@ -0,0 +1,94 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + bool LastPacketFull = false; + + if (Length > USB_ControlRequest.wLength) + Length = USB_ControlRequest.wLength; + else if (!(Length)) + Endpoint_ClearIN(); + + while (Length || LastPacketFull) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + else if (Endpoint_IsOUTReceived()) + break; + + if (Endpoint_IsINReady()) + { + uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); + + while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInEndpoint++; + } + + LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); + Endpoint_ClearIN(); + } + } + + while (!(Endpoint_IsOUTReceived())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_RW.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_RW.c new file mode 100644 index 000000000..02ad97867 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Endpoint_RW.c @@ -0,0 +1,90 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_ENDPOINT(); + + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_ENDPOINT +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Pipe_RW.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Pipe_RW.c new file mode 100644 index 000000000..05846bb61 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/Template/Template_Pipe_RW.c @@ -0,0 +1,89 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + Pipe_SetPipeToken(TEMPLATE_TOKEN); + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Pipe_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_PIPE(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return PIPE_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Pipe_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return PIPE_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TOKEN +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_PIPE +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c new file mode 100644 index 000000000..8ee63318f --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c @@ -0,0 +1,222 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#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 defined(USB_CAN_BE_BOTH) + if (Mode == USB_MODE_UID) + { + AVR32_USBB.USBCON.uide = true; + USB_INT_Enable(USB_INT_IDTI); + USB_CurrentMode = USB_GetUSBModeFromUID(); + } + else + { + AVR32_USBB.USBCON.uide = false; + USB_CurrentMode = Mode; + } + #else + AVR32_USBB.USBCON.uide = false; + #endif + + USB_IsInitialized = true; + + USB_ResetInterface(); +} + +void USB_Disable(void) +{ + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Detach(); + USB_Controller_Disable(); + + USB_OTGPAD_Off(); + + #if defined(USB_CAN_BE_BOTH) + USB_CurrentMode = USB_MODE_None; + #endif + + AVR32_PM.GCCTRL[3].cen = false; + + USB_IsInitialized = false; +} + +void USB_ResetInterface(void) +{ + #if defined(USB_CAN_BE_BOTH) + bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide; + #endif + + AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC); + AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0); + AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].diven = (F_USB != USB_CLOCK_REQUIRED_FREQ); + AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].div = (F_USB == USB_CLOCK_REQUIRED_FREQ) ? 0 : (uint32_t)((F_USB / USB_CLOCK_REQUIRED_FREQ / 2) - 1); + AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].cen = true; + + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Controller_Reset(); + + #if defined(USB_CAN_BE_BOTH) + if (UIDModeSelectEnabled) + USB_INT_Enable(USB_INT_IDTI); + #endif + + USB_CLK_Unfreeze(); + + if (USB_CurrentMode == USB_MODE_Device) + { + #if defined(USB_CAN_BE_DEVICE) + AVR32_USBB.USBCON.uimod = true; + + USB_Init_Device(); + #endif + } + else if (USB_CurrentMode == USB_MODE_Host) + { + #if defined(INVERTED_VBUS_ENABLE_LINE) + AVR32_USBB.USBCON.vbuspo = true; + #endif + + #if defined(USB_CAN_BE_HOST) + AVR32_USBB.USBCON.uimod = false; + + USB_Init_Host(); + #endif + } + + USB_OTGPAD_On(); +} + +#if defined(USB_CAN_BE_DEVICE) +static void USB_Init_Device(void) +{ + USB_DeviceState = DEVICE_STATE_Unattached; + USB_Device_ConfigurationNumber = 0; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + USB_Device_RemoteWakeupEnabled = false; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + USB_Device_CurrentlySelfPowered = false; + #endif + + #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) + USB_Descriptor_Device_t* DeviceDescriptorPtr; + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + #endif + + if (USB_Options & USB_DEVICE_OPT_LOWSPEED) + { + USB_Device_SetLowSpeed(); + } + else + { + #if defined(USB_DEVICE_OPT_HIGHSPEED) + if (USB_Options & USB_DEVICE_OPT_HIGHSPEED) + USB_Device_SetHighSpeed(); + else + USB_Device_SetFullSpeed(); + #else + USB_Device_SetFullSpeed(); + #endif + } + + USB_INT_Enable(USB_INT_VBUSTI); + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + USB_Device_ControlEndpointSize, 1); + + USB_INT_Clear(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_EORSTI); + + USB_Attach(); +} +#endif + +#if defined(USB_CAN_BE_HOST) +static void USB_Init_Host(void) +{ + USB_HostState = HOST_STATE_Unattached; + USB_Host_ConfigurationNumber = 0; + USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE; + + USB_Host_HostMode_On(); + + USB_Host_VBUS_Auto_On(); + + USB_INT_Enable(USB_INT_DCONNI); + USB_INT_Enable(USB_INT_BCERRI); + + USB_Attach(); +} +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h new file mode 100644 index 000000000..bcae49bd4 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBController_UC3.h @@ -0,0 +1,365 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller definitions for the AVR32 UC3 microcontrollers. + * \copydetails Group_USBManagement_UC3 + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USBManagement + * \defgroup Group_USBManagement_UC3 USB Interface Management (UC3) + * \brief USB Controller definitions for the AVR32 UC3 microcontrollers. + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_UC3_H__ +#define __USBCONTROLLER_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../Events.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "../Host.h" + #include "../OTG.h" + #include "../Pipe.h" + #include "../HostStandardReq.h" + #include "../PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "../Device.h" + #include "../Endpoint.h" + #include "../DeviceStandardReq.h" + #include "../EndpointStream.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks and Defines: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if !defined(F_USB) + #error F_USB is not defined. You must define F_USB to the frequency of the clock input to the USB module. + #endif + + #if (defined(USB_SERIES_UC3A3_AVR) || defined(USB_SERIES_UC3A4_AVR)) + #if ((F_USB < 12000000) || (F_USB % 12000000)) + #error Invalid F_USB specified. F_USB must be a multiple of 12MHz for UC3A3 and UC3A4 devices. + #endif + #else + #if ((F_USB < 48000000) || (F_USB % 48000000)) + #error Invalid F_USB specified. F_USB must be a multiple of 48MHz for UC3A and UC3B devices. + #endif + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Controller Option Masks */ + //@{ + /** Selects one of the system's main clock oscillators as the input clock to the USB Generic Clock source + * generation module. This indicates that an external oscillator should be used directly instead of an + * internal PLL clock source. + */ + #define USB_OPT_GCLK_SRC_OSC (1 << 2) + + /** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source + * generation module. This indicates that one of the device's PLL outputs should be used instead of an + * external oscillator source. + */ + #define USB_OPT_GCLK_SRC_PLL (0 << 2) + + /** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */ + #define USB_OPT_GCLK_CHANNEL_0 (1 << 3) + + /** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */ + #define USB_OPT_GCLK_CHANNEL_1 (0 << 3) + //@} + + #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: */ + /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power). + * + * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise. + */ + static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool USB_VBUS_GetStatus(void) + { + return AVR32_USBB.USBSTA.vbus; + } + + /** 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) + { + AVR32_USBB.UDCON.detach = true; + } + + /** 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) + { + AVR32_USBB.UDCON.detach = false; + } + + /* 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 behavior. This should be comprised of + * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the + * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device + * mode speed. + * + * \note To reduce the FLASH requirements of the library if only device or host mode is required, + * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY + * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler + * via the -D switch. If the mode is statically set, this parameter does not exist in the + * function prototype. + * \n\n + * + * \note To reduce the FLASH requirements of the library if only fixed settings are required, + * the options may be set statically in the same manner as the mode (see the Mode parameter of + * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token, + * defined to the appropriate options masks. When the options are statically set, this + * parameter does not exist in the function prototype. + * + * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks. + */ + void USB_Init( + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + const uint8_t Mode + #endif + + #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__) + , + #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) + void + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + const uint8_t Options + #endif + ); + + /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO + * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface + * is restarted with the \ref USB_Init() function. + */ + void USB_Disable(void); + + /** Resets the interface, when already initialized. This will re-enumerate the device if already connected + * to a host, or re-enumerate an already attached device when in host mode. + */ + void USB_ResetInterface(void); + + /* Global Variables: */ + #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__) + /** Indicates the mode that the USB interface is currently initialized to, a value from the + * \ref USB_Modes_t enum. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \note When the controller is initialized into UID auto-detection mode, this variable will hold the + * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller + * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time + * options, or a limitation of the USB controller in the chosen device model) this will evaluate to + * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the + * USB interface is not initialized. + */ + extern volatile uint8_t USB_CurrentMode; + #elif defined(USB_HOST_ONLY) + #define USB_CurrentMode USB_MODE_Host + #elif defined(USB_DEVICE_ONLY) + #define USB_CurrentMode USB_MODE_Device + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init() + * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module. + * + * \attention 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__) + /* Macros: */ + #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) + #define USB_CLOCK_REQUIRED_FREQ 12000000UL + #else + #define USB_CLOCK_REQUIRED_FREQ 48000000UL + #endif + + /* 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_OTGPAD_On(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTGPAD_On(void) + { + AVR32_USBB.USBCON.otgpade = true; + } + + static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE; + static inline void USB_OTGPAD_Off(void) + { + AVR32_USBB.USBCON.otgpade = false; + } + + static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE; + static inline void USB_CLK_Freeze(void) + { + AVR32_USBB.USBCON.frzclk = true; + } + + static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE; + static inline void USB_CLK_Unfreeze(void) + { + AVR32_USBB.USBCON.frzclk = false; + } + + static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Enable(void) + { + AVR32_USBB.USBCON.usbe = true; + } + + static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Disable(void) + { + AVR32_USBB.USBCON.usbe = false; + } + + static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Reset(void) + { + AVR32_USBB.USBCON.usbe = false; + AVR32_USBB.USBCON.usbe = true; + } + + #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 (AVR32_USBB.USBSTA.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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c new file mode 100644 index 000000000..e11a4b642 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c @@ -0,0 +1,228 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBInterrupt.h" + +void USB_INT_DisableAllInterrupts(void) +{ + AVR32_USBB.USBCON.vbuste = false; + AVR32_USBB.USBCON.idte = false; + + AVR32_USBB.uhinteclr = -1; + AVR32_USBB.udinteclr = -1; +} + +void USB_INT_ClearAllInterrupts(void) +{ + AVR32_USBB.USBSTACLR.vbustic = true; + AVR32_USBB.USBSTACLR.idtic = true; + + AVR32_USBB.uhintclr = -1; + AVR32_USBB.udintclr = -1; +} + +ISR(USB_GEN_vect) +{ + #if defined(USB_CAN_BE_DEVICE) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) + { + USB_INT_Clear(USB_INT_SOFI); + + EVENT_USB_Device_StartOfFrame(); + } + #endif + + if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI)) + { + USB_INT_Clear(USB_INT_VBUSTI); + + if (USB_VBUS_GetStatus()) + { + USB_DeviceState = DEVICE_STATE_Powered; + EVENT_USB_Device_Connect(); + } + else + { + USB_DeviceState = DEVICE_STATE_Unattached; + EVENT_USB_Device_Disconnect(); + } + } + + if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI)) + { + USB_INT_Disable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_WAKEUPI); + + USB_CLK_Freeze(); + + USB_DeviceState = DEVICE_STATE_Suspended; + EVENT_USB_Device_Suspend(); + } + + if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI)) + { + USB_CLK_Unfreeze(); + + USB_INT_Clear(USB_INT_WAKEUPI); + + USB_INT_Disable(USB_INT_WAKEUPI); + USB_INT_Enable(USB_INT_SUSPI); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + EVENT_USB_Device_WakeUp(); + } + + if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) + { + USB_INT_Clear(USB_INT_EORSTI); + + USB_DeviceState = DEVICE_STATE_Default; + USB_Device_ConfigurationNumber = 0; + + USB_INT_Clear(USB_INT_SUSPI); + USB_INT_Disable(USB_INT_SUSPI); + USB_INT_Enable(USB_INT_WAKEUPI); + + USB_Device_SetDeviceAddress(0); + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + USB_Device_ControlEndpointSize, 1); + + #if defined(INTERRUPT_CONTROL_ENDPOINT) + USB_INT_Enable(USB_INT_RXSTPI); + #endif + + EVENT_USB_Device_Reset(); + } + #endif + + #if defined(USB_CAN_BE_HOST) + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI)) + { + USB_INT_Clear(USB_INT_HSOFI); + + EVENT_USB_Host_StartOfFrame(); + } + #endif + + if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI)) + { + USB_INT_Clear(USB_INT_DDISCI); + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Disable(USB_INT_DDISCI); + + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } + + if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI)) + { + USB_INT_Clear(USB_INT_VBERRI); + + USB_Host_VBUS_Manual_Off(); + USB_Host_VBUS_Auto_Off(); + + EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip); + EVENT_USB_Host_DeviceUnattached(); + + USB_HostState = HOST_STATE_Unattached; + } + + if (USB_INT_HasOccurred(USB_INT_DCONNI) && USB_INT_IsEnabled(USB_INT_DCONNI)) + { + USB_INT_Clear(USB_INT_DCONNI); + USB_INT_Disable(USB_INT_DCONNI); + + EVENT_USB_Host_DeviceAttached(); + + USB_INT_Enable(USB_INT_DDISCI); + + USB_HostState = HOST_STATE_Powered; + } + + if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI)) + { + USB_INT_Clear(USB_INT_BCERRI); + + EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0); + EVENT_USB_Host_DeviceUnattached(); + + USB_ResetInterface(); + } + #endif + + #if defined(USB_CAN_BE_BOTH) + if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI)) + { + USB_INT_Clear(USB_INT_IDTI); + + if (USB_DeviceState != DEVICE_STATE_Unattached) + EVENT_USB_Device_Disconnect(); + + if (USB_HostState != HOST_STATE_Unattached) + EVENT_USB_Host_DeviceUnattached(); + + USB_CurrentMode = USB_GetUSBModeFromUID(); + USB_ResetInterface(); + + EVENT_USB_UIDChange(); + } + #endif +} + +#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE) +ISR(USB_COM_vect) +{ + uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Disable(USB_INT_RXSTPI); + + GlobalInterruptEnable(); + + USB_Device_ProcessControlRequest(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + USB_INT_Enable(USB_INT_RXSTPI); + Endpoint_SelectEndpoint(PrevSelectedEndpoint); +} +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h new file mode 100644 index 000000000..625e3f782 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h @@ -0,0 +1,370 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller Interrupt definitions for the AVR32 UC3 microcontrollers. + * + * This file contains definitions required for the correct handling of low level USB service routine interrupts + * from the USB controller. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBINTERRUPT_UC3_H__ +#define __USBINTERRUPT_UC3_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* External Variables: */ + extern volatile uint32_t USB_Endpoint_SelectedEndpoint; + + /* Enums: */ + enum USB_Interrupts_t + { + USB_INT_VBUSTI = 0, + #if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)) + USB_INT_IDTI = 1, + #endif + #if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)) + USB_INT_WAKEUPI = 2, + USB_INT_SUSPI = 3, + USB_INT_EORSTI = 4, + USB_INT_SOFI = 5, + USB_INT_RXSTPI = 6, + #endif + #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)) + USB_INT_HSOFI = 7, + USB_INT_DCONNI = 8, + USB_INT_DDISCI = 9, + USB_INT_RSTI = 10, + USB_INT_BCERRI = 11, + USB_INT_VBERRI = 12, + #endif + }; + + /* Inline Functions: */ + static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Enable(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_VBUSTI: + AVR32_USBB.USBCON.vbuste = true; + break; + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + AVR32_USBB.USBCON.idte = true; + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + AVR32_USBB.UDINTESET.wakeupes = true; + break; + case USB_INT_SUSPI: + AVR32_USBB.UDINTESET.suspes = true; + break; + case USB_INT_EORSTI: + AVR32_USBB.UDINTESET.eorstes = true; + break; + case USB_INT_SOFI: + AVR32_USBB.UDINTESET.sofes = true; + break; + case USB_INT_RXSTPI: + (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].rxstpes = true; + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + AVR32_USBB.UHINTESET.hsofies = true; + break; + case USB_INT_DCONNI: + AVR32_USBB.UHINTESET.dconnies = true; + break; + case USB_INT_DDISCI: + AVR32_USBB.UHINTESET.ddiscies = true; + break; + case USB_INT_RSTI: + AVR32_USBB.UHINTESET.rsties = true; + break; + case USB_INT_BCERRI: + AVR32_USBB.USBCON.bcerre = true; + break; + case USB_INT_VBERRI: + AVR32_USBB.USBCON.vberre = true; + break; + #endif + } + } + + static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Disable(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_VBUSTI: + AVR32_USBB.USBCON.vbuste = false; + break; + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + AVR32_USBB.USBCON.idte = false; + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + AVR32_USBB.UDINTECLR.wakeupec = true; + break; + case USB_INT_SUSPI: + AVR32_USBB.UDINTECLR.suspec = true; + break; + case USB_INT_EORSTI: + AVR32_USBB.UDINTECLR.eorstec = true; + break; + case USB_INT_SOFI: + AVR32_USBB.UDINTECLR.sofec = true; + break; + case USB_INT_RXSTPI: + (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].rxstpec = true; + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + AVR32_USBB.UHINTECLR.hsofiec = true; + break; + case USB_INT_DCONNI: + AVR32_USBB.UHINTECLR.dconniec = true; + break; + case USB_INT_DDISCI: + AVR32_USBB.UHINTECLR.ddisciec = true; + break; + case USB_INT_RSTI: + AVR32_USBB.UHINTECLR.rstiec = true; + break; + case USB_INT_BCERRI: + AVR32_USBB.USBCON.bcerre = false; + break; + case USB_INT_VBERRI: + AVR32_USBB.USBCON.vberre = false; + break; + #endif + } + } + + static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Clear(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_VBUSTI: + AVR32_USBB.USBSTACLR.vbustic = true; + (void)AVR32_USBB.USBSTACLR; + break; + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + AVR32_USBB.USBSTACLR.idtic = true; + (void)AVR32_USBB.USBSTACLR; + break; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + AVR32_USBB.UDINTCLR.wakeupc = true; + (void)AVR32_USBB.UDINTCLR; + break; + case USB_INT_SUSPI: + AVR32_USBB.UDINTCLR.suspc = true; + (void)AVR32_USBB.UDINTCLR; + break; + case USB_INT_EORSTI: + AVR32_USBB.UDINTCLR.eorstc = true; + (void)AVR32_USBB.UDINTCLR; + break; + case USB_INT_SOFI: + AVR32_USBB.UDINTCLR.sofc = true; + (void)AVR32_USBB.UDINTCLR; + break; + case USB_INT_RXSTPI: + (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].rxstpic = true; + break; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + AVR32_USBB.UHINTCLR.hsofic = true; + (void)AVR32_USBB.UHINTCLR; + break; + case USB_INT_DCONNI: + AVR32_USBB.UHINTCLR.dconnic = true; + (void)AVR32_USBB.UHINTCLR; + break; + case USB_INT_DDISCI: + AVR32_USBB.UHINTCLR.ddiscic = true; + (void)AVR32_USBB.UHINTCLR; + break; + case USB_INT_RSTI: + AVR32_USBB.UHINTCLR.rstic = true; + (void)AVR32_USBB.UHINTCLR; + break; + case USB_INT_BCERRI: + AVR32_USBB.USBSTACLR.bcerric = true; + (void)AVR32_USBB.USBSTACLR; + break; + case USB_INT_VBERRI: + AVR32_USBB.USBSTACLR.vberric = true; + (void)AVR32_USBB.USBSTACLR; + break; + #endif + } + } + + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_VBUSTI: + return AVR32_USBB.USBCON.vbuste; + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + return AVR32_USBB.USBCON.idte; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + return AVR32_USBB.UDINTE.wakeupe; + case USB_INT_SUSPI: + return AVR32_USBB.UDINTE.suspe; + case USB_INT_EORSTI: + return AVR32_USBB.UDINTE.eorste; + case USB_INT_SOFI: + return AVR32_USBB.UDINTE.sofe; + case USB_INT_RXSTPI: + return (&AVR32_USBB.UECON0)[USB_Endpoint_SelectedEndpoint].rxstpe; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + return AVR32_USBB.UHINTE.hsofie; + case USB_INT_DCONNI: + return AVR32_USBB.UHINTE.dconnie; + case USB_INT_DDISCI: + return AVR32_USBB.UHINTE.ddiscie; + case USB_INT_RSTI: + return AVR32_USBB.UHINTE.rstie; + case USB_INT_BCERRI: + return AVR32_USBB.USBCON.bcerre; + case USB_INT_VBERRI: + return AVR32_USBB.USBCON.vberre; + #endif + } + + return false; + } + + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_VBUSTI: + return AVR32_USBB.USBSTA.vbusti; + #if defined(USB_CAN_BE_BOTH) + case USB_INT_IDTI: + return AVR32_USBB.USBSTA.idti; + #endif + #if defined(USB_CAN_BE_DEVICE) + case USB_INT_WAKEUPI: + return AVR32_USBB.UDINT.wakeup; + case USB_INT_SUSPI: + return AVR32_USBB.UDINT.susp; + case USB_INT_EORSTI: + return AVR32_USBB.UDINT.eorst; + case USB_INT_SOFI: + return AVR32_USBB.UDINT.sof; + case USB_INT_RXSTPI: + return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rxstpi; + #endif + #if defined(USB_CAN_BE_HOST) + case USB_INT_HSOFI: + return AVR32_USBB.UHINT.hsofi; + case USB_INT_DCONNI: + return AVR32_USBB.UHINT.dconni; + case USB_INT_DDISCI: + return AVR32_USBB.UHINT.ddisci; + case USB_INT_RSTI: + return AVR32_USBB.UHINT.rsti; + case USB_INT_BCERRI: + return AVR32_USBB.USBSTA.bcerri; + case USB_INT_VBERRI: + return AVR32_USBB.USBSTA.vberri; + #endif + } + + return false; + } + + /* Includes: */ + #include "../USBMode.h" + #include "../Events.h" + #include "../USBController.h" + + /* Function Prototypes: */ + void USB_INT_ClearAllInterrupts(void); + void USB_INT_DisableAllInterrupts(void); + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + #if defined(__DOXYGEN__) + /** Interrupt service routine handler for the USB controller ISR group. This interrupt routine must be + * linked to the entire USB controller ISR vector group inside the AVR32's interrupt controller peripheral, + * using the user application's preferred USB controller driver. + */ + void USB_GEN_vect(void); + #else + ISR(USB_GEN_vect); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBController.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBController.h new file mode 100644 index 000000000..9b1f0a9a6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBController.h @@ -0,0 +1,151 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Common USB Controller definitions for all architectures. + * \copydetails Group_USBManagement + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_USBManagement USB Interface Management + * \brief USB Controller definitions for general USB controller management. + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_H__ +#define __USBCONTROLLER_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks and Defines: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Defines: */ + /** \name Endpoint Direction Masks */ + //@{ + /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's + * direction for comparing with the \c ENDPOINT_DIR_* masks. + */ + #define ENDPOINT_DIR_MASK 0x80 + + /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with + * the index of the address within a device to obtain the full endpoint address. + */ + #define ENDPOINT_DIR_OUT 0x00 + + /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with + * the index of the address within a device to obtain the full endpoint address. + */ + #define ENDPOINT_DIR_IN 0x80 + //@} + + /** \name Pipe Direction Masks */ + //@{ + /** Pipe direction mask, for masking against pipe addresses to retrieve the pipe's + * direction for comparing with the \c PIPE_DIR_* masks. + */ + #define PIPE_DIR_MASK 0x80 + + /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with + * the index of the address within a device to obtain the full endpoint address. + */ + #define PIPE_DIR_OUT 0x00 + + /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with + * the index of the address within a device to obtain the full endpoint address. + */ + #define PIPE_DIR_IN 0x80 + //@} + + /** \name Endpoint/Pipe Type Masks */ + //@{ + /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared + * with the \c EP_TYPE_* masks to determine the exact type of the endpoint. + */ + #define EP_TYPE_MASK 0x03 + + /** Mask for a CONTROL type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_CONTROL 0x00 + + /** Mask for an ISOCHRONOUS type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_ISOCHRONOUS 0x01 + + /** Mask for a BULK type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_BULK 0x02 + + /** Mask for an INTERRUPT type endpoint or pipe. + * + * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions. + */ + #define EP_TYPE_INTERRUPT 0x03 + //@} + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/USBController_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/USBController_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/USBController_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBInterrupt.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBInterrupt.h new file mode 100644 index 000000000..583860262 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBInterrupt.h @@ -0,0 +1,73 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB controller interrupt service routine management. + * + * This file contains definitions required for the correct handling of low level USB service routine interrupts + * from the USB controller. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBINTERRUPT_H__ +#define __USBINTERRUPT_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Architecture Includes: */ + #if (ARCH == ARCH_AVR8) + #include "AVR8/USBInterrupt_AVR8.h" + #elif (ARCH == ARCH_UC3) + #include "UC3/USBInterrupt_UC3.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/USBInterrupt_XMEGA.h" + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBMode.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBMode.h new file mode 100644 index 000000000..8a52b092b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBMode.h @@ -0,0 +1,286 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB mode and feature support definitions. + * \copydetails Group_USBMode + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USB + * \defgroup Group_USBMode USB Mode Tokens + * \brief USB mode and feature support definitions. + * + * This file defines macros indicating the type of USB controller the library is being compiled for, and its + * capabilities. These macros may then be referenced in the user application to selectively enable or disable + * code sections depending on if they are defined or not. + * + * After the inclusion of the master USB driver header, one or more of the following tokens may be defined, to + * allow the user code to conditionally enable or disable code based on the USB controller family and allowable + * USB modes. These tokens may be tested against to eliminate code relating to a USB mode which is not enabled for + * the given compilation. + * + * @{ + */ + +#ifndef __USBMODE_H__ +#define __USBMODE_H__ + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + #if defined(__DOXYGEN__) + /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller + * (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined. + */ + #define USB_SERIES_2_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller + * (i.e. ATMEGAxxU4) when defined. + */ + #define USB_SERIES_4_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller + * (i.e. AT90USBxxx6) when defined. + */ + #define USB_SERIES_6_AVR + + /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller + * (i.e. AT90USBxxx7) when defined. + */ + #define USB_SERIES_7_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller + * (i.e. AT32UC3A0*) when defined. + */ + #define USB_SERIES_UC3A0_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller + * (i.e. AT32UC3A1*) when defined. + */ + #define USB_SERIES_UC3A1_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller + * (i.e. AT32UC3A3*) when defined. + */ + #define USB_SERIES_UC3A3_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A4 Series USB controller + * (i.e. AT32UC3A4*) when defined. + */ + #define USB_SERIES_UC3A4_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller + * (i.e. AT32UC3B0*) when defined. + */ + #define USB_SERIES_UC3B0_AVR + + /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller + * (i.e. AT32UC3B1*) when defined. + */ + #define USB_SERIES_UC3B1_AVR + + /** Indicates that the target AVR microcontroller belongs to the XMEGA A1U Series USB controller + * (i.e. ATXMEGA*A1U) when defined. + */ + #define USB_SERIES_A1U_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA A3U Series USB controller + * (i.e. ATXMEGA*A3U) when defined. + */ + #define USB_SERIES_A3U_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA A4U Series USB controller + * (i.e. ATXMEGA*A4U) when defined. + */ + #define USB_SERIES_A4U_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA B1 Series USB controller + * (i.e. ATXMEGA*B1) when defined. + */ + #define USB_SERIES_B1_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA B3 Series USB controller + * (i.e. ATXMEGA*B3) when defined. + */ + #define USB_SERIES_B3_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA C3 Series USB controller + * (i.e. ATXMEGA*C3) when defined. + */ + #define USB_SERIES_C3_XMEGA + + /** Indicates that the target AVR microcontroller belongs to the XMEGA C4 Series USB controller + * (i.e. ATXMEGA*C4) when defined. + */ + #define USB_SERIES_C4_XMEGA + + /** Indicates that the target microcontroller and compilation settings allow for the + * target to be configured in USB Device mode when defined. + */ + #define USB_CAN_BE_DEVICE + + /** Indicates that the target microcontroller and compilation settings allow for the + * target to be configured in USB Host mode when defined. + */ + #define USB_CAN_BE_HOST + + /** Indicates that the target microcontroller and compilation settings allow for the + * target to be configured in either USB Device or Host mode when defined. + */ + #define USB_CAN_BE_BOTH + #else + /* Macros: */ + #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \ + defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)) + #define USB_SERIES_2_AVR + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)) + #define USB_SERIES_4_AVR + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) + #define USB_SERIES_6_AVR + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) + #define USB_SERIES_7_AVR + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \ + defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__)) + #define USB_SERIES_UC3A0_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \ + defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__)) + #define USB_SERIES_UC3A1_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \ + defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \ + defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A364S__)) + #define USB_SERIES_UC3A3_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \ + defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \ + defined(__AVR32_UC3A464__) || defined(__AVR32_UC3A464S__)) + #define USB_SERIES_UC3A4_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \ + defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__)) + #define USB_SERIES_UC3B0_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \ + defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__)) + #define USB_SERIES_UC3B1_AVR32 + #define USB_CAN_BE_DEVICE + #define USB_CAN_BE_HOST + #elif (defined(__AVR_ATxmega128A1U__) || defined(__AVR_ATxmega64A1U__)) + #define USB_SERIES_A1U_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega64A3U__) || defined(__AVR_ATxmega128A3U__) || \ + defined(__AVR_ATxmega192A3U__) || defined(__AVR_ATxmega256A3U__)) + #define USB_SERIES_A3U_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega256A3BU__)) + #define USB_SERIES_A3BU_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega16A4U__) || defined(__AVR_ATxmega32A4U__) || \ + defined(__AVR_ATxmega64A4U__) || defined(__AVR_ATxmega128A4U__)) + #define USB_SERIES_A4U_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega128B1__) || defined(__AVR_ATxmega64B1__)) + #define USB_SERIES_B1_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega128B3__) || defined(__AVR_ATxmega64B3__)) + #define USB_SERIES_B3_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega128C3__) || defined(__AVR_ATxmega64C3__) || \ + defined(__AVR_ATxmega192C3__) || defined(__AVR_ATxmega256C3__) || \ + defined(__AVR_ATxmega384C3__)) + #define USB_SERIES_C3_XMEGA + #define USB_CAN_BE_DEVICE + #elif (defined(__AVR_ATxmega16C4__) || defined(__AVR_ATxmega32C4__)) + #define USB_SERIES_C4_XMEGA + #define USB_CAN_BE_DEVICE + #endif + + #if (defined(USB_CAN_BE_DEVICE) && defined(USB_CAN_BE_HOST)) + #define USB_CAN_BE_BOTH + #endif + + #if defined(USB_HOST_ONLY) + #if !defined(USB_CAN_BE_HOST) + #error USB_HOST_ONLY is not available for the currently selected microcontroller model. + #else + #undef USB_CAN_BE_DEVICE + #undef USB_CAN_BE_BOTH + #endif + #endif + + #if defined(USB_DEVICE_ONLY) + #if !defined(USB_CAN_BE_DEVICE) + #error USB_DEVICE_ONLY is not available for the currently selected microcontroller model. + #else + #undef USB_CAN_BE_HOST + #undef USB_CAN_BE_BOTH + #endif + #endif + + #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY)) + #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive. + #endif + + #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST)) + #error The currently selected device or architecture is not supported under the USB component of the library. + #endif + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.c new file mode 100644 index 000000000..e0a99150a --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.c @@ -0,0 +1,91 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USBTASK_C +#define __INCLUDE_FROM_USB_DRIVER +#include "USBTask.h" + +volatile bool USB_IsInitialized; +USB_Request_Header_t USB_ControlRequest; + +#if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR) +volatile uint8_t USB_HostState; +#endif + +#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR) +volatile uint8_t USB_DeviceState; +#endif + +void USB_USBTask(void) +{ + #if defined(USB_HOST_ONLY) + USB_HostTask(); + #elif defined(USB_DEVICE_ONLY) + USB_DeviceTask(); + #else + if (USB_CurrentMode == USB_MODE_Device) + USB_DeviceTask(); + #if defined(USB_CAN_BE_HOST) + else if (USB_CurrentMode == USB_MODE_Host) + USB_HostTask(); + #endif + #endif +} + +#if defined(USB_CAN_BE_DEVICE) +static void USB_DeviceTask(void) +{ + if (USB_DeviceState != DEVICE_STATE_Unattached) + { + uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); + + Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); + + if (Endpoint_IsSETUPReceived()) + USB_Device_ProcessControlRequest(); + + Endpoint_SelectEndpoint(PrevEndpoint); + } +} +#endif + +#if defined(USB_CAN_BE_HOST) +static void USB_HostTask(void) +{ + uint8_t PrevPipe = Pipe_GetCurrentPipe(); + + Pipe_SelectPipe(PIPE_CONTROLPIPE); + + USB_Host_ProcessNextHostState(); + + Pipe_SelectPipe(PrevPipe); +} +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.h new file mode 100644 index 000000000..531fa6dca --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/USBTask.h @@ -0,0 +1,204 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Main USB service task management. + * + * This file contains the function definitions required for the main USB service task, which must be called + * from the user application to ensure that the USB connection to or from a connected USB device is maintained. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBTASK_H__ +#define __USBTASK_H__ + + /* Includes: */ + #include "../../../Common/Common.h" + #include "USBMode.h" + #include "USBController.h" + #include "Events.h" + #include "StdRequestType.h" + #include "StdDescriptors.h" + + #if defined(USB_CAN_BE_DEVICE) + #include "DeviceStandardReq.h" + #endif + + #if defined(USB_CAN_BE_HOST) + #include "HostStandardReq.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Global Variables: */ + /** Indicates if the USB interface is currently initialized but not necessarily connected to a host + * or device (i.e. if \ref USB_Init() has been run). If this is false, all other library globals related + * to the USB driver are invalid. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \ingroup Group_USBManagement + */ + extern volatile bool USB_IsInitialized; + + /** Structure containing the last received Control request when in Device mode (for use in user-applications + * inside of the \ref EVENT_USB_Device_ControlRequest() event, or for filling up with a control request to + * issue when in Host mode before calling \ref USB_Host_SendControlRequest(). + * + * \note The contents of this structure is automatically endian-corrected for the current CPU architecture. + * + * \ingroup Group_USBManagement + */ + extern USB_Request_Header_t USB_ControlRequest; + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__) + /** Indicates the current host state machine state. When in host mode, this indicates the state + * via one of the values of the \ref USB_Host_States_t enum values. + * + * This value should not be altered by the user application as it is handled automatically by the + * library. + * + * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be + * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the + * \c HOST_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to + * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used + * in the user application except implicitly via the library APIs. + * + * \note This global is only present if the user application can be a USB host. + * + * \see \ref USB_Host_States_t for a list of possible device states. + * + * \ingroup Group_Host + */ + extern volatile uint8_t USB_HostState; + #else + #define _GET_HOST_GPIOR_NAME2(y) GPIOR ## y + #define _GET_HOST_GPIOR_NAME(x) _GET_HOST_GPIOR_NAME2(x) + #define USB_HostState _GET_HOST_GPIOR_NAME(HOST_STATE_AS_GPIOR) + #endif + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__) + /** Indicates the current device state machine state. When in device mode, this indicates the state + * via one of the values of the \ref USB_Device_States_t enum values. + * + * This value should not be altered by the user application as it is handled automatically by the + * library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used + * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events). + * + * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be + * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the + * \c DEVICE_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to + * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used + * in the user application except implicitly via the library APIs. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value except in the circumstances outlined above. + * + * \note This global is only present if the user application can be a USB device. + * \n\n + * + * \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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.c new file mode 100644 index 000000000..47c345900 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.c @@ -0,0 +1,49 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Device.h" + +void USB_Device_SendRemoteWakeup(void) +{ + USB.CTRLB |= USB_RWAKEUP_bm; +} + +#endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.h new file mode 100644 index 000000000..aec693a3c --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.h @@ -0,0 +1,258 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Device definitions for the AVR XMEGA microcontrollers. + * \copydetails Group_Device_XMEGA + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_Device + * \defgroup Group_Device_XMEGA Device Management (XMEGA) + * \brief USB Device definitions for the AVR XMEGA microcontrollers. + * + * Architecture specific USB Device definitions for the Atmel AVR XMEGA microcontrollers. + * + * @{ + */ + +#ifndef __USBDEVICE_XMEGA_H__ +#define __USBDEVICE_XMEGA_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBController.h" + #include "../StdDescriptors.h" + #include "../USBInterrupt.h" + #include "../Endpoint.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)) + #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive. + #endif + + #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)) + #error USE_FLASH_DESCRIPTORS and USE_RAM_DESCRIPTORS are mutually exclusive. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Device Mode Option Masks */ + //@{ + /** 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) + + #if (F_USB > 6000000) + /** 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) + #endif + //@} + + #if (!defined(NO_INTERNAL_SERIAL) || defined(__DOXYGEN__)) + /** String descriptor index for the device's unique serial number string descriptor within the device. + * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port + * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain + * a unique serial number internally, and setting the device descriptors serial number string index to this value + * will cause it to use the internal serial number. + * + * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial + * number for the device. + */ + #define USE_INTERNAL_SERIAL 0xDC + + /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_LENGTH_BITS (8 * (1 + (offsetof(NVM_PROD_SIGNATURES_t, COORDY1) - offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0)))) + + /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller + * model. + */ + #define INTERNAL_SERIAL_START_ADDRESS offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0) + #else + #define USE_INTERNAL_SERIAL NO_DESCRIPTOR + + #define INTERNAL_SERIAL_LENGTH_BITS 0 + #define INTERNAL_SERIAL_START_ADDRESS 0 + #endif + + /* Function Prototypes: */ + /** Sends a Remote Wakeup request to the host. This signals to the host that the device should + * be taken out of suspended mode, and communications should resume. + * + * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the + * host computer when the host has suspended all USB devices to enter a low power state. + * + * \note This function should only be used if the device has indicated to the host that it + * supports the Remote Wakeup feature in the device descriptors, and should only be + * issued if the host is currently allowing remote wakeup events from the device (i.e., + * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP + * compile time option is used, this function is unavailable. + * \n\n + * + * \note The USB clock must be running for this function to operate. If the stack is initialized with + * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running + * before attempting to call this function. + * + * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors. + */ + void USB_Device_SendRemoteWakeup(void); + + /* Inline Functions: */ + /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) + * the frame number is incremented by one. + * + * \return Current USB frame number from the USB controller. + */ + static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline uint16_t USB_Device_GetFrameNumber(void) + { + return ((USB_EndpointTable_t*)USB.EPPTR)->FrameNum; + } + + #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 This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_EnableSOFEvents(void) + { + USB.INTCTRLA |= USB_SOFIE_bm; + } + + /** 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 This function is not available when the \c NO_SOF_EVENTS compile time token is defined. + */ + static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_DisableSOFEvents(void) + { + USB.INTCTRLA &= ~USB_SOFIE_bm; + } + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Inline Functions: */ + static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetLowSpeed(void) + { + USB.CTRLA &= ~USB_SPEED_bm; + } + + static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetFullSpeed(void) + { + USB.CTRLA |= USB_SPEED_bm; + } + + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void USB_Device_SetDeviceAddress(const uint8_t Address) + { + USB.ADDR = Address; + } + + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_Device_IsAddressSet(void) + { + return ((USB.ADDR != 0) ? true : false); + } + + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1); + static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) + { + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS; + + for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) + { + uint8_t SerialByte; + + NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc; + SerialByte = pgm_read_byte(SigReadAddress); + NVM.CMD = 0; + + if (SerialCharNum & 0x01) + { + SerialByte >>= 4; + SigReadAddress++; + } + + SerialByte &= 0x0F; + + UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte)); + } + + SetGlobalInterruptMask(CurrentGlobalInt); + } + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c new file mode 100644 index 000000000..0a1a77505 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c @@ -0,0 +1,275 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "EndpointStream_XMEGA.h" + +#if !defined(CONTROL_ONLY_DEVICE) +uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Discard_8(); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t ErrorCode; + uint16_t BytesInTransfer = 0; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + Length -= *BytesProcessed; + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + Endpoint_Write_8(0); + + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations, + * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */ + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE +#define TEMPLATE_BUFFER_TYPE const void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE +#define TEMPLATE_BUFFER_TYPE void* +#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_RW.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE + #define TEMPLATE_BUFFER_TYPE const void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE + #define TEMPLATE_BUFFER_TYPE void* + #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_RW.c" +#endif + +#endif + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr) +#include "Template/Template_Endpoint_Control_W.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE +#define TEMPLATE_BUFFER_OFFSET(Length) 0 +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE +#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) +#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount +#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8() +#include "Template/Template_Endpoint_Control_R.c" + +#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" +#endif + +#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr)) + #include "Template/Template_Endpoint_Control_W.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE + #define TEMPLATE_BUFFER_OFFSET(Length) 0 + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_Control_R.c" + + #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE + #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) + #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount + #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8()) + #include "Template/Template_Endpoint_Control_R.c" +#endif + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.h new file mode 100644 index 000000000..4d2a9f573 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.h @@ -0,0 +1,648 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Endpoint data stream transmission and reception management for the AVR XMEGA microcontrollers. + * \copydetails Group_EndpointStreamRW_XMEGA + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointStreamRW + * \defgroup Group_EndpointStreamRW_XMEGA Read/Write of Multi-Byte Streams (XMEGA) + * \brief Endpoint data stream transmission and reception management for the Atmel AVR XMEGA architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of data streams from + * and to endpoints. + * + * @{ + */ + +#ifndef __ENDPOINT_STREAM_XMEGA_H__ +#define __ENDPOINT_STREAM_XMEGA_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../USBTask.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Function Prototypes: */ + /** \name Stream functions for null data */ + //@{ + + /** Reads and discards the given number of bytes from the currently selected endpoint's bank, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of bytes to discard via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Discard_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending + * full packets to the host as needed. The last packet is not automatically sent once the + * remaining bytes have been written; the user is responsible for manually sending the last + * packet to the host via the \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Length Number of zero bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Null_Stream(uint16_t Length, + uint16_t* const BytesProcessed); + + //@} + + /** \name Stream functions for RAM source/destination data */ + //@{ + + /** Writes the given number of bytes to the endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes full while there is still data to process (and after the current + * packet transmission has been initiated) the BytesProcessed location will be updated with the + * total number of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The last packet filled is not automatically sent; + * the user is responsible for manually sending the last written packet to the host via the + * \ref Endpoint_ClearIN() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Stream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, + * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid + * storage location, the transfer will instead be performed as a series of chunks. Each time + * the endpoint bank becomes empty while there is still data to process (and after the current + * packet has been acknowledged) the BytesProcessed location will be updated with the total number + * of bytes processed in the stream, and the function will exit with an error code of + * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed + * in the user code - to continue the transfer, call the function again with identical parameters + * and it will resume until the BytesProcessed value reaches the total transfer length. + * + * Single Stream Transfer Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * + * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * NULL)) != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * Partial Stream Transfers Example: + * \code + * uint8_t DataStream[512]; + * uint8_t ErrorCode; + * uint16_t BytesProcessed; + * + * BytesProcessed = 0; + * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream), + * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer) + * { + * // Stream not yet complete - do other actions here, abort if required + * } + * + * if (ErrorCode != ENDPOINT_RWSTREAM_NoError) + * { + * // Stream failed to complete - check ErrorCode here + * } + * \endcode + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The last packet is not automatically + * discarded once the remaining bytes has been read; the user is responsible for manually + * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro. + * + * \note This routine should not be used on CONTROL type endpoints. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Stream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the status OUT packet + * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian, + * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared + * in both failure and success states; the user is responsible for manually clearing the status OUT packet + * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian, + * discarding fully read packets from the host as needed. The device IN acknowledgement is not + * automatically sent after success or failure states; the user is responsible for manually sending the + * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for EEPROM source/destination data */ + //@{ + + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE(). + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_EStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE(). + * + * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_LE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE(). + * + * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be read at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_EStream_BE(void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE(). + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[out] Buffer Pointer to the destination data buffer to write to. + * \param[in] Length Number of bytes to send via the currently selected endpoint. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /** \name Stream functions for PROGMEM source/destination data */ + //@{ + + /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_LE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current + * transaction should be updated, \c NULL if the entire stream should be written at once. + * + * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_PStream_BE(const void* const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + + /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE(). + * + * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly. + * + * \note This function automatically clears the control transfer's status stage. Do not manually attempt + * to clear the status stage when using this routine in a control transaction. + * \n\n + * + * \note This routine should only be used on CONTROL type endpoints. + * \n\n + * + * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained + * together; i.e. the entire stream data must be read or written at the one time. + * + * \param[in] Buffer Pointer to the source data buffer to read from. + * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer. + * + * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum. + */ + uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer, + uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); + //@} + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c new file mode 100644 index 000000000..b105e18c3 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c @@ -0,0 +1,168 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_DEVICE) + +#include "../Endpoint.h" + +#if !defined(FIXED_CONTROL_ENDPOINT_SIZE) +uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE; +#endif + +Endpoint_FIFOPair_t USB_Endpoint_FIFOs[ENDPOINT_TOTAL_ENDPOINTS]; + +volatile uint8_t USB_Endpoint_SelectedEndpoint; +volatile USB_EP_t* USB_Endpoint_SelectedHandle; +volatile Endpoint_FIFO_t* USB_Endpoint_SelectedFIFO; + +bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, + const uint8_t Entries) +{ + for (uint8_t i = 0; i < Entries; i++) + { + if (!(Table[i].Address)) + continue; + + if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks))) + { + return false; + } + } + + return true; +} + +bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Address, + const uint8_t Config, + const uint8_t Size) +{ + Endpoint_SelectEndpoint(Address); + + USB_Endpoint_SelectedHandle->CTRL = 0; + USB_Endpoint_SelectedHandle->STATUS = (Address & ENDPOINT_DIR_IN) ? USB_EP_BUSNACK0_bm : 0; + USB_Endpoint_SelectedHandle->CTRL = Config; + USB_Endpoint_SelectedHandle->CNT = 0; + USB_Endpoint_SelectedHandle->DATAPTR = (intptr_t)USB_Endpoint_SelectedFIFO->Data; + + USB_Endpoint_SelectedFIFO->Length = (Address & ENDPOINT_DIR_IN) ? Size : 0; + USB_Endpoint_SelectedFIFO->Position = 0; + + return true; +} + +void Endpoint_ClearEndpoints(void) +{ + for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) + { + ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0; + ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0; + } +} + +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 + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h new file mode 100644 index 000000000..a4118889b --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h @@ -0,0 +1,777 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Endpoint definitions for the AVR XMEGA microcontrollers. + * \copydetails Group_EndpointManagement_XMEGA + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_EndpointRW + * \defgroup Group_EndpointRW_XMEGA Endpoint Data Reading and Writing (XMEGA) + * \brief Endpoint data read/write definitions for the Atmel AVR XMEGA architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints. + */ + +/** \ingroup Group_EndpointPrimitiveRW + * \defgroup Group_EndpointPrimitiveRW_XMEGA Read/Write of Primitive Data Types (XMEGA) + * \brief Endpoint primitive read/write definitions for the Atmel AVR XMEGA architecture. + * + * Functions, macros, variables, enums and types related to data reading and writing of primitive data types + * from and to endpoints. + */ + +/** \ingroup Group_EndpointPacketManagement + * \defgroup Group_EndpointPacketManagement_XMEGA Endpoint Packet Management (XMEGA) + * \brief Endpoint packet management definitions for the Atmel AVR XMEGA architecture. + * + * Functions, macros, variables, enums and types related to packet management of endpoints. + */ + +/** \ingroup Group_EndpointManagement + * \defgroup Group_EndpointManagement_XMEGA Endpoint Management (XMEGA) + * \brief Endpoint management definitions for the Atmel AVR XMEGA architecture. + * + * Functions, macros and enums related to endpoint management when in USB Device mode. This + * module contains the endpoint management macros, as well as endpoint interrupt and data + * send/receive functions for various data types. + * + * @{ + */ + +#ifndef __ENDPOINT_XMEGA_H__ +#define __ENDPOINT_XMEGA_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + #include "../USBController.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (!defined(MAX_ENDPOINT_INDEX) && !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 16 + #else + #if defined(CONTROL_ONLY_DEVICE) + #define ENDPOINT_TOTAL_ENDPOINTS 1 + #else + #define ENDPOINT_TOTAL_ENDPOINTS (MAX_ENDPOINT_INDEX + 1) + #endif + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Type Defines: */ + typedef struct + { + uint8_t Data[64]; + + uint8_t Length; + uint8_t Position; + } Endpoint_FIFO_t; + + typedef struct + { + Endpoint_FIFO_t OUT; + Endpoint_FIFO_t IN; + } Endpoint_FIFOPair_t; + + /* External Variables: */ + extern Endpoint_FIFOPair_t USB_Endpoint_FIFOs[ENDPOINT_TOTAL_ENDPOINTS]; + extern volatile uint8_t USB_Endpoint_SelectedEndpoint; + extern volatile USB_EP_t* USB_Endpoint_SelectedHandle; + extern volatile Endpoint_FIFO_t* USB_Endpoint_SelectedFIFO; + + /* 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 << USB_EP_BUFSIZE_gp); + } + + /* Function Prototypes: */ + bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Address, + const uint8_t Config, + const uint8_t Size); + void Endpoint_ClearEndpoints(void); + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size + * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined. + */ + #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8 + #endif + + /* Enums: */ + /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function. + * + * \ingroup Group_EndpointRW_XMEGA + */ + 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: */ + /** Selects the given endpoint address. + * + * Any endpoint operations which do not require the endpoint address to be indicated will operate on + * the currently selected endpoint. + * + * \param[in] Address Endpoint address to select. + */ + static inline void Endpoint_SelectEndpoint(const uint8_t Address); + static inline void Endpoint_SelectEndpoint(const uint8_t Address) + { + uint8_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK); + + USB_Endpoint_SelectedEndpoint = Address; + + if (Address & ENDPOINT_DIR_IN) + { + USB_Endpoint_SelectedFIFO = &USB_Endpoint_FIFOs[EndpointNumber].IN; + USB_Endpoint_SelectedHandle = &((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EndpointNumber].IN; + } + else + { + USB_Endpoint_SelectedFIFO = &USB_Endpoint_FIFOs[EndpointNumber].OUT; + USB_Endpoint_SelectedHandle = &((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EndpointNumber].OUT; + } + } + + /** Configures the specified endpoint address 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] Address Endpoint address to configure. + * + * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types + * are available on Low Speed USB devices - refer to the USB 2.0 specification. + * + * \param[in] 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 hardware banks to use for the endpoint being configured. + * + * \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. + * + * \return Boolean \c true if the configuration succeeded, \c false otherwise. + */ + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, + const uint8_t Type, + const uint16_t Size, + const uint8_t Banks) ATTR_ALWAYS_INLINE; + static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address, + const uint8_t Type, + const uint16_t Size, + const uint8_t Banks) + { + uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size)); + + if ((Address & ENDPOINT_EPNUM_MASK) >= ENDPOINT_TOTAL_ENDPOINTS) + return false; + + // TODO - Fix once limitations are lifted + EPConfigMask &= ~USB_EP_PINGPONG_bm; + if (Size > 64) + return false; + + switch (Type) + { + case EP_TYPE_CONTROL: + EPConfigMask |= USB_EP_TYPE_CONTROL_gc; + break; + case EP_TYPE_ISOCHRONOUS: + EPConfigMask |= USB_EP_TYPE_ISOCHRONOUS_gc; + break; + default: + EPConfigMask |= USB_EP_TYPE_BULK_gc; + break; + } + + if (Type == EP_TYPE_CONTROL) + Endpoint_ConfigureEndpoint_PRV(Address ^ ENDPOINT_DIR_IN, EPConfigMask, Size); + + return Endpoint_ConfigureEndpoint_PRV(Address, EPConfigMask, Size); + } + + /** Indicates the number of bytes currently stored in the current endpoint's selected bank. + * + * \ingroup Group_EndpointRW_XMEGA + * + * \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 (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN) + return USB_Endpoint_SelectedFIFO->Position; + else + return (USB_Endpoint_SelectedFIFO->Length - USB_Endpoint_SelectedFIFO->Position); + } + + /** Get the endpoint address of the currently selected endpoint. This is typically used to save + * the currently selected endpoint 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) + { + return USB_Endpoint_SelectedEndpoint; + } + + /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's + * data In and Out pointers to the bank's contents. + * + * \param[in] Address Endpoint address whose FIFO buffers are to be reset. + */ + static inline void Endpoint_ResetEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ResetEndpoint(const uint8_t Address) + { + if (Address & ENDPOINT_DIR_IN) + USB_Endpoint_FIFOs[Address & ENDPOINT_EPNUM_MASK].IN.Position = 0; + else + USB_Endpoint_FIFOs[Address & ENDPOINT_EPNUM_MASK].OUT.Position = 0; + } + + /** Determines if the currently selected endpoint is enabled, but not necessarily configured. + * + * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise. + */ + static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsEnabled(void) + { + return true; + } + + /** 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_XMEGA + */ + static inline void Endpoint_AbortPendingIN(void) + { + USB_Endpoint_SelectedHandle->STATUS |= USB_EP_BUSNACK0_bm; + } + + /** 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_XMEGA + * + * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending + * on its direction. + */ + static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsReadWriteAllowed(void) + { + return (USB_Endpoint_SelectedFIFO->Position < USB_Endpoint_SelectedFIFO->Length); + } + + /** Determines if the currently selected endpoint is configured. + * + * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise. + */ + static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsConfigured(void) + { + return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) ? true : false); + } + + /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host. + * + * \ingroup Group_EndpointPacketManagement_XMEGA + * + * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise. + */ + static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsINReady(void) + { + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); + + return ((USB_Endpoint_SelectedHandle->STATUS & USB_EP_BUSNACK0_bm) ? true : false); + } + + /** Determines if the selected OUT endpoint has received new packet from the host. + * + * \ingroup Group_EndpointPacketManagement_XMEGA + * + * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise. + */ + static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsOUTReceived(void) + { + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); + + if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_TRNCOMPL0_bm) + { + USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT; + return true; + } + + return false; + } + + /** Determines if the current CONTROL type endpoint has received a SETUP packet. + * + * \ingroup Group_EndpointPacketManagement_XMEGA + * + * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise. + */ + static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsSETUPReceived(void) + { + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); + + if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm) + { + USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT; + return true; + } + + return false; + } + + /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the + * endpoint for the next packet. + * + * \ingroup Group_EndpointPacketManagement_XMEGA + * + * \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) + { + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); + USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm); + USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm; + USB_Endpoint_SelectedFIFO->Position = 0; + + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); + USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm; + USB_Endpoint_SelectedFIFO->Position = 0; + } + + /** 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_XMEGA + */ + static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearIN(void) + { + USB_Endpoint_SelectedHandle->CNT = USB_Endpoint_SelectedFIFO->Position; + USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm); + USB_Endpoint_SelectedFIFO->Position = 0; + } + + /** 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_XMEGA + */ + static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearOUT(void) + { + USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm); + USB_Endpoint_SelectedFIFO->Position = 0; + } + + /** 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_XMEGA + */ + static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_StallTransaction(void) + { + USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm; + + if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc) + { + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint ^ ENDPOINT_DIR_IN); + USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm; + } + } + + /** Clears the STALL condition on the currently selected endpoint. + * + * \ingroup Group_EndpointPacketManagement_XMEGA + */ + static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_ClearStall(void) + { + USB_Endpoint_SelectedHandle->CTRL &= ~USB_EP_STALL_bm; + } + + /** Determines if the currently selected endpoint is stalled, false otherwise. + * + * \ingroup Group_EndpointPacketManagement_XMEGA + * + * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise. + */ + static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline bool Endpoint_IsStalled(void) + { + return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_STALL_bm) ? 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) + { + USB_Endpoint_SelectedHandle->STATUS &= ~USB_EP_TOGGLE_bm; + } + + /** Determines the currently selected endpoint's direction. + * + * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask. + */ + static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_GetEndpointDirection(void) + { + return (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN); + } + + /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \return Next byte in the currently selected endpoint's FIFO buffer. + */ + static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint8_t Endpoint_Read_8(void) + { + return USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++]; + } + + /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_8(const uint8_t Data) + { + USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++] = Data; + } + + /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + */ + static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_8(void) + { + USB_Endpoint_SelectedFIFO->Position++; + } + + /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_LE(void) + { + uint16_t Byte0 = Endpoint_Read_8(); + uint16_t Byte1 = Endpoint_Read_8(); + + return ((Byte1 << 8) | Byte0); + } + + /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \return Next two bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint16_t Endpoint_Read_16_BE(void) + { + uint16_t Byte0 = Endpoint_Read_8(); + uint16_t Byte1 = Endpoint_Read_8(); + + return ((Byte0 << 8) | Byte1); + } + + /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_LE(const uint16_t Data) + { + Endpoint_Write_8(Data & 0xFF); + Endpoint_Write_8(Data >> 8); + } + + /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_16_BE(const uint16_t Data) + { + Endpoint_Write_8(Data >> 8); + Endpoint_Write_8(Data & 0xFF); + } + + /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + */ + static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_16(void) + { + Endpoint_Discard_8(); + Endpoint_Discard_8(); + } + + /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_LE(void) + { + uint32_t Byte0 = Endpoint_Read_8(); + uint32_t Byte1 = Endpoint_Read_8(); + uint32_t Byte2 = Endpoint_Read_8(); + uint32_t Byte3 = Endpoint_Read_8(); + + return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0); + } + + /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \return Next four bytes in the currently selected endpoint's FIFO buffer. + */ + static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; + static inline uint32_t Endpoint_Read_32_BE(void) + { + uint32_t Byte0 = Endpoint_Read_8(); + uint32_t Byte1 = Endpoint_Read_8(); + uint32_t Byte2 = Endpoint_Read_8(); + uint32_t Byte3 = Endpoint_Read_8(); + + return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3); + } + + /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_LE(const uint32_t Data) + { + Endpoint_Write_8(Data & 0xFF); + Endpoint_Write_8(Data >> 8); + Endpoint_Write_8(Data >> 16); + Endpoint_Write_8(Data >> 24); + } + + /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN + * direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + * + * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer. + */ + static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Write_32_BE(const uint32_t Data) + { + Endpoint_Write_8(Data >> 24); + Endpoint_Write_8(Data >> 16); + Endpoint_Write_8(Data >> 8); + Endpoint_Write_8(Data & 0xFF); + } + + /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. + * + * \ingroup Group_EndpointPrimitiveRW_XMEGA + */ + static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE; + static inline void Endpoint_Discard_32(void) + { + Endpoint_Discard_8(); + Endpoint_Discard_8(); + Endpoint_Discard_8(); + Endpoint_Discard_8(); + } + + /* External Variables: */ + /** Global indicating the maximum packet size of the default control endpoint located at address + * 0 in the device. This value is set to the value indicated in the device descriptor in the user + * project once the USB interface is initialized into device mode. + * + * If space is an issue, it is possible to fix this to a static value by defining the control + * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile + * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically + * read from the descriptors at runtime and instead fixed to the given value. When used, it is + * important that the descriptor control endpoint size value matches the size given as the + * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token + * be used in the device descriptors to ensure this. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + */ + #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__)) + extern uint8_t USB_Device_ControlEndpointSize; + #else + #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE + #endif + + /* Function Prototypes: */ + /** Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple + * endpoints at the same time. + * + * \note Endpoints with a zero address will be ignored, thus this function cannot be used to configure the + * control endpoint. + * + * \param[in] Table Pointer to a table of endpoint descriptions. + * \param[in] Entries Number of entries in the endpoint table to configure. + * + * \return Boolean \c true if all endpoints configured successfully, \c false otherwise. + */ + bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table, + const uint8_t Entries); + + /** 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. + * + * \note This routine should not be called on non CONTROL type endpoints. + */ + 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_XMEGA + * + * \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/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c new file mode 100644 index 000000000..39d920afe --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Host_XMEGA.c @@ -0,0 +1,41 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c new file mode 100644 index 000000000..39d920afe --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/PipeStream_XMEGA.c @@ -0,0 +1,41 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c new file mode 100644 index 000000000..6106cb581 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Pipe_XMEGA.c @@ -0,0 +1,37 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBMode.h" + +#if defined(USB_CAN_BE_HOST) + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_R.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_R.c new file mode 100644 index 000000000..35776410e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_R.c @@ -0,0 +1,87 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN); + + if (!(Length)) + Endpoint_ClearOUT(); + + while (Length) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + + if (Endpoint_IsOUTReceived()) + { + while (Length && Endpoint_BytesInEndpoint()) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + } + + Endpoint_ClearOUT(); + } + } + + while (!(Endpoint_IsINReady())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c new file mode 100644 index 000000000..ed2d2d9b7 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_Control_W.c @@ -0,0 +1,96 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer, + uint16_t Length) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + bool LastPacketFull = false; + + Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN); + + if (Length > USB_ControlRequest.wLength) + Length = USB_ControlRequest.wLength; + else if (!(Length)) + Endpoint_ClearIN(); + + while (Length || LastPacketFull) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + else if (Endpoint_IsSETUPReceived()) + return ENDPOINT_RWCSTREAM_HostAborted; + else if (Endpoint_IsOUTReceived()) + break; + + if (Endpoint_IsINReady()) + { + uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint(); + + while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize)) + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInEndpoint++; + } + + LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize); + Endpoint_ClearIN(); + } + } + + while (!(Endpoint_IsOUTReceived())) + { + uint8_t USB_DeviceState_LCL = USB_DeviceState; + + if (USB_DeviceState_LCL == DEVICE_STATE_Unattached) + return ENDPOINT_RWCSTREAM_DeviceDisconnected; + else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended) + return ENDPOINT_RWCSTREAM_BusSuspended; + } + + return ENDPOINT_RWCSTREAM_NoError; +} + +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_TRANSFER_BYTE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_RW.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_RW.c new file mode 100644 index 000000000..02ad97867 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/Template/Template_Endpoint_RW.c @@ -0,0 +1,90 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(TEMPLATE_FUNC_NAME) + +// cppcheck-suppress unusedFunction +uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer, + uint16_t Length, + uint16_t* const BytesProcessed) +{ + uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); + uint16_t BytesInTransfer = 0; + uint8_t ErrorCode; + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + + if (BytesProcessed != NULL) + { + Length -= *BytesProcessed; + TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed); + } + + while (Length) + { + if (!(Endpoint_IsReadWriteAllowed())) + { + TEMPLATE_CLEAR_ENDPOINT(); + + #if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); + #endif + + if (BytesProcessed != NULL) + { + *BytesProcessed += BytesInTransfer; + return ENDPOINT_RWSTREAM_IncompleteTransfer; + } + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + else + { + TEMPLATE_TRANSFER_BYTE(DataStream); + TEMPLATE_BUFFER_MOVE(DataStream, 1); + Length--; + BytesInTransfer++; + } + } + + return ENDPOINT_RWSTREAM_NoError; +} + +#undef TEMPLATE_FUNC_NAME +#undef TEMPLATE_BUFFER_TYPE +#undef TEMPLATE_TRANSFER_BYTE +#undef TEMPLATE_CLEAR_ENDPOINT +#undef TEMPLATE_BUFFER_OFFSET +#undef TEMPLATE_BUFFER_MOVE + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c new file mode 100644 index 000000000..3899278db --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.c @@ -0,0 +1,189 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#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 + +/* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for 8-bit AVR-GCC */ +uint8_t USB_EndpointTable[sizeof(USB_EndpointTable_t) + 1]; + +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 + + USB_IsInitialized = true; + + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc; + USB.CAL0 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL0)); + USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1)); + NVM.CMD = 0; + + /* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for the 8-bit AVR-GCC toochain */ + USB.EPPTR = ((intptr_t)&USB_EndpointTable[1] & ~(1 << 0)); + USB.CTRLA = (USB_STFRNUM_bm | ((ENDPOINT_TOTAL_ENDPOINTS - 1) << USB_MAXEP_gp)); + + if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH) + USB.INTCTRLA = (3 << USB_INTLVL_gp); + else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED) + USB.INTCTRLA = (2 << USB_INTLVL_gp); + else + USB.INTCTRLA = (1 << USB_INTLVL_gp); + + SetGlobalInterruptMask(CurrentGlobalInt); + + USB_ResetInterface(); +} + +void USB_Disable(void) +{ + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Detach(); + USB_Controller_Disable(); + + USB_IsInitialized = false; +} + +void USB_ResetInterface(void) +{ + #if defined(USB_DEVICE_OPT_FULLSPEED) + if (USB_Options & USB_DEVICE_OPT_LOWSPEED) + CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp); + else + CLK.USBCTRL = (((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp); + #else + CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp); + #endif + + if (USB_Options & USB_OPT_PLLCLKSRC) + CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm); + else + CLK.USBCTRL |= (CLK_USBSRC_RC32M_gc | CLK_USBSEN_bm); + + USB_Device_SetDeviceAddress(0); + + USB_INT_DisableAllInterrupts(); + USB_INT_ClearAllInterrupts(); + + USB_Controller_Reset(); + USB_Init_Device(); +} + +#if defined(USB_CAN_BE_DEVICE) +static void USB_Init_Device(void) +{ + USB_DeviceState = DEVICE_STATE_Unattached; + USB_Device_ConfigurationNumber = 0; + + #if !defined(NO_DEVICE_REMOTE_WAKEUP) + USB_Device_RemoteWakeupEnabled = false; + #endif + + #if !defined(NO_DEVICE_SELF_POWER) + USB_Device_CurrentlySelfPowered = false; + #endif + + #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) + USB_Descriptor_Device_t* DeviceDescriptorPtr; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + uint8_t DescriptorAddressSpace; + + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR) + { + if (DescriptorAddressSpace == MEMSPACE_FLASH) + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else if (DescriptorAddressSpace == MEMSPACE_EEPROM) + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + } + #else + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) + { + #if defined(USE_RAM_DESCRIPTORS) + USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + #elif defined(USE_EEPROM_DESCRIPTORS) + USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #else + USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + #endif + } + #endif + #endif + + if (USB_Options & USB_DEVICE_OPT_LOWSPEED) + USB_Device_SetLowSpeed(); + else + USB_Device_SetFullSpeed(); + + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + USB_Device_ControlEndpointSize, 1); + + USB_INT_Enable(USB_INT_BUSEVENTI); + + USB_Attach(); +} +#endif + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h new file mode 100644 index 000000000..bb37905ab --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBController_XMEGA.h @@ -0,0 +1,313 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller definitions for the AVR XMEGA microcontrollers. + * \copydetails Group_USBManagement_XMEGA + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +/** \ingroup Group_USBManagement + * \defgroup Group_USBManagement_XMEGA USB Interface Management (XMEGA) + * \brief USB Controller definitions for the AVR XMEGA microcontrollers. + * + * Functions, macros, variables, enums and types related to the setup and management of the USB interface. + * + * @{ + */ + +#ifndef __USBCONTROLLER_XMEGA_H__ +#define __USBCONTROLLER_XMEGA_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + #include "../USBMode.h" + #include "../Events.h" + #include "../USBTask.h" + #include "../USBInterrupt.h" + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Type Defines: */ + typedef struct + { + struct + { + USB_EP_t OUT; + USB_EP_t IN; + } Endpoints[16]; + uint16_t FrameNum; + } ATTR_PACKED USB_EndpointTable_t; + + /* External Variables: */ + extern uint8_t USB_EndpointTable[]; + + #endif + + /* Includes: */ + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "../Device.h" + #include "../Endpoint.h" + #include "../DeviceStandardReq.h" + #include "../EndpointStream.h" + #endif + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks and Defines: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + #if !defined(F_USB) + #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile. + #endif + + #if ((F_USB % 6000000) || (F_USB < 6000000)) + #error Invalid F_USB specified. F_USB must be a multiple of 6MHz for USB Low Speed operation, and a multiple of 48MHz for Full Speed operation. + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** \name USB Controller Option Masks */ + //@{ + /** Sets the USB bus interrupt priority level to be low priority. The USB bus interrupt is used for Start of Frame events, bus suspend + * and resume events, bus reset events and other events related to the management of the USB bus. + */ + #define USB_OPT_BUSEVENT_PRILOW ((0 << 2) | (0 << 1)) + + /** Sets the USB bus interrupt priority level to be medium priority. The USB bus interrupt is used for Start of Frame events, bus suspend + * and resume events, bus reset events and other events related to the management of the USB bus. + */ + #define USB_OPT_BUSEVENT_PRIMED ((0 << 2) | (1 << 1)) + + /** Sets the USB bus interrupt priority level to be high priority. The USB bus interrupt is used for Start of Frame events, bus suspend + * and resume events, bus reset events and other events related to the management of the USB bus. + */ + #define USB_OPT_BUSEVENT_PRIHIGH ((1 << 2) | (0 << 1)) + + /** Sets the USB controller to source its clock from the internal RC 32MHz clock, once it has been DFLL calibrated to 48MHz. */ + #define USB_OPT_RC32MCLKSRC (0 << 3) + + /** Sets the USB controller to source its clock from the internal PLL. */ + #define USB_OPT_PLLCLKSRC (1 << 3) + //@} + + #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: */ + /** 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) + { + USB.CTRLB &= ~USB_ATTACH_bm; + } + + /** 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) + { + USB.CTRLB |= USB_ATTACH_bm; + } + + /* 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 behavior. This should be comprised of + * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the + * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device + * mode speed. + * + * \note To reduce the FLASH requirements of the library if only device or host mode is required, + * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY + * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler + * via the -D switch. If the mode is statically set, this parameter does not exist in the + * function prototype. + * \n\n + * + * \note To reduce the FLASH requirements of the library if only fixed settings are required, + * the options may be set statically in the same manner as the mode (see the Mode parameter of + * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token, + * defined to the appropriate options masks. When the options are statically set, this + * parameter does not exist in the function prototype. + * \n\n + * + * \note The mode parameter does not exist on devices where only one mode is possible, such as USB + * AVR models which only implement the USB device mode in hardware. + * + * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks. + */ + void USB_Init( + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + const uint8_t Mode + #endif + + #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__) + , + #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS)) + void + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + const uint8_t Options + #endif + ); + + /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO + * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface + * is restarted with the \ref USB_Init() function. + */ + void USB_Disable(void); + + /** Resets the interface, when already initialized. This will re-enumerate the device if already connected + * to a host, or re-enumerate an already attached device when in host mode. + */ + void USB_ResetInterface(void); + + /* Global Variables: */ + #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__) + /** Indicates the mode that the USB interface is currently initialized to, a value from the + * \ref USB_Modes_t enum. + * + * \attention This variable should be treated as read-only in the user application, and never manually + * changed in value. + * + * \note When the controller is initialized into UID auto-detection mode, this variable will hold the + * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller + * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time + * options, or a limitation of the USB controller in the chosen device model) this will evaluate to + * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the + * USB interface is not initialized. + */ + extern volatile uint8_t USB_CurrentMode; + #elif defined(USB_DEVICE_ONLY) + #define USB_CurrentMode USB_MODE_Device + #endif + + #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__) + /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init() + * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module. + * + * \attention 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. */ + }; + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Function Prototypes: */ + #if defined(__INCLUDE_FROM_USB_CONTROLLER_C) + static void USB_Init_Device(void); + #endif + + /* Inline Functions: */ + static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Enable(void) + { + USB.CTRLA |= USB_ENABLE_bm; + } + + static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Disable(void) + { + USB.CTRLA &= ~USB_ENABLE_bm; + } + + static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE; + static inline void USB_Controller_Reset(void) + { + USB.CTRLA &= ~USB_ENABLE_bm; + USB.CTRLA |= USB_ENABLE_bm; + } + + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c new file mode 100644 index 000000000..9bba25ae9 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.c @@ -0,0 +1,106 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../../../Common/Common.h" +#if (ARCH == ARCH_XMEGA) + +#define __INCLUDE_FROM_USB_DRIVER +#include "../USBInterrupt.h" + +void USB_INT_DisableAllInterrupts(void) +{ + USB.INTCTRLA &= USB_INTLVL_gm; + USB.INTCTRLB = 0; +} + +void USB_INT_ClearAllInterrupts(void) +{ + USB.INTFLAGSACLR = 0xFF; + USB.INTFLAGSBCLR = 0xFF; +} + +ISR(USB_BUSEVENT_vect) +{ + #if !defined(NO_SOF_EVENTS) + if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI)) + { + USB_INT_Clear(USB_INT_SOFI); + + EVENT_USB_Device_StartOfFrame(); + } + #endif + + if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend)) + { + USB_INT_Clear(USB_INT_BUSEVENTI_Suspend); + + #if !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_BUSEVENTI_Resume)) + { + USB_INT_Clear(USB_INT_BUSEVENTI_Resume); + + if (USB_Device_ConfigurationNumber) + USB_DeviceState = DEVICE_STATE_Configured; + else + USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; + + #if !defined(NO_LIMITED_CONTROLLER_CONNECT) + EVENT_USB_Device_Connect(); + #else + EVENT_USB_Device_WakeUp(); + #endif + } + + if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Reset)) + { + USB_INT_Clear(USB_INT_BUSEVENTI_Reset); + + USB_DeviceState = DEVICE_STATE_Default; + USB_Device_ConfigurationNumber = 0; + + USB_Device_SetDeviceAddress(0); + + Endpoint_ClearEndpoints(); + Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL, + USB_Device_ControlEndpointSize, 1); + + EVENT_USB_Device_Reset(); + } +} + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h new file mode 100644 index 000000000..5eef7121e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/Core/XMEGA/USBInterrupt_XMEGA.h @@ -0,0 +1,166 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief USB Controller Interrupt definitions for the AVR XMEGA microcontrollers. + * + * This file contains definitions required for the correct handling of low level USB service routine interrupts + * from the USB controller. + * + * \note This file should not be included directly. It is automatically included as needed by the USB driver + * dispatch header located in LUFA/Drivers/USB/USB.h. + */ + +#ifndef __USBINTERRUPT_XMEGA_H__ +#define __USBINTERRUPT_XMEGA_H__ + + /* Includes: */ + #include "../../../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Preprocessor Checks: */ + #if !defined(__INCLUDE_FROM_USB_DRIVER) + #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Enums: */ + enum USB_Interrupts_t + { + USB_INT_BUSEVENTI = 1, + USB_INT_BUSEVENTI_Suspend = 2, + USB_INT_BUSEVENTI_Resume = 3, + USB_INT_BUSEVENTI_Reset = 4, + USB_INT_SOFI = 5, + }; + + /* Inline Functions: */ + static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Enable(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_BUSEVENTI: + USB.INTCTRLA |= USB_BUSEVIE_bm; + return; + case USB_INT_SOFI: + USB.INTCTRLA |= USB_SOFIE_bm; + return; + } + } + + static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Disable(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_BUSEVENTI: + USB.INTCTRLA &= ~USB_BUSEVIE_bm; + return; + case USB_INT_SOFI: + USB.INTCTRLA &= ~USB_SOFIE_bm; + return; + } + } + + static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE; + static inline void USB_INT_Clear(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_BUSEVENTI_Suspend: + USB.INTFLAGSACLR = USB_SUSPENDIF_bm; + return; + case USB_INT_BUSEVENTI_Resume: + USB.INTFLAGSACLR = USB_RESUMEIF_bm; + return; + case USB_INT_BUSEVENTI_Reset: + USB.INTFLAGSACLR = USB_RSTIF_bm; + return; + case USB_INT_SOFI: + USB.INTFLAGSACLR = USB_SOFIF_bm; + return; + } + } + + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_BUSEVENTI: + return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false); + case USB_INT_SOFI: + return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false); + } + + return false; + } + + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; + static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) + { + switch (Interrupt) + { + case USB_INT_BUSEVENTI_Suspend: + return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false); + case USB_INT_BUSEVENTI_Resume: + return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false); + case USB_INT_BUSEVENTI_Reset: + return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false); + case USB_INT_SOFI: + return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false); + } + + return false; + } + + /* Includes: */ + #include "../USBMode.h" + #include "../Events.h" + #include "../USBController.h" + + /* Function Prototypes: */ + void USB_INT_ClearAllInterrupts(void); + void USB_INT_DisableAllInterrupts(void); + #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/USB.h b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/USB.h new file mode 100644 index 000000000..66f0fd3c0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Drivers/USB/USB.h @@ -0,0 +1,418 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Master include file for the library USB functionality. + * + * Master include file for the library USB functionality. + * + * This file should be included in all user projects making use of the USB portions of the library, instead of + * the individual USB driver submodule headers. + */ + +/** \defgroup Group_USB USB Core - LUFA/Drivers/USB/USB.h + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Drivers/USB/Core/ConfigDescriptors.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/DeviceStandardReq.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/Events.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/HostStandardReq.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/USBTask.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Device_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Endpoint_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/EndpointStream_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Host_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/Pipe_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/PipeStream_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/USBController_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Core/ARCH/USBInterrupt_ARCH.c (Makefile source module name: LUFA_SRC_USB) + * - LUFA/Drivers/USB/Class/Common/HIDParser.c (Makefile source module name: LUFA_SRC_USB) + * + * \section Sec_ModDescription Module Description + * Driver and framework for the USB controller of the selected architecture and microcontroller model. This module + * consists of many submodules, and is designed to provide an easy way to configure and control USB host, device + * or OTG mode USB applications. + * + * The USB stack requires the sole control over the USB controller in the microcontroller only; i.e. it does not + * require any additional timers or other peripherals to operate. This ensures that the USB stack requires as few + * resources as possible. + * + * The USB stack can be used in Device Mode for connections to USB Hosts (see \ref Group_Device), in Host mode for + * hosting of other USB devices (see \ref Group_Host), or as a dual role device which can either act as a USB host + * or device depending on what peripheral is connected (see \ref Group_OTG). Both modes also require a common set + * of USB management functions found \ref Group_USBManagement. + */ + +/** \defgroup Group_USBClassDrivers USB Class Drivers + * + * Drivers for both host and device mode of the standard USB classes, for rapid application development. + * Class drivers give a framework which sits on top of the low level library API, allowing for standard + * USB classes to be implemented in a project with minimal user code. These drivers can be used in + * conjunction with the library low level APIs to implement interfaces both via the class drivers and via + * the standard library APIs. + * + * Multiple device mode class drivers can be used within a project, including multiple instances of the + * same class driver. In this way, USB Hosts and Devices can be made quickly using the internal class drivers + * so that more time and effort can be put into the end application instead of the USB protocol. + * + * The available class drivers and their modes are listed below. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * +* + * + * + * + * + * + * + * + * + * + * + * + *
USB ClassDevice ModeHost Mode
Android Open AccessoryNoYes
Audio 1.0YesYes
CDC-ACMYesYes
HIDYesYes
MIDIYesYes
Mass StorageYesYes
PrinterNoYes
RNDISYesYes
Still ImageNoYes
+ * + * + * \section Sec_UsingClassDrivers Using the Class Drivers + * To make the Class drivers easy to integrate into a user application, they all implement a standardized + * design with similarly named/used function, enums, defines and types. The two different modes are implemented + * slightly differently, and thus will be explained separately. For information on a specific class driver, read + * the class driver's module documentation. + * + * \subsection Sec_ClassDriverDevice Device Mode Class Drivers + * Implementing a Device Mode Class Driver in a user application requires a number of steps to be followed. Firstly, + * the module configuration and state structure must be added to the project source. These structures are named in a + * similar manner between classes, that of USB_ClassInfo_{Class Name}_Device_t, and are used to hold the + * complete state and configuration for each class instance. Multiple class instances is where the power of the class + * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_* + * structure. + * + * Inside the ClassInfo structure lies two sections, a \c Config section, and a \c State section. The \c Config + * section contains the instance's configuration parameters, and must have all fields set by the user application + * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters + * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters. + * + * 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, + * .DataINEndpoint = + * { + * .Address = (ENDPOINT_DIR_IN | 1), + * .Size = 64, + * .Banks = 1, + * }, + * }, + * }; + * \endcode + * + * \note The class driver's configuration parameters should match those used in the device's descriptors that are + * sent to the host. + * + * To initialize the Class driver instance, the driver's {Class Name}_Device_ConfigureEndpoints() function + * should be called in response to the \ref EVENT_USB_Device_ConfigurationChanged() event. This function will return a + * boolean true value if the driver successfully initialized the instance. Like all the class driver functions, this function + * takes in the address of the specific instance you wish to initialize - in this manner, multiple separate instances of + * the same class type can be initialized like this: + * + * \code + * void EVENT_USB_Device_ConfigurationChanged(void) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_READY); + * + * if (!(Audio_Device_ConfigureEndpoints(&My_Audio_Interface))) + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * } + * \endcode + * + * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's + * {Class Name}_Device_USBTask() function in the main program loop. The exact implementation of this + * function varies between class drivers, and can be used for any internal class driver purpose to maintain each + * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each + * separate instance, just like the main USB maintenance routine \ref USB_USBTask(): + * + * \code + * int main(void) + * { + * SetupHardware(); + * + * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + * + * for (;;) + * { + * if (USB_DeviceState != DEVICE_STATE_Configured) + * Create_And_Process_Samples(); + * + * Audio_Device_USBTask(&My_Audio_Interface); + * USB_USBTask(); + * } + * } + * \endcode + * + * The final standardized Device Class Driver function is the Control Request handler function + * {Class Name}_Device_ProcessControlRequest(), which should be called when the + * \ref EVENT_USB_Device_ControlRequest() event fires. This function should also be called for + * each class driver instance, using the address of the instance to operate on as the function's + * parameter. The request handler will abort if it is determined that the current request is not + * targeted at the given class driver instance, thus these methods can safely be called + * one-after-another in the event handler with no form of error checking: + * + * \code + * void EVENT_USB_Device_ControlRequest(void) + * { + * Audio_Device_ProcessControlRequest(&My_Audio_Interface); + * } + * \endcode + * + * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_* + * in the function's name) which must also be added to the user application - refer to each + * individual class driver's documentation for mandatory callbacks. In addition, each class driver may + * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which + * the user application may choose to implement, or ignore if not needed. + * + * The individual Device Mode Class Driver documentation contains more information on the non-standardized, + * class-specific functions which the user application can then use on the driver instances, such as data + * read and write routines. See each driver's individual documentation for more information on the + * class-specific functions. + * + * \subsection Sec_ClassDriverHost Host Mode Class Drivers + * Implementing a Host Mode Class Driver in a user application requires a number of steps to be followed. Firstly, + * the module configuration and state structure must be added to the project source. These structures are named in a + * similar manner between classes, that of USB_ClassInfo_{Class Name}_Host_t, and are used to hold the + * complete state and configuration for each class instance. Multiple class instances is where the power of the class + * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_* + * structure. + * + * Inside the \c USB_ClassInfo_* structure lies two sections, a \c Config section, and a \c State section. The \c Config + * section contains the instance's configuration parameters, and must have all fields set by the user application + * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters + * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters. + * + * The following is an example of a properly initialized instance of the MIDI Host Class Driver structure: + * + * \code + * USB_ClassInfo_MIDI_Host_t My_MIDI_Interface = + * { + * .Config = + * { + * .DataINPipe = + * { + * .Address = (PIPE_DIR_IN | 1), + * .Size = 64, + * .Banks = 1, + * }, + * .DataOUTPipe = + * { + * .Address = (PIPE_DIR_OUT | 2), + * .Size = 64, + * .Banks = 1, + * }, + * }, + * }; + * \endcode + * + * To initialize the Class driver instance, the driver's {Class Name}_Host_ConfigurePipes() function + * should be called in response to the \c EVENT_USB_Host_DeviceEnumerationComplete() event firing. This function will + * will return an error code from the class driver's {Class Name}_EnumerationFailure_ErrorCodes_t enum + * to indicate if the driver successfully initialized the instance and bound it to an interface in the attached device. + * Like all the class driver functions, this function takes in the address of the specific instance you wish to initialize - + * in this manner, multiple separate instances of the same class type can be initialized. A fragment of a Class Driver + * based Host mode application may look like the following: + * + * \code + * void EVENT_USB_Host_DeviceEnumerationComplete(void) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); + * + * uint16_t ConfigDescriptorSize; + * uint8_t ConfigDescriptorData[512]; + * + * if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, + * sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * return; + * } + * + * if (MIDI_Host_ConfigurePipes(&Keyboard_MIDI_Interface, + * ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * return; + * } + * + * if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) + * { + * LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + * return; + * } + * + * LEDs_SetAllLEDs(LEDMASK_USB_READY); + * } + * \endcode + * + * Note that the function also requires the device's configuration descriptor so that it can determine which interface + * in the device to bind to - this can be retrieved as shown in the above fragment using the + * \ref USB_Host_GetDeviceConfigDescriptor() function. If the device does not implement the interface the class driver + * is looking for, if all the matching interfaces are already bound to class driver instances or if an error occurs while + * binding to a device interface (for example, a device endpoint bank larger that the maximum supported bank size is used) + * the configuration will fail. + * + * To complete the device enumeration after binding the host mode Class Drivers to the attached device, a call to + * \c USB_Host_SetDeviceConfiguration() must be made. If the device configuration is not set within the + * \c EVENT_USB_Host_DeviceEnumerationComplete() event, the host still will assume the device enumeration has failed. + * + * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's + * {Class Name}_Host_USBTask() function in the main program loop. The exact implementation of this + * function varies between class drivers, and can be used for any internal class driver purpose to maintain each + * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each + * separate instance, just like the main USB maintenance routine \ref USB_USBTask(): + * + * \code + * int main(void) + * { + * SetupHardware(); + * + * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + * + * for (;;) + * { + * if (USB_HostState != HOST_STATE_Configured) + * Create_And_Process_Samples(); + * + * MIDI_Host_USBTask(&My_Audio_Interface); + * USB_USBTask(); + * } + * } + * \endcode + * + * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_* + * in the function's name) which must also be added to the user application - refer to each + * individual class driver's documentation for mandatory callbacks. In addition, each class driver may + * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which + * the user application may choose to implement, or ignore if not needed. + * + * The individual Host Mode Class Driver documentation contains more information on the non-standardized, + * class-specific functions which the user application can then use on the driver instances, such as data + * read and write routines. See each driver's individual documentation for more information on the + * class-specific functions. + */ + +#ifndef __USB_H__ +#define __USB_H__ + + /* Macros: */ + #define __INCLUDE_FROM_USB_DRIVER + + /* Includes: */ + #include "../../Common/Common.h" + #include "Core/USBMode.h" + + /* Includes: */ + #include "Core/USBTask.h" + #include "Core/Events.h" + #include "Core/StdDescriptors.h" + #include "Core/ConfigDescriptors.h" + #include "Core/USBController.h" + #include "Core/USBInterrupt.h" + + #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__) + #include "Core/Host.h" + #include "Core/Pipe.h" + #include "Core/HostStandardReq.h" + #include "Core/PipeStream.h" + #endif + + #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__) + #include "Core/Device.h" + #include "Core/Endpoint.h" + #include "Core/DeviceStandardReq.h" + #include "Core/EndpointStream.h" + #endif + + #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__) + #include "Core/OTG.h" + #endif + + #include "Class/AndroidAccessoryClass.h" + #include "Class/AudioClass.h" + #include "Class/CDCClass.h" + #include "Class/HIDClass.h" + #include "Class/MassStorageClass.h" + #include "Class/MIDIClass.h" + #include "Class/PrinterClass.h" + #include "Class/RNDISClass.h" + #include "Class/StillImageClass.h" + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/License.txt b/protocol/lufa/LUFA-120730/LUFA/License.txt new file mode 100644 index 000000000..9e27adfb2 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/License.txt @@ -0,0 +1,24 @@ + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org + + +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. \ No newline at end of file diff --git a/protocol/lufa/LUFA-120730/LUFA/Platform/Platform.h b/protocol/lufa/LUFA-120730/LUFA/Platform/Platform.h new file mode 100644 index 000000000..9bd29f5c0 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Platform/Platform.h @@ -0,0 +1,80 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Architecture Specific Hardware Platform Drivers. + * + * This file is the master dispatch header file for the device-specific hardware platform drivers, for low level + * hardware configuration and management. The platform drivers are a set of drivers which are designed to provide + * a high level management layer for the various low level system functions such as clock control and interrupt + * management. + * + * User code may choose to either include this master dispatch header file to include all available platform + * driver header files for the current architecture, or may choose to only include the specific platform driver + * modules required for a particular application. + */ + +/** \defgroup Group_PlatformDrivers System Platform Drivers - LUFA/Platform/Platform.h + * \brief Hardware platform drivers. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - UC3 Architecture Only: LUFA/Platform/UC3/InterruptManagement.c (Makefile source module name: LUFA_SRC_PLATFORM) + * - UC3 Architecture Only: LUFA/Platform/UC3/Exception.S (Makefile source module name: LUFA_SRC_PLATFORM) + * + * \section Sec_ModDescription Module Description + * Device-specific hardware platform drivers, for low level hardware configuration and management. The platform + * drivers are a set of drivers which are designed to provide a high level management layer for the various low level + * system functions such as clock control and interrupt management. + * + * User code may choose to either include this master dispatch header file to include all available platform + * driver header files for the current architecture, or may choose to only include the specific platform driver + * modules required for a particular application. + * + * \note The exact APIs and availability of sub-modules within the platform driver group may vary depending on the + * target used - see individual target module documentation for the API specific to your target processor. + */ + +#ifndef __LUFA_PLATFORM_H__ +#define __LUFA_PLATFORM_H__ + + /* Includes: */ + #include "../Common/Common.h" + + /* Includes: */ + #if (ARCH == ARCH_UC3) + #include "UC3/ClockManagement.h" + #include "UC3/InterruptManagement.h" + #elif (ARCH == ARCH_XMEGA) + #include "XMEGA/ClockManagement.h" + #endif + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/ClockManagement.h b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/ClockManagement.h new file mode 100644 index 000000000..fb62fdcc9 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/ClockManagement.h @@ -0,0 +1,338 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Module Clock Driver for the AVR32 UC3 microcontrollers. + * + * Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration + * of the various clocks within the device to clock the various peripherals. + */ + +/** \ingroup Group_PlatformDrivers_UC3 + * \defgroup Group_PlatformDrivers_UC3Clocks Clock Management Driver - LUFA/Platform/UC3/ClockManagement.h + * \brief Module Clock Driver for the AVR32 UC3 microcontrollers. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration + * of the various clocks within the device to clock the various peripherals. + * + * Usage Example: + * \code + * #include + * + * void main(void) + * { + * // Start the master external oscillator which will be used as the main clock reference + * AVR32CLK_StartExternalOscillator(0, EXOSC_MODE_8MHZ_OR_MORE, EXOSC_START_0CLK); + * + * // Start the PLL for the CPU clock, switch CPU to it + * AVR32CLK_StartPLL(0, CLOCK_SRC_OSC0, 12000000, F_CPU); + * AVR32CLK_SetCPUClockSource(CLOCK_SRC_PLL0, F_CPU); + * + * // Start the PLL for the USB Generic Clock module + * AVR32CLK_StartPLL(1, CLOCK_SRC_OSC0, 12000000, 48000000); + * } + * \endcode + * + * @{ + */ + +#ifndef _UC3_CLOCK_MANAGEMENT_H_ +#define _UC3_CLOCK_MANAGEMENT_H_ + + /* Includes: */ + #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: */ + /** Enum for the possible external oscillator types. */ + enum UC3_Extern_OSC_ClockTypes_t + { + EXOSC_MODE_CLOCK = AVR32_PM_OSCCTRL0_MODE_EXT_CLOCK, /**< External clock (non-crystal) mode. */ + EXOSC_MODE_900KHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G0, /**< External crystal oscillator equal to or slower than 900KHz. */ + EXOSC_MODE_3MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G1, /**< External crystal oscillator equal to or slower than 3MHz. */ + EXOSC_MODE_8MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G2, /**< External crystal oscillator equal to or slower than 8MHz. */ + EXOSC_MODE_8MHZ_OR_MORE = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G3, /**< External crystal oscillator equal to or faster than 8MHz. */ + }; + + /** Enum for the possible external oscillator startup times. */ + enum UC3_Extern_OSC_ClockStartup_t + { + EXOSC_START_0CLK = AVR32_PM_OSCCTRL0_STARTUP_0_RCOSC, /**< Immediate startup, no delay. */ + EXOSC_START_64CLK = AVR32_PM_OSCCTRL0_STARTUP_64_RCOSC, /**< Wait 64 clock cycles before startup for stability. */ + EXOSC_START_128CLK = AVR32_PM_OSCCTRL0_STARTUP_128_RCOSC, /**< Wait 128 clock cycles before startup for stability. */ + EXOSC_START_2048CLK = AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC, /**< Wait 2048 clock cycles before startup for stability. */ + EXOSC_START_4096CLK = AVR32_PM_OSCCTRL0_STARTUP_4096_RCOSC, /**< Wait 4096 clock cycles before startup for stability. */ + EXOSC_START_8192CLK = AVR32_PM_OSCCTRL0_STARTUP_8192_RCOSC, /**< Wait 8192 clock cycles before startup for stability. */ + EXOSC_START_16384CLK = AVR32_PM_OSCCTRL0_STARTUP_16384_RCOSC, /**< Wait 16384 clock cycles before startup for stability. */ + }; + + /** Enum for the possible module clock sources. */ + enum UC3_System_ClockSource_t + { + CLOCK_SRC_SLOW_CLK = 0, /**< Clock sourced from the internal slow clock. */ + CLOCK_SRC_OSC0 = 1, /**< Clock sourced from the Oscillator 0 clock. */ + CLOCK_SRC_OSC1 = 2, /**< Clock sourced from the Oscillator 1 clock. */ + CLOCK_SRC_PLL0 = 3, /**< Clock sourced from the PLL 0 clock. */ + CLOCK_SRC_PLL1 = 4, /**< Clock sourced from the PLL 1 clock. */ + }; + + /* Inline Functions: */ + /** Starts the given external oscillator of the UC3 microcontroller, with the given options. This routine blocks until + * the oscillator is ready for use. + * + * \param[in] Channel Index of the external oscillator to start. + * \param[in] Type Type of clock attached to the given oscillator channel, a value from \ref UC3_Extern_OSC_ClockTypes_t. + * \param[in] Startup Statup time of the external oscillator, a value from \ref UC3_Extern_OSC_ClockStartup_t. + * + * \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified. + */ + static inline bool AVR32CLK_StartExternalOscillator(const uint8_t Channel, + const uint8_t Type, + const uint8_t Startup) ATTR_ALWAYS_INLINE; + static inline bool AVR32CLK_StartExternalOscillator(const uint8_t Channel, + const uint8_t Type, + const uint8_t Startup) + { + switch (Channel) + { + case 0: + AVR32_PM.OSCCTRL0.startup = Startup; + AVR32_PM.OSCCTRL0.mode = Type; + break; + case 1: + AVR32_PM.OSCCTRL1.startup = Startup; + AVR32_PM.OSCCTRL1.mode = Type; + break; + default: + return false; + } + + AVR32_PM.mcctrl |= (1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel)); + + while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_OSC0RDY_OFFSET + Channel)))); + return true; + } + + /** Stops the given external oscillator of the UC3 microcontroller. + * + * \param[in] Channel Index of the external oscillator to stop. + */ + static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel) ATTR_ALWAYS_INLINE; + static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel) + { + AVR32_PM.mcctrl &= ~(1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel)); + } + + /** Starts the given PLL of the UC3 microcontroller, with the given options. This routine blocks until the PLL is ready for use. + * + * \attention The output frequency must be equal to or greater than the source frequency. + * + * \param[in] Channel Index of the PLL to start. + * \param[in] Source Clock source for the PLL, a value from \ref UC3_System_ClockSource_t. + * \param[in] SourceFreq Frequency of the PLL's clock source, in Hz. + * \param[in] Frequency Target frequency of the PLL's output. + * + * \return Boolean \c true if the PLL was successfully started, \c false if invalid parameters specified. + */ + static inline bool AVR32CLK_StartPLL(const uint8_t Channel, + const uint8_t Source, + const uint32_t SourceFreq, + const uint32_t Frequency) ATTR_ALWAYS_INLINE; + static inline bool AVR32CLK_StartPLL(const uint8_t Channel, + const uint8_t Source, + const uint32_t SourceFreq, + const uint32_t Frequency) + { + if (SourceFreq > Frequency) + return false; + + switch (Source) + { + case CLOCK_SRC_OSC0: + AVR32_PM.PLL[Channel].pllosc = 0; + break; + case CLOCK_SRC_OSC1: + AVR32_PM.PLL[Channel].pllosc = 1; + break; + default: + return false; + } + + AVR32_PM.PLL[Channel].pllmul = (Frequency / SourceFreq) ? (((Frequency / SourceFreq) - 1) / 2) : 0; + AVR32_PM.PLL[Channel].plldiv = 0; + AVR32_PM.PLL[Channel].pllen = true; + + while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_LOCK0_OFFSET + Channel)))); + return true; + } + + /** Stops the given PLL of the UC3 microcontroller. + * + * \param[in] Channel Index of the PLL to stop. + */ + static inline void AVR32CLK_StopPLL(const uint8_t Channel) ATTR_ALWAYS_INLINE; + static inline void AVR32CLK_StopPLL(const uint8_t Channel) + { + AVR32_PM.PLL[Channel].pllen = false; + } + + /** Starts the given Generic Clock of the UC3 microcontroller, with the given options. + * + * \param[in] Channel Index of the Generic Clock to start. + * \param[in] Source Clock source for the Generic Clock, a value from \ref UC3_System_ClockSource_t. + * \param[in] SourceFreq Frequency of the Generic Clock's clock source, in Hz. + * \param[in] Frequency Target frequency of the Generic Clock's output. + * + * \return Boolean \c true if the Generic Clock was successfully started, \c false if invalid parameters specified. + */ + static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel, + const uint8_t Source, + const uint32_t SourceFreq, + const uint32_t Frequency) ATTR_ALWAYS_INLINE; + static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel, + const uint8_t Source, + const uint32_t SourceFreq, + const uint32_t Frequency) + { + if (Channel >= AVR32_PM_GCLK_NUM) + return false; + + if (SourceFreq < Frequency) + return false; + + switch (Source) + { + case CLOCK_SRC_OSC0: + AVR32_PM.GCCTRL[Channel].pllsel = false; + AVR32_PM.GCCTRL[Channel].oscsel = 0; + break; + case CLOCK_SRC_OSC1: + AVR32_PM.GCCTRL[Channel].pllsel = false; + AVR32_PM.GCCTRL[Channel].oscsel = 1; + break; + case CLOCK_SRC_PLL0: + AVR32_PM.GCCTRL[Channel].pllsel = true; + AVR32_PM.GCCTRL[Channel].oscsel = 0; + break; + case CLOCK_SRC_PLL1: + AVR32_PM.GCCTRL[Channel].pllsel = true; + AVR32_PM.GCCTRL[Channel].oscsel = 1; + break; + default: + return false; + } + + AVR32_PM.GCCTRL[Channel].diven = (SourceFreq > Frequency) ? true : false; + AVR32_PM.GCCTRL[Channel].div = (((SourceFreq / Frequency) - 1) / 2); + AVR32_PM.GCCTRL[Channel].cen = true; + + return true; + } + + /** Stops the given generic clock of the UC3 microcontroller. + * + * \param[in] Channel Index of the generic clock to stop. + * + * \return Boolean \c true if the generic clock was sucessfully stopped, \c false if invalid parameters specified. + */ + static inline bool AVR32CLK_StopGenericClock(const uint8_t Channel) ATTR_ALWAYS_INLINE; + static inline bool AVR32CLK_StopGenericClock(const uint8_t Channel) + { + if (Channel >= AVR32_PM_GCLK_NUM) + return false; + + AVR32_PM.GCCTRL[Channel].cen = false; + + return true; + } + + /** Sets the clock source for the main microcontroller core. The given clock source should be configured + * and ready for use before this function is called. + * + * This function will configure the FLASH controller's wait states automatically to suit the given clock source. + * + * \param[in] Source Clock source for the CPU core, a value from \ref UC3_System_ClockSource_t. + * \param[in] SourceFreq Frequency of the CPU core's clock source, in Hz. + * + * \return Boolean \c true if the CPU core clock was sucessfully altered, \c false if invalid parameters specified. + */ + static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source, + const uint32_t SourceFreq) ATTR_ALWAYS_INLINE; + static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source, + const uint32_t SourceFreq) + { + if (SourceFreq > AVR32_PM_CPU_MAX_FREQ) + return false; + + AVR32_FLASHC.FCR.fws = (SourceFreq > AVR32_FLASHC_FWS_0_MAX_FREQ) ? true : false; + + switch (Source) + { + #if defined(AVR32_PM_MCCTRL_MCSEL_SLOW) + case CLOCK_SRC_SLOW_CLK: + AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_SLOW; + break; + #endif + #if defined(AVR32_PM_MCCTRL_MCSEL_OSC0) + case CLOCK_SRC_OSC0: + AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_OSC0; + break; + #endif + #if defined(AVR32_PM_MCCTRL_MCSEL_PLL0) + case CLOCK_SRC_PLL0: + AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_PLL0; + break; + #endif + default: + return false; + } + + return true; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/Exception.S b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/Exception.S new file mode 100644 index 000000000..1666323e5 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/Exception.S @@ -0,0 +1,128 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2011. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#if defined(__AVR32__) +#include + +.section .exception_handlers, "ax", @progbits + +// ================= EXCEPTION TABLE ================ +.balign 0x200 +.global EVBA_Table +EVBA_Table: + +.org 0x000 +Exception_Unrecoverable_Exception: + rjmp $ +.org 0x004 +Exception_TLB_Multiple_Hit: + rjmp $ +.org 0x008 +Exception_Bus_Error_Data_Fetch: + rjmp $ +.org 0x00C +Exception_Bus_Error_Instruction_Fetch: + rjmp $ +.org 0x010 +Exception_NMI: + rjmp $ +.org 0x014 +Exception_Instruction_Address: + rjmp $ +.org 0x018 +Exception_ITLB_Protection: + rjmp $ +.org 0x01C +Exception_OCD_Breakpoint: + rjmp $ +.org 0x020 +Exception_Illegal_Opcode: + rjmp $ +.org 0x024 +Exception_Unimplemented_Instruction: + rjmp $ +.org 0x028 +Exception_Privilege_Violation: + rjmp $ +.org 0x02C +Exception_Floating_Point: + rjmp $ +.org 0x030 +Exception_Coprocessor_Absent: + rjmp $ +.org 0x034 +Exception_Data_Address_Read: + rjmp $ +.org 0x038 +Exception_Data_Address_Write: + rjmp $ +.org 0x03C +Exception_DTLB_Protection_Read: + rjmp $ +.org 0x040 +Exception_DTLB_Protection_Write: + rjmp $ +.org 0x044 +Exception_DTLB_Modified: + rjmp $ +.org 0x050 +Exception_ITLB_Miss: + rjmp $ +.org 0x060 +Exception_DTLB_Miss_Read: + rjmp $ +.org 0x070 +Exception_DTLB_Miss_Write: + rjmp $ +.org 0x100 +Exception_Supervisor_Call: + rjmp $ +// ============== END OF EXCEPTION TABLE ============= + +// ============= GENERAL INTERRUPT HANDLER =========== +.balign 4 +.irp Level, 0, 1, 2, 3 +Exception_INT\Level: + mov r12, \Level + call INTC_GetInterruptHandler + mov pc, r12 +.endr +// ========= END OF GENERAL INTERRUPT HANDLER ======== + +// ====== GENERAL INTERRUPT HANDLER OFFSET TABLE ====== +.balign 4 +.global Autovector_Table +Autovector_Table: +.irp Level, 0, 1, 2, 3 + .word ((AVR32_INTC_INT0 + \Level) << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (Exception_INT\Level - EVBA_Table) +.endr +// === END OF GENERAL INTERRUPT HANDLER OFFSET TABLE === + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.c b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.c new file mode 100644 index 000000000..84e16ba20 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.c @@ -0,0 +1,68 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "../../Common/Common.h" +#if (ARCH == ARCH_UC3) + +#define __INCLUDE_FROM_INTMANAGEMENT_C +#include "InterruptManagement.h" + +/** Interrupt vector table, containing the ISR to call for each interrupt group */ +InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS]; + +/** ISR for unhandled interrupt groups */ +ISR(Unhandled_Interrupt) +{ + for (;;); +} + +/** Retrieves the associated interrupt handler for the interrupt group currently being fired. This + * is called directly from the exception handler routine before dispatching to the ISR. + */ +InterruptHandlerPtr_t INTC_GetInterruptHandler(const uint_reg_t InterruptLevel) +{ + return InterruptHandlers[AVR32_INTC.icr[AVR32_INTC_INT3 - InterruptLevel]]; +} + +/** Initializes the interrupt controller ready to handle interrupts. This must be called at the + * start of the user program before any interrupts are registered or enabled. + */ +void INTC_Init(void) +{ + for (uint8_t InterruptGroup = 0; InterruptGroup < AVR32_INTC_NUM_INT_GRPS; InterruptGroup++) + { + InterruptHandlers[InterruptGroup] = Unhandled_Interrupt; + AVR32_INTC.ipr[InterruptGroup] = Autovector_Table[AVR32_INTC_INT0]; + } + + __builtin_mtsr(AVR32_EVBA, (uintptr_t)&EVBA_Table); +} + +#endif diff --git a/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.h b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.h new file mode 100644 index 000000000..b0e1e3ec1 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Platform/UC3/InterruptManagement.h @@ -0,0 +1,163 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers. + * + * Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt + * handlers within the device. + */ + +/** \ingroup Group_PlatformDrivers_UC3 + * \defgroup Group_PlatformDrivers_UC3Interrupts Interrupt Controller Driver - LUFA/Platform/UC3/InterruptManagement.h + * \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - LUFA/Platform/UC3/InterruptManagement.c (Makefile source module name: LUFA_SRC_PLATFORM) + * - LUFA/Platform/UC3/Exception.S (Makefile source module name: LUFA_SRC_PLATFORM) + * + * \section Sec_ModDescription Module Description + * Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt + * handlers within the device. + * + * Usage Example: + * \code + * #include + * + * ISR(USB_Group_IRQ_Handler) + * { + * // USB group handler code here + * } + * + * void main(void) + * { + * INTC_Init(); + * INTC_RegisterGroupHandler(INTC_IRQ_GROUP(AVR32_USBB_IRQ), AVR32_INTC_INT0, USB_Group_IRQ_Handler); + * } + * \endcode + * + * @{ + */ + +#ifndef _UC3_INTERRUPT_MANAGEMENT_H_ +#define _UC3_INTERRUPT_MANAGEMENT_H_ + + /* Includes: */ + #include "../../Common/Common.h" + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Private Interface - For use in library only: */ + #if !defined(__DOXYGEN__) + /* Type Defines: */ + typedef void (*InterruptHandlerPtr_t)(void); + + /* External Variables: */ + #if defined(__INCLUDE_FROM_INTMANAGEMENT_C) + extern const void EVBA_Table; + #endif + extern InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS]; + extern const uint32_t Autovector_Table[]; + #endif + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Converts a given interrupt index into its associated interrupt group. + * + * \param[in] IRQIndex Index of the interrupt request to convert. + * + * \return Interrupt group number associated with the interrupt index. + */ + #define INTC_IRQ_GROUP(IRQIndex) (IRQIndex / 32) + + /** Converts a given interrupt index into its associated interrupt line. + * + * \param[in] IRQIndex Index of the interrupt request to convert. + * + * \return Interrupt line number associated with the interrupt index. + */ + #define INTC_IRQ_LINE(IRQIndex) (IRQIndex % 32) + + /* Function Prototypes: */ + void INTC_Init(void); + InterruptHandlerPtr_t INTC_GetInterruptHandler(const uint_reg_t InterruptLevel); + + /* Inline Functions: */ + /** Registers a handler for a given interrupt group. On the AVR32 UC3 devices, interrupts are grouped by + * peripheral. To save on SRAM used, a single ISR handles all interrupt lines within a single group - to + * determine the exact line that has interrupted within the group ISR handler, use \ref INTC_GetGroupInterrupts(). + * + * If multiple interrupts with the same group are registered, the last registered handler will become the + * handler called for interrupts raised within that group. + * + * To obtain the group number of a specific interrupt index, use the \ref INTC_IRQ_GROUP() macro. + * + * \param[in] GroupNumber Group number of the interrupt group to register a handler for. + * \param[in] InterruptLevel Priority level for the specified interrupt, a \c AVR32_INTC_INT* mask. + * \param[in] Handler Address of the ISR handler for the interrupt group. + */ + static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber, + const uint8_t InterruptLevel, + const InterruptHandlerPtr_t Handler) ATTR_ALWAYS_INLINE; + static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber, + const uint8_t InterruptLevel, + const InterruptHandlerPtr_t Handler) + { + InterruptHandlers[GroupNumber] = Handler; + AVR32_INTC.ipr[GroupNumber] = Autovector_Table[InterruptLevel]; + } + + /** Retrieves the pending interrupts for a given interrupt group. The result of this function should be masked + * against interrupt request indexes converted to a request line number via the \ref INTC_IRQ_LINE() macro. To + * obtain the group number of a given interrupt request, use the \ref INTC_IRQ_GROUP() macro. + * + * \param[in] GroupNumber Group number of the interrupt group to check. + * + * \return Mask of pending interrupt lines for the given interrupt group. + */ + static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber) ATTR_ALWAYS_INLINE; + static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber) + { + return AVR32_INTC.irr[GroupNumber]; + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Platform/XMEGA/ClockManagement.h b/protocol/lufa/LUFA-120730/LUFA/Platform/XMEGA/ClockManagement.h new file mode 100644 index 000000000..cd9c5f49e --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Platform/XMEGA/ClockManagement.h @@ -0,0 +1,397 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * \brief Module Clock Driver for the AVR USB XMEGA microcontrollers. + * + * Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration + * of the various clocks within the device to clock the various peripherals. + */ + +/** \ingroup Group_PlatformDrivers_XMEGA + * \defgroup Group_PlatformDrivers_XMEGAClocks Clock Management Driver - LUFA/Platform/XMEGA/ClockManagement.h + * \brief Module Clock Driver for the AVR USB XMEGA microcontrollers. + * + * \section Sec_Dependencies Module Source Dependencies + * The following files must be built with any user project that uses this module: + * - None + * + * \section Sec_ModDescription Module Description + * Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration + * of the various clocks within the device to clock the various peripherals. + * + * Usage Example: + * \code + * #include + * + * void main(void) + * { + * // Start the PLL to multiply the 2MHz RC oscillator to F_CPU and switch the CPU core to run from it + * XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + * XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + * + * // Start the 32MHz internal RC oscillator and start the DFLL to increase it to F_USB using the USB SOF as a reference + * XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + * XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + * } + * \endcode + * + * @{ + */ + +#ifndef _XMEGA_CLOCK_MANAGEMENT_H_ +#define _XMEGA_CLOCK_MANAGEMENT_H_ + + /* Includes: */ + #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: */ + /** Enum for the possible external oscillator frequency ranges. */ + enum XMEGA_Extern_OSC_ClockFrequency_t + { + EXOSC_FREQ_2MHZ_MAX = OSC_FRQRANGE_04TO2_gc, /**< External crystal oscillator equal to or slower than 2MHz. */ + EXOSC_FREQ_9MHZ_MAX = OSC_FRQRANGE_2TO9_gc, /**< External crystal oscillator equal to or slower than 9MHz. */ + EXOSC_FREQ_12MHZ_MAX = OSC_FRQRANGE_9TO12_gc, /**< External crystal oscillator equal to or slower than 12MHz. */ + EXOSC_FREQ_16MHZ_MAX = OSC_FRQRANGE_12TO16_gc, /**< External crystal oscillator equal to or slower than 16MHz. */ + }; + + /** Enum for the possible external oscillator startup times. */ + enum XMEGA_Extern_OSC_ClockStartup_t + { + EXOSC_START_6CLK = OSC_XOSCSEL_EXTCLK_gc, /**< Wait 6 clock cycles before startup (external clock). */ + EXOSC_START_32KCLK = OSC_XOSCSEL_32KHz_gc, /**< Wait 32K clock cycles before startup (32.768KHz crystal). */ + EXOSC_START_256CLK = OSC_XOSCSEL_XTAL_256CLK_gc, /**< Wait 256 clock cycles before startup. */ + EXOSC_START_1KCLK = OSC_XOSCSEL_XTAL_1KCLK_gc, /**< Wait 1K clock cycles before startup. */ + EXOSC_START_16KCLK = OSC_XOSCSEL_XTAL_16KCLK_gc, /**< Wait 16K clock cycles before startup. */ + }; + + /** Enum for the possible module clock sources. */ + enum XMEGA_System_ClockSource_t + { + CLOCK_SRC_INT_RC2MHZ = 0, /**< Clock sourced from the Internal 2MHz RC Oscillator clock. */ + CLOCK_SRC_INT_RC32MHZ = 1, /**< Clock sourced from the Internal 32MHz RC Oscillator clock. */ + CLOCK_SRC_INT_RC32KHZ = 2, /**< Clock sourced from the Internal 32KHz RC Oscillator clock. */ + CLOCK_SRC_XOSC = 3, /**< Clock sourced from the External Oscillator clock. */ + CLOCK_SRC_PLL = 4, /**< Clock sourced from the Internal PLL clock. */ + }; + + /** Enum for the possible DFLL clock reference sources. */ + enum XMEGA_System_DFLLReference_t + { + DFLL_REF_INT_RC32KHZ = 0, /**< Reference clock sourced from the Internal 32KHz RC Oscillator clock. */ + DFLL_REF_EXT_RC32KHZ = 1, /**< Reference clock sourced from the External 32KHz RC Oscillator clock connected to TOSC pins. */ + DFLL_REF_INT_USBSOF = 2, /**< Reference clock sourced from the USB Start Of Frame packets. */ + }; + + /* Inline Functions: */ + /** Write a value to a location protected by the XMEGA CCP protection mechanism. This function uses inline assembly to ensure that + * the protected address is written to within four clock cycles of the CCP key being written. + * + * \param[in] Address Address to write to, a memory address protected by the CCP mechanism + * \param[in] Value Value to write to the protected location + */ + static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value) ATTR_ALWAYS_INLINE; + static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value) + { + __asm__ __volatile__ ( + "out %0, __zero_reg__" "\n\t" /* Zero RAMPZ using fixed zero value register */ + "movw r30, %1" "\n\t" /* Copy address to Z register pair */ + "out %2, %3" "\n\t" /* Write key to CCP register */ + "st Z, %4" "\n\t" /* Indirectly write value to address */ + : /* No output operands */ + : /* Input operands: */ "m" (RAMPZ), "e" (Address), "m" (CCP), "r" (CCP_IOREG_gc), "r" (Value) + : /* Clobbered registers: */ "r30", "r31" + ); + } + + /** Starts the external oscillator of the XMEGA microcontroller, with the given options. This routine blocks until + * the oscillator is ready for use. + * + * \param[in] FreqRange Frequency range of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockFrequency_t. + * \param[in] Startup Startup time of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockStartup_t. + * + * \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified. + */ + static inline bool XMEGACLK_StartExternalOscillator(const uint8_t FreqRange, + const uint8_t Startup) ATTR_ALWAYS_INLINE; + static inline bool XMEGACLK_StartExternalOscillator(const uint8_t FreqRange, + const uint8_t Startup) + { + OSC.XOSCCTRL = (FreqRange | ((Startup == EXOSC_START_32KCLK) ? OSC_X32KLPM_bm : 0) | Startup); + OSC.CTRL |= OSC_XOSCEN_bm; + + while (!(OSC.STATUS & OSC_XOSCRDY_bm)); + return true; + } + + /** Stops the external oscillator of the XMEGA microcontroller. */ + static inline void XMEGACLK_StopExternalOscillator(void) ATTR_ALWAYS_INLINE; + static inline void XMEGACLK_StopExternalOscillator(void) + { + OSC.CTRL &= ~OSC_XOSCEN_bm; + } + + /** Starts the given internal oscillator of the XMEGA microcontroller, with the given options. This routine blocks until + * the oscillator is ready for use. + * + * \param[in] Source Internal oscillator to start, a value from \ref XMEGA_System_ClockSource_t. + * + * \return Boolean \c true if the internal oscillator was successfully started, \c false if invalid parameters specified. + */ + static inline uint8_t XMEGACLK_StartInternalOscillator(const uint8_t Source) ATTR_ALWAYS_INLINE; + static inline uint8_t XMEGACLK_StartInternalOscillator(const uint8_t Source) + { + switch (Source) + { + case CLOCK_SRC_INT_RC2MHZ: + OSC.CTRL |= OSC_RC2MEN_bm; + while (!(OSC.STATUS & OSC_RC2MRDY_bm)); + return true; + case CLOCK_SRC_INT_RC32MHZ: + OSC.CTRL |= OSC_RC32MEN_bm; + while (!(OSC.STATUS & OSC_RC32MRDY_bm)); + return true; + case CLOCK_SRC_INT_RC32KHZ: + OSC.CTRL |= OSC_RC32KEN_bm; + while (!(OSC.STATUS & OSC_RC32KRDY_bm)); + return true; + } + + return false; + } + + /** Stops the given internal oscillator of the XMEGA microcontroller. + * + * \param[in] Source Internal oscillator to stop, a value from \ref XMEGA_System_ClockSource_t. + * + * \return Boolean \c true if the internal oscillator was successfully stopped, \c false if invalid parameters specified. + */ + static inline bool XMEGACLK_StopInternalOscillator(const uint8_t Source) ATTR_ALWAYS_INLINE; + static inline bool XMEGACLK_StopInternalOscillator(const uint8_t Source) + { + switch (Source) + { + case CLOCK_SRC_INT_RC2MHZ: + OSC.CTRL &= ~OSC_RC2MEN_bm; + return true; + case CLOCK_SRC_INT_RC32MHZ: + OSC.CTRL &= ~OSC_RC32MEN_bm; + return true; + case CLOCK_SRC_INT_RC32KHZ: + OSC.CTRL &= ~OSC_RC32KEN_bm; + return true; + } + + return false; + } + + /** Starts the PLL of the XMEGA microcontroller, with the given options. This routine blocks until the PLL is ready for use. + * + * \attention The output frequency must be equal to or greater than the source frequency. + * + * \param[in] Source Clock source for the PLL, a value from \ref XMEGA_System_ClockSource_t. + * \param[in] SourceFreq Frequency of the PLL's clock source, in Hz. + * \param[in] Frequency Target frequency of the PLL's output. + * + * \return Boolean \c true if the PLL was successfully started, \c false if invalid parameters specified. + */ + static inline bool XMEGACLK_StartPLL(const uint8_t Source, + const uint32_t SourceFreq, + const uint32_t Frequency) ATTR_ALWAYS_INLINE; + static inline bool XMEGACLK_StartPLL(const uint8_t Source, + const uint32_t SourceFreq, + const uint32_t Frequency) + { + uint8_t MulFactor = (Frequency / SourceFreq); + + if (SourceFreq > Frequency) + return false; + + if (MulFactor > 31) + return false; + + switch (Source) + { + case CLOCK_SRC_INT_RC2MHZ: + OSC.PLLCTRL = (OSC_PLLSRC_RC2M_gc | MulFactor); + break; + case CLOCK_SRC_INT_RC32MHZ: + OSC.PLLCTRL = (OSC_PLLSRC_RC32M_gc | MulFactor); + break; + case CLOCK_SRC_XOSC: + OSC.PLLCTRL = (OSC_PLLSRC_XOSC_gc | MulFactor); + break; + default: + return false; + } + + OSC.CTRL |= OSC_PLLEN_bm; + + while (!(OSC.STATUS & OSC_PLLRDY_bm)); + return true; + } + + /** Stops the PLL of the XMEGA microcontroller. */ + static inline void XMEGACLK_StopPLL(void) ATTR_ALWAYS_INLINE; + static inline void XMEGACLK_StopPLL(void) + { + OSC.CTRL &= ~OSC_PLLEN_bm; + } + + /** Starts the DFLL of the XMEGA microcontroller, with the given options. + * + * \param[in] Source RC Clock source for the DFLL, a value from \ref XMEGA_System_ClockSource_t. + * \param[in] Reference Reference clock source for the DFLL, an value from \ref XMEGA_System_DFLLReference_t. + * \param[in] Frequency Target frequency of the DFLL's output. + * + * \return Boolean \c true if the DFLL was successfully started, \c false if invalid parameters specified. + */ + static inline bool XMEGACLK_StartDFLL(const uint8_t Source, + const uint8_t Reference, + const uint32_t Frequency) ATTR_ALWAYS_INLINE; + static inline bool XMEGACLK_StartDFLL(const uint8_t Source, + const uint8_t Reference, + const uint32_t Frequency) + { + uint16_t DFLLCompare = (Frequency / 1000); + + switch (Source) + { + case CLOCK_SRC_INT_RC2MHZ: + OSC.DFLLCTRL |= (Reference << OSC_RC2MCREF_bp); + DFLLRC2M.COMP1 = (DFLLCompare & 0xFF); + DFLLRC2M.COMP2 = (DFLLCompare >> 8); + DFLLRC2M.CTRL = DFLL_ENABLE_bm; + break; + case CLOCK_SRC_INT_RC32MHZ: + OSC.DFLLCTRL |= (Reference << OSC_RC32MCREF_gp); + DFLLRC32M.COMP1 = (DFLLCompare & 0xFF); + DFLLRC32M.COMP2 = (DFLLCompare >> 8); + + if (Reference == DFLL_REF_INT_USBSOF) + { + NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc; + DFLLRC32M.CALA = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBRCOSCA)); + DFLLRC32M.CALB = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBRCOSC)); + NVM.CMD = 0; + } + + DFLLRC32M.CTRL = DFLL_ENABLE_bm; + break; + default: + return false; + } + + return true; + } + + /** Stops the given DFLL of the XMEGA microcontroller. + * + * \param[in] Source RC Clock source for the DFLL to be stopped, a value from \ref XMEGA_System_ClockSource_t. + * + * \return Boolean \c true if the DFLL was successfully stopped, \c false if invalid parameters specified. + */ + static inline bool XMEGACLK_StopDFLL(const uint8_t Source) ATTR_ALWAYS_INLINE; + static inline bool XMEGACLK_StopDFLL(const uint8_t Source) + { + switch (Source) + { + case CLOCK_SRC_INT_RC2MHZ: + DFLLRC2M.CTRL = 0; + break; + case CLOCK_SRC_INT_RC32MHZ: + DFLLRC32M.CTRL = 0; + break; + default: + return false; + } + + return true; + } + + /** Sets the clock source for the main microcontroller core. The given clock source should be configured + * and ready for use before this function is called. + * + * \param[in] Source Clock source for the CPU core, a value from \ref XMEGA_System_ClockSource_t. + * + * \return Boolean \c true if the CPU core clock was successfully altered, \c false if invalid parameters specified. + */ + static inline bool XMEGACLK_SetCPUClockSource(const uint8_t Source) ATTR_ALWAYS_INLINE; + static inline bool XMEGACLK_SetCPUClockSource(const uint8_t Source) + { + uint8_t ClockSourceMask = 0; + + switch (Source) + { + case CLOCK_SRC_INT_RC2MHZ: + ClockSourceMask = CLK_SCLKSEL_RC2M_gc; + break; + case CLOCK_SRC_INT_RC32MHZ: + ClockSourceMask = CLK_SCLKSEL_RC32M_gc; + break; + case CLOCK_SRC_INT_RC32KHZ: + ClockSourceMask = CLK_SCLKSEL_RC32K_gc; + break; + case CLOCK_SRC_XOSC: + ClockSourceMask = CLK_SCLKSEL_XOSC_gc; + break; + case CLOCK_SRC_PLL: + ClockSourceMask = CLK_SCLKSEL_PLL_gc; + break; + default: + return false; + } + + uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask(); + GlobalInterruptDisable(); + + XMEGACLK_CCP_Write(&CLK.CTRL, ClockSourceMask); + + SetGlobalInterruptMask(CurrentGlobalInt); + + Delay_MS(1); + return (CLK.CTRL == ClockSourceMask); + } + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ + diff --git a/protocol/lufa/LUFA-120730/LUFA/Version.h b/protocol/lufa/LUFA-120730/LUFA/Version.h new file mode 100644 index 000000000..29b5020f6 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/Version.h @@ -0,0 +1,52 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * \brief LUFA library version constants. + * + * Version constants for informational purposes and version-specific macro creation. This header file contains the + * current LUFA version number in several forms, for use in the user-application (for example, for printing out + * whilst debugging, or for testing for version compatibility). + */ + +#ifndef __LUFA_VERSION_H__ +#define __LUFA_VERSION_H__ + + /* Public Interface - May be used in end-application: */ + /* Macros: */ + /** Indicates the version number of the library, as an integer. */ + #define LUFA_VERSION_INTEGER 0x120730 + + /** Indicates the version number of the library, as a string. */ + #define LUFA_VERSION_STRING "120730" + +#endif + diff --git a/protocol/lufa/LUFA-120730/LUFA/makefile b/protocol/lufa/LUFA-120730/LUFA/makefile new file mode 100644 index 000000000..fcf46bf68 --- /dev/null +++ b/protocol/lufa/LUFA-120730/LUFA/makefile @@ -0,0 +1,50 @@ +# +# LUFA Library +# Copyright (C) Dean Camera, 2012. +# +# dean [at] fourwalledcubicle [dot] com +# www.lufa-lib.org +# +# --------------------------------------- +# Makefile for the LUFA library itself. +# --------------------------------------- + +LUFA_VERSION_NUM := $(shell grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2) +EXCLUDE_FROM_EXPORT := Documentation DoxygenPages CodeTemplates Build *.conf *.tar *.o *.d *.lss *.lst *.hex *.elf *.hex *.eep *.map *.bin + +all: + +export_tar: + @echo Exporting LUFA library to a TAR archive... + @tar -cf LUFA_$(LUFA_VERSION_NUM).tar --directory=. $(EXCLUDE_FROM_EXPORT:%=--exclude=%) * + @tar -cf LUFA_$(LUFA_VERSION_NUM)_Code_Templates.tar CodeTemplates + @echo Export LUFA_$(LUFA_VERSION_NUM).tar complete. + +version: + @echo "LUFA $(LUFA_VERSION_NUM)" + +# Check if this is being included from a legacy or non LUFA build system makefile +ifneq ($(LUFA_PATH),) + LUFA_ROOT_PATH = $(patsubst %/,%,$(LUFA_PATH))/LUFA/ + + include $(patsubst %/,%,$(LUFA_PATH))/LUFA/Build/lufa.sources.in +else + LUFA_BUILD_MODULES += MASTER + LUFA_BUILD_TARGETS += export_tar version + + LUFA_PATH = . + ARCH = {AVR8,UC3,XMEGA} + DOXYGEN_OVERRIDE_PARAMS = QUIET=YES PROJECT_NUMBER=$(LUFA_VERSION_NUM) + + clean: + rm -f $(LUFA_SRC_ALL_FILES:%.c=%.o) + rm -f $(LUFA_SRC_ALL_FILES:%.c=%.d) + rm -f $(LUFA_SRC_ALL_FILES:%.c=%.lst) + + include Build/lufa_core.mk + include Build/lufa_sources.mk + include Build/lufa_doxygen.mk +endif + + +.PHONY: all export_tar version clean \ No newline at end of file diff --git a/protocol/lufa/LUFA-120730/README.txt b/protocol/lufa/LUFA-120730/README.txt new file mode 100644 index 000000000..aacb4af9a --- /dev/null +++ b/protocol/lufa/LUFA-120730/README.txt @@ -0,0 +1,56 @@ + + _ _ _ ___ _ + | | | | | __/ \ + | |_| U | _| o | - The Lightweight USB + |___|___|_||_n_| Framework for AVRs + ========================================= + Written by Dean Camera + dean [at] fourwalledcubicle [dot] com + + http://www.lufa-lib.org + ========================================= + + LUFA is donation supported. To support LUFA, + please donate at http://www.lufa-lib.org/donate + + Released under a modified MIT license - see + LUFA/License.txt for license details. + + For Commercial Licensing information, see + http://www.lufa-lib.org/license + + +This package contains the complete LUFA library, demos, user-submitted +projects and bootloaders for use with compatible microcontroller models. +LUFA is a simple to use, lightweight framework which sits atop the hardware +USB controller in specific AVR microcontroller models, and allows for the +quick and easy creation of complex USB devices and hosts. + +To get started, you will need to install the "Doxygen" documentation +generation tool. If you use Linux, this can be installed via the "doxygen" +package in your chosen package management tool - under Ubuntu, this can be +achieved by running the following command in the terminal: + + sudo apt-get install doxygen + +Other package managers and distributions will have similar methods to +install Doxygen. In Windows, you can download a prebuilt installer for +Doxygen from its website, www.doxygen.org. + +Once installed, you can then use the Doxygen tool to generate the library +documentation from the command line or terminal of your operating system. To +do this, open your terminal or command line to the root directory of the +LUFA package, and type the following command: + + make doxygen + +Which will recursively generate documentation for all elements in the +library - the core, plus all demos, projects and bootloaders. Generated +documentation will then be available by opening the file "index.html" of the +created Documentation/html/ subdirectories inside each project folder. + +The documentation for the library itself (but not the documentation for the +individual demos, projects or bootloaders) is also available as a separate +package from the project webpage for convenience if Doxygen cannot be +installed. + diff --git a/protocol/lufa/LUFA-git b/protocol/lufa/LUFA-git new file mode 160000 index 000000000..b6c18b2a7 --- /dev/null +++ b/protocol/lufa/LUFA-git @@ -0,0 +1 @@ +Subproject commit b6c18b2a7c544653efbe12a1d4e8ba65e7d83c35 diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c new file mode 100644 index 000000000..c13a81bda --- /dev/null +++ b/protocol/lufa/descriptor.c @@ -0,0 +1,630 @@ +/* + * Copyright 2012 Jun Wako + * This file is based on: + * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse + * LUFA-120219/Demos/Device/Lowlevel/GenericHID + */ + +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + 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 "util.h" +#include "report.h" +#include "descriptor.h" + + +/******************************************************************************* + * HID Report Descriptors + ******************************************************************************/ +const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = +{ + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x06), /* Keyboard */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ + HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ + HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, 0x08), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_CONSTANT), /* reserved */ + + HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ + HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ + HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ + HID_RI_REPORT_COUNT(8, 0x05), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x03), + HID_RI_OUTPUT(8, HID_IOF_CONSTANT), + + HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */ + HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */ + HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Keyboard Application */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_REPORT_COUNT(8, 0x06), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), + HID_RI_END_COLLECTION(0), +}; + +#ifdef MOUSE_ENABLE +const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = +{ + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x02), /* Mouse */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_USAGE(8, 0x01), /* Pointer */ + HID_RI_COLLECTION(8, 0x00), /* Physical */ + + HID_RI_USAGE_PAGE(8, 0x09), /* Button */ + HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */ + HID_RI_USAGE_MAXIMUM(8, 0x05), /* Button 5 */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, 0x05), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x03), + HID_RI_INPUT(8, HID_IOF_CONSTANT), + + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x30), /* Usage X */ + HID_RI_USAGE(8, 0x31), /* Usage Y */ + HID_RI_LOGICAL_MINIMUM(8, -127), + HID_RI_LOGICAL_MAXIMUM(8, 127), + HID_RI_REPORT_COUNT(8, 0x02), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + + HID_RI_USAGE(8, 0x38), /* Wheel */ + HID_RI_LOGICAL_MINIMUM(8, -127), + HID_RI_LOGICAL_MAXIMUM(8, 127), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + + HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */ + HID_RI_USAGE(16, 0x0238), /* AC Pan (Horizontal wheel) */ + HID_RI_LOGICAL_MINIMUM(8, -127), + HID_RI_LOGICAL_MAXIMUM(8, 127), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + + HID_RI_END_COLLECTION(0), + HID_RI_END_COLLECTION(0), +}; +#endif + +#ifdef EXTRAKEY_ENABLE +const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = +{ + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x80), /* System Control */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), + HID_RI_LOGICAL_MINIMUM(16, 0x0001), + HID_RI_LOGICAL_MAXIMUM(16, 0x00B7), + HID_RI_USAGE_MINIMUM(16, 0x0001), /* System Power Down */ + HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */ + HID_RI_REPORT_SIZE(8, 16), + HID_RI_REPORT_COUNT(8, 1), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), + HID_RI_END_COLLECTION(0), + + HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */ + HID_RI_USAGE(8, 0x01), /* Consumer Control */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER), + HID_RI_LOGICAL_MINIMUM(16, 0x0001), + HID_RI_LOGICAL_MAXIMUM(16, 0x029C), + HID_RI_USAGE_MINIMUM(16, 0x0001), /* +10 */ + HID_RI_USAGE_MAXIMUM(16, 0x029C), /* AC Distribute Vertically */ + HID_RI_REPORT_SIZE(8, 16), + HID_RI_REPORT_COUNT(8, 1), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), + HID_RI_END_COLLECTION(0), +}; +#endif + +#ifdef CONSOLE_ENABLE +const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = +{ + HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */ + HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0xFF), + HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), + HID_RI_REPORT_SIZE(8, 0x08), + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_END_COLLECTION(0), +}; +#endif + +#ifdef NKRO_ENABLE +const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] = +{ + HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ + HID_RI_USAGE(8, 0x06), /* Keyboard */ + HID_RI_COLLECTION(8, 0x01), /* Application */ + HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ + HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ + HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, 0x08), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + + HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ + HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ + HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ + HID_RI_REPORT_COUNT(8, 0x05), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x03), + HID_RI_OUTPUT(8, HID_IOF_CONSTANT), + + HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ + HID_RI_USAGE_MINIMUM(8, 0x00), /* Keyboard 0 */ + HID_RI_USAGE_MAXIMUM(8, (NKRO_EPSIZE-1)*8-1), /* Keyboard Right GUI */ + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_REPORT_COUNT(8, (NKRO_EPSIZE-1)*8), + HID_RI_REPORT_SIZE(8, 0x01), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_END_COLLECTION(0), +}; +#endif + +/******************************************************************************* + * Device Descriptors + ******************************************************************************/ +const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = +{ + .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, + + .USBSpecification = VERSION_BCD(1,1,0), + .Class = USB_CSCP_NoDeviceClass, + .SubClass = USB_CSCP_NoDeviceSubclass, + .Protocol = USB_CSCP_NoDeviceProtocol, + + .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, + + /* specified in config.h */ + .VendorID = VENDOR_ID, + .ProductID = PRODUCT_ID, + .ReleaseNumber = DEVICE_VER, + + .ManufacturerStrIndex = 0x01, + .ProductStrIndex = 0x02, + .SerialNumStrIndex = NO_DESCRIPTOR, + + .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS +}; + +/******************************************************************************* + * Configuration Descriptors + ******************************************************************************/ +const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = +{ + .Config = + { + .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, + + .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), + .TotalInterfaces = TOTAL_INTERFACES, + + .ConfigurationNumber = 1, + .ConfigurationStrIndex = NO_DESCRIPTOR, + + .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP), + + .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) + }, + + /* + * Keyboard + */ + .Keyboard_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = KEYBOARD_INTERFACE, + .AlternateSetting = 0x00, + + .TotalEndpoints = 1, + + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_BootSubclass, + .Protocol = HID_CSCP_KeyboardBootProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .Keyboard_HID = + { + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, + + .HIDSpec = VERSION_BCD(1,1,1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(KeyboardReport) + }, + + .Keyboard_INEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = KEYBOARD_EPSIZE, + .PollingIntervalMS = 0x0A + }, + + /* + * Mouse + */ +#ifdef MOUSE_ENABLE + .Mouse_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = MOUSE_INTERFACE, + .AlternateSetting = 0x00, + + .TotalEndpoints = 1, + + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_BootSubclass, + .Protocol = HID_CSCP_MouseBootProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .Mouse_HID = + { + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, + + .HIDSpec = VERSION_BCD(1,1,1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(MouseReport) + }, + + .Mouse_INEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = MOUSE_EPSIZE, + .PollingIntervalMS = 0x0A + }, +#endif + + /* + * Extra + */ +#ifdef EXTRAKEY_ENABLE + .Extrakey_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = EXTRAKEY_INTERFACE, + .AlternateSetting = 0x00, + + .TotalEndpoints = 1, + + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_NonBootSubclass, + .Protocol = HID_CSCP_NonBootProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .Extrakey_HID = + { + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, + + .HIDSpec = VERSION_BCD(1,1,1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(ExtrakeyReport) + }, + + .Extrakey_INEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = EXTRAKEY_EPSIZE, + .PollingIntervalMS = 0x0A + }, +#endif + + /* + * Console + */ +#ifdef CONSOLE_ENABLE + .Console_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = CONSOLE_INTERFACE, + .AlternateSetting = 0x00, + + .TotalEndpoints = 2, + + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_NonBootSubclass, + .Protocol = HID_CSCP_NonBootProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .Console_HID = + { + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, + + .HIDSpec = VERSION_BCD(1,1,1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(ConsoleReport) + }, + + .Console_INEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CONSOLE_EPSIZE, + .PollingIntervalMS = 0x01 + }, + + .Console_OUTEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = CONSOLE_EPSIZE, + .PollingIntervalMS = 0x01 + }, +#endif + + /* + * NKRO + */ +#ifdef NKRO_ENABLE + .NKRO_Interface = + { + .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, + + .InterfaceNumber = NKRO_INTERFACE, + .AlternateSetting = 0x00, + + .TotalEndpoints = 1, + + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_NonBootSubclass, + .Protocol = HID_CSCP_NonBootProtocol, + + .InterfaceStrIndex = NO_DESCRIPTOR + }, + + .NKRO_HID = + { + .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, + + .HIDSpec = VERSION_BCD(1,1,1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(NKROReport) + }, + + .NKRO_INEndpoint = + { + .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, + + .EndpointAddress = (ENDPOINT_DIR_IN | NKRO_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = NKRO_EPSIZE, + .PollingIntervalMS = 0x01 + }, +#endif +}; + + +/******************************************************************************* + * String Descriptors + ******************************************************************************/ +const USB_Descriptor_String_t PROGMEM LanguageString = +{ + .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, + + .UnicodeString = {LANGUAGE_ID_ENG} +}; + +const USB_Descriptor_String_t PROGMEM ManufacturerString = +{ + /* subtract 1 for null terminator */ + .Header = {.Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER))-1), .Type = DTYPE_String}, + + .UnicodeString = LSTR(MANUFACTURER) +}; + +const USB_Descriptor_String_t PROGMEM ProductString = +{ + /* subtract 1 for null terminator */ + .Header = {.Size = USB_STRING_LEN(sizeof(STR(PRODUCT))-1), .Type = DTYPE_String}, + + .UnicodeString = LSTR(PRODUCT) +}; + + +/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" + * documentation) by the application code so that the address and size of a requested descriptor can be given + * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function + * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the + * USB host. + */ +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + const void** const DescriptorAddress) +{ + const uint8_t DescriptorType = (wValue >> 8); + const uint8_t DescriptorIndex = (wValue & 0xFF); + + const void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = &DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = &ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + switch (DescriptorIndex ) + { + case 0x00: + Address = &LanguageString; + Size = pgm_read_byte(&LanguageString.Header.Size); + break; + case 0x01: + Address = &ManufacturerString; + Size = pgm_read_byte(&ManufacturerString.Header.Size); + break; + case 0x02: + Address = &ProductString; + Size = pgm_read_byte(&ProductString.Header.Size); + break; + } + break; + case HID_DTYPE_HID: + switch (wIndex) { + case KEYBOARD_INTERFACE: + Address = &ConfigurationDescriptor.Keyboard_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + break; +#ifdef MOUSE_ENABLE + case MOUSE_INTERFACE: + Address = &ConfigurationDescriptor.Mouse_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + break; +#endif +#ifdef EXTRAKEY_ENABLE + case EXTRAKEY_INTERFACE: + Address = &ConfigurationDescriptor.Extrakey_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + break; +#endif +#ifdef CONSOLE_ENABLE + case CONSOLE_INTERFACE: + Address = &ConfigurationDescriptor.Console_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + break; +#endif +#ifdef NKRO_ENABLE + case NKRO_INTERFACE: + Address = &ConfigurationDescriptor.NKRO_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + break; +#endif + } + break; + case HID_DTYPE_Report: + switch (wIndex) { + case KEYBOARD_INTERFACE: + Address = &KeyboardReport; + Size = sizeof(KeyboardReport); + break; +#ifdef MOUSE_ENABLE + case MOUSE_INTERFACE: + Address = &MouseReport; + Size = sizeof(MouseReport); + break; +#endif +#ifdef EXTRAKEY_ENABLE + case EXTRAKEY_INTERFACE: + Address = &ExtrakeyReport; + Size = sizeof(ExtrakeyReport); + break; +#endif +#ifdef CONSOLE_ENABLE + case CONSOLE_INTERFACE: + Address = &ConsoleReport; + Size = sizeof(ConsoleReport); + break; +#endif +#ifdef NKRO_ENABLE + case NKRO_INTERFACE: + Address = &NKROReport; + Size = sizeof(NKROReport); + break; +#endif + } + break; + } + + *DescriptorAddress = Address; + return Size; +} diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h new file mode 100644 index 000000000..42af07917 --- /dev/null +++ b/protocol/lufa/descriptor.h @@ -0,0 +1,176 @@ +/* + * Copyright 2012,2013 Jun Wako + * This file is based on: + * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse + * LUFA-120219/Demos/Device/Lowlevel/GenericHID + */ + +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/** \file + * + * Header file for Descriptors.c. + */ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + +#include +#include + + +typedef struct +{ + USB_Descriptor_Configuration_Header_t Config; + + // Keyboard HID Interface + USB_Descriptor_Interface_t Keyboard_Interface; + USB_HID_Descriptor_HID_t Keyboard_HID; + USB_Descriptor_Endpoint_t Keyboard_INEndpoint; + +#ifdef MOUSE_ENABLE + // Mouse HID Interface + USB_Descriptor_Interface_t Mouse_Interface; + USB_HID_Descriptor_HID_t Mouse_HID; + USB_Descriptor_Endpoint_t Mouse_INEndpoint; +#endif + +#ifdef EXTRAKEY_ENABLE + // Extrakey HID Interface + USB_Descriptor_Interface_t Extrakey_Interface; + USB_HID_Descriptor_HID_t Extrakey_HID; + USB_Descriptor_Endpoint_t Extrakey_INEndpoint; +#endif + +#ifdef CONSOLE_ENABLE + // Console HID Interface + USB_Descriptor_Interface_t Console_Interface; + USB_HID_Descriptor_HID_t Console_HID; + USB_Descriptor_Endpoint_t Console_INEndpoint; + USB_Descriptor_Endpoint_t Console_OUTEndpoint; +#endif + +#ifdef NKRO_ENABLE + // NKRO HID Interface + USB_Descriptor_Interface_t NKRO_Interface; + USB_HID_Descriptor_HID_t NKRO_HID; + USB_Descriptor_Endpoint_t NKRO_INEndpoint; +#endif +} USB_Descriptor_Configuration_t; + + +/* index of interface */ +#define KEYBOARD_INTERFACE 0 + +#ifdef MOUSE_ENABLE +# define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1) +#else +# define MOUSE_INTERFACE KEYBOARD_INTERFACE +#endif + +#ifdef EXTRAKEY_ENABLE +# define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1) +#else +# define EXTRAKEY_INTERFACE MOUSE_INTERFACE +#endif + +#ifdef CONSOLE_ENABLE +# define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1) +#else +# define CONSOLE_INTERFACE EXTRAKEY_INTERFACE +#endif + +#ifdef NKRO_ENABLE +# define NKRO_INTERFACE (CONSOLE_INTERFACE + 1) +#else +# define NKRO_INTERFACE CONSOLE_INTERFACE +#endif + + +/* nubmer of interfaces */ +#define TOTAL_INTERFACES (NKRO_INTERFACE + 1) + + +// Endopoint number and size +#define KEYBOARD_IN_EPNUM 1 + +#ifdef MOUSE_ENABLE +# define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1) +#else +# define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM +#endif + +#ifdef EXTRAKEY_ENABLE +# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1) +#else +# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM +#endif + +#ifdef CONSOLE_ENABLE +# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) +# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1) +//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) +#else +# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM +#endif + +#ifdef NKRO_ENABLE +# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1) +# if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4 +# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)" +# endif +#endif + + +#define KEYBOARD_EPSIZE 8 +#define MOUSE_EPSIZE 8 +#define EXTRAKEY_EPSIZE 8 +#define CONSOLE_EPSIZE 32 +#define NKRO_EPSIZE 16 + + +uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, + const uint8_t wIndex, + const void** const DescriptorAddress) + ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); + + +/* new API */ +#if LUFA_VERSION_INTEGER < 0x140302 + #undef VERSION_BCD + #define VERSION_BCD(Major, Minor, Revision) \ + CPU_TO_LE16( ((Major & 0xFF) << 8) | \ + ((Minor & 0x0F) << 4) | \ + (Revision & 0x0F) ) +#endif + +#endif diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c new file mode 100644 index 000000000..cdfc7bc6a --- /dev/null +++ b/protocol/lufa/lufa.c @@ -0,0 +1,605 @@ +/* + * Copyright 2012 Jun Wako + * This file is based on: + * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse + * LUFA-120219/Demos/Device/Lowlevel/GenericHID + */ + +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + 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 "report.h" +#include "host.h" +#include "host_driver.h" +#include "keyboard.h" +#include "action.h" +#include "led.h" +#include "sendchar.h" +#include "debug.h" +#ifdef SLEEP_LED_ENABLE +#include "sleep_led.h" +#endif +#include "suspend.h" + +#include "descriptor.h" +#include "lufa.h" + +uint8_t keyboard_idle = 0; +uint8_t keyboard_protocol = 1; +static uint8_t keyboard_led_stats = 0; + +static report_keyboard_t keyboard_report_sent; + + +/* Host driver */ +static uint8_t keyboard_leds(void); +static void send_keyboard(report_keyboard_t *report); +static void send_mouse(report_mouse_t *report); +static void send_system(uint16_t data); +static void send_consumer(uint16_t data); +host_driver_t lufa_driver = { + keyboard_leds, + send_keyboard, + send_mouse, + send_system, + send_consumer +}; + + +/******************************************************************************* + * Console + ******************************************************************************/ +#ifdef CONSOLE_ENABLE +static void Console_Task(void) +{ + /* Device must be connected and configured for the task to run */ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + uint8_t ep = Endpoint_GetCurrentEndpoint(); + +#if 0 + // TODO: impl receivechar()/recvchar() + Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM); + + /* Check to see if a packet has been sent from the host */ + if (Endpoint_IsOUTReceived()) + { + /* Check to see if the packet contains data */ + if (Endpoint_IsReadWriteAllowed()) + { + /* Create a temporary buffer to hold the read in report from the host */ + uint8_t ConsoleData[CONSOLE_EPSIZE]; + + /* Read Console Report Data */ + Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL); + + /* Process Console Report Data */ + //ProcessConsoleHIDReport(ConsoleData); + } + + /* Finalize the stream transfer to send the last packet */ + Endpoint_ClearOUT(); + } +#endif + + /* IN packet */ + Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); + if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) { + Endpoint_SelectEndpoint(ep); + return; + } + + // fill empty bank + while (Endpoint_IsReadWriteAllowed()) + Endpoint_Write_8(0); + + // flash senchar packet + if (Endpoint_IsINReady()) { + Endpoint_ClearIN(); + } + + Endpoint_SelectEndpoint(ep); +} +#else +static void Console_Task(void) +{ +} +#endif + + +/******************************************************************************* + * USB Events + ******************************************************************************/ +/* + * Event Order of Plug in: + * 0) EVENT_USB_Device_Connect + * 1) EVENT_USB_Device_Suspend + * 2) EVENT_USB_Device_Reset + * 3) EVENT_USB_Device_Wake +*/ +void EVENT_USB_Device_Connect(void) +{ + print("[C]"); + /* For battery powered device */ + if (!USB_IsInitialized) { + USB_Disable(); + USB_Init(); + USB_Device_EnableSOFEvents(); + } +} + +void EVENT_USB_Device_Disconnect(void) +{ + print("[D]"); + /* For battery powered device */ + USB_IsInitialized = false; +/* TODO: This doesn't work. After several plug in/outs can not be enumerated. + if (USB_IsInitialized) { + USB_Disable(); // Disable all interrupts + USB_Controller_Enable(); + USB_INT_Enable(USB_INT_VBUSTI); + } +*/ +} + +void EVENT_USB_Device_Reset(void) +{ + print("[R]"); +} + +void EVENT_USB_Device_Suspend() +{ + print("[S]"); + matrix_power_down(); +#ifdef SLEEP_LED_ENABLE + sleep_led_enable(); +#endif +} + +void EVENT_USB_Device_WakeUp() +{ + print("[W]"); + suspend_wakeup_init(); + +#ifdef SLEEP_LED_ENABLE + sleep_led_disable(); + // NOTE: converters may not accept this + led_set(host_keyboard_leds()); +#endif +} + +void EVENT_USB_Device_StartOfFrame(void) +{ + Console_Task(); +} + +/** Event handler for the USB_ConfigurationChanged event. + * This is fired when the host sets the current configuration of the USB device after enumeration. + */ +void EVENT_USB_Device_ConfigurationChanged(void) +{ + bool ConfigSuccess = true; + + /* Setup Keyboard HID Report Endpoints */ + ConfigSuccess &= ENDPOINT_CONFIG(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE); + +#ifdef MOUSE_ENABLE + /* Setup Mouse HID Report Endpoint */ + ConfigSuccess &= ENDPOINT_CONFIG(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE); +#endif + +#ifdef EXTRAKEY_ENABLE + /* Setup Extra HID Report Endpoint */ + ConfigSuccess &= ENDPOINT_CONFIG(EXTRAKEY_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + EXTRAKEY_EPSIZE, ENDPOINT_BANK_SINGLE); +#endif + +#ifdef CONSOLE_ENABLE + /* Setup Console HID Report Endpoints */ + ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE); +#if 0 + ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, + CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); +#endif +#endif + +#ifdef NKRO_ENABLE + /* Setup NKRO HID Report Endpoints */ + ConfigSuccess &= ENDPOINT_CONFIG(NKRO_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, + NKRO_EPSIZE, ENDPOINT_BANK_SINGLE); +#endif +} + +/* +Appendix G: HID Request Support Requirements + +The following table enumerates the requests that need to be supported by various types of HID class devices. + +Device type GetReport SetReport GetIdle SetIdle GetProtocol SetProtocol +------------------------------------------------------------------------------------------ +Boot Mouse Required Optional Optional Optional Required Required +Non-Boot Mouse Required Optional Optional Optional Optional Optional +Boot Keyboard Required Optional Required Required Required Required +Non-Boot Keybrd Required Optional Required Required Optional Optional +Other Device Required Optional Optional Optional Optional Optional +*/ +/** Event handler for the USB_ControlRequest event. + * This is fired before passing along unhandled control requests to the library for processing internally. + */ +void EVENT_USB_Device_ControlRequest(void) +{ + uint8_t* ReportData = NULL; + uint8_t ReportSize = 0; + + /* Handle HID Class specific requests */ + switch (USB_ControlRequest.bRequest) + { + case HID_REQ_GetReport: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + + // Interface + switch (USB_ControlRequest.wIndex) { + case KEYBOARD_INTERFACE: + // TODO: test/check + ReportData = (uint8_t*)&keyboard_report_sent; + ReportSize = sizeof(keyboard_report_sent); + break; + } + + /* Write the report data to the control endpoint */ + Endpoint_Write_Control_Stream_LE(ReportData, ReportSize); + Endpoint_ClearOUT(); + } + + break; + case HID_REQ_SetReport: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + + // Interface + switch (USB_ControlRequest.wIndex) { + case KEYBOARD_INTERFACE: +#ifdef NKRO_ENABLE + case NKRO_INTERFACE: +#endif + Endpoint_ClearSETUP(); + + while (!(Endpoint_IsOUTReceived())) { + if (USB_DeviceState == DEVICE_STATE_Unattached) + return; + } + keyboard_led_stats = Endpoint_Read_8(); + + Endpoint_ClearOUT(); + Endpoint_ClearStatusStage(); + break; + } + + } + + break; + + case HID_REQ_GetProtocol: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) { + Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(keyboard_protocol); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + } + + break; + case HID_REQ_SetProtocol: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00); +#ifdef NKRO_ENABLE + keyboard_nkro = !!keyboard_protocol; +#endif + clear_keyboard(); + } + } + + break; + case HID_REQ_SetIdle: + if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + Endpoint_ClearStatusStage(); + + keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8); + } + + break; + case HID_REQ_GetIdle: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) + { + Endpoint_ClearSETUP(); + while (!(Endpoint_IsINReady())); + Endpoint_Write_8(keyboard_idle); + Endpoint_ClearIN(); + Endpoint_ClearStatusStage(); + } + + break; + } +} + +/******************************************************************************* + * Host driver + ******************************************************************************/ +static uint8_t keyboard_leds(void) +{ + return keyboard_led_stats; +} + +static void send_keyboard(report_keyboard_t *report) +{ + uint8_t timeout = 255; + + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + /* Select the Keyboard Report Endpoint */ +#ifdef NKRO_ENABLE + if (keyboard_nkro) { + /* Report protocol - NKRO */ + Endpoint_SelectEndpoint(NKRO_IN_EPNUM); + + /* Check if write ready for a polling interval around 1ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4); + if (!Endpoint_IsReadWriteAllowed()) return; + + /* Write Keyboard Report Data */ + Endpoint_Write_Stream_LE(report, NKRO_EPSIZE, NULL); + } + else +#endif + { + /* Boot protocol */ + Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM); + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + + /* Write Keyboard Report Data */ + Endpoint_Write_Stream_LE(report, KEYBOARD_EPSIZE, NULL); + } + + /* Finalize the stream transfer to send the last packet */ + Endpoint_ClearIN(); + + keyboard_report_sent = *report; +} + +static void send_mouse(report_mouse_t *report) +{ +#ifdef MOUSE_ENABLE + uint8_t timeout = 255; + + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + /* Select the Mouse Report Endpoint */ + Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + + /* Write Mouse Report Data */ + Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL); + + /* Finalize the stream transfer to send the last packet */ + Endpoint_ClearIN(); +#endif +} + +static void send_system(uint16_t data) +{ + uint8_t timeout = 255; + + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + report_extra_t r = { + .report_id = REPORT_ID_SYSTEM, + .usage = data + }; + Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + + Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); + Endpoint_ClearIN(); +} + +static void send_consumer(uint16_t data) +{ + uint8_t timeout = 255; + + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + report_extra_t r = { + .report_id = REPORT_ID_CONSUMER, + .usage = data + }; + Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); + + /* Check if write ready for a polling interval around 10ms */ + while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); + if (!Endpoint_IsReadWriteAllowed()) return; + + Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); + Endpoint_ClearIN(); +} + + +/******************************************************************************* + * sendchar + ******************************************************************************/ +#ifdef CONSOLE_ENABLE +#define SEND_TIMEOUT 5 +int8_t sendchar(uint8_t c) +{ + // Not wait once timeouted. + // Because sendchar() is called so many times, waiting each call causes big lag. + static bool timeouted = false; + + if (USB_DeviceState != DEVICE_STATE_Configured) + return -1; + + uint8_t ep = Endpoint_GetCurrentEndpoint(); + Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); + if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) { + goto ERROR_EXIT; + } + + if (timeouted && !Endpoint_IsReadWriteAllowed()) { + goto ERROR_EXIT; + } + + timeouted = false; + + uint8_t timeout = SEND_TIMEOUT; + while (!Endpoint_IsReadWriteAllowed()) { + if (USB_DeviceState != DEVICE_STATE_Configured) { + goto ERROR_EXIT; + } + if (Endpoint_IsStalled()) { + goto ERROR_EXIT; + } + if (!(timeout--)) { + timeouted = true; + goto ERROR_EXIT; + } + _delay_ms(1); + } + + Endpoint_Write_8(c); + + // send when bank is full + if (!Endpoint_IsReadWriteAllowed()) + Endpoint_ClearIN(); + + Endpoint_SelectEndpoint(ep); + return 0; +ERROR_EXIT: + Endpoint_SelectEndpoint(ep); + return -1; +} +#else +int8_t sendchar(uint8_t c) +{ + return 0; +} +#endif + + +/******************************************************************************* + * main + ******************************************************************************/ +static void SetupHardware(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Disable clock division */ + clock_prescale_set(clock_div_1); + + // Leonardo needs. Without this USB device is not recognized. + USB_Disable(); + + USB_Init(); + + // for Console_Task + USB_Device_EnableSOFEvents(); + print_set_sendchar(sendchar); +} + +int main(void) __attribute__ ((weak)); +int main(void) +{ + SetupHardware(); + sei(); + + /* wait for USB startup & debug output */ + while (USB_DeviceState != DEVICE_STATE_Configured) { +#if defined(INTERRUPT_CONTROL_ENDPOINT) + ; +#else + USB_USBTask(); +#endif + } + print("USB configured.\n"); + + /* init modules */ + keyboard_init(); + host_set_driver(&lufa_driver); +#ifdef SLEEP_LED_ENABLE + sleep_led_init(); +#endif + + print("Keyboard start.\n"); + while (1) { + while (USB_DeviceState == DEVICE_STATE_Suspended) { + print("[s]"); + suspend_power_down(); + if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) { + USB_Device_SendRemoteWakeup(); + } + } + + keyboard_task(); + +#if !defined(INTERRUPT_CONTROL_ENDPOINT) + USB_USBTask(); +#endif + } +} diff --git a/protocol/lufa/lufa.h b/protocol/lufa/lufa.h new file mode 100644 index 000000000..195123c0f --- /dev/null +++ b/protocol/lufa/lufa.h @@ -0,0 +1,80 @@ +/* + * Copyright 2012 Jun Wako + * This file is based on: + * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse + * LUFA-120219/Demos/Device/Lowlevel/GenericHID + */ + +/* + LUFA Library + Copyright (C) Dean Camera, 2012. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _LUFA_H_ +#define _LUFA_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "host.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +extern host_driver_t lufa_driver; + +#ifdef __cplusplus +} +#endif + +/* extra report structure */ +typedef struct { + uint8_t report_id; + uint16_t usage; +} __attribute__ ((packed)) report_extra_t; + + +#if LUFA_VERSION_INTEGER < 0x120730 + /* old API 120219 */ + #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank) +#else + /* new API >= 120730 */ + #define ENDPOINT_BANK_SINGLE 1 + #define ENDPOINT_BANK_DOUBLE 2 + #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank) +#endif + +#endif diff --git a/protocol/m0110.c b/protocol/m0110.c new file mode 100644 index 000000000..0d3a5aaa4 --- /dev/null +++ b/protocol/m0110.c @@ -0,0 +1,591 @@ +/* +Copyright 2011,2012 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ +/* M0110A Support was contributed by skagon@github */ + +#include +#include +#include +#include +#include "m0110.h" +#include "debug.h" + + +static inline uint8_t raw2scan(uint8_t raw); +static inline uint8_t inquiry(void); +static inline uint8_t instant(void); +static inline void clock_lo(void); +static inline void clock_hi(void); +static inline bool clock_in(void); +static inline void data_lo(void); +static inline void data_hi(void); +static inline bool data_in(void); +static inline uint16_t wait_clock_lo(uint16_t us); +static inline uint16_t wait_clock_hi(uint16_t us); +static inline uint16_t wait_data_lo(uint16_t us); +static inline uint16_t wait_data_hi(uint16_t us); +static inline void idle(void); +static inline void request(void); + + +#define WAIT_US(stat, us, err) do { \ + if (!wait_##stat(us)) { \ + m0110_error = err; \ + goto ERROR; \ + } \ +} while (0) + +#define WAIT_MS(stat, ms, err) do { \ + uint16_t _ms = ms; \ + while (_ms) { \ + if (wait_##stat(1000)) { \ + break; \ + } \ + _ms--; \ + } \ + if (_ms == 0) { \ + m0110_error = err; \ + goto ERROR; \ + } \ +} while (0) + +#define KEY(raw) ((raw) & 0x7f) +#define IS_BREAK(raw) (((raw) & 0x80) == 0x80) + + +uint8_t m0110_error = 0; + + +void m0110_init(void) +{ + idle(); + _delay_ms(1000); + +/* Not needed to initialize in fact. + uint8_t data; + m0110_send(M0110_MODEL); + data = m0110_recv(); + print("m0110_init model: "); phex(data); print("\n"); + + m0110_send(M0110_TEST); + data = m0110_recv(); + print("m0110_init test: "); phex(data); print("\n"); +*/ +} + +uint8_t m0110_send(uint8_t data) +{ + m0110_error = 0; + + request(); + WAIT_MS(clock_lo, 250, 1); // keyboard may block long time + for (uint8_t bit = 0x80; bit; bit >>= 1) { + WAIT_US(clock_lo, 250, 3); + if (data&bit) { + data_hi(); + } else { + data_lo(); + } + WAIT_US(clock_hi, 200, 4); + } + _delay_us(100); // hold last bit for 80us + idle(); + return 1; +ERROR: + print("m0110_send err: "); phex(m0110_error); print("\n"); + _delay_ms(500); + idle(); + return 0; +} + +uint8_t m0110_recv(void) +{ + uint8_t data = 0; + m0110_error = 0; + + WAIT_MS(clock_lo, 250, 1); // keyboard may block long time + for (uint8_t i = 0; i < 8; i++) { + data <<= 1; + WAIT_US(clock_lo, 200, 2); + WAIT_US(clock_hi, 200, 3); + if (data_in()) { + data |= 1; + } + } + idle(); + return data; +ERROR: + print("m0110_recv err: "); phex(m0110_error); print("\n"); + _delay_ms(500); + idle(); + return 0xFF; +} + +/* +Handling for exceptional case of key combinations for M0110A + +Shift and Calc/Arrow key could be operated simultaneously: + + Case Shift Arrow Events Interpret + ------------------------------------------------------------------- + 1 Down Down 71, 79, DD Calc(d)*a *b + 2 Down Up 71, 79, UU Arrow&Calc(u)*a + 3 Up Down F1, 79, DD Shift(u) *c + 4 Up Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a + + Case Shift Calc Events Interpret + ------------------------------------------------------------------- + 5(1) Down Down 71, 71, 79, DD Shift(d) and Cacl(d) + 6(2) Down Up F1, 71, 79, UU Shift(u) and Arrow&Calc(u)*a + 7(1) Up Down F1, 71, 79, DD Shift(u) and Calc(d) + 8(4) Up Up F1, F1, 79, UU Shift(ux2) and Arrow&Calc(u)*a + +During Calc key is hold: + Case Shift Arrow Events Interpret + ------------------------------------------------------------------- + A(3) ---- Down F1, 79, DD Shift(u) *c + B ---- Up 79, UU Arrow&Calc(u)*a + C Down ---- F1, 71 Shift(u) and Shift(d) + D Up ---- F1 Shift(u) + E Hold Down 79, DD Normal + F Hold Up 79, UU Arrow&Calc(u)*a + G(1) Down Down F1, 71, 79, DD Shift(u)*b and Calc(d)*a + H(2) Down Up F1, 71, 79, UU Shift(u) and Arrow&Calc(u)*a + I(3) Up Down F1, F1, 79, DD Shift(ux2) *c + J(4) Up Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a + + Case Shift Calc Events Interpret + ------------------------------------------------------------------- + K(1) ---- Down 71, 79, DD Calc(d)*a + L(4) ---- Up F1, 79, UU Shift(u) and Arrow&Calc(u)*a + M(1) Hold Down 71, 79, DD Calc(d)*a + N Hold Up 79, UU Arrow&Calc(u)*a + + Where DD/UU indicates part of Keypad Down/Up event. + *a: Impossible to distinguish btween Arrow and Calc event. + *b: Shift(d) event is ignored. + *c: Arrow/Calc(d) event is ignored. +*/ +uint8_t m0110_recv_key(void) +{ + static uint8_t keybuf = 0x00; + static uint8_t keybuf2 = 0x00; + static uint8_t rawbuf = 0x00; + uint8_t raw, raw2, raw3; + + if (keybuf) { + raw = keybuf; + keybuf = 0x00; + return raw; + } + if (keybuf2) { + raw = keybuf2; + keybuf2 = 0x00; + return raw; + } + + if (rawbuf) { + raw = rawbuf; + rawbuf = 0x00; + } else { + raw = instant(); // Use INSTANT for better response. Should be INQUIRY ? + } + switch (KEY(raw)) { + case M0110_KEYPAD: + raw2 = instant(); + switch (KEY(raw2)) { + case M0110_ARROW_UP: + case M0110_ARROW_DOWN: + case M0110_ARROW_LEFT: + case M0110_ARROW_RIGHT: + if (IS_BREAK(raw2)) { + // Case B,F,N: + keybuf = (raw2scan(raw2) | M0110_CALC_OFFSET); // Calc(u) + return (raw2scan(raw2) | M0110_KEYPAD_OFFSET); // Arrow(u) + } + break; + } + // Keypad or Arrow + return (raw2scan(raw2) | M0110_KEYPAD_OFFSET); + break; + case M0110_SHIFT: + raw2 = instant(); + switch (KEY(raw2)) { + case M0110_SHIFT: + // Case: 5-8,C,G,H + rawbuf = raw2; + return raw2scan(raw); // Shift(d/u) + break; + case M0110_KEYPAD: + // Shift + Arrow, Calc, or etc. + raw3 = instant(); + switch (KEY(raw3)) { + case M0110_ARROW_UP: + case M0110_ARROW_DOWN: + case M0110_ARROW_LEFT: + case M0110_ARROW_RIGHT: + if (IS_BREAK(raw)) { + if (IS_BREAK(raw3)) { + // Case 4: + print("(4)\n"); + keybuf2 = raw2scan(raw); // Shift(u) + keybuf = (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(u) + return (raw2scan(raw3) | M0110_KEYPAD_OFFSET); // Arrow(u) + } else { + // Case 3: + print("(3)\n"); + return (raw2scan(raw)); // Shift(u) + } + } else { + if (IS_BREAK(raw3)) { + // Case 2: + print("(2)\n"); + keybuf = (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(u) + return (raw2scan(raw3) | M0110_KEYPAD_OFFSET); // Arrow(u) + } else { + // Case 1: + print("(1)\n"); + return (raw2scan(raw3) | M0110_CALC_OFFSET); // Calc(d) + } + } + break; + default: + // Shift + Keypad + keybuf = (raw2scan(raw3) | M0110_KEYPAD_OFFSET); + return raw2scan(raw); // Shift(d/u) + break; + } + break; + default: + // Shift + Normal keys + keybuf = raw2scan(raw2); + return raw2scan(raw); // Shift(d/u) + break; + } + break; + default: + // Normal keys + return raw2scan(raw); + break; + } +} + + +static inline uint8_t raw2scan(uint8_t raw) { + return (raw == M0110_NULL) ? M0110_NULL : ( + (raw == M0110_ERROR) ? M0110_ERROR : ( + ((raw&0x80) | ((raw&0x7F)>>1)) + ) + ); +} + +static inline uint8_t inquiry(void) +{ + m0110_send(M0110_INQUIRY); + return m0110_recv(); +} + +static inline uint8_t instant(void) +{ + m0110_send(M0110_INSTANT); + uint8_t data = m0110_recv(); + if (data != M0110_NULL) { + debug_hex(data); debug(" "); + } + return data; +} + +static inline void clock_lo() +{ + M0110_CLOCK_PORT &= ~(1<HOST: HOST reads bit on rising edge. + CLOCK ~~~~~~~~~~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~~~~~~~~~ + DATA ~~~~~~~~~~~~X777777X666666X555555X444444X333333X222222X111111X000000X~~~~~~~ + <--> 160us(clock low) + <---> 180us(clock high) + +3) HOST->KEYBOARD: HOST asserts bit on falling edge. + CLOCK ~~~~~~~~~~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~|__|~~~~~~~~~~~ + DATA ~~~~~~|_____X777777X666666X555555X444444X333333X222222X111111X000000X~~~~~~~ + <----> 840us(request to send by host) <---> 80us(hold DATA) + <--> 180us(clock low) + <---> 220us(clock high) + + +Protocol +-------- +COMMAND: + Inquiry 0x10 get key event with block + Instant 0x12 get key event + Model 0x14 get model number(M0110 responds with 0x09) + bit 7 1 if another device connected(used when keypad exists?) + bit4-6 next device model number + bit1-3 keyboard model number + bit 0 always 1 + Test 0x16 test(ACK:0x7D/NAK:0x77) + +KEY EVENT: + bit 7 key state(0:press 1:release) + bit 6-1 scan code(see below) + bit 0 always 1 + To get scan code use this: ((bits&(1<<7)) | ((bits&0x7F))>>1). + + Note: On the M0110A, Keypad keys and Arrow keys are preceded by 0x79. + Moreover, some Keypad keys(=, /, * and +) are preceded by 0x71 on press and 0xF1 on release. + +ARROW KEYS: + Arrow keys and Calc keys(+,*,/,= on keypad) share same byte sequence and preceding byte of + Calc keys(0x71 and 0xF1) means press and release event of SHIFT. This causes a very confusing situation, + it is difficult or impossible to tell Calc key from Arrow key plus SHIFT in some cases. + + Raw key events: + press release + ---------------- ---------------- + Left: 0x79, 0x0D 0x79, 0x8D + Right: 0x79, 0x05 0x79, 0x85 + Up: 0x79, 0x1B 0x79, 0x9B + Down: 0x79, 0x11 0x79, 0x91 + Pad+: 0x71, 0x79, 0x0D 0xF1, 0x79, 0x8D + Pad*: 0x71, 0x79, 0x05 0xF1, 0x79, 0x85 + Pad/: 0x71, 0x79, 0x1B 0xF1, 0x79, 0x9B + Pad=: 0x71, 0x79, 0x11 0xF1, 0x79, 0x91 + + +RAW CODE: + M0110A + ,---------------------------------------------------------. ,---------------. + | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *| + |---------------------------------------------------------| |---------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -| + |-----------------------------------------------------' | |---------------| + |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| + |---------------------------------------------------------| |---------------| + |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| | + |---------------------------------------------------------' |-----------|Ent| + |Optio|Mac | Space | \|Lft|Rgt|Dn | | 0| .| | + `---------------------------------------------------------' `---------------' + ,---------------------------------------------------------. ,---------------. + | 65| 25| 27| 29| 2B| 2F| 2D| 35| 39| 33| 3B| 37| 31| 67| |+0F|*11|*1B|*05| + |---------------------------------------------------------| |---------------| + | 61| 19| 1B| 1D| 1F| 23| 21| 41| 45| 3F| 47| 43| 3D| | |+33|+37|+39|+1D| + |-----------------------------------------------------' | |---------------| + | 73| 01| 03| 05| 07| 0B| 09| 4D| 51| 4B| 53| 4F| 49| |+2D|+2F|+31|*0D| + |---------------------------------------------------------| |---------------| + | 71| 0D| 0F| 11| 13| 17| 5B| 5D| 27| 5F| 59| 71|+1B| |+27|+29|+2B| | + |---------------------------------------------------------' |-----------|+19| + | 75| 6F| 63 | 55|+0D|+05|+11| | +25|+03| | + `---------------------------------------------------------' `---------------' + + 0x79, 0xDD / 0xF1, 0xUU + * 0x71, 0x79,DD / 0xF1, 0x79, 0xUU + + +MODEL NUMBER: + M0110: 0x09 00001001 : model number 4 (100) + M0110A: 0x0B 00001011 : model number 5 (101) + M0110 & M0120: ??? + + +Scan Code +--------- + m0110_recv_key() function returns following scan codes instead of M0110 raw codes. + Scan codes are 1 byte size and MSB(bit7) is set when key is released. + + scancode = ((raw&0x80) | ((raw&0x7F)>>1)) + + M0110 M0120 + ,---------------------------------------------------------. ,---------------. + | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| -|Lft|Rgt| + |---------------------------------------------------------| |---------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9|Up | + |---------------------------------------------------------| |---------------| + |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6|Dn | + |---------------------------------------------------------| |---------------| + |Shift | Z| X| C| V| B| N| M| ,| ,| /| | | 1| 2| 3| | + `---------------------------------------------------------' |-----------|Ent| + |Opt|Mac | Space |Enter|Opt| | 0| .| | + `------------------------------------------------' `---------------' + ,---------------------------------------------------------. ,---------------. + | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 4E| 46| 42| + |---------------------------------------------------------| |---------------| + | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A| | 59| 5B| 5C| 4D| + |---------------------------------------------------------| |---------------| + | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | 56| 57| 58| 48| + |---------------------------------------------------------| |---------------| + | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 38| | 53| 54| 55| | + `---------------------------------------------------------' |-----------| 4C| + | 3A| 37| 31 | 34| 3A| | 52| 41| | + `------------------------------------------------' `---------------' + + International keyboard(See page 22 of "Technical Info for 128K/512K") + ,---------------------------------------------------------. + | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| + |---------------------------------------------------------| + | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A| + |------------------------------------------------------ | + | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | + |---------------------------------------------------------| + | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 0A| 38| + `---------------------------------------------------------' + | 3A| 37| 34 | 31| 3A| + `------------------------------------------------' + + M0110A + ,---------------------------------------------------------. ,---------------. + | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *| + |---------------------------------------------------------| |---------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -| + |-----------------------------------------------------' | |---------------| + |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| + |---------------------------------------------------------| |---------------| + |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| | + |---------------------------------------------------------' |-----------|Ent| + |Optio|Mac | Space | \|Lft|Rgt|Dn | | 0| .| | + `---------------------------------------------------------' `---------------' + ,---------------------------------------------------------. ,---------------. + | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62| + |---------------------------------------------------------| |---------------| + | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| | | 59| 5B| 5C| 4E| + |-----------------------------------------------------' | |---------------| + | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | 56| 57| 58| 66| + |---------------------------------------------------------| |---------------| + | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 38| 4D| | 53| 54| 55| | + |---------------------------------------------------------' |-----------| 4C| + | 3A| 37| 31 | 2A| 46| 42| 48| | 52| 41| | + `---------------------------------------------------------' `---------------' + + +References +---------- +Technical Info for 128K/512K and Plus + ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20128K.pdf + ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20Plus.pdf +Protocol: + Page 20 of Tech Info for 128K/512K + http://www.mac.linux-m68k.org/devel/plushw.php +Connector: + Page 20 of Tech Info for 128K/512K + http://www.kbdbabel.org/conn/kbd_connector_macplus.png +Signaling: + http://www.kbdbabel.org/signaling/kbd_signaling_mac.png + http://typematic.blog.shinobi.jp/Entry/14/ +M0110 raw scan codes: + Page 22 of Tech Info for 128K/512K + Page 07 of Tech Info for Plus + http://m0115.web.fc2.com/m0110.jpg + http://m0115.web.fc2.com/m0110a.jpg +*/ diff --git a/protocol/m0110.h b/protocol/m0110.h new file mode 100644 index 000000000..2b95ed34d --- /dev/null +++ b/protocol/m0110.h @@ -0,0 +1,92 @@ +/* +Copyright 2011,2012 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef M0110_H +#define M0110_H + + +/* port settings for clock and data line */ +#if !(defined(M0110_CLOCK_PORT) && \ + defined(M0110_CLOCK_PIN) && \ + defined(M0110_CLOCK_DDR) && \ + defined(M0110_CLOCK_BIT)) +# error "M0110 clock port setting is required in config.h" +#endif + +#if !(defined(M0110_DATA_PORT) && \ + defined(M0110_DATA_PIN) && \ + defined(M0110_DATA_DDR) && \ + defined(M0110_DATA_BIT)) +# error "M0110 data port setting is required in config.h" +#endif + +/* Commands */ +#define M0110_INQUIRY 0x10 +#define M0110_INSTANT 0x14 +#define M0110_MODEL 0x16 +#define M0110_TEST 0x36 + +/* Response(raw byte from M0110) */ +#define M0110_NULL 0x7B +#define M0110_KEYPAD 0x79 +#define M0110_TEST_ACK 0x7D +#define M0110_TEST_NAK 0x77 +#define M0110_SHIFT 0x71 +#define M0110_ARROW_UP 0x1B +#define M0110_ARROW_DOWN 0x11 +#define M0110_ARROW_LEFT 0x0D +#define M0110_ARROW_RIGHT 0x05 + +/* This inidcates no response. */ +#define M0110_ERROR 0xFF + +/* scan code offset for keypad and arrow keys */ +#define M0110_KEYPAD_OFFSET 0x40 +#define M0110_CALC_OFFSET 0x60 + + +extern uint8_t m0110_error; + +/* host role */ +void m0110_init(void); +uint8_t m0110_send(uint8_t data); +uint8_t m0110_recv(void); +uint8_t m0110_recv_key(void); +uint8_t m0110_inquiry(void); +uint8_t m0110_instant(void); + +#endif diff --git a/protocol/mbed/HIDKeyboard.cpp b/protocol/mbed/HIDKeyboard.cpp new file mode 100644 index 000000000..947077cd2 --- /dev/null +++ b/protocol/mbed/HIDKeyboard.cpp @@ -0,0 +1,271 @@ +#include +#include "USBHID.h" +#include "USBHID_Types.h" +#include "USBDescriptor.h" +#include "HIDKeyboard.h" + +#define DEFAULT_CONFIGURATION (1) + + +HIDKeyboard::HIDKeyboard(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) +{ + USBDevice::connect(); +} + +bool HIDKeyboard::sendReport(report_keyboard_t report) { + USBDevice::write(EP1IN, report.raw, sizeof(report), MAX_PACKET_SIZE_EP1); + return true; +} + +uint8_t HIDKeyboard::leds() { + return led_state; +} + +bool HIDKeyboard::USBCallback_setConfiguration(uint8_t configuration) { + if (configuration != DEFAULT_CONFIGURATION) { + return false; + } + + // Configure endpoints > 0 + addEndpoint(EPINT_IN, MAX_PACKET_SIZE_EPINT); + //addEndpoint(EPINT_OUT, MAX_PACKET_SIZE_EPINT); + + // We activate the endpoint to be able to recceive data + //readStart(EPINT_OUT, MAX_PACKET_SIZE_EPINT); + return true; +} + + +uint8_t * HIDKeyboard::stringImanufacturerDesc() { + static uint8_t stringImanufacturerDescriptor[] = { + 0x18, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 't',0,'m',0,'k',0,'-',0,'k',0,'b',0,'d',0,'.',0,'c',0,'o',0,'m',0 /*bString iManufacturer*/ + }; + return stringImanufacturerDescriptor; +} + +uint8_t * HIDKeyboard::stringIproductDesc() { + static uint8_t stringIproductDescriptor[] = { + 0x0a, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + 'm',0,'b',0,'e',0,'d',0 /*bString iProduct*/ + }; + return stringIproductDescriptor; +} + +uint8_t * HIDKeyboard::stringIserialDesc() { + static uint8_t stringIserialDescriptor[] = { + 0x04, /*bLength*/ + STRING_DESCRIPTOR, /*bDescriptorType 0x03*/ + '0',0 /*bString iSerial*/ + }; + return stringIserialDescriptor; +} + +uint8_t * HIDKeyboard::reportDesc() { + static uint8_t reportDescriptor[] = { + USAGE_PAGE(1), 0x01, // Generic Desktop + USAGE(1), 0x06, // Keyboard + COLLECTION(1), 0x01, // Application + + USAGE_PAGE(1), 0x07, // Key Codes + USAGE_MINIMUM(1), 0xE0, + USAGE_MAXIMUM(1), 0xE7, + LOGICAL_MINIMUM(1), 0x00, + LOGICAL_MAXIMUM(1), 0x01, + REPORT_SIZE(1), 0x01, + REPORT_COUNT(1), 0x08, + INPUT(1), 0x02, // Data, Variable, Absolute + + REPORT_COUNT(1), 0x01, + REPORT_SIZE(1), 0x08, + INPUT(1), 0x01, // Constant + + REPORT_COUNT(1), 0x05, + REPORT_SIZE(1), 0x01, + USAGE_PAGE(1), 0x08, // LEDs + USAGE_MINIMUM(1), 0x01, + USAGE_MAXIMUM(1), 0x05, + OUTPUT(1), 0x02, // Data, Variable, Absolute + + REPORT_COUNT(1), 0x01, + REPORT_SIZE(1), 0x03, + OUTPUT(1), 0x01, // Constant + + + REPORT_COUNT(1), 0x06, + REPORT_SIZE(1), 0x08, + LOGICAL_MINIMUM(1), 0x00, + LOGICAL_MAXIMUM(1), 0xFF, + USAGE_PAGE(1), 0x07, // Key Codes + USAGE_MINIMUM(1), 0x00, + USAGE_MAXIMUM(1), 0xFF, + INPUT(1), 0x00, // Data, Array + END_COLLECTION(0), + }; + reportLength = sizeof(reportDescriptor); + return reportDescriptor; +} + +uint16_t HIDKeyboard::reportDescLength() { + reportDesc(); + return reportLength; +} + +#define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ + + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ + + (1 * HID_DESCRIPTOR_LENGTH) \ + + (1 * ENDPOINT_DESCRIPTOR_LENGTH)) +uint8_t * HIDKeyboard::configurationDesc() { + static uint8_t configurationDescriptor[] = { + CONFIGURATION_DESCRIPTOR_LENGTH,// bLength + CONFIGURATION_DESCRIPTOR, // bDescriptorType + LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) + MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) + 0x01, // bNumInterfaces + DEFAULT_CONFIGURATION, // bConfigurationValue + 0x00, // iConfiguration + C_RESERVED | C_REMOTE_WAKEUP, // bmAttributes + C_POWER(100), // bMaxPowerHello World from Mbed + + INTERFACE_DESCRIPTOR_LENGTH, // bLength + INTERFACE_DESCRIPTOR, // bDescriptorType + 0x00, // bInterfaceNumber + 0x00, // bAlternateSetting + 0x01, // bNumEndpoints + HID_CLASS, // bInterfaceClass + 1, // bInterfaceSubClass (boot) + 1, // bInterfaceProtocol (keyboard) + 0x00, // iInterface + + HID_DESCRIPTOR_LENGTH, // bLength + HID_DESCRIPTOR, // bDescriptorType + LSB(HID_VERSION_1_11), // bcdHID (LSB) + MSB(HID_VERSION_1_11), // bcdHID (MSB) + 0x00, // bCountryCode + 0x01, // bNumDescriptors + REPORT_DESCRIPTOR, // bDescriptorType + (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) + (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) + + ENDPOINT_DESCRIPTOR_LENGTH, // bLength + ENDPOINT_DESCRIPTOR, // bDescriptorType + PHY_TO_DESC(EP1IN), // bEndpointAddress + E_INTERRUPT, // bmAttributes + LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) + MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) + 1, // bInterval (milliseconds) + }; + return configurationDescriptor; +} + +#if 0 +uint8_t * HIDKeyboard::deviceDesc() { + static uint8_t deviceDescriptor[] = { + DEVICE_DESCRIPTOR_LENGTH, /* bLength */ + DEVICE_DESCRIPTOR, /* bDescriptorType */ + LSB(USB_VERSION_2_0), /* bcdUSB (LSB) */ + MSB(USB_VERSION_2_0), /* bcdUSB (MSB) */ + 0x00, /* bDeviceClass */ + 0x00, /* bDeviceSubClass */ + 0x00, /* bDeviceprotocol */ + MAX_PACKET_SIZE_EP0, /* bMaxPacketSize0 */ + (uint8_t)(LSB(0xfeed)), /* idVendor (LSB) */ + (uint8_t)(MSB(0xfeed)), /* idVendor (MSB) */ + (uint8_t)(LSB(0x1bed)), /* idProduct (LSB) */ + (uint8_t)(MSB(0x1bed)), /* idProduct (MSB) */ + (uint8_t)(LSB(0x0002)), /* bcdDevice (LSB) */ + (uint8_t)(MSB(0x0002)), /* bcdDevice (MSB) */ + 0, /* iManufacturer */ + 0, /* iProduct */ + 0, /* iSerialNumber */ + 0x01 /* bNumConfigurations */ + }; + return deviceDescriptor; +} +#endif + +bool HIDKeyboard::USBCallback_request() { + bool success = false; + CONTROL_TRANSFER * transfer = getTransferPtr(); + uint8_t *hidDescriptor; + + // Process additional standard requests + + if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE)) + { + switch (transfer->setup.bRequest) + { + case GET_DESCRIPTOR: + switch (DESCRIPTOR_TYPE(transfer->setup.wValue)) + { + case REPORT_DESCRIPTOR: + if ((reportDesc() != NULL) \ + && (reportDescLength() != 0)) + { + transfer->remaining = reportDescLength(); + transfer->ptr = reportDesc(); + transfer->direction = DEVICE_TO_HOST; + success = true; + } + break; + case HID_DESCRIPTOR: + // Find the HID descriptor, after the configuration descriptor + hidDescriptor = findDescriptor(HID_DESCRIPTOR); + if (hidDescriptor != NULL) + { + transfer->remaining = HID_DESCRIPTOR_LENGTH; + transfer->ptr = hidDescriptor; + transfer->direction = DEVICE_TO_HOST; + success = true; + } + break; + + default: + break; + } + break; + default: + break; + } + } + + // Process class-specific requests + if (transfer->setup.bmRequestType.Type == CLASS_TYPE) + { + switch (transfer->setup.bRequest) { + case SET_REPORT: + // LED indicator + // TODO: check Interface and Report length? + // if (transfer->setup.wIndex == INTERFACE_KEYBOAD) { } + // if (transfer->setup.wLength == 1) + + transfer->remaining = 1; + //transfer->ptr = ?? what ptr should be set when OUT(not used?) + transfer->direction = HOST_TO_DEVICE; + transfer->notify = true; /* notify with USBCallback_requestCompleted */ + success = true; + default: + break; + } + } + + return success; +} + +void HIDKeyboard::USBCallback_requestCompleted(uint8_t * buf, uint32_t length) +{ + if (length > 0) { + CONTROL_TRANSFER *transfer = getTransferPtr(); + if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { + switch (transfer->setup.bRequest) { + case SET_REPORT: + led_state = buf[0]; + break; + default: + break; + } + } + } +} diff --git a/protocol/mbed/HIDKeyboard.h b/protocol/mbed/HIDKeyboard.h new file mode 100644 index 000000000..c537e5ece --- /dev/null +++ b/protocol/mbed/HIDKeyboard.h @@ -0,0 +1,31 @@ +#ifndef HIDKEYBOARD_H + +#include "stdint.h" +#include "stdbool.h" +#include "USBHID.h" +#include "report.h" + + +class HIDKeyboard : public USBDevice { +public: + HIDKeyboard(uint16_t vendor_id = 0xFEED, uint16_t product_id = 0xabed, uint16_t product_release = 0x0001); + + bool sendReport(report_keyboard_t report); + uint8_t leds(void); +protected: + uint16_t reportLength; + virtual bool USBCallback_setConfiguration(uint8_t configuration); + virtual uint8_t * stringImanufacturerDesc(); + virtual uint8_t * stringIproductDesc(); + virtual uint8_t * stringIserialDesc(); + virtual uint16_t reportDescLength(); + virtual uint8_t * reportDesc(); + virtual uint8_t * configurationDesc(); + //virtual uint8_t * deviceDesc(); + virtual bool USBCallback_request(); + virtual void USBCallback_requestCompleted(uint8_t * buf, uint32_t length); +private: + uint8_t led_state; +}; + +#endif diff --git a/protocol/mbed/mbed_driver.cpp b/protocol/mbed/mbed_driver.cpp new file mode 100644 index 000000000..6c7b16e23 --- /dev/null +++ b/protocol/mbed/mbed_driver.cpp @@ -0,0 +1,41 @@ +#include "HIDKeyboard.h" +#include "host.h" +#include "host_driver.h" +#include "mbed_driver.h" + +HIDKeyboard keyboard; + + +/* Host driver */ +static uint8_t keyboard_leds(void); +static void send_keyboard(report_keyboard_t *report); +static void send_mouse(report_mouse_t *report); +static void send_system(uint16_t data); +static void send_consumer(uint16_t data); + +host_driver_t mbed_driver = { + keyboard_leds, + send_keyboard, + send_mouse, + send_system, + send_consumer +}; + + +static uint8_t keyboard_leds(void) +{ + return keyboard.leds(); +} +static void send_keyboard(report_keyboard_t *report) +{ + keyboard.sendReport(*report); +} +static void send_mouse(report_mouse_t *report) +{ +} +static void send_system(uint16_t data) +{ +} +static void send_consumer(uint16_t data) +{ +} diff --git a/protocol/mbed/mbed_driver.h b/protocol/mbed/mbed_driver.h new file mode 100644 index 000000000..dd1153b43 --- /dev/null +++ b/protocol/mbed/mbed_driver.h @@ -0,0 +1,3 @@ +#include "host_driver.h" + +extern host_driver_t mbed_driver; diff --git a/protocol/news.c b/protocol/news.c new file mode 100644 index 000000000..00755a5e2 --- /dev/null +++ b/protocol/news.c @@ -0,0 +1,168 @@ +/* +Copyright 2012 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include "news.h" + + +void news_init(void) +{ + NEWS_KBD_RX_INIT(); +} + +// RX ring buffer +#define RBUF_SIZE 8 +static uint8_t rbuf[RBUF_SIZE]; +static uint8_t rbuf_head = 0; +static uint8_t rbuf_tail = 0; + +uint8_t news_recv(void) +{ + uint8_t data = 0; + if (rbuf_head == rbuf_tail) { + return 0; + } + + data = rbuf[rbuf_tail]; + rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE; + return data; +} + +// USART RX complete interrupt +ISR(NEWS_KBD_RX_VECT) +{ + uint8_t next = (rbuf_head + 1) % RBUF_SIZE; + if (next != rbuf_tail) { + rbuf[rbuf_head] = NEWS_KBD_RX_DATA; + rbuf_head = next; + } +} + + +/* +SONY NEWS Keyboard Protocol +=========================== + +Resources +--------- + Mouse protocol of NWA-5461(Japanese) + http://groups.google.com/group/fj.sys.news/browse_thread/thread/a01b3e3ac6ae5b2d + + SONY NEWS Info(Japanese) + http://katsu.watanabe.name/doc/sonynews/ + + +Pinouts +------- + EIA 232 male connector from NWP-5461 + ------------- + \ 1 2 3 4 5 / + \ 6 7 8 9 / + --------- + 1 VCC + 2 BZ(Speaker) + 3 Keyboard Data(from keyboard MCU TxD) + 4 NC + 5 GND + 6 Unknown Input(to keyboard MCU RxD via schmitt trigger) + 7 Mouse Data(from Mouse Ext connector) + 8 Unknown Input(to Keyboard MCU Input via diode and buffer) + 9 FG + NOTE: Two LED on keyboard are controlled by pin 6,8? + + EIA 232 male connector from NWP-411A + ------------- + \ 1 2 3 4 5 / + \ 6 7 8 9 / + --------- + 1 VCC + 2 BZ(Speaker) + 3 Keyboard Data(from keyboard MCU TxD) + 4 NC + 5 GND + 6 NC + 7 Mouse Data(from Mouse Ext connector) + 8 NC + 9 FG + NOTE: These are just from my guess and not confirmed. + + +Signaling +--------- + ~~~~~~~~~~ ____XOO0X111X222X333X444X555X666X777~~~~ ~~~~~~~ + Idle Start LSB MSB Stop Idle + + Idle: High + Start bit: Low + Stop bit: High + Bit order: LSB first + + Baud rate: 9600 + Interface: TTL level(5V) UART + + NOTE: This is observed on NWP-5461 with its DIP switch all OFF. + + +Format +------ + MSB LSB + 7 6 5 4 3 2 1 0 bit + | | | | | | | | + | +-+-+-+-+-+-+-- scan code(00-7F) + +---------------- break flag: sets when released + + +Scan Codes +---------- + SONY NEWS NWP-5461 + ,---. ,------------------------, ,------------------------. ,---------. + | 7A| | 01 | 02 | 03 | 04 | 05 | | 06 | 07 | 08 | 09 | 0A | | 68 | 69 | ,-----------. + `---' `------------------------' `------------------------' `---------' | 64| 65| 52| + ,-------------------------------------------------------------. ,---. ,---------------| + | 0B| 0C| 0D| 0E| 0F| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19 | | 6A| | 4B| 4C| 4D| 4E| + |-------------------------------------------------------------| |---| |---------------| + | 1A | 1B| 1C| 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| | | 6B| | 4F| 50| 51| 56| + |---------------------------------------------------------' | |---| |---------------| + | 28 | 29| 2A| 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35 | | 6C| | 53| 54| 55| | + |-------------------------------------------------------------| |---| |-----------| 5A| + | 36 | 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 42 | | 6D| | 57| 59| 58| | + |-------------------------------------------------------------| |---| |---------------| + | 43 | 44 | 45 | 46 | 47 | 48| 49| 4A | | 6E| | 66| 5B| 5C| 5D| + `-------------------------------------------------------------' `---' `---------------' +*/ diff --git a/protocol/news.h b/protocol/news.h new file mode 100644 index 000000000..35e09c4d2 --- /dev/null +++ b/protocol/news.h @@ -0,0 +1,51 @@ +/* +Copyright 2012 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef NEWS_H +#define NEWS_H +/* + * Primitive PS/2 Library for AVR + */ + + +/* host role */ +void news_init(void); +uint8_t news_recv(void); + +/* device role */ + +#endif diff --git a/protocol/next_kbd.c b/protocol/next_kbd.c new file mode 100644 index 000000000..a5a07a7a8 --- /dev/null +++ b/protocol/next_kbd.c @@ -0,0 +1,204 @@ +/* + +NeXT non-ADB Keyboard Protocol + +Copyright 2013, Benjamin Gould (bgould@github.com) + +Based on: +TMK firmware code Copyright 2011,2012 Jun WAKO +Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license + +Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB +Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html +Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/ + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include +#include +#include "next_kbd.h" +#include "debug.h" + +static inline void out_lo(void); +static inline void out_hi(void); +static inline void query(void); +static inline void reset(void); +static inline uint32_t response(void); + +#define out_hi_delay(intervals) do { out_hi(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0); +#define out_lo_delay(intervals) do { out_lo(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0); +#define query_delay(intervals) do { query(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0); +#define reset_delay(intervals) do { reset(); _delay_us(NEXT_KBD_TIMING * intervals); } while (0); + +void next_kbd_init(void) +{ + out_hi(); + NEXT_KBD_IN_DDR &= ~(1< +Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license + +Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB +Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html +Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/ + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include + +#ifndef NEXT_KBD_H +#define NEXT_KBD_H + +#define NEXT_KBD_KMBUS_IDLE 0x300600 +#define NEXT_KBD_TIMING 50 + +extern uint8_t next_kbd_error; + +/* host role */ +void next_kbd_init(void); +void next_kbd_set_leds(bool left, bool right); +uint32_t next_kbd_recv(void); + +#endif diff --git a/protocol/pjrc.mk b/protocol/pjrc.mk new file mode 100644 index 000000000..36585de7d --- /dev/null +++ b/protocol/pjrc.mk @@ -0,0 +1,26 @@ +PJRC_DIR = protocol/pjrc + +SRC += $(PJRC_DIR)/main.c \ + $(PJRC_DIR)/pjrc.c \ + $(PJRC_DIR)/usb_keyboard.c \ + $(PJRC_DIR)/usb_debug.c \ + $(PJRC_DIR)/usb.c + +# Option modules +ifdef MOUSEKEY_ENABLE + SRC += $(PJRC_DIR)/usb_mouse.c +endif + +ifdef PS2_MOUSE_ENABLE + SRC += $(PJRC_DIR)/usb_mouse.c +endif + +ifdef EXTRAKEY_ENABLE + SRC += $(PJRC_DIR)/usb_extra.c +endif + +# Search Path +VPATH += $(TMK_DIR)/$(PJRC_DIR) + +# This indicates using LUFA stack +OPT_DEFS += -DPROTOCOL_PJRC diff --git a/protocol/pjrc/MEMO.txt b/protocol/pjrc/MEMO.txt new file mode 100644 index 000000000..b0f059831 --- /dev/null +++ b/protocol/pjrc/MEMO.txt @@ -0,0 +1,25 @@ +Endpoint configuration +---------------------- +0 Control endpoint +1 keyboard +2 mouse +3 debug +4 extra key(consumer/system) +5 nkro keyboard(supported only on ATmega32U4/16U4 and AT90USB64/128) + + +ATmega32U4/16U4, AT90USB64/128 +• Endpoint 0:programmable size FIFO up to 64 bytes, default control endpoint +• Endpoints 1 programmable size FIFO up to 256 bytes in ping-pong mode. +• Endpoints 2 to 6: programmable size FIFO up to 64 bytes in ping-pong mode. + +AT90USB82/162, ATmega8U2/16U2/32U2 +• Endpoint 0:programmable size FIFO up to 64 bytes, default control endpoint +• Endpoints 1 and 2: programmable size FIFO up to 64 bytes. +• Endpoints 3 and 4: programmable size FIFO up to 64 bytes with ping-pong mode. + +ping-pong mode means double buffer feature. + + +NOTE: ATmega8U2/16U2/32U2 is not supported with PJRC stack at this time. +TODO: Macro definition for ATmega8U2/16U2/32U2 in usb.h diff --git a/protocol/pjrc/main.c b/protocol/pjrc/main.c new file mode 100644 index 000000000..e7bdcc059 --- /dev/null +++ b/protocol/pjrc/main.c @@ -0,0 +1,72 @@ +/* Keyboard example with debug channel, for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_keyboard.html + * Copyright (c) 2008 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include "keyboard.h" +#include "usb.h" +#include "matrix.h" +#include "print.h" +#include "debug.h" +#include "sendchar.h" +#include "util.h" +#include "suspend.h" +#include "host.h" +#include "pjrc.h" + + +#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) + + +int main(void) +{ + // set for 16 MHz clock + CPU_PRESCALE(0); + + // Initialize the USB, and then wait for the host to set configuration. + // If the Teensy is powered without a PC connected to the USB port, + // this will wait forever. + usb_init(); + while (!usb_configured()) /* wait */ ; + + print_set_sendchar(sendchar); + + keyboard_init(); + host_set_driver(pjrc_driver()); +#ifdef SLEEP_LED_ENABLE + sleep_led_init(); +#endif + while (1) { + while (suspend) { + suspend_power_down(); + if (remote_wakeup && suspend_wakeup_condition()) { + usb_remote_wakeup(); + } + } + + keyboard_task(); + } +} diff --git a/protocol/pjrc/pjrc.c b/protocol/pjrc/pjrc.c new file mode 100644 index 000000000..0562a12ff --- /dev/null +++ b/protocol/pjrc/pjrc.c @@ -0,0 +1,76 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include "usb_keyboard.h" +#include "usb_mouse.h" +#include "usb_extra.h" +#include "host_driver.h" +#include "pjrc.h" + + +/*------------------------------------------------------------------* + * Host driver + *------------------------------------------------------------------*/ +static uint8_t keyboard_leds(void); +static void send_keyboard(report_keyboard_t *report); +static void send_mouse(report_mouse_t *report); +static void send_system(uint16_t data); +static void send_consumer(uint16_t data); + +static host_driver_t driver = { + keyboard_leds, + send_keyboard, + send_mouse, + send_system, + send_consumer +}; + +host_driver_t *pjrc_driver(void) +{ + return &driver; +} + +static uint8_t keyboard_leds(void) { + return usb_keyboard_leds; +} + +static void send_keyboard(report_keyboard_t *report) +{ + usb_keyboard_send_report(report); +} + +static void send_mouse(report_mouse_t *report) +{ +#ifdef MOUSE_ENABLE + usb_mouse_send(report->x, report->y, report->v, report->h, report->buttons); +#endif +} + +static void send_system(uint16_t data) +{ +#ifdef EXTRAKEY_ENABLE + usb_extra_system_send(data); +#endif +} + +static void send_consumer(uint16_t data) +{ +#ifdef EXTRAKEY_ENABLE + usb_extra_consumer_send(data); +#endif +} diff --git a/protocol/pjrc/pjrc.h b/protocol/pjrc/pjrc.h new file mode 100644 index 000000000..06e79626f --- /dev/null +++ b/protocol/pjrc/pjrc.h @@ -0,0 +1,26 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef PJRC_H +#define PJRC_H + +#include "host_driver.h" + + +host_driver_t *pjrc_driver(void); + +#endif diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c new file mode 100644 index 000000000..1e6ba8719 --- /dev/null +++ b/protocol/pjrc/usb.c @@ -0,0 +1,1002 @@ +/* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_keyboard.html + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include "usb.h" +#include "usb_keyboard.h" +#include "usb_mouse.h" +#include "usb_debug.h" +#include "usb_extra.h" +#include "led.h" +#include "print.h" +#include "util.h" +#ifdef SLEEP_LED_ENABLE +#include "sleep_led.h" +#endif +#include "suspend.h" +#include "action.h" +#include "action_util.h" + + +/************************************************************************** + * + * Configurable Options + * + **************************************************************************/ + +// You can change these to give your code its own name. +#ifndef MANUFACTURER +# define STR_MANUFACTURER L"t.m.k." +#else +# define STR_MANUFACTURER LSTR(MANUFACTURER) +#endif +#ifndef PRODUCT +# define STR_PRODUCT L"t.m.k. keyboard" +#else +# define STR_PRODUCT LSTR(PRODUCT) +#endif + + +// Mac OS-X and Linux automatically load the correct drivers. On +// Windows, even though the driver is supplied by Microsoft, an +// INF file is needed to load the driver. These numbers need to +// match the INF file. +#ifndef VENDOR_ID +# define VENDOR_ID 0xFEED +#endif + +#ifndef PRODUCT_ID +# define PRODUCT_ID 0xBABE +#endif + +#ifndef DEVICE_VER +# define DEVICE_VER 0x0100 +#endif + + +// USB devices are supposed to implment a halt feature, which is +// rarely (if ever) used. If you comment this line out, the halt +// code will be removed, saving 102 bytes of space (gcc 4.3.0). +// This is not strictly USB compliant, but works with all major +// operating systems. +#define SUPPORT_ENDPOINT_HALT + + + +/************************************************************************** + * + * Endpoint Buffer Configuration + * + **************************************************************************/ + +#define ENDPOINT0_SIZE 32 + +bool remote_wakeup = false; +bool suspend = false; + +// 0:control endpoint is enabled automatically by controller. +static const uint8_t PROGMEM endpoint_config_table[] = { + // enable, UECFG0X(type, direction), UECFG1X(size, bank, allocation) + 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD_SIZE) | KBD_BUFFER, // 1 +#ifdef MOUSE_ENABLE + 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(MOUSE_SIZE) | MOUSE_BUFFER, // 2 +#else + 0, // 2 +#endif +#ifdef CONSOLE_ENABLE + 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(DEBUG_TX_SIZE) | DEBUG_TX_BUFFER, // 3 +#else + 0, +#endif +#ifdef EXTRAKEY_ENABLE + 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(EXTRA_SIZE) | EXTRA_BUFFER, // 4 +#else + 0, // 4 +#endif +#ifdef NKRO_ENABLE + 1, EP_TYPE_INTERRUPT_IN, EP_SIZE(KBD2_SIZE) | KBD2_BUFFER, // 5 +#else + 0, // 5 +#endif + 0, // 6 +}; + + +/************************************************************************** + * + * Descriptor Data + * + **************************************************************************/ + +// Descriptors are the data that your computer reads when it auto-detects +// this USB device (called "enumeration" in USB lingo). The most commonly +// changed items are editable at the top of this file. Changing things +// in here should only be done by those who've read chapter 9 of the USB +// spec and relevant portions of any USB class specifications! + + +static const uint8_t PROGMEM device_descriptor[] = { + 18, // bLength + 1, // bDescriptorType + 0x00, 0x02, // bcdUSB + 0, // bDeviceClass + 0, // bDeviceSubClass + 0, // bDeviceProtocol + ENDPOINT0_SIZE, // bMaxPacketSize0 + LSB(VENDOR_ID), MSB(VENDOR_ID), // idVendor + LSB(PRODUCT_ID), MSB(PRODUCT_ID), // idProduct + LSB(DEVICE_VER), MSB(DEVICE_VER), // bcdDevice + 1, // iManufacturer + 2, // iProduct + 0, // iSerialNumber + 1 // bNumConfigurations +}; + +// Keyboard Protocol 1, HID 1.11 spec, Appendix B, page 59-60 +static const uint8_t PROGMEM keyboard_hid_report_desc[] = { + 0x05, 0x01, // Usage Page (Generic Desktop), + 0x09, 0x06, // Usage (Keyboard), + 0xA1, 0x01, // Collection (Application), + 0x75, 0x01, // Report Size (1), + 0x95, 0x08, // Report Count (8), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0xE0, // Usage Minimum (224), + 0x29, 0xE7, // Usage Maximum (231), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0x01, // Logical Maximum (1), + 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte + 0x95, 0x01, // Report Count (1), + 0x75, 0x08, // Report Size (8), + 0x81, 0x03, // Input (Constant), ;Reserved byte + 0x95, 0x05, // Report Count (5), + 0x75, 0x01, // Report Size (1), + 0x05, 0x08, // Usage Page (LEDs), + 0x19, 0x01, // Usage Minimum (1), + 0x29, 0x05, // Usage Maximum (5), + 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report + 0x95, 0x01, // Report Count (1), + 0x75, 0x03, // Report Size (3), + 0x91, 0x03, // Output (Constant), ;LED report padding + 0x95, KBD_REPORT_KEYS, // Report Count (), + 0x75, 0x08, // Report Size (8), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0xFF, // Logical Maximum(255), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0x00, // Usage Minimum (0), + 0x29, 0xFF, // Usage Maximum (255), + 0x81, 0x00, // Input (Data, Array), + 0xc0 // End Collection +}; +#ifdef NKRO_ENABLE +static const uint8_t PROGMEM keyboard2_hid_report_desc[] = { + 0x05, 0x01, // Usage Page (Generic Desktop), + 0x09, 0x06, // Usage (Keyboard), + 0xA1, 0x01, // Collection (Application), + // bitmap of modifiers + 0x75, 0x01, // Report Size (1), + 0x95, 0x08, // Report Count (8), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0xE0, // Usage Minimum (224), + 0x29, 0xE7, // Usage Maximum (231), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0x01, // Logical Maximum (1), + 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte + // LED output report + 0x95, 0x05, // Report Count (5), + 0x75, 0x01, // Report Size (1), + 0x05, 0x08, // Usage Page (LEDs), + 0x19, 0x01, // Usage Minimum (1), + 0x29, 0x05, // Usage Maximum (5), + 0x91, 0x02, // Output (Data, Variable, Absolute), + 0x95, 0x01, // Report Count (1), + 0x75, 0x03, // Report Size (3), + 0x91, 0x03, // Output (Constant), + // bitmap of keys + 0x95, KBD2_REPORT_KEYS*8, // Report Count (), + 0x75, 0x01, // Report Size (1), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0x01, // Logical Maximum(1), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0x00, // Usage Minimum (0), + 0x29, KBD2_REPORT_KEYS*8-1, // Usage Maximum (), + 0x81, 0x02, // Input (Data, Variable, Absolute), + 0xc0 // End Collection +}; +#endif + +#ifdef MOUSE_ENABLE +// Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension +// http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521 +// http://www.keil.com/forum/15671/ +// http://www.microsoft.com/whdc/device/input/wheel.mspx +static const uint8_t PROGMEM mouse_hid_report_desc[] = { + /* mouse */ + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x02, // USAGE (Mouse) + 0xa1, 0x01, // COLLECTION (Application) + //0x85, REPORT_ID_MOUSE, // REPORT_ID (1) + 0x09, 0x01, // USAGE (Pointer) + 0xa1, 0x00, // COLLECTION (Physical) + // ---------------------------- Buttons + 0x05, 0x09, // USAGE_PAGE (Button) + 0x19, 0x01, // USAGE_MINIMUM (Button 1) + 0x29, 0x05, // USAGE_MAXIMUM (Button 5) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x05, // REPORT_COUNT (5) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x75, 0x03, // REPORT_SIZE (3) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x03, // INPUT (Cnst,Var,Abs) + // ---------------------------- X,Y position + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x30, // USAGE (X) + 0x09, 0x31, // USAGE (Y) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x02, // REPORT_COUNT (2) + 0x81, 0x06, // INPUT (Data,Var,Rel) + // ---------------------------- Vertical wheel + 0x09, 0x38, // USAGE (Wheel) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical + 0x45, 0x00, // PHYSICAL_MAXIMUM (0) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x06, // INPUT (Data,Var,Rel) + // ---------------------------- Horizontal wheel + 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) + 0x0a, 0x38, 0x02, // USAGE (AC Pan) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x06, // INPUT (Data,Var,Rel) + 0xc0, // END_COLLECTION + 0xc0, // END_COLLECTION +}; +#endif + +static const uint8_t PROGMEM debug_hid_report_desc[] = { + 0x06, 0x31, 0xFF, // Usage Page 0xFF31 (vendor defined) + 0x09, 0x74, // Usage 0x74 + 0xA1, 0x53, // Collection 0x53 + 0x75, 0x08, // report size = 8 bits + 0x15, 0x00, // logical minimum = 0 + 0x26, 0xFF, 0x00, // logical maximum = 255 + 0x95, DEBUG_TX_SIZE, // report count + 0x09, 0x75, // usage + 0x81, 0x02, // Input (array) + 0xC0 // end collection +}; + +#ifdef EXTRAKEY_ENABLE +// audio controls & system controls +// http://www.microsoft.com/whdc/archive/w2kbd.mspx +static const uint8_t PROGMEM extra_hid_report_desc[] = { + /* system control */ + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x80, // USAGE (System Control) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) + 0x15, 0x01, // LOGICAL_MINIMUM (0x1) + 0x25, 0xb7, // LOGICAL_MAXIMUM (0xb7) + 0x19, 0x01, // USAGE_MINIMUM (0x1) + 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) + 0x75, 0x10, // REPORT_SIZE (16) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x00, // INPUT (Data,Array,Abs) + 0xc0, // END_COLLECTION + /* consumer */ + 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) + 0x09, 0x01, // USAGE (Consumer Control) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, REPORT_ID_CONSUMER, // REPORT_ID (3) + 0x15, 0x01, // LOGICAL_MINIMUM (0x1) + 0x26, 0x9c, 0x02, // LOGICAL_MAXIMUM (0x29c) + 0x19, 0x01, // USAGE_MINIMUM (0x1) + 0x2a, 0x9c, 0x02, // USAGE_MAXIMUM (0x29c) + 0x75, 0x10, // REPORT_SIZE (16) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x00, // INPUT (Data,Array,Abs) + 0xc0, // END_COLLECTION +}; +#endif + +#define KBD_HID_DESC_NUM 0 +#define KBD_HID_DESC_OFFSET (9+(9+9+7)*KBD_HID_DESC_NUM+9) + +#ifdef MOUSE_ENABLE +# define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 1) +# define MOUSE_HID_DESC_OFFSET (9+(9+9+7)*MOUSE_HID_DESC_NUM+9) +#else +# define MOUSE_HID_DESC_NUM (KBD_HID_DESC_NUM + 0) +#endif + +#ifdef CONSOLE_ENABLE +#define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 1) +#define DEBUG_HID_DESC_OFFSET (9+(9+9+7)*DEBUG_HID_DESC_NUM+9) +#else +# define DEBUG_HID_DESC_NUM (MOUSE_HID_DESC_NUM + 0) +#endif + +#ifdef EXTRAKEY_ENABLE +# define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 1) +# define EXTRA_HID_DESC_OFFSET (9+(9+9+7)*EXTRA_HID_DESC_NUM+9) +#else +# define EXTRA_HID_DESC_NUM (DEBUG_HID_DESC_NUM + 0) +#endif + +#ifdef NKRO_ENABLE +# define KBD2_HID_DESC_NUM (EXTRA_HID_DESC_NUM + 1) +# define KBD2_HID_DESC_OFFSET (9+(9+9+7)*EXTRA_HID_DESC_NUM+9) +#else +# define KBD2_HID_DESC_NUM (EXTRA_HID_DESC_NUM + 0) +#endif + +#define NUM_INTERFACES (KBD2_HID_DESC_NUM + 1) +#define CONFIG1_DESC_SIZE (9+(9+9+7)*NUM_INTERFACES) +static const uint8_t PROGMEM config1_descriptor[CONFIG1_DESC_SIZE] = { + // configuration descriptor, USB spec 9.6.3, page 264-266, Table 9-10 + 9, // bLength; + 2, // bDescriptorType; + LSB(CONFIG1_DESC_SIZE), // wTotalLength + MSB(CONFIG1_DESC_SIZE), + NUM_INTERFACES, // bNumInterfaces + 1, // bConfigurationValue + 0, // iConfiguration + 0xA0, // bmAttributes + 50, // bMaxPower + + // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 + 9, // bLength + 4, // bDescriptorType + KBD_INTERFACE, // bInterfaceNumber + 0, // bAlternateSetting + 1, // bNumEndpoints + 0x03, // bInterfaceClass (0x03 = HID) + 0x01, // bInterfaceSubClass (0x01 = Boot) + 0x01, // bInterfaceProtocol (0x01 = Keyboard) + 0, // iInterface + // HID descriptor, HID 1.11 spec, section 6.2.1 + 9, // bLength + 0x21, // bDescriptorType + 0x11, 0x01, // bcdHID + 0, // bCountryCode + 1, // bNumDescriptors + 0x22, // bDescriptorType + sizeof(keyboard_hid_report_desc), // wDescriptorLength + 0, + // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 + 7, // bLength + 5, // bDescriptorType + KBD_ENDPOINT | 0x80, // bEndpointAddress + 0x03, // bmAttributes (0x03=intr) + KBD_SIZE, 0, // wMaxPacketSize + 10, // bInterval + +#ifdef MOUSE_ENABLE + // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 + 9, // bLength + 4, // bDescriptorType + MOUSE_INTERFACE, // bInterfaceNumber + 0, // bAlternateSetting + 1, // bNumEndpoints + 0x03, // bInterfaceClass (0x03 = HID) + // ThinkPad T23 BIOS doesn't work with boot mouse. + 0x00, // bInterfaceSubClass (0x01 = Boot) + 0x00, // bInterfaceProtocol (0x02 = Mouse) +/* + 0x01, // bInterfaceSubClass (0x01 = Boot) + 0x02, // bInterfaceProtocol (0x02 = Mouse) +*/ + 0, // iInterface + // HID descriptor, HID 1.11 spec, section 6.2.1 + 9, // bLength + 0x21, // bDescriptorType + 0x11, 0x01, // bcdHID + 0, // bCountryCode + 1, // bNumDescriptors + 0x22, // bDescriptorType + sizeof(mouse_hid_report_desc), // wDescriptorLength + 0, + // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 + 7, // bLength + 5, // bDescriptorType + MOUSE_ENDPOINT | 0x80, // bEndpointAddress + 0x03, // bmAttributes (0x03=intr) + MOUSE_SIZE, 0, // wMaxPacketSize + 1, // bInterval +#endif + +#ifdef CONSOLE_ENABLE + // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 + 9, // bLength + 4, // bDescriptorType + DEBUG_INTERFACE, // bInterfaceNumber + 0, // bAlternateSetting + 1, // bNumEndpoints + 0x03, // bInterfaceClass (0x03 = HID) + 0x00, // bInterfaceSubClass + 0x00, // bInterfaceProtocol + 0, // iInterface + // HID descriptor, HID 1.11 spec, section 6.2.1 + 9, // bLength + 0x21, // bDescriptorType + 0x11, 0x01, // bcdHID + 0, // bCountryCode + 1, // bNumDescriptors + 0x22, // bDescriptorType + sizeof(debug_hid_report_desc), // wDescriptorLength + 0, + // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 + 7, // bLength + 5, // bDescriptorType + DEBUG_TX_ENDPOINT | 0x80, // bEndpointAddress + 0x03, // bmAttributes (0x03=intr) + DEBUG_TX_SIZE, 0, // wMaxPacketSize + 1, // bInterval +#endif + +#ifdef EXTRAKEY_ENABLE + // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 + 9, // bLength + 4, // bDescriptorType + EXTRA_INTERFACE, // bInterfaceNumber + 0, // bAlternateSetting + 1, // bNumEndpoints + 0x03, // bInterfaceClass (0x03 = HID) + 0x00, // bInterfaceSubClass + 0x00, // bInterfaceProtocol + 0, // iInterface + // HID descriptor, HID 1.11 spec, section 6.2.1 + 9, // bLength + 0x21, // bDescriptorType + 0x11, 0x01, // bcdHID + 0, // bCountryCode + 1, // bNumDescriptors + 0x22, // bDescriptorType + sizeof(extra_hid_report_desc), // wDescriptorLength + 0, + // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 + 7, // bLength + 5, // bDescriptorType + EXTRA_ENDPOINT | 0x80, // bEndpointAddress + 0x03, // bmAttributes (0x03=intr) + EXTRA_SIZE, 0, // wMaxPacketSize + 10, // bInterval +#endif + +#ifdef NKRO_ENABLE + // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 + 9, // bLength + 4, // bDescriptorType + KBD2_INTERFACE, // bInterfaceNumber + 0, // bAlternateSetting + 1, // bNumEndpoints + 0x03, // bInterfaceClass (0x03 = HID) + 0x00, // bInterfaceSubClass (0x01 = Boot) + 0x00, // bInterfaceProtocol (0x01 = Keyboard) + 0, // iInterface + // HID descriptor, HID 1.11 spec, section 6.2.1 + 9, // bLength + 0x21, // bDescriptorType + 0x11, 0x01, // bcdHID + 0, // bCountryCode + 1, // bNumDescriptors + 0x22, // bDescriptorType + sizeof(keyboard2_hid_report_desc), // wDescriptorLength + 0, + // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 + 7, // bLength + 5, // bDescriptorType + KBD2_ENDPOINT | 0x80, // bEndpointAddress + 0x03, // bmAttributes (0x03=intr) + KBD2_SIZE, 0, // wMaxPacketSize + 1, // bInterval +#endif +}; + +// If you're desperate for a little extra code memory, these strings +// can be completely removed if iManufacturer, iProduct, iSerialNumber +// in the device desciptor are changed to zeros. +struct usb_string_descriptor_struct { + uint8_t bLength; + uint8_t bDescriptorType; + int16_t wString[]; +}; +static const struct usb_string_descriptor_struct PROGMEM string0 = { + 4, + 3, + {0x0409} +}; +static const struct usb_string_descriptor_struct PROGMEM string1 = { + sizeof(STR_MANUFACTURER), + 3, + STR_MANUFACTURER +}; +static const struct usb_string_descriptor_struct PROGMEM string2 = { + sizeof(STR_PRODUCT), + 3, + STR_PRODUCT +}; + +// This table defines which descriptor data is sent for each specific +// request from the host (in wValue and wIndex). +static const struct descriptor_list_struct { + uint16_t wValue; // descriptor type + uint16_t wIndex; + const uint8_t *addr; + uint8_t length; +} PROGMEM descriptor_list[] = { + // DEVICE descriptor + {0x0100, 0x0000, device_descriptor, sizeof(device_descriptor)}, + // CONFIGURATION descriptor + {0x0200, 0x0000, config1_descriptor, sizeof(config1_descriptor)}, + // HID/REPORT descriptors + {0x2100, KBD_INTERFACE, config1_descriptor+KBD_HID_DESC_OFFSET, 9}, + {0x2200, KBD_INTERFACE, keyboard_hid_report_desc, sizeof(keyboard_hid_report_desc)}, +#ifdef MOUSE_ENABLE + {0x2100, MOUSE_INTERFACE, config1_descriptor+MOUSE_HID_DESC_OFFSET, 9}, + {0x2200, MOUSE_INTERFACE, mouse_hid_report_desc, sizeof(mouse_hid_report_desc)}, +#endif +#ifdef CONSOLE_ENABLE + {0x2100, DEBUG_INTERFACE, config1_descriptor+DEBUG_HID_DESC_OFFSET, 9}, + {0x2200, DEBUG_INTERFACE, debug_hid_report_desc, sizeof(debug_hid_report_desc)}, +#endif +#ifdef EXTRAKEY_ENABLE + {0x2100, EXTRA_INTERFACE, config1_descriptor+EXTRA_HID_DESC_OFFSET, 9}, + {0x2200, EXTRA_INTERFACE, extra_hid_report_desc, sizeof(extra_hid_report_desc)}, +#endif +#ifdef NKRO_ENABLE + {0x2100, KBD2_INTERFACE, config1_descriptor+KBD2_HID_DESC_OFFSET, 9}, + {0x2200, KBD2_INTERFACE, keyboard2_hid_report_desc, sizeof(keyboard2_hid_report_desc)}, +#endif + // STRING descriptors + {0x0300, 0x0000, (const uint8_t *)&string0, 4}, + {0x0301, 0x0409, (const uint8_t *)&string1, sizeof(STR_MANUFACTURER)}, + {0x0302, 0x0409, (const uint8_t *)&string2, sizeof(STR_PRODUCT)} +}; +#define NUM_DESC_LIST (sizeof(descriptor_list)/sizeof(struct descriptor_list_struct)) + + +/************************************************************************** + * + * Variables - these are the only non-stack RAM usage + * + **************************************************************************/ + +// zero when we are not configured, non-zero when enumerated +static volatile uint8_t usb_configuration=0; + + +/************************************************************************** + * + * Public Functions - these are the API intended for the user + * + **************************************************************************/ + + +// initialize USB +void usb_init(void) +{ + HW_CONFIG(); + USB_FREEZE(); // enable USB + PLL_CONFIG(); // config PLL + while (!(PLLCSR & (1<mods; + UEDATX = 0; + uint8_t keys = keyboard_protocol ? KBD_REPORT_KEYS : 6; + for (uint8_t i=0; ikeys[i]; + } + UEINTX = 0x3A; +*/ + } + } + } + } +} + + + +// Misc functions to wait for ready and send/receive packets +static inline void usb_wait_in_ready(void) +{ + while (!(UEINTX & (1<= NUM_DESC_LIST) { + UECONX = (1< desc_length) len = desc_length; + do { + // wait for host ready for IN packet + do { + i = UEINTX; + } while (!(i & ((1<= 1 && i <= MAX_ENDPOINT) { + usb_send_in(); + UENUM = i; + if (bRequest == SET_FEATURE) { + UECONX = (1<mods; + UEDATX = 0; + for (i=0; i<6; i++) { + UEDATX = keyboard_report->keys[i]; + } + usb_send_in(); + return; + } + if (bRequest == HID_GET_IDLE) { + usb_wait_in_ready(); + UEDATX = keyboard_idle; + usb_send_in(); + return; + } + if (bRequest == HID_GET_PROTOCOL) { + usb_wait_in_ready(); + UEDATX = keyboard_protocol; + usb_send_in(); + return; + } + } + if (bmRequestType == 0x21) { + if (bRequest == HID_SET_REPORT) { + usb_wait_receive_out(); + usb_keyboard_leds = UEDATX; + usb_ack_out(); + usb_send_in(); + return; + } + if (bRequest == HID_SET_IDLE) { + keyboard_idle = (wValue >> 8); + usb_keyboard_idle_count = 0; + //usb_wait_in_ready(); + usb_send_in(); + return; + } + if (bRequest == HID_SET_PROTOCOL) { + keyboard_protocol = wValue; +#ifdef NKRO_ENABLE + keyboard_nkro = !!keyboard_protocol; +#endif + clear_keyboard(); + //usb_wait_in_ready(); + usb_send_in(); + return; + } + } + } +#ifdef MOUSE_ENABLE + if (wIndex == MOUSE_INTERFACE) { + if (bmRequestType == 0xA1) { + if (bRequest == HID_GET_REPORT) { + if (wValue == HID_REPORT_INPUT) { + usb_wait_in_ready(); + UEDATX = 0; + UEDATX = 0; + UEDATX = 0; + UEDATX = 0; + usb_send_in(); + return; + } + if (wValue == HID_REPORT_FEATURE) { + usb_wait_in_ready(); + UEDATX = 0x05; + usb_send_in(); + return; + } + } + if (bRequest == HID_GET_PROTOCOL) { + usb_wait_in_ready(); + UEDATX = usb_mouse_protocol; + usb_send_in(); + return; + } + } + if (bmRequestType == 0x21) { + if (bRequest == HID_SET_PROTOCOL) { + usb_mouse_protocol = wValue; + usb_send_in(); + return; + } + } + } +#endif + if (wIndex == DEBUG_INTERFACE) { + if (bRequest == HID_GET_REPORT && bmRequestType == 0xA1) { + len = wLength; + do { + // wait for host ready for IN packet + do { + i = UEINTX; + } while (!(i & ((1< +#include +#include + + +extern bool remote_wakeup; +extern bool suspend; + +void usb_init(void); // initialize everything +uint8_t usb_configured(void); // is the USB port configured +void usb_remote_wakeup(void); + + +#define EP_TYPE_CONTROL 0x00 +#define EP_TYPE_BULK_IN 0x81 +#define EP_TYPE_BULK_OUT 0x80 +#define EP_TYPE_INTERRUPT_IN 0xC1 +#define EP_TYPE_INTERRUPT_OUT 0xC0 +#define EP_TYPE_ISOCHRONOUS_IN 0x41 +#define EP_TYPE_ISOCHRONOUS_OUT 0x40 + +#define EP_SINGLE_BUFFER 0x02 +#define EP_DOUBLE_BUFFER 0x06 + +#define EP_SIZE(s) ((s) == 64 ? 0x30 : \ + ((s) == 32 ? 0x20 : \ + ((s) == 16 ? 0x10 : \ + 0x00))) + +#if defined (__AVR_AT90USB162__) || defined (__AVR_AT90USB82__) +# define MAX_ENDPOINT 4 +# define UERST_MASK 0x1E +#else +# define MAX_ENDPOINT 6 +# define UERST_MASK 0x7E +#endif + +#define LSB(n) (n & 255) +#define MSB(n) ((n >> 8) & 255) + +#if defined(__AVR_AT90USB162__) +#define HW_CONFIG() +#define PLL_CONFIG() (PLLCSR = ((1< +#include "sendchar.h" +#include "usb_debug.h" + + +// the time remaining before we transmit any partially full +// packet, or send a zero length packet. +volatile uint8_t debug_flush_timer=0; + + +int8_t sendchar(uint8_t c) +{ + static uint8_t previous_timeout=0; + uint8_t timeout, intr_state; + + // if we're not online (enumerated and configured), error + if (!usb_configured()) return -1; + // interrupts are disabled so these functions can be + // used from the main program or interrupt context, + // even both in the same program! + intr_state = SREG; + cli(); + UENUM = DEBUG_TX_ENDPOINT; + // if we gave up due to timeout before, don't wait again + if (previous_timeout) { + if (!(UEINTX & (1< +#include "usb.h" + + +#define DEBUG_INTERFACE 2 +#define DEBUG_TX_ENDPOINT 3 +#define DEBUG_TX_SIZE 32 +#define DEBUG_TX_BUFFER EP_DOUBLE_BUFFER + + +extern volatile uint8_t debug_flush_timer; + + +void usb_debug_flush_output(void); // immediately transmit any buffered output + +#endif diff --git a/protocol/pjrc/usb_extra.c b/protocol/pjrc/usb_extra.c new file mode 100644 index 000000000..fe1f422c0 --- /dev/null +++ b/protocol/pjrc/usb_extra.c @@ -0,0 +1,70 @@ +/* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_keyboard.html + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include "host.h" +#include "usb_extra.h" + + +int8_t usb_extra_send(uint8_t report_id, uint16_t data) +{ + uint8_t intr_state, timeout; + + if (!usb_configured()) return -1; + intr_state = SREG; + cli(); + UENUM = EXTRA_ENDPOINT; + timeout = UDFNUML + 50; + while (1) { + // are we ready to transmit? + if (UEINTX & (1<>8)&0xFF; + + UEINTX = 0x3A; + SREG = intr_state; + return 0; +} + +int8_t usb_extra_consumer_send(uint16_t bits) +{ + return usb_extra_send(REPORT_ID_CONSUMER, bits); +} + +int8_t usb_extra_system_send(uint16_t bits) +{ + return usb_extra_send(REPORT_ID_SYSTEM, bits); +} diff --git a/protocol/pjrc/usb_extra.h b/protocol/pjrc/usb_extra.h new file mode 100644 index 000000000..042ac4837 --- /dev/null +++ b/protocol/pjrc/usb_extra.h @@ -0,0 +1,46 @@ +/* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_keyboard.html + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef USB_EXTRA_H +#define USB_EXTRA_H 1 +/* + * Enhanced keyboard features for Windows: + * Audio control and System control + * + * http://www.microsoft.com/whdc/archive/w2kbd.mspx + */ + +#include +#include "usb.h" + + +#define EXTRA_INTERFACE 3 +#define EXTRA_ENDPOINT 4 +#define EXTRA_SIZE 8 +#define EXTRA_BUFFER EP_DOUBLE_BUFFER + + +int8_t usb_extra_consumer_send(uint16_t bits); +int8_t usb_extra_system_send(uint16_t bits); + +#endif diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c new file mode 100644 index 000000000..4b87b5d7b --- /dev/null +++ b/protocol/pjrc/usb_keyboard.c @@ -0,0 +1,110 @@ +/* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_keyboard.html + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include "keycode.h" +#include "usb_keyboard.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "host.h" + + +// protocol setting from the host. We use exactly the same report +// either way, so this variable only stores the setting since we +// are required to be able to report which setting is in use. +uint8_t keyboard_protocol=1; + +// the idle configuration, how often we send the report to the +// host (ms * 4) even when it hasn't changed +// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request. +uint8_t keyboard_idle=125; + +// count until idle timeout +uint8_t usb_keyboard_idle_count=0; + +// 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana +volatile uint8_t usb_keyboard_leds=0; + + +static inline int8_t send_report(report_keyboard_t *report, uint8_t endpoint, uint8_t keys_start, uint8_t keys_end); + + +int8_t usb_keyboard_send_report(report_keyboard_t *report) +{ + int8_t result = 0; + +#ifdef NKRO_ENABLE + if (keyboard_nkro) + result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE); + else +#endif + { + result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE); + } + + if (result) return result; + usb_keyboard_idle_count = 0; + usb_keyboard_print_report(report); + return 0; +} + +void usb_keyboard_print_report(report_keyboard_t *report) +{ + if (!debug_keyboard) return; + print("keys: "); + for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { phex(report->keys[i]); print(" "); } + print(" mods: "); phex(report->mods); print("\n"); +} + + +static inline int8_t send_report(report_keyboard_t *report, uint8_t endpoint, uint8_t keys_start, uint8_t keys_end) +{ + uint8_t intr_state, timeout; + + if (!usb_configured()) return -1; + intr_state = SREG; + cli(); + UENUM = endpoint; + timeout = UDFNUML + 50; + while (1) { + // are we ready to transmit? + if (UEINTX & (1<raw[i]; + } + UEINTX = 0x3A; + SREG = intr_state; + return 0; +} diff --git a/protocol/pjrc/usb_keyboard.h b/protocol/pjrc/usb_keyboard.h new file mode 100644 index 000000000..9b798e9a8 --- /dev/null +++ b/protocol/pjrc/usb_keyboard.h @@ -0,0 +1,40 @@ +/* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_keyboard.html + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef USB_KEYBOARD_H +#define USB_KEYBOARD_H 1 + +#include +#include +#include "usb.h" +#include "host.h" + + +extern uint8_t usb_keyboard_idle_count; +extern volatile uint8_t usb_keyboard_leds; + + +int8_t usb_keyboard_send_report(report_keyboard_t *report); +void usb_keyboard_print_report(report_keyboard_t *report); + +#endif diff --git a/protocol/pjrc/usb_mouse.c b/protocol/pjrc/usb_mouse.c new file mode 100644 index 000000000..d81db756f --- /dev/null +++ b/protocol/pjrc/usb_mouse.c @@ -0,0 +1,81 @@ +/* USB Mouse Plus Debug Channel Example for Teensy USB Development Board + * http://www.pjrc.com/teensy/usb_mouse.html + * Copyright (c) 2009 PJRC.COM, LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include "usb_mouse.h" +#include "print.h" +#include "debug.h" + + +uint8_t usb_mouse_protocol=1; + + +int8_t usb_mouse_send(int8_t x, int8_t y, int8_t wheel_v, int8_t wheel_h, uint8_t buttons) +{ + uint8_t intr_state, timeout; + + if (!usb_configured()) return -1; + if (x == -128) x = -127; + if (y == -128) y = -127; + if (wheel_v == -128) wheel_v = -127; + if (wheel_h == -128) wheel_h = -127; + intr_state = SREG; + cli(); + UENUM = MOUSE_ENDPOINT; + timeout = UDFNUML + 50; + while (1) { + // are we ready to transmit? + if (UEINTX & (1< +#include +#include "usb.h" + + +#define MOUSE_INTERFACE 1 +#define MOUSE_ENDPOINT 2 +#define MOUSE_SIZE 8 +#define MOUSE_BUFFER EP_SINGLE_BUFFER + +#define MOUSE_BTN1 (1<<0) +#define MOUSE_BTN2 (1<<1) +#define MOUSE_BTN3 (1<<2) +#define MOUSE_BTN4 (1<<3) +#define MOUSE_BTN5 (1<<4) + + +extern uint8_t usb_mouse_protocol; + + +int8_t usb_mouse_send(int8_t x, int8_t y, int8_t wheel_v, int8_t wheel_h, uint8_t buttons); +void usb_mouse_print(int8_t x, int8_t y, int8_t wheel_v, int8_t wheel_h, uint8_t buttons); + +#endif diff --git a/protocol/ps2.h b/protocol/ps2.h new file mode 100644 index 000000000..acde679cf --- /dev/null +++ b/protocol/ps2.h @@ -0,0 +1,134 @@ +/* +Copyright 2010,2011,2012,2013 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef PS2_H +#define PS2_H + +#include +#include "wait.h" +#include "ps2_io.h" +#include "print.h" + +/* + * Primitive PS/2 Library for AVR + * + * PS/2 Resources + * -------------- + * [1] The PS/2 Mouse/Keyboard Protocol + * http://www.computer-engineering.org/ps2protocol/ + * Concise and thorough primer of PS/2 protocol. + * + * [2] Keyboard and Auxiliary Device Controller + * http://www.mcamafia.de/pdf/ibm_hitrc07.pdf + * Signal Timing and Format + * + * [3] Keyboards(101- and 102-key) + * http://www.mcamafia.de/pdf/ibm_hitrc11.pdf + * Keyboard Layout, Scan Code Set, POR, and Commands. + * + * [4] PS/2 Reference Manuals + * http://www.mcamafia.de/pdf/ibm_hitrc07.pdf + * Collection of IBM Personal System/2 documents. + * + * [5] TrackPoint Engineering Specifications for version 3E + * https://web.archive.org/web/20100526161812/http://wwwcssrv.almaden.ibm.com/trackpoint/download.html + */ +#define PS2_ACK 0xFA +#define PS2_RESEND 0xFE +#define PS2_SET_LED 0xED + +// TODO: error numbers +#define PS2_ERR_NONE 0 +#define PS2_ERR_STARTBIT1 1 +#define PS2_ERR_STARTBIT2 2 +#define PS2_ERR_STARTBIT3 3 +#define PS2_ERR_PARITY 0x10 +#define PS2_ERR_NODATA 0x20 + +#define PS2_LED_SCROLL_LOCK 0 +#define PS2_LED_NUM_LOCK 1 +#define PS2_LED_CAPS_LOCK 2 + + +extern uint8_t ps2_error; + +void ps2_host_init(void); +uint8_t ps2_host_send(uint8_t data); +uint8_t ps2_host_recv_response(void); +uint8_t ps2_host_recv(void); +void ps2_host_set_led(uint8_t usb_led); + + +/*-------------------------------------------------------------------- + * static functions + *------------------------------------------------------------------*/ +static inline uint16_t wait_clock_lo(uint16_t us) +{ + while (clock_in() && us) { asm(""); wait_us(1); us--; } + return us; +} +static inline uint16_t wait_clock_hi(uint16_t us) +{ + while (!clock_in() && us) { asm(""); wait_us(1); us--; } + return us; +} +static inline uint16_t wait_data_lo(uint16_t us) +{ + while (data_in() && us) { asm(""); wait_us(1); us--; } + return us; +} +static inline uint16_t wait_data_hi(uint16_t us) +{ + while (!data_in() && us) { asm(""); wait_us(1); us--; } + return us; +} + +/* idle state that device can send */ +static inline void idle(void) +{ + clock_hi(); + data_hi(); +} + +/* inhibit device to send */ +static inline void inhibit(void) +{ + clock_lo(); + data_hi(); +} + +#endif diff --git a/protocol/ps2_busywait.c b/protocol/ps2_busywait.c new file mode 100644 index 000000000..a64933219 --- /dev/null +++ b/protocol/ps2_busywait.c @@ -0,0 +1,189 @@ +/* +Copyright 2010,2011,2012,2013 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * PS/2 protocol busywait version + */ + +#include +#include "wait.h" +#include "ps2.h" +#include "ps2_io.h" +#include "debug.h" + + +#define WAIT(stat, us, err) do { \ + if (!wait_##stat(us)) { \ + ps2_error = err; \ + goto ERROR; \ + } \ +} while (0) + + +uint8_t ps2_error = PS2_ERR_NONE; + + +void ps2_host_init(void) +{ + clock_init(); + data_init(); + + // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) + wait_ms(2500); + + inhibit(); +} + +uint8_t ps2_host_send(uint8_t data) +{ + bool parity = true; + ps2_error = PS2_ERR_NONE; + + /* terminate a transmission if we have */ + inhibit(); + wait_us(100); // 100us [4]p.13, [5]p.50 + + /* 'Request to Send' and Start bit */ + data_lo(); + clock_hi(); + WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 + + /* Data bit */ + for (uint8_t i = 0; i < 8; i++) { + wait_us(15); + if (data&(1< PS2_ERR_STARTBIT3) { + xprintf("x%02X\n", ps2_error); + } + inhibit(); + return 0; +} + +/* send LED state to keyboard */ +void ps2_host_set_led(uint8_t led) +{ + ps2_host_send(0xED); + ps2_host_send(led); +} diff --git a/protocol/ps2_interrupt.c b/protocol/ps2_interrupt.c new file mode 100644 index 000000000..8114442ba --- /dev/null +++ b/protocol/ps2_interrupt.c @@ -0,0 +1,279 @@ +/* +Copyright 2010,2011,2012,2013 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * PS/2 protocol Pin interrupt version + */ + +#include +#include +#include +#include "ps2.h" +#include "ps2_io.h" +#include "print.h" + + +#define WAIT(stat, us, err) do { \ + if (!wait_##stat(us)) { \ + ps2_error = err; \ + goto ERROR; \ + } \ +} while (0) + + +uint8_t ps2_error = PS2_ERR_NONE; + + +static inline uint8_t pbuf_dequeue(void); +static inline void pbuf_enqueue(uint8_t data); +static inline bool pbuf_has_data(void); +static inline void pbuf_clear(void); + + +void ps2_host_init(void) +{ + idle(); + PS2_INT_INIT(); + PS2_INT_ON(); + // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) + //_delay_ms(2500); +} + +uint8_t ps2_host_send(uint8_t data) +{ + bool parity = true; + ps2_error = PS2_ERR_NONE; + + PS2_INT_OFF(); + + /* terminate a transmission if we have */ + inhibit(); + _delay_us(100); // 100us [4]p.13, [5]p.50 + + /* 'Request to Send' and Start bit */ + data_lo(); + clock_hi(); + WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 + + /* Data bit[2-9] */ + for (uint8_t i = 0; i < 8; i++) { + _delay_us(15); + if (data&(1<>= 1; + if (data_in()) { + data |= 0x80; + parity++; + } + break; + case PARITY: + if (data_in()) { + if (!(parity & 0x01)) + goto ERROR; + } else { + if (parity & 0x01) + goto ERROR; + } + break; + case STOP: + if (!data_in()) + goto ERROR; + pbuf_enqueue(data); + goto DONE; + break; + default: + goto ERROR; + } + goto RETURN; +ERROR: + ps2_error = state; +DONE: + state = INIT; + data = 0; + parity = 1; +RETURN: + return; +} + +/* send LED state to keyboard */ +void ps2_host_set_led(uint8_t led) +{ + ps2_host_send(0xED); + ps2_host_send(led); +} + + +/*-------------------------------------------------------------------- + * Ring buffer to store scan codes from keyboard + *------------------------------------------------------------------*/ +#define PBUF_SIZE 32 +static uint8_t pbuf[PBUF_SIZE]; +static uint8_t pbuf_head = 0; +static uint8_t pbuf_tail = 0; +static inline void pbuf_enqueue(uint8_t data) +{ + uint8_t sreg = SREG; + cli(); + uint8_t next = (pbuf_head + 1) % PBUF_SIZE; + if (next != pbuf_tail) { + pbuf[pbuf_head] = data; + pbuf_head = next; + } else { + print("pbuf: full\n"); + } + SREG = sreg; +} +static inline uint8_t pbuf_dequeue(void) +{ + uint8_t val = 0; + + uint8_t sreg = SREG; + cli(); + if (pbuf_head != pbuf_tail) { + val = pbuf[pbuf_tail]; + pbuf_tail = (pbuf_tail + 1) % PBUF_SIZE; + } + SREG = sreg; + + return val; +} +static inline bool pbuf_has_data(void) +{ + uint8_t sreg = SREG; + cli(); + bool has_data = (pbuf_head != pbuf_tail); + SREG = sreg; + return has_data; +} +static inline void pbuf_clear(void) +{ + uint8_t sreg = SREG; + cli(); + pbuf_head = pbuf_tail = 0; + SREG = sreg; +} + diff --git a/protocol/ps2_io.h b/protocol/ps2_io.h new file mode 100644 index 000000000..a46a358e7 --- /dev/null +++ b/protocol/ps2_io.h @@ -0,0 +1,15 @@ +#ifndef PS2_IO_H +#define PS2_IO_H + + +void clock_init(void); +void clock_lo(void); +void clock_hi(void); +bool clock_in(void); + +void data_init(void); +void data_lo(void); +void data_hi(void); +bool data_in(void); + +#endif diff --git a/protocol/ps2_io_avr.c b/protocol/ps2_io_avr.c new file mode 100644 index 000000000..ed462345b --- /dev/null +++ b/protocol/ps2_io_avr.c @@ -0,0 +1,75 @@ +#include +#include +#include + +/* Check port settings for clock and data line */ +#if !(defined(PS2_CLOCK_PORT) && \ + defined(PS2_CLOCK_PIN) && \ + defined(PS2_CLOCK_DDR) && \ + defined(PS2_CLOCK_BIT)) +# error "PS/2 clock port setting is required in config.h" +#endif + +#if !(defined(PS2_DATA_PORT) && \ + defined(PS2_DATA_PIN) && \ + defined(PS2_DATA_DDR) && \ + defined(PS2_DATA_BIT)) +# error "PS/2 data port setting is required in config.h" +#endif + + +/* + * Clock + */ +void clock_init(void) +{ +} + +void clock_lo(void) +{ + PS2_CLOCK_PORT &= ~(1< +#include "ps2_io.h" +#include "gpio_api.h" + + +static gpio_t clock; +static gpio_t data; + +/* + * Clock + */ +void clock_init(void) +{ + gpio_init(&clock, P0_9); + gpio_mode(&clock, OpenDrain|PullNone); +} + +void clock_lo(void) +{ + gpio_dir(&clock, PIN_OUTPUT); + gpio_write(&clock, 0); +} +void clock_hi(void) +{ + gpio_dir(&clock, PIN_OUTPUT); + gpio_write(&clock, 1); +} + +bool clock_in(void) +{ + gpio_dir(&clock, PIN_INPUT); + return gpio_read(&clock); +} + +/* + * Data + */ +void data_init(void) +{ + gpio_init(&data, P0_8); + gpio_mode(&data, OpenDrain|PullNone); +} + +void data_lo(void) +{ + gpio_dir(&data, PIN_OUTPUT); + gpio_write(&data, 0); +} + +void data_hi(void) +{ + gpio_dir(&data, PIN_OUTPUT); + gpio_write(&data, 1); +} + +bool data_in(void) +{ + gpio_dir(&data, PIN_INPUT); + return gpio_read(&data); +} diff --git a/protocol/ps2_mouse.c b/protocol/ps2_mouse.c new file mode 100644 index 000000000..c3e8b3c1c --- /dev/null +++ b/protocol/ps2_mouse.c @@ -0,0 +1,220 @@ +/* +Copyright 2011,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include "ps2.h" +#include "ps2_mouse.h" +#include "report.h" +#include "host.h" +#include "timer.h" +#include "print.h" +#include "debug.h" + + +static report_mouse_t mouse_report = {}; + + +static void print_usb_data(void); + + +/* supports only 3 button mouse at this time */ +uint8_t ps2_mouse_init(void) { + uint8_t rcv; + + ps2_host_init(); + + _delay_ms(1000); // wait for powering up + + // send Reset + rcv = ps2_host_send(0xFF); + print("ps2_mouse_init: send Reset: "); + phex(rcv); phex(ps2_error); print("\n"); + + // read completion code of BAT + rcv = ps2_host_recv_response(); + print("ps2_mouse_init: read BAT: "); + phex(rcv); phex(ps2_error); print("\n"); + + // read Device ID + rcv = ps2_host_recv_response(); + print("ps2_mouse_init: read DevID: "); + phex(rcv); phex(ps2_error); print("\n"); + + // send Set Remote mode + rcv = ps2_host_send(0xF0); + print("ps2_mouse_init: send 0xF0: "); + phex(rcv); phex(ps2_error); print("\n"); + + return 0; +} + +#define X_IS_NEG (mouse_report.buttons & (1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef PS2_MOUSE_H +#define PS2_MOUSE_H + +#include + +#define PS2_MOUSE_READ_DATA 0xEB + +/* + * Data format: + * byte|7 6 5 4 3 2 1 0 + * ----+-------------------------------------------------------------- + * 0|Yovflw Xovflw Ysign Xsign 1 Middle Right Left + * 1| X movement(0-255) + * 2| Y movement(0-255) + */ +#define PS2_MOUSE_BTN_MASK 0x07 +#define PS2_MOUSE_BTN_LEFT 0 +#define PS2_MOUSE_BTN_RIGHT 1 +#define PS2_MOUSE_BTN_MIDDLE 2 +#define PS2_MOUSE_X_SIGN 4 +#define PS2_MOUSE_Y_SIGN 5 +#define PS2_MOUSE_X_OVFLW 6 +#define PS2_MOUSE_Y_OVFLW 7 + + +/* + * Scroll by mouse move with pressing button + */ +/* mouse button to start scrolling; set 0 to disable scroll */ +#ifndef PS2_MOUSE_SCROLL_BTN_MASK +#define PS2_MOUSE_SCROLL_BTN_MASK (1< + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * PS/2 protocol USART version + */ + +#include +#include +#include +#include "ps2.h" +#include "ps2_io.h" +#include "print.h" + + +#define WAIT(stat, us, err) do { \ + if (!wait_##stat(us)) { \ + ps2_error = err; \ + goto ERROR; \ + } \ +} while (0) + + +uint8_t ps2_error = PS2_ERR_NONE; + + +static inline uint8_t pbuf_dequeue(void); +static inline void pbuf_enqueue(uint8_t data); +static inline bool pbuf_has_data(void); +static inline void pbuf_clear(void); + + +void ps2_host_init(void) +{ + idle(); // without this many USART errors occur when cable is disconnected + PS2_USART_INIT(); + PS2_USART_RX_INT_ON(); + // POR(150-2000ms) plus BAT(300-500ms) may take 2.5sec([3]p.20) + //_delay_ms(2500); +} + +uint8_t ps2_host_send(uint8_t data) +{ + bool parity = true; + ps2_error = PS2_ERR_NONE; + + PS2_USART_OFF(); + + /* terminate a transmission if we have */ + inhibit(); + _delay_us(100); // [4]p.13 + + /* 'Request to Send' and Start bit */ + data_lo(); + clock_hi(); + WAIT(clock_lo, 10000, 10); // 10ms [5]p.50 + + /* Data bit[2-9] */ + for (uint8_t i = 0; i < 8; i++) { + _delay_us(15); + if (data&(1< + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef SERIAL_H +#define SERIAL_H + +/* host role */ +void serial_init(void); +uint8_t serial_recv(void); +int16_t serial_recv2(void); +void serial_send(uint8_t data); + +#endif diff --git a/protocol/serial_mouse.h b/protocol/serial_mouse.h new file mode 100644 index 000000000..226314fc0 --- /dev/null +++ b/protocol/serial_mouse.h @@ -0,0 +1,33 @@ +/* +Copyright 2014 Robin Haberkorn + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef SERIAL_MOUSE_H +#define SERIAL_MOUSE_H + +#include + +#include "serial.h" + +static inline uint8_t serial_mouse_init(void) +{ + serial_init(); + return 0; +} + +void serial_mouse_task(void); + +#endif diff --git a/protocol/serial_mouse_microsoft.c b/protocol/serial_mouse_microsoft.c new file mode 100644 index 000000000..ab74b7cdd --- /dev/null +++ b/protocol/serial_mouse_microsoft.c @@ -0,0 +1,124 @@ +/* +Copyright 2014 Robin Haberkorn + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include + +#include "serial.h" +#include "serial_mouse.h" +#include "report.h" +#include "host.h" +#include "timer.h" +#include "print.h" +#include "debug.h" + +#ifdef MAX +#undef MAX +#endif +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) + +static void print_usb_data(const report_mouse_t *report); + +void serial_mouse_task(void) +{ + /* 3 byte ring buffer */ + static uint8_t buffer[3]; + static int buffer_cur = 0; + + static report_mouse_t report = {}; + + int16_t rcv; + + rcv = serial_recv2(); + if (rcv < 0) + /* no new data */ + return; + + if (debug_mouse) + xprintf("serial_mouse: byte: %04X\n", rcv); + + /* + * If bit 6 is one, this signals the beginning + * of a 3 byte sequence/packet. + */ + if (rcv & (1 << 6)) + buffer_cur = 0; + + buffer[buffer_cur] = (uint8_t)rcv; + + if (buffer_cur == 0 && buffer[buffer_cur] == 0x20) { + /* + * Logitech extension: This must be a follow-up on + * the last 3-byte packet signaling a middle button click + */ + report.buttons |= MOUSE_BTN3; + report.x = report.y = 0; + + print_usb_data(&report); + host_mouse_send(&report); + return; + } + + buffer_cur++; + + if (buffer_cur < 3) + return; + buffer_cur = 0; + + /* + * parse 3 byte packet. + * NOTE: We only get a complete packet + * if the mouse moved or the button states + * change. + */ + report.buttons = 0; + if (buffer[0] & (1 << 5)) + report.buttons |= MOUSE_BTN1; + if (buffer[0] & (1 << 4)) + report.buttons |= MOUSE_BTN2; + + report.x = (buffer[0] << 6) | buffer[1]; + report.y = ((buffer[0] << 4) & 0xC0) | buffer[2]; + + /* USB HID uses values from -127 to 127 only */ + report.x = MAX(report.x, -127); + report.y = MAX(report.y, -127); + +#if 0 + if (!report.buttons && !report.x && !report.y) { + /* + * Microsoft extension: Middle mouse button pressed + * FIXME: I don't know how exactly this extension works. + */ + report.buttons |= MOUSE_BTN3; + } +#endif + + print_usb_data(&report); + host_mouse_send(&report); +} + +static void print_usb_data(const report_mouse_t *report) +{ + if (!debug_mouse) + return; + + xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n", + report->buttons, report->x, report->y, + report->v, report->h); +} diff --git a/protocol/serial_mouse_mousesystems.c b/protocol/serial_mouse_mousesystems.c new file mode 100644 index 000000000..cfe899621 --- /dev/null +++ b/protocol/serial_mouse_mousesystems.c @@ -0,0 +1,131 @@ +/* +Copyright 2014 Robin Haberkorn + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include + +#include "serial.h" +#include "serial_mouse.h" +#include "report.h" +#include "host.h" +#include "timer.h" +#include "print.h" +#include "debug.h" + +#ifdef MAX +#undef MAX +#endif +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) + +//#define SERIAL_MOUSE_CENTER_SCROLL + +static void print_usb_data(const report_mouse_t *report); + +void serial_mouse_task(void) +{ + /* 5 byte ring buffer */ + static uint8_t buffer[5]; + static int buffer_cur = 0; + + int16_t rcv; + + report_mouse_t report = {0, 0, 0, 0, 0}; + + rcv = serial_recv2(); + if (rcv < 0) + /* no new data */ + return; + + if (debug_mouse) + xprintf("serial_mouse: byte: %04X\n", rcv); + + /* + * Synchronization: mouse(4) says that all + * bytes but the first one in the packet have + * bit 7 == 0, but this is untrue. + * Therefore we discard all bytes up to the + * first one with the characteristic bit pattern. + */ + if (buffer_cur == 0 && (rcv >> 3) != 0x10) + return; + + buffer[buffer_cur++] = (uint8_t)rcv; + + if (buffer_cur < 5) + return; + buffer_cur = 0; + +#ifdef SERIAL_MOUSE_CENTER_SCROLL + if ((buffer[0] & 0x7) == 0x5 && (buffer[1] || buffer[2])) { + /* USB HID uses only values from -127 to 127 */ + report.h = MAX((int8_t)buffer[1], -127); + report.v = MAX((int8_t)buffer[2], -127); + + print_usb_data(&report); + host_mouse_send(&report); + + if (buffer[3] || buffer[4]) { + report.h = MAX((int8_t)buffer[3], -127); + report.v = MAX((int8_t)buffer[4], -127); + + print_usb_data(&report); + host_mouse_send(&report); + } + + return; + } +#endif + + /* + * parse 5 byte packet. + * NOTE: We only get a complete packet + * if the mouse moved or the button states + * change. + */ + if (!(buffer[0] & (1 << 2))) + report.buttons |= MOUSE_BTN1; + if (!(buffer[0] & (1 << 1))) + report.buttons |= MOUSE_BTN3; + if (!(buffer[0] & (1 << 0))) + report.buttons |= MOUSE_BTN2; + + /* USB HID uses only values from -127 to 127 */ + report.x = MAX((int8_t)buffer[1], -127); + report.y = MAX(-(int8_t)buffer[2], -127); + + print_usb_data(&report); + host_mouse_send(&report); + + if (buffer[3] || buffer[4]) { + report.x = MAX((int8_t)buffer[3], -127); + report.y = MAX(-(int8_t)buffer[4], -127); + + print_usb_data(&report); + host_mouse_send(&report); + } +} + +static void print_usb_data(const report_mouse_t *report) +{ + if (!debug_mouse) + return; + + xprintf("serial_mouse usb: [%02X|%d %d %d %d]\n", + report->buttons, report->x, report->y, + report->v, report->h); +} diff --git a/protocol/serial_soft.c b/protocol/serial_soft.c new file mode 100644 index 000000000..44822b7e4 --- /dev/null +++ b/protocol/serial_soft.c @@ -0,0 +1,240 @@ +/* +Copyright 2012 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include "serial.h" + +/* + * Stupid Inefficient Busy-wait Software Serial + * which is still useful for negative logic signal like Sun protocol + * if it is not supported by hardware UART. + * + * TODO: delay is not accurate enough. Instruction cycle should be counted and inline assemby is needed. + */ + +#define WAIT_US (1000000L/SERIAL_SOFT_BAUD) + +#ifdef SERIAL_SOFT_LOGIC_NEGATIVE + #define SERIAL_SOFT_RXD_IN() !(SERIAL_SOFT_RXD_READ()) + #define SERIAL_SOFT_TXD_ON() SERIAL_SOFT_TXD_LO() + #define SERIAL_SOFT_TXD_OFF() SERIAL_SOFT_TXD_HI() +#else + #define SERIAL_SOFT_RXD_IN() !!(SERIAL_SOFT_RXD_READ()) + #define SERIAL_SOFT_TXD_ON() SERIAL_SOFT_TXD_HI() + #define SERIAL_SOFT_TXD_OFF() SERIAL_SOFT_TXD_LO() +#endif + +#ifdef SERIAL_SOFT_PARITY_EVEN + #define SERIAL_SOFT_PARITY_VAL 0 +#elif defined(SERIAL_SOFT_PARITY_ODD) + #define SERIAL_SOFT_PARITY_VAL 1 +#endif + +/* debug for signal timing, see debug pin with oscilloscope */ +#define SERIAL_SOFT_DEBUG +#ifdef SERIAL_SOFT_DEBUG + #define SERIAL_SOFT_DEBUG_INIT() (DDRD |= 1<<7) + #define SERIAL_SOFT_DEBUG_TGL() (PORTD ^= 1<<7) +#else + #define SERIAL_SOFT_DEBUG_INIT() + #define SERIAL_SOFT_DEBUG_TGL() +#endif + + +void serial_init(void) +{ + SERIAL_SOFT_DEBUG_INIT(); + + SERIAL_SOFT_RXD_INIT(); + SERIAL_SOFT_TXD_INIT(); +} + +/* RX ring buffer */ +#define RBUF_SIZE 8 +static uint8_t rbuf[RBUF_SIZE]; +static uint8_t rbuf_head = 0; +static uint8_t rbuf_tail = 0; + + +uint8_t serial_recv(void) +{ + uint8_t data = 0; + if (rbuf_head == rbuf_tail) { + return 0; + } + + data = rbuf[rbuf_tail]; + rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE; + return data; +} + +int16_t serial_recv2(void) +{ + uint8_t data = 0; + if (rbuf_head == rbuf_tail) { + return -1; + } + + data = rbuf[rbuf_tail]; + rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE; + return data; +} + +void serial_send(uint8_t data) +{ + /* signal state: IDLE: ON, START: OFF, STOP: ON, DATA0: OFF, DATA1: ON */ + +#ifdef SERIAL_SOFT_BIT_ORDER_MSB + #ifdef SERIAL_SOFT_DATA_7BIT + uint8_t mask = 0x40; + #else + uint8_t mask = 0x80; + #endif +#else + uint8_t mask = 0x01; +#endif + + uint8_t parity = 0; + + /* start bit */ + SERIAL_SOFT_TXD_OFF(); + _delay_us(WAIT_US); + +#ifdef SERIAL_SOFT_DATA_7BIT + while (mask&0x7F) { +#else + while (mask&0xFF) { +#endif + if (data&mask) { + SERIAL_SOFT_TXD_ON(); + parity ^= 1; + } else { + SERIAL_SOFT_TXD_OFF(); + } + _delay_us(WAIT_US); + +#ifdef SERIAL_SOFT_BIT_ORDER_MSB + mask >>= 1; +#else + mask <<= 1; +#endif + } + +#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD) + /* to center of parity bit */ + if (parity != SERIAL_SOFT_PARITY_VAL) { + SERIAL_SOFT_TXD_ON(); + } else { + SERIAL_SOFT_TXD_OFF(); + } + _delay_us(WAIT_US); +#endif + + /* stop bit */ + SERIAL_SOFT_TXD_ON(); + _delay_us(WAIT_US); +} + +/* detect edge of start bit */ +ISR(SERIAL_SOFT_RXD_VECT) +{ + SERIAL_SOFT_DEBUG_TGL(); + SERIAL_SOFT_RXD_INT_ENTER() + + uint8_t data = 0; + +#ifdef SERIAL_SOFT_BIT_ORDER_MSB + #ifdef SERIAL_SOFT_DATA_7BIT + uint8_t mask = 0x40; + #else + uint8_t mask = 0x80; + #endif +#else + uint8_t mask = 0x01; +#endif + + uint8_t parity = 0; + + /* to center of start bit */ + _delay_us(WAIT_US/2); + SERIAL_SOFT_DEBUG_TGL(); + do { + /* to center of next bit */ + _delay_us(WAIT_US); + + SERIAL_SOFT_DEBUG_TGL(); + if (SERIAL_SOFT_RXD_IN()) { + data |= mask; + parity ^= 1; + } +#ifdef SERIAL_SOFT_BIT_ORDER_MSB + mask >>= 1; +#else + mask <<= 1; +#endif +#ifdef SERIAL_SOFT_DATA_7BIT + } while (mask&0x7F); +#else + } while (mask&0xFF); +#endif + +#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD) + /* to center of parity bit */ + _delay_us(WAIT_US); + if (SERIAL_SOFT_RXD_IN()) { parity ^= 1; } + SERIAL_SOFT_DEBUG_TGL(); +#endif + + /* to center of stop bit */ + _delay_us(WAIT_US); + + uint8_t next = (rbuf_head + 1) % RBUF_SIZE; +#if defined(SERIAL_SOFT_PARITY_EVEN) || defined(SERIAL_SOFT_PARITY_ODD) + if ((parity == SERIAL_SOFT_PARITY_VAL) && next != rbuf_tail) { +#else + if (next != rbuf_tail) { +#endif + rbuf[rbuf_head] = data; + rbuf_head = next; + } + + SERIAL_SOFT_RXD_INT_EXIT(); + SERIAL_SOFT_DEBUG_TGL(); +} diff --git a/protocol/serial_uart.c b/protocol/serial_uart.c new file mode 100644 index 000000000..35df27fd6 --- /dev/null +++ b/protocol/serial_uart.c @@ -0,0 +1,112 @@ +/* +Copyright 2013 Jun WAKO + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include "serial.h" + + +#if defined(SERIAL_UART_RTS_LO) && defined(SERIAL_UART_RTS_HI) + // Buffer state + // Empty: RBUF_SPACE == RBUF_SIZE(head==tail) + // Last 1 space: RBUF_SPACE == 2 + // Full: RBUF_SPACE == 1(last cell of rbuf be never used.) + #define RBUF_SPACE() (rbuf_head < rbuf_tail ? (rbuf_tail - rbuf_head) : (RBUF_SIZE - rbuf_head + rbuf_tail)) + // allow to send + #define rbuf_check_rts_lo() do { if (RBUF_SPACE() > 2) SERIAL_UART_RTS_LO(); } while (0) + // prohibit to send + #define rbuf_check_rts_hi() do { if (RBUF_SPACE() <= 2) SERIAL_UART_RTS_HI(); } while (0) +#else + #define rbuf_check_rts_lo() + #define rbuf_check_rts_hi() +#endif + + +void serial_init(void) +{ + SERIAL_UART_INIT(); +} + +// RX ring buffer +#define RBUF_SIZE 256 +static uint8_t rbuf[RBUF_SIZE]; +static uint8_t rbuf_head = 0; +static uint8_t rbuf_tail = 0; + +uint8_t serial_recv(void) +{ + uint8_t data = 0; + if (rbuf_head == rbuf_tail) { + return 0; + } + + data = rbuf[rbuf_tail]; + rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE; + rbuf_check_rts_lo(); + return data; +} + +int16_t serial_recv2(void) +{ + uint8_t data = 0; + if (rbuf_head == rbuf_tail) { + return -1; + } + + data = rbuf[rbuf_tail]; + rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE; + rbuf_check_rts_lo(); + return data; +} + +void serial_send(uint8_t data) +{ + while (!SERIAL_UART_TXD_READY) ; + SERIAL_UART_DATA = data; +} + +// USART RX complete interrupt +ISR(SERIAL_UART_RXD_VECT) +{ + uint8_t next = (rbuf_head + 1) % RBUF_SIZE; + if (next != rbuf_tail) { + rbuf[rbuf_head] = SERIAL_UART_DATA; + rbuf_head = next; + } + rbuf_check_rts_hi(); +} diff --git a/protocol/usb_hid.mk b/protocol/usb_hid.mk new file mode 100644 index 000000000..1f79bda3b --- /dev/null +++ b/protocol/usb_hid.mk @@ -0,0 +1,74 @@ +USB_HID_DIR = protocol/usb_hid + + +# +# USB Host Shield +# +USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0 +USB_HOST_SHIELD_SRC = \ + $(USB_HOST_SHIELD_DIR)/Usb.cpp \ + $(USB_HOST_SHIELD_DIR)/hid.cpp \ + $(USB_HOST_SHIELD_DIR)/usbhub.cpp \ + $(USB_HOST_SHIELD_DIR)/parsetools.cpp \ + $(USB_HOST_SHIELD_DIR)/message.cpp + + + +# +# Arduino +# +ARDUINO_DIR = $(USB_HID_DIR)/arduino-1.0.1 +ARDUINO_CORES_DIR = $(ARDUINO_DIR)/cores/arduino +ARDUINO_CORES_SRC = \ + $(ARDUINO_CORES_DIR)/Print.cpp \ + $(ARDUINO_CORES_DIR)/Stream.cpp + +# replaced with override_Serial.c +# $(ARDUINO_CORES_DIR)/CDC.cpp \ +# $(ARDUINO_CORES_DIR)/HID.cpp \ +# $(ARDUINO_CORES_DIR)/USBCore.cpp \ + +# replaced with override_wiring.c and common/timer.c +# $(ARDUINO_CORES_DIR)/wiring.c \ + + + +# +# HID parser +# +SRC += $(USB_HID_DIR)/parser.cpp + +# replace arduino/CDC.cpp +SRC += $(USB_HID_DIR)/override_Serial.cpp + +# replace arduino/wiring.c +SRC += $(USB_HID_DIR)/override_wiring.c +SRC += common/avr/timer.c + +SRC += $(USB_HOST_SHIELD_SRC) +SRC += $(ARDUINO_CORES_SRC) + + +OPT_DEFS += -DARDUINO=101 +# Arduino USBCore needs USB_VID and USB_PID. +#OPT_DEFS += -DARDUINO=101 -DUSB_VID=0x2341 -DUSB_PID=0x8036 + + + +# +# Search Path +# +VPATH += $(TMK_DIR)/$(USB_HID_DIR) +VPATH += $(TMK_DIR)/$(USB_HOST_SHIELD_DIR) + +# for #include "Arduino.h" +VPATH += $(TMK_DIR)/$(ARDUINO_CORES_DIR) + +# for #include "pins_arduino.h" +VPATH += $(TMK_DIR)/$(ARDUINO_DIR)/variants/leonardo + +# ad hoc workaround for compile problem on Windows: +# Windows doesn't know difference between common/print.h and arduino/Print.h. +# On Linux no problem. +# Change file name common/print.h to console.h ? +VPATH := $(TMK_DIR)/common $(VPATH) diff --git a/protocol/usb_hid/README b/protocol/usb_hid/README new file mode 100644 index 000000000..0d2efc2aa --- /dev/null +++ b/protocol/usb_hid/README @@ -0,0 +1,47 @@ +USB HID protocol +================ +Host side of USB HID keyboard protocol implementation. +Only standard HID Boot mode is supported at this time. This means most of normal keyboards are supported while proprietary >6KRO and NKRO is not. + +Third party Libraries +--------------------- +USB_Host_Shield_2.0 + Circuits@Home repository is git-submoduled. Do git submodule init & update to get the content. + https://github.com/felis/USB_Host_Shield_2.0 + +arduino-1.0.1 + Arduino files copied from: + https://github.com/arduino/Arduino/hardware/arduino/{cores,variants} + + +Test build +---------- +In test directory; + $ make + $ DEV=/dev/ttyACM0 make program + +You can see HID keyboard reports on debug output. + + +Restriction and Bug +------------------- +Not supported/confirmed yet. + Hub, suspend, keyboard LED + +Switching power on VBUS: + To power reset device. + http://www.circuitsathome.com/camera-control/simulating-cable-disconnect-on-usb-host-shield-2-0 + This is needed for a device which are not initilized with 'USB Bus Reset'(long SE0) + +Can't bus-reset a keyboard which already attached on bus properly. + Slow start up of Leonardo's bootloader causes this? + Need to unplug/plug a keyboard after firmware starts up. + MAX3421E doesn't work SAMPLEBUS well to know whether device connected or not. + +Keyboard with other endpoints than boot keyboard may go wrong. + On my keyboard with mouse key the converter locks up when using mouse key function. + +Can't compile on Windows filesystem. + On Linux no problem. + Windows doesn't know difference between common/print.h and arduino/Print.h. + Change file name common/print.h to console.h ? diff --git a/protocol/usb_hid/USB_Host_Shield_2.0 b/protocol/usb_hid/USB_Host_Shield_2.0 new file mode 160000 index 000000000..7c2e6c1bc --- /dev/null +++ b/protocol/usb_hid/USB_Host_Shield_2.0 @@ -0,0 +1 @@ +Subproject commit 7c2e6c1bcdcc22cfdbd82edd9d8fc4c4276ead47 diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Arduino.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Arduino.h new file mode 100644 index 000000000..830c9952f --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Arduino.h @@ -0,0 +1,215 @@ +#ifndef Arduino_h +#define Arduino_h + +#include +#include +#include + +#include +#include +#include + +#include "binary.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#define HIGH 0x1 +#define LOW 0x0 + +#define INPUT 0x0 +#define OUTPUT 0x1 +#define INPUT_PULLUP 0x2 + +#define true 0x1 +#define false 0x0 + +#define PI 3.1415926535897932384626433832795 +#define HALF_PI 1.5707963267948966192313216916398 +#define TWO_PI 6.283185307179586476925286766559 +#define DEG_TO_RAD 0.017453292519943295769236907684886 +#define RAD_TO_DEG 57.295779513082320876798154814105 + +#define SERIAL 0x0 +#define DISPLAY 0x1 + +#define LSBFIRST 0 +#define MSBFIRST 1 + +#define CHANGE 1 +#define FALLING 2 +#define RISING 3 + +#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) +#define DEFAULT 0 +#define EXTERNAL 1 +#define INTERNAL 2 +#else +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__) +#define INTERNAL1V1 2 +#define INTERNAL2V56 3 +#else +#define INTERNAL 3 +#endif +#define DEFAULT 1 +#define EXTERNAL 0 +#endif + +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif + +#define min(a,b) ((a)<(b)?(a):(b)) +#define max(a,b) ((a)>(b)?(a):(b)) +#define abs(x) ((x)>0?(x):-(x)) +#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define radians(deg) ((deg)*DEG_TO_RAD) +#define degrees(rad) ((rad)*RAD_TO_DEG) +#define sq(x) ((x)*(x)) + +#define interrupts() sei() +#define noInterrupts() cli() + +#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) +#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) +#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) + +#define lowByte(w) ((uint8_t) ((w) & 0xff)) +#define highByte(w) ((uint8_t) ((w) >> 8)) + +#define bitRead(value, bit) (((value) >> (bit)) & 0x01) +#define bitSet(value, bit) ((value) |= (1UL << (bit))) +#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) +#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) + + +typedef unsigned int word; + +#define bit(b) (1UL << (b)) + +typedef uint8_t boolean; +typedef uint8_t byte; + +void init(void); + +void pinMode(uint8_t, uint8_t); +void digitalWrite(uint8_t, uint8_t); +int digitalRead(uint8_t); +int analogRead(uint8_t); +void analogReference(uint8_t mode); +void analogWrite(uint8_t, int); + +unsigned long millis(void); +unsigned long micros(void); +void delay(unsigned long); +void delayMicroseconds(unsigned int us); +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); + +void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); +uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); + +void attachInterrupt(uint8_t, void (*)(void), int mode); +void detachInterrupt(uint8_t); + +void setup(void); +void loop(void); + +// Get the bit location within the hardware port of the given virtual pin. +// This comes from the pins_*.c file for the active board configuration. + +#define analogInPinToBit(P) (P) + +// On the ATmega1280, the addresses of some of the port registers are +// greater than 255, so we can't store them in uint8_t's. +extern const uint16_t PROGMEM port_to_mode_PGM[]; +extern const uint16_t PROGMEM port_to_input_PGM[]; +extern const uint16_t PROGMEM port_to_output_PGM[]; + +extern const uint8_t PROGMEM digital_pin_to_port_PGM[]; +// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[]; +extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[]; +extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; + +// Get the bit location within the hardware port of the given virtual pin. +// This comes from the pins_*.c file for the active board configuration. +// +// These perform slightly better as macros compared to inline functions +// +#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) ) +#define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) ) +#define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) ) +#define analogInPinToBit(P) (P) +#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) ) +#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) ) +#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) ) + +#define NOT_A_PIN 0 +#define NOT_A_PORT 0 + +#ifdef ARDUINO_MAIN +#define PA 1 +#define PB 2 +#define PC 3 +#define PD 4 +#define PE 5 +#define PF 6 +#define PG 7 +#define PH 8 +#define PJ 10 +#define PK 11 +#define PL 12 +#endif + +#define NOT_ON_TIMER 0 +#define TIMER0A 1 +#define TIMER0B 2 +#define TIMER1A 3 +#define TIMER1B 4 +#define TIMER2 5 +#define TIMER2A 6 +#define TIMER2B 7 + +#define TIMER3A 8 +#define TIMER3B 9 +#define TIMER3C 10 +#define TIMER4A 11 +#define TIMER4B 12 +#define TIMER4C 13 +#define TIMER4D 14 +#define TIMER5A 15 +#define TIMER5B 16 +#define TIMER5C 17 + +#ifdef __cplusplus +} // extern "C" +#endif + +#ifdef __cplusplus +#include "WCharacter.h" +#include "WString.h" +#include "HardwareSerial.h" + +uint16_t makeWord(uint16_t w); +uint16_t makeWord(byte h, byte l); + +#define word(...) makeWord(__VA_ARGS__) + +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); + +void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); +void noTone(uint8_t _pin); + +// WMath prototypes +long random(long); +long random(long, long); +void randomSeed(unsigned int); +long map(long, long, long, long, long); + +#endif + +#include "pins_arduino.h" + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/CDC.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/CDC.cpp new file mode 100644 index 000000000..1ee3a488a --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/CDC.cpp @@ -0,0 +1,233 @@ + + +/* Copyright (c) 2011, Peter Barrett +** +** Permission to use, copy, modify, and/or distribute this software for +** any purpose with or without fee is hereby granted, provided that the +** above copyright notice and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR +** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +** WHETHER 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 "Platform.h" +#include "USBAPI.h" +#include + +#if defined(USBCON) +#ifdef CDC_ENABLED + +#if (RAMEND < 1000) +#define SERIAL_BUFFER_SIZE 16 +#else +#define SERIAL_BUFFER_SIZE 64 +#endif + +struct ring_buffer +{ + unsigned char buffer[SERIAL_BUFFER_SIZE]; + volatile int head; + volatile int tail; +}; + +ring_buffer cdc_rx_buffer = { { 0 }, 0, 0}; + +typedef struct +{ + u32 dwDTERate; + u8 bCharFormat; + u8 bParityType; + u8 bDataBits; + u8 lineState; +} LineInfo; + +static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 }; + +#define WEAK __attribute__ ((weak)) + +extern const CDCDescriptor _cdcInterface PROGMEM; +const CDCDescriptor _cdcInterface = +{ + D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1), + + // CDC communication interface + D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), + D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd) + D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not) + D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported + D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 + D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40), + + // CDC data interface + D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0), + D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0), + D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0) +}; + +int WEAK CDC_GetInterface(u8* interfaceNum) +{ + interfaceNum[0] += 2; // uses 2 + return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface)); +} + +bool WEAK CDC_Setup(Setup& setup) +{ + u8 r = setup.bRequest; + u8 requestType = setup.bmRequestType; + + if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType) + { + if (CDC_GET_LINE_CODING == r) + { + USB_SendControl(0,(void*)&_usbLineInfo,7); + return true; + } + } + + if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType) + { + if (CDC_SET_LINE_CODING == r) + { + USB_RecvControl((void*)&_usbLineInfo,7); + return true; + } + + if (CDC_SET_CONTROL_LINE_STATE == r) + { + _usbLineInfo.lineState = setup.wValueL; + + // auto-reset into the bootloader is triggered when the port, already + // open at 1200 bps, is closed. this is the signal to start the watchdog + // with a relatively long period so it can finish housekeeping tasks + // like servicing endpoints before the sketch ends + if (1200 == _usbLineInfo.dwDTERate) { + // We check DTR state to determine if host port is open (bit 0 of lineState). + if ((_usbLineInfo.lineState & 0x01) == 0) { + *(uint16_t *)0x0800 = 0x7777; + wdt_enable(WDTO_120MS); + } else { + // Most OSs do some intermediate steps when configuring ports and DTR can + // twiggle more than once before stabilizing. + // To avoid spurious resets we set the watchdog to 250ms and eventually + // cancel if DTR goes back high. + + wdt_disable(); + wdt_reset(); + *(uint16_t *)0x0800 = 0x0; + } + } + return true; + } + } + return false; +} + + +int _serialPeek = -1; +void Serial_::begin(uint16_t baud_count) +{ +} + +void Serial_::end(void) +{ +} + +void Serial_::accept(void) +{ + ring_buffer *buffer = &cdc_rx_buffer; + int c = USB_Recv(CDC_RX); + int i = (unsigned int)(buffer->head+1) % SERIAL_BUFFER_SIZE; + + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if (i != buffer->tail) { + buffer->buffer[buffer->head] = c; + buffer->head = i; + } +} + +int Serial_::available(void) +{ + ring_buffer *buffer = &cdc_rx_buffer; + return (unsigned int)(SERIAL_BUFFER_SIZE + buffer->head - buffer->tail) % SERIAL_BUFFER_SIZE; +} + +int Serial_::peek(void) +{ + ring_buffer *buffer = &cdc_rx_buffer; + if (buffer->head == buffer->tail) { + return -1; + } else { + return buffer->buffer[buffer->tail]; + } +} + +int Serial_::read(void) +{ + ring_buffer *buffer = &cdc_rx_buffer; + // if the head isn't ahead of the tail, we don't have any characters + if (buffer->head == buffer->tail) { + return -1; + } else { + unsigned char c = buffer->buffer[buffer->tail]; + buffer->tail = (unsigned int)(buffer->tail + 1) % SERIAL_BUFFER_SIZE; + return c; + } +} + +void Serial_::flush(void) +{ + USB_Flush(CDC_TX); +} + +size_t Serial_::write(uint8_t c) +{ + /* only try to send bytes if the high-level CDC connection itself + is open (not just the pipe) - the OS should set lineState when the port + is opened and clear lineState when the port is closed. + bytes sent before the user opens the connection or after + the connection is closed are lost - just like with a UART. */ + + // TODO - ZE - check behavior on different OSes and test what happens if an + // open connection isn't broken cleanly (cable is yanked out, host dies + // or locks up, or host virtual serial port hangs) + if (_usbLineInfo.lineState > 0) { + int r = USB_Send(CDC_TX,&c,1); + if (r > 0) { + return r; + } else { + setWriteError(); + return 0; + } + } + setWriteError(); + return 0; +} + +// This operator is a convenient way for a sketch to check whether the +// port has actually been configured and opened by the host (as opposed +// to just being connected to the host). It can be used, for example, in +// setup() before printing to ensure that an application on the host is +// actually ready to receive and display the data. +// We add a short delay before returning to fix a bug observed by Federico +// where the port is configured (lineState != 0) but not quite opened. +Serial_::operator bool() { + bool result = false; + if (_usbLineInfo.lineState > 0) + result = true; + delay(10); + return result; +} + +Serial_ Serial; + +#endif +#endif /* if defined(USBCON) */ diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Client.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Client.h new file mode 100644 index 000000000..ea134838a --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Client.h @@ -0,0 +1,26 @@ +#ifndef client_h +#define client_h +#include "Print.h" +#include "Stream.h" +#include "IPAddress.h" + +class Client : public Stream { + +public: + virtual int connect(IPAddress ip, uint16_t port) =0; + virtual int connect(const char *host, uint16_t port) =0; + virtual size_t write(uint8_t) =0; + virtual size_t write(const uint8_t *buf, size_t size) =0; + virtual int available() = 0; + virtual int read() = 0; + virtual int read(uint8_t *buf, size_t size) = 0; + virtual int peek() = 0; + virtual void flush() = 0; + virtual void stop() = 0; + virtual uint8_t connected() = 0; + virtual operator bool() = 0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/HID.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/HID.cpp new file mode 100644 index 000000000..ac6360844 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/HID.cpp @@ -0,0 +1,520 @@ + + +/* Copyright (c) 2011, Peter Barrett +** +** Permission to use, copy, modify, and/or distribute this software for +** any purpose with or without fee is hereby granted, provided that the +** above copyright notice and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR +** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +** WHETHER 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 "Platform.h" +#include "USBAPI.h" +#include "USBDesc.h" + +#if defined(USBCON) +#ifdef HID_ENABLED + +//#define RAWHID_ENABLED + +// Singletons for mouse and keyboard + +Mouse_ Mouse; +Keyboard_ Keyboard; + +//================================================================================ +//================================================================================ + +// HID report descriptor + +#define LSB(_x) ((_x) & 0xFF) +#define MSB(_x) ((_x) >> 8) + +#define RAWHID_USAGE_PAGE 0xFFC0 +#define RAWHID_USAGE 0x0C00 +#define RAWHID_TX_SIZE 64 +#define RAWHID_RX_SIZE 64 + +extern const u8 _hidReportDescriptor[] PROGMEM; +const u8 _hidReportDescriptor[] = { + + // Mouse + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 54 + 0x09, 0x02, // USAGE (Mouse) + 0xa1, 0x01, // COLLECTION (Application) + 0x09, 0x01, // USAGE (Pointer) + 0xa1, 0x00, // COLLECTION (Physical) + 0x85, 0x01, // REPORT_ID (1) + 0x05, 0x09, // USAGE_PAGE (Button) + 0x19, 0x01, // USAGE_MINIMUM (Button 1) + 0x29, 0x03, // USAGE_MAXIMUM (Button 3) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x95, 0x03, // REPORT_COUNT (3) + 0x75, 0x01, // REPORT_SIZE (1) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x95, 0x01, // REPORT_COUNT (1) + 0x75, 0x05, // REPORT_SIZE (5) + 0x81, 0x03, // INPUT (Cnst,Var,Abs) + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x30, // USAGE (X) + 0x09, 0x31, // USAGE (Y) + 0x09, 0x38, // USAGE (Wheel) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x03, // REPORT_COUNT (3) + 0x81, 0x06, // INPUT (Data,Var,Rel) + 0xc0, // END_COLLECTION + 0xc0, // END_COLLECTION + + // Keyboard + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) // 47 + 0x09, 0x06, // USAGE (Keyboard) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, 0x02, // REPORT_ID (2) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + + 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) + 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + + 0x95, 0x08, // REPORT_COUNT (8) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x95, 0x01, // REPORT_COUNT (1) + 0x75, 0x08, // REPORT_SIZE (8) + 0x81, 0x03, // INPUT (Cnst,Var,Abs) + + 0x95, 0x06, // REPORT_COUNT (6) + 0x75, 0x08, // REPORT_SIZE (8) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x65, // LOGICAL_MAXIMUM (101) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + + 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) + 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) + 0x81, 0x00, // INPUT (Data,Ary,Abs) + 0xc0, // END_COLLECTION + +#if RAWHID_ENABLED + // RAW HID + 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30 + 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE), + + 0xA1, 0x01, // Collection 0x01 + 0x85, 0x03, // REPORT_ID (3) + 0x75, 0x08, // report size = 8 bits + 0x15, 0x00, // logical minimum = 0 + 0x26, 0xFF, 0x00, // logical maximum = 255 + + 0x95, 64, // report count TX + 0x09, 0x01, // usage + 0x81, 0x02, // Input (array) + + 0x95, 64, // report count RX + 0x09, 0x02, // usage + 0x91, 0x02, // Output (array) + 0xC0 // end collection +#endif +}; + +extern const HIDDescriptor _hidInterface PROGMEM; +const HIDDescriptor _hidInterface = +{ + D_INTERFACE(HID_INTERFACE,1,3,0,0), + D_HIDREPORT(sizeof(_hidReportDescriptor)), + D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01) +}; + +//================================================================================ +//================================================================================ +// Driver + +u8 _hid_protocol = 1; +u8 _hid_idle = 1; + +#define WEAK __attribute__ ((weak)) + +int WEAK HID_GetInterface(u8* interfaceNum) +{ + interfaceNum[0] += 1; // uses 1 + return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface)); +} + +int WEAK HID_GetDescriptor(int i) +{ + return USB_SendControl(TRANSFER_PGM,_hidReportDescriptor,sizeof(_hidReportDescriptor)); +} + +void WEAK HID_SendReport(u8 id, const void* data, int len) +{ + USB_Send(HID_TX, &id, 1); + USB_Send(HID_TX | TRANSFER_RELEASE,data,len); +} + +bool WEAK HID_Setup(Setup& setup) +{ + u8 r = setup.bRequest; + u8 requestType = setup.bmRequestType; + if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType) + { + if (HID_GET_REPORT == r) + { + //HID_GetReport(); + return true; + } + if (HID_GET_PROTOCOL == r) + { + //Send8(_hid_protocol); // TODO + return true; + } + } + + if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType) + { + if (HID_SET_PROTOCOL == r) + { + _hid_protocol = setup.wValueL; + return true; + } + + if (HID_SET_IDLE == r) + { + _hid_idle = setup.wValueL; + return true; + } + } + return false; +} + +//================================================================================ +//================================================================================ +// Mouse + +Mouse_::Mouse_(void) : _buttons(0) +{ +} + +void Mouse_::begin(void) +{ +} + +void Mouse_::end(void) +{ +} + +void Mouse_::click(uint8_t b) +{ + _buttons = b; + move(0,0,0); + _buttons = 0; + move(0,0,0); +} + +void Mouse_::move(signed char x, signed char y, signed char wheel) +{ + u8 m[4]; + m[0] = _buttons; + m[1] = x; + m[2] = y; + m[3] = wheel; + HID_SendReport(1,m,4); +} + +void Mouse_::buttons(uint8_t b) +{ + if (b != _buttons) + { + _buttons = b; + move(0,0,0); + } +} + +void Mouse_::press(uint8_t b) +{ + buttons(_buttons | b); +} + +void Mouse_::release(uint8_t b) +{ + buttons(_buttons & ~b); +} + +bool Mouse_::isPressed(uint8_t b) +{ + if ((b & _buttons) > 0) + return true; + return false; +} + +//================================================================================ +//================================================================================ +// Keyboard + +Keyboard_::Keyboard_(void) +{ +} + +void Keyboard_::begin(void) +{ +} + +void Keyboard_::end(void) +{ +} + +void Keyboard_::sendReport(KeyReport* keys) +{ + HID_SendReport(2,keys,sizeof(KeyReport)); +} + +extern +const uint8_t _asciimap[128] PROGMEM; + +#define SHIFT 0x80 +const uint8_t _asciimap[128] = +{ + 0x00, // NUL + 0x00, // SOH + 0x00, // STX + 0x00, // ETX + 0x00, // EOT + 0x00, // ENQ + 0x00, // ACK + 0x00, // BEL + 0x2a, // BS Backspace + 0x2b, // TAB Tab + 0x28, // LF Enter + 0x00, // VT + 0x00, // FF + 0x00, // CR + 0x00, // SO + 0x00, // SI + 0x00, // DEL + 0x00, // DC1 + 0x00, // DC2 + 0x00, // DC3 + 0x00, // DC4 + 0x00, // NAK + 0x00, // SYN + 0x00, // ETB + 0x00, // CAN + 0x00, // EM + 0x00, // SUB + 0x00, // ESC + 0x00, // FS + 0x00, // GS + 0x00, // RS + 0x00, // US + + 0x2c, // ' ' + 0x1e|SHIFT, // ! + 0x34|SHIFT, // " + 0x20|SHIFT, // # + 0x21|SHIFT, // $ + 0x22|SHIFT, // % + 0x24|SHIFT, // & + 0x34, // ' + 0x26|SHIFT, // ( + 0x27|SHIFT, // ) + 0x25|SHIFT, // * + 0x2e|SHIFT, // + + 0x36, // , + 0x2d, // - + 0x37, // . + 0x38, // / + 0x27, // 0 + 0x1e, // 1 + 0x1f, // 2 + 0x20, // 3 + 0x21, // 4 + 0x22, // 5 + 0x23, // 6 + 0x24, // 7 + 0x25, // 8 + 0x26, // 9 + 0x33|SHIFT, // : + 0x33, // ; + 0x36|SHIFT, // < + 0x2e, // = + 0x37|SHIFT, // > + 0x38|SHIFT, // ? + 0x1f|SHIFT, // @ + 0x04|SHIFT, // A + 0x05|SHIFT, // B + 0x06|SHIFT, // C + 0x07|SHIFT, // D + 0x08|SHIFT, // E + 0x09|SHIFT, // F + 0x0a|SHIFT, // G + 0x0b|SHIFT, // H + 0x0c|SHIFT, // I + 0x0d|SHIFT, // J + 0x0e|SHIFT, // K + 0x0f|SHIFT, // L + 0x10|SHIFT, // M + 0x11|SHIFT, // N + 0x12|SHIFT, // O + 0x13|SHIFT, // P + 0x14|SHIFT, // Q + 0x15|SHIFT, // R + 0x16|SHIFT, // S + 0x17|SHIFT, // T + 0x18|SHIFT, // U + 0x19|SHIFT, // V + 0x1a|SHIFT, // W + 0x1b|SHIFT, // X + 0x1c|SHIFT, // Y + 0x1d|SHIFT, // Z + 0x2f, // [ + 0x31, // bslash + 0x30, // ] + 0x23|SHIFT, // ^ + 0x2d|SHIFT, // _ + 0x35, // ` + 0x04, // a + 0x05, // b + 0x06, // c + 0x07, // d + 0x08, // e + 0x09, // f + 0x0a, // g + 0x0b, // h + 0x0c, // i + 0x0d, // j + 0x0e, // k + 0x0f, // l + 0x10, // m + 0x11, // n + 0x12, // o + 0x13, // p + 0x14, // q + 0x15, // r + 0x16, // s + 0x17, // t + 0x18, // u + 0x19, // v + 0x1a, // w + 0x1b, // x + 0x1c, // y + 0x1d, // z + 0x2f|SHIFT, // + 0x31|SHIFT, // | + 0x30|SHIFT, // } + 0x35|SHIFT, // ~ + 0 // DEL +}; + +uint8_t USBPutChar(uint8_t c); + +// press() adds the specified key (printing, non-printing, or modifier) +// to the persistent key report and sends the report. Because of the way +// USB HID works, the host acts like the key remains pressed until we +// call release(), releaseAll(), or otherwise clear the report and resend. +size_t Keyboard_::press(uint8_t k) +{ + uint8_t i; + if (k >= 136) { // it's a non-printing key (not a modifier) + k = k - 136; + } else if (k >= 128) { // it's a modifier key + _keyReport.modifiers |= (1<<(k-128)); + k = 0; + } else { // it's a printing key + k = pgm_read_byte(_asciimap + k); + if (!k) { + setWriteError(); + return 0; + } + if (k & 0x80) { // it's a capital letter or other character reached with shift + _keyReport.modifiers |= 0x02; // the left shift modifier + k &= 0x7F; + } + } + + // Add k to the key report only if it's not already present + // and if there is an empty slot. + if (_keyReport.keys[0] != k && _keyReport.keys[1] != k && + _keyReport.keys[2] != k && _keyReport.keys[3] != k && + _keyReport.keys[4] != k && _keyReport.keys[5] != k) { + + for (i=0; i<6; i++) { + if (_keyReport.keys[i] == 0x00) { + _keyReport.keys[i] = k; + break; + } + } + if (i == 6) { + setWriteError(); + return 0; + } + } + sendReport(&_keyReport); + return 1; +} + +// release() takes the specified key out of the persistent key report and +// sends the report. This tells the OS the key is no longer pressed and that +// it shouldn't be repeated any more. +size_t Keyboard_::release(uint8_t k) +{ + uint8_t i; + if (k >= 136) { // it's a non-printing key (not a modifier) + k = k - 136; + } else if (k >= 128) { // it's a modifier key + _keyReport.modifiers &= ~(1<<(k-128)); + k = 0; + } else { // it's a printing key + k = pgm_read_byte(_asciimap + k); + if (!k) { + return 0; + } + if (k & 0x80) { // it's a capital letter or other character reached with shift + _keyReport.modifiers &= ~(0x02); // the left shift modifier + k &= 0x7F; + } + } + + // Test the key report to see if k is present. Clear it if it exists. + // Check all positions in case the key is present more than once (which it shouldn't be) + for (i=0; i<6; i++) { + if (0 != k && _keyReport.keys[i] == k) { + _keyReport.keys[i] = 0x00; + } + } + + sendReport(&_keyReport); + return 1; +} + +void Keyboard_::releaseAll(void) +{ + _keyReport.keys[0] = 0; + _keyReport.keys[1] = 0; + _keyReport.keys[2] = 0; + _keyReport.keys[3] = 0; + _keyReport.keys[4] = 0; + _keyReport.keys[5] = 0; + _keyReport.modifiers = 0; + sendReport(&_keyReport); +} + +size_t Keyboard_::write(uint8_t c) +{ + uint8_t p = press(c); // Keydown + uint8_t r = release(c); // Keyup + return (p); // just return the result of press() since release() almost always returns 1 +} + +#endif + +#endif /* if defined(USBCON) */ \ No newline at end of file diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.cpp new file mode 100644 index 000000000..f40ddee06 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.cpp @@ -0,0 +1,428 @@ +/* + HardwareSerial.cpp - Hardware serial library for Wiring + Copyright (c) 2006 Nicholas Zambetti. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 23 November 2006 by David A. Mellis + Modified 28 September 2010 by Mark Sproul +*/ + +#include +#include +#include +#include +#include "Arduino.h" +#include "wiring_private.h" + +// this next line disables the entire HardwareSerial.cpp, +// this is so I can support Attiny series and any other chip without a uart +#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H) + +#include "HardwareSerial.h" + +// Define constants and variables for buffering incoming serial data. We're +// using a ring buffer (I think), in which head is the index of the location +// to which to write the next incoming character and tail is the index of the +// location from which to read. +#if (RAMEND < 1000) + #define SERIAL_BUFFER_SIZE 16 +#else + #define SERIAL_BUFFER_SIZE 64 +#endif + +struct ring_buffer +{ + unsigned char buffer[SERIAL_BUFFER_SIZE]; + volatile unsigned int head; + volatile unsigned int tail; +}; + +#if defined(USBCON) + ring_buffer rx_buffer = { { 0 }, 0, 0}; + ring_buffer tx_buffer = { { 0 }, 0, 0}; +#endif +#if defined(UBRRH) || defined(UBRR0H) + ring_buffer rx_buffer = { { 0 }, 0, 0 }; + ring_buffer tx_buffer = { { 0 }, 0, 0 }; +#endif +#if defined(UBRR1H) + ring_buffer rx_buffer1 = { { 0 }, 0, 0 }; + ring_buffer tx_buffer1 = { { 0 }, 0, 0 }; +#endif +#if defined(UBRR2H) + ring_buffer rx_buffer2 = { { 0 }, 0, 0 }; + ring_buffer tx_buffer2 = { { 0 }, 0, 0 }; +#endif +#if defined(UBRR3H) + ring_buffer rx_buffer3 = { { 0 }, 0, 0 }; + ring_buffer tx_buffer3 = { { 0 }, 0, 0 }; +#endif + +inline void store_char(unsigned char c, ring_buffer *buffer) +{ + int i = (unsigned int)(buffer->head + 1) % SERIAL_BUFFER_SIZE; + + // if we should be storing the received character into the location + // just before the tail (meaning that the head would advance to the + // current location of the tail), we're about to overflow the buffer + // and so we don't write the character or advance the head. + if (i != buffer->tail) { + buffer->buffer[buffer->head] = c; + buffer->head = i; + } +} + +#if !defined(USART0_RX_vect) && defined(USART1_RX_vect) +// do nothing - on the 32u4 the first USART is USART1 +#else +#if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \ + !defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \ + !defined(SIG_UART_RECV) + #error "Don't know what the Data Received vector is called for the first UART" +#else + void serialEvent() __attribute__((weak)); + void serialEvent() {} + #define serialEvent_implemented +#if defined(USART_RX_vect) + SIGNAL(USART_RX_vect) +#elif defined(SIG_USART0_RECV) + SIGNAL(SIG_USART0_RECV) +#elif defined(SIG_UART0_RECV) + SIGNAL(SIG_UART0_RECV) +#elif defined(USART0_RX_vect) + SIGNAL(USART0_RX_vect) +#elif defined(SIG_UART_RECV) + SIGNAL(SIG_UART_RECV) +#endif + { + #if defined(UDR0) + unsigned char c = UDR0; + #elif defined(UDR) + unsigned char c = UDR; + #else + #error UDR not defined + #endif + store_char(c, &rx_buffer); + } +#endif +#endif + +#if defined(USART1_RX_vect) + void serialEvent1() __attribute__((weak)); + void serialEvent1() {} + #define serialEvent1_implemented + SIGNAL(USART1_RX_vect) + { + unsigned char c = UDR1; + store_char(c, &rx_buffer1); + } +#elif defined(SIG_USART1_RECV) + #error SIG_USART1_RECV +#endif + +#if defined(USART2_RX_vect) && defined(UDR2) + void serialEvent2() __attribute__((weak)); + void serialEvent2() {} + #define serialEvent2_implemented + SIGNAL(USART2_RX_vect) + { + unsigned char c = UDR2; + store_char(c, &rx_buffer2); + } +#elif defined(SIG_USART2_RECV) + #error SIG_USART2_RECV +#endif + +#if defined(USART3_RX_vect) && defined(UDR3) + void serialEvent3() __attribute__((weak)); + void serialEvent3() {} + #define serialEvent3_implemented + SIGNAL(USART3_RX_vect) + { + unsigned char c = UDR3; + store_char(c, &rx_buffer3); + } +#elif defined(SIG_USART3_RECV) + #error SIG_USART3_RECV +#endif + +void serialEventRun(void) +{ +#ifdef serialEvent_implemented + if (Serial.available()) serialEvent(); +#endif +#ifdef serialEvent1_implemented + if (Serial1.available()) serialEvent1(); +#endif +#ifdef serialEvent2_implemented + if (Serial2.available()) serialEvent2(); +#endif +#ifdef serialEvent3_implemented + if (Serial3.available()) serialEvent3(); +#endif +} + + +#if !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect) +// do nothing - on the 32u4 the first USART is USART1 +#else +#if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect) + #error "Don't know what the Data Register Empty vector is called for the first UART" +#else +#if defined(UART0_UDRE_vect) +ISR(UART0_UDRE_vect) +#elif defined(UART_UDRE_vect) +ISR(UART_UDRE_vect) +#elif defined(USART0_UDRE_vect) +ISR(USART0_UDRE_vect) +#elif defined(USART_UDRE_vect) +ISR(USART_UDRE_vect) +#endif +{ + if (tx_buffer.head == tx_buffer.tail) { + // Buffer empty, so disable interrupts +#if defined(UCSR0B) + cbi(UCSR0B, UDRIE0); +#else + cbi(UCSRB, UDRIE); +#endif + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer.buffer[tx_buffer.tail]; + tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE; + + #if defined(UDR0) + UDR0 = c; + #elif defined(UDR) + UDR = c; + #else + #error UDR not defined + #endif + } +} +#endif +#endif + +#ifdef USART1_UDRE_vect +ISR(USART1_UDRE_vect) +{ + if (tx_buffer1.head == tx_buffer1.tail) { + // Buffer empty, so disable interrupts + cbi(UCSR1B, UDRIE1); + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer1.buffer[tx_buffer1.tail]; + tx_buffer1.tail = (tx_buffer1.tail + 1) % SERIAL_BUFFER_SIZE; + + UDR1 = c; + } +} +#endif + +#ifdef USART2_UDRE_vect +ISR(USART2_UDRE_vect) +{ + if (tx_buffer2.head == tx_buffer2.tail) { + // Buffer empty, so disable interrupts + cbi(UCSR2B, UDRIE2); + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer2.buffer[tx_buffer2.tail]; + tx_buffer2.tail = (tx_buffer2.tail + 1) % SERIAL_BUFFER_SIZE; + + UDR2 = c; + } +} +#endif + +#ifdef USART3_UDRE_vect +ISR(USART3_UDRE_vect) +{ + if (tx_buffer3.head == tx_buffer3.tail) { + // Buffer empty, so disable interrupts + cbi(UCSR3B, UDRIE3); + } + else { + // There is more data in the output buffer. Send the next byte + unsigned char c = tx_buffer3.buffer[tx_buffer3.tail]; + tx_buffer3.tail = (tx_buffer3.tail + 1) % SERIAL_BUFFER_SIZE; + + UDR3 = c; + } +} +#endif + + +// Constructors //////////////////////////////////////////////////////////////// + +HardwareSerial::HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, + volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, + volatile uint8_t *ucsra, volatile uint8_t *ucsrb, + volatile uint8_t *udr, + uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x) +{ + _rx_buffer = rx_buffer; + _tx_buffer = tx_buffer; + _ubrrh = ubrrh; + _ubrrl = ubrrl; + _ucsra = ucsra; + _ucsrb = ucsrb; + _udr = udr; + _rxen = rxen; + _txen = txen; + _rxcie = rxcie; + _udrie = udrie; + _u2x = u2x; +} + +// Public Methods ////////////////////////////////////////////////////////////// + +void HardwareSerial::begin(unsigned long baud) +{ + uint16_t baud_setting; + bool use_u2x = true; + +#if F_CPU == 16000000UL + // hardcoded exception for compatibility with the bootloader shipped + // with the Duemilanove and previous boards and the firmware on the 8U2 + // on the Uno and Mega 2560. + if (baud == 57600) { + use_u2x = false; + } +#endif + +try_again: + + if (use_u2x) { + *_ucsra = 1 << _u2x; + baud_setting = (F_CPU / 4 / baud - 1) / 2; + } else { + *_ucsra = 0; + baud_setting = (F_CPU / 8 / baud - 1) / 2; + } + + if ((baud_setting > 4095) && use_u2x) + { + use_u2x = false; + goto try_again; + } + + // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register) + *_ubrrh = baud_setting >> 8; + *_ubrrl = baud_setting; + + sbi(*_ucsrb, _rxen); + sbi(*_ucsrb, _txen); + sbi(*_ucsrb, _rxcie); + cbi(*_ucsrb, _udrie); +} + +void HardwareSerial::end() +{ + // wait for transmission of outgoing data + while (_tx_buffer->head != _tx_buffer->tail) + ; + + cbi(*_ucsrb, _rxen); + cbi(*_ucsrb, _txen); + cbi(*_ucsrb, _rxcie); + cbi(*_ucsrb, _udrie); + + // clear any received data + _rx_buffer->head = _rx_buffer->tail; +} + +int HardwareSerial::available(void) +{ + return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % SERIAL_BUFFER_SIZE; +} + +int HardwareSerial::peek(void) +{ + if (_rx_buffer->head == _rx_buffer->tail) { + return -1; + } else { + return _rx_buffer->buffer[_rx_buffer->tail]; + } +} + +int HardwareSerial::read(void) +{ + // if the head isn't ahead of the tail, we don't have any characters + if (_rx_buffer->head == _rx_buffer->tail) { + return -1; + } else { + unsigned char c = _rx_buffer->buffer[_rx_buffer->tail]; + _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % SERIAL_BUFFER_SIZE; + return c; + } +} + +void HardwareSerial::flush() +{ + while (_tx_buffer->head != _tx_buffer->tail) + ; +} + +size_t HardwareSerial::write(uint8_t c) +{ + int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE; + + // If the output buffer is full, there's nothing for it other than to + // wait for the interrupt handler to empty it a bit + // ???: return 0 here instead? + while (i == _tx_buffer->tail) + ; + + _tx_buffer->buffer[_tx_buffer->head] = c; + _tx_buffer->head = i; + + sbi(*_ucsrb, _udrie); + + return 1; +} + +HardwareSerial::operator bool() { + return true; +} + +// Preinstantiate Objects ////////////////////////////////////////////////////// + +#if defined(UBRRH) && defined(UBRRL) + HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRIE, U2X); +#elif defined(UBRR0H) && defined(UBRR0L) + HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0); +#elif defined(USBCON) + // do nothing - Serial object and buffers are initialized in CDC code +#else + #error no serial port defined (port 0) +#endif + +#if defined(UBRR1H) + HardwareSerial Serial1(&rx_buffer1, &tx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRIE1, U2X1); +#endif +#if defined(UBRR2H) + HardwareSerial Serial2(&rx_buffer2, &tx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRIE2, U2X2); +#endif +#if defined(UBRR3H) + HardwareSerial Serial3(&rx_buffer3, &tx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRIE3, U2X3); +#endif + +#endif // whole file + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.h new file mode 100644 index 000000000..bf4924c6d --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/HardwareSerial.h @@ -0,0 +1,81 @@ +/* + HardwareSerial.h - Hardware serial library for Wiring + Copyright (c) 2006 Nicholas Zambetti. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 28 September 2010 by Mark Sproul +*/ + +#ifndef HardwareSerial_h +#define HardwareSerial_h + +#include + +#include "Stream.h" + +struct ring_buffer; + +class HardwareSerial : public Stream +{ + private: + ring_buffer *_rx_buffer; + ring_buffer *_tx_buffer; + volatile uint8_t *_ubrrh; + volatile uint8_t *_ubrrl; + volatile uint8_t *_ucsra; + volatile uint8_t *_ucsrb; + volatile uint8_t *_udr; + uint8_t _rxen; + uint8_t _txen; + uint8_t _rxcie; + uint8_t _udrie; + uint8_t _u2x; + public: + HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, + volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, + volatile uint8_t *ucsra, volatile uint8_t *ucsrb, + volatile uint8_t *udr, + uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); + void begin(unsigned long); + void end(); + virtual int available(void); + virtual int peek(void); + virtual int read(void); + virtual void flush(void); + virtual size_t write(uint8_t); + using Print::write; // pull in write(str) and write(buf, size) from Print + operator bool(); +}; + +#if defined(UBRRH) || defined(UBRR0H) + extern HardwareSerial Serial; +#elif defined(USBCON) + #include "USBAPI.h" +// extern HardwareSerial Serial_; +#endif +#if defined(UBRR1H) + extern HardwareSerial Serial1; +#endif +#if defined(UBRR2H) + extern HardwareSerial Serial2; +#endif +#if defined(UBRR3H) + extern HardwareSerial Serial3; +#endif + +extern void serialEventRun(void) __attribute__((weak)); + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.cpp new file mode 100644 index 000000000..fe3deb77a --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.cpp @@ -0,0 +1,56 @@ + +#include +#include + +IPAddress::IPAddress() +{ + memset(_address, 0, sizeof(_address)); +} + +IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) +{ + _address[0] = first_octet; + _address[1] = second_octet; + _address[2] = third_octet; + _address[3] = fourth_octet; +} + +IPAddress::IPAddress(uint32_t address) +{ + memcpy(_address, &address, sizeof(_address)); +} + +IPAddress::IPAddress(const uint8_t *address) +{ + memcpy(_address, address, sizeof(_address)); +} + +IPAddress& IPAddress::operator=(const uint8_t *address) +{ + memcpy(_address, address, sizeof(_address)); + return *this; +} + +IPAddress& IPAddress::operator=(uint32_t address) +{ + memcpy(_address, (const uint8_t *)&address, sizeof(_address)); + return *this; +} + +bool IPAddress::operator==(const uint8_t* addr) +{ + return memcmp(addr, _address, sizeof(_address)) == 0; +} + +size_t IPAddress::printTo(Print& p) const +{ + size_t n = 0; + for (int i =0; i < 3; i++) + { + n += p.print(_address[i], DEC); + n += p.print('.'); + } + n += p.print(_address[3], DEC); + return n; +} + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.h new file mode 100644 index 000000000..2585aec0e --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/IPAddress.h @@ -0,0 +1,76 @@ +/* + * + * MIT License: + * Copyright (c) 2011 Adrian McEwen + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * adrianm@mcqn.com 1/1/2011 + */ + +#ifndef IPAddress_h +#define IPAddress_h + +#include + +// A class to make it easier to handle and pass around IP addresses + +class IPAddress : public Printable { +private: + uint8_t _address[4]; // IPv4 address + // Access the raw byte array containing the address. Because this returns a pointer + // to the internal structure rather than a copy of the address this function should only + // be used when you know that the usage of the returned uint8_t* will be transient and not + // stored. + uint8_t* raw_address() { return _address; }; + +public: + // Constructors + IPAddress(); + IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet); + IPAddress(uint32_t address); + IPAddress(const uint8_t *address); + + // Overloaded cast operator to allow IPAddress objects to be used where a pointer + // to a four-byte uint8_t array is expected + operator uint32_t() { return *((uint32_t*)_address); }; + bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); }; + bool operator==(const uint8_t* addr); + + // Overloaded index operator to allow getting and setting individual octets of the address + uint8_t operator[](int index) const { return _address[index]; }; + uint8_t& operator[](int index) { return _address[index]; }; + + // Overloaded copy operators to allow initialisation of IPAddress objects from other types + IPAddress& operator=(const uint8_t *address); + IPAddress& operator=(uint32_t address); + + virtual size_t printTo(Print& p) const; + + friend class EthernetClass; + friend class UDP; + friend class Client; + friend class Server; + friend class DhcpClass; + friend class DNSClient; +}; + +const IPAddress INADDR_NONE(0,0,0,0); + + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Platform.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Platform.h new file mode 100644 index 000000000..8b8f74277 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Platform.h @@ -0,0 +1,23 @@ + +#ifndef __PLATFORM_H__ +#define __PLATFORM_H__ + +#include +#include +#include +#include +#include + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned long u32; + +#include "Arduino.h" + +#if defined(USBCON) + #include "USBDesc.h" + #include "USBCore.h" + #include "USBAPI.h" +#endif /* if defined(USBCON) */ + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.cpp new file mode 100644 index 000000000..e541a6ce7 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.cpp @@ -0,0 +1,263 @@ +/* + Print.cpp - Base class that provides print() and println() + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Modified 23 November 2006 by David A. Mellis + */ + +#include +#include +#include +#include +#include "Arduino.h" + +#include "Print.h" + +// Public Methods ////////////////////////////////////////////////////////////// + +/* default implementation: may be overridden */ +size_t Print::write(const uint8_t *buffer, size_t size) +{ + size_t n = 0; + while (size--) { + n += write(*buffer++); + } + return n; +} + +size_t Print::print(const __FlashStringHelper *ifsh) +{ + const char PROGMEM *p = (const char PROGMEM *)ifsh; + size_t n = 0; + while (1) { + unsigned char c = pgm_read_byte(p++); + if (c == 0) break; + n += write(c); + } + return n; +} + +size_t Print::print(const String &s) +{ + size_t n = 0; + for (uint16_t i = 0; i < s.length(); i++) { + n += write(s[i]); + } + return n; +} + +size_t Print::print(const char str[]) +{ + return write(str); +} + +size_t Print::print(char c) +{ + return write(c); +} + +size_t Print::print(unsigned char b, int base) +{ + return print((unsigned long) b, base); +} + +size_t Print::print(int n, int base) +{ + return print((long) n, base); +} + +size_t Print::print(unsigned int n, int base) +{ + return print((unsigned long) n, base); +} + +size_t Print::print(long n, int base) +{ + if (base == 0) { + return write(n); + } else if (base == 10) { + if (n < 0) { + int t = print('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } else { + return printNumber(n, base); + } +} + +size_t Print::print(unsigned long n, int base) +{ + if (base == 0) return write(n); + else return printNumber(n, base); +} + +size_t Print::print(double n, int digits) +{ + return printFloat(n, digits); +} + +size_t Print::println(const __FlashStringHelper *ifsh) +{ + size_t n = print(ifsh); + n += println(); + return n; +} + +size_t Print::print(const Printable& x) +{ + return x.printTo(*this); +} + +size_t Print::println(void) +{ + size_t n = print('\r'); + n += print('\n'); + return n; +} + +size_t Print::println(const String &s) +{ + size_t n = print(s); + n += println(); + return n; +} + +size_t Print::println(const char c[]) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(char c) +{ + size_t n = print(c); + n += println(); + return n; +} + +size_t Print::println(unsigned char b, int base) +{ + size_t n = print(b, base); + n += println(); + return n; +} + +size_t Print::println(int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned int num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(unsigned long num, int base) +{ + size_t n = print(num, base); + n += println(); + return n; +} + +size_t Print::println(double num, int digits) +{ + size_t n = print(num, digits); + n += println(); + return n; +} + +size_t Print::println(const Printable& x) +{ + size_t n = print(x); + n += println(); + return n; +} + +// Private Methods ///////////////////////////////////////////////////////////// + +size_t Print::printNumber(unsigned long n, uint8_t base) { + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if (base < 2) base = 10; + + do { + unsigned long m = n; + n /= base; + char c = m - base * n; + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } while(n); + + return write(str); +} + +size_t Print::printFloat(double number, uint8_t digits) +{ + size_t n = 0; + + // Handle negative numbers + if (number < 0.0) + { + n += print('-'); + number = -number; + } + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + for (uint8_t i=0; i 0) { + n += print("."); + } + + // Extract digits from the remainder one at a time + while (digits-- > 0) + { + remainder *= 10.0; + int toPrint = int(remainder); + n += print(toPrint); + remainder -= toPrint; + } + + return n; +} diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.h new file mode 100644 index 000000000..1af6b723f --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Print.h @@ -0,0 +1,78 @@ +/* + Print.h - Base class that provides print() and println() + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Print_h +#define Print_h + +#include +#include // for size_t + +#include "WString.h" +#include "Printable.h" + +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 + +class Print +{ + private: + int write_error; + size_t printNumber(unsigned long, uint8_t); + size_t printFloat(double, uint8_t); + protected: + void setWriteError(int err = 1) { write_error = err; } + public: + Print() : write_error(0) {} + + int getWriteError() { return write_error; } + void clearWriteError() { setWriteError(0); } + + virtual size_t write(uint8_t) = 0; + size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); } + virtual size_t write(const uint8_t *buffer, size_t size); + + size_t print(const __FlashStringHelper *); + size_t print(const String &); + size_t print(const char[]); + size_t print(char); + size_t print(unsigned char, int = DEC); + size_t print(int, int = DEC); + size_t print(unsigned int, int = DEC); + size_t print(long, int = DEC); + size_t print(unsigned long, int = DEC); + size_t print(double, int = 2); + size_t print(const Printable&); + + size_t println(const __FlashStringHelper *); + size_t println(const String &s); + size_t println(const char[]); + size_t println(char); + size_t println(unsigned char, int = DEC); + size_t println(int, int = DEC); + size_t println(unsigned int, int = DEC); + size_t println(long, int = DEC); + size_t println(unsigned long, int = DEC); + size_t println(double, int = 2); + size_t println(const Printable&); + size_t println(void); +}; + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Printable.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Printable.h new file mode 100644 index 000000000..d03c9af62 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Printable.h @@ -0,0 +1,40 @@ +/* + Printable.h - Interface class that allows printing of complex types + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef Printable_h +#define Printable_h + +#include + +class Print; + +/** The Printable class provides a way for new classes to allow themselves to be printed. + By deriving from Printable and implementing the printTo method, it will then be possible + for users to print out instances of this class by passing them into the usual + Print::print and Print::println methods. +*/ + +class Printable +{ + public: + virtual size_t printTo(Print& p) const = 0; +}; + +#endif + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Server.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Server.h new file mode 100644 index 000000000..9674c7626 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Server.h @@ -0,0 +1,9 @@ +#ifndef server_h +#define server_h + +class Server : public Print { +public: + virtual void begin() =0; +}; + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.cpp new file mode 100644 index 000000000..aafb7fcf9 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.cpp @@ -0,0 +1,270 @@ +/* + Stream.cpp - adds parsing methods to Stream class + Copyright (c) 2008 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Created July 2011 + parsing functions based on TextFinder library by Michael Margolis + */ + +#include "Arduino.h" +#include "Stream.h" + +#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait +#define NO_SKIP_CHAR 1 // a magic char not found in a valid ASCII numeric field + +// private method to read stream with timeout +int Stream::timedRead() +{ + int c; + _startMillis = millis(); + do { + c = read(); + if (c >= 0) return c; + } while(millis() - _startMillis < _timeout); + return -1; // -1 indicates timeout +} + +// private method to peek stream with timeout +int Stream::timedPeek() +{ + int c; + _startMillis = millis(); + do { + c = peek(); + if (c >= 0) return c; + } while(millis() - _startMillis < _timeout); + return -1; // -1 indicates timeout +} + +// returns peek of the next digit in the stream or -1 if timeout +// discards non-numeric characters +int Stream::peekNextDigit() +{ + int c; + while (1) { + c = timedPeek(); + if (c < 0) return c; // timeout + if (c == '-') return c; + if (c >= '0' && c <= '9') return c; + read(); // discard non-numeric + } +} + +// Public Methods +////////////////////////////////////////////////////////////// + +void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait +{ + _timeout = timeout; +} + + // find returns true if the target string is found +bool Stream::find(char *target) +{ + return findUntil(target, NULL); +} + +// reads data from the stream until the target string of given length is found +// returns true if target string is found, false if timed out +bool Stream::find(char *target, size_t length) +{ + return findUntil(target, length, NULL, 0); +} + +// as find but search ends if the terminator string is found +bool Stream::findUntil(char *target, char *terminator) +{ + return findUntil(target, strlen(target), terminator, strlen(terminator)); +} + +// reads data from the stream until the target string of the given length is found +// search terminated if the terminator string is found +// returns true if target string is found, false if terminated or timed out +bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen) +{ + size_t index = 0; // maximum target string length is 64k bytes! + size_t termIndex = 0; + int c; + + if( *target == 0) + return true; // return true if target is a null string + while( (c = timedRead()) > 0){ + + if(c != target[index]) + index = 0; // reset index if any char does not match + + if( c == target[index]){ + //////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1); + if(++index >= targetLen){ // return true if all chars in the target match + return true; + } + } + + if(termLen > 0 && c == terminator[termIndex]){ + if(++termIndex >= termLen) + return false; // return false if terminate string found before target string + } + else + termIndex = 0; + } + return false; +} + + +// returns the first valid (long) integer value from the current position. +// initial characters that are not digits (or the minus sign) are skipped +// function is terminated by the first character that is not a digit. +long Stream::parseInt() +{ + return parseInt(NO_SKIP_CHAR); // terminate on first non-digit character (or timeout) +} + +// as above but a given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +long Stream::parseInt(char skipChar) +{ + boolean isNegative = false; + long value = 0; + int c; + + c = peekNextDigit(); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if(c == skipChar) + ; // ignore this charactor + else if(c == '-') + isNegative = true; + else if(c >= '0' && c <= '9') // is c a digit? + value = value * 10 + c - '0'; + read(); // consume the character we got with peek + c = timedPeek(); + } + while( (c >= '0' && c <= '9') || c == skipChar ); + + if(isNegative) + value = -value; + return value; +} + + +// as parseInt but returns a floating point value +float Stream::parseFloat() +{ + return parseFloat(NO_SKIP_CHAR); +} + +// as above but the given skipChar is ignored +// this allows format characters (typically commas) in values to be ignored +float Stream::parseFloat(char skipChar){ + boolean isNegative = false; + boolean isFraction = false; + long value = 0; + char c; + float fraction = 1.0; + + c = peekNextDigit(); + // ignore non numeric leading characters + if(c < 0) + return 0; // zero returned if timeout + + do{ + if(c == skipChar) + ; // ignore + else if(c == '-') + isNegative = true; + else if (c == '.') + isFraction = true; + else if(c >= '0' && c <= '9') { // is c a digit? + value = value * 10 + c - '0'; + if(isFraction) + fraction *= 0.1; + } + read(); // consume the character we got with peek + c = timedPeek(); + } + while( (c >= '0' && c <= '9') || c == '.' || c == skipChar ); + + if(isNegative) + value = -value; + if(isFraction) + return value * fraction; + else + return value; +} + +// read characters from stream into buffer +// terminates if length characters have been read, or timeout (see setTimeout) +// returns the number of characters placed in the buffer +// the buffer is NOT null terminated. +// +size_t Stream::readBytes(char *buffer, size_t length) +{ + size_t count = 0; + while (count < length) { + int c = timedRead(); + if (c < 0) break; + *buffer++ = (char)c; + count++; + } + return count; +} + + +// as readBytes with terminator character +// terminates if length characters have been read, timeout, or if the terminator character detected +// returns the number of characters placed in the buffer (0 means no valid data found) + +size_t Stream::readBytesUntil(char terminator, char *buffer, size_t length) +{ + if (length < 1) return 0; + size_t index = 0; + while (index < length) { + int c = timedRead(); + if (c < 0 || c == terminator) break; + *buffer++ = (char)c; + index++; + } + return index; // return number of characters, not including null terminator +} + +String Stream::readString() +{ + String ret; + int c = timedRead(); + while (c >= 0) + { + ret += (char)c; + c = timedRead(); + } + return ret; +} + +String Stream::readStringUntil(char terminator) +{ + String ret; + int c = timedRead(); + while (c >= 0 && c != terminator) + { + ret += (char)c; + c = timedRead(); + } + return ret; +} + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.h new file mode 100644 index 000000000..58bbf752f --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Stream.h @@ -0,0 +1,96 @@ +/* + Stream.h - base class for character-based streams. + Copyright (c) 2010 David A. Mellis. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + parsing functions based on TextFinder library by Michael Margolis +*/ + +#ifndef Stream_h +#define Stream_h + +#include +#include "Print.h" + +// compatability macros for testing +/* +#define getInt() parseInt() +#define getInt(skipChar) parseInt(skipchar) +#define getFloat() parseFloat() +#define getFloat(skipChar) parseFloat(skipChar) +#define getString( pre_string, post_string, buffer, length) +readBytesBetween( pre_string, terminator, buffer, length) +*/ + +class Stream : public Print +{ + private: + unsigned long _timeout; // number of milliseconds to wait for the next char before aborting timed read + unsigned long _startMillis; // used for timeout measurement + int timedRead(); // private method to read stream with timeout + int timedPeek(); // private method to peek stream with timeout + int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout + + public: + virtual int available() = 0; + virtual int read() = 0; + virtual int peek() = 0; + virtual void flush() = 0; + + Stream() {_timeout=1000;} + +// parsing methods + + void setTimeout(unsigned long timeout); // sets maximum milliseconds to wait for stream data, default is 1 second + + bool find(char *target); // reads data from the stream until the target string is found + // returns true if target string is found, false if timed out (see setTimeout) + + bool find(char *target, size_t length); // reads data from the stream until the target string of given length is found + // returns true if target string is found, false if timed out + + bool findUntil(char *target, char *terminator); // as find but search ends if the terminator string is found + + bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen); // as above but search ends if the terminate string is found + + + long parseInt(); // returns the first valid (long) integer value from the current position. + // initial characters that are not digits (or the minus sign) are skipped + // integer is terminated by the first character that is not a digit. + + float parseFloat(); // float version of parseInt + + size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer + // terminates if length characters have been read or timeout (see setTimeout) + // returns the number of characters placed in the buffer (0 means no valid data found) + + size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character + // terminates if length characters have been read, timeout, or if the terminator character detected + // returns the number of characters placed in the buffer (0 means no valid data found) + + // Arduino String functions to be added here + String readString(); + String readStringUntil(char terminator); + + protected: + long parseInt(char skipChar); // as above but the given skipChar is ignored + // as above but the given skipChar is ignored + // this allows format characters (typically commas) in values to be ignored + + float parseFloat(char skipChar); // as above but the given skipChar is ignored +}; + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Tone.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Tone.cpp new file mode 100644 index 000000000..20eed3f48 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Tone.cpp @@ -0,0 +1,601 @@ +/* Tone.cpp + + A Tone Generator Library + + Written by Brett Hagman + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Version Modified By Date Comments +------- ----------- -------- -------- +0001 B Hagman 09/08/02 Initial coding +0002 B Hagman 09/08/18 Multiple pins +0003 B Hagman 09/08/18 Moved initialization from constructor to begin() +0004 B Hagman 09/09/26 Fixed problems with ATmega8 +0005 B Hagman 09/11/23 Scanned prescalars for best fit on 8 bit timers + 09/11/25 Changed pin toggle method to XOR + 09/11/25 Fixed timer0 from being excluded +0006 D Mellis 09/12/29 Replaced objects with functions +0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register +*************************************************/ + +#include +#include +#include "Arduino.h" +#include "pins_arduino.h" + +#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) +#define TCCR2A TCCR2 +#define TCCR2B TCCR2 +#define COM2A1 COM21 +#define COM2A0 COM20 +#define OCR2A OCR2 +#define TIMSK2 TIMSK +#define OCIE2A OCIE2 +#define TIMER2_COMPA_vect TIMER2_COMP_vect +#define TIMSK1 TIMSK +#endif + +// timerx_toggle_count: +// > 0 - duration specified +// = 0 - stopped +// < 0 - infinitely (until stop() method called, or new play() called) + +#if !defined(__AVR_ATmega8__) +volatile long timer0_toggle_count; +volatile uint8_t *timer0_pin_port; +volatile uint8_t timer0_pin_mask; +#endif + +volatile long timer1_toggle_count; +volatile uint8_t *timer1_pin_port; +volatile uint8_t timer1_pin_mask; +volatile long timer2_toggle_count; +volatile uint8_t *timer2_pin_port; +volatile uint8_t timer2_pin_mask; + +#if defined(TIMSK3) +volatile long timer3_toggle_count; +volatile uint8_t *timer3_pin_port; +volatile uint8_t timer3_pin_mask; +#endif + +#if defined(TIMSK4) +volatile long timer4_toggle_count; +volatile uint8_t *timer4_pin_port; +volatile uint8_t timer4_pin_mask; +#endif + +#if defined(TIMSK5) +volatile long timer5_toggle_count; +volatile uint8_t *timer5_pin_port; +volatile uint8_t timer5_pin_mask; +#endif + + +// MLS: This does not make sense, the 3 options are the same +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + +#define AVAILABLE_TONE_PINS 1 + +const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 3, 4, 5, 1, 0 */ }; +static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255, 255, 255, 255 */ }; + +#elif defined(__AVR_ATmega8__) + +#define AVAILABLE_TONE_PINS 1 + +const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1 */ }; +static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255 */ }; + +#else + +#define AVAILABLE_TONE_PINS 1 + +// Leave timer 0 to last. +const uint8_t PROGMEM tone_pin_to_timer_PGM[] = { 2 /*, 1, 0 */ }; +static uint8_t tone_pins[AVAILABLE_TONE_PINS] = { 255 /*, 255, 255 */ }; + +#endif + + + +static int8_t toneBegin(uint8_t _pin) +{ + int8_t _timer = -1; + + // if we're already using the pin, the timer should be configured. + for (int i = 0; i < AVAILABLE_TONE_PINS; i++) { + if (tone_pins[i] == _pin) { + return pgm_read_byte(tone_pin_to_timer_PGM + i); + } + } + + // search for an unused timer. + for (int i = 0; i < AVAILABLE_TONE_PINS; i++) { + if (tone_pins[i] == 255) { + tone_pins[i] = _pin; + _timer = pgm_read_byte(tone_pin_to_timer_PGM + i); + break; + } + } + + if (_timer != -1) + { + // Set timer specific stuff + // All timers in CTC mode + // 8 bit timers will require changing prescalar values, + // whereas 16 bit timers are set to either ck/1 or ck/64 prescalar + switch (_timer) + { + #if defined(TCCR0A) && defined(TCCR0B) + case 0: + // 8 bit timer + TCCR0A = 0; + TCCR0B = 0; + bitWrite(TCCR0A, WGM01, 1); + bitWrite(TCCR0B, CS00, 1); + timer0_pin_port = portOutputRegister(digitalPinToPort(_pin)); + timer0_pin_mask = digitalPinToBitMask(_pin); + break; + #endif + + #if defined(TCCR1A) && defined(TCCR1B) && defined(WGM12) + case 1: + // 16 bit timer + TCCR1A = 0; + TCCR1B = 0; + bitWrite(TCCR1B, WGM12, 1); + bitWrite(TCCR1B, CS10, 1); + timer1_pin_port = portOutputRegister(digitalPinToPort(_pin)); + timer1_pin_mask = digitalPinToBitMask(_pin); + break; + #endif + + #if defined(TCCR2A) && defined(TCCR2B) + case 2: + // 8 bit timer + TCCR2A = 0; + TCCR2B = 0; + bitWrite(TCCR2A, WGM21, 1); + bitWrite(TCCR2B, CS20, 1); + timer2_pin_port = portOutputRegister(digitalPinToPort(_pin)); + timer2_pin_mask = digitalPinToBitMask(_pin); + break; + #endif + + #if defined(TCCR3A) && defined(TCCR3B) && defined(TIMSK3) + case 3: + // 16 bit timer + TCCR3A = 0; + TCCR3B = 0; + bitWrite(TCCR3B, WGM32, 1); + bitWrite(TCCR3B, CS30, 1); + timer3_pin_port = portOutputRegister(digitalPinToPort(_pin)); + timer3_pin_mask = digitalPinToBitMask(_pin); + break; + #endif + + #if defined(TCCR4A) && defined(TCCR4B) && defined(TIMSK4) + case 4: + // 16 bit timer + TCCR4A = 0; + TCCR4B = 0; + #if defined(WGM42) + bitWrite(TCCR4B, WGM42, 1); + #elif defined(CS43) + #warning this may not be correct + // atmega32u4 + bitWrite(TCCR4B, CS43, 1); + #endif + bitWrite(TCCR4B, CS40, 1); + timer4_pin_port = portOutputRegister(digitalPinToPort(_pin)); + timer4_pin_mask = digitalPinToBitMask(_pin); + break; + #endif + + #if defined(TCCR5A) && defined(TCCR5B) && defined(TIMSK5) + case 5: + // 16 bit timer + TCCR5A = 0; + TCCR5B = 0; + bitWrite(TCCR5B, WGM52, 1); + bitWrite(TCCR5B, CS50, 1); + timer5_pin_port = portOutputRegister(digitalPinToPort(_pin)); + timer5_pin_mask = digitalPinToBitMask(_pin); + break; + #endif + } + } + + return _timer; +} + + + +// frequency (in hertz) and duration (in milliseconds). + +void tone(uint8_t _pin, unsigned int frequency, unsigned long duration) +{ + uint8_t prescalarbits = 0b001; + long toggle_count = 0; + uint32_t ocr = 0; + int8_t _timer; + + _timer = toneBegin(_pin); + + if (_timer >= 0) + { + // Set the pinMode as OUTPUT + pinMode(_pin, OUTPUT); + + // if we are using an 8 bit timer, scan through prescalars to find the best fit + if (_timer == 0 || _timer == 2) + { + ocr = F_CPU / frequency / 2 - 1; + prescalarbits = 0b001; // ck/1: same for both timers + if (ocr > 255) + { + ocr = F_CPU / frequency / 2 / 8 - 1; + prescalarbits = 0b010; // ck/8: same for both timers + + if (_timer == 2 && ocr > 255) + { + ocr = F_CPU / frequency / 2 / 32 - 1; + prescalarbits = 0b011; + } + + if (ocr > 255) + { + ocr = F_CPU / frequency / 2 / 64 - 1; + prescalarbits = _timer == 0 ? 0b011 : 0b100; + + if (_timer == 2 && ocr > 255) + { + ocr = F_CPU / frequency / 2 / 128 - 1; + prescalarbits = 0b101; + } + + if (ocr > 255) + { + ocr = F_CPU / frequency / 2 / 256 - 1; + prescalarbits = _timer == 0 ? 0b100 : 0b110; + if (ocr > 255) + { + // can't do any better than /1024 + ocr = F_CPU / frequency / 2 / 1024 - 1; + prescalarbits = _timer == 0 ? 0b101 : 0b111; + } + } + } + } + +#if defined(TCCR0B) + if (_timer == 0) + { + TCCR0B = prescalarbits; + } + else +#endif +#if defined(TCCR2B) + { + TCCR2B = prescalarbits; + } +#else + { + // dummy place holder to make the above ifdefs work + } +#endif + } + else + { + // two choices for the 16 bit timers: ck/1 or ck/64 + ocr = F_CPU / frequency / 2 - 1; + + prescalarbits = 0b001; + if (ocr > 0xffff) + { + ocr = F_CPU / frequency / 2 / 64 - 1; + prescalarbits = 0b011; + } + + if (_timer == 1) + { +#if defined(TCCR1B) + TCCR1B = (TCCR1B & 0b11111000) | prescalarbits; +#endif + } +#if defined(TCCR3B) + else if (_timer == 3) + TCCR3B = (TCCR3B & 0b11111000) | prescalarbits; +#endif +#if defined(TCCR4B) + else if (_timer == 4) + TCCR4B = (TCCR4B & 0b11111000) | prescalarbits; +#endif +#if defined(TCCR5B) + else if (_timer == 5) + TCCR5B = (TCCR5B & 0b11111000) | prescalarbits; +#endif + + } + + + // Calculate the toggle count + if (duration > 0) + { + toggle_count = 2 * frequency * duration / 1000; + } + else + { + toggle_count = -1; + } + + // Set the OCR for the given timer, + // set the toggle count, + // then turn on the interrupts + switch (_timer) + { + +#if defined(OCR0A) && defined(TIMSK0) && defined(OCIE0A) + case 0: + OCR0A = ocr; + timer0_toggle_count = toggle_count; + bitWrite(TIMSK0, OCIE0A, 1); + break; +#endif + + case 1: +#if defined(OCR1A) && defined(TIMSK1) && defined(OCIE1A) + OCR1A = ocr; + timer1_toggle_count = toggle_count; + bitWrite(TIMSK1, OCIE1A, 1); +#elif defined(OCR1A) && defined(TIMSK) && defined(OCIE1A) + // this combination is for at least the ATmega32 + OCR1A = ocr; + timer1_toggle_count = toggle_count; + bitWrite(TIMSK, OCIE1A, 1); +#endif + break; + +#if defined(OCR2A) && defined(TIMSK2) && defined(OCIE2A) + case 2: + OCR2A = ocr; + timer2_toggle_count = toggle_count; + bitWrite(TIMSK2, OCIE2A, 1); + break; +#endif + +#if defined(TIMSK3) + case 3: + OCR3A = ocr; + timer3_toggle_count = toggle_count; + bitWrite(TIMSK3, OCIE3A, 1); + break; +#endif + +#if defined(TIMSK4) + case 4: + OCR4A = ocr; + timer4_toggle_count = toggle_count; + bitWrite(TIMSK4, OCIE4A, 1); + break; +#endif + +#if defined(OCR5A) && defined(TIMSK5) && defined(OCIE5A) + case 5: + OCR5A = ocr; + timer5_toggle_count = toggle_count; + bitWrite(TIMSK5, OCIE5A, 1); + break; +#endif + + } + } +} + + +// XXX: this function only works properly for timer 2 (the only one we use +// currently). for the others, it should end the tone, but won't restore +// proper PWM functionality for the timer. +void disableTimer(uint8_t _timer) +{ + switch (_timer) + { + case 0: + #if defined(TIMSK0) + TIMSK0 = 0; + #elif defined(TIMSK) + TIMSK = 0; // atmega32 + #endif + break; + +#if defined(TIMSK1) && defined(OCIE1A) + case 1: + bitWrite(TIMSK1, OCIE1A, 0); + break; +#endif + + case 2: + #if defined(TIMSK2) && defined(OCIE2A) + bitWrite(TIMSK2, OCIE2A, 0); // disable interrupt + #endif + #if defined(TCCR2A) && defined(WGM20) + TCCR2A = (1 << WGM20); + #endif + #if defined(TCCR2B) && defined(CS22) + TCCR2B = (TCCR2B & 0b11111000) | (1 << CS22); + #endif + #if defined(OCR2A) + OCR2A = 0; + #endif + break; + +#if defined(TIMSK3) + case 3: + TIMSK3 = 0; + break; +#endif + +#if defined(TIMSK4) + case 4: + TIMSK4 = 0; + break; +#endif + +#if defined(TIMSK5) + case 5: + TIMSK5 = 0; + break; +#endif + } +} + + +void noTone(uint8_t _pin) +{ + int8_t _timer = -1; + + for (int i = 0; i < AVAILABLE_TONE_PINS; i++) { + if (tone_pins[i] == _pin) { + _timer = pgm_read_byte(tone_pin_to_timer_PGM + i); + tone_pins[i] = 255; + } + } + + disableTimer(_timer); + + digitalWrite(_pin, 0); +} + +#if 0 +#if !defined(__AVR_ATmega8__) +ISR(TIMER0_COMPA_vect) +{ + if (timer0_toggle_count != 0) + { + // toggle the pin + *timer0_pin_port ^= timer0_pin_mask; + + if (timer0_toggle_count > 0) + timer0_toggle_count--; + } + else + { + disableTimer(0); + *timer0_pin_port &= ~(timer0_pin_mask); // keep pin low after stop + } +} +#endif + + +ISR(TIMER1_COMPA_vect) +{ + if (timer1_toggle_count != 0) + { + // toggle the pin + *timer1_pin_port ^= timer1_pin_mask; + + if (timer1_toggle_count > 0) + timer1_toggle_count--; + } + else + { + disableTimer(1); + *timer1_pin_port &= ~(timer1_pin_mask); // keep pin low after stop + } +} +#endif + + +ISR(TIMER2_COMPA_vect) +{ + + if (timer2_toggle_count != 0) + { + // toggle the pin + *timer2_pin_port ^= timer2_pin_mask; + + if (timer2_toggle_count > 0) + timer2_toggle_count--; + } + else + { + // need to call noTone() so that the tone_pins[] entry is reset, so the + // timer gets initialized next time we call tone(). + // XXX: this assumes timer 2 is always the first one used. + noTone(tone_pins[0]); +// disableTimer(2); +// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop + } +} + + + +//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#if 0 + +ISR(TIMER3_COMPA_vect) +{ + if (timer3_toggle_count != 0) + { + // toggle the pin + *timer3_pin_port ^= timer3_pin_mask; + + if (timer3_toggle_count > 0) + timer3_toggle_count--; + } + else + { + disableTimer(3); + *timer3_pin_port &= ~(timer3_pin_mask); // keep pin low after stop + } +} + +ISR(TIMER4_COMPA_vect) +{ + if (timer4_toggle_count != 0) + { + // toggle the pin + *timer4_pin_port ^= timer4_pin_mask; + + if (timer4_toggle_count > 0) + timer4_toggle_count--; + } + else + { + disableTimer(4); + *timer4_pin_port &= ~(timer4_pin_mask); // keep pin low after stop + } +} + +ISR(TIMER5_COMPA_vect) +{ + if (timer5_toggle_count != 0) + { + // toggle the pin + *timer5_pin_port ^= timer5_pin_mask; + + if (timer5_toggle_count > 0) + timer5_toggle_count--; + } + else + { + disableTimer(5); + *timer5_pin_port &= ~(timer5_pin_mask); // keep pin low after stop + } +} + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBAPI.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBAPI.h new file mode 100644 index 000000000..d5abdb690 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBAPI.h @@ -0,0 +1,195 @@ + + +#ifndef __USBAPI__ +#define __USBAPI__ + +#if defined(USBCON) + +//================================================================================ +//================================================================================ +// USB + +class USBDevice_ +{ +public: + USBDevice_(); + bool configured(); + + void attach(); + void detach(); // Serial port goes down too... + void poll(); +}; +extern USBDevice_ USBDevice; + +//================================================================================ +//================================================================================ +// Serial over CDC (Serial1 is the physical port) + +class Serial_ : public Stream +{ +private: + ring_buffer *_cdc_rx_buffer; +public: + void begin(uint16_t baud_count); + void end(void); + + virtual int available(void); + virtual void accept(void); + virtual int peek(void); + virtual int read(void); + virtual void flush(void); + virtual size_t write(uint8_t); + operator bool(); +}; +extern Serial_ Serial; + +//================================================================================ +//================================================================================ +// Mouse + +#define MOUSE_LEFT 1 +#define MOUSE_RIGHT 2 +#define MOUSE_MIDDLE 4 +#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE) + +class Mouse_ +{ +private: + uint8_t _buttons; + void buttons(uint8_t b); +public: + Mouse_(void); + void begin(void); + void end(void); + void click(uint8_t b = MOUSE_LEFT); + void move(signed char x, signed char y, signed char wheel = 0); + void press(uint8_t b = MOUSE_LEFT); // press LEFT by default + void release(uint8_t b = MOUSE_LEFT); // release LEFT by default + bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default +}; +extern Mouse_ Mouse; + +//================================================================================ +//================================================================================ +// Keyboard + +#define KEY_LEFT_CTRL 0x80 +#define KEY_LEFT_SHIFT 0x81 +#define KEY_LEFT_ALT 0x82 +#define KEY_LEFT_GUI 0x83 +#define KEY_RIGHT_CTRL 0x84 +#define KEY_RIGHT_SHIFT 0x85 +#define KEY_RIGHT_ALT 0x86 +#define KEY_RIGHT_GUI 0x87 + +#define KEY_UP_ARROW 0xDA +#define KEY_DOWN_ARROW 0xD9 +#define KEY_LEFT_ARROW 0xD8 +#define KEY_RIGHT_ARROW 0xD7 +#define KEY_BACKSPACE 0xB2 +#define KEY_TAB 0xB3 +#define KEY_RETURN 0xB0 +#define KEY_ESC 0xB1 +#define KEY_INSERT 0xD1 +#define KEY_DELETE 0xD4 +#define KEY_PAGE_UP 0xD3 +#define KEY_PAGE_DOWN 0xD6 +#define KEY_HOME 0xD2 +#define KEY_END 0xD5 +#define KEY_CAPS_LOCK 0xC1 +#define KEY_F1 0xC2 +#define KEY_F2 0xC3 +#define KEY_F3 0xC4 +#define KEY_F4 0xC5 +#define KEY_F5 0xC6 +#define KEY_F6 0xC7 +#define KEY_F7 0xC8 +#define KEY_F8 0xC9 +#define KEY_F9 0xCA +#define KEY_F10 0xCB +#define KEY_F11 0xCC +#define KEY_F12 0xCD + +// Low level key report: up to 6 keys and shift, ctrl etc at once +typedef struct +{ + uint8_t modifiers; + uint8_t reserved; + uint8_t keys[6]; +} KeyReport; + +class Keyboard_ : public Print +{ +private: + KeyReport _keyReport; + void sendReport(KeyReport* keys); +public: + Keyboard_(void); + void begin(void); + void end(void); + virtual size_t write(uint8_t k); + virtual size_t press(uint8_t k); + virtual size_t release(uint8_t k); + virtual void releaseAll(void); +}; +extern Keyboard_ Keyboard; + +//================================================================================ +//================================================================================ +// Low level API + +typedef struct +{ + uint8_t bmRequestType; + uint8_t bRequest; + uint8_t wValueL; + uint8_t wValueH; + uint16_t wIndex; + uint16_t wLength; +} Setup; + +//================================================================================ +//================================================================================ +// HID 'Driver' + +int HID_GetInterface(uint8_t* interfaceNum); +int HID_GetDescriptor(int i); +bool HID_Setup(Setup& setup); +void HID_SendReport(uint8_t id, const void* data, int len); + +//================================================================================ +//================================================================================ +// MSC 'Driver' + +int MSC_GetInterface(uint8_t* interfaceNum); +int MSC_GetDescriptor(int i); +bool MSC_Setup(Setup& setup); +bool MSC_Data(uint8_t rx,uint8_t tx); + +//================================================================================ +//================================================================================ +// CSC 'Driver' + +int CDC_GetInterface(uint8_t* interfaceNum); +int CDC_GetDescriptor(int i); +bool CDC_Setup(Setup& setup); + +//================================================================================ +//================================================================================ + +#define TRANSFER_PGM 0x80 +#define TRANSFER_RELEASE 0x40 +#define TRANSFER_ZERO 0x20 + +int USB_SendControl(uint8_t flags, const void* d, int len); +int USB_RecvControl(void* d, int len); + +uint8_t USB_Available(uint8_t ep); +int USB_Send(uint8_t ep, const void* data, int len); // blocking +int USB_Recv(uint8_t ep, void* data, int len); // non-blocking +int USB_Recv(uint8_t ep); // non-blocking +void USB_Flush(uint8_t ep); + +#endif + +#endif /* if defined(USBCON) */ \ No newline at end of file diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBCore.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBCore.cpp new file mode 100644 index 000000000..6766be61a --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBCore.cpp @@ -0,0 +1,672 @@ + + +/* Copyright (c) 2010, Peter Barrett +** +** Permission to use, copy, modify, and/or distribute this software for +** any purpose with or without fee is hereby granted, provided that the +** above copyright notice and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR +** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +** WHETHER 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 "Platform.h" +#include "USBAPI.h" +#include "USBDesc.h" + +#if defined(USBCON) + +#define EP_TYPE_CONTROL 0x00 +#define EP_TYPE_BULK_IN 0x81 +#define EP_TYPE_BULK_OUT 0x80 +#define EP_TYPE_INTERRUPT_IN 0xC1 +#define EP_TYPE_INTERRUPT_OUT 0xC0 +#define EP_TYPE_ISOCHRONOUS_IN 0x41 +#define EP_TYPE_ISOCHRONOUS_OUT 0x40 + +/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ +#define TX_RX_LED_PULSE_MS 100 +volatile u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ +volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ + +//================================================================== +//================================================================== + +extern const u16 STRING_LANGUAGE[] PROGMEM; +extern const u16 STRING_IPRODUCT[] PROGMEM; +extern const u16 STRING_IMANUFACTURER[] PROGMEM; +extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM; +extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM; + +const u16 STRING_LANGUAGE[2] = { + (3<<8) | (2+2), + 0x0409 // English +}; + +const u16 STRING_IPRODUCT[17] = { + (3<<8) | (2+2*16), +#if USB_PID == 0x8036 + 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o' +#else + 'U','S','B',' ','I','O',' ','B','o','a','r','d',' ',' ',' ',' ' +#endif +}; + +const u16 STRING_IMANUFACTURER[12] = { + (3<<8) | (2+2*11), +#if USB_VID == 0x2341 + 'A','r','d','u','i','n','o',' ','L','L','C' +#else + 'U','n','k','n','o','w','n',' ',' ',' ',' ' +#endif +}; + +#ifdef CDC_ENABLED +#define DEVICE_CLASS 0x02 +#else +#define DEVICE_CLASS 0x00 +#endif + +// DEVICE DESCRIPTOR +const DeviceDescriptor USB_DeviceDescriptor = + D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1); + +const DeviceDescriptor USB_DeviceDescriptorA = + D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1); + +//================================================================== +//================================================================== + +volatile u8 _usbConfiguration = 0; + +static inline void WaitIN(void) +{ + while (!(UEINTX & (1< len) + n = len; + len -= n; + { + LockEP lock(ep); + if (ep & TRANSFER_ZERO) + { + while (n--) + Send8(0); + } + else if (ep & TRANSFER_PGM) + { + while (n--) + Send8(pgm_read_byte(data++)); + } + else + { + while (n--) + Send8(*data++); + } + if (!ReadWriteAllowed() || ((len == 0) && (ep & TRANSFER_RELEASE))) // Release full buffer + ReleaseTX(); + } + } + TXLED1; // light the TX LED + TxLEDPulse = TX_RX_LED_PULSE_MS; + return r; +} + +extern const u8 _initEndpoints[] PROGMEM; +const u8 _initEndpoints[] = +{ + 0, + +#ifdef CDC_ENABLED + EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM + EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT + EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN +#endif + +#ifdef HID_ENABLED + EP_TYPE_INTERRUPT_IN // HID_ENDPOINT_INT +#endif +}; + +#define EP_SINGLE_64 0x32 // EP0 +#define EP_DOUBLE_64 0x36 // Other endpoints + +static +void InitEP(u8 index, u8 type, u8 size) +{ + UENUM = index; + UECONX = 1; + UECFG0X = type; + UECFG1X = size; +} + +static +void InitEndpoints() +{ + for (u8 i = 1; i < sizeof(_initEndpoints); i++) + { + UENUM = i; + UECONX = 1; + UECFG0X = pgm_read_byte(_initEndpoints+i); + UECFG1X = EP_DOUBLE_64; + } + UERST = 0x7E; // And reset them + UERST = 0; +} + +// Handle CLASS_INTERFACE requests +static +bool ClassInterfaceRequest(Setup& setup) +{ + u8 i = setup.wIndex; + +#ifdef CDC_ENABLED + if (CDC_ACM_INTERFACE == i) + return CDC_Setup(setup); +#endif + +#ifdef HID_ENABLED + if (HID_INTERFACE == i) + return HID_Setup(setup); +#endif + return false; +} + +int _cmark; +int _cend; +void InitControl(int end) +{ + SetEP(0); + _cmark = 0; + _cend = end; +} + +static +bool SendControl(u8 d) +{ + if (_cmark < _cend) + { + if (!WaitForINOrOUT()) + return false; + Send8(d); + if (!((_cmark + 1) & 0x3F)) + ClearIN(); // Fifo is full, release this packet + } + _cmark++; + return true; +}; + +// Clipped by _cmark/_cend +int USB_SendControl(u8 flags, const void* d, int len) +{ + int sent = len; + const u8* data = (const u8*)d; + bool pgm = flags & TRANSFER_PGM; + while (len--) + { + u8 c = pgm ? pgm_read_byte(data++) : *data++; + if (!SendControl(c)) + return -1; + } + return sent; +} + +// Does not timeout or cross fifo boundaries +// Will only work for transfers <= 64 bytes +// TODO +int USB_RecvControl(void* d, int len) +{ + WaitOUT(); + Recv((u8*)d,len); + ClearOUT(); + return len; +} + +int SendInterfaces() +{ + int total = 0; + u8 interfaces = 0; + +#ifdef CDC_ENABLED + total = CDC_GetInterface(&interfaces); +#endif + +#ifdef HID_ENABLED + total += HID_GetInterface(&interfaces); +#endif + + return interfaces; +} + +// Construct a dynamic configuration descriptor +// This really needs dynamic endpoint allocation etc +// TODO +static +bool SendConfiguration(int maxlen) +{ + // Count and measure interfaces + InitControl(0); + int interfaces = SendInterfaces(); + ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor),interfaces); + + // Now send them + InitControl(maxlen); + USB_SendControl(0,&config,sizeof(ConfigDescriptor)); + SendInterfaces(); + return true; +} + +u8 _cdcComposite = 0; + +static +bool SendDescriptor(Setup& setup) +{ + u8 t = setup.wValueH; + if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t) + return SendConfiguration(setup.wLength); + + InitControl(setup.wLength); +#ifdef HID_ENABLED + if (HID_REPORT_DESCRIPTOR_TYPE == t) + return HID_GetDescriptor(t); +#endif + + u8 desc_length = 0; + const u8* desc_addr = 0; + if (USB_DEVICE_DESCRIPTOR_TYPE == t) + { + if (setup.wLength == 8) + _cdcComposite = 1; + desc_addr = _cdcComposite ? (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor; + } + else if (USB_STRING_DESCRIPTOR_TYPE == t) + { + if (setup.wValueL == 0) + desc_addr = (const u8*)&STRING_LANGUAGE; + else if (setup.wValueL == IPRODUCT) + desc_addr = (const u8*)&STRING_IPRODUCT; + else if (setup.wValueL == IMANUFACTURER) + desc_addr = (const u8*)&STRING_IMANUFACTURER; + else + return false; + } + + if (desc_addr == 0) + return false; + if (desc_length == 0) + desc_length = pgm_read_byte(desc_addr); + + USB_SendControl(TRANSFER_PGM,desc_addr,desc_length); + return true; +} + +// Endpoint 0 interrupt +ISR(USB_COM_vect) +{ + SetEP(0); + if (!ReceivedSetupInt()) + return; + + Setup setup; + Recv((u8*)&setup,8); + ClearSetupInt(); + + u8 requestType = setup.bmRequestType; + if (requestType & REQUEST_DEVICETOHOST) + WaitIN(); + else + ClearIN(); + + bool ok = true; + if (REQUEST_STANDARD == (requestType & REQUEST_TYPE)) + { + // Standard Requests + u8 r = setup.bRequest; + if (GET_STATUS == r) + { + Send8(0); // TODO + Send8(0); + } + else if (CLEAR_FEATURE == r) + { + } + else if (SET_FEATURE == r) + { + } + else if (SET_ADDRESS == r) + { + WaitIN(); + UDADDR = setup.wValueL | (1<> 8) & 0xFF) + +#define CDC_V1_10 0x0110 +#define CDC_COMMUNICATION_INTERFACE_CLASS 0x02 + +#define CDC_CALL_MANAGEMENT 0x01 +#define CDC_ABSTRACT_CONTROL_MODEL 0x02 +#define CDC_HEADER 0x00 +#define CDC_ABSTRACT_CONTROL_MANAGEMENT 0x02 +#define CDC_UNION 0x06 +#define CDC_CS_INTERFACE 0x24 +#define CDC_CS_ENDPOINT 0x25 +#define CDC_DATA_INTERFACE_CLASS 0x0A + +#define MSC_SUBCLASS_SCSI 0x06 +#define MSC_PROTOCOL_BULK_ONLY 0x50 + +#define HID_HID_DESCRIPTOR_TYPE 0x21 +#define HID_REPORT_DESCRIPTOR_TYPE 0x22 +#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23 + + +// Device +typedef struct { + u8 len; // 18 + u8 dtype; // 1 USB_DEVICE_DESCRIPTOR_TYPE + u16 usbVersion; // 0x200 + u8 deviceClass; + u8 deviceSubClass; + u8 deviceProtocol; + u8 packetSize0; // Packet 0 + u16 idVendor; + u16 idProduct; + u16 deviceVersion; // 0x100 + u8 iManufacturer; + u8 iProduct; + u8 iSerialNumber; + u8 bNumConfigurations; +} DeviceDescriptor; + +// Config +typedef struct { + u8 len; // 9 + u8 dtype; // 2 + u16 clen; // total length + u8 numInterfaces; + u8 config; + u8 iconfig; + u8 attributes; + u8 maxPower; +} ConfigDescriptor; + +// String + +// Interface +typedef struct +{ + u8 len; // 9 + u8 dtype; // 4 + u8 number; + u8 alternate; + u8 numEndpoints; + u8 interfaceClass; + u8 interfaceSubClass; + u8 protocol; + u8 iInterface; +} InterfaceDescriptor; + +// Endpoint +typedef struct +{ + u8 len; // 7 + u8 dtype; // 5 + u8 addr; + u8 attr; + u16 packetSize; + u8 interval; +} EndpointDescriptor; + +// Interface Association Descriptor +// Used to bind 2 interfaces together in CDC compostite device +typedef struct +{ + u8 len; // 8 + u8 dtype; // 11 + u8 firstInterface; + u8 interfaceCount; + u8 functionClass; + u8 funtionSubClass; + u8 functionProtocol; + u8 iInterface; +} IADDescriptor; + +// CDC CS interface descriptor +typedef struct +{ + u8 len; // 5 + u8 dtype; // 0x24 + u8 subtype; + u8 d0; + u8 d1; +} CDCCSInterfaceDescriptor; + +typedef struct +{ + u8 len; // 4 + u8 dtype; // 0x24 + u8 subtype; + u8 d0; +} CDCCSInterfaceDescriptor4; + +typedef struct +{ + u8 len; + u8 dtype; // 0x24 + u8 subtype; // 1 + u8 bmCapabilities; + u8 bDataInterface; +} CMFunctionalDescriptor; + +typedef struct +{ + u8 len; + u8 dtype; // 0x24 + u8 subtype; // 1 + u8 bmCapabilities; +} ACMFunctionalDescriptor; + +typedef struct +{ + // IAD + IADDescriptor iad; // Only needed on compound device + + // Control + InterfaceDescriptor cif; // + CDCCSInterfaceDescriptor header; + CMFunctionalDescriptor callManagement; // Call Management + ACMFunctionalDescriptor controlManagement; // ACM + CDCCSInterfaceDescriptor functionalDescriptor; // CDC_UNION + EndpointDescriptor cifin; + + // Data + InterfaceDescriptor dif; + EndpointDescriptor in; + EndpointDescriptor out; +} CDCDescriptor; + +typedef struct +{ + InterfaceDescriptor msc; + EndpointDescriptor in; + EndpointDescriptor out; +} MSCDescriptor; + +typedef struct +{ + u8 len; // 9 + u8 dtype; // 0x21 + u8 addr; + u8 versionL; // 0x101 + u8 versionH; // 0x101 + u8 country; + u8 desctype; // 0x22 report + u8 descLenL; + u8 descLenH; +} HIDDescDescriptor; + +typedef struct +{ + InterfaceDescriptor hid; + HIDDescDescriptor desc; + EndpointDescriptor in; +} HIDDescriptor; + + +#define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \ + { 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs } + +#define D_CONFIG(_totalLength,_interfaces) \ + { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(500) } + +#define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \ + { 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 } + +#define D_ENDPOINT(_addr,_attr,_packetSize, _interval) \ + { 7, 5, _addr,_attr,_packetSize, _interval } + +#define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \ + { 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 } + +#define D_HIDREPORT(_descriptorLength) \ + { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 } + +#define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 } +#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 } + + +#endif \ No newline at end of file diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBDesc.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBDesc.h new file mode 100644 index 000000000..900713e0f --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/USBDesc.h @@ -0,0 +1,63 @@ + + +/* Copyright (c) 2011, Peter Barrett +** +** Permission to use, copy, modify, and/or distribute this software for +** any purpose with or without fee is hereby granted, provided that the +** above copyright notice and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR +** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES +** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +** WHETHER 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 CDC_ENABLED +#define HID_ENABLED + + +#ifdef CDC_ENABLED +#define CDC_INTERFACE_COUNT 2 +#define CDC_ENPOINT_COUNT 3 +#else +#define CDC_INTERFACE_COUNT 0 +#define CDC_ENPOINT_COUNT 0 +#endif + +#ifdef HID_ENABLED +#define HID_INTERFACE_COUNT 1 +#define HID_ENPOINT_COUNT 1 +#else +#define HID_INTERFACE_COUNT 0 +#define HID_ENPOINT_COUNT 0 +#endif + +#define CDC_ACM_INTERFACE 0 // CDC ACM +#define CDC_DATA_INTERFACE 1 // CDC Data +#define CDC_FIRST_ENDPOINT 1 +#define CDC_ENDPOINT_ACM (CDC_FIRST_ENDPOINT) // CDC First +#define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1) +#define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2) + +#define HID_INTERFACE (CDC_ACM_INTERFACE + CDC_INTERFACE_COUNT) // HID Interface +#define HID_FIRST_ENDPOINT (CDC_FIRST_ENDPOINT + CDC_ENPOINT_COUNT) +#define HID_ENDPOINT_INT (HID_FIRST_ENDPOINT) + +#define INTERFACE_COUNT (MSC_INTERFACE + MSC_INTERFACE_COUNT) + +#ifdef CDC_ENABLED +#define CDC_RX CDC_ENDPOINT_OUT +#define CDC_TX CDC_ENDPOINT_IN +#endif + +#ifdef HID_ENABLED +#define HID_TX HID_ENDPOINT_INT +#endif + +#define IMANUFACTURER 1 +#define IPRODUCT 2 + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/Udp.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Udp.h new file mode 100644 index 000000000..dc5644b9d --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/Udp.h @@ -0,0 +1,88 @@ +/* + * Udp.cpp: Library to send/receive UDP packets. + * + * NOTE: UDP is fast, but has some important limitations (thanks to Warren Gray for mentioning these) + * 1) UDP does not guarantee the order in which assembled UDP packets are received. This + * might not happen often in practice, but in larger network topologies, a UDP + * packet can be received out of sequence. + * 2) UDP does not guard against lost packets - so packets *can* disappear without the sender being + * aware of it. Again, this may not be a concern in practice on small local networks. + * For more information, see http://www.cafeaulait.org/course/week12/35.html + * + * MIT License: + * Copyright (c) 2008 Bjoern Hartmann + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * bjoern@cs.stanford.edu 12/30/2008 + */ + +#ifndef udp_h +#define udp_h + +#include +#include + +class UDP : public Stream { + +public: + virtual uint8_t begin(uint16_t) =0; // initialize, start listening on specified port. Returns 1 if successful, 0 if there are no sockets available to use + virtual void stop() =0; // Finish with the UDP socket + + // Sending UDP packets + + // Start building up a packet to send to the remote host specific in ip and port + // Returns 1 if successful, 0 if there was a problem with the supplied IP address or port + virtual int beginPacket(IPAddress ip, uint16_t port) =0; + // Start building up a packet to send to the remote host specific in host and port + // Returns 1 if successful, 0 if there was a problem resolving the hostname or port + virtual int beginPacket(const char *host, uint16_t port) =0; + // Finish off this packet and send it + // Returns 1 if the packet was sent successfully, 0 if there was an error + virtual int endPacket() =0; + // Write a single byte into the packet + virtual size_t write(uint8_t) =0; + // Write size bytes from buffer into the packet + virtual size_t write(const uint8_t *buffer, size_t size) =0; + + // Start processing the next available incoming packet + // Returns the size of the packet in bytes, or 0 if no packets are available + virtual int parsePacket() =0; + // Number of bytes remaining in the current packet + virtual int available() =0; + // Read a single byte from the current packet + virtual int read() =0; + // Read up to len bytes from the current packet and place them into buffer + // Returns the number of bytes read, or 0 if none are available + virtual int read(unsigned char* buffer, size_t len) =0; + // Read up to len characters from the current packet and place them into buffer + // Returns the number of characters read, or 0 if none are available + virtual int read(char* buffer, size_t len) =0; + // Return the next byte from the current packet without moving on to the next byte + virtual int peek() =0; + virtual void flush() =0; // Finish reading the current packet + + // Return the IP address of the host who sent the current incoming packet + virtual IPAddress remoteIP() =0; + // Return the port of the host who sent the current incoming packet + virtual uint16_t remotePort() =0; +protected: + uint8_t* rawIPAddress(IPAddress& addr) { return addr.raw_address(); }; +}; + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/WCharacter.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WCharacter.h new file mode 100644 index 000000000..79733b50a --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WCharacter.h @@ -0,0 +1,168 @@ +/* + WCharacter.h - Character utility functions for Wiring & Arduino + Copyright (c) 2010 Hernando Barragan. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Character_h +#define Character_h + +#include + +// WCharacter.h prototypes +inline boolean isAlphaNumeric(int c) __attribute__((always_inline)); +inline boolean isAlpha(int c) __attribute__((always_inline)); +inline boolean isAscii(int c) __attribute__((always_inline)); +inline boolean isWhitespace(int c) __attribute__((always_inline)); +inline boolean isControl(int c) __attribute__((always_inline)); +inline boolean isDigit(int c) __attribute__((always_inline)); +inline boolean isGraph(int c) __attribute__((always_inline)); +inline boolean isLowerCase(int c) __attribute__((always_inline)); +inline boolean isPrintable(int c) __attribute__((always_inline)); +inline boolean isPunct(int c) __attribute__((always_inline)); +inline boolean isSpace(int c) __attribute__((always_inline)); +inline boolean isUpperCase(int c) __attribute__((always_inline)); +inline boolean isHexadecimalDigit(int c) __attribute__((always_inline)); +inline int toAscii(int c) __attribute__((always_inline)); +inline int toLowerCase(int c) __attribute__((always_inline)); +inline int toUpperCase(int c)__attribute__((always_inline)); + + +// Checks for an alphanumeric character. +// It is equivalent to (isalpha(c) || isdigit(c)). +inline boolean isAlphaNumeric(int c) +{ + return ( isalnum(c) == 0 ? false : true); +} + + +// Checks for an alphabetic character. +// It is equivalent to (isupper(c) || islower(c)). +inline boolean isAlpha(int c) +{ + return ( isalpha(c) == 0 ? false : true); +} + + +// Checks whether c is a 7-bit unsigned char value +// that fits into the ASCII character set. +inline boolean isAscii(int c) +{ + return ( isascii (c) == 0 ? false : true); +} + + +// Checks for a blank character, that is, a space or a tab. +inline boolean isWhitespace(int c) +{ + return ( isblank (c) == 0 ? false : true); +} + + +// Checks for a control character. +inline boolean isControl(int c) +{ + return ( iscntrl (c) == 0 ? false : true); +} + + +// Checks for a digit (0 through 9). +inline boolean isDigit(int c) +{ + return ( isdigit (c) == 0 ? false : true); +} + + +// Checks for any printable character except space. +inline boolean isGraph(int c) +{ + return ( isgraph (c) == 0 ? false : true); +} + + +// Checks for a lower-case character. +inline boolean isLowerCase(int c) +{ + return (islower (c) == 0 ? false : true); +} + + +// Checks for any printable character including space. +inline boolean isPrintable(int c) +{ + return ( isprint (c) == 0 ? false : true); +} + + +// Checks for any printable character which is not a space +// or an alphanumeric character. +inline boolean isPunct(int c) +{ + return ( ispunct (c) == 0 ? false : true); +} + + +// Checks for white-space characters. For the avr-libc library, +// these are: space, formfeed ('\f'), newline ('\n'), carriage +// return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). +inline boolean isSpace(int c) +{ + return ( isspace (c) == 0 ? false : true); +} + + +// Checks for an uppercase letter. +inline boolean isUpperCase(int c) +{ + return ( isupper (c) == 0 ? false : true); +} + + +// Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 +// 8 9 a b c d e f A B C D E F. +inline boolean isHexadecimalDigit(int c) +{ + return ( isxdigit (c) == 0 ? false : true); +} + + +// Converts c to a 7-bit unsigned char value that fits into the +// ASCII character set, by clearing the high-order bits. +inline int toAscii(int c) +{ + return toascii (c); +} + + +// Warning: +// Many people will be unhappy if you use this function. +// This function will convert accented letters into random +// characters. + +// Converts the letter c to lower case, if possible. +inline int toLowerCase(int c) +{ + return tolower (c); +} + + +// Converts the letter c to upper case, if possible. +inline int toUpperCase(int c) +{ + return toupper (c); +} + +#endif \ No newline at end of file diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/WInterrupts.c b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WInterrupts.c new file mode 100644 index 000000000..8f3ec847f --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WInterrupts.c @@ -0,0 +1,298 @@ +/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Wiring project - http://wiring.uniandes.edu.co + + Copyright (c) 2004-05 Hernando Barragan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + Modified 24 November 2006 by David A. Mellis + Modified 1 August 2010 by Mark Sproul +*/ + +#include +#include +#include +#include +#include + +#include "wiring_private.h" + +static volatile voidFuncPtr intFunc[EXTERNAL_NUM_INTERRUPTS]; +// volatile static voidFuncPtr twiIntFunc; + +void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { + if(interruptNum < EXTERNAL_NUM_INTERRUPTS) { + intFunc[interruptNum] = userFunc; + + // Configure the interrupt mode (trigger on low input, any change, rising + // edge, or falling edge). The mode constants were chosen to correspond + // to the configuration bits in the hardware register, so we simply shift + // the mode into place. + + // Enable the interrupt. + + switch (interruptNum) { +#if defined(__AVR_ATmega32U4__) + // I hate doing this, but the register assignment differs between the 1280/2560 + // and the 32U4. Since avrlib defines registers PCMSK1 and PCMSK2 that aren't + // even present on the 32U4 this is the only way to distinguish between them. + case 0: + EICRA = (EICRA & ~((1<= howbig) { + return howsmall; + } + long diff = howbig - howsmall; + return random(diff) + howsmall; +} + +long map(long x, long in_min, long in_max, long out_min, long out_max) +{ + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + +unsigned int makeWord(unsigned int w) { return w; } +unsigned int makeWord(unsigned char h, unsigned char l) { return (h << 8) | l; } \ No newline at end of file diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.cpp new file mode 100644 index 000000000..c6839fc0d --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.cpp @@ -0,0 +1,645 @@ +/* + WString.cpp - String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... + Copyright (c) 2009-10 Hernando Barragan. All rights reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "WString.h" + + +/*********************************************/ +/* Constructors */ +/*********************************************/ + +String::String(const char *cstr) +{ + init(); + if (cstr) copy(cstr, strlen(cstr)); +} + +String::String(const String &value) +{ + init(); + *this = value; +} + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +String::String(String &&rval) +{ + init(); + move(rval); +} +String::String(StringSumHelper &&rval) +{ + init(); + move(rval); +} +#endif + +String::String(char c) +{ + init(); + char buf[2]; + buf[0] = c; + buf[1] = 0; + *this = buf; +} + +String::String(unsigned char value, unsigned char base) +{ + init(); + char buf[9]; + utoa(value, buf, base); + *this = buf; +} + +String::String(int value, unsigned char base) +{ + init(); + char buf[18]; + itoa(value, buf, base); + *this = buf; +} + +String::String(unsigned int value, unsigned char base) +{ + init(); + char buf[17]; + utoa(value, buf, base); + *this = buf; +} + +String::String(long value, unsigned char base) +{ + init(); + char buf[34]; + ltoa(value, buf, base); + *this = buf; +} + +String::String(unsigned long value, unsigned char base) +{ + init(); + char buf[33]; + ultoa(value, buf, base); + *this = buf; +} + +String::~String() +{ + free(buffer); +} + +/*********************************************/ +/* Memory Management */ +/*********************************************/ + +inline void String::init(void) +{ + buffer = NULL; + capacity = 0; + len = 0; + flags = 0; +} + +void String::invalidate(void) +{ + if (buffer) free(buffer); + buffer = NULL; + capacity = len = 0; +} + +unsigned char String::reserve(unsigned int size) +{ + if (buffer && capacity >= size) return 1; + if (changeBuffer(size)) { + if (len == 0) buffer[0] = 0; + return 1; + } + return 0; +} + +unsigned char String::changeBuffer(unsigned int maxStrLen) +{ + char *newbuffer = (char *)realloc(buffer, maxStrLen + 1); + if (newbuffer) { + buffer = newbuffer; + capacity = maxStrLen; + return 1; + } + return 0; +} + +/*********************************************/ +/* Copy and Move */ +/*********************************************/ + +String & String::copy(const char *cstr, unsigned int length) +{ + if (!reserve(length)) { + invalidate(); + return *this; + } + len = length; + strcpy(buffer, cstr); + return *this; +} + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +void String::move(String &rhs) +{ + if (buffer) { + if (capacity >= rhs.len) { + strcpy(buffer, rhs.buffer); + len = rhs.len; + rhs.len = 0; + return; + } else { + free(buffer); + } + } + buffer = rhs.buffer; + capacity = rhs.capacity; + len = rhs.len; + rhs.buffer = NULL; + rhs.capacity = 0; + rhs.len = 0; +} +#endif + +String & String::operator = (const String &rhs) +{ + if (this == &rhs) return *this; + + if (rhs.buffer) copy(rhs.buffer, rhs.len); + else invalidate(); + + return *this; +} + +#ifdef __GXX_EXPERIMENTAL_CXX0X__ +String & String::operator = (String &&rval) +{ + if (this != &rval) move(rval); + return *this; +} + +String & String::operator = (StringSumHelper &&rval) +{ + if (this != &rval) move(rval); + return *this; +} +#endif + +String & String::operator = (const char *cstr) +{ + if (cstr) copy(cstr, strlen(cstr)); + else invalidate(); + + return *this; +} + +/*********************************************/ +/* concat */ +/*********************************************/ + +unsigned char String::concat(const String &s) +{ + return concat(s.buffer, s.len); +} + +unsigned char String::concat(const char *cstr, unsigned int length) +{ + unsigned int newlen = len + length; + if (!cstr) return 0; + if (length == 0) return 1; + if (!reserve(newlen)) return 0; + strcpy(buffer + len, cstr); + len = newlen; + return 1; +} + +unsigned char String::concat(const char *cstr) +{ + if (!cstr) return 0; + return concat(cstr, strlen(cstr)); +} + +unsigned char String::concat(char c) +{ + char buf[2]; + buf[0] = c; + buf[1] = 0; + return concat(buf, 1); +} + +unsigned char String::concat(unsigned char num) +{ + char buf[4]; + itoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(int num) +{ + char buf[7]; + itoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(unsigned int num) +{ + char buf[6]; + utoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(long num) +{ + char buf[12]; + ltoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +unsigned char String::concat(unsigned long num) +{ + char buf[11]; + ultoa(num, buf, 10); + return concat(buf, strlen(buf)); +} + +/*********************************************/ +/* Concatenate */ +/*********************************************/ + +StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(rhs.buffer, rhs.len)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr) +{ + StringSumHelper &a = const_cast(lhs); + if (!cstr || !a.concat(cstr, strlen(cstr))) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, char c) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(c)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num) +{ + StringSumHelper &a = const_cast(lhs); + if (!a.concat(num)) a.invalidate(); + return a; +} + +/*********************************************/ +/* Comparison */ +/*********************************************/ + +int String::compareTo(const String &s) const +{ + if (!buffer || !s.buffer) { + if (s.buffer && s.len > 0) return 0 - *(unsigned char *)s.buffer; + if (buffer && len > 0) return *(unsigned char *)buffer; + return 0; + } + return strcmp(buffer, s.buffer); +} + +unsigned char String::equals(const String &s2) const +{ + return (len == s2.len && compareTo(s2) == 0); +} + +unsigned char String::equals(const char *cstr) const +{ + if (len == 0) return (cstr == NULL || *cstr == 0); + if (cstr == NULL) return buffer[0] == 0; + return strcmp(buffer, cstr) == 0; +} + +unsigned char String::operator<(const String &rhs) const +{ + return compareTo(rhs) < 0; +} + +unsigned char String::operator>(const String &rhs) const +{ + return compareTo(rhs) > 0; +} + +unsigned char String::operator<=(const String &rhs) const +{ + return compareTo(rhs) <= 0; +} + +unsigned char String::operator>=(const String &rhs) const +{ + return compareTo(rhs) >= 0; +} + +unsigned char String::equalsIgnoreCase( const String &s2 ) const +{ + if (this == &s2) return 1; + if (len != s2.len) return 0; + if (len == 0) return 1; + const char *p1 = buffer; + const char *p2 = s2.buffer; + while (*p1) { + if (tolower(*p1++) != tolower(*p2++)) return 0; + } + return 1; +} + +unsigned char String::startsWith( const String &s2 ) const +{ + if (len < s2.len) return 0; + return startsWith(s2, 0); +} + +unsigned char String::startsWith( const String &s2, unsigned int offset ) const +{ + if (offset > len - s2.len || !buffer || !s2.buffer) return 0; + return strncmp( &buffer[offset], s2.buffer, s2.len ) == 0; +} + +unsigned char String::endsWith( const String &s2 ) const +{ + if ( len < s2.len || !buffer || !s2.buffer) return 0; + return strcmp(&buffer[len - s2.len], s2.buffer) == 0; +} + +/*********************************************/ +/* Character Access */ +/*********************************************/ + +char String::charAt(unsigned int loc) const +{ + return operator[](loc); +} + +void String::setCharAt(unsigned int loc, char c) +{ + if (loc < len) buffer[loc] = c; +} + +char & String::operator[](unsigned int index) +{ + static char dummy_writable_char; + if (index >= len || !buffer) { + dummy_writable_char = 0; + return dummy_writable_char; + } + return buffer[index]; +} + +char String::operator[]( unsigned int index ) const +{ + if (index >= len || !buffer) return 0; + return buffer[index]; +} + +void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const +{ + if (!bufsize || !buf) return; + if (index >= len) { + buf[0] = 0; + return; + } + unsigned int n = bufsize - 1; + if (n > len - index) n = len - index; + strncpy((char *)buf, buffer + index, n); + buf[n] = 0; +} + +/*********************************************/ +/* Search */ +/*********************************************/ + +int String::indexOf(char c) const +{ + return indexOf(c, 0); +} + +int String::indexOf( char ch, unsigned int fromIndex ) const +{ + if (fromIndex >= len) return -1; + const char* temp = strchr(buffer + fromIndex, ch); + if (temp == NULL) return -1; + return temp - buffer; +} + +int String::indexOf(const String &s2) const +{ + return indexOf(s2, 0); +} + +int String::indexOf(const String &s2, unsigned int fromIndex) const +{ + if (fromIndex >= len) return -1; + const char *found = strstr(buffer + fromIndex, s2.buffer); + if (found == NULL) return -1; + return found - buffer; +} + +int String::lastIndexOf( char theChar ) const +{ + return lastIndexOf(theChar, len - 1); +} + +int String::lastIndexOf(char ch, unsigned int fromIndex) const +{ + if (fromIndex >= len) return -1; + char tempchar = buffer[fromIndex + 1]; + buffer[fromIndex + 1] = '\0'; + char* temp = strrchr( buffer, ch ); + buffer[fromIndex + 1] = tempchar; + if (temp == NULL) return -1; + return temp - buffer; +} + +int String::lastIndexOf(const String &s2) const +{ + return lastIndexOf(s2, len - s2.len); +} + +int String::lastIndexOf(const String &s2, unsigned int fromIndex) const +{ + if (s2.len == 0 || len == 0 || s2.len > len) return -1; + if (fromIndex >= len) fromIndex = len - 1; + int found = -1; + for (char *p = buffer; p <= buffer + fromIndex; p++) { + p = strstr(p, s2.buffer); + if (!p) break; + if ((unsigned int)(p - buffer) <= fromIndex) found = p - buffer; + } + return found; +} + +String String::substring( unsigned int left ) const +{ + return substring(left, len); +} + +String String::substring(unsigned int left, unsigned int right) const +{ + if (left > right) { + unsigned int temp = right; + right = left; + left = temp; + } + String out; + if (left > len) return out; + if (right > len) right = len; + char temp = buffer[right]; // save the replaced character + buffer[right] = '\0'; + out = buffer + left; // pointer arithmetic + buffer[right] = temp; //restore character + return out; +} + +/*********************************************/ +/* Modification */ +/*********************************************/ + +void String::replace(char find, char replace) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + if (*p == find) *p = replace; + } +} + +void String::replace(const String& find, const String& replace) +{ + if (len == 0 || find.len == 0) return; + int diff = replace.len - find.len; + char *readFrom = buffer; + char *foundAt; + if (diff == 0) { + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + memcpy(foundAt, replace.buffer, replace.len); + readFrom = foundAt + replace.len; + } + } else if (diff < 0) { + char *writeTo = buffer; + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + unsigned int n = foundAt - readFrom; + memcpy(writeTo, readFrom, n); + writeTo += n; + memcpy(writeTo, replace.buffer, replace.len); + writeTo += replace.len; + readFrom = foundAt + find.len; + len += diff; + } + strcpy(writeTo, readFrom); + } else { + unsigned int size = len; // compute size needed for result + while ((foundAt = strstr(readFrom, find.buffer)) != NULL) { + readFrom = foundAt + find.len; + size += diff; + } + if (size == len) return; + if (size > capacity && !changeBuffer(size)) return; // XXX: tell user! + int index = len - 1; + while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) { + readFrom = buffer + index + find.len; + memmove(readFrom + diff, readFrom, len - (readFrom - buffer)); + len += diff; + buffer[len] = 0; + memcpy(buffer + index, replace.buffer, replace.len); + index--; + } + } +} + +void String::toLowerCase(void) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = tolower(*p); + } +} + +void String::toUpperCase(void) +{ + if (!buffer) return; + for (char *p = buffer; *p; p++) { + *p = toupper(*p); + } +} + +void String::trim(void) +{ + if (!buffer || len == 0) return; + char *begin = buffer; + while (isspace(*begin)) begin++; + char *end = buffer + len - 1; + while (isspace(*end) && end >= begin) end--; + len = end + 1 - begin; + if (begin > buffer) memcpy(buffer, begin, len); + buffer[len] = 0; +} + +/*********************************************/ +/* Parsing / Conversion */ +/*********************************************/ + +long String::toInt(void) const +{ + if (buffer) return atol(buffer); + return 0; +} + + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h new file mode 100644 index 000000000..947325e5f --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/WString.h @@ -0,0 +1,205 @@ +/* + WString.h - String library for Wiring & Arduino + ...mostly rewritten by Paul Stoffregen... + Copyright (c) 2009-10 Hernando Barragan. All right reserved. + Copyright 2011, Paul Stoffregen, paul@pjrc.com + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef String_class_h +#define String_class_h +#ifdef __cplusplus + +#include +#include +#include +#include + +// When compiling programs with this class, the following gcc parameters +// dramatically increase performance and memory (RAM) efficiency, typically +// with little or no increase in code size. +// -felide-constructors +// -std=c++0x + +class __FlashStringHelper; +#define F(string_literal) (reinterpret_cast(PSTR(string_literal))) + +// An inherited class for holding the result of a concatenation. These +// result objects are assumed to be writable by subsequent concatenations. +class StringSumHelper; + +// The string class +class String +{ + // use a function pointer to allow for "if (s)" without the + // complications of an operator bool(). for more information, see: + // http://www.artima.com/cppsource/safebool.html + typedef void (String::*StringIfHelperType)() const; + void StringIfHelper() const {} + +public: + // constructors + // creates a copy of the initial value. + // if the initial value is null or invalid, or if memory allocation + // fails, the string will be marked as invalid (i.e. "if (s)" will + // be false). + String(const char *cstr = ""); + String(const String &str); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + String(String &&rval); + String(StringSumHelper &&rval); + #endif + explicit String(char c); + explicit String(unsigned char, unsigned char base=10); + explicit String(int, unsigned char base=10); + explicit String(unsigned int, unsigned char base=10); + explicit String(long, unsigned char base=10); + explicit String(unsigned long, unsigned char base=10); + ~String(void); + + // memory management + // return true on success, false on failure (in which case, the string + // is left unchanged). reserve(0), if successful, will validate an + // invalid string (i.e., "if (s)" will be true afterwards) + unsigned char reserve(unsigned int size); + inline unsigned int length(void) const {return len;} + + // creates a copy of the assigned value. if the value is null or + // invalid, or if the memory allocation fails, the string will be + // marked as invalid ("if (s)" will be false). + String & operator = (const String &rhs); + String & operator = (const char *cstr); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + String & operator = (String &&rval); + String & operator = (StringSumHelper &&rval); + #endif + + // concatenate (works w/ built-in types) + + // returns true on success, false on failure (in which case, the string + // is left unchanged). if the argument is null or invalid, the + // concatenation is considered unsucessful. + unsigned char concat(const String &str); + unsigned char concat(const char *cstr); + unsigned char concat(char c); + unsigned char concat(unsigned char c); + unsigned char concat(int num); + unsigned char concat(unsigned int num); + unsigned char concat(long num); + unsigned char concat(unsigned long num); + + // if there's not enough memory for the concatenated value, the string + // will be left unchanged (but this isn't signalled in any way) + String & operator += (const String &rhs) {concat(rhs); return (*this);} + String & operator += (const char *cstr) {concat(cstr); return (*this);} + String & operator += (char c) {concat(c); return (*this);} + String & operator += (unsigned char num) {concat(num); return (*this);} + String & operator += (int num) {concat(num); return (*this);} + String & operator += (unsigned int num) {concat(num); return (*this);} + String & operator += (long num) {concat(num); return (*this);} + String & operator += (unsigned long num) {concat(num); return (*this);} + + friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs); + friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr); + friend StringSumHelper & operator + (const StringSumHelper &lhs, char c); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); + + // comparison (only works w/ Strings and "strings") + operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } + int compareTo(const String &s) const; + unsigned char equals(const String &s) const; + unsigned char equals(const char *cstr) const; + unsigned char operator == (const String &rhs) const {return equals(rhs);} + unsigned char operator == (const char *cstr) const {return equals(cstr);} + unsigned char operator != (const String &rhs) const {return !equals(rhs);} + unsigned char operator != (const char *cstr) const {return !equals(cstr);} + unsigned char operator < (const String &rhs) const; + unsigned char operator > (const String &rhs) const; + unsigned char operator <= (const String &rhs) const; + unsigned char operator >= (const String &rhs) const; + unsigned char equalsIgnoreCase(const String &s) const; + unsigned char startsWith( const String &prefix) const; + unsigned char startsWith(const String &prefix, unsigned int offset) const; + unsigned char endsWith(const String &suffix) const; + + // character acccess + char charAt(unsigned int index) const; + void setCharAt(unsigned int index, char c); + char operator [] (unsigned int index) const; + char& operator [] (unsigned int index); + void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const; + void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const + {getBytes((unsigned char *)buf, bufsize, index);} + + // search + int indexOf( char ch ) const; + int indexOf( char ch, unsigned int fromIndex ) const; + int indexOf( const String &str ) const; + int indexOf( const String &str, unsigned int fromIndex ) const; + int lastIndexOf( char ch ) const; + int lastIndexOf( char ch, unsigned int fromIndex ) const; + int lastIndexOf( const String &str ) const; + int lastIndexOf( const String &str, unsigned int fromIndex ) const; + String substring( unsigned int beginIndex ) const; + String substring( unsigned int beginIndex, unsigned int endIndex ) const; + + // modification + void replace(char find, char replace); + void replace(const String& find, const String& replace); + void toLowerCase(void); + void toUpperCase(void); + void trim(void); + + // parsing/conversion + long toInt(void) const; + +protected: + char *buffer; // the actual char array + unsigned int capacity; // the array length minus one (for the '\0') + unsigned int len; // the String length (not counting the '\0') + unsigned char flags; // unused, for future features +protected: + void init(void); + void invalidate(void); + unsigned char changeBuffer(unsigned int maxStrLen); + unsigned char concat(const char *cstr, unsigned int length); + + // copy and move + String & copy(const char *cstr, unsigned int length); + #ifdef __GXX_EXPERIMENTAL_CXX0X__ + void move(String &rhs); + #endif +}; + +class StringSumHelper : public String +{ +public: + StringSumHelper(const String &s) : String(s) {} + StringSumHelper(const char *p) : String(p) {} + StringSumHelper(char c) : String(c) {} + StringSumHelper(unsigned char num) : String(num) {} + StringSumHelper(int num) : String(num) {} + StringSumHelper(unsigned int num) : String(num) {} + StringSumHelper(long num) : String(num) {} + StringSumHelper(unsigned long num) : String(num) {} +}; + +#endif // __cplusplus +#endif // String_class_h diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/binary.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/binary.h new file mode 100644 index 000000000..af1498033 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/binary.h @@ -0,0 +1,515 @@ +#ifndef Binary_h +#define Binary_h + +#define B0 0 +#define B00 0 +#define B000 0 +#define B0000 0 +#define B00000 0 +#define B000000 0 +#define B0000000 0 +#define B00000000 0 +#define B1 1 +#define B01 1 +#define B001 1 +#define B0001 1 +#define B00001 1 +#define B000001 1 +#define B0000001 1 +#define B00000001 1 +#define B10 2 +#define B010 2 +#define B0010 2 +#define B00010 2 +#define B000010 2 +#define B0000010 2 +#define B00000010 2 +#define B11 3 +#define B011 3 +#define B0011 3 +#define B00011 3 +#define B000011 3 +#define B0000011 3 +#define B00000011 3 +#define B100 4 +#define B0100 4 +#define B00100 4 +#define B000100 4 +#define B0000100 4 +#define B00000100 4 +#define B101 5 +#define B0101 5 +#define B00101 5 +#define B000101 5 +#define B0000101 5 +#define B00000101 5 +#define B110 6 +#define B0110 6 +#define B00110 6 +#define B000110 6 +#define B0000110 6 +#define B00000110 6 +#define B111 7 +#define B0111 7 +#define B00111 7 +#define B000111 7 +#define B0000111 7 +#define B00000111 7 +#define B1000 8 +#define B01000 8 +#define B001000 8 +#define B0001000 8 +#define B00001000 8 +#define B1001 9 +#define B01001 9 +#define B001001 9 +#define B0001001 9 +#define B00001001 9 +#define B1010 10 +#define B01010 10 +#define B001010 10 +#define B0001010 10 +#define B00001010 10 +#define B1011 11 +#define B01011 11 +#define B001011 11 +#define B0001011 11 +#define B00001011 11 +#define B1100 12 +#define B01100 12 +#define B001100 12 +#define B0001100 12 +#define B00001100 12 +#define B1101 13 +#define B01101 13 +#define B001101 13 +#define B0001101 13 +#define B00001101 13 +#define B1110 14 +#define B01110 14 +#define B001110 14 +#define B0001110 14 +#define B00001110 14 +#define B1111 15 +#define B01111 15 +#define B001111 15 +#define B0001111 15 +#define B00001111 15 +#define B10000 16 +#define B010000 16 +#define B0010000 16 +#define B00010000 16 +#define B10001 17 +#define B010001 17 +#define B0010001 17 +#define B00010001 17 +#define B10010 18 +#define B010010 18 +#define B0010010 18 +#define B00010010 18 +#define B10011 19 +#define B010011 19 +#define B0010011 19 +#define B00010011 19 +#define B10100 20 +#define B010100 20 +#define B0010100 20 +#define B00010100 20 +#define B10101 21 +#define B010101 21 +#define B0010101 21 +#define B00010101 21 +#define B10110 22 +#define B010110 22 +#define B0010110 22 +#define B00010110 22 +#define B10111 23 +#define B010111 23 +#define B0010111 23 +#define B00010111 23 +#define B11000 24 +#define B011000 24 +#define B0011000 24 +#define B00011000 24 +#define B11001 25 +#define B011001 25 +#define B0011001 25 +#define B00011001 25 +#define B11010 26 +#define B011010 26 +#define B0011010 26 +#define B00011010 26 +#define B11011 27 +#define B011011 27 +#define B0011011 27 +#define B00011011 27 +#define B11100 28 +#define B011100 28 +#define B0011100 28 +#define B00011100 28 +#define B11101 29 +#define B011101 29 +#define B0011101 29 +#define B00011101 29 +#define B11110 30 +#define B011110 30 +#define B0011110 30 +#define B00011110 30 +#define B11111 31 +#define B011111 31 +#define B0011111 31 +#define B00011111 31 +#define B100000 32 +#define B0100000 32 +#define B00100000 32 +#define B100001 33 +#define B0100001 33 +#define B00100001 33 +#define B100010 34 +#define B0100010 34 +#define B00100010 34 +#define B100011 35 +#define B0100011 35 +#define B00100011 35 +#define B100100 36 +#define B0100100 36 +#define B00100100 36 +#define B100101 37 +#define B0100101 37 +#define B00100101 37 +#define B100110 38 +#define B0100110 38 +#define B00100110 38 +#define B100111 39 +#define B0100111 39 +#define B00100111 39 +#define B101000 40 +#define B0101000 40 +#define B00101000 40 +#define B101001 41 +#define B0101001 41 +#define B00101001 41 +#define B101010 42 +#define B0101010 42 +#define B00101010 42 +#define B101011 43 +#define B0101011 43 +#define B00101011 43 +#define B101100 44 +#define B0101100 44 +#define B00101100 44 +#define B101101 45 +#define B0101101 45 +#define B00101101 45 +#define B101110 46 +#define B0101110 46 +#define B00101110 46 +#define B101111 47 +#define B0101111 47 +#define B00101111 47 +#define B110000 48 +#define B0110000 48 +#define B00110000 48 +#define B110001 49 +#define B0110001 49 +#define B00110001 49 +#define B110010 50 +#define B0110010 50 +#define B00110010 50 +#define B110011 51 +#define B0110011 51 +#define B00110011 51 +#define B110100 52 +#define B0110100 52 +#define B00110100 52 +#define B110101 53 +#define B0110101 53 +#define B00110101 53 +#define B110110 54 +#define B0110110 54 +#define B00110110 54 +#define B110111 55 +#define B0110111 55 +#define B00110111 55 +#define B111000 56 +#define B0111000 56 +#define B00111000 56 +#define B111001 57 +#define B0111001 57 +#define B00111001 57 +#define B111010 58 +#define B0111010 58 +#define B00111010 58 +#define B111011 59 +#define B0111011 59 +#define B00111011 59 +#define B111100 60 +#define B0111100 60 +#define B00111100 60 +#define B111101 61 +#define B0111101 61 +#define B00111101 61 +#define B111110 62 +#define B0111110 62 +#define B00111110 62 +#define B111111 63 +#define B0111111 63 +#define B00111111 63 +#define B1000000 64 +#define B01000000 64 +#define B1000001 65 +#define B01000001 65 +#define B1000010 66 +#define B01000010 66 +#define B1000011 67 +#define B01000011 67 +#define B1000100 68 +#define B01000100 68 +#define B1000101 69 +#define B01000101 69 +#define B1000110 70 +#define B01000110 70 +#define B1000111 71 +#define B01000111 71 +#define B1001000 72 +#define B01001000 72 +#define B1001001 73 +#define B01001001 73 +#define B1001010 74 +#define B01001010 74 +#define B1001011 75 +#define B01001011 75 +#define B1001100 76 +#define B01001100 76 +#define B1001101 77 +#define B01001101 77 +#define B1001110 78 +#define B01001110 78 +#define B1001111 79 +#define B01001111 79 +#define B1010000 80 +#define B01010000 80 +#define B1010001 81 +#define B01010001 81 +#define B1010010 82 +#define B01010010 82 +#define B1010011 83 +#define B01010011 83 +#define B1010100 84 +#define B01010100 84 +#define B1010101 85 +#define B01010101 85 +#define B1010110 86 +#define B01010110 86 +#define B1010111 87 +#define B01010111 87 +#define B1011000 88 +#define B01011000 88 +#define B1011001 89 +#define B01011001 89 +#define B1011010 90 +#define B01011010 90 +#define B1011011 91 +#define B01011011 91 +#define B1011100 92 +#define B01011100 92 +#define B1011101 93 +#define B01011101 93 +#define B1011110 94 +#define B01011110 94 +#define B1011111 95 +#define B01011111 95 +#define B1100000 96 +#define B01100000 96 +#define B1100001 97 +#define B01100001 97 +#define B1100010 98 +#define B01100010 98 +#define B1100011 99 +#define B01100011 99 +#define B1100100 100 +#define B01100100 100 +#define B1100101 101 +#define B01100101 101 +#define B1100110 102 +#define B01100110 102 +#define B1100111 103 +#define B01100111 103 +#define B1101000 104 +#define B01101000 104 +#define B1101001 105 +#define B01101001 105 +#define B1101010 106 +#define B01101010 106 +#define B1101011 107 +#define B01101011 107 +#define B1101100 108 +#define B01101100 108 +#define B1101101 109 +#define B01101101 109 +#define B1101110 110 +#define B01101110 110 +#define B1101111 111 +#define B01101111 111 +#define B1110000 112 +#define B01110000 112 +#define B1110001 113 +#define B01110001 113 +#define B1110010 114 +#define B01110010 114 +#define B1110011 115 +#define B01110011 115 +#define B1110100 116 +#define B01110100 116 +#define B1110101 117 +#define B01110101 117 +#define B1110110 118 +#define B01110110 118 +#define B1110111 119 +#define B01110111 119 +#define B1111000 120 +#define B01111000 120 +#define B1111001 121 +#define B01111001 121 +#define B1111010 122 +#define B01111010 122 +#define B1111011 123 +#define B01111011 123 +#define B1111100 124 +#define B01111100 124 +#define B1111101 125 +#define B01111101 125 +#define B1111110 126 +#define B01111110 126 +#define B1111111 127 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/main.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/main.cpp new file mode 100644 index 000000000..3d4e079d2 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/main.cpp @@ -0,0 +1,20 @@ +#include + +int main(void) +{ + init(); + +#if defined(USBCON) + USBDevice.attach(); +#endif + + setup(); + + for (;;) { + loop(); + if (serialEventRun) serialEventRun(); + } + + return 0; +} + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/new.cpp b/protocol/usb_hid/arduino-1.0.1/cores/arduino/new.cpp new file mode 100644 index 000000000..0f6d4220e --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/new.cpp @@ -0,0 +1,18 @@ +#include + +void * operator new(size_t size) +{ + return malloc(size); +} + +void operator delete(void * ptr) +{ + free(ptr); +} + +int __cxa_guard_acquire(__guard *g) {return !*(char *)(g);}; +void __cxa_guard_release (__guard *g) {*(char *)g = 1;}; +void __cxa_guard_abort (__guard *) {}; + +void __cxa_pure_virtual(void) {}; + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/new.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/new.h new file mode 100644 index 000000000..cd940ce8b --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/new.h @@ -0,0 +1,22 @@ +/* Header to define new/delete operators as they aren't provided by avr-gcc by default + Taken from http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=59453 + */ + +#ifndef NEW_H +#define NEW_H + +#include + +void * operator new(size_t size); +void operator delete(void * ptr); + +__extension__ typedef int __guard __attribute__((mode (__DI__))); + +extern "C" int __cxa_guard_acquire(__guard *); +extern "C" void __cxa_guard_release (__guard *); +extern "C" void __cxa_guard_abort (__guard *); + +extern "C" void __cxa_pure_virtual(void); + +#endif + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring.c b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring.c new file mode 100644 index 000000000..ac8bb6f9b --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring.c @@ -0,0 +1,324 @@ +/* + wiring.c - Partial implementation of the Wiring API for the ATmega8. + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id$ +*/ + +#include "wiring_private.h" + +// the prescaler is set so that timer0 ticks every 64 clock cycles, and the +// the overflow handler is called every 256 ticks. +#define MICROSECONDS_PER_TIMER0_OVERFLOW (clockCyclesToMicroseconds(64 * 256)) + +// the whole number of milliseconds per timer0 overflow +#define MILLIS_INC (MICROSECONDS_PER_TIMER0_OVERFLOW / 1000) + +// the fractional number of milliseconds per timer0 overflow. we shift right +// by three to fit these numbers into a byte. (for the clock speeds we care +// about - 8 and 16 MHz - this doesn't lose precision.) +#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3) +#define FRACT_MAX (1000 >> 3) + +volatile unsigned long timer0_overflow_count = 0; +volatile unsigned long timer0_millis = 0; +static unsigned char timer0_fract = 0; + +#if defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) +SIGNAL(TIM0_OVF_vect) +#else +SIGNAL(TIMER0_OVF_vect) +#endif +{ + // copy these to local variables so they can be stored in registers + // (volatile variables must be read from memory on every access) + unsigned long m = timer0_millis; + unsigned char f = timer0_fract; + + m += MILLIS_INC; + f += FRACT_INC; + if (f >= FRACT_MAX) { + f -= FRACT_MAX; + m += 1; + } + + timer0_fract = f; + timer0_millis = m; + timer0_overflow_count++; +} + +unsigned long millis() +{ + unsigned long m; + uint8_t oldSREG = SREG; + + // disable interrupts while we read timer0_millis or we might get an + // inconsistent value (e.g. in the middle of a write to timer0_millis) + cli(); + m = timer0_millis; + SREG = oldSREG; + + return m; +} + +unsigned long micros() { + unsigned long m; + uint8_t oldSREG = SREG, t; + + cli(); + m = timer0_overflow_count; +#if defined(TCNT0) + t = TCNT0; +#elif defined(TCNT0L) + t = TCNT0L; +#else + #error TIMER 0 not defined +#endif + + +#ifdef TIFR0 + if ((TIFR0 & _BV(TOV0)) && (t < 255)) + m++; +#else + if ((TIFR & _BV(TOV0)) && (t < 255)) + m++; +#endif + + SREG = oldSREG; + + return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond()); +} + +void delay(unsigned long ms) +{ + uint16_t start = (uint16_t)micros(); + + while (ms > 0) { + if (((uint16_t)micros() - start) >= 1000) { + ms--; + start += 1000; + } + } +} + +/* Delay for the given number of microseconds. Assumes a 8 or 16 MHz clock. */ +void delayMicroseconds(unsigned int us) +{ + // calling avrlib's delay_us() function with low values (e.g. 1 or + // 2 microseconds) gives delays longer than desired. + //delay_us(us); +#if F_CPU >= 20000000L + // for the 20 MHz clock on rare Arduino boards + + // for a one-microsecond delay, simply wait 2 cycle and return. The overhead + // of the function call yields a delay of exactly a one microsecond. + __asm__ __volatile__ ( + "nop" "\n\t" + "nop"); //just waiting 2 cycle + if (--us == 0) + return; + + // the following loop takes a 1/5 of a microsecond (4 cycles) + // per iteration, so execute it five times for each microsecond of + // delay requested. + us = (us<<2) + us; // x5 us + + // account for the time taken in the preceeding commands. + us -= 2; + +#elif F_CPU >= 16000000L + // for the 16 MHz clock on most Arduino boards + + // for a one-microsecond delay, simply return. the overhead + // of the function call yields a delay of approximately 1 1/8 us. + if (--us == 0) + return; + + // the following loop takes a quarter of a microsecond (4 cycles) + // per iteration, so execute it four times for each microsecond of + // delay requested. + us <<= 2; + + // account for the time taken in the preceeding commands. + us -= 2; +#else + // for the 8 MHz internal clock on the ATmega168 + + // for a one- or two-microsecond delay, simply return. the overhead of + // the function calls takes more than two microseconds. can't just + // subtract two, since us is unsigned; we'd overflow. + if (--us == 0) + return; + if (--us == 0) + return; + + // the following loop takes half of a microsecond (4 cycles) + // per iteration, so execute it twice for each microsecond of + // delay requested. + us <<= 1; + + // partially compensate for the time taken by the preceeding commands. + // we can't subtract any more than this or we'd overflow w/ small delays. + us--; +#endif + + // busy wait + __asm__ __volatile__ ( + "1: sbiw %0,1" "\n\t" // 2 cycles + "brne 1b" : "=w" (us) : "0" (us) // 2 cycles + ); +} + +void init() +{ + // this needs to be called before setup() or some functions won't + // work there + sei(); + + // on the ATmega168, timer 0 is also used for fast hardware pwm + // (using phase-correct PWM would mean that timer 0 overflowed half as often + // resulting in different millis() behavior on the ATmega8 and ATmega168) +#if defined(TCCR0A) && defined(WGM01) + sbi(TCCR0A, WGM01); + sbi(TCCR0A, WGM00); +#endif + + // set timer 0 prescale factor to 64 +#if defined(__AVR_ATmega128__) + // CPU specific: different values for the ATmega128 + sbi(TCCR0, CS02); +#elif defined(TCCR0) && defined(CS01) && defined(CS00) + // this combination is for the standard atmega8 + sbi(TCCR0, CS01); + sbi(TCCR0, CS00); +#elif defined(TCCR0B) && defined(CS01) && defined(CS00) + // this combination is for the standard 168/328/1280/2560 + sbi(TCCR0B, CS01); + sbi(TCCR0B, CS00); +#elif defined(TCCR0A) && defined(CS01) && defined(CS00) + // this combination is for the __AVR_ATmega645__ series + sbi(TCCR0A, CS01); + sbi(TCCR0A, CS00); +#else + #error Timer 0 prescale factor 64 not set correctly +#endif + + // enable timer 0 overflow interrupt +#if defined(TIMSK) && defined(TOIE0) + sbi(TIMSK, TOIE0); +#elif defined(TIMSK0) && defined(TOIE0) + sbi(TIMSK0, TOIE0); +#else + #error Timer 0 overflow interrupt not set correctly +#endif + + // timers 1 and 2 are used for phase-correct hardware pwm + // this is better for motors as it ensures an even waveform + // note, however, that fast pwm mode can achieve a frequency of up + // 8 MHz (with a 16 MHz clock) at 50% duty cycle + +#if defined(TCCR1B) && defined(CS11) && defined(CS10) + TCCR1B = 0; + + // set timer 1 prescale factor to 64 + sbi(TCCR1B, CS11); +#if F_CPU >= 8000000L + sbi(TCCR1B, CS10); +#endif +#elif defined(TCCR1) && defined(CS11) && defined(CS10) + sbi(TCCR1, CS11); +#if F_CPU >= 8000000L + sbi(TCCR1, CS10); +#endif +#endif + // put timer 1 in 8-bit phase correct pwm mode +#if defined(TCCR1A) && defined(WGM10) + sbi(TCCR1A, WGM10); +#elif defined(TCCR1) + #warning this needs to be finished +#endif + + // set timer 2 prescale factor to 64 +#if defined(TCCR2) && defined(CS22) + sbi(TCCR2, CS22); +#elif defined(TCCR2B) && defined(CS22) + sbi(TCCR2B, CS22); +#else + #warning Timer 2 not finished (may not be present on this CPU) +#endif + + // configure timer 2 for phase correct pwm (8-bit) +#if defined(TCCR2) && defined(WGM20) + sbi(TCCR2, WGM20); +#elif defined(TCCR2A) && defined(WGM20) + sbi(TCCR2A, WGM20); +#else + #warning Timer 2 not finished (may not be present on this CPU) +#endif + +#if defined(TCCR3B) && defined(CS31) && defined(WGM30) + sbi(TCCR3B, CS31); // set timer 3 prescale factor to 64 + sbi(TCCR3B, CS30); + sbi(TCCR3A, WGM30); // put timer 3 in 8-bit phase correct pwm mode +#endif + +#if defined(TCCR4A) && defined(TCCR4B) && defined(TCCR4D) /* beginning of timer4 block for 32U4 and similar */ + sbi(TCCR4B, CS42); // set timer4 prescale factor to 64 + sbi(TCCR4B, CS41); + sbi(TCCR4B, CS40); + sbi(TCCR4D, WGM40); // put timer 4 in phase- and frequency-correct PWM mode + sbi(TCCR4A, PWM4A); // enable PWM mode for comparator OCR4A + sbi(TCCR4C, PWM4D); // enable PWM mode for comparator OCR4D +#else /* beginning of timer4 block for ATMEGA1280 and ATMEGA2560 */ +#if defined(TCCR4B) && defined(CS41) && defined(WGM40) + sbi(TCCR4B, CS41); // set timer 4 prescale factor to 64 + sbi(TCCR4B, CS40); + sbi(TCCR4A, WGM40); // put timer 4 in 8-bit phase correct pwm mode +#endif +#endif /* end timer4 block for ATMEGA1280/2560 and similar */ + +#if defined(TCCR5B) && defined(CS51) && defined(WGM50) + sbi(TCCR5B, CS51); // set timer 5 prescale factor to 64 + sbi(TCCR5B, CS50); + sbi(TCCR5A, WGM50); // put timer 5 in 8-bit phase correct pwm mode +#endif + +#if defined(ADCSRA) + // set a2d prescale factor to 128 + // 16 MHz / 128 = 125 KHz, inside the desired 50-200 KHz range. + // XXX: this will not work properly for other clock speeds, and + // this code should use F_CPU to determine the prescale factor. + sbi(ADCSRA, ADPS2); + sbi(ADCSRA, ADPS1); + sbi(ADCSRA, ADPS0); + + // enable a2d conversions + sbi(ADCSRA, ADEN); +#endif + + // the bootloader connects pins 0 and 1 to the USART; disconnect them + // here so they can be used as normal digital i/o; they will be + // reconnected in Serial.begin() +#if defined(UCSRB) + UCSRB = 0; +#elif defined(UCSR0B) + UCSR0B = 0; +#endif +} diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_analog.c b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_analog.c new file mode 100644 index 000000000..0e9881f6a --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_analog.c @@ -0,0 +1,282 @@ +/* + wiring_analog.c - analog input and output + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + Modified 28 September 2010 by Mark Sproul + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ + +#include "wiring_private.h" +#include "pins_arduino.h" + +uint8_t analog_reference = DEFAULT; + +void analogReference(uint8_t mode) +{ + // can't actually set the register here because the default setting + // will connect AVCC and the AREF pin, which would cause a short if + // there's something connected to AREF. + analog_reference = mode; +} + +int analogRead(uint8_t pin) +{ + uint8_t low, high; + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + if (pin >= 54) pin -= 54; // allow for channel or pin numbers +#elif defined(__AVR_ATmega32U4__) + if (pin >= 18) pin -= 18; // allow for channel or pin numbers +#elif defined(__AVR_ATmega1284__) + if (pin >= 24) pin -= 24; // allow for channel or pin numbers +#else + if (pin >= 14) pin -= 14; // allow for channel or pin numbers +#endif + +#if defined(__AVR_ATmega32U4__) + pin = analogPinToChannel(pin); + ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5); +#elif defined(ADCSRB) && defined(MUX5) + // the MUX5 bit of ADCSRB selects whether we're reading from channels + // 0 to 7 (MUX5 low) or 8 to 15 (MUX5 high). + ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((pin >> 3) & 0x01) << MUX5); +#endif + + // set the analog reference (high two bits of ADMUX) and select the + // channel (low 4 bits). this also sets ADLAR (left-adjust result) + // to 0 (the default). +#if defined(ADMUX) + ADMUX = (analog_reference << 6) | (pin & 0x07); +#endif + + // without a delay, we seem to read from the wrong channel + //delay(1); + +#if defined(ADCSRA) && defined(ADCL) + // start the conversion + sbi(ADCSRA, ADSC); + + // ADSC is cleared when the conversion finishes + while (bit_is_set(ADCSRA, ADSC)); + + // we have to read ADCL first; doing so locks both ADCL + // and ADCH until ADCH is read. reading ADCL second would + // cause the results of each conversion to be discarded, + // as ADCL and ADCH would be locked when it completed. + low = ADCL; + high = ADCH; +#else + // we dont have an ADC, return 0 + low = 0; + high = 0; +#endif + + // combine the two bytes + return (high << 8) | low; +} + +// Right now, PWM output only works on the pins with +// hardware support. These are defined in the appropriate +// pins_*.c file. For the rest of the pins, we default +// to digital output. +void analogWrite(uint8_t pin, int val) +{ + // We need to make sure the PWM output is enabled for those pins + // that support it, as we turn it off when digitally reading or + // writing with them. Also, make sure the pin is in output mode + // for consistenty with Wiring, which doesn't require a pinMode + // call for the analog output pins. + pinMode(pin, OUTPUT); + if (val == 0) + { + digitalWrite(pin, LOW); + } + else if (val == 255) + { + digitalWrite(pin, HIGH); + } + else + { + switch(digitalPinToTimer(pin)) + { + // XXX fix needed for atmega8 + #if defined(TCCR0) && defined(COM00) && !defined(__AVR_ATmega8__) + case TIMER0A: + // connect pwm to pin on timer 0 + sbi(TCCR0, COM00); + OCR0 = val; // set pwm duty + break; + #endif + + #if defined(TCCR0A) && defined(COM0A1) + case TIMER0A: + // connect pwm to pin on timer 0, channel A + sbi(TCCR0A, COM0A1); + OCR0A = val; // set pwm duty + break; + #endif + + #if defined(TCCR0A) && defined(COM0B1) + case TIMER0B: + // connect pwm to pin on timer 0, channel B + sbi(TCCR0A, COM0B1); + OCR0B = val; // set pwm duty + break; + #endif + + #if defined(TCCR1A) && defined(COM1A1) + case TIMER1A: + // connect pwm to pin on timer 1, channel A + sbi(TCCR1A, COM1A1); + OCR1A = val; // set pwm duty + break; + #endif + + #if defined(TCCR1A) && defined(COM1B1) + case TIMER1B: + // connect pwm to pin on timer 1, channel B + sbi(TCCR1A, COM1B1); + OCR1B = val; // set pwm duty + break; + #endif + + #if defined(TCCR2) && defined(COM21) + case TIMER2: + // connect pwm to pin on timer 2 + sbi(TCCR2, COM21); + OCR2 = val; // set pwm duty + break; + #endif + + #if defined(TCCR2A) && defined(COM2A1) + case TIMER2A: + // connect pwm to pin on timer 2, channel A + sbi(TCCR2A, COM2A1); + OCR2A = val; // set pwm duty + break; + #endif + + #if defined(TCCR2A) && defined(COM2B1) + case TIMER2B: + // connect pwm to pin on timer 2, channel B + sbi(TCCR2A, COM2B1); + OCR2B = val; // set pwm duty + break; + #endif + + #if defined(TCCR3A) && defined(COM3A1) + case TIMER3A: + // connect pwm to pin on timer 3, channel A + sbi(TCCR3A, COM3A1); + OCR3A = val; // set pwm duty + break; + #endif + + #if defined(TCCR3A) && defined(COM3B1) + case TIMER3B: + // connect pwm to pin on timer 3, channel B + sbi(TCCR3A, COM3B1); + OCR3B = val; // set pwm duty + break; + #endif + + #if defined(TCCR3A) && defined(COM3C1) + case TIMER3C: + // connect pwm to pin on timer 3, channel C + sbi(TCCR3A, COM3C1); + OCR3C = val; // set pwm duty + break; + #endif + + #if defined(TCCR4A) + case TIMER4A: + //connect pwm to pin on timer 4, channel A + sbi(TCCR4A, COM4A1); + #if defined(COM4A0) // only used on 32U4 + cbi(TCCR4A, COM4A0); + #endif + OCR4A = val; // set pwm duty + break; + #endif + + #if defined(TCCR4A) && defined(COM4B1) + case TIMER4B: + // connect pwm to pin on timer 4, channel B + sbi(TCCR4A, COM4B1); + OCR4B = val; // set pwm duty + break; + #endif + + #if defined(TCCR4A) && defined(COM4C1) + case TIMER4C: + // connect pwm to pin on timer 4, channel C + sbi(TCCR4A, COM4C1); + OCR4C = val; // set pwm duty + break; + #endif + + #if defined(TCCR4C) && defined(COM4D1) + case TIMER4D: + // connect pwm to pin on timer 4, channel D + sbi(TCCR4C, COM4D1); + #if defined(COM4D0) // only used on 32U4 + cbi(TCCR4C, COM4D0); + #endif + OCR4D = val; // set pwm duty + break; + #endif + + + #if defined(TCCR5A) && defined(COM5A1) + case TIMER5A: + // connect pwm to pin on timer 5, channel A + sbi(TCCR5A, COM5A1); + OCR5A = val; // set pwm duty + break; + #endif + + #if defined(TCCR5A) && defined(COM5B1) + case TIMER5B: + // connect pwm to pin on timer 5, channel B + sbi(TCCR5A, COM5B1); + OCR5B = val; // set pwm duty + break; + #endif + + #if defined(TCCR5A) && defined(COM5C1) + case TIMER5C: + // connect pwm to pin on timer 5, channel C + sbi(TCCR5A, COM5C1); + OCR5C = val; // set pwm duty + break; + #endif + + case NOT_ON_TIMER: + default: + if (val < 128) { + digitalWrite(pin, LOW); + } else { + digitalWrite(pin, HIGH); + } + } + } +} + diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_digital.c b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_digital.c new file mode 100644 index 000000000..be323b1df --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_digital.c @@ -0,0 +1,178 @@ +/* + wiring_digital.c - digital input and output functions + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + Modified 28 September 2010 by Mark Sproul + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ + +#define ARDUINO_MAIN +#include "wiring_private.h" +#include "pins_arduino.h" + +void pinMode(uint8_t pin, uint8_t mode) +{ + uint8_t bit = digitalPinToBitMask(pin); + uint8_t port = digitalPinToPort(pin); + volatile uint8_t *reg, *out; + + if (port == NOT_A_PIN) return; + + // JWS: can I let the optimizer do this? + reg = portModeRegister(port); + out = portOutputRegister(port); + + if (mode == INPUT) { + uint8_t oldSREG = SREG; + cli(); + *reg &= ~bit; + *out &= ~bit; + SREG = oldSREG; + } else if (mode == INPUT_PULLUP) { + uint8_t oldSREG = SREG; + cli(); + *reg &= ~bit; + *out |= bit; + SREG = oldSREG; + } else { + uint8_t oldSREG = SREG; + cli(); + *reg |= bit; + SREG = oldSREG; + } +} + +// Forcing this inline keeps the callers from having to push their own stuff +// on the stack. It is a good performance win and only takes 1 more byte per +// user than calling. (It will take more bytes on the 168.) +// +// But shouldn't this be moved into pinMode? Seems silly to check and do on +// each digitalread or write. +// +// Mark Sproul: +// - Removed inline. Save 170 bytes on atmega1280 +// - changed to a switch statment; added 32 bytes but much easier to read and maintain. +// - Added more #ifdefs, now compiles for atmega645 +// +//static inline void turnOffPWM(uint8_t timer) __attribute__ ((always_inline)); +//static inline void turnOffPWM(uint8_t timer) +static void turnOffPWM(uint8_t timer) +{ + switch (timer) + { + #if defined(TCCR1A) && defined(COM1A1) + case TIMER1A: cbi(TCCR1A, COM1A1); break; + #endif + #if defined(TCCR1A) && defined(COM1B1) + case TIMER1B: cbi(TCCR1A, COM1B1); break; + #endif + + #if defined(TCCR2) && defined(COM21) + case TIMER2: cbi(TCCR2, COM21); break; + #endif + + #if defined(TCCR0A) && defined(COM0A1) + case TIMER0A: cbi(TCCR0A, COM0A1); break; + #endif + + #if defined(TIMER0B) && defined(COM0B1) + case TIMER0B: cbi(TCCR0A, COM0B1); break; + #endif + #if defined(TCCR2A) && defined(COM2A1) + case TIMER2A: cbi(TCCR2A, COM2A1); break; + #endif + #if defined(TCCR2A) && defined(COM2B1) + case TIMER2B: cbi(TCCR2A, COM2B1); break; + #endif + + #if defined(TCCR3A) && defined(COM3A1) + case TIMER3A: cbi(TCCR3A, COM3A1); break; + #endif + #if defined(TCCR3A) && defined(COM3B1) + case TIMER3B: cbi(TCCR3A, COM3B1); break; + #endif + #if defined(TCCR3A) && defined(COM3C1) + case TIMER3C: cbi(TCCR3A, COM3C1); break; + #endif + + #if defined(TCCR4A) && defined(COM4A1) + case TIMER4A: cbi(TCCR4A, COM4A1); break; + #endif + #if defined(TCCR4A) && defined(COM4B1) + case TIMER4B: cbi(TCCR4A, COM4B1); break; + #endif + #if defined(TCCR4A) && defined(COM4C1) + case TIMER4C: cbi(TCCR4A, COM4C1); break; + #endif + #if defined(TCCR4C) && defined(COM4D1) + case TIMER4D: cbi(TCCR4C, COM4D1); break; + #endif + + #if defined(TCCR5A) + case TIMER5A: cbi(TCCR5A, COM5A1); break; + case TIMER5B: cbi(TCCR5A, COM5B1); break; + case TIMER5C: cbi(TCCR5A, COM5C1); break; + #endif + } +} + +void digitalWrite(uint8_t pin, uint8_t val) +{ + uint8_t timer = digitalPinToTimer(pin); + uint8_t bit = digitalPinToBitMask(pin); + uint8_t port = digitalPinToPort(pin); + volatile uint8_t *out; + + if (port == NOT_A_PIN) return; + + // If the pin that support PWM output, we need to turn it off + // before doing a digital write. + if (timer != NOT_ON_TIMER) turnOffPWM(timer); + + out = portOutputRegister(port); + + uint8_t oldSREG = SREG; + cli(); + + if (val == LOW) { + *out &= ~bit; + } else { + *out |= bit; + } + + SREG = oldSREG; +} + +int digitalRead(uint8_t pin) +{ + uint8_t timer = digitalPinToTimer(pin); + uint8_t bit = digitalPinToBitMask(pin); + uint8_t port = digitalPinToPort(pin); + + if (port == NOT_A_PIN) return LOW; + + // If the pin that support PWM output, we need to turn it off + // before getting a digital reading. + if (timer != NOT_ON_TIMER) turnOffPWM(timer); + + if (*portInputRegister(port) & bit) return HIGH; + return LOW; +} diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_private.h b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_private.h new file mode 100644 index 000000000..f0ceb0cc4 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_private.h @@ -0,0 +1,69 @@ +/* + wiring_private.h - Internal header file. + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 239 2007-01-12 17:58:39Z mellis $ +*/ + +#ifndef WiringPrivate_h +#define WiringPrivate_h + +#include +#include +#include +#include + +#include "Arduino.h" + +#ifdef __cplusplus +extern "C"{ +#endif + +#ifndef cbi +#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) +#endif +#ifndef sbi +#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) +#endif + +#define EXTERNAL_INT_0 0 +#define EXTERNAL_INT_1 1 +#define EXTERNAL_INT_2 2 +#define EXTERNAL_INT_3 3 +#define EXTERNAL_INT_4 4 +#define EXTERNAL_INT_5 5 +#define EXTERNAL_INT_6 6 +#define EXTERNAL_INT_7 7 + +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#define EXTERNAL_NUM_INTERRUPTS 8 +#elif defined(__AVR_ATmega1284P__) +#define EXTERNAL_NUM_INTERRUPTS 3 +#else +#define EXTERNAL_NUM_INTERRUPTS 2 +#endif + +typedef void (*voidFuncPtr)(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_pulse.c b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_pulse.c new file mode 100644 index 000000000..0d968865d --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_pulse.c @@ -0,0 +1,69 @@ +/* + wiring_pulse.c - pulseIn() function + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ + +#include "wiring_private.h" +#include "pins_arduino.h" + +/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH + * or LOW, the type of pulse to measure. Works on pulses from 2-3 microseconds + * to 3 minutes in length, but must be called at least a few dozen microseconds + * before the start of the pulse. */ +unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) +{ + // cache the port and bit of the pin in order to speed up the + // pulse width measuring loop and achieve finer resolution. calling + // digitalRead() instead yields much coarser resolution. + uint8_t bit = digitalPinToBitMask(pin); + uint8_t port = digitalPinToPort(pin); + uint8_t stateMask = (state ? bit : 0); + unsigned long width = 0; // keep initialization out of time critical area + + // convert the timeout from microseconds to a number of times through + // the initial loop; it takes 16 clock cycles per iteration. + unsigned long numloops = 0; + unsigned long maxloops = microsecondsToClockCycles(timeout) / 16; + + // wait for any previous pulse to end + while ((*portInputRegister(port) & bit) == stateMask) + if (numloops++ == maxloops) + return 0; + + // wait for the pulse to start + while ((*portInputRegister(port) & bit) != stateMask) + if (numloops++ == maxloops) + return 0; + + // wait for the pulse to stop + while ((*portInputRegister(port) & bit) == stateMask) { + if (numloops++ == maxloops) + return 0; + width++; + } + + // convert the reading to microseconds. The loop has been determined + // to be 20 clock cycles long and have about 16 clocks between the edge + // and the start of the loop. There will be some error introduced by + // the interrupt handlers. + return clockCyclesToMicroseconds(width * 21 + 16); +} diff --git a/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_shift.c b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_shift.c new file mode 100644 index 000000000..cfe786758 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/cores/arduino/wiring_shift.c @@ -0,0 +1,55 @@ +/* + wiring_shift.c - shiftOut() function + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2005-2006 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.c 248 2007-02-03 15:36:30Z mellis $ +*/ + +#include "wiring_private.h" + +uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { + uint8_t value = 0; + uint8_t i; + + for (i = 0; i < 8; ++i) { + digitalWrite(clockPin, HIGH); + if (bitOrder == LSBFIRST) + value |= digitalRead(dataPin) << i; + else + value |= digitalRead(dataPin) << (7 - i); + digitalWrite(clockPin, LOW); + } + return value; +} + +void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) +{ + uint8_t i; + + for (i = 0; i < 8; i++) { + if (bitOrder == LSBFIRST) + digitalWrite(dataPin, !!(val & (1 << i))); + else + digitalWrite(dataPin, !!(val & (1 << (7 - i)))); + + digitalWrite(clockPin, HIGH); + digitalWrite(clockPin, LOW); + } +} diff --git a/protocol/usb_hid/arduino-1.0.1/variants/eightanaloginputs/pins_arduino.h b/protocol/usb_hid/arduino-1.0.1/variants/eightanaloginputs/pins_arduino.h new file mode 100644 index 000000000..52b37efc4 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/variants/eightanaloginputs/pins_arduino.h @@ -0,0 +1,27 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#include "../standard/pins_arduino.h" +#undef NUM_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 8 diff --git a/protocol/usb_hid/arduino-1.0.1/variants/leonardo/pins_arduino.h b/protocol/usb_hid/arduino-1.0.1/variants/leonardo/pins_arduino.h new file mode 100644 index 000000000..9f770d6ce --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/variants/leonardo/pins_arduino.h @@ -0,0 +1,256 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) +#define TXLED0 PORTD |= (1<<5) +#define TXLED1 PORTD &= ~(1<<5) +#define RXLED0 PORTB |= (1<<0) +#define RXLED1 PORTB &= ~(1<<0) + +static const uint8_t SDA = 2; +static const uint8_t SCL = 3; + +// Map SPI port to 'new' pins D14..D17 +static const uint8_t SS = 17; +static const uint8_t MOSI = 16; +static const uint8_t MISO = 14; +static const uint8_t SCK = 15; + +// Mapping of analog pins as digital I/O +// A6-A11 share with digital pins +static const uint8_t A0 = 18; +static const uint8_t A1 = 19; +static const uint8_t A2 = 20; +static const uint8_t A3 = 21; +static const uint8_t A4 = 22; +static const uint8_t A5 = 23; +static const uint8_t A6 = 24; // D4 +static const uint8_t A7 = 25; // D6 +static const uint8_t A8 = 26; // D8 +static const uint8_t A9 = 27; // D9 +static const uint8_t A10 = 28; // D10 +static const uint8_t A11 = 29; // D12 + +#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) +#define digitalPinToPCICRbit(p) 0 +#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) +#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) + +// __AVR_ATmega32U4__ has an unusual mapping of pins to channels +extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; +#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) + +#ifdef ARDUINO_MAIN + +// On the Arduino board, digital pins are also used +// for the analog output (software PWM). Analog input +// pins are a separate set. + +// ATMEL ATMEGA32U4 / ARDUINO LEONARDO +// +// D0 PD2 RXD1/INT2 +// D1 PD3 TXD1/INT3 +// D2 PD1 SDA SDA/INT1 +// D3# PD0 PWM8/SCL OC0B/SCL/INT0 +// D4 A6 PD4 ADC8 +// D5# PC6 ??? OC3A/#OC4A +// D6# A7 PD7 FastPWM #OC4D/ADC10 +// D7 PE6 INT6/AIN0 +// +// D8 A8 PB4 ADC11/PCINT4 +// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5 +// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6 +// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7 +// D12 A11 PD6 T1/#OC4D/ADC9 +// D13# PC7 PWM10 CLK0/OC4A +// +// A0 D18 PF7 ADC7 +// A1 D19 PF6 ADC6 +// A2 D20 PF5 ADC5 +// A3 D21 PF4 ADC4 +// A4 D22 PF1 ADC1 +// A5 D23 PF0 ADC0 +// +// New pins D14..D17 to map SPI port to digital pins +// +// MISO D14 PB3 MISO,PCINT3 +// SCK D15 PB1 SCK,PCINT1 +// MOSI D16 PB2 MOSI,PCINT2 +// SS D17 PB0 RXLED,SS/PCINT0 +// +// TXLED PD5 +// RXLED PB0 +// HWB PE2 HWB + +// these arrays map port names (e.g. port B) to the +// appropriate addresses for various functions (e.g. reading +// and writing) +const uint16_t PROGMEM port_to_mode_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, + (uint16_t) &DDRE, + (uint16_t) &DDRF, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, + (uint16_t) &PORTE, + (uint16_t) &PORTF, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, + (uint16_t) &PINE, + (uint16_t) &PINF, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[30] = { + PD, // D0 - PD2 + PD, // D1 - PD3 + PD, // D2 - PD1 + PD, // D3 - PD0 + PD, // D4 - PD4 + PC, // D5 - PC6 + PD, // D6 - PD7 + PE, // D7 - PE6 + + PB, // D8 - PB4 + PB, // D9 - PB5 + PB, // D10 - PB6 + PB, // D11 - PB7 + PD, // D12 - PD6 + PC, // D13 - PC7 + + PB, // D14 - MISO - PB3 + PB, // D15 - SCK - PB1 + PB, // D16 - MOSI - PB2 + PB, // D17 - SS - PB0 + + PF, // D18 - A0 - PF7 + PF, // D19 - A1 - PF6 + PF, // D20 - A2 - PF5 + PF, // D21 - A3 - PF4 + PF, // D22 - A4 - PF1 + PF, // D23 - A5 - PF0 + + PD, // D24 / D4 - A6 - PD4 + PD, // D25 / D6 - A7 - PD7 + PB, // D26 / D8 - A8 - PB4 + PB, // D27 / D9 - A9 - PB5 + PB, // D28 / D10 - A10 - PB6 + PD, // D29 / D12 - A11 - PD6 +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[30] = { + _BV(2), // D0 - PD2 + _BV(3), // D1 - PD3 + _BV(1), // D2 - PD1 + _BV(0), // D3 - PD0 + _BV(4), // D4 - PD4 + _BV(6), // D5 - PC6 + _BV(7), // D6 - PD7 + _BV(6), // D7 - PE6 + + _BV(4), // D8 - PB4 + _BV(5), // D9 - PB5 + _BV(6), // D10 - PB6 + _BV(7), // D11 - PB7 + _BV(6), // D12 - PD6 + _BV(7), // D13 - PC7 + + _BV(3), // D14 - MISO - PB3 + _BV(1), // D15 - SCK - PB1 + _BV(2), // D16 - MOSI - PB2 + _BV(0), // D17 - SS - PB0 + + _BV(7), // D18 - A0 - PF7 + _BV(6), // D19 - A1 - PF6 + _BV(5), // D20 - A2 - PF5 + _BV(4), // D21 - A3 - PF4 + _BV(1), // D22 - A4 - PF1 + _BV(0), // D23 - A5 - PF0 + + _BV(4), // D24 / D4 - A6 - PD4 + _BV(7), // D25 / D6 - A7 - PD7 + _BV(4), // D26 / D8 - A8 - PB4 + _BV(5), // D27 / D9 - A9 - PB5 + _BV(6), // D28 / D10 - A10 - PB6 + _BV(6), // D29 / D12 - A11 - PD6 +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[16] = { + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + TIMER0B, /* 3 */ + NOT_ON_TIMER, + TIMER3A, /* 5 */ + TIMER4D, /* 6 */ + NOT_ON_TIMER, + + NOT_ON_TIMER, + TIMER1A, /* 9 */ + TIMER1B, /* 10 */ + TIMER0A, /* 11 */ + + NOT_ON_TIMER, + TIMER4A, /* 13 */ + + NOT_ON_TIMER, + NOT_ON_TIMER, +}; + +const uint8_t PROGMEM analog_pin_to_channel_PGM[12] = { + 7, // A0 PF7 ADC7 + 6, // A1 PF6 ADC6 + 5, // A2 PF5 ADC5 + 4, // A3 PF4 ADC4 + 1, // A4 PF1 ADC1 + 0, // A5 PF0 ADC0 + 8, // A6 D4 PD4 ADC8 + 10, // A7 D6 PD7 ADC10 + 11, // A8 D8 PB4 ADC11 + 12, // A9 D9 PB5 ADC12 + 13, // A10 D10 PB6 ADC13 + 9 // A11 D12 PD6 ADC9 +}; + +#endif /* ARDUINO_MAIN */ +#endif /* Pins_Arduino_h */ diff --git a/protocol/usb_hid/arduino-1.0.1/variants/mega/pins_arduino.h b/protocol/usb_hid/arduino-1.0.1/variants/mega/pins_arduino.h new file mode 100644 index 000000000..5a9b4cb09 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/variants/mega/pins_arduino.h @@ -0,0 +1,363 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define NUM_DIGITAL_PINS 70 +#define NUM_ANALOG_INPUTS 16 +#define analogInputToDigitalPin(p) ((p < 16) ? (p) + 54 : -1) +#define digitalPinHasPWM(p) (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46)) + +static const uint8_t SS = 53; +static const uint8_t MOSI = 51; +static const uint8_t MISO = 50; +static const uint8_t SCK = 52; + +static const uint8_t SDA = 20; +static const uint8_t SCL = 21; +static const uint8_t LED_BUILTIN = 13; + +static const uint8_t A0 = 54; +static const uint8_t A1 = 55; +static const uint8_t A2 = 56; +static const uint8_t A3 = 57; +static const uint8_t A4 = 58; +static const uint8_t A5 = 59; +static const uint8_t A6 = 60; +static const uint8_t A7 = 61; +static const uint8_t A8 = 62; +static const uint8_t A9 = 63; +static const uint8_t A10 = 64; +static const uint8_t A11 = 65; +static const uint8_t A12 = 66; +static const uint8_t A13 = 67; +static const uint8_t A14 = 68; +static const uint8_t A15 = 69; + +// A majority of the pins are NOT PCINTs, SO BE WARNED (i.e. you cannot use them as receive pins) +// Only pins available for RECEIVE (TRANSMIT can be on any pin): +// (I've deliberately left out pin mapping to the Hardware USARTs - seems senseless to me) +// Pins: 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69 + +#define digitalPinToPCICR(p) ( (((p) >= 10) && ((p) <= 13)) || \ + (((p) >= 50) && ((p) <= 53)) || \ + (((p) >= 62) && ((p) <= 69)) ? (&PCICR) : ((uint8_t *)0) ) + +#define digitalPinToPCICRbit(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? 0 : \ + ( (((p) >= 62) && ((p) <= 69)) ? 2 : \ + 0 ) ) + +#define digitalPinToPCMSK(p) ( (((p) >= 10) && ((p) <= 13)) || (((p) >= 50) && ((p) <= 53)) ? (&PCMSK0) : \ + ( (((p) >= 62) && ((p) <= 69)) ? (&PCMSK2) : \ + ((uint8_t *)0) ) ) + +#define digitalPinToPCMSKbit(p) ( (((p) >= 10) && ((p) <= 13)) ? ((p) - 6) : \ + ( ((p) == 50) ? 3 : \ + ( ((p) == 51) ? 2 : \ + ( ((p) == 52) ? 1 : \ + ( ((p) == 53) ? 0 : \ + ( (((p) >= 62) && ((p) <= 69)) ? ((p) - 62) : \ + 0 ) ) ) ) ) ) + +#ifdef ARDUINO_MAIN + +const uint16_t PROGMEM port_to_mode_PGM[] = { + NOT_A_PORT, + (uint16_t) &DDRA, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, + (uint16_t) &DDRE, + (uint16_t) &DDRF, + (uint16_t) &DDRG, + (uint16_t) &DDRH, + NOT_A_PORT, + (uint16_t) &DDRJ, + (uint16_t) &DDRK, + (uint16_t) &DDRL, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + (uint16_t) &PORTA, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, + (uint16_t) &PORTE, + (uint16_t) &PORTF, + (uint16_t) &PORTG, + (uint16_t) &PORTH, + NOT_A_PORT, + (uint16_t) &PORTJ, + (uint16_t) &PORTK, + (uint16_t) &PORTL, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PIN, + (uint16_t) &PINA, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, + (uint16_t) &PINE, + (uint16_t) &PINF, + (uint16_t) &PING, + (uint16_t) &PINH, + NOT_A_PIN, + (uint16_t) &PINJ, + (uint16_t) &PINK, + (uint16_t) &PINL, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { + // PORTLIST + // ------------------------------------------- + PE , // PE 0 ** 0 ** USART0_RX + PE , // PE 1 ** 1 ** USART0_TX + PE , // PE 4 ** 2 ** PWM2 + PE , // PE 5 ** 3 ** PWM3 + PG , // PG 5 ** 4 ** PWM4 + PE , // PE 3 ** 5 ** PWM5 + PH , // PH 3 ** 6 ** PWM6 + PH , // PH 4 ** 7 ** PWM7 + PH , // PH 5 ** 8 ** PWM8 + PH , // PH 6 ** 9 ** PWM9 + PB , // PB 4 ** 10 ** PWM10 + PB , // PB 5 ** 11 ** PWM11 + PB , // PB 6 ** 12 ** PWM12 + PB , // PB 7 ** 13 ** PWM13 + PJ , // PJ 1 ** 14 ** USART3_TX + PJ , // PJ 0 ** 15 ** USART3_RX + PH , // PH 1 ** 16 ** USART2_TX + PH , // PH 0 ** 17 ** USART2_RX + PD , // PD 3 ** 18 ** USART1_TX + PD , // PD 2 ** 19 ** USART1_RX + PD , // PD 1 ** 20 ** I2C_SDA + PD , // PD 0 ** 21 ** I2C_SCL + PA , // PA 0 ** 22 ** D22 + PA , // PA 1 ** 23 ** D23 + PA , // PA 2 ** 24 ** D24 + PA , // PA 3 ** 25 ** D25 + PA , // PA 4 ** 26 ** D26 + PA , // PA 5 ** 27 ** D27 + PA , // PA 6 ** 28 ** D28 + PA , // PA 7 ** 29 ** D29 + PC , // PC 7 ** 30 ** D30 + PC , // PC 6 ** 31 ** D31 + PC , // PC 5 ** 32 ** D32 + PC , // PC 4 ** 33 ** D33 + PC , // PC 3 ** 34 ** D34 + PC , // PC 2 ** 35 ** D35 + PC , // PC 1 ** 36 ** D36 + PC , // PC 0 ** 37 ** D37 + PD , // PD 7 ** 38 ** D38 + PG , // PG 2 ** 39 ** D39 + PG , // PG 1 ** 40 ** D40 + PG , // PG 0 ** 41 ** D41 + PL , // PL 7 ** 42 ** D42 + PL , // PL 6 ** 43 ** D43 + PL , // PL 5 ** 44 ** D44 + PL , // PL 4 ** 45 ** D45 + PL , // PL 3 ** 46 ** D46 + PL , // PL 2 ** 47 ** D47 + PL , // PL 1 ** 48 ** D48 + PL , // PL 0 ** 49 ** D49 + PB , // PB 3 ** 50 ** SPI_MISO + PB , // PB 2 ** 51 ** SPI_MOSI + PB , // PB 1 ** 52 ** SPI_SCK + PB , // PB 0 ** 53 ** SPI_SS + PF , // PF 0 ** 54 ** A0 + PF , // PF 1 ** 55 ** A1 + PF , // PF 2 ** 56 ** A2 + PF , // PF 3 ** 57 ** A3 + PF , // PF 4 ** 58 ** A4 + PF , // PF 5 ** 59 ** A5 + PF , // PF 6 ** 60 ** A6 + PF , // PF 7 ** 61 ** A7 + PK , // PK 0 ** 62 ** A8 + PK , // PK 1 ** 63 ** A9 + PK , // PK 2 ** 64 ** A10 + PK , // PK 3 ** 65 ** A11 + PK , // PK 4 ** 66 ** A12 + PK , // PK 5 ** 67 ** A13 + PK , // PK 6 ** 68 ** A14 + PK , // PK 7 ** 69 ** A15 +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + // PIN IN PORT + // ------------------------------------------- + _BV( 0 ) , // PE 0 ** 0 ** USART0_RX + _BV( 1 ) , // PE 1 ** 1 ** USART0_TX + _BV( 4 ) , // PE 4 ** 2 ** PWM2 + _BV( 5 ) , // PE 5 ** 3 ** PWM3 + _BV( 5 ) , // PG 5 ** 4 ** PWM4 + _BV( 3 ) , // PE 3 ** 5 ** PWM5 + _BV( 3 ) , // PH 3 ** 6 ** PWM6 + _BV( 4 ) , // PH 4 ** 7 ** PWM7 + _BV( 5 ) , // PH 5 ** 8 ** PWM8 + _BV( 6 ) , // PH 6 ** 9 ** PWM9 + _BV( 4 ) , // PB 4 ** 10 ** PWM10 + _BV( 5 ) , // PB 5 ** 11 ** PWM11 + _BV( 6 ) , // PB 6 ** 12 ** PWM12 + _BV( 7 ) , // PB 7 ** 13 ** PWM13 + _BV( 1 ) , // PJ 1 ** 14 ** USART3_TX + _BV( 0 ) , // PJ 0 ** 15 ** USART3_RX + _BV( 1 ) , // PH 1 ** 16 ** USART2_TX + _BV( 0 ) , // PH 0 ** 17 ** USART2_RX + _BV( 3 ) , // PD 3 ** 18 ** USART1_TX + _BV( 2 ) , // PD 2 ** 19 ** USART1_RX + _BV( 1 ) , // PD 1 ** 20 ** I2C_SDA + _BV( 0 ) , // PD 0 ** 21 ** I2C_SCL + _BV( 0 ) , // PA 0 ** 22 ** D22 + _BV( 1 ) , // PA 1 ** 23 ** D23 + _BV( 2 ) , // PA 2 ** 24 ** D24 + _BV( 3 ) , // PA 3 ** 25 ** D25 + _BV( 4 ) , // PA 4 ** 26 ** D26 + _BV( 5 ) , // PA 5 ** 27 ** D27 + _BV( 6 ) , // PA 6 ** 28 ** D28 + _BV( 7 ) , // PA 7 ** 29 ** D29 + _BV( 7 ) , // PC 7 ** 30 ** D30 + _BV( 6 ) , // PC 6 ** 31 ** D31 + _BV( 5 ) , // PC 5 ** 32 ** D32 + _BV( 4 ) , // PC 4 ** 33 ** D33 + _BV( 3 ) , // PC 3 ** 34 ** D34 + _BV( 2 ) , // PC 2 ** 35 ** D35 + _BV( 1 ) , // PC 1 ** 36 ** D36 + _BV( 0 ) , // PC 0 ** 37 ** D37 + _BV( 7 ) , // PD 7 ** 38 ** D38 + _BV( 2 ) , // PG 2 ** 39 ** D39 + _BV( 1 ) , // PG 1 ** 40 ** D40 + _BV( 0 ) , // PG 0 ** 41 ** D41 + _BV( 7 ) , // PL 7 ** 42 ** D42 + _BV( 6 ) , // PL 6 ** 43 ** D43 + _BV( 5 ) , // PL 5 ** 44 ** D44 + _BV( 4 ) , // PL 4 ** 45 ** D45 + _BV( 3 ) , // PL 3 ** 46 ** D46 + _BV( 2 ) , // PL 2 ** 47 ** D47 + _BV( 1 ) , // PL 1 ** 48 ** D48 + _BV( 0 ) , // PL 0 ** 49 ** D49 + _BV( 3 ) , // PB 3 ** 50 ** SPI_MISO + _BV( 2 ) , // PB 2 ** 51 ** SPI_MOSI + _BV( 1 ) , // PB 1 ** 52 ** SPI_SCK + _BV( 0 ) , // PB 0 ** 53 ** SPI_SS + _BV( 0 ) , // PF 0 ** 54 ** A0 + _BV( 1 ) , // PF 1 ** 55 ** A1 + _BV( 2 ) , // PF 2 ** 56 ** A2 + _BV( 3 ) , // PF 3 ** 57 ** A3 + _BV( 4 ) , // PF 4 ** 58 ** A4 + _BV( 5 ) , // PF 5 ** 59 ** A5 + _BV( 6 ) , // PF 6 ** 60 ** A6 + _BV( 7 ) , // PF 7 ** 61 ** A7 + _BV( 0 ) , // PK 0 ** 62 ** A8 + _BV( 1 ) , // PK 1 ** 63 ** A9 + _BV( 2 ) , // PK 2 ** 64 ** A10 + _BV( 3 ) , // PK 3 ** 65 ** A11 + _BV( 4 ) , // PK 4 ** 66 ** A12 + _BV( 5 ) , // PK 5 ** 67 ** A13 + _BV( 6 ) , // PK 6 ** 68 ** A14 + _BV( 7 ) , // PK 7 ** 69 ** A15 +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { + // TIMERS + // ------------------------------------------- + NOT_ON_TIMER , // PE 0 ** 0 ** USART0_RX + NOT_ON_TIMER , // PE 1 ** 1 ** USART0_TX + TIMER3B , // PE 4 ** 2 ** PWM2 + TIMER3C , // PE 5 ** 3 ** PWM3 + TIMER0B , // PG 5 ** 4 ** PWM4 + TIMER3A , // PE 3 ** 5 ** PWM5 + TIMER4A , // PH 3 ** 6 ** PWM6 + TIMER4B , // PH 4 ** 7 ** PWM7 + TIMER4C , // PH 5 ** 8 ** PWM8 + TIMER2B , // PH 6 ** 9 ** PWM9 + TIMER2A , // PB 4 ** 10 ** PWM10 + TIMER1A , // PB 5 ** 11 ** PWM11 + TIMER1B , // PB 6 ** 12 ** PWM12 + TIMER0A , // PB 7 ** 13 ** PWM13 + NOT_ON_TIMER , // PJ 1 ** 14 ** USART3_TX + NOT_ON_TIMER , // PJ 0 ** 15 ** USART3_RX + NOT_ON_TIMER , // PH 1 ** 16 ** USART2_TX + NOT_ON_TIMER , // PH 0 ** 17 ** USART2_RX + NOT_ON_TIMER , // PD 3 ** 18 ** USART1_TX + NOT_ON_TIMER , // PD 2 ** 19 ** USART1_RX + NOT_ON_TIMER , // PD 1 ** 20 ** I2C_SDA + NOT_ON_TIMER , // PD 0 ** 21 ** I2C_SCL + NOT_ON_TIMER , // PA 0 ** 22 ** D22 + NOT_ON_TIMER , // PA 1 ** 23 ** D23 + NOT_ON_TIMER , // PA 2 ** 24 ** D24 + NOT_ON_TIMER , // PA 3 ** 25 ** D25 + NOT_ON_TIMER , // PA 4 ** 26 ** D26 + NOT_ON_TIMER , // PA 5 ** 27 ** D27 + NOT_ON_TIMER , // PA 6 ** 28 ** D28 + NOT_ON_TIMER , // PA 7 ** 29 ** D29 + NOT_ON_TIMER , // PC 7 ** 30 ** D30 + NOT_ON_TIMER , // PC 6 ** 31 ** D31 + NOT_ON_TIMER , // PC 5 ** 32 ** D32 + NOT_ON_TIMER , // PC 4 ** 33 ** D33 + NOT_ON_TIMER , // PC 3 ** 34 ** D34 + NOT_ON_TIMER , // PC 2 ** 35 ** D35 + NOT_ON_TIMER , // PC 1 ** 36 ** D36 + NOT_ON_TIMER , // PC 0 ** 37 ** D37 + NOT_ON_TIMER , // PD 7 ** 38 ** D38 + NOT_ON_TIMER , // PG 2 ** 39 ** D39 + NOT_ON_TIMER , // PG 1 ** 40 ** D40 + NOT_ON_TIMER , // PG 0 ** 41 ** D41 + NOT_ON_TIMER , // PL 7 ** 42 ** D42 + NOT_ON_TIMER , // PL 6 ** 43 ** D43 + TIMER5C , // PL 5 ** 44 ** D44 + TIMER5B , // PL 4 ** 45 ** D45 + TIMER5A , // PL 3 ** 46 ** D46 + NOT_ON_TIMER , // PL 2 ** 47 ** D47 + NOT_ON_TIMER , // PL 1 ** 48 ** D48 + NOT_ON_TIMER , // PL 0 ** 49 ** D49 + NOT_ON_TIMER , // PB 3 ** 50 ** SPI_MISO + NOT_ON_TIMER , // PB 2 ** 51 ** SPI_MOSI + NOT_ON_TIMER , // PB 1 ** 52 ** SPI_SCK + NOT_ON_TIMER , // PB 0 ** 53 ** SPI_SS + NOT_ON_TIMER , // PF 0 ** 54 ** A0 + NOT_ON_TIMER , // PF 1 ** 55 ** A1 + NOT_ON_TIMER , // PF 2 ** 56 ** A2 + NOT_ON_TIMER , // PF 3 ** 57 ** A3 + NOT_ON_TIMER , // PF 4 ** 58 ** A4 + NOT_ON_TIMER , // PF 5 ** 59 ** A5 + NOT_ON_TIMER , // PF 6 ** 60 ** A6 + NOT_ON_TIMER , // PF 7 ** 61 ** A7 + NOT_ON_TIMER , // PK 0 ** 62 ** A8 + NOT_ON_TIMER , // PK 1 ** 63 ** A9 + NOT_ON_TIMER , // PK 2 ** 64 ** A10 + NOT_ON_TIMER , // PK 3 ** 65 ** A11 + NOT_ON_TIMER , // PK 4 ** 66 ** A12 + NOT_ON_TIMER , // PK 5 ** 67 ** A13 + NOT_ON_TIMER , // PK 6 ** 68 ** A14 + NOT_ON_TIMER , // PK 7 ** 69 ** A15 +}; + +#endif + +#endif \ No newline at end of file diff --git a/protocol/usb_hid/arduino-1.0.1/variants/standard/pins_arduino.h b/protocol/usb_hid/arduino-1.0.1/variants/standard/pins_arduino.h new file mode 100644 index 000000000..30b426630 --- /dev/null +++ b/protocol/usb_hid/arduino-1.0.1/variants/standard/pins_arduino.h @@ -0,0 +1,218 @@ +/* + pins_arduino.h - Pin definition functions for Arduino + Part of Arduino - http://www.arduino.cc/ + + Copyright (c) 2007 David A. Mellis + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General + Public License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, + Boston, MA 02111-1307 USA + + $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ +*/ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define NUM_DIGITAL_PINS 20 +#define NUM_ANALOG_INPUTS 6 +#define analogInputToDigitalPin(p) ((p < 6) ? (p) + 14 : -1) + +#if defined(__AVR_ATmega8__) +#define digitalPinHasPWM(p) ((p) == 9 || (p) == 10 || (p) == 11) +#else +#define digitalPinHasPWM(p) ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11) +#endif + +static const uint8_t SS = 10; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 12; +static const uint8_t SCK = 13; + +static const uint8_t SDA = 18; +static const uint8_t SCL = 19; +static const uint8_t LED_BUILTIN = 13; + +static const uint8_t A0 = 14; +static const uint8_t A1 = 15; +static const uint8_t A2 = 16; +static const uint8_t A3 = 17; +static const uint8_t A4 = 18; +static const uint8_t A5 = 19; +static const uint8_t A6 = 20; +static const uint8_t A7 = 21; + +#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0)) +#define digitalPinToPCICRbit(p) (((p) <= 7) ? 2 : (((p) <= 13) ? 0 : 1)) +#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0)))) +#define digitalPinToPCMSKbit(p) (((p) <= 7) ? (p) : (((p) <= 13) ? ((p) - 8) : ((p) - 14))) + +#ifdef ARDUINO_MAIN + +// On the Arduino board, digital pins are also used +// for the analog output (software PWM). Analog input +// pins are a separate set. + +// ATMEL ATMEGA8 & 168 / ARDUINO +// +// +-\/-+ +// PC6 1| |28 PC5 (AI 5) +// (D 0) PD0 2| |27 PC4 (AI 4) +// (D 1) PD1 3| |26 PC3 (AI 3) +// (D 2) PD2 4| |25 PC2 (AI 2) +// PWM+ (D 3) PD3 5| |24 PC1 (AI 1) +// (D 4) PD4 6| |23 PC0 (AI 0) +// VCC 7| |22 GND +// GND 8| |21 AREF +// PB6 9| |20 AVCC +// PB7 10| |19 PB5 (D 13) +// PWM+ (D 5) PD5 11| |18 PB4 (D 12) +// PWM+ (D 6) PD6 12| |17 PB3 (D 11) PWM +// (D 7) PD7 13| |16 PB2 (D 10) PWM +// (D 8) PB0 14| |15 PB1 (D 9) PWM +// +----+ +// +// (PWM+ indicates the additional PWM pins on the ATmega168.) + +// ATMEL ATMEGA1280 / ARDUINO +// +// 0-7 PE0-PE7 works +// 8-13 PB0-PB5 works +// 14-21 PA0-PA7 works +// 22-29 PH0-PH7 works +// 30-35 PG5-PG0 works +// 36-43 PC7-PC0 works +// 44-51 PJ7-PJ0 works +// 52-59 PL7-PL0 works +// 60-67 PD7-PD0 works +// A0-A7 PF0-PF7 +// A8-A15 PK0-PK7 + + +// these arrays map port names (e.g. port B) to the +// appropriate addresses for various functions (e.g. reading +// and writing) +const uint16_t PROGMEM port_to_mode_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &DDRB, + (uint16_t) &DDRC, + (uint16_t) &DDRD, +}; + +const uint16_t PROGMEM port_to_output_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PORTB, + (uint16_t) &PORTC, + (uint16_t) &PORTD, +}; + +const uint16_t PROGMEM port_to_input_PGM[] = { + NOT_A_PORT, + NOT_A_PORT, + (uint16_t) &PINB, + (uint16_t) &PINC, + (uint16_t) &PIND, +}; + +const uint8_t PROGMEM digital_pin_to_port_PGM[] = { + PD, /* 0 */ + PD, + PD, + PD, + PD, + PD, + PD, + PD, + PB, /* 8 */ + PB, + PB, + PB, + PB, + PB, + PC, /* 14 */ + PC, + PC, + PC, + PC, + PC, +}; + +const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { + _BV(0), /* 0, port D */ + _BV(1), + _BV(2), + _BV(3), + _BV(4), + _BV(5), + _BV(6), + _BV(7), + _BV(0), /* 8, port B */ + _BV(1), + _BV(2), + _BV(3), + _BV(4), + _BV(5), + _BV(0), /* 14, port C */ + _BV(1), + _BV(2), + _BV(3), + _BV(4), + _BV(5), +}; + +const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { + NOT_ON_TIMER, /* 0 - port D */ + NOT_ON_TIMER, + NOT_ON_TIMER, + // on the ATmega168, digital pin 3 has hardware pwm +#if defined(__AVR_ATmega8__) + NOT_ON_TIMER, +#else + TIMER2B, +#endif + NOT_ON_TIMER, + // on the ATmega168, digital pins 5 and 6 have hardware pwm +#if defined(__AVR_ATmega8__) + NOT_ON_TIMER, + NOT_ON_TIMER, +#else + TIMER0B, + TIMER0A, +#endif + NOT_ON_TIMER, + NOT_ON_TIMER, /* 8 - port B */ + TIMER1A, + TIMER1B, +#if defined(__AVR_ATmega8__) + TIMER2, +#else + TIMER2A, +#endif + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, /* 14 - port C */ + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, + NOT_ON_TIMER, +}; + +#endif + +#endif diff --git a/protocol/usb_hid/leonardo_led.h b/protocol/usb_hid/leonardo_led.h new file mode 100644 index 000000000..6f67a88f5 --- /dev/null +++ b/protocol/usb_hid/leonardo_led.h @@ -0,0 +1,10 @@ +#ifndef LEONARDO_LED_H +#define LEONARDO_LED_H + +// Leonardo "TX" LED for debug +#define LED_TX_INIT (DDRD |= (1<<5)) +#define LED_TX_ON (PORTD &= ~(1<<5)) +#define LED_TX_OFF (PORTD |= (1<<5)) +#define LED_TX_TOGGLE (PORTD ^= (1<<5)) + +#endif diff --git a/protocol/usb_hid/override_Serial.cpp b/protocol/usb_hid/override_Serial.cpp new file mode 100644 index 000000000..e1755a5dc --- /dev/null +++ b/protocol/usb_hid/override_Serial.cpp @@ -0,0 +1,51 @@ +/* + * Null implementation of Serial to dump debug print into blackhole + */ +#include "Arduino.h" +#include "sendchar.h" + +#include "USBAPI.h" + + +void Serial_::begin(uint16_t baud_count) +{ +} + +void Serial_::end(void) +{ +} + +void Serial_::accept(void) +{ +} + +int Serial_::available(void) +{ + return 0; +} + +int Serial_::peek(void) +{ + return -1; +} + +int Serial_::read(void) +{ + return -1; +} + +void Serial_::flush(void) +{ +} + +size_t Serial_::write(uint8_t c) +{ + sendchar(c); + return 1; +} + +Serial_::operator bool() { + return true; +} + +Serial_ Serial; diff --git a/protocol/usb_hid/override_wiring.c b/protocol/usb_hid/override_wiring.c new file mode 100644 index 000000000..1e9a94ce2 --- /dev/null +++ b/protocol/usb_hid/override_wiring.c @@ -0,0 +1,29 @@ +/* + * To keep Timer0 for common/timer.c override arduino/wiring.c. + */ +#define __DELAY_BACKWARD_COMPATIBLE__ +#include +#include "common/timer.h" +#include "Arduino.h" + + +unsigned long millis() +{ + return timer_read32(); +} +unsigned long micros() +{ + return timer_read32() * 1000UL; +} +void delay(unsigned long ms) +{ + _delay_ms(ms); +} +void delayMicroseconds(unsigned int us) +{ + _delay_us(us); +} +void init() +{ + timer_init(); +} diff --git a/protocol/usb_hid/parser.cpp b/protocol/usb_hid/parser.cpp new file mode 100644 index 000000000..28151f9d5 --- /dev/null +++ b/protocol/usb_hid/parser.cpp @@ -0,0 +1,24 @@ +#include "parser.h" +#include "usb_hid.h" + +#include "debug.h" + + +report_keyboard_t usb_hid_keyboard_report; +uint16_t usb_hid_time_stamp; + + +void KBDReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) +{ + ::memcpy(&usb_hid_keyboard_report, buf, sizeof(report_keyboard_t)); + usb_hid_time_stamp = millis(); + + debug("KBDReport: "); + debug_hex(usb_hid_keyboard_report.mods); + debug(" --"); + for (uint8_t i = 0; i < 6; i++) { + debug(" "); + debug_hex(usb_hid_keyboard_report.keys[i]); + } + debug("\r\n"); +} diff --git a/protocol/usb_hid/parser.h b/protocol/usb_hid/parser.h new file mode 100644 index 000000000..703eb1ed4 --- /dev/null +++ b/protocol/usb_hid/parser.h @@ -0,0 +1,12 @@ +#ifndef PARSER_H +#define PARSER_H + +#include "hid.h" + +class KBDReportParser : public HIDReportParser +{ +public: + virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); +}; + +#endif diff --git a/protocol/usb_hid/test/Makefile b/protocol/usb_hid/test/Makefile new file mode 100644 index 000000000..83bf2aed6 --- /dev/null +++ b/protocol/usb_hid/test/Makefile @@ -0,0 +1,126 @@ +#---------------------------------------------------------------------------- +# 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. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# 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 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". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = usb_hid_test + +TMK_DIR = ../../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# MCU name +MCU = atmega32u4 + + +# 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_USB below, as it is sourced by +# F_USB 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 = 16000000 + + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) +# Interrupt driven control endpoint task +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + + +# Build Options +# comment out to disable the options. +# +# Console for debug +OPT_DEFS += -DCONSOLE_ENABLE + +# Boot Section Size in bytes +# Teensy halfKay 512 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +#OPT_DEFS += -DBOOT_SIZE=4096 + + + +SRC = test.cpp +SRC += common/debug.c +SRC += common/print.c + +CONFIG_H = config.h + + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) +VPATH += $(TMK_DIR)/common + + + +# program Leonardo +PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -P$(DEV) -b57600 -Uflash:w:$(TARGET).hex + + + +include $(TMK_DIR)/protocol/usb_hid.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/rules.mk diff --git a/protocol/usb_hid/test/config.h b/protocol/usb_hid/test/config.h new file mode 100644 index 000000000..c2230fb57 --- /dev/null +++ b/protocol/usb_hid/test/config.h @@ -0,0 +1,40 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xCAFE +#define DEVICE_VER 0x0814 +#define MANUFACTURER t.m.k. +#define PRODUCT USB to USB keyboard converter + + +#define DESCRIPTION Product from t.m.k. keyboard firmware project + + +/* matrix size */ +#define MATRIX_ROWS 32 +#define MATRIX_COLS 8 + + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT))) + +#endif diff --git a/protocol/usb_hid/test/test.cpp b/protocol/usb_hid/test/test.cpp new file mode 100644 index 000000000..4958f0c61 --- /dev/null +++ b/protocol/usb_hid/test/test.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include +#include + +// USB HID host +#include "Usb.h" +#include "hid.h" +#include "hidboot.h" +#include "parser.h" + +// LUFA +#include "lufa.h" + +#include "debug.h" + +#include "leonardo_led.h" + + +static USB usb_host; +static HIDBoot kbd(&usb_host); +static KBDReportParser kbd_parser; + +static void LUFA_setup(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Disable clock division */ + clock_prescale_set(clock_div_1); + + // Leonardo needs. Without this USB device is not recognized. + USB_Disable(); + + USB_Init(); + + // for Console_Task + USB_Device_EnableSOFEvents(); +} + +static void HID_setup() +{ + // Arduino Timer startup: wiring.c + init(); + + if (usb_host.Init() == -1) { + debug("HID init: failed\n"); + LED_TX_OFF; + } + + _delay_ms(200); + + kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser); +} + +int main(void) +{ + // LED for debug + LED_TX_INIT; + LED_TX_ON; + + print_enable = true; + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; + debug_mouse = true; + + LUFA_setup(); + sei(); + + // wait for startup of sendchar routine + while (USB_DeviceState != DEVICE_STATE_Configured) ; + if (debug_enable) { + _delay_ms(1000); + } + + HID_setup(); + + debug("init: done\n"); + for (;;) { + usb_host.Task(); + +#if !defined(INTERRUPT_CONTROL_ENDPOINT) + // LUFA Task for control request + USB_USBTask(); +#endif + } + + return 0; +} diff --git a/protocol/usb_hid/usb_hid.h b/protocol/usb_hid/usb_hid.h new file mode 100644 index 000000000..083b68d1f --- /dev/null +++ b/protocol/usb_hid/usb_hid.h @@ -0,0 +1,10 @@ +#ifndef USB_HID_H +#define USB_HID_H + +#include "report.h" + + +extern report_keyboard_t usb_hid_keyboard_report; +extern uint16_t usb_hid_time_stamp; + +#endif diff --git a/protocol/vusb.mk b/protocol/vusb.mk new file mode 100644 index 000000000..3cba3f71a --- /dev/null +++ b/protocol/vusb.mk @@ -0,0 +1,21 @@ +VUSB_DIR = protocol/vusb + +OPT_DEFS += -DPROTOCOL_VUSB + +SRC += $(VUSB_DIR)/main.c \ + $(VUSB_DIR)/vusb.c \ + $(VUSB_DIR)/usbdrv/usbdrv.c \ + $(VUSB_DIR)/usbdrv/usbdrvasm.S \ + $(VUSB_DIR)/usbdrv/oddebug.c + + +ifdef NO_UART +SRC += $(COMMON_DIR)/sendchar_null.c +else +SRC += $(COMMON_DIR)/sendchar_uart.c \ + $(COMMON_DIR)/uart.c +endif + + +# Search Path +VPATH += $(TMK_DIR)/protocol/vusb:$(TMK_DIR)/protocol/vusb/usbdrv diff --git a/protocol/vusb/main.c b/protocol/vusb/main.c new file mode 100644 index 000000000..8e4a266e9 --- /dev/null +++ b/protocol/vusb/main.c @@ -0,0 +1,100 @@ +/* Name: main.c + * Project: hid-mouse, a very simple HID example + * Author: Christian Starkjohann + * Creation Date: 2008-04-07 + * Tabsize: 4 + * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ + */ +#include +#include +#include +#include +#include +#include "usbdrv.h" +#include "oddebug.h" +#include "vusb.h" +#include "keyboard.h" +#include "host.h" +#include "timer.h" +#include "uart.h" +#include "debug.h" + + +#define UART_BAUD_RATE 115200 + + +/* This is from main.c of USBaspLoader */ +static void initForUsbConnectivity(void) +{ + uint8_t i = 0; + + usbInit(); + /* enforce USB re-enumerate: */ + usbDeviceDisconnect(); /* do this while interrupts are disabled */ + while(--i){ /* fake USB disconnect for > 250 ms */ + wdt_reset(); + _delay_ms(1); + } + usbDeviceConnect(); + sei(); +} + +int main(void) +{ + bool suspended = false; +#if USB_COUNT_SOF + uint16_t last_timer = timer_read(); +#endif + + CLKPR = 0x80, CLKPR = 0; +#ifndef PS2_USE_USART + uart_init(UART_BAUD_RATE); +#endif + + keyboard_init(); + host_set_driver(vusb_driver()); + + debug("initForUsbConnectivity()\n"); + initForUsbConnectivity(); + + debug("main loop\n"); + while (1) { +#if USB_COUNT_SOF + if (usbSofCount != 0) { + suspended = false; + usbSofCount = 0; + last_timer = timer_read(); + } else { + // Suspend when no SOF in 3ms-10ms(7.1.7.4 Suspending of USB1.1) + if (timer_elapsed(last_timer) > 5) { + suspended = true; +/* + uart_putchar('S'); + _delay_ms(1); + cli(); + set_sleep_mode(SLEEP_MODE_PWR_DOWN); + sleep_enable(); + sleep_bod_disable(); + sei(); + sleep_cpu(); + sleep_disable(); + _delay_ms(10); + uart_putchar('W'); +*/ + } + } +#endif + if (!suspended) { + usbPoll(); + + // TODO: configuration process is incosistent. it sometime fails. + // To prevent failing to configure NOT scan keyboard during configuration + if (usbConfiguration && usbInterruptIsReady()) { + keyboard_task(); + } + vusb_transfer_keyboard(); + } + } +} diff --git a/protocol/vusb/sendchar_usart.c b/protocol/vusb/sendchar_usart.c new file mode 100644 index 000000000..8d24f87d1 --- /dev/null +++ b/protocol/vusb/sendchar_usart.c @@ -0,0 +1,23 @@ +/* + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + */ +#include +#include "oddebug.h" +#include "sendchar.h" + + +#if DEBUG_LEVEL > 0 +/* from oddebug.c */ +int8_t sendchar(uint8_t c) +{ + while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ + ODDBG_UDR = c; + return 1; +} +#else +int8_t sendchar(uint8_t c) +{ + return 1; +} +#endif diff --git a/protocol/vusb/usbdrv/Changelog.txt b/protocol/vusb/usbdrv/Changelog.txt new file mode 100644 index 000000000..5c6354ab1 --- /dev/null +++ b/protocol/vusb/usbdrv/Changelog.txt @@ -0,0 +1,308 @@ +This file documents changes in the firmware-only USB driver for atmel's AVR +microcontrollers. New entries are always appended to the end of the file. +Scroll down to the bottom to see the most recent changes. + +2005-04-01: + - Implemented endpoint 1 as interrupt-in endpoint. + - Moved all configuration options to usbconfig.h which is not part of the + driver. + - Changed interface for usbVendorSetup(). + - Fixed compatibility with ATMega8 device. + - Various minor optimizations. + +2005-04-11: + - Changed interface to application: Use usbFunctionSetup(), usbFunctionRead() + and usbFunctionWrite() now. Added configuration options to choose which + of these functions to compile in. + - Assembler module delivers receive data non-inverted now. + - Made register and bit names compatible with more AVR devices. + +2005-05-03: + - Allow address of usbRxBuf on any memory page as long as the buffer does + not cross 256 byte page boundaries. + - Better device compatibility: works with Mega88 now. + - Code optimization in debugging module. + - Documentation updates. + +2006-01-02: + - Added (free) default Vendor- and Product-IDs bought from voti.nl. + - Added USBID-License.txt file which defines the rules for using the free + shared VID/PID pair. + - Added Readme.txt to the usbdrv directory which clarifies administrative + issues. + +2006-01-25: + - Added "configured state" to become more standards compliant. + - Added "HALT" state for interrupt endpoint. + - Driver passes the "USB Command Verifier" test from usb.org now. + - Made "serial number" a configuration option. + - Minor optimizations, we now recommend compiler option "-Os" for best + results. + - Added a version number to usbdrv.h + +2006-02-03: + - New configuration variable USB_BUFFER_SECTION for the memory section where + the USB rx buffer will go. This defaults to ".bss" if not defined. Since + this buffer MUST NOT cross 256 byte pages (not even touch a page at the + end), the user may want to pass a linker option similar to + "-Wl,--section-start=.mybuffer=0x800060". + - Provide structure for usbRequest_t. + - New defines for USB constants. + - Prepared for HID implementations. + - Increased data size limit for interrupt transfers to 8 bytes. + - New macro usbInterruptIsReady() to query interrupt buffer state. + +2006-02-18: + - Ensure that the data token which is sent as an ack to an OUT transfer is + always zero sized. This fixes a bug where the host reports an error after + sending an out transfer to the device, although all data arrived at the + device. + - Updated docs in usbdrv.h to reflect changed API in usbFunctionWrite(). + +* Release 2006-02-20 + + - Give a compiler warning when compiling with debugging turned on. + - Added Oleg Semyonov's changes for IAR-cc compatibility. + - Added new (optional) functions usbDeviceConnect() and usbDeviceDisconnect() + (also thanks to Oleg!). + - Rearranged tests in usbPoll() to save a couple of instructions in the most + likely case that no actions are pending. + - We need a delay between the SET ADDRESS request until the new address + becomes active. This delay was handled in usbPoll() until now. Since the + spec says that the delay must not exceed 2ms, previous versions required + aggressive polling during the enumeration phase. We have now moved the + handling of the delay into the interrupt routine. + - We must not reply with NAK to a SETUP transaction. We can only achieve this + by making sure that the rx buffer is empty when SETUP tokens are expected. + We therefore don't pass zero sized data packets from the status phase of + a transfer to usbPoll(). This change MAY cause troubles if you rely on + receiving a less than 8 bytes long packet in usbFunctionWrite() to + identify the end of a transfer. usbFunctionWrite() will NEVER be called + with a zero length. + +* Release 2006-03-14 + + - Improved IAR C support: tiny memory model, more devices + - Added template usbconfig.h file under the name usbconfig-prototype.h + +* Release 2006-03-26 + + - Added provision for one more interrupt-in endpoint (endpoint 3). + - Added provision for one interrupt-out endpoint (endpoint 1). + - Added flowcontrol macros for USB. + - Added provision for custom configuration descriptor. + - Allow ANY two port bits for D+ and D-. + - Merged (optional) receive endpoint number into global usbRxToken variable. + - Use USB_CFG_IOPORTNAME instead of USB_CFG_IOPORT. We now construct the + variable name from the single port letter instead of computing the address + of related ports from the output-port address. + +* Release 2006-06-26 + + - Updated documentation in usbdrv.h and usbconfig-prototype.h to reflect the + new features. + - Removed "#warning" directives because IAR does not understand them. Use + unused static variables instead to generate a warning. + - Do not include when compiling with IAR. + - Introduced USB_CFG_DESCR_PROPS_* in usbconfig.h to configure how each + USB descriptor should be handled. It is now possible to provide descriptor + data in Flash, RAM or dynamically at runtime. + - STALL is now a status in usbTxLen* instead of a message. We can now conform + to the spec and leave the stall status pending until it is cleared. + - Made usbTxPacketCnt1 and usbTxPacketCnt3 public. This allows the + application code to reset data toggling on interrupt pipes. + +* Release 2006-07-18 + + - Added an #if !defined __ASSEMBLER__ to the warning in usbdrv.h. This fixes + an assembler error. + - usbDeviceDisconnect() takes pull-up resistor to high impedance now. + +* Release 2007-02-01 + + - Merged in some code size improvements from usbtiny (thanks to Dick + Streefland for these optimizations!) + - Special alignment requirement for usbRxBuf not required any more. Thanks + again to Dick Streefland for this hint! + - Reverted to "#warning" instead of unused static variables -- new versions + of IAR CC should handle this directive. + - Changed Open Source license to GNU GPL v2 in order to make linking against + other free libraries easier. We no longer require publication of the + circuit diagrams, but we STRONGLY encourage it. If you improve the driver + itself, PLEASE grant us a royalty free license to your changes for our + commercial license. + +* Release 2007-03-29 + + - New configuration option "USB_PUBLIC" in usbconfig.h. + - Set USB version number to 1.10 instead of 1.01. + - Code used USB_CFG_DESCR_PROPS_STRING_DEVICE and + USB_CFG_DESCR_PROPS_STRING_PRODUCT inconsistently. Changed all occurrences + to USB_CFG_DESCR_PROPS_STRING_PRODUCT. + - New assembler module for 16.5 MHz RC oscillator clock with PLL in receiver + code. + - New assembler module for 16 MHz crystal. + - usbdrvasm.S contains common code only, clock-specific parts have been moved + to usbdrvasm12.S, usbdrvasm16.S and usbdrvasm165.S respectively. + +* Release 2007-06-25 + + - 16 MHz module: Do SE0 check in stuffed bits as well. + +* Release 2007-07-07 + + - Define hi8(x) for IAR compiler to limit result to 8 bits. This is necessary + for negative values. + - Added 15 MHz module contributed by V. Bosch. + - Interrupt vector name can now be configured. This is useful if somebody + wants to use a different hardware interrupt than INT0. + +* Release 2007-08-07 + + - Moved handleIn3 routine in usbdrvasm16.S so that relative jump range is + not exceeded. + - More config options: USB_RX_USER_HOOK(), USB_INITIAL_DATATOKEN, + USB_COUNT_SOF + - USB_INTR_PENDING can now be a memory address, not just I/O + +* Release 2007-09-19 + + - Split out common parts of assembler modules into separate include file + - Made endpoint numbers configurable so that given interface definitions + can be matched. See USB_CFG_EP3_NUMBER in usbconfig-prototype.h. + - Store endpoint number for interrupt/bulk-out so that usbFunctionWriteOut() + can handle any number of endpoints. + - Define usbDeviceConnect() and usbDeviceDisconnect() even if no + USB_CFG_PULLUP_IOPORTNAME is defined. Directly set D+ and D- to 0 in this + case. + +* Release 2007-12-01 + + - Optimize usbDeviceConnect() and usbDeviceDisconnect() for less code size + when USB_CFG_PULLUP_IOPORTNAME is not defined. + +* Release 2007-12-13 + + - Renamed all include-only assembler modules from *.S to *.inc so that + people don't add them to their project sources. + - Distribute leap bits in tx loop more evenly for 16 MHz module. + - Use "macro" and "endm" instead of ".macro" and ".endm" for IAR + - Avoid compiler warnings for constant expr range by casting some values in + USB descriptors. + +* Release 2008-01-21 + + - Fixed bug in 15 and 16 MHz module where the new address set with + SET_ADDRESS was already accepted at the next NAK or ACK we send, not at + the next data packet we send. This caused problems when the host polled + too fast. Thanks to Alexander Neumann for his help and patience debugging + this issue! + +* Release 2008-02-05 + + - Fixed bug in 16.5 MHz module where a register was used in the interrupt + handler before it was pushed. This bug was introduced with version + 2007-09-19 when common parts were moved to a separate file. + - Optimized CRC routine (thanks to Reimar Doeffinger). + +* Release 2008-02-16 + + - Removed outdated IAR compatibility stuff (code sections). + - Added hook macros for USB_RESET_HOOK() and USB_SET_ADDRESS_HOOK(). + - Added optional routine usbMeasureFrameLength() for calibration of the + internal RC oscillator. + +* Release 2008-02-28 + + - USB_INITIAL_DATATOKEN defaults to USBPID_DATA1 now, which means that we + start with sending USBPID_DATA0. + - Changed defaults in usbconfig-prototype.h + - Added free USB VID/PID pair for MIDI class devices + - Restructured AVR-USB as separate package, not part of PowerSwitch any more. + +* Release 2008-04-18 + + - Restructured usbdrv.c so that it is easier to read and understand. + - Better code optimization with gcc 4. + - If a second interrupt in endpoint is enabled, also add it to config + descriptor. + - Added config option for long transfers (above 254 bytes), see + USB_CFG_LONG_TRANSFERS in usbconfig.h. + - Added 20 MHz module contributed by Jeroen Benschop. + +* Release 2008-05-13 + + - Fixed bug in libs-host/hiddata.c function usbhidGetReport(): length + was not incremented, pointer to length was incremented instead. + - Added code to command line tool(s) which claims an interface. This code + is disabled by default, but may be necessary on newer Linux kernels. + - Added usbconfig.h option "USB_CFG_CHECK_DATA_TOGGLING". + - New header "usbportability.h" prepares ports to other development + environments. + - Long transfers (above 254 bytes) did not work when usbFunctionRead() was + used to supply the data. Fixed this bug. [Thanks to Alexander Neumann!] + - In hiddata.c (example code for sending/receiving data over HID), use + USB_RECIP_DEVICE instead of USB_RECIP_INTERFACE for control transfers so + that we need not claim the interface. + - in usbPoll() loop 20 times polling for RESET state instead of 10 times. + This accounts for the higher clock rates we now support. + - Added a module for 12.8 MHz RC oscillator with PLL in receiver loop. + - Added hook to SOF code so that oscillator can be tuned to USB frame clock. + - Added timeout to waitForJ loop. Helps preventing unexpected hangs. + - Added example code for oscillator tuning to libs-device (thanks to + Henrik Haftmann for the idea to this routine). + - Implemented option USB_CFG_SUPPRESS_INTR_CODE. + +* Release 2008-10-22 + + - Fixed libs-device/osctune.h: OSCCAL is memory address on ATMega88 and + similar, not offset of 0x20 needs to be added. + - Allow distribution under GPLv3 for those who have to link against other + code distributed under GPLv3. + +* Release 2008-11-26 + + - Removed libusb-win32 dependency for hid-data example in Makefile.windows. + It was never required and confused many people. + - Added extern uchar usbRxToken to usbdrv.h. + - Integrated a module with CRC checks at 18 MHz by Lukas Schrittwieser. + +* Release 2009-03-23 + + - Hid-mouse example used settings from hid-data example, fixed that. + - Renamed project to V-USB due to a trademark issue with Atmel(r). + - Changed CommercialLicense.txt and USBID-License.txt to make the + background of USB ID registration clearer. + +* Release 2009-04-15 + + - Changed CommercialLicense.txt to reflect the new range of PIDs from + Jason Kotzin. + - Removed USBID-License.txt in favor of USB-IDs-for-free.txt and + USB-ID-FAQ.txt + - Fixed a bug in the 12.8 MHz module: End Of Packet decection was made in + the center between bit 0 and 1 of each byte. This is where the data lines + are expected to change and the sampled data may therefore be nonsense. + We therefore check EOP ONLY if bits 0 AND 1 have both been read as 0 on D-. + - Fixed a bitstuffing problem in the 16 MHz module: If bit 6 was stuffed, + the unstuffing code in the receiver routine was 1 cycle too long. If + multiple bytes had the unstuffing in bit 6, the error summed up until the + receiver was out of sync. + - Included option for faster CRC routine. + Thanks to Slawomir Fras (BoskiDialer) for this code! + - Updated bits in Configuration Descriptor's bmAttributes according to + USB 1.1 (in particular bit 7, it is a must-be-set bit now). + +* Release 2009-08-22 + + - Moved first DBG1() after odDebugInit() in all examples. + - Use vector INT0_vect instead of SIG_INTERRUPT0 if defined. This makes + V-USB compatible with the new "p" suffix devices (e.g. ATMega328p). + - USB_CFG_CLOCK_KHZ setting is now required in usbconfig.h (no default any + more). + - New option USB_CFG_DRIVER_FLASH_PAGE allows boot loaders on devices with + more than 64 kB flash. + - Built-in configuration descriptor allows custom definition for second + endpoint now. + +* Release 2010-07-15 diff --git a/protocol/vusb/usbdrv/CommercialLicense.txt b/protocol/vusb/usbdrv/CommercialLicense.txt new file mode 100644 index 000000000..11d07d9df --- /dev/null +++ b/protocol/vusb/usbdrv/CommercialLicense.txt @@ -0,0 +1,166 @@ +V-USB Driver Software License Agreement +Version 2009-08-03 + +THIS LICENSE AGREEMENT GRANTS YOU CERTAIN RIGHTS IN A SOFTWARE. YOU CAN +ENTER INTO THIS AGREEMENT AND ACQUIRE THE RIGHTS OUTLINED BELOW BY PAYING +THE AMOUNT ACCORDING TO SECTION 4 ("PAYMENT") TO OBJECTIVE DEVELOPMENT. + + +1 DEFINITIONS + +1.1 "OBJECTIVE DEVELOPMENT" shall mean OBJECTIVE DEVELOPMENT Software GmbH, +Grosse Schiffgasse 1A/7, 1020 Wien, AUSTRIA. + +1.2 "You" shall mean the Licensee. + +1.3 "V-USB" shall mean all files included in the package distributed under +the name "vusb" by OBJECTIVE DEVELOPMENT (http://www.obdev.at/vusb/) +unless otherwise noted. This includes the firmware-only USB device +implementation for Atmel AVR microcontrollers, some simple device examples +and host side software examples and libraries. + + +2 LICENSE GRANTS + +2.1 Source Code. OBJECTIVE DEVELOPMENT shall furnish you with the source +code of V-USB. + +2.2 Distribution and Use. OBJECTIVE DEVELOPMENT grants you the +non-exclusive right to use, copy and distribute V-USB with your hardware +product(s), restricted by the limitations in section 3 below. + +2.3 Modifications. OBJECTIVE DEVELOPMENT grants you the right to modify +the source code and your copy of V-USB according to your needs. + +2.4 USB IDs. OBJECTIVE DEVELOPMENT furnishes you with one or two USB +Product ID(s), sent to you in e-mail. These Product IDs are reserved +exclusively for you. OBJECTIVE DEVELOPMENT has obtained USB Product ID +ranges under the Vendor ID 5824 from Wouter van Ooijen (Van Ooijen +Technische Informatica, www.voti.nl) and under the Vendor ID 8352 from +Jason Kotzin (Clay Logic, www.claylogic.com). Both owners of the Vendor IDs +have obtained these IDs from the USB Implementers Forum, Inc. +(www.usb.org). OBJECTIVE DEVELOPMENT disclaims all liability which might +arise from the assignment of USB IDs. + +2.5 USB Certification. Although not part of this agreement, we want to make +it clear that you cannot become USB certified when you use V-USB or a USB +Product ID assigned by OBJECTIVE DEVELOPMENT. AVR microcontrollers don't +meet the electrical specifications required by the USB specification and +the USB Implementers Forum certifies only members who bought a Vendor ID of +their own. + + +3 LICENSE RESTRICTIONS + +3.1 Number of Units. Only one of the following three definitions is +applicable. Which one is determined by the amount you pay to OBJECTIVE +DEVELOPMENT, see section 4 ("Payment") below. + +Hobby License: You may use V-USB according to section 2 above in no more +than 5 hardware units. These units must not be sold for profit. + +Entry Level License: You may use V-USB according to section 2 above in no +more than 150 hardware units. + +Professional License: You may use V-USB according to section 2 above in +any number of hardware units, except for large scale production ("unlimited +fair use"). Quantities below 10,000 units are not considered large scale +production. If your reach quantities which are obviously large scale +production, you must pay a license fee of 0.10 EUR per unit for all units +above 10,000. + +3.2 Rental. You may not rent, lease, or lend V-USB or otherwise encumber +any copy of V-USB, or any of the rights granted herein. + +3.3 Transfer. You may not transfer your rights under this Agreement to +another party without OBJECTIVE DEVELOPMENT's prior written consent. If +such consent is obtained, you may permanently transfer this License to +another party. The recipient of such transfer must agree to all terms and +conditions of this Agreement. + +3.4 Reservation of Rights. OBJECTIVE DEVELOPMENT retains all rights not +expressly granted. + +3.5 Non-Exclusive Rights. Your license rights under this Agreement are +non-exclusive. + +3.6 Third Party Rights. This Agreement cannot grant you rights controlled +by third parties. In particular, you are not allowed to use the USB logo or +other trademarks owned by the USB Implementers Forum, Inc. without their +consent. Since such consent depends on USB certification, it should be +noted that V-USB will not pass certification because it does not +implement checksum verification and the microcontroller ports do not meet +the electrical specifications. + + +4 PAYMENT + +The payment amount depends on the variation of this agreement (according to +section 3.1) into which you want to enter. Concrete prices are listed on +OBJECTIVE DEVELOPMENT's web site, usually at +http://www.obdev.at/vusb/license.html. You agree to pay the amount listed +there to OBJECTIVE DEVELOPMENT or OBJECTIVE DEVELOPMENT's payment processor +or reseller. + + +5 COPYRIGHT AND OWNERSHIP + +V-USB is protected by copyright laws and international copyright +treaties, as well as other intellectual property laws and treaties. V-USB +is licensed, not sold. + + +6 TERM AND TERMINATION + +6.1 Term. This Agreement shall continue indefinitely. However, OBJECTIVE +DEVELOPMENT may terminate this Agreement and revoke the granted license and +USB-IDs if you fail to comply with any of its terms and conditions. + +6.2 Survival of Terms. All provisions regarding secrecy, confidentiality +and limitation of liability shall survive termination of this agreement. + + +7 DISCLAIMER OF WARRANTY AND LIABILITY + +LIMITED WARRANTY. V-USB IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, OBJECTIVE +DEVELOPMENT AND ITS SUPPLIERS HEREBY DISCLAIM ALL WARRANTIES, EITHER +EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND +NON-INFRINGEMENT, WITH REGARD TO V-USB, AND THE PROVISION OF OR FAILURE +TO PROVIDE SUPPORT SERVICES. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL +RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE/JURISDICTION TO +STATE/JURISDICTION. + +LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, +IN NO EVENT SHALL OBJECTIVE DEVELOPMENT OR ITS SUPPLIERS BE LIABLE FOR ANY +SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER +(INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, +BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY +LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE V-USB OR THE +PROVISION OF OR FAILURE TO PROVIDE SUPPORT SERVICES, EVEN IF OBJECTIVE +DEVELOPMENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN ANY +CASE, OBJECTIVE DEVELOPMENT'S ENTIRE LIABILITY UNDER ANY PROVISION OF THIS +AGREEMENT SHALL BE LIMITED TO THE AMOUNT ACTUALLY PAID BY YOU FOR V-USB. + + +8 MISCELLANEOUS TERMS + +8.1 Marketing. OBJECTIVE DEVELOPMENT has the right to mention for marketing +purposes that you entered into this agreement. + +8.2 Entire Agreement. This document represents the entire agreement between +OBJECTIVE DEVELOPMENT and you. It may only be modified in writing signed by +an authorized representative of both, OBJECTIVE DEVELOPMENT and you. + +8.3 Severability. In case a provision of these terms and conditions should +be or become partly or entirely invalid, ineffective, or not executable, +the validity of all other provisions shall not be affected. + +8.4 Applicable Law. This agreement is governed by the laws of the Republic +of Austria. + +8.5 Responsible Courts. The responsible courts in Vienna/Austria will have +exclusive jurisdiction regarding all disputes in connection with this +agreement. + diff --git a/protocol/vusb/usbdrv/License.txt b/protocol/vusb/usbdrv/License.txt new file mode 100644 index 000000000..4460cfbae --- /dev/null +++ b/protocol/vusb/usbdrv/License.txt @@ -0,0 +1,361 @@ +OBJECTIVE DEVELOPMENT GmbH's V-USB driver software is distributed under the +terms and conditions of the GNU GPL version 2 or the GNU GPL version 3. It is +your choice whether you apply the terms of version 2 or version 3. The full +text of GPLv2 is included below. In addition to the requirements in the GPL, +we STRONGLY ENCOURAGE you to do the following: + +(1) Publish your entire project on a web site and drop us a note with the URL. +Use the form at http://www.obdev.at/vusb/feedback.html for your submission. + +(2) Adhere to minimum publication standards. Please include AT LEAST: + - a circuit diagram in PDF, PNG or GIF format + - full source code for the host software + - a Readme.txt file in ASCII format which describes the purpose of the + project and what can be found in which directories and which files + - a reference to http://www.obdev.at/vusb/ + +(3) If you improve the driver firmware itself, please give us a free license +to your modifications for our commercial license offerings. + + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/protocol/vusb/usbdrv/Readme.txt b/protocol/vusb/usbdrv/Readme.txt new file mode 100644 index 000000000..970dc66b2 --- /dev/null +++ b/protocol/vusb/usbdrv/Readme.txt @@ -0,0 +1,172 @@ +This is the Readme file to Objective Development's firmware-only USB driver +for Atmel AVR microcontrollers. For more information please visit +http://www.obdev.at/vusb/ + +This directory contains the USB firmware only. Copy it as-is to your own +project and add all .c and .S files to your project (these files are marked +with an asterisk in the list below). Then copy usbconfig-prototype.h as +usbconfig.h to your project and edit it according to your configuration. + + +TECHNICAL DOCUMENTATION +======================= +The technical documentation (API) for the firmware driver is contained in the +file "usbdrv.h". Please read all of it carefully! Configuration options are +documented in "usbconfig-prototype.h". + +The driver consists of the following files: + Readme.txt ............. The file you are currently reading. + Changelog.txt .......... Release notes for all versions of the driver. + usbdrv.h ............... Driver interface definitions and technical docs. +* usbdrv.c ............... High level language part of the driver. Link this + module to your code! +* usbdrvasm.S ............ Assembler part of the driver. This module is mostly + a stub and includes one of the usbdrvasm*.S files + depending on processor clock. Link this module to + your code! + usbdrvasm*.inc ......... Assembler routines for particular clock frequencies. + Included by usbdrvasm.S, don't link it directly! + asmcommon.inc .......... Common assembler routines. Included by + usbdrvasm*.inc, don't link it directly! + usbconfig-prototype.h .. Prototype for your own usbdrv.h file. +* oddebug.c .............. Debug functions. Only used when DEBUG_LEVEL is + defined to a value greater than 0. Link this module + to your code! + oddebug.h .............. Interface definitions of the debug module. + usbportability.h ....... Header with compiler-dependent stuff. + usbdrvasm.asm .......... Compatibility stub for IAR-C-compiler. Use this + module instead of usbdrvasm.S when you assembler + with IAR's tools. + License.txt ............ Open Source license for this driver. + CommercialLicense.txt .. Optional commercial license for this driver. + USB-ID-FAQ.txt ......... General infos about USB Product- and Vendor-IDs. + USB-IDs-for-free.txt ... List and terms of use for free shared PIDs. + +(*) ... These files should be linked to your project. + + +CPU CORE CLOCK FREQUENCY +======================== +We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz, +16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The +actual clock rate must be configured in usbconfig.h. + +12 MHz Clock +This is the traditional clock rate of V-USB because it's the lowest clock +rate where the timing constraints of the USB spec can be met. + +15 MHz Clock +Similar to 12 MHz, but some NOPs inserted. On the other hand, the higher clock +rate allows for some loops which make the resulting code size somewhat smaller +than the 12 MHz version. + +16 MHz Clock +This clock rate has been added for users of the Arduino board and other +ready-made boards which come with a fixed 16 MHz crystal. It's also an option +if you need the slightly higher clock rate for performance reasons. Since +16 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code +is somewhat tricky and has to insert a leap cycle every third byte. + +12.8 MHz and 16.5 MHz Clock +The assembler modules for these clock rates differ from the other modules +because they have been built for an RC oscillator with only 1% precision. The +receiver code inserts leap cycles to compensate for clock deviations. 1% is +also the precision which can be achieved by calibrating the internal RC +oscillator of the AVR. Please note that only AVRs with internal 64 MHz PLL +oscillator can reach 16.5 MHz with the RC oscillator. This includes the very +popular ATTiny25, ATTiny45, ATTiny85 series as well as the ATTiny26. Almost +all AVRs can reach 12.8 MHz, although this is outside the specified range. + +See the EasyLogger example at http://www.obdev.at/vusb/easylogger.html for +code which calibrates the RC oscillator based on the USB frame clock. + +18 MHz Clock +This module is closer to the USB specification because it performs an on the +fly CRC check for incoming packets. Packets with invalid checksum are +discarded as required by the spec. If you also implement checks for data +PID toggling on application level (see option USB_CFG_CHECK_DATA_TOGGLING +in usbconfig.h for more info), this ensures data integrity. Due to the CRC +tables and alignment requirements, this code is bigger than modules for other +clock rates. To activate this module, you must define USB_CFG_CHECK_CRC to 1 +and USB_CFG_CLOCK_KHZ to 18000 in usbconfig.h. + +20 MHz Clock +This module is for people who won't do it with less than the maximum. Since +20 MHz is not divisible by the USB low speed bit clock of 1.5 MHz, the code +uses similar tricks as the 16 MHz module to insert leap cycles. + + +USB IDENTIFIERS +=============== +Every USB device needs a vendor- and a product-identifier (VID and PID). VIDs +are obtained from usb.org for a price of 1,500 USD. Once you have a VID, you +can assign PIDs at will. + +Since an entry level cost of 1,500 USD is too high for most small companies +and hobbyists, we provide some VID/PID pairs for free. See the file +USB-IDs-for-free.txt for details. + +Objective Development also has some license offerings which include product +IDs. See http://www.obdev.at/vusb/ for details. + + +DEVELOPMENT SYSTEM +================== +This driver has been developed and optimized for the GNU compiler version 3 +and 4. We recommend that you use the GNU compiler suite because it is freely +available. V-USB has also been ported to the IAR compiler and assembler. It +has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the +"small" and "tiny" memory model. Not every release is tested with IAR CC and +the driver may therefore fail to compile with IAR. Please note that gcc is +more efficient for usbdrv.c because this module has been deliberately +optimized for gcc. + +Gcc version 3 produces smaller code than version 4 due to new optimizing +capabilities which don't always improve things on 8 bit CPUs. The code size +generated by gcc 4 can be reduced with the compiler options +-fno-move-loop-invariants, -fno-tree-scev-cprop and +-fno-inline-small-functions in addition to -Os. On devices with more than +8k of flash memory, we also recommend the linker option --relax (written as +-Wl,--relax for gcc) to convert absolute calls into relative where possible. + +For more information about optimizing options see: + + http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html + +These optimizations are good for gcc 4.x. Version 3.x of gcc does not support +most of these options and produces good code anyway. + + +USING V-USB FOR FREE +==================== +The AVR firmware driver is published under the GNU General Public License +Version 2 (GPL2) and the GNU General Public License Version 3 (GPL3). It is +your choice whether you apply the terms of version 2 or version 3. + +If you decide for the free GPL2 or GPL3, we STRONGLY ENCOURAGE you to do the +following things IN ADDITION to the obligations from the GPL: + +(1) Publish your entire project on a web site and drop us a note with the URL. +Use the form at http://www.obdev.at/vusb/feedback.html for your submission. +If you don't have a web site, you can publish the project in obdev's +documentation wiki at +http://www.obdev.at/goto.php?t=vusb-wiki&p=hosted-projects. + +(2) Adhere to minimum publication standards. Please include AT LEAST: + - a circuit diagram in PDF, PNG or GIF format + - full source code for the host software + - a Readme.txt file in ASCII format which describes the purpose of the + project and what can be found in which directories and which files + - a reference to http://www.obdev.at/vusb/ + +(3) If you improve the driver firmware itself, please give us a free license +to your modifications for our commercial license offerings. + + +COMMERCIAL LICENSES FOR V-USB +============================= +If you don't want to publish your source code under the terms of the GPL, +you can simply pay money for V-USB. As an additional benefit you get +USB PIDs for free, reserved exclusively to you. See the file +"CommercialLicense.txt" for details. + diff --git a/protocol/vusb/usbdrv/USB-ID-FAQ.txt b/protocol/vusb/usbdrv/USB-ID-FAQ.txt new file mode 100644 index 000000000..d1de8fb61 --- /dev/null +++ b/protocol/vusb/usbdrv/USB-ID-FAQ.txt @@ -0,0 +1,149 @@ +Version 2009-08-22 + +========================== +WHY DO WE NEED THESE IDs? +========================== + +USB is more than a low level protocol for data transport. It also defines a +common set of requests which must be understood by all devices. And as part +of these common requests, the specification defines data structures, the +USB Descriptors, which are used to describe the properties of the device. + +From the perspective of an operating system, it is therefore possible to find +out basic properties of a device (such as e.g. the manufacturer and the name +of the device) without a device-specific driver. This is essential because +the operating system can choose a driver to load based on this information +(Plug-And-Play). + +Among the most important properties in the Device Descriptor are the USB +Vendor- and Product-ID. Both are 16 bit integers. The most simple form of +driver matching is based on these IDs. The driver announces the Vendor- and +Product-IDs of the devices it can handle and the operating system loads the +appropriate driver when the device is connected. + +It is obvious that this technique only works if the pair Vendor- plus +Product-ID is unique: Only devices which require the same driver can have the +same pair of IDs. + + +===================================================== +HOW DOES THE USB STANDARD ENSURE THAT IDs ARE UNIQUE? +===================================================== + +Since it is so important that USB IDs are unique, the USB Implementers Forum, +Inc. (usb.org) needs a way to enforce this legally. It is not forbidden by +law to build a device and assign it any random numbers as IDs. Usb.org +therefore needs an agreement to regulate the use of USB IDs. The agreement +binds only parties who agreed to it, of course. Everybody else is free to use +any numbers for their IDs. + +So how can usb.org ensure that every manufacturer of USB devices enters into +an agreement with them? They do it via trademark licensing. Usb.org has +registered the trademark "USB", all associated logos and related terms. If +you want to put an USB logo on your product or claim that it is USB +compliant, you must license these trademarks from usb.org. And this is where +you enter into an agreement. See the "USB-IF Trademark License Agreement and +Usage Guidelines for the USB-IF Logo" at +http://www.usb.org/developers/logo_license/. + +Licensing the USB trademarks requires that you buy a USB Vendor-ID from +usb.org (one-time fee of ca. 2,000 USD), that you become a member of usb.org +(yearly fee of ca. 4,000 USD) and that you meet all the technical +specifications from the USB spec. + +This means that most hobbyists and small companies will never be able to +become USB compliant, just because membership is so expensive. And you can't +be compliant with a driver based on V-USB anyway, because the AVR's port pins +don't meet the electrical specifications for USB. So, in principle, all +hobbyists and small companies are free to choose any random numbers for their +IDs. They have nothing to lose... + +There is one exception worth noting, though: If you use a sub-component which +implements USB, the vendor of the sub-components may guarantee USB +compliance. This might apply to some or all of FTDI's solutions. + + +======================================================================= +WHY SHOULD YOU OBTAIN USB IDs EVEN IF YOU DON'T LICENSE USB TRADEMARKS? +======================================================================= + +You have learned in the previous section that you are free to choose any +numbers for your IDs anyway. So why not do exactly this? There is still the +technical issue. If you choose IDs which are already in use by somebody else, +operating systems will load the wrong drivers and your device won't work. +Even if you choose IDs which are not currently in use, they may be in use in +the next version of the operating system or even after an automatic update. + +So what you need is a pair of Vendor- and Product-IDs for which you have the +guarantee that no USB compliant product uses them. This implies that no +operating system will ever ship with drivers responsible for these IDs. + + +============================================== +HOW DOES OBJECTIVE DEVELOPMENT HANDLE USB IDs? +============================================== + +Objective Development gives away pairs of USB-IDs with their V-USB licenses. +In order to ensure that these IDs are unique, Objective Development has an +agreement with the company/person who has bought the USB Vendor-ID from +usb.org. This agreement ensures that a range of USB Product-IDs is reserved +for assignment by Objective Development and that the owner of the Vendor-ID +won't give it to anybody else. + +This means that you have to trust three parties to ensure uniqueness of +your IDs: + + - Objective Development, that they don't give the same PID to more than + one person. + - The owner of the Vendor-ID that they don't assign PIDs from the range + assigned to Objective Development to anybody else. + - Usb.org that they don't assign the same Vendor-ID a second time. + + +================================== +WHO IS THE OWNER OF THE VENDOR-ID? +================================== + +Objective Development has obtained ranges of USB Product-IDs under two +Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen +Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason +Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their +Vendor-ID directly from usb.org. + + +========================================================================= +CAN I USE USB-IDs FROM OBJECTIVE DEVELOPMENT WITH OTHER DRIVERS/HARDWARE? +========================================================================= + +The short answer is: Yes. All you get is a guarantee that the IDs are never +assigned to anybody else. What more do you need? + + +============================ +WHAT ABOUT SHARED ID PAIRS? +============================ + +Objective Development has reserved some PID/VID pairs for shared use. You +have no guarantee of uniqueness for them, except that no USB compliant device +uses them. In order to avoid technical problems, we must ensure that all +devices with the same pair of IDs use the same driver on kernel level. For +details, see the file USB-IDs-for-free.txt. + + +====================================================== +I HAVE HEARD THAT SUB-LICENSING OF USB-IDs IS ILLEGAL? +====================================================== + +A 16 bit integer number cannot be protected by copyright laws. It is not +sufficiently complex. And since none of the parties involved entered into the +USB-IF Trademark License Agreement, we are not bound by this agreement. So +there is no reason why it should be illegal to sub-license USB-IDs. + + +============================================= +WHO IS LIABLE IF THERE ARE INCOMPATIBILITIES? +============================================= + +Objective Development disclaims all liabilities which might arise from the +assignment of IDs. If you guarantee product features to your customers +without proper disclaimer, YOU are liable for that. diff --git a/protocol/vusb/usbdrv/USB-IDs-for-free.txt b/protocol/vusb/usbdrv/USB-IDs-for-free.txt new file mode 100644 index 000000000..2f4d59ad1 --- /dev/null +++ b/protocol/vusb/usbdrv/USB-IDs-for-free.txt @@ -0,0 +1,148 @@ +Version 2009-08-22 + +=========================== +FREE USB-IDs FOR SHARED USE +=========================== + +Objective Development has reserved a set of USB Product-IDs for use according +to the guidelines outlined below. For more information about the concept of +USB IDs please see the file USB-ID-FAQ.txt. Objective Development guarantees +that the IDs listed below are not used by any USB compliant devices. + + +==================== +MECHANISM OF SHARING +==================== + +From a technical point of view, two different devices can share the same USB +Vendor- and Product-ID if they require the same driver on operating system +level. We make use of this fact by assigning separate IDs for various device +classes. On application layer, devices must be distinguished by their textual +name or serial number. We offer separate sets of IDs for discrimination by +textual name and for serial number. + +Examples for shared use of USB IDs are included with V-USB in the "examples" +subdirectory. + + +====================================== +IDs FOR DISCRIMINATION BY TEXTUAL NAME +====================================== + +If you use one of the IDs listed below, your device and host-side software +must conform to these rules: + +(1) The USB device MUST provide a textual representation of the manufacturer +and product identification. The manufacturer identification MUST be available +at least in USB language 0x0409 (English/US). + +(2) The textual manufacturer identification MUST contain either an Internet +domain name (e.g. "mycompany.com") registered and owned by you, or an e-mail +address under your control (e.g. "myname@gmx.net"). You can embed the domain +name or e-mail address in any string you like, e.g. "Objective Development +http://www.obdev.at/vusb/". + +(3) You are responsible for retaining ownership of the domain or e-mail +address for as long as any of your products are in use. + +(4) You may choose any string for the textual product identification, as long +as this string is unique within the scope of your textual manufacturer +identification. + +(5) Application side device look-up MUST be based on the textual manufacturer +and product identification in addition to VID/PID matching. The driver +matching MUST be a comparison of the entire strings, NOT a sub-string match. + +(6) For devices which implement a particular USB device class (e.g. HID), the +operating system's default class driver MUST be used. If an operating system +driver for Vendor Class devices is needed, this driver must be libusb or +libusb-win32 (see http://libusb.org/ and +http://libusb-win32.sourceforge.net/). + +Table if IDs for discrimination by textual name: + +PID dec (hex) | VID dec (hex) | Description of use +==============+===============+============================================ +1500 (0x05dc) | 5824 (0x16c0) | For Vendor Class devices with libusb +--------------+---------------+-------------------------------------------- +1503 (0x05df) | 5824 (0x16c0) | For generic HID class devices (which are + | | NOT mice, keyboards or joysticks) +--------------+---------------+-------------------------------------------- +1505 (0x05e1) | 5824 (0x16c0) | For CDC-ACM class devices (modems) +--------------+---------------+-------------------------------------------- +1508 (0x05e4) | 5824 (0x16c0) | For MIDI class devices +--------------+---------------+-------------------------------------------- + +Note that Windows caches the textual product- and vendor-description for +mice, keyboards and joysticks. Name-bsed discrimination is therefore not +recommended for these device classes. + + +======================================= +IDs FOR DISCRIMINATION BY SERIAL NUMBER +======================================= + +If you use one of the IDs listed below, your device and host-side software +must conform to these rules: + +(1) The USB device MUST provide a textual representation of the serial +number. The serial number string MUST be available at least in USB language +0x0409 (English/US). + +(2) The serial number MUST start with either an Internet domain name (e.g. +"mycompany.com") registered and owned by you, or an e-mail address under your +control (e.g. "myname@gmx.net"), both terminated with a colon (":") character. +You MAY append any string you like for further discrimination of your devices. + +(3) You are responsible for retaining ownership of the domain or e-mail +address for as long as any of your products are in use. + +(5) Application side device look-up MUST be based on the serial number string +in addition to VID/PID matching. The matching must start at the first +character of the serial number string and include the colon character +terminating your domain or e-mail address. It MAY stop anywhere after that. + +(6) For devices which implement a particular USB device class (e.g. HID), the +operating system's default class driver MUST be used. If an operating system +driver for Vendor Class devices is needed, this driver must be libusb or +libusb-win32 (see http://libusb.org/ and +http://libusb-win32.sourceforge.net/). + +Table if IDs for discrimination by serial number string: + +PID dec (hex) | VID dec (hex) | Description of use +===============+===============+=========================================== +10200 (0x27d8) | 5824 (0x16c0) | For Vendor Class devices with libusb +---------------+---------------+------------------------------------------- +10201 (0x27d9) | 5824 (0x16c0) | For generic HID class devices (which are + | | NOT mice, keyboards or joysticks) +---------------+---------------+------------------------------------------- +10202 (0x27da) | 5824 (0x16c0) | For USB Mice +---------------+---------------+------------------------------------------- +10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards +---------------+---------------+------------------------------------------- +10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks +---------------+---------------+------------------------------------------- +10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems) +---------------+---------------+------------------------------------------- +10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices +---------------+---------------+------------------------------------------- + + +================= +ORIGIN OF USB-IDs +================= + +OBJECTIVE DEVELOPMENT Software GmbH has obtained all VID/PID pairs listed +here from Wouter van Ooijen (see www.voti.nl) for exclusive disposition. +Wouter van Ooijen has obtained the VID from the USB Implementers Forum, Inc. +(see www.usb.org). The VID is registered for the company name "Van Ooijen +Technische Informatica". + + +========== +DISCLAIMER +========== + +OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any +problems which are caused by the shared use of these VID/PID pairs. diff --git a/protocol/vusb/usbdrv/asmcommon.inc b/protocol/vusb/usbdrv/asmcommon.inc new file mode 100644 index 000000000..07d692be3 --- /dev/null +++ b/protocol/vusb/usbdrv/asmcommon.inc @@ -0,0 +1,188 @@ +/* Name: asmcommon.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2007-11-05 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id$ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file contains assembler code which is shared among the USB driver +implementations for different CPU cocks. Since the code must be inserted +in the middle of the module, it's split out into this file and #included. + +Jump destinations called from outside: + sofError: Called when no start sequence was found. + se0: Called when a package has been successfully received. + overflow: Called when receive buffer overflows. + doReturn: Called after sending data. + +Outside jump destinations used by this module: + waitForJ: Called to receive an already arriving packet. + sendAckAndReti: + sendNakAndReti: + sendCntAndReti: + usbSendAndReti: + +The following macros must be defined before this file is included: + .macro POP_STANDARD + .endm + .macro POP_RETI + .endm +*/ + +#define token x1 + +overflow: + ldi x2, 1< 0 + +#warning "Never compile production devices with debugging enabled" + +static void uartPutc(char c) +{ + while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */ + ODDBG_UDR = c; +} + +static uchar hexAscii(uchar h) +{ + h &= 0xf; + if(h >= 10) + h += 'a' - (uchar)10 - '0'; + h += '0'; + return h; +} + +static void printHex(uchar c) +{ + uartPutc(hexAscii(c >> 4)); + uartPutc(hexAscii(c)); +} + +void odDebug(uchar prefix, uchar *data, uchar len) +{ + printHex(prefix); + uartPutc(':'); + while(len--){ + uartPutc(' '); + printHex(*data++); + } + uartPutc('\r'); + uartPutc('\n'); +} + +#endif diff --git a/protocol/vusb/usbdrv/oddebug.h b/protocol/vusb/usbdrv/oddebug.h new file mode 100644 index 000000000..d61309daa --- /dev/null +++ b/protocol/vusb/usbdrv/oddebug.h @@ -0,0 +1,123 @@ +/* Name: oddebug.h + * Project: AVR library + * Author: Christian Starkjohann + * Creation Date: 2005-01-16 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: oddebug.h 692 2008-11-07 15:07:40Z cs $ + */ + +#ifndef __oddebug_h_included__ +#define __oddebug_h_included__ + +/* +General Description: +This module implements a function for debug logs on the serial line of the +AVR microcontroller. Debugging can be configured with the define +'DEBUG_LEVEL'. If this macro is not defined or defined to 0, all debugging +calls are no-ops. If it is 1, DBG1 logs will appear, but not DBG2. If it is +2, DBG1 and DBG2 logs will be printed. + +A debug log consists of a label ('prefix') to indicate which debug log created +the output and a memory block to dump in hex ('data' and 'len'). +*/ + + +#ifndef F_CPU +# define F_CPU 12000000 /* 12 MHz */ +#endif + +/* make sure we have the UART defines: */ +#include "usbportability.h" + +#ifndef uchar +# define uchar unsigned char +#endif + +#if DEBUG_LEVEL > 0 && !(defined TXEN || defined TXEN0) /* no UART in device */ +# warning "Debugging disabled because device has no UART" +# undef DEBUG_LEVEL +#endif + +#ifndef DEBUG_LEVEL +# define DEBUG_LEVEL 0 +#endif + +/* ------------------------------------------------------------------------- */ + +#if DEBUG_LEVEL > 0 +# define DBG1(prefix, data, len) odDebug(prefix, data, len) +#else +# define DBG1(prefix, data, len) +#endif + +#if DEBUG_LEVEL > 1 +# define DBG2(prefix, data, len) odDebug(prefix, data, len) +#else +# define DBG2(prefix, data, len) +#endif + +/* ------------------------------------------------------------------------- */ + +#if DEBUG_LEVEL > 0 +extern void odDebug(uchar prefix, uchar *data, uchar len); + +/* Try to find our control registers; ATMEL likes to rename these */ + +#if defined UBRR +# define ODDBG_UBRR UBRR +#elif defined UBRRL +# define ODDBG_UBRR UBRRL +#elif defined UBRR0 +# define ODDBG_UBRR UBRR0 +#elif defined UBRR0L +# define ODDBG_UBRR UBRR0L +#endif + +#if defined UCR +# define ODDBG_UCR UCR +#elif defined UCSRB +# define ODDBG_UCR UCSRB +#elif defined UCSR0B +# define ODDBG_UCR UCSR0B +#endif + +#if defined TXEN +# define ODDBG_TXEN TXEN +#else +# define ODDBG_TXEN TXEN0 +#endif + +#if defined USR +# define ODDBG_USR USR +#elif defined UCSRA +# define ODDBG_USR UCSRA +#elif defined UCSR0A +# define ODDBG_USR UCSR0A +#endif + +#if defined UDRE +# define ODDBG_UDRE UDRE +#else +# define ODDBG_UDRE UDRE0 +#endif + +#if defined UDR +# define ODDBG_UDR UDR +#elif defined UDR0 +# define ODDBG_UDR UDR0 +#endif + +static inline void odDebugInit(void) +{ + ODDBG_UCR |= (1<len & 0x10){ /* packet buffer was empty */ + txStatus->buffer[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* toggle token */ + }else{ + txStatus->len = USBPID_NAK; /* avoid sending outdated (overwritten) interrupt data */ + } + p = txStatus->buffer + 1; + i = len; + do{ /* if len == 0, we still copy 1 byte, but that's no problem */ + *p++ = *data++; + }while(--i > 0); /* loop control at the end is 2 bytes shorter than at beginning */ + usbCrc16Append(&txStatus->buffer[1], len); + txStatus->len = len + 4; /* len must be given including sync byte */ + DBG2(0x21 + (((int)txStatus >> 3) & 3), txStatus->buffer, len + 3); +} + +USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len) +{ + usbGenericSetInterrupt(data, len, &usbTxStatus1); +} +#endif + +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 +USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len) +{ + usbGenericSetInterrupt(data, len, &usbTxStatus3); +} +#endif +#endif /* USB_CFG_SUPPRESS_INTR_CODE */ + +/* ------------------ utilities for code following below ------------------- */ + +/* Use defines for the switch statement so that we can choose between an + * if()else if() and a switch/case based implementation. switch() is more + * efficient for a LARGE set of sequential choices, if() is better in all other + * cases. + */ +#if USB_CFG_USE_SWITCH_STATEMENT +# define SWITCH_START(cmd) switch(cmd){{ +# define SWITCH_CASE(value) }break; case (value):{ +# define SWITCH_CASE2(v1,v2) }break; case (v1): case(v2):{ +# define SWITCH_CASE3(v1,v2,v3) }break; case (v1): case(v2): case(v3):{ +# define SWITCH_DEFAULT }break; default:{ +# define SWITCH_END }} +#else +# define SWITCH_START(cmd) {uchar _cmd = cmd; if(0){ +# define SWITCH_CASE(value) }else if(_cmd == (value)){ +# define SWITCH_CASE2(v1,v2) }else if(_cmd == (v1) || _cmd == (v2)){ +# define SWITCH_CASE3(v1,v2,v3) }else if(_cmd == (v1) || _cmd == (v2) || (_cmd == v3)){ +# define SWITCH_DEFAULT }else{ +# define SWITCH_END }} +#endif + +#ifndef USB_RX_USER_HOOK +#define USB_RX_USER_HOOK(data, len) +#endif +#ifndef USB_SET_ADDRESS_HOOK +#define USB_SET_ADDRESS_HOOK() +#endif + +/* ------------------------------------------------------------------------- */ + +/* We use if() instead of #if in the macro below because #if can't be used + * in macros and the compiler optimizes constant conditions anyway. + * This may cause problems with undefined symbols if compiled without + * optimizing! + */ +#define GET_DESCRIPTOR(cfgProp, staticName) \ + if(cfgProp){ \ + if((cfgProp) & USB_PROP_IS_RAM) \ + flags = 0; \ + if((cfgProp) & USB_PROP_IS_DYNAMIC){ \ + len = usbFunctionDescriptor(rq); \ + }else{ \ + len = USB_PROP_LENGTH(cfgProp); \ + usbMsgPtr = (uchar *)(staticName); \ + } \ + } + +/* usbDriverDescriptor() is similar to usbFunctionDescriptor(), but used + * internally for all types of descriptors. + */ +static inline usbMsgLen_t usbDriverDescriptor(usbRequest_t *rq) +{ +usbMsgLen_t len = 0; +uchar flags = USB_FLG_MSGPTR_IS_ROM; + + SWITCH_START(rq->wValue.bytes[1]) + SWITCH_CASE(USBDESCR_DEVICE) /* 1 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice) + SWITCH_CASE(USBDESCR_CONFIG) /* 2 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_CONFIGURATION, usbDescriptorConfiguration) + SWITCH_CASE(USBDESCR_STRING) /* 3 */ +#if USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC + if(USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_RAM) + flags = 0; + len = usbFunctionDescriptor(rq); +#else /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */ + SWITCH_START(rq->wValue.bytes[0]) + SWITCH_CASE(0) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0) + SWITCH_CASE(1) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_VENDOR, usbDescriptorStringVendor) + SWITCH_CASE(2) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_PRODUCT, usbDescriptorStringDevice) + SWITCH_CASE(3) + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER, usbDescriptorStringSerialNumber) + SWITCH_DEFAULT + if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){ + len = usbFunctionDescriptor(rq); + } + SWITCH_END +#endif /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */ +#if USB_CFG_DESCR_PROPS_HID_REPORT /* only support HID descriptors if enabled */ + SWITCH_CASE(USBDESCR_HID) /* 0x21 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18) + SWITCH_CASE(USBDESCR_HID_REPORT)/* 0x22 */ + GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID_REPORT, usbDescriptorHidReport) +#endif + SWITCH_DEFAULT + if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){ + len = usbFunctionDescriptor(rq); + } + SWITCH_END + usbMsgFlags = flags; + return len; +} + +/* ------------------------------------------------------------------------- */ + +/* usbDriverSetup() is similar to usbFunctionSetup(), but it's used for + * standard requests instead of class and custom requests. + */ +static inline usbMsgLen_t usbDriverSetup(usbRequest_t *rq) +{ +uchar len = 0, *dataPtr = usbTxBuf + 9; /* there are 2 bytes free space at the end of the buffer */ +uchar value = rq->wValue.bytes[0]; +#if USB_CFG_IMPLEMENT_HALT +uchar index = rq->wIndex.bytes[0]; +#endif + + dataPtr[0] = 0; /* default reply common to USBRQ_GET_STATUS and USBRQ_GET_INTERFACE */ + SWITCH_START(rq->bRequest) + SWITCH_CASE(USBRQ_GET_STATUS) /* 0 */ + uchar recipient = rq->bmRequestType & USBRQ_RCPT_MASK; /* assign arith ops to variables to enforce byte size */ + if(USB_CFG_IS_SELF_POWERED && recipient == USBRQ_RCPT_DEVICE) + dataPtr[0] = USB_CFG_IS_SELF_POWERED; +#if USB_CFG_IMPLEMENT_HALT + if(recipient == USBRQ_RCPT_ENDPOINT && index == 0x81) /* request status for endpoint 1 */ + dataPtr[0] = usbTxLen1 == USBPID_STALL; +#endif + dataPtr[1] = 0; + len = 2; +#if USB_CFG_IMPLEMENT_HALT + SWITCH_CASE2(USBRQ_CLEAR_FEATURE, USBRQ_SET_FEATURE) /* 1, 3 */ + if(value == 0 && index == 0x81){ /* feature 0 == HALT for endpoint == 1 */ + usbTxLen1 = rq->bRequest == USBRQ_CLEAR_FEATURE ? USBPID_NAK : USBPID_STALL; + usbResetDataToggling(); + } +#endif + SWITCH_CASE(USBRQ_SET_ADDRESS) /* 5 */ + usbNewDeviceAddr = value; + USB_SET_ADDRESS_HOOK(); + SWITCH_CASE(USBRQ_GET_DESCRIPTOR) /* 6 */ + len = usbDriverDescriptor(rq); + goto skipMsgPtrAssignment; + SWITCH_CASE(USBRQ_GET_CONFIGURATION) /* 8 */ + dataPtr = &usbConfiguration; /* send current configuration value */ + len = 1; + SWITCH_CASE(USBRQ_SET_CONFIGURATION) /* 9 */ + usbConfiguration = value; + usbResetStall(); + SWITCH_CASE(USBRQ_GET_INTERFACE) /* 10 */ + len = 1; +#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE + SWITCH_CASE(USBRQ_SET_INTERFACE) /* 11 */ + usbResetDataToggling(); + usbResetStall(); +#endif + SWITCH_DEFAULT /* 7=SET_DESCRIPTOR, 12=SYNC_FRAME */ + /* Should we add an optional hook here? */ + SWITCH_END + usbMsgPtr = dataPtr; +skipMsgPtrAssignment: + return len; +} + +/* ------------------------------------------------------------------------- */ + +/* usbProcessRx() is called for every message received by the interrupt + * routine. It distinguishes between SETUP and DATA packets and processes + * them accordingly. + */ +static inline void usbProcessRx(uchar *data, uchar len) +{ +usbRequest_t *rq = (void *)data; + +/* usbRxToken can be: + * 0x2d 00101101 (USBPID_SETUP for setup data) + * 0xe1 11100001 (USBPID_OUT: data phase of setup transfer) + * 0...0x0f for OUT on endpoint X + */ + DBG2(0x10 + (usbRxToken & 0xf), data, len + 2); /* SETUP=1d, SETUP-DATA=11, OUTx=1x */ + USB_RX_USER_HOOK(data, len) +#if USB_CFG_IMPLEMENT_FN_WRITEOUT + if(usbRxToken < 0x10){ /* OUT to endpoint != 0: endpoint number in usbRxToken */ + usbFunctionWriteOut(data, len); + return; + } +#endif + if(usbRxToken == (uchar)USBPID_SETUP){ + if(len != 8) /* Setup size must be always 8 bytes. Ignore otherwise. */ + return; + usbMsgLen_t replyLen; + usbTxBuf[0] = USBPID_DATA0; /* initialize data toggling */ + usbTxLen = USBPID_NAK; /* abort pending transmit */ + usbMsgFlags = 0; + uchar type = rq->bmRequestType & USBRQ_TYPE_MASK; + if(type != USBRQ_TYPE_STANDARD){ /* standard requests are handled by driver */ + replyLen = usbFunctionSetup(data); + }else{ + replyLen = usbDriverSetup(rq); + } +#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE + if(replyLen == USB_NO_MSG){ /* use user-supplied read/write function */ + /* do some conditioning on replyLen, but on IN transfers only */ + if((rq->bmRequestType & USBRQ_DIR_MASK) != USBRQ_DIR_HOST_TO_DEVICE){ + if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */ + replyLen = rq->wLength.bytes[0]; + }else{ + replyLen = rq->wLength.word; + } + } + usbMsgFlags = USB_FLG_USE_USER_RW; + }else /* The 'else' prevents that we limit a replyLen of USB_NO_MSG to the maximum transfer len. */ +#endif + if(sizeof(replyLen) < sizeof(rq->wLength.word)){ /* help compiler with optimizing */ + if(!rq->wLength.bytes[1] && replyLen > rq->wLength.bytes[0]) /* limit length to max */ + replyLen = rq->wLength.bytes[0]; + }else{ + if(replyLen > rq->wLength.word) /* limit length to max */ + replyLen = rq->wLength.word; + } + usbMsgLen = replyLen; + }else{ /* usbRxToken must be USBPID_OUT, which means data phase of setup (control-out) */ +#if USB_CFG_IMPLEMENT_FN_WRITE + if(usbMsgFlags & USB_FLG_USE_USER_RW){ + uchar rval = usbFunctionWrite(data, len); + if(rval == 0xff){ /* an error occurred */ + usbTxLen = USBPID_STALL; + }else if(rval != 0){ /* This was the final package */ + usbMsgLen = 0; /* answer with a zero-sized data packet */ + } + } +#endif + } +} + +/* ------------------------------------------------------------------------- */ + +/* This function is similar to usbFunctionRead(), but it's also called for + * data handled automatically by the driver (e.g. descriptor reads). + */ +static uchar usbDeviceRead(uchar *data, uchar len) +{ + if(len > 0){ /* don't bother app with 0 sized reads */ +#if USB_CFG_IMPLEMENT_FN_READ + if(usbMsgFlags & USB_FLG_USE_USER_RW){ + len = usbFunctionRead(data, len); + }else +#endif + { + uchar i = len, *r = usbMsgPtr; + if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */ + do{ + uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */ + *data++ = c; + r++; + }while(--i); + }else{ /* RAM data */ + do{ + *data++ = *r++; + }while(--i); + } + usbMsgPtr = r; + } + } + return len; +} + +/* ------------------------------------------------------------------------- */ + +/* usbBuildTxBlock() is called when we have data to transmit and the + * interrupt routine's transmit buffer is empty. + */ +static inline void usbBuildTxBlock(void) +{ +usbMsgLen_t wantLen; +uchar len; + + wantLen = usbMsgLen; + if(wantLen > 8) + wantLen = 8; + usbMsgLen -= wantLen; + usbTxBuf[0] ^= USBPID_DATA0 ^ USBPID_DATA1; /* DATA toggling */ + len = usbDeviceRead(usbTxBuf + 1, wantLen); + if(len <= 8){ /* valid data packet */ + usbCrc16Append(&usbTxBuf[1], len); + len += 4; /* length including sync byte */ + if(len < 12) /* a partial package identifies end of message */ + usbMsgLen = USB_NO_MSG; + }else{ + len = USBPID_STALL; /* stall the endpoint */ + usbMsgLen = USB_NO_MSG; + } + usbTxLen = len; + DBG2(0x20, usbTxBuf, len-1); +} + +/* ------------------------------------------------------------------------- */ + +static inline void usbHandleResetHook(uchar notResetState) +{ +#ifdef USB_RESET_HOOK +static uchar wasReset; +uchar isReset = !notResetState; + + if(wasReset != isReset){ + USB_RESET_HOOK(isReset); + wasReset = isReset; + } +#endif +} + +/* ------------------------------------------------------------------------- */ + +USB_PUBLIC void usbPoll(void) +{ +schar len; +uchar i; + + len = usbRxLen - 3; + if(len >= 0){ +/* We could check CRC16 here -- but ACK has already been sent anyway. If you + * need data integrity checks with this driver, check the CRC in your app + * code and report errors back to the host. Since the ACK was already sent, + * retries must be handled on application level. + * unsigned crc = usbCrc16(buffer + 1, usbRxLen - 3); + */ + usbProcessRx(usbRxBuf + USB_BUFSIZE + 1 - usbInputBufOffset, len); +#if USB_CFG_HAVE_FLOWCONTROL + if(usbRxLen > 0) /* only mark as available if not inactivated */ + usbRxLen = 0; +#else + usbRxLen = 0; /* mark rx buffer as available */ +#endif + } + if(usbTxLen & 0x10){ /* transmit system idle */ + if(usbMsgLen != USB_NO_MSG){ /* transmit data pending? */ + usbBuildTxBlock(); + } + } + for(i = 20; i > 0; i--){ + uchar usbLineStatus = USBIN & USBMASK; + if(usbLineStatus != 0) /* SE0 has ended */ + goto isNotReset; + } + /* RESET condition, called multiple times during reset */ + usbNewDeviceAddr = 0; + usbDeviceAddr = 0; + usbResetStall(); + DBG1(0xff, 0, 0); +isNotReset: + usbHandleResetHook(i); +} + +/* ------------------------------------------------------------------------- */ + +USB_PUBLIC void usbInit(void) +{ +#if USB_INTR_CFG_SET != 0 + USB_INTR_CFG |= USB_INTR_CFG_SET; +#endif +#if USB_INTR_CFG_CLR != 0 + USB_INTR_CFG &= ~(USB_INTR_CFG_CLR); +#endif + USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT); + usbResetDataToggling(); +#if USB_CFG_HAVE_INTRIN_ENDPOINT && !USB_CFG_SUPPRESS_INTR_CODE + usbTxLen1 = USBPID_NAK; +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 + usbTxLen3 = USBPID_NAK; +#endif +#endif +} + +/* ------------------------------------------------------------------------- */ diff --git a/protocol/vusb/usbdrv/usbdrv.h b/protocol/vusb/usbdrv/usbdrv.h new file mode 100644 index 000000000..42fe16372 --- /dev/null +++ b/protocol/vusb/usbdrv/usbdrv.h @@ -0,0 +1,735 @@ +/* Name: usbdrv.h + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2004-12-29 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbdrv.h 793 2010-07-15 15:58:11Z cs $ + */ + +#ifndef __usbdrv_h_included__ +#define __usbdrv_h_included__ +#include "usbconfig.h" +#include "usbportability.h" + +/* +Hardware Prerequisites: +======================= +USB lines D+ and D- MUST be wired to the same I/O port. We recommend that D+ +triggers the interrupt (best achieved by using INT0 for D+), but it is also +possible to trigger the interrupt from D-. If D- is used, interrupts are also +triggered by SOF packets. D- requires a pull-up of 1.5k to +3.5V (and the +device must be powered at 3.5V) to identify as low-speed USB device. A +pull-down or pull-up of 1M SHOULD be connected from D+ to +3.5V to prevent +interference when no USB master is connected. If you use Zener diodes to limit +the voltage on D+ and D-, you MUST use a pull-down resistor, not a pull-up. +We use D+ as interrupt source and not D- because it does not trigger on +keep-alive and RESET states. If you want to count keep-alive events with +USB_COUNT_SOF, you MUST use D- as an interrupt source. + +As a compile time option, the 1.5k pull-up resistor on D- can be made +switchable to allow the device to disconnect at will. See the definition of +usbDeviceConnect() and usbDeviceDisconnect() further down in this file. + +Please adapt the values in usbconfig.h according to your hardware! + +The device MUST be clocked at exactly 12 MHz, 15 MHz, 16 MHz or 20 MHz +or at 12.8 MHz resp. 16.5 MHz +/- 1%. See usbconfig-prototype.h for details. + + +Limitations: +============ +Robustness with respect to communication errors: +The driver assumes error-free communication. It DOES check for errors in +the PID, but does NOT check bit stuffing errors, SE0 in middle of a byte, +token CRC (5 bit) and data CRC (16 bit). CRC checks can not be performed due +to timing constraints: We must start sending a reply within 7 bit times. +Bit stuffing and misplaced SE0 would have to be checked in real-time, but CPU +performance does not permit that. The driver does not check Data0/Data1 +toggling, but application software can implement the check. + +Input characteristics: +Since no differential receiver circuit is used, electrical interference +robustness may suffer. The driver samples only one of the data lines with +an ordinary I/O pin's input characteristics. However, since this is only a +low speed USB implementation and the specification allows for 8 times the +bit rate over the same hardware, we should be on the safe side. Even the spec +requires detection of asymmetric states at high bit rate for SE0 detection. + +Number of endpoints: +The driver supports the following endpoints: + +- Endpoint 0, the default control endpoint. +- Any number of interrupt- or bulk-out endpoints. The data is sent to + usbFunctionWriteOut() and USB_CFG_IMPLEMENT_FN_WRITEOUT must be defined + to 1 to activate this feature. The endpoint number can be found in the + global variable 'usbRxToken'. +- One default interrupt- or bulk-in endpoint. This endpoint is used for + interrupt- or bulk-in transfers which are not handled by any other endpoint. + You must define USB_CFG_HAVE_INTRIN_ENDPOINT in order to activate this + feature and call usbSetInterrupt() to send interrupt/bulk data. +- One additional interrupt- or bulk-in endpoint. This was endpoint 3 in + previous versions of this driver but can now be configured to any endpoint + number. You must define USB_CFG_HAVE_INTRIN_ENDPOINT3 in order to activate + this feature and call usbSetInterrupt3() to send interrupt/bulk data. The + endpoint number can be set with USB_CFG_EP3_NUMBER. + +Please note that the USB standard forbids bulk endpoints for low speed devices! +Most operating systems allow them anyway, but the AVR will spend 90% of the CPU +time in the USB interrupt polling for bulk data. + +Maximum data payload: +Data payload of control in and out transfers may be up to 254 bytes. In order +to accept payload data of out transfers, you need to implement +'usbFunctionWrite()'. + +USB Suspend Mode supply current: +The USB standard limits power consumption to 500uA when the bus is in suspend +mode. This is not a problem for self-powered devices since they don't need +bus power anyway. Bus-powered devices can achieve this only by putting the +CPU in sleep mode. The driver does not implement suspend handling by itself. +However, the application may implement activity monitoring and wakeup from +sleep. The host sends regular SE0 states on the bus to keep it active. These +SE0 states can be detected by using D- as the interrupt source. Define +USB_COUNT_SOF to 1 and use the global variable usbSofCount to check for bus +activity. + +Operation without an USB master: +The driver behaves neutral without connection to an USB master if D- reads +as 1. To avoid spurious interrupts, we recommend a high impedance (e.g. 1M) +pull-down or pull-up resistor on D+ (interrupt). If Zener diodes are used, +use a pull-down. If D- becomes statically 0, the driver may block in the +interrupt routine. + +Interrupt latency: +The application must ensure that the USB interrupt is not disabled for more +than 25 cycles (this is for 12 MHz, faster clocks allow longer latency). +This implies that all interrupt routines must either have the "ISR_NOBLOCK" +attribute set (see "avr/interrupt.h") or be written in assembler with "sei" +as the first instruction. + +Maximum interrupt duration / CPU cycle consumption: +The driver handles all USB communication during the interrupt service +routine. The routine will not return before an entire USB message is received +and the reply is sent. This may be up to ca. 1200 cycles @ 12 MHz (= 100us) if +the host conforms to the standard. The driver will consume CPU cycles for all +USB messages, even if they address another (low-speed) device on the same bus. + +*/ + +/* ------------------------------------------------------------------------- */ +/* --------------------------- Module Interface ---------------------------- */ +/* ------------------------------------------------------------------------- */ + +#define USBDRV_VERSION 20100715 +/* This define uniquely identifies a driver version. It is a decimal number + * constructed from the driver's release date in the form YYYYMMDD. If the + * driver's behavior or interface changes, you can use this constant to + * distinguish versions. If it is not defined, the driver's release date is + * older than 2006-01-25. + */ + + +#ifndef USB_PUBLIC +#define USB_PUBLIC +#endif +/* USB_PUBLIC is used as declaration attribute for all functions exported by + * the USB driver. The default is no attribute (see above). You may define it + * to static either in usbconfig.h or from the command line if you include + * usbdrv.c instead of linking against it. Including the C module of the driver + * directly in your code saves a couple of bytes in flash memory. + */ + +#ifndef __ASSEMBLER__ +#ifndef uchar +#define uchar unsigned char +#endif +#ifndef schar +#define schar signed char +#endif +/* shortcuts for well defined 8 bit integer types */ + +#if USB_CFG_LONG_TRANSFERS /* if more than 254 bytes transfer size required */ +# define usbMsgLen_t unsigned +#else +# define usbMsgLen_t uchar +#endif +/* usbMsgLen_t is the data type used for transfer lengths. By default, it is + * defined to uchar, allowing a maximum of 254 bytes (255 is reserved for + * USB_NO_MSG below). If the usbconfig.h defines USB_CFG_LONG_TRANSFERS to 1, + * a 16 bit data type is used, allowing up to 16384 bytes (the rest is used + * for flags in the descriptor configuration). + */ +#define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */ + +struct usbRequest; /* forward declaration */ + +USB_PUBLIC void usbInit(void); +/* This function must be called before interrupts are enabled and the main + * loop is entered. We exepct that the PORT and DDR bits for D+ and D- have + * not been changed from their default status (which is 0). If you have changed + * them, set both back to 0 (configure them as input with no internal pull-up). + */ +USB_PUBLIC void usbPoll(void); +/* This function must be called at regular intervals from the main loop. + * Maximum delay between calls is somewhat less than 50ms (USB timeout for + * accepting a Setup message). Otherwise the device will not be recognized. + * Please note that debug outputs through the UART take ~ 0.5ms per byte + * at 19200 bps. + */ +extern uchar *usbMsgPtr; +/* This variable may be used to pass transmit data to the driver from the + * implementation of usbFunctionWrite(). It is also used internally by the + * driver for standard control requests. + */ +USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]); +/* This function is called when the driver receives a SETUP transaction from + * the host which is not answered by the driver itself (in practice: class and + * vendor requests). All control transfers start with a SETUP transaction where + * the host communicates the parameters of the following (optional) data + * transfer. The SETUP data is available in the 'data' parameter which can + * (and should) be casted to 'usbRequest_t *' for a more user-friendly access + * to parameters. + * + * If the SETUP indicates a control-in transfer, you should provide the + * requested data to the driver. There are two ways to transfer this data: + * (1) Set the global pointer 'usbMsgPtr' to the base of the static RAM data + * block and return the length of the data in 'usbFunctionSetup()'. The driver + * will handle the rest. Or (2) return USB_NO_MSG in 'usbFunctionSetup()'. The + * driver will then call 'usbFunctionRead()' when data is needed. See the + * documentation for usbFunctionRead() for details. + * + * If the SETUP indicates a control-out transfer, the only way to receive the + * data from the host is through the 'usbFunctionWrite()' call. If you + * implement this function, you must return USB_NO_MSG in 'usbFunctionSetup()' + * to indicate that 'usbFunctionWrite()' should be used. See the documentation + * of this function for more information. If you just want to ignore the data + * sent by the host, return 0 in 'usbFunctionSetup()'. + * + * Note that calls to the functions usbFunctionRead() and usbFunctionWrite() + * are only done if enabled by the configuration in usbconfig.h. + */ +USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq); +/* You need to implement this function ONLY if you provide USB descriptors at + * runtime (which is an expert feature). It is very similar to + * usbFunctionSetup() above, but it is called only to request USB descriptor + * data. See the documentation of usbFunctionSetup() above for more info. + */ +#if USB_CFG_HAVE_INTRIN_ENDPOINT +USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len); +/* This function sets the message which will be sent during the next interrupt + * IN transfer. The message is copied to an internal buffer and must not exceed + * a length of 8 bytes. The message may be 0 bytes long just to indicate the + * interrupt status to the host. + * If you need to transfer more bytes, use a control read after the interrupt. + */ +#define usbInterruptIsReady() (usbTxLen1 & 0x10) +/* This macro indicates whether the last interrupt message has already been + * sent. If you set a new interrupt message before the old was sent, the + * message already buffered will be lost. + */ +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 +USB_PUBLIC void usbSetInterrupt3(uchar *data, uchar len); +#define usbInterruptIsReady3() (usbTxLen3 & 0x10) +/* Same as above for endpoint 3 */ +#endif +#endif /* USB_CFG_HAVE_INTRIN_ENDPOINT */ +#if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH /* simplified interface for backward compatibility */ +#define usbHidReportDescriptor usbDescriptorHidReport +/* should be declared as: PROGMEM char usbHidReportDescriptor[]; */ +/* If you implement an HID device, you need to provide a report descriptor. + * The HID report descriptor syntax is a bit complex. If you understand how + * report descriptors are constructed, we recommend that you use the HID + * Descriptor Tool from usb.org, see http://www.usb.org/developers/hidpage/. + * Otherwise you should probably start with a working example. + */ +#endif /* USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH */ +#if USB_CFG_IMPLEMENT_FN_WRITE +USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len); +/* This function is called by the driver to provide a control transfer's + * payload data (control-out). It is called in chunks of up to 8 bytes. The + * total count provided in the current control transfer can be obtained from + * the 'length' property in the setup data. If an error occurred during + * processing, return 0xff (== -1). The driver will answer the entire transfer + * with a STALL token in this case. If you have received the entire payload + * successfully, return 1. If you expect more data, return 0. If you don't + * know whether the host will send more data (you should know, the total is + * provided in the usbFunctionSetup() call!), return 1. + * NOTE: If you return 0xff for STALL, 'usbFunctionWrite()' may still be called + * for the remaining data. You must continue to return 0xff for STALL in these + * calls. + * In order to get usbFunctionWrite() called, define USB_CFG_IMPLEMENT_FN_WRITE + * to 1 in usbconfig.h and return 0xff in usbFunctionSetup().. + */ +#endif /* USB_CFG_IMPLEMENT_FN_WRITE */ +#if USB_CFG_IMPLEMENT_FN_READ +USB_PUBLIC uchar usbFunctionRead(uchar *data, uchar len); +/* This function is called by the driver to ask the application for a control + * transfer's payload data (control-in). It is called in chunks of up to 8 + * bytes each. You should copy the data to the location given by 'data' and + * return the actual number of bytes copied. If you return less than requested, + * the control-in transfer is terminated. If you return 0xff, the driver aborts + * the transfer with a STALL token. + * In order to get usbFunctionRead() called, define USB_CFG_IMPLEMENT_FN_READ + * to 1 in usbconfig.h and return 0xff in usbFunctionSetup().. + */ +#endif /* USB_CFG_IMPLEMENT_FN_READ */ + +extern uchar usbRxToken; /* may be used in usbFunctionWriteOut() below */ +#if USB_CFG_IMPLEMENT_FN_WRITEOUT +USB_PUBLIC void usbFunctionWriteOut(uchar *data, uchar len); +/* This function is called by the driver when data is received on an interrupt- + * or bulk-out endpoint. The endpoint number can be found in the global + * variable usbRxToken. You must define USB_CFG_IMPLEMENT_FN_WRITEOUT to 1 in + * usbconfig.h to get this function called. + */ +#endif /* USB_CFG_IMPLEMENT_FN_WRITEOUT */ +#ifdef USB_CFG_PULLUP_IOPORTNAME +#define usbDeviceConnect() ((USB_PULLUP_DDR |= (1<device, 1=device->host + * t ..... type: 0=standard, 1=class, 2=vendor, 3=reserved + * r ..... recipient: 0=device, 1=interface, 2=endpoint, 3=other + */ + +/* USB setup recipient values */ +#define USBRQ_RCPT_MASK 0x1f +#define USBRQ_RCPT_DEVICE 0 +#define USBRQ_RCPT_INTERFACE 1 +#define USBRQ_RCPT_ENDPOINT 2 + +/* USB request type values */ +#define USBRQ_TYPE_MASK 0x60 +#define USBRQ_TYPE_STANDARD (0<<5) +#define USBRQ_TYPE_CLASS (1<<5) +#define USBRQ_TYPE_VENDOR (2<<5) + +/* USB direction values: */ +#define USBRQ_DIR_MASK 0x80 +#define USBRQ_DIR_HOST_TO_DEVICE (0<<7) +#define USBRQ_DIR_DEVICE_TO_HOST (1<<7) + +/* USB Standard Requests */ +#define USBRQ_GET_STATUS 0 +#define USBRQ_CLEAR_FEATURE 1 +#define USBRQ_SET_FEATURE 3 +#define USBRQ_SET_ADDRESS 5 +#define USBRQ_GET_DESCRIPTOR 6 +#define USBRQ_SET_DESCRIPTOR 7 +#define USBRQ_GET_CONFIGURATION 8 +#define USBRQ_SET_CONFIGURATION 9 +#define USBRQ_GET_INTERFACE 10 +#define USBRQ_SET_INTERFACE 11 +#define USBRQ_SYNCH_FRAME 12 + +/* USB descriptor constants */ +#define USBDESCR_DEVICE 1 +#define USBDESCR_CONFIG 2 +#define USBDESCR_STRING 3 +#define USBDESCR_INTERFACE 4 +#define USBDESCR_ENDPOINT 5 +#define USBDESCR_HID 0x21 +#define USBDESCR_HID_REPORT 0x22 +#define USBDESCR_HID_PHYS 0x23 + +//#define USBATTR_BUSPOWER 0x80 // USB 1.1 does not define this value any more +#define USBATTR_SELFPOWER 0x40 +#define USBATTR_REMOTEWAKE 0x20 + +/* USB HID Requests */ +#define USBRQ_HID_GET_REPORT 0x01 +#define USBRQ_HID_GET_IDLE 0x02 +#define USBRQ_HID_GET_PROTOCOL 0x03 +#define USBRQ_HID_SET_REPORT 0x09 +#define USBRQ_HID_SET_IDLE 0x0a +#define USBRQ_HID_SET_PROTOCOL 0x0b + +/* ------------------------------------------------------------------------- */ + +#endif /* __usbdrv_h_included__ */ diff --git a/protocol/vusb/usbdrv/usbdrvasm.S b/protocol/vusb/usbdrv/usbdrvasm.S new file mode 100644 index 000000000..45fcf1831 --- /dev/null +++ b/protocol/vusb/usbdrv/usbdrvasm.S @@ -0,0 +1,393 @@ +/* Name: usbdrvasm.S + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2007-06-13 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id: usbdrvasm.S 785 2010-05-30 17:57:07Z cs $ + */ + +/* +General Description: +This module is the assembler part of the USB driver. This file contains +general code (preprocessor acrobatics and CRC computation) and then includes +the file appropriate for the given clock rate. +*/ + +#define __SFR_OFFSET 0 /* used by avr-libc's register definitions */ +#include "usbportability.h" +#include "usbdrv.h" /* for common defs */ + +/* register names */ +#define x1 r16 +#define x2 r17 +#define shift r18 +#define cnt r19 +#define x3 r20 +#define x4 r21 +#define x5 r22 +#define bitcnt x5 +#define phase x4 +#define leap x4 + +/* Some assembler dependent definitions and declarations: */ + +#ifdef __IAR_SYSTEMS_ASM__ + extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBufOffset + extern usbCurrentTok, usbRxLen, usbRxToken, usbTxLen + extern usbTxBuf, usbTxStatus1, usbTxStatus3 +# if USB_COUNT_SOF + extern usbSofCount +# endif + public usbCrc16 + public usbCrc16Append + + COMMON INTVEC +# ifndef USB_INTR_VECTOR + ORG INT0_vect +# else /* USB_INTR_VECTOR */ + ORG USB_INTR_VECTOR +# undef USB_INTR_VECTOR +# endif /* USB_INTR_VECTOR */ +# define USB_INTR_VECTOR usbInterruptHandler + rjmp USB_INTR_VECTOR + RSEG CODE + +#else /* __IAR_SYSTEMS_ASM__ */ + +# ifndef USB_INTR_VECTOR /* default to hardware interrupt INT0 */ +# ifdef INT0_vect +# define USB_INTR_VECTOR INT0_vect // this is the "new" define for the vector +# else +# define USB_INTR_VECTOR SIG_INTERRUPT0 // this is the "old" vector +# endif +# endif + .text + .global USB_INTR_VECTOR + .type USB_INTR_VECTOR, @function + .global usbCrc16 + .global usbCrc16Append +#endif /* __IAR_SYSTEMS_ASM__ */ + + +#if USB_INTR_PENDING < 0x40 /* This is an I/O address, use in and out */ +# define USB_LOAD_PENDING(reg) in reg, USB_INTR_PENDING +# define USB_STORE_PENDING(reg) out USB_INTR_PENDING, reg +#else /* It's a memory address, use lds and sts */ +# define USB_LOAD_PENDING(reg) lds reg, USB_INTR_PENDING +# define USB_STORE_PENDING(reg) sts USB_INTR_PENDING, reg +#endif + +#define usbTxLen1 usbTxStatus1 +#define usbTxBuf1 (usbTxStatus1 + 1) +#define usbTxLen3 usbTxStatus3 +#define usbTxBuf3 (usbTxStatus3 + 1) + + +;---------------------------------------------------------------------------- +; Utility functions +;---------------------------------------------------------------------------- + +#ifdef __IAR_SYSTEMS_ASM__ +/* Register assignments for usbCrc16 on IAR cc */ +/* Calling conventions on IAR: + * First parameter passed in r16/r17, second in r18/r19 and so on. + * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) + * Result is passed in r16/r17 + * In case of the "tiny" memory model, pointers are only 8 bit with no + * padding. We therefore pass argument 1 as "16 bit unsigned". + */ +RTMODEL "__rt_version", "3" +/* The line above will generate an error if cc calling conventions change. + * The value "3" above is valid for IAR 4.10B/W32 + */ +# define argLen r18 /* argument 2 */ +# define argPtrL r16 /* argument 1 */ +# define argPtrH r17 /* argument 1 */ + +# define resCrcL r16 /* result */ +# define resCrcH r17 /* result */ + +# define ptrL ZL +# define ptrH ZH +# define ptr Z +# define byte r22 +# define bitCnt r19 +# define polyL r20 +# define polyH r21 +# define scratch r23 + +#else /* __IAR_SYSTEMS_ASM__ */ +/* Register assignments for usbCrc16 on gcc */ +/* Calling conventions on gcc: + * First parameter passed in r24/r25, second in r22/23 and so on. + * Callee must preserve r1-r17, r28/r29 + * Result is passed in r24/r25 + */ +# define argLen r22 /* argument 2 */ +# define argPtrL r24 /* argument 1 */ +# define argPtrH r25 /* argument 1 */ + +# define resCrcL r24 /* result */ +# define resCrcH r25 /* result */ + +# define ptrL XL +# define ptrH XH +# define ptr x +# define byte r18 +# define bitCnt r19 +# define polyL r20 +# define polyH r21 +# define scratch r23 + +#endif + +#if USB_USE_FAST_CRC + +; This implementation is faster, but has bigger code size +; Thanks to Slawomir Fras (BoskiDialer) for this code! +; It implements the following C pseudo-code: +; unsigned table(unsigned char x) +; { +; unsigned value; +; +; value = (unsigned)x << 6; +; value ^= (unsigned)x << 7; +; if(parity(x)) +; value ^= 0xc001; +; return value; +; } +; unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen) +; { +; unsigned crc = 0xffff; +; +; while(argLen--) +; crc = table(lo8(crc) ^ *argPtr++) ^ hi8(crc); +; return ~crc; +; } + +; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); +; argPtr r24+25 / r16+r17 +; argLen r22 / r18 +; temp variables: +; byte r18 / r22 +; scratch r23 +; resCrc r24+r25 / r16+r17 +; ptr X / Z +usbCrc16: + mov ptrL, argPtrL + mov ptrH, argPtrH + ldi resCrcL, 0xFF + ldi resCrcH, 0xFF + rjmp usbCrc16LoopTest +usbCrc16ByteLoop: + ld byte, ptr+ + eor resCrcL, byte ; resCrcL is now 'x' in table() + mov byte, resCrcL ; compute parity of 'x' + swap byte + eor byte, resCrcL + mov scratch, byte + lsr byte + lsr byte + eor byte, scratch + inc byte + lsr byte + andi byte, 1 ; byte is now parity(x) + mov scratch, resCrcL + mov resCrcL, resCrcH + eor resCrcL, byte ; low byte of if(parity(x)) value ^= 0xc001; + neg byte + andi byte, 0xc0 + mov resCrcH, byte ; high byte of if(parity(x)) value ^= 0xc001; + clr byte + lsr scratch + ror byte + eor resCrcH, scratch + eor resCrcL, byte + lsr scratch + ror byte + eor resCrcH, scratch + eor resCrcL, byte +usbCrc16LoopTest: + subi argLen, 1 + brsh usbCrc16ByteLoop + com resCrcL + com resCrcH + ret + +#else /* USB_USE_FAST_CRC */ + +; This implementation is slower, but has less code size +; +; extern unsigned usbCrc16(unsigned char *argPtr, unsigned char argLen); +; argPtr r24+25 / r16+r17 +; argLen r22 / r18 +; temp variables: +; byte r18 / r22 +; bitCnt r19 +; poly r20+r21 +; scratch r23 +; resCrc r24+r25 / r16+r17 +; ptr X / Z +usbCrc16: + mov ptrL, argPtrL + mov ptrH, argPtrH + ldi resCrcL, 0 + ldi resCrcH, 0 + ldi polyL, lo8(0xa001) + ldi polyH, hi8(0xa001) + com argLen ; argLen = -argLen - 1: modified loop to ensure that carry is set + ldi bitCnt, 0 ; loop counter with starnd condition = end condition + rjmp usbCrcLoopEntry +usbCrcByteLoop: + ld byte, ptr+ + eor resCrcL, byte +usbCrcBitLoop: + ror resCrcH ; carry is always set here (see brcs jumps to here) + ror resCrcL + brcs usbCrcNoXor + eor resCrcL, polyL + eor resCrcH, polyH +usbCrcNoXor: + subi bitCnt, 224 ; (8 * 224) % 256 = 0; this loop iterates 8 times + brcs usbCrcBitLoop +usbCrcLoopEntry: + subi argLen, -1 + brcs usbCrcByteLoop +usbCrcReady: + ret +; Thanks to Reimar Doeffinger for optimizing this CRC routine! + +#endif /* USB_USE_FAST_CRC */ + +; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len); +usbCrc16Append: + rcall usbCrc16 + st ptr+, resCrcL + st ptr+, resCrcH + ret + +#undef argLen +#undef argPtrL +#undef argPtrH +#undef resCrcL +#undef resCrcH +#undef ptrL +#undef ptrH +#undef ptr +#undef byte +#undef bitCnt +#undef polyL +#undef polyH +#undef scratch + + +#if USB_CFG_HAVE_MEASURE_FRAME_LENGTH +#ifdef __IAR_SYSTEMS_ASM__ +/* Register assignments for usbMeasureFrameLength on IAR cc */ +/* Calling conventions on IAR: + * First parameter passed in r16/r17, second in r18/r19 and so on. + * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer) + * Result is passed in r16/r17 + * In case of the "tiny" memory model, pointers are only 8 bit with no + * padding. We therefore pass argument 1 as "16 bit unsigned". + */ +# define resL r16 +# define resH r17 +# define cnt16L r30 +# define cnt16H r31 +# define cntH r18 + +#else /* __IAR_SYSTEMS_ASM__ */ +/* Register assignments for usbMeasureFrameLength on gcc */ +/* Calling conventions on gcc: + * First parameter passed in r24/r25, second in r22/23 and so on. + * Callee must preserve r1-r17, r28/r29 + * Result is passed in r24/r25 + */ +# define resL r24 +# define resH r25 +# define cnt16L r24 +# define cnt16H r25 +# define cntH r26 +#endif +# define cnt16 cnt16L + +; extern unsigned usbMeasurePacketLength(void); +; returns time between two idle strobes in multiples of 7 CPU clocks +.global usbMeasureFrameLength +usbMeasureFrameLength: + ldi cntH, 6 ; wait ~ 10 ms for D- == 0 + clr cnt16L + clr cnt16H +usbMFTime16: + dec cntH + breq usbMFTimeout +usbMFWaitStrobe: ; first wait for D- == 0 (idle strobe) + sbiw cnt16, 1 ;[0] [6] + breq usbMFTime16 ;[2] + sbic USBIN, USBMINUS ;[3] + rjmp usbMFWaitStrobe ;[4] +usbMFWaitIdle: ; then wait until idle again + sbis USBIN, USBMINUS ;1 wait for D- == 1 + rjmp usbMFWaitIdle ;2 + ldi cnt16L, 1 ;1 represents cycles so far + clr cnt16H ;1 +usbMFWaitLoop: + in cntH, USBIN ;[0] [7] + adiw cnt16, 1 ;[1] + breq usbMFTimeout ;[3] + andi cntH, USBMASK ;[4] + brne usbMFWaitLoop ;[5] +usbMFTimeout: +#if resL != cnt16L + mov resL, cnt16L + mov resH, cnt16H +#endif + ret + +#undef resL +#undef resH +#undef cnt16 +#undef cnt16L +#undef cnt16H +#undef cntH + +#endif /* USB_CFG_HAVE_MEASURE_FRAME_LENGTH */ + +;---------------------------------------------------------------------------- +; Now include the clock rate specific code +;---------------------------------------------------------------------------- + +#ifndef USB_CFG_CLOCK_KHZ +# ifdef F_CPU +# define USB_CFG_CLOCK_KHZ (F_CPU/1000) +# else +# error "USB_CFG_CLOCK_KHZ not defined in usbconfig.h and no F_CPU set!" +# endif +#endif + +#if USB_CFG_CHECK_CRC /* separate dispatcher for CRC type modules */ +# if USB_CFG_CLOCK_KHZ == 18000 +# include "usbdrvasm18-crc.inc" +# else +# error "USB_CFG_CLOCK_KHZ is not one of the supported crc-rates!" +# endif +#else /* USB_CFG_CHECK_CRC */ +# if USB_CFG_CLOCK_KHZ == 12000 +# include "usbdrvasm12.inc" +# elif USB_CFG_CLOCK_KHZ == 12800 +# include "usbdrvasm128.inc" +# elif USB_CFG_CLOCK_KHZ == 15000 +# include "usbdrvasm15.inc" +# elif USB_CFG_CLOCK_KHZ == 16000 +# include "usbdrvasm16.inc" +# elif USB_CFG_CLOCK_KHZ == 16500 +# include "usbdrvasm165.inc" +# elif USB_CFG_CLOCK_KHZ == 20000 +# include "usbdrvasm20.inc" +# else +# error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!" +# endif +#endif /* USB_CFG_CHECK_CRC */ diff --git a/protocol/vusb/usbdrv/usbdrvasm.asm b/protocol/vusb/usbdrv/usbdrvasm.asm new file mode 100644 index 000000000..9cc4e4d73 --- /dev/null +++ b/protocol/vusb/usbdrv/usbdrvasm.asm @@ -0,0 +1,21 @@ +/* Name: usbdrvasm.asm + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2006-03-01 + * Tabsize: 4 + * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id$ + */ + +/* +General Description: +The IAR compiler/assembler system prefers assembler files with file extension +".asm". We simply provide this file as an alias for usbdrvasm.S. + +Thanks to Oleg Semyonov for his help with the IAR tools port! +*/ + +#include "usbdrvasm.S" + +end diff --git a/protocol/vusb/usbdrv/usbdrvasm12.inc b/protocol/vusb/usbdrv/usbdrvasm12.inc new file mode 100644 index 000000000..c1167584c --- /dev/null +++ b/protocol/vusb/usbdrv/usbdrvasm12.inc @@ -0,0 +1,393 @@ +/* Name: usbdrvasm12.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2004-12-29 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbdrvasm12.inc 740 2009-04-13 18:23:31Z cs $ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 12 MHz version of the asssembler part of the USB driver. It +requires a 12 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! + + +Timing constraints according to spec (in bit times): +timing subject min max CPUcycles +--------------------------------------------------------------------------- +EOP of OUT/SETUP to sync pattern of DATA0 (both rx) 2 16 16-128 +EOP of IN to sync pattern of DATA0 (rx, then tx) 2 7.5 16-60 +DATAx (rx) to ACK/NAK/STALL (tx) 2 7.5 16-60 +*/ + +;Software-receiver engine. Strict timing! Don't change unless you can preserve timing! +;interrupt response time: 4 cycles + insn running = 7 max if interrupts always enabled +;max allowable interrupt latency: 34 cycles -> max 25 cycles interrupt disable +;max stack usage: [ret(2), YL, SREG, YH, shift, x1, x2, x3, cnt, x4] = 11 bytes +;Numbers in brackets are maximum cycles since SOF. +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG [sofError], YH, shift, x1, x2, x3, cnt + push YL ;2 [35] push only what is necessary to sync with edge ASAP + in YL, SREG ;1 [37] + push YL ;2 [39] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of 1/4 bit which meets the spec. + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push YH ;2 [2] + lds YL, usbInputBufOffset;2 [4] + clr YH ;1 [5] + subi YL, lo8(-(usbRxBuf));1 [6] + sbci YH, hi8(-(usbRxBuf));1 [7] + + sbis USBIN, USBMINUS ;1 [8] we want two bits K [sample 1 cycle too early] + rjmp haveTwoBitsK ;2 [10] + pop YH ;2 [11] undo the push from before + rjmp waitForK ;2 [13] this was not the end of sync, retry +haveTwoBitsK: +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- + push shift ;2 [16] + push x1 ;2 [12] + push x2 ;2 [14] + + in x1, USBIN ;1 [17] <-- sample bit 0 + ldi shift, 0xff ;1 [18] + bst x1, USBMINUS ;1 [19] + bld shift, 0 ;1 [20] + push x3 ;2 [22] + push cnt ;2 [24] + + in x2, USBIN ;1 [25] <-- sample bit 1 + ser x3 ;1 [26] [inserted init instruction] + eor x1, x2 ;1 [27] + bst x1, USBMINUS ;1 [28] + bld shift, 1 ;1 [29] + ldi cnt, USB_BUFSIZE;1 [30] [inserted init instruction] + rjmp rxbit2 ;2 [32] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- + +unstuff0: ;1 (branch taken) + andi x3, ~0x01 ;1 [15] + mov x1, x2 ;1 [16] x2 contains last sampled (stuffed) bit + in x2, USBIN ;1 [17] <-- sample bit 1 again + ori shift, 0x01 ;1 [18] + rjmp didUnstuff0 ;2 [20] + +unstuff1: ;1 (branch taken) + mov x2, x1 ;1 [21] x1 contains last sampled (stuffed) bit + andi x3, ~0x02 ;1 [22] + ori shift, 0x02 ;1 [23] + nop ;1 [24] + in x1, USBIN ;1 [25] <-- sample bit 2 again + rjmp didUnstuff1 ;2 [27] + +unstuff2: ;1 (branch taken) + andi x3, ~0x04 ;1 [29] + ori shift, 0x04 ;1 [30] + mov x1, x2 ;1 [31] x2 contains last sampled (stuffed) bit + nop ;1 [32] + in x2, USBIN ;1 [33] <-- sample bit 3 + rjmp didUnstuff2 ;2 [35] + +unstuff3: ;1 (branch taken) + in x2, USBIN ;1 [34] <-- sample stuffed bit 3 [one cycle too late] + andi x3, ~0x08 ;1 [35] + ori shift, 0x08 ;1 [36] + rjmp didUnstuff3 ;2 [38] + +unstuff4: ;1 (branch taken) + andi x3, ~0x10 ;1 [40] + in x1, USBIN ;1 [41] <-- sample stuffed bit 4 + ori shift, 0x10 ;1 [42] + rjmp didUnstuff4 ;2 [44] + +unstuff5: ;1 (branch taken) + andi x3, ~0x20 ;1 [48] + in x2, USBIN ;1 [49] <-- sample stuffed bit 5 + ori shift, 0x20 ;1 [50] + rjmp didUnstuff5 ;2 [52] + +unstuff6: ;1 (branch taken) + andi x3, ~0x40 ;1 [56] + in x1, USBIN ;1 [57] <-- sample stuffed bit 6 + ori shift, 0x40 ;1 [58] + rjmp didUnstuff6 ;2 [60] + +; extra jobs done during bit interval: +; bit 0: store, clear [SE0 is unreliable here due to bit dribbling in hubs] +; bit 1: se0 check +; bit 2: overflow check +; bit 3: recovery from delay [bit 0 tasks took too long] +; bit 4: none +; bit 5: none +; bit 6: none +; bit 7: jump, eor +rxLoop: + eor x3, shift ;1 [0] reconstruct: x3 is 0 at bit locations we changed, 1 at others + in x1, USBIN ;1 [1] <-- sample bit 0 + st y+, x3 ;2 [3] store data + ser x3 ;1 [4] + nop ;1 [5] + eor x2, x1 ;1 [6] + bst x2, USBMINUS;1 [7] + bld shift, 0 ;1 [8] + in x2, USBIN ;1 [9] <-- sample bit 1 (or possibly bit 0 stuffed) + andi x2, USBMASK ;1 [10] + breq se0 ;1 [11] SE0 check for bit 1 + andi shift, 0xf9 ;1 [12] +didUnstuff0: + breq unstuff0 ;1 [13] + eor x1, x2 ;1 [14] + bst x1, USBMINUS;1 [15] + bld shift, 1 ;1 [16] +rxbit2: + in x1, USBIN ;1 [17] <-- sample bit 2 (or possibly bit 1 stuffed) + andi shift, 0xf3 ;1 [18] + breq unstuff1 ;1 [19] do remaining work for bit 1 +didUnstuff1: + subi cnt, 1 ;1 [20] + brcs overflow ;1 [21] loop control + eor x2, x1 ;1 [22] + bst x2, USBMINUS;1 [23] + bld shift, 2 ;1 [24] + in x2, USBIN ;1 [25] <-- sample bit 3 (or possibly bit 2 stuffed) + andi shift, 0xe7 ;1 [26] + breq unstuff2 ;1 [27] +didUnstuff2: + eor x1, x2 ;1 [28] + bst x1, USBMINUS;1 [29] + bld shift, 3 ;1 [30] +didUnstuff3: + andi shift, 0xcf ;1 [31] + breq unstuff3 ;1 [32] + in x1, USBIN ;1 [33] <-- sample bit 4 + eor x2, x1 ;1 [34] + bst x2, USBMINUS;1 [35] + bld shift, 4 ;1 [36] +didUnstuff4: + andi shift, 0x9f ;1 [37] + breq unstuff4 ;1 [38] + nop2 ;2 [40] + in x2, USBIN ;1 [41] <-- sample bit 5 + eor x1, x2 ;1 [42] + bst x1, USBMINUS;1 [43] + bld shift, 5 ;1 [44] +didUnstuff5: + andi shift, 0x3f ;1 [45] + breq unstuff5 ;1 [46] + nop2 ;2 [48] + in x1, USBIN ;1 [49] <-- sample bit 6 + eor x2, x1 ;1 [50] + bst x2, USBMINUS;1 [51] + bld shift, 6 ;1 [52] +didUnstuff6: + cpi shift, 0x02 ;1 [53] + brlo unstuff6 ;1 [54] + nop2 ;2 [56] + in x2, USBIN ;1 [57] <-- sample bit 7 + eor x1, x2 ;1 [58] + bst x1, USBMINUS;1 [59] + bld shift, 7 ;1 [60] +didUnstuff7: + cpi shift, 0x04 ;1 [61] + brsh rxLoop ;2 [63] loop control +unstuff7: + andi x3, ~0x80 ;1 [63] + ori shift, 0x80 ;1 [64] + in x2, USBIN ;1 [65] <-- sample stuffed bit 7 + nop ;1 [66] + rjmp didUnstuff7 ;2 [68] + +macro POP_STANDARD ; 12 cycles + pop cnt + pop x3 + pop x2 + pop x1 + pop shift + pop YH + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +;---------------------------------------------------------------------------- +; Transmitting data +;---------------------------------------------------------------------------- + +txByteLoop: +txBitloop: +stuffN1Delay: ; [03] + ror shift ;[-5] [11] [59] + brcc doExorN1 ;[-4] [60] + subi x4, 1 ;[-3] + brne commonN1 ;[-2] + lsl shift ;[-1] compensate ror after rjmp stuffDelay + nop ;[00] stuffing consists of just waiting 8 cycles + rjmp stuffN1Delay ;[01] after ror, C bit is reliably clear + +sendNakAndReti: ;0 [-19] 19 cycles until SOP + ldi x3, USBPID_NAK ;1 [-18] + rjmp usbSendX3 ;2 [-16] +sendAckAndReti: ;0 [-19] 19 cycles until SOP + ldi x3, USBPID_ACK ;1 [-18] + rjmp usbSendX3 ;2 [-16] +sendCntAndReti: ;0 [-17] 17 cycles until SOP + mov x3, cnt ;1 [-16] +usbSendX3: ;0 [-16] + ldi YL, 20 ;1 [-15] 'x3' is R20 + ldi YH, 0 ;1 [-14] + ldi cnt, 2 ;1 [-13] +; rjmp usbSendAndReti fallthrough + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) or USBOUT = 0x01 +; K = (D+ = 1), (D- = 0) or USBOUT = 0x02 +; Spec allows 7.5 bit times from EOP to SOP for replies (= 60 cycles) + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte +;uses: x1...x2, x4, shift, cnt, Y [x1 = mirror USBOUT, x2 = USBMASK, x4 = bitstuff cnt] +;Numbers in brackets are time since first bit of sync pattern is sent (start of instruction) +usbSendAndReti: + in x2, USBDDR ;[-12] 12 cycles until SOP + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS ;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + out USBDDR, x2 ;[-8] <--- acquire bus + in x1, USBOUT ;[-7] port mirror for tx loop + ldi shift, 0x40 ;[-6] sync byte is first byte sent (we enter loop after ror) + ldi x2, USBMASK ;[-5] + push x4 ;[-4] +doExorN1: + eor x1, x2 ;[-2] [06] [62] + ldi x4, 6 ;[-1] [07] [63] +commonN1: +stuffN2Delay: + out USBOUT, x1 ;[00] [08] [64] <--- set bit + ror shift ;[01] + brcc doExorN2 ;[02] + subi x4, 1 ;[03] + brne commonN2 ;[04] + lsl shift ;[05] compensate ror after rjmp stuffDelay + rjmp stuffN2Delay ;[06] after ror, C bit is reliably clear +doExorN2: + eor x1, x2 ;[04] [12] + ldi x4, 6 ;[05] [13] +commonN2: + nop ;[06] [14] + subi cnt, 171 ;[07] [15] trick: (3 * 171) & 0xff = 1 + out USBOUT, x1 ;[08] [16] <--- set bit + brcs txBitloop ;[09] [25] [41] + +stuff6Delay: + ror shift ;[42] [50] + brcc doExor6 ;[43] + subi x4, 1 ;[44] + brne common6 ;[45] + lsl shift ;[46] compensate ror after rjmp stuffDelay + nop ;[47] stuffing consists of just waiting 8 cycles + rjmp stuff6Delay ;[48] after ror, C bit is reliably clear +doExor6: + eor x1, x2 ;[45] [53] + ldi x4, 6 ;[46] +common6: +stuff7Delay: + ror shift ;[47] [55] + out USBOUT, x1 ;[48] <--- set bit + brcc doExor7 ;[49] + subi x4, 1 ;[50] + brne common7 ;[51] + lsl shift ;[52] compensate ror after rjmp stuffDelay + rjmp stuff7Delay ;[53] after ror, C bit is reliably clear +doExor7: + eor x1, x2 ;[51] [59] + ldi x4, 6 ;[52] +common7: + ld shift, y+ ;[53] + tst cnt ;[55] + out USBOUT, x1 ;[56] <--- set bit + brne txByteLoop ;[57] + +;make SE0: + cbr x1, USBMASK ;[58] prepare SE0 [spec says EOP may be 15 to 18 cycles] + lds x2, usbNewDeviceAddr;[59] + lsl x2 ;[61] we compare with left shifted address + subi YL, 2 + 20 ;[62] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[63] + out USBOUT, x1 ;[00] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[01] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< 12.5625 MHz +max frequency: 69.286 cycles for 8 bit -> 12.99 MHz +nominal frequency: 12.77 MHz ( = sqrt(min * max)) + +sampling positions: (next even number in range [+/- 0.5]) +cycle index range: 0 ... 66 +bits: +.5, 8.875, 17.25, 25.625, 34, 42.375, 50.75, 59.125 +[0/1], [9], [17], [25/+26], [34], [+42/43], [51], [59] + +bit number: 0 1 2 3 4 5 6 7 +spare cycles 1 2 1 2 1 1 1 0 + +operations to perform: duration cycle + ---------------- + eor fix, shift 1 -> 00 + andi phase, USBMASK 1 -> 08 + breq se0 1 -> 16 (moved to 11) + st y+, data 2 -> 24, 25 + mov data, fix 1 -> 33 + ser data 1 -> 41 + subi cnt, 1 1 -> 49 + brcs overflow 1 -> 50 + +layout of samples and operations: +[##] = sample bit +<##> = sample phase +*##* = operation + +0: *00* [01] 02 03 04 <05> 06 07 +1: *08* [09] 10 11 12 <13> 14 15 *16* +2: [17] 18 19 20 <21> 22 23 +3: *24* *25* [26] 27 28 29 <30> 31 32 +4: *33* [34] 35 36 37 <38> 39 40 +5: *41* [42] 43 44 45 <46> 47 48 +6: *49* *50* [51] 52 53 54 <55> 56 57 58 +7: [59] 60 61 62 <63> 64 65 66 +*****************************************************************************/ + +/* we prefer positive expressions (do if condition) instead of negative + * (skip if condition), therefore use defines for skip instructions: + */ +#define ifioclr sbis +#define ifioset sbic +#define ifrclr sbrs +#define ifrset sbrc + +/* The registers "fix" and "data" swap their meaning during the loop. Use + * defines to keep their name constant. + */ +#define fix x2 +#define data x1 +#undef phase /* phase has a default definition to x4 */ +#define phase x3 + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG [sofError], YH, shift, x1, x2, x3, cnt, r0 + push YL ;2 push only what is necessary to sync with edge ASAP + in YL, SREG ;1 + push YL ;2 +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of 1/4 bit which meets the spec. + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS ;[0] + rjmp foundK ;[1] +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError + +foundK: +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push YH ;[2] + lds YL, usbInputBufOffset;[4] + clr YH ;[6] + subi YL, lo8(-(usbRxBuf));[7] + sbci YH, hi8(-(usbRxBuf));[8] + + sbis USBIN, USBMINUS ;[9] we want two bits K [we want to sample at 8 + 4 - 1.5 = 10.5] + rjmp haveTwoBitsK ;[10] + pop YH ;[11] undo the push from before + rjmp waitForK ;[13] this was not the end of sync, retry +haveTwoBitsK: +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +#define fix x2 +#define data x1 + + push shift ;[12] + push x1 ;[14] + push x2 ;[16] + ldi shift, 0x80 ;[18] prevent bit-unstuffing but init low bits to 0 + ifioset USBIN, USBMINUS ;[19] [01] <--- bit 0 [10.5 + 8 = 18.5] + ori shift, 1<<0 ;[02] + push x3 ;[03] + push cnt ;[05] + push r0 ;[07] + ifioset USBIN, USBMINUS ;[09] <--- bit 1 + ori shift, 1<<1 ;[10] + ser fix ;[11] + ldi cnt, USB_BUFSIZE ;[12] + mov data, shift ;[13] + lsl shift ;[14] + nop2 ;[15] + ifioset USBIN, USBMINUS ;[17] <--- bit 2 + ori data, 3<<2 ;[18] store in bit 2 AND bit 3 + eor shift, data ;[19] do nrzi decoding + andi data, 1<<3 ;[20] + in phase, USBIN ;[21] <- phase + brne jumpToEntryAfterSet ;[22] if USBMINS at bit 3 was 1 + nop ;[23] + rjmp entryAfterClr ;[24] +jumpToEntryAfterSet: + rjmp entryAfterSet ;[24] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- +#undef fix +#define fix x1 +#undef data +#define data x2 + +bit7IsSet: + ifrclr phase, USBMINUS ;[62] check phase only if D- changed + lpm ;[63] + in phase, USBIN ;[64] <- phase (one cycle too late) + ori shift, 1 << 7 ;[65] + nop ;[66] +;;;;rjmp bit0AfterSet ; -> [00] == [67] moved block up to save jump +bit0AfterSet: + eor fix, shift ;[00] +#undef fix +#define fix x2 +#undef data +#define data x1 /* we now have result in data, fix is reset to 0xff */ + ifioclr USBIN, USBMINUS ;[01] <--- sample 0 + rjmp bit0IsClr ;[02] + andi shift, ~(7 << 0) ;[03] + breq unstuff0s ;[04] + in phase, USBIN ;[05] <- phase + rjmp bit1AfterSet ;[06] +unstuff0s: + in phase, USBIN ;[06] <- phase (one cycle too late) + andi fix, ~(1 << 0) ;[07] + ifioclr USBIN, USBMINUS ;[00] + ifioset USBIN, USBPLUS ;[01] + rjmp bit0IsClr ;[02] executed if first expr false or second true +se0AndStore: ; executed only if both bits 0 + st y+, x1 ;[15/17] cycles after start of byte + rjmp se0 ;[17/19] + +bit0IsClr: + ifrset phase, USBMINUS ;[04] check phase only if D- changed + lpm ;[05] + in phase, USBIN ;[06] <- phase (one cycle too late) + ori shift, 1 << 0 ;[07] +bit1AfterClr: + andi phase, USBMASK ;[08] + ifioset USBIN, USBMINUS ;[09] <--- sample 1 + rjmp bit1IsSet ;[10] + breq se0AndStore ;[11] if D- was 0 in bits 0 AND 1 and D+ was 0 in between, we have SE0 + andi shift, ~(7 << 1) ;[12] + in phase, USBIN ;[13] <- phase + breq unstuff1c ;[14] + rjmp bit2AfterClr ;[15] +unstuff1c: + andi fix, ~(1 << 1) ;[16] + nop2 ;[08] + nop2 ;[10] +bit1IsSet: + ifrclr phase, USBMINUS ;[12] check phase only if D- changed + lpm ;[13] + in phase, USBIN ;[14] <- phase (one cycle too late) + ori shift, 1 << 1 ;[15] + nop ;[16] +bit2AfterSet: + ifioclr USBIN, USBMINUS ;[17] <--- sample 2 + rjmp bit2IsClr ;[18] + andi shift, ~(7 << 2) ;[19] + breq unstuff2s ;[20] + in phase, USBIN ;[21] <- phase + rjmp bit3AfterSet ;[22] +unstuff2s: + in phase, USBIN ;[22] <- phase (one cycle too late) + andi fix, ~(1 << 2) ;[23] + nop2 ;[16] + nop2 ;[18] +bit2IsClr: + ifrset phase, USBMINUS ;[20] check phase only if D- changed + lpm ;[21] + in phase, USBIN ;[22] <- phase (one cycle too late) + ori shift, 1 << 2 ;[23] +bit3AfterClr: + st y+, data ;[24] +entryAfterClr: + ifioset USBIN, USBMINUS ;[26] <--- sample 3 + rjmp bit3IsSet ;[27] + andi shift, ~(7 << 3) ;[28] + breq unstuff3c ;[29] + in phase, USBIN ;[30] <- phase + rjmp bit4AfterClr ;[31] +unstuff3c: + in phase, USBIN ;[31] <- phase (one cycle too late) + andi fix, ~(1 << 3) ;[32] + nop2 ;[25] + nop2 ;[27] +bit3IsSet: + ifrclr phase, USBMINUS ;[29] check phase only if D- changed + lpm ;[30] + in phase, USBIN ;[31] <- phase (one cycle too late) + ori shift, 1 << 3 ;[32] +bit4AfterSet: + mov data, fix ;[33] undo this move by swapping defines +#undef fix +#define fix x1 +#undef data +#define data x2 + ifioclr USBIN, USBMINUS ;[34] <--- sample 4 + rjmp bit4IsClr ;[35] + andi shift, ~(7 << 4) ;[36] + breq unstuff4s ;[37] + in phase, USBIN ;[38] <- phase + rjmp bit5AfterSet ;[39] +unstuff4s: + in phase, USBIN ;[39] <- phase (one cycle too late) + andi fix, ~(1 << 4) ;[40] + nop2 ;[33] + nop2 ;[35] +bit4IsClr: + ifrset phase, USBMINUS ;[37] check phase only if D- changed + lpm ;[38] + in phase, USBIN ;[39] <- phase (one cycle too late) + ori shift, 1 << 4 ;[40] +bit5AfterClr: + ser data ;[41] + ifioset USBIN, USBMINUS ;[42] <--- sample 5 + rjmp bit5IsSet ;[43] + andi shift, ~(7 << 5) ;[44] + breq unstuff5c ;[45] + in phase, USBIN ;[46] <- phase + rjmp bit6AfterClr ;[47] +unstuff5c: + in phase, USBIN ;[47] <- phase (one cycle too late) + andi fix, ~(1 << 5) ;[48] + nop2 ;[41] + nop2 ;[43] +bit5IsSet: + ifrclr phase, USBMINUS ;[45] check phase only if D- changed + lpm ;[46] + in phase, USBIN ;[47] <- phase (one cycle too late) + ori shift, 1 << 5 ;[48] +bit6AfterSet: + subi cnt, 1 ;[49] + brcs jumpToOverflow ;[50] + ifioclr USBIN, USBMINUS ;[51] <--- sample 6 + rjmp bit6IsClr ;[52] + andi shift, ~(3 << 6) ;[53] + cpi shift, 2 ;[54] + in phase, USBIN ;[55] <- phase + brlt unstuff6s ;[56] + rjmp bit7AfterSet ;[57] + +jumpToOverflow: + rjmp overflow + +unstuff6s: + andi fix, ~(1 << 6) ;[50] + lpm ;[51] +bit6IsClr: + ifrset phase, USBMINUS ;[54] check phase only if D- changed + lpm ;[55] + in phase, USBIN ;[56] <- phase (one cycle too late) + ori shift, 1 << 6 ;[57] + nop ;[58] +bit7AfterClr: + ifioset USBIN, USBMINUS ;[59] <--- sample 7 + rjmp bit7IsSet ;[60] + andi shift, ~(1 << 7) ;[61] + cpi shift, 4 ;[62] + in phase, USBIN ;[63] <- phase + brlt unstuff7c ;[64] + rjmp bit0AfterClr ;[65] -> [00] == [67] +unstuff7c: + andi fix, ~(1 << 7) ;[58] + nop ;[59] + rjmp bit7IsSet ;[60] + +bit7IsClr: + ifrset phase, USBMINUS ;[62] check phase only if D- changed + lpm ;[63] + in phase, USBIN ;[64] <- phase (one cycle too late) + ori shift, 1 << 7 ;[65] + nop ;[66] +;;;;rjmp bit0AfterClr ; -> [00] == [67] moved block up to save jump +bit0AfterClr: + eor fix, shift ;[00] +#undef fix +#define fix x2 +#undef data +#define data x1 /* we now have result in data, fix is reset to 0xff */ + ifioset USBIN, USBMINUS ;[01] <--- sample 0 + rjmp bit0IsSet ;[02] + andi shift, ~(7 << 0) ;[03] + breq unstuff0c ;[04] + in phase, USBIN ;[05] <- phase + rjmp bit1AfterClr ;[06] +unstuff0c: + in phase, USBIN ;[06] <- phase (one cycle too late) + andi fix, ~(1 << 0) ;[07] + ifioclr USBIN, USBMINUS ;[00] + ifioset USBIN, USBPLUS ;[01] + rjmp bit0IsSet ;[02] executed if first expr false or second true + rjmp se0AndStore ;[03] executed only if both bits 0 +bit0IsSet: + ifrclr phase, USBMINUS ;[04] check phase only if D- changed + lpm ;[05] + in phase, USBIN ;[06] <- phase (one cycle too late) + ori shift, 1 << 0 ;[07] +bit1AfterSet: + andi shift, ~(7 << 1) ;[08] compensated by "ori shift, 1<<1" if bit1IsClr + ifioclr USBIN, USBMINUS ;[09] <--- sample 1 + rjmp bit1IsClr ;[10] + breq unstuff1s ;[11] + nop2 ;[12] do not check for SE0 if bit 0 was 1 + in phase, USBIN ;[14] <- phase (one cycle too late) + rjmp bit2AfterSet ;[15] +unstuff1s: + in phase, USBIN ;[13] <- phase + andi fix, ~(1 << 1) ;[14] + lpm ;[07] + nop2 ;[10] +bit1IsClr: + ifrset phase, USBMINUS ;[12] check phase only if D- changed + lpm ;[13] + in phase, USBIN ;[14] <- phase (one cycle too late) + ori shift, 1 << 1 ;[15] + nop ;[16] +bit2AfterClr: + ifioset USBIN, USBMINUS ;[17] <--- sample 2 + rjmp bit2IsSet ;[18] + andi shift, ~(7 << 2) ;[19] + breq unstuff2c ;[20] + in phase, USBIN ;[21] <- phase + rjmp bit3AfterClr ;[22] +unstuff2c: + in phase, USBIN ;[22] <- phase (one cycle too late) + andi fix, ~(1 << 2) ;[23] + nop2 ;[16] + nop2 ;[18] +bit2IsSet: + ifrclr phase, USBMINUS ;[20] check phase only if D- changed + lpm ;[21] + in phase, USBIN ;[22] <- phase (one cycle too late) + ori shift, 1 << 2 ;[23] +bit3AfterSet: + st y+, data ;[24] +entryAfterSet: + ifioclr USBIN, USBMINUS ;[26] <--- sample 3 + rjmp bit3IsClr ;[27] + andi shift, ~(7 << 3) ;[28] + breq unstuff3s ;[29] + in phase, USBIN ;[30] <- phase + rjmp bit4AfterSet ;[31] +unstuff3s: + in phase, USBIN ;[31] <- phase (one cycle too late) + andi fix, ~(1 << 3) ;[32] + nop2 ;[25] + nop2 ;[27] +bit3IsClr: + ifrset phase, USBMINUS ;[29] check phase only if D- changed + lpm ;[30] + in phase, USBIN ;[31] <- phase (one cycle too late) + ori shift, 1 << 3 ;[32] +bit4AfterClr: + mov data, fix ;[33] undo this move by swapping defines +#undef fix +#define fix x1 +#undef data +#define data x2 + ifioset USBIN, USBMINUS ;[34] <--- sample 4 + rjmp bit4IsSet ;[35] + andi shift, ~(7 << 4) ;[36] + breq unstuff4c ;[37] + in phase, USBIN ;[38] <- phase + rjmp bit5AfterClr ;[39] +unstuff4c: + in phase, USBIN ;[39] <- phase (one cycle too late) + andi fix, ~(1 << 4) ;[40] + nop2 ;[33] + nop2 ;[35] +bit4IsSet: + ifrclr phase, USBMINUS ;[37] check phase only if D- changed + lpm ;[38] + in phase, USBIN ;[39] <- phase (one cycle too late) + ori shift, 1 << 4 ;[40] +bit5AfterSet: + ser data ;[41] + ifioclr USBIN, USBMINUS ;[42] <--- sample 5 + rjmp bit5IsClr ;[43] + andi shift, ~(7 << 5) ;[44] + breq unstuff5s ;[45] + in phase, USBIN ;[46] <- phase + rjmp bit6AfterSet ;[47] +unstuff5s: + in phase, USBIN ;[47] <- phase (one cycle too late) + andi fix, ~(1 << 5) ;[48] + nop2 ;[41] + nop2 ;[43] +bit5IsClr: + ifrset phase, USBMINUS ;[45] check phase only if D- changed + lpm ;[46] + in phase, USBIN ;[47] <- phase (one cycle too late) + ori shift, 1 << 5 ;[48] +bit6AfterClr: + subi cnt, 1 ;[49] + brcs overflow ;[50] + ifioset USBIN, USBMINUS ;[51] <--- sample 6 + rjmp bit6IsSet ;[52] + andi shift, ~(3 << 6) ;[53] + cpi shift, 2 ;[54] + in phase, USBIN ;[55] <- phase + brlt unstuff6c ;[56] + rjmp bit7AfterClr ;[57] +unstuff6c: + andi fix, ~(1 << 6) ;[50] + lpm ;[51] +bit6IsSet: + ifrclr phase, USBMINUS ;[54] check phase only if D- changed + lpm ;[55] + in phase, USBIN ;[56] <- phase (one cycle too late) + ori shift, 1 << 6 ;[57] +bit7AfterSet: + ifioclr USBIN, USBMINUS ;[59] <--- sample 7 + rjmp bit7IsClr ;[60] + andi shift, ~(1 << 7) ;[61] + cpi shift, 4 ;[62] + in phase, USBIN ;[63] <- phase + brlt unstuff7s ;[64] + rjmp bit0AfterSet ;[65] -> [00] == [67] +unstuff7s: + andi fix, ~(1 << 7) ;[58] + nop ;[59] + rjmp bit7IsClr ;[60] + +macro POP_STANDARD ; 14 cycles + pop r0 + pop cnt + pop x3 + pop x2 + pop x1 + pop shift + pop YH + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +;---------------------------------------------------------------------------- +; Transmitting data +;---------------------------------------------------------------------------- + +txByteLoop: +txBitloop: +stuffN1Delay: ; [03] + ror shift ;[-5] [11] [63] + brcc doExorN1 ;[-4] [64] + subi x3, 1 ;[-3] + brne commonN1 ;[-2] + lsl shift ;[-1] compensate ror after rjmp stuffDelay + nop ;[00] stuffing consists of just waiting 8 cycles + rjmp stuffN1Delay ;[01] after ror, C bit is reliably clear + +sendNakAndReti: + ldi cnt, USBPID_NAK ;[-19] + rjmp sendCntAndReti ;[-18] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov r0, cnt ;[-16] + ldi YL, 0 ;[-15] R0 address is 0 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) or USBOUT = 0x01 +; K = (D+ = 1), (D- = 0) or USBOUT = 0x02 +; Spec allows 7.5 bit times from EOP to SOP for replies (= 60 cycles) + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte +;uses: x1...x3, shift, cnt, Y [x1 = mirror USBOUT, x2 = USBMASK, x3 = bitstuff cnt] +;Numbers in brackets are time since first bit of sync pattern is sent (start of instruction) +usbSendAndReti: + in x2, USBDDR ;[-10] 10 cycles until SOP + ori x2, USBMASK ;[-9] + sbi USBOUT, USBMINUS ;[-8] prepare idle state; D+ and D- must have been 0 (no pullups) + out USBDDR, x2 ;[-6] <--- acquire bus + in x1, USBOUT ;[-5] port mirror for tx loop + ldi shift, 0x40 ;[-4] sync byte is first byte sent (we enter loop after ror) + ldi x2, USBMASK ;[-3] +doExorN1: + eor x1, x2 ;[-2] [06] [62] + ldi x3, 6 ;[-1] [07] [63] +commonN1: +stuffN2Delay: + out USBOUT, x1 ;[00] [08] [64] <--- set bit + ror shift ;[01] + brcc doExorN2 ;[02] + subi x3, 1 ;[03] + brne commonN2 ;[04] + lsl shift ;[05] compensate ror after rjmp stuffDelay + rjmp stuffN2Delay ;[06] after ror, C bit is reliably clear +doExorN2: + eor x1, x2 ;[04] [12] + ldi x3, 6 ;[05] [13] +commonN2: + nop2 ;[06] [14] + subi cnt, 171 ;[08] [16] trick: (3 * 171) & 0xff = 1 + out USBOUT, x1 ;[09] [17] <--- set bit + brcs txBitloop ;[10] [27] [44] + +stuff6Delay: + ror shift ;[45] [53] + brcc doExor6 ;[46] + subi x3, 1 ;[47] + brne common6 ;[48] + lsl shift ;[49] compensate ror after rjmp stuffDelay + nop ;[50] stuffing consists of just waiting 8 cycles + rjmp stuff6Delay ;[51] after ror, C bit is reliably clear +doExor6: + eor x1, x2 ;[48] [56] + ldi x3, 6 ;[49] +common6: +stuff7Delay: + ror shift ;[50] [58] + out USBOUT, x1 ;[51] <--- set bit + brcc doExor7 ;[52] + subi x3, 1 ;[53] + brne common7 ;[54] + lsl shift ;[55] compensate ror after rjmp stuffDelay + rjmp stuff7Delay ;[56] after ror, C bit is reliably clear +doExor7: + eor x1, x2 ;[54] [62] + ldi x3, 6 ;[55] +common7: + ld shift, y+ ;[56] + nop ;[58] + tst cnt ;[59] + out USBOUT, x1 ;[60] [00]<--- set bit + brne txByteLoop ;[61] [01] +;make SE0: + cbr x1, USBMASK ;[02] prepare SE0 [spec says EOP may be 15 to 18 cycles] + lds x2, usbNewDeviceAddr;[03] + lsl x2 ;[05] we compare with left shifted address + subi YL, 2 + 0 ;[06] Only assign address on data packets, not ACK/NAK in r0 + sbci YH, 0 ;[07] + out USBOUT, x1 ;[00] <-- out SE0 -- from now 2 bits = 16 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[01] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< 0) + echo "$s\n"; + } +} + +function printBit($isAfterSet, $bitNum) +{ + ob_start(); + if($isAfterSet){ +?> + ifioclr USBIN, USBMINUS ;[00] <--- sample + rjmp bit#IsClr ;[01] + andi shift, ~(7 << #) ;[02] + breq unstuff#s ;[03] + in phase, USBIN ;[04] <- phase + rjmp bit@AfterSet ;[05] +unstuff#s: + in phase, USBIN ;[05] <- phase (one cycle too late) + andi fix, ~(1 << #) ;[06] + nop2 ;[-1] + nop2 ;[01] +bit#IsClr: + ifrset phase, USBMINUS ;[03] check phase only if D- changed + lpm ;[04] + in phase, USBIN ;[05] <- phase (one cycle too late) + ori shift, 1 << # ;[06] + + ifioset USBIN, USBMINUS ;[00] <--- sample + rjmp bit#IsSet ;[01] + andi shift, ~(7 << #) ;[02] + breq unstuff#c ;[03] + in phase, USBIN ;[04] <- phase + rjmp bit@AfterClr ;[05] +unstuff#c: + in phase, USBIN ;[05] <- phase (one cycle too late) + andi fix, ~(1 << #) ;[06] + nop2 ;[-1] + nop2 ;[01] +bit#IsSet: + ifrclr phase, USBMINUS ;[03] check phase only if D- changed + lpm ;[04] + in phase, USBIN ;[05] <- phase (one cycle too late) + ori shift, 1 << # ;[06] + +*****************************************************************************/ diff --git a/protocol/vusb/usbdrv/usbdrvasm15.inc b/protocol/vusb/usbdrv/usbdrvasm15.inc new file mode 100644 index 000000000..401b7f8ff --- /dev/null +++ b/protocol/vusb/usbdrv/usbdrvasm15.inc @@ -0,0 +1,423 @@ +/* Name: usbdrvasm15.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: contributed by V. Bosch + * Creation Date: 2007-08-06 + * Tabsize: 4 + * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id: usbdrvasm15.inc 740 2009-04-13 18:23:31Z cs $ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 15 MHz version of the asssembler part of the USB driver. It +requires a 15 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! +*/ + +;max stack usage: [ret(2), YL, SREG, YH, bitcnt, shift, x1, x2, x3, x4, cnt] = 12 bytes +;nominal frequency: 15 MHz -> 10.0 cycles per bit, 80.0 cycles per byte +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts + +;---------------------------------------------------------------------------- +; order of registers pushed: +; YL, SREG [sofError] YH, shift, x1, x2, x3, bitcnt, cnt, x4 +;---------------------------------------------------------------------------- +USB_INTR_VECTOR: + push YL ;2 push only what is necessary to sync with edge ASAP + in YL, SREG ;1 + push YL ;2 +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +; +; sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +; sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +;------------------------------------------------------------------------------- +; The following code results in a sampling window of < 1/4 bit +; which meets the spec. +;------------------------------------------------------------------------------- +waitForK: ;- + sbis USBIN, USBMINUS ;1 [00] <-- sample + rjmp foundK ;2 [01] + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK + sbis USBIN, USBMINUS ; <-- sample + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +;------------------------------------------------------------------------------ +; {3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for +; center sampling] +; we have 1 bit time for setup purposes, then sample again. +; Numbers in brackets are cycles from center of first sync (double K) +; bit after the instruction +;------------------------------------------------------------------------------ +foundK: ;- [02] + lds YL, usbInputBufOffset;2 [03+04] tx loop + push YH ;2 [05+06] + clr YH ;1 [07] + subi YL, lo8(-(usbRxBuf)) ;1 [08] [rx loop init] + sbci YH, hi8(-(usbRxBuf)) ;1 [09] [rx loop init] + push shift ;2 [10+11] + ser shift ;1 [12] + sbis USBIN, USBMINUS ;1 [-1] [13] <--sample:we want two bits K (sample 1 cycle too early) + rjmp haveTwoBitsK ;2 [00] [14] + pop shift ;2 [15+16] undo the push from before + pop YH ;2 [17+18] undo the push from before + rjmp waitForK ;2 [19+20] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 20 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: ;- [01] + push x1 ;2 [02+03] + push x2 ;2 [04+05] + push x3 ;2 [06+07] + push bitcnt ;2 [08+09] + in x1, USBIN ;1 [00] [10] <-- sample bit 0 + bst x1, USBMINUS ;1 [01] + bld shift, 0 ;1 [02] + push cnt ;2 [03+04] + ldi cnt, USB_BUFSIZE ;1 [05] + push x4 ;2 [06+07] tx loop + rjmp rxLoop ;2 [08] +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- +unstuff0: ;- [07] (branch taken) + andi x3, ~0x01 ;1 [08] + mov x1, x2 ;1 [09] x2 contains last sampled (stuffed) bit + in x2, USBIN ;1 [00] [10] <-- sample bit 1 again + andi x2, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 1 + ori shift, 0x01 ;1 [03] 0b00000001 + nop ;1 [04] + rjmp didUnstuff0 ;2 [05] +;----------------------------------------------------- +unstuff1: ;- [05] (branch taken) + mov x2, x1 ;1 [06] x1 contains last sampled (stuffed) bit + andi x3, ~0x02 ;1 [07] + ori shift, 0x02 ;1 [08] 0b00000010 + nop ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 2 again + andi x1, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 2 + rjmp didUnstuff1 ;2 [03] +;----------------------------------------------------- +unstuff2: ;- [05] (branch taken) + andi x3, ~0x04 ;1 [06] + ori shift, 0x04 ;1 [07] 0b00000100 + mov x1, x2 ;1 [08] x2 contains last sampled (stuffed) bit + nop ;1 [09] + in x2, USBIN ;1 [00] [10] <-- sample bit 3 + andi x2, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 3 + rjmp didUnstuff2 ;2 [03] +;----------------------------------------------------- +unstuff3: ;- [00] [10] (branch taken) + in x2, USBIN ;1 [01] [11] <-- sample stuffed bit 3 one cycle too late + andi x2, USBMASK ;1 [02] + breq se0Hop ;1 [03] SE0 check for stuffed bit 3 + andi x3, ~0x08 ;1 [04] + ori shift, 0x08 ;1 [05] 0b00001000 + rjmp didUnstuff3 ;2 [06] +;---------------------------------------------------------------------------- +; extra jobs done during bit interval: +; +; bit 0: store, clear [SE0 is unreliable here due to bit dribbling in hubs], +; overflow check, jump to the head of rxLoop +; bit 1: SE0 check +; bit 2: SE0 check, recovery from delay [bit 0 tasks took too long] +; bit 3: SE0 check, recovery from delay [bit 0 tasks took too long] +; bit 4: SE0 check, none +; bit 5: SE0 check, none +; bit 6: SE0 check, none +; bit 7: SE0 check, reconstruct: x3 is 0 at bit locations we changed, 1 at others +;---------------------------------------------------------------------------- +rxLoop: ;- [09] + in x2, USBIN ;1 [00] [10] <-- sample bit 1 (or possibly bit 0 stuffed) + andi x2, USBMASK ;1 [01] + brne SkipSe0Hop ;1 [02] +se0Hop: ;- [02] + rjmp se0 ;2 [03] SE0 check for bit 1 +SkipSe0Hop: ;- [03] + ser x3 ;1 [04] + andi shift, 0xf9 ;1 [05] 0b11111001 + breq unstuff0 ;1 [06] +didUnstuff0: ;- [06] + eor x1, x2 ;1 [07] + bst x1, USBMINUS ;1 [08] + bld shift, 1 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 2 (or possibly bit 1 stuffed) + andi x1, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 2 + andi shift, 0xf3 ;1 [03] 0b11110011 + breq unstuff1 ;1 [04] do remaining work for bit 1 +didUnstuff1: ;- [04] + eor x2, x1 ;1 [05] + bst x2, USBMINUS ;1 [06] + bld shift, 2 ;1 [07] + nop2 ;2 [08+09] + in x2, USBIN ;1 [00] [10] <-- sample bit 3 (or possibly bit 2 stuffed) + andi x2, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 3 + andi shift, 0xe7 ;1 [03] 0b11100111 + breq unstuff2 ;1 [04] +didUnstuff2: ;- [04] + eor x1, x2 ;1 [05] + bst x1, USBMINUS ;1 [06] + bld shift, 3 ;1 [07] +didUnstuff3: ;- [07] + andi shift, 0xcf ;1 [08] 0b11001111 + breq unstuff3 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 4 + andi x1, USBMASK ;1 [01] + breq se0Hop ;1 [02] SE0 check for bit 4 + eor x2, x1 ;1 [03] + bst x2, USBMINUS ;1 [04] + bld shift, 4 ;1 [05] +didUnstuff4: ;- [05] + andi shift, 0x9f ;1 [06] 0b10011111 + breq unstuff4 ;1 [07] + nop2 ;2 [08+09] + in x2, USBIN ;1 [00] [10] <-- sample bit 5 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for bit 5 + eor x1, x2 ;1 [03] + bst x1, USBMINUS ;1 [04] + bld shift, 5 ;1 [05] +didUnstuff5: ;- [05] + andi shift, 0x3f ;1 [06] 0b00111111 + breq unstuff5 ;1 [07] + nop2 ;2 [08+09] + in x1, USBIN ;1 [00] [10] <-- sample bit 6 + andi x1, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for bit 6 + eor x2, x1 ;1 [03] + bst x2, USBMINUS ;1 [04] + bld shift, 6 ;1 [05] +didUnstuff6: ;- [05] + cpi shift, 0x02 ;1 [06] 0b00000010 + brlo unstuff6 ;1 [07] + nop2 ;2 [08+09] + in x2, USBIN ;1 [00] [10] <-- sample bit 7 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for bit 7 + eor x1, x2 ;1 [03] + bst x1, USBMINUS ;1 [04] + bld shift, 7 ;1 [05] +didUnstuff7: ;- [05] + cpi shift, 0x04 ;1 [06] 0b00000100 + brlo unstuff7 ;1 [07] + eor x3, shift ;1 [08] reconstruct: x3 is 0 at bit locations we changed, 1 at others + nop ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample bit 0 + st y+, x3 ;2 [01+02] store data + eor x2, x1 ;1 [03] + bst x2, USBMINUS ;1 [04] + bld shift, 0 ;1 [05] + subi cnt, 1 ;1 [06] + brcs overflow ;1 [07] + rjmp rxLoop ;2 [08] +;----------------------------------------------------- +unstuff4: ;- [08] + andi x3, ~0x10 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample stuffed bit 4 + andi x1, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 4 + ori shift, 0x10 ;1 [03] + rjmp didUnstuff4 ;2 [04] +;----------------------------------------------------- +unstuff5: ;- [08] + ori shift, 0x20 ;1 [09] + in x2, USBIN ;1 [00] [10] <-- sample stuffed bit 5 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 5 + andi x3, ~0x20 ;1 [03] + rjmp didUnstuff5 ;2 [04] +;----------------------------------------------------- +unstuff6: ;- [08] + andi x3, ~0x40 ;1 [09] + in x1, USBIN ;1 [00] [10] <-- sample stuffed bit 6 + andi x1, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 6 + ori shift, 0x40 ;1 [03] + rjmp didUnstuff6 ;2 [04] +;----------------------------------------------------- +unstuff7: ;- [08] + andi x3, ~0x80 ;1 [09] + in x2, USBIN ;1 [00] [10] <-- sample stuffed bit 7 + andi x2, USBMASK ;1 [01] + breq se0 ;1 [02] SE0 check for stuffed bit 7 + ori shift, 0x80 ;1 [03] + rjmp didUnstuff7 ;2 [04] + +macro POP_STANDARD ; 16 cycles + pop x4 + pop cnt + pop bitcnt + pop x3 + pop x2 + pop x1 + pop shift + pop YH + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +;--------------------------------------------------------------------------- +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies +;--------------------------------------------------------------------------- +bitstuffN: ;- [04] + eor x1, x4 ;1 [05] + clr x2 ;1 [06] + nop ;1 [07] + rjmp didStuffN ;1 [08] +;--------------------------------------------------------------------------- +bitstuff6: ;- [04] + eor x1, x4 ;1 [05] + clr x2 ;1 [06] + rjmp didStuff6 ;1 [07] +;--------------------------------------------------------------------------- +bitstuff7: ;- [02] + eor x1, x4 ;1 [03] + clr x2 ;1 [06] + nop ;1 [05] + rjmp didStuff7 ;1 [06] +;--------------------------------------------------------------------------- +sendNakAndReti: ;- [-19] + ldi x3, USBPID_NAK ;1 [-18] + rjmp sendX3AndReti ;1 [-17] +;--------------------------------------------------------------------------- +sendAckAndReti: ;- [-17] + ldi cnt, USBPID_ACK ;1 [-16] +sendCntAndReti: ;- [-16] + mov x3, cnt ;1 [-15] +sendX3AndReti: ;- [-15] + ldi YL, 20 ;1 [-14] x3==r20 address is 20 + ldi YH, 0 ;1 [-13] + ldi cnt, 2 ;1 [-12] +; rjmp usbSendAndReti fallthrough +;--------------------------------------------------------------------------- +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent +;We need not to match the transfer rate exactly because the spec demands +;only 1.5% precision anyway. +usbSendAndReti: ;- [-13] 13 cycles until SOP + in x2, USBDDR ;1 [-12] + ori x2, USBMASK ;1 [-11] + sbi USBOUT, USBMINUS ;2 [-09-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;1 [-08] port mirror for tx loop + out USBDDR, x2 ;1 [-07] <- acquire bus + ; need not init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;1 [-06] exor mask + ldi shift, 0x80 ;1 [-05] sync byte is first byte sent + ldi bitcnt, 6 ;1 [-04] +txBitLoop: ;- [-04] [06] + sbrs shift, 0 ;1 [-03] [07] + eor x1, x4 ;1 [-02] [08] + ror shift ;1 [-01] [09] +didStuffN: ;- [09] + out USBOUT, x1 ;1 [00] [10] <-- out N + ror x2 ;1 [01] + cpi x2, 0xfc ;1 [02] + brcc bitstuffN ;1 [03] + dec bitcnt ;1 [04] + brne txBitLoop ;1 [05] + sbrs shift, 0 ;1 [06] + eor x1, x4 ;1 [07] + ror shift ;1 [08] +didStuff6: ;- [08] + nop ;1 [09] + out USBOUT, x1 ;1 [00] [10] <-- out 6 + ror x2 ;1 [01] + cpi x2, 0xfc ;1 [02] + brcc bitstuff6 ;1 [03] + sbrs shift, 0 ;1 [04] + eor x1, x4 ;1 [05] + ror shift ;1 [06] + ror x2 ;1 [07] +didStuff7: ;- [07] + ldi bitcnt, 6 ;1 [08] + cpi x2, 0xfc ;1 [09] + out USBOUT, x1 ;1 [00] [10] <-- out 7 + brcc bitstuff7 ;1 [01] + ld shift, y+ ;2 [02+03] + dec cnt ;1 [04] + brne txBitLoop ;1 [05] +makeSE0: + cbr x1, USBMASK ;1 [06] prepare SE0 [spec says EOP may be 19 to 23 cycles] + lds x2, usbNewDeviceAddr;2 [07+08] + lsl x2 ;1 [09] we compare with left shifted address +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + out USBOUT, x1 ;1 [00] [10] <-- out SE0-- from now 2 bits==20 cycl. until bus idle + subi YL, 20 + 2 ;1 [01] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;1 [02] + breq skipAddrAssign ;1 [03] + sts usbDeviceAddr, x2 ;2 [04+05] if not skipped: SE0 is one cycle longer +;---------------------------------------------------------------------------- +;end of usbDeviceAddress transfer +skipAddrAssign: ;- [03/04] + ldi x2, 1< 10.6666666 cycles per bit, 85.333333333 cycles per byte +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt + push YL ;[-25] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-23] + push YL ;[-22] + push YH ;[-20] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-15] + rjmp foundK ;[-14] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-12] +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push bitcnt ;[-12] +; [---] ;[-11] + lds YL, usbInputBufOffset;[-10] +; [---] ;[-9] + clr YH ;[-8] + subi YL, lo8(-(usbRxBuf));[-7] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-6] [rx loop init] + push shift ;[-5] +; [---] ;[-4] + ldi bitcnt, 0x55 ;[-3] [rx loop init] + sbis USBIN, USBMINUS ;[-2] we want two bits K (sample 2 cycles too early) + rjmp haveTwoBitsK ;[-1] + pop shift ;[0] undo the push from before + pop bitcnt ;[2] undo the push from before + rjmp waitForK ;[4] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 21 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[1] + push x2 ;[3] + push x3 ;[5] + ldi shift, 0 ;[7] + ldi x3, 1<<4 ;[8] [rx loop init] first sample is inverse bit, compensate that + push x4 ;[9] == leap + + in x1, USBIN ;[11] <-- sample bit 0 + andi x1, USBMASK ;[12] + bst x1, USBMINUS ;[13] + bld shift, 7 ;[14] + push cnt ;[15] + ldi leap, 0 ;[17] [rx loop init] + ldi cnt, USB_BUFSIZE;[18] [rx loop init] + rjmp rxbit1 ;[19] arrives at [21] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- + +; duration of unstuffing code should be 10.66666667 cycles. We adjust "leap" +; accordingly to approximate this value in the long run. + +unstuff6: + andi x2, USBMASK ;[03] + ori x3, 1<<6 ;[04] will not be shifted any more + andi shift, ~0x80;[05] + mov x1, x2 ;[06] sampled bit 7 is actually re-sampled bit 6 + subi leap, -1 ;[07] total duration = 11 bits -> subtract 1/3 + rjmp didUnstuff6 ;[08] + +unstuff7: + ori x3, 1<<7 ;[09] will not be shifted any more + in x2, USBIN ;[00] [10] re-sample bit 7 + andi x2, USBMASK ;[01] + andi shift, ~0x80;[02] + subi leap, 2 ;[03] total duration = 10 bits -> add 1/3 + rjmp didUnstuff7 ;[04] + +unstuffEven: + ori x3, 1<<6 ;[09] will be shifted right 6 times for bit 0 + in x1, USBIN ;[00] [10] + andi shift, ~0x80;[01] + andi x1, USBMASK ;[02] + breq se0 ;[03] + subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 + nop2 ;[05] + rjmp didUnstuffE ;[06] + +unstuffOdd: + ori x3, 1<<5 ;[09] will be shifted right 4 times for bit 1 + in x2, USBIN ;[00] [10] + andi shift, ~0x80;[01] + andi x2, USBMASK ;[02] + breq se0 ;[03] + subi leap, -1 ;[04] total duration = 11 bits -> subtract 1/3 + nop2 ;[05] + rjmp didUnstuffO ;[06] + +rxByteLoop: + andi x1, USBMASK ;[03] + eor x2, x1 ;[04] + subi leap, 1 ;[05] + brpl skipLeap ;[06] + subi leap, -3 ;1 one leap cycle every 3rd byte -> 85 + 1/3 cycles per byte + nop ;1 +skipLeap: + subi x2, 1 ;[08] + ror shift ;[09] +didUnstuff6: + cpi shift, 0xfc ;[10] + in x2, USBIN ;[00] [11] <-- sample bit 7 + brcc unstuff6 ;[01] + andi x2, USBMASK ;[02] + eor x1, x2 ;[03] + subi x1, 1 ;[04] + ror shift ;[05] +didUnstuff7: + cpi shift, 0xfc ;[06] + brcc unstuff7 ;[07] + eor x3, shift ;[08] reconstruct: x3 is 1 at bit locations we changed, 0 at others + st y+, x3 ;[09] store data +rxBitLoop: + in x1, USBIN ;[00] [11] <-- sample bit 0/2/4 + andi x1, USBMASK ;[01] + eor x2, x1 ;[02] + andi x3, 0x3f ;[03] topmost two bits reserved for 6 and 7 + subi x2, 1 ;[04] + ror shift ;[05] + cpi shift, 0xfc ;[06] + brcc unstuffEven ;[07] +didUnstuffE: + lsr x3 ;[08] + lsr x3 ;[09] +rxbit1: + in x2, USBIN ;[00] [10] <-- sample bit 1/3/5 + andi x2, USBMASK ;[01] + breq se0 ;[02] + eor x1, x2 ;[03] + subi x1, 1 ;[04] + ror shift ;[05] + cpi shift, 0xfc ;[06] + brcc unstuffOdd ;[07] +didUnstuffO: + subi bitcnt, 0xab;[08] == addi 0x55, 0x55 = 0x100/3 + brcs rxBitLoop ;[09] + + subi cnt, 1 ;[10] + in x1, USBIN ;[00] [11] <-- sample bit 6 + brcc rxByteLoop ;[01] + rjmp overflow + +macro POP_STANDARD ; 14 cycles + pop cnt + pop x4 + pop x3 + pop x2 + pop x1 + pop shift + pop bitcnt + endm +macro POP_RETI ; 7 cycles + pop YH + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies + +bitstuffN: + eor x1, x4 ;[5] + ldi x2, 0 ;[6] + nop2 ;[7] + nop ;[9] + out USBOUT, x1 ;[10] <-- out + rjmp didStuffN ;[0] + +bitstuff6: + eor x1, x4 ;[5] + ldi x2, 0 ;[6] Carry is zero due to brcc + rol shift ;[7] compensate for ror shift at branch destination + rjmp didStuff6 ;[8] + +bitstuff7: + ldi x2, 0 ;[2] Carry is zero due to brcc + rjmp didStuff7 ;[3] + + +sendNakAndReti: + ldi x3, USBPID_NAK ;[-18] + rjmp sendX3AndReti ;[-17] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov x3, cnt ;[-16] +sendX3AndReti: + ldi YL, 20 ;[-15] x3==r20 address is 20 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent +;We don't match the transfer rate exactly (don't insert leap cycles every third +;byte) because the spec demands only 1.5% precision anyway. +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-7] <- acquire bus +; need not init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-6] exor mask + ldi shift, 0x80 ;[-5] sync byte is first byte sent +txByteLoop: + ldi bitcnt, 0x35 ;[-4] [6] binary 0011 0101 +txBitLoop: + sbrs shift, 0 ;[-3] [7] + eor x1, x4 ;[-2] [8] + out USBOUT, x1 ;[-1] [9] <-- out N + ror shift ;[0] [10] + ror x2 ;[1] +didStuffN: + cpi x2, 0xfc ;[2] + brcc bitstuffN ;[3] + lsr bitcnt ;[4] + brcc txBitLoop ;[5] + brne txBitLoop ;[6] + + sbrs shift, 0 ;[7] + eor x1, x4 ;[8] +didStuff6: + out USBOUT, x1 ;[-1] [9] <-- out 6 + ror shift ;[0] [10] + ror x2 ;[1] + cpi x2, 0xfc ;[2] + brcc bitstuff6 ;[3] + ror shift ;[4] +didStuff7: + ror x2 ;[5] + sbrs x2, 7 ;[6] + eor x1, x4 ;[7] + nop ;[8] + cpi x2, 0xfc ;[9] + out USBOUT, x1 ;[-1][10] <-- out 7 + brcc bitstuff7 ;[0] [11] + ld shift, y+ ;[1] + dec cnt ;[3] + brne txByteLoop ;[4] +;make SE0: + cbr x1, USBMASK ;[5] prepare SE0 [spec says EOP may be 21 to 25 cycles] + lds x2, usbNewDeviceAddr;[6] + lsl x2 ;[8] we compare with left shifted address + subi YL, 20 + 2 ;[9] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[10] + out USBOUT, x1 ;[11] <-- out SE0 -- from now 2 bits = 22 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[0] + sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< max 52 cycles interrupt disable +;max stack usage: [ret(2), r0, SREG, YL, YH, shift, x1, x2, x3, x4, cnt] = 12 bytes +;nominal frequency: 16.5 MHz -> 11 cycles per bit +; 16.3125 MHz < F_CPU < 16.6875 MHz (+/- 1.1%) +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG [sofError], r0, YH, shift, x1, x2, x3, x4, cnt + push YL ;[-23] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-21] + push YL ;[-20] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-15] + rjmp foundK ;[-14] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-12] +;{3, 5} after falling D- edge, average delay: 4 cycles [we want 5 for center sampling] +;we have 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push r0 ;[-12] +; [---] ;[-11] + push YH ;[-10] +; [---] ;[-9] + lds YL, usbInputBufOffset;[-8] +; [---] ;[-7] + clr YH ;[-6] + subi YL, lo8(-(usbRxBuf));[-5] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-4] [rx loop init] + mov r0, x2 ;[-3] [rx loop init] + sbis USBIN, USBMINUS ;[-2] we want two bits K (sample 2 cycles too early) + rjmp haveTwoBitsK ;[-1] + pop YH ;[0] undo the pushes from before + pop r0 ;[2] + rjmp waitForK ;[4] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 22 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: ;[1] + push shift ;[1] + push x1 ;[3] + push x2 ;[5] + push x3 ;[7] + ldi shift, 0xff ;[9] [rx loop init] + ori x3, 0xff ;[10] [rx loop init] == ser x3, clear zero flag + + in x1, USBIN ;[11] <-- sample bit 0 + bst x1, USBMINUS ;[12] + bld shift, 0 ;[13] + push x4 ;[14] == phase +; [---] ;[15] + push cnt ;[16] +; [---] ;[17] + ldi phase, 0 ;[18] [rx loop init] + ldi cnt, USB_BUFSIZE;[19] [rx loop init] + rjmp rxbit1 ;[20] +; [---] ;[21] + +;---------------------------------------------------------------------------- +; Receiver loop (numbers in brackets are cycles within byte after instr) +;---------------------------------------------------------------------------- +/* +byte oriented operations done during loop: +bit 0: store data +bit 1: SE0 check +bit 2: overflow check +bit 3: catch up +bit 4: rjmp to achieve conditional jump range +bit 5: PLL +bit 6: catch up +bit 7: jump, fixup bitstuff +; 87 [+ 2] cycles +------------------------------------------------------------------ +*/ +continueWithBit5: + in x2, USBIN ;[055] <-- bit 5 + eor r0, x2 ;[056] + or phase, r0 ;[057] + sbrc phase, USBMINUS ;[058] + lpm ;[059] optional nop3; modifies r0 + in phase, USBIN ;[060] <-- phase + eor x1, x2 ;[061] + bst x1, USBMINUS ;[062] + bld shift, 5 ;[063] + andi shift, 0x3f ;[064] + in x1, USBIN ;[065] <-- bit 6 + breq unstuff5 ;[066] *** unstuff escape + eor phase, x1 ;[067] + eor x2, x1 ;[068] + bst x2, USBMINUS ;[069] + bld shift, 6 ;[070] +didUnstuff6: ;[ ] + in r0, USBIN ;[071] <-- phase + cpi shift, 0x02 ;[072] + brlo unstuff6 ;[073] *** unstuff escape +didUnstuff5: ;[ ] + nop2 ;[074] +; [---] ;[075] + in x2, USBIN ;[076] <-- bit 7 + eor x1, x2 ;[077] + bst x1, USBMINUS ;[078] + bld shift, 7 ;[079] +didUnstuff7: ;[ ] + eor r0, x2 ;[080] + or phase, r0 ;[081] + in r0, USBIN ;[082] <-- phase + cpi shift, 0x04 ;[083] + brsh rxLoop ;[084] +; [---] ;[085] +unstuff7: ;[ ] + andi x3, ~0x80 ;[085] + ori shift, 0x80 ;[086] + in x2, USBIN ;[087] <-- sample stuffed bit 7 + nop ;[088] + rjmp didUnstuff7 ;[089] +; [---] ;[090] + ;[080] + +unstuff5: ;[067] + eor phase, x1 ;[068] + andi x3, ~0x20 ;[069] + ori shift, 0x20 ;[070] + in r0, USBIN ;[071] <-- phase + mov x2, x1 ;[072] + nop ;[073] + nop2 ;[074] +; [---] ;[075] + in x1, USBIN ;[076] <-- bit 6 + eor r0, x1 ;[077] + or phase, r0 ;[078] + eor x2, x1 ;[079] + bst x2, USBMINUS ;[080] + bld shift, 6 ;[081] no need to check bitstuffing, we just had one + in r0, USBIN ;[082] <-- phase + rjmp didUnstuff5 ;[083] +; [---] ;[084] + ;[074] + +unstuff6: ;[074] + andi x3, ~0x40 ;[075] + in x1, USBIN ;[076] <-- bit 6 again + ori shift, 0x40 ;[077] + nop2 ;[078] +; [---] ;[079] + rjmp didUnstuff6 ;[080] +; [---] ;[081] + ;[071] + +unstuff0: ;[013] + eor r0, x2 ;[014] + or phase, r0 ;[015] + andi x2, USBMASK ;[016] check for SE0 + in r0, USBIN ;[017] <-- phase + breq didUnstuff0 ;[018] direct jump to se0 would be too long + andi x3, ~0x01 ;[019] + ori shift, 0x01 ;[020] + mov x1, x2 ;[021] mov existing sample + in x2, USBIN ;[022] <-- bit 1 again + rjmp didUnstuff0 ;[023] +; [---] ;[024] + ;[014] + +unstuff1: ;[024] + eor r0, x1 ;[025] + or phase, r0 ;[026] + andi x3, ~0x02 ;[027] + in r0, USBIN ;[028] <-- phase + ori shift, 0x02 ;[029] + mov x2, x1 ;[030] + rjmp didUnstuff1 ;[031] +; [---] ;[032] + ;[022] + +unstuff2: ;[035] + eor r0, x2 ;[036] + or phase, r0 ;[037] + andi x3, ~0x04 ;[038] + in r0, USBIN ;[039] <-- phase + ori shift, 0x04 ;[040] + mov x1, x2 ;[041] + rjmp didUnstuff2 ;[042] +; [---] ;[043] + ;[033] + +unstuff3: ;[043] + in x2, USBIN ;[044] <-- bit 3 again + eor r0, x2 ;[045] + or phase, r0 ;[046] + andi x3, ~0x08 ;[047] + ori shift, 0x08 ;[048] + nop ;[049] + in r0, USBIN ;[050] <-- phase + rjmp didUnstuff3 ;[051] +; [---] ;[052] + ;[042] + +unstuff4: ;[053] + andi x3, ~0x10 ;[054] + in x1, USBIN ;[055] <-- bit 4 again + ori shift, 0x10 ;[056] + rjmp didUnstuff4 ;[057] +; [---] ;[058] + ;[048] + +rxLoop: ;[085] + eor x3, shift ;[086] reconstruct: x3 is 0 at bit locations we changed, 1 at others + in x1, USBIN ;[000] <-- bit 0 + st y+, x3 ;[001] +; [---] ;[002] + eor r0, x1 ;[003] + or phase, r0 ;[004] + eor x2, x1 ;[005] + in r0, USBIN ;[006] <-- phase + ser x3 ;[007] + bst x2, USBMINUS ;[008] + bld shift, 0 ;[009] + andi shift, 0xf9 ;[010] +rxbit1: ;[ ] + in x2, USBIN ;[011] <-- bit 1 + breq unstuff0 ;[012] *** unstuff escape + andi x2, USBMASK ;[013] SE0 check for bit 1 +didUnstuff0: ;[ ] Z only set if we detected SE0 in bitstuff + breq se0 ;[014] + eor r0, x2 ;[015] + or phase, r0 ;[016] + in r0, USBIN ;[017] <-- phase + eor x1, x2 ;[018] + bst x1, USBMINUS ;[019] + bld shift, 1 ;[020] + andi shift, 0xf3 ;[021] +didUnstuff1: ;[ ] + in x1, USBIN ;[022] <-- bit 2 + breq unstuff1 ;[023] *** unstuff escape + eor r0, x1 ;[024] + or phase, r0 ;[025] + subi cnt, 1 ;[026] overflow check + brcs overflow ;[027] + in r0, USBIN ;[028] <-- phase + eor x2, x1 ;[029] + bst x2, USBMINUS ;[030] + bld shift, 2 ;[031] + andi shift, 0xe7 ;[032] +didUnstuff2: ;[ ] + in x2, USBIN ;[033] <-- bit 3 + breq unstuff2 ;[034] *** unstuff escape + eor r0, x2 ;[035] + or phase, r0 ;[036] + eor x1, x2 ;[037] + bst x1, USBMINUS ;[038] + in r0, USBIN ;[039] <-- phase + bld shift, 3 ;[040] + andi shift, 0xcf ;[041] +didUnstuff3: ;[ ] + breq unstuff3 ;[042] *** unstuff escape + nop ;[043] + in x1, USBIN ;[044] <-- bit 4 + eor x2, x1 ;[045] + bst x2, USBMINUS ;[046] + bld shift, 4 ;[047] +didUnstuff4: ;[ ] + eor r0, x1 ;[048] + or phase, r0 ;[049] + in r0, USBIN ;[050] <-- phase + andi shift, 0x9f ;[051] + breq unstuff4 ;[052] *** unstuff escape + rjmp continueWithBit5;[053] +; [---] ;[054] + +macro POP_STANDARD ; 16 cycles + pop cnt + pop x4 + pop x3 + pop x2 + pop x1 + pop shift + pop YH + pop r0 + endm +macro POP_RETI ; 5 cycles + pop YL + out SREG, YL + pop YL + endm + +#include "asmcommon.inc" + + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies + +bitstuff7: + eor x1, x4 ;[4] + ldi x2, 0 ;[5] + nop2 ;[6] C is zero (brcc) + rjmp didStuff7 ;[8] + +bitstuffN: + eor x1, x4 ;[5] + ldi x2, 0 ;[6] + lpm ;[7] 3 cycle NOP, modifies r0 + out USBOUT, x1 ;[10] <-- out + rjmp didStuffN ;[0] + +#define bitStatus x3 + +sendNakAndReti: + ldi cnt, USBPID_NAK ;[-19] + rjmp sendCntAndReti ;[-18] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov r0, cnt ;[-16] + ldi YL, 0 ;[-15] R0 address is 0 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-7] <- acquire bus +; need not init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-6] exor mask + ldi shift, 0x80 ;[-5] sync byte is first byte sent + ldi bitStatus, 0xff ;[-4] init bit loop counter, works for up to 12 bytes +byteloop: +bitloop: + sbrs shift, 0 ;[8] [-3] + eor x1, x4 ;[9] [-2] + out USBOUT, x1 ;[10] [-1] <-- out + ror shift ;[0] + ror x2 ;[1] +didStuffN: + cpi x2, 0xfc ;[2] + brcc bitstuffN ;[3] + nop ;[4] + subi bitStatus, 37 ;[5] 256 / 7 ~=~ 37 + brcc bitloop ;[6] when we leave the loop, bitStatus has almost the initial value + sbrs shift, 0 ;[7] + eor x1, x4 ;[8] + ror shift ;[9] +didStuff7: + out USBOUT, x1 ;[10] <-- out + ror x2 ;[0] + cpi x2, 0xfc ;[1] + brcc bitstuff7 ;[2] + ld shift, y+ ;[3] + dec cnt ;[5] + brne byteloop ;[6] +;make SE0: + cbr x1, USBMASK ;[7] prepare SE0 [spec says EOP may be 21 to 25 cycles] + lds x2, usbNewDeviceAddr;[8] + lsl x2 ;[10] we compare with left shifted address + out USBOUT, x1 ;[11] <-- out SE0 -- from now 2 bits = 22 cycles until bus idle +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + subi YL, 2 ;[0] Only assign address on data packets, not ACK/NAK in r0 + sbci YH, 0 ;[1] + breq skipAddrAssign ;[2] + sts usbDeviceAddr, x2; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< 12 cycles per bit +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts +;register use in receive loop to receive the data bytes: +; shift assembles the byte currently being received +; x1 holds the D+ and D- line state +; x2 holds the previous line state +; cnt holds the number of bytes left in the receive buffer +; x3 holds the higher crc byte (see algorithm below) +; x4 is used as temporary register for the crc algorithm +; x5 is used for unstuffing: when unstuffing the last received bit is inverted in shift (to prevent further +; unstuffing calls. In the same time the corresponding bit in x5 is cleared to mark the bit as beening iverted +; zl lower crc value and crc table index +; zh used for crc table accesses + +;-------------------------------------------------------------------------------------------------------------- +; CRC mods: +; table driven crc checker, Z points to table in prog space +; ZL is the lower crc byte, x3 is the higher crc byte +; x4 is used as temp register to store different results +; the initialization of the crc register is not 0xFFFF but 0xFE54. This is because during the receipt of the +; first data byte an virtual zero data byte is added to the crc register, this results in the correct initial +; value of 0xFFFF at beginning of the second data byte before the first data byte is added to the crc. +; The magic number 0xFE54 results form the crc table: At tabH[0x54] = 0xFF = crcH (required) and +; tabL[0x54] = 0x01 -> crcL = 0x01 xor 0xFE = 0xFF +; bitcnt is renamed to x5 and is used for unstuffing purposes, the unstuffing works like in the 12MHz version +;-------------------------------------------------------------------------------------------------------------- +; CRC algorithm: +; The crc register is formed by x3 (higher byte) and ZL (lower byte). The algorithm uses a 'reversed' form +; i.e. that it takes the least significant bit first and shifts to the right. So in fact the highest order +; bit seen from the polynomial devision point of view is the lsb of ZL. (If this sounds strange to you i +; propose a research on CRC :-) ) +; Each data byte received is xored to ZL, the lower crc byte. This byte now builds the crc +; table index. Next the new high byte is loaded from the table and stored in x4 until we have space in x3 +; (its destination). +; Afterwards the lower table is loaded from the table and stored in ZL (the old index is overwritten as +; we don't need it anymore. In fact this is a right shift by 8 bits.) Now the old crc high value is xored +; to ZL, this is the second shift of the old crc value. Now x4 (the temp reg) is moved to x3 and the crc +; calculation is done. +; Prior to the first byte the two CRC register have to be initialized to 0xFFFF (as defined in usb spec) +; however the crc engine also runs during the receipt of the first byte, therefore x3 and zl are initialized +; to a magic number which results in a crc value of 0xFFFF after the first complete byte. +; +; This algorithm is split into the extra cycles of the different bits: +; bit7: XOR the received byte to ZL +; bit5: load the new high byte to x4 +; bit6: load the lower xor byte from the table, xor zl and x3, store result in zl (=the new crc low value) +; move x4 (the new high byte) to x3, the crc value is ready +; + + +macro POP_STANDARD ; 18 cycles + pop ZH + pop ZL + pop cnt + pop x5 + pop x3 + pop x2 + pop x1 + pop shift + pop x4 + endm +macro POP_RETI ; 7 cycles + pop YH + pop YL + out SREG, YL + pop YL + endm + +macro CRC_CLEANUP_AND_CHECK + ; the last byte has already been xored with the lower crc byte, we have to do the table lookup and xor + ; x3 is the higher crc byte, zl the lower one + ldi ZH, hi8(usbCrcTableHigh);[+1] get the new high byte from the table + lpm x2, Z ;[+2][+3][+4] + ldi ZH, hi8(usbCrcTableLow);[+5] get the new low xor byte from the table + lpm ZL, Z ;[+6][+7][+8] + eor ZL, x3 ;[+7] xor the old high byte with the value from the table, x2:ZL now holds the crc value + cpi ZL, 0x01 ;[+8] if the crc is ok we have a fixed remainder value of 0xb001 in x2:ZL (see usb spec) + brne ignorePacket ;[+9] detected a crc fault -> paket is ignored and retransmitted by the host + cpi x2, 0xb0 ;[+10] + brne ignorePacket ;[+11] detected a crc fault -> paket is ignored and retransmitted by the host + endm + + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG, YH, [sofError], x4, shift, x1, x2, x3, x5, cnt, ZL, ZH + push YL ;[-28] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-26] + push YL ;[-25] + push YH ;[-23] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-17] + rjmp foundK ;[-16] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-15] +;{3, 5} after falling D- edge, average delay: 4 cycles +;bit0 should be at 30 (2.5 bits) for center sampling. Currently at 4 so 26 cylces till bit 0 sample +;use 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push x4 ;[-14] +; [---] ;[-13] + lds YL, usbInputBufOffset;[-12] used to toggle the two usb receive buffers +; [---] ;[-11] + clr YH ;[-10] + subi YL, lo8(-(usbRxBuf));[-9] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-8] [rx loop init] + push shift ;[-7] +; [---] ;[-6] + ldi shift, 0x80 ;[-5] the last bit is the end of byte marker for the pid receiver loop + clc ;[-4] the carry has to be clear for receipt of pid bit 0 + sbis USBIN, USBMINUS ;[-3] we want two bits K (sample 3 cycles too early) + rjmp haveTwoBitsK ;[-2] + pop shift ;[-1] undo the push from before + pop x4 ;[1] + rjmp waitForK ;[3] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 24 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[0] + push x2 ;[2] + push x3 ;[4] crc high byte + ldi x2, 1< jump back and store the byte + ori shift, 0x01 ;[11] invert the last received bit to prevent furhter unstuffing + in x2, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + andi x5, 0xFE ;[1] mark this bit as inverted (will be corrected before storing shift) + eor x1, x2 ;[2] x1 and x2 have to be different because the stuff bit is always a zero + andi x1, USBMASK ;[3] mask the interesting bits + breq stuffErr ;[4] if the stuff bit is a 1-bit something went wrong + mov x1, x2 ;[5] the next bit expects the last state to be in x1 + rjmp didunstuff0 ;[6] + ;[7] jump delay of rjmp didunstuffX + +unstuff1: ;[11] this is the jump delay of breq unstuffX + in x1, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + ori shift, 0x02 ;[1] invert the last received bit to prevent furhter unstuffing + andi x5, 0xFD ;[2] mark this bit as inverted (will be corrected before storing shift) + eor x2, x1 ;[3] x1 and x2 have to be different because the stuff bit is always a zero + andi x2, USBMASK ;[4] mask the interesting bits + breq stuffErr ;[5] if the stuff bit is a 1-bit something went wrong + mov x2, x1 ;[6] the next bit expects the last state to be in x2 + nop2 ;[7] + ;[8] + rjmp didunstuff1 ;[9] + ;[10] jump delay of rjmp didunstuffX + +unstuff2: ;[9] this is the jump delay of breq unstuffX + ori shift, 0x04 ;[10] invert the last received bit to prevent furhter unstuffing + andi x5, 0xFB ;[11] mark this bit as inverted (will be corrected before storing shift) + in x2, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + eor x1, x2 ;[1] x1 and x2 have to be different because the stuff bit is always a zero + andi x1, USBMASK ;[2] mask the interesting bits + breq stuffErr ;[3] if the stuff bit is a 1-bit something went wrong + mov x1, x2 ;[4] the next bit expects the last state to be in x1 + nop2 ;[5] + ;[6] + rjmp didunstuff2 ;[7] + ;[8] jump delay of rjmp didunstuffX + +unstuff3: ;[9] this is the jump delay of breq unstuffX + ori shift, 0x08 ;[10] invert the last received bit to prevent furhter unstuffing + andi x5, 0xF7 ;[11] mark this bit as inverted (will be corrected before storing shift) + in x1, USBIN ;[0] we have some free cycles so we could check for bit stuffing errors + eor x2, x1 ;[1] x1 and x2 have to be different because the stuff bit is always a zero + andi x2, USBMASK ;[2] mask the interesting bits + breq stuffErr ;[3] if the stuff bit is a 1-bit something went wrong + mov x2, x1 ;[4] the next bit expects the last state to be in x2 + nop2 ;[5] + ;[6] + rjmp didunstuff3 ;[7] + ;[8] jump delay of rjmp didunstuffX + + + +; the include has to be here due to branch distance restirctions +#define __USE_CRC__ +#include "asmcommon.inc" + + + +; USB spec says: +; idle = J +; J = (D+ = 0), (D- = 1) +; K = (D+ = 1), (D- = 0) +; Spec allows 7.5 bit times from EOP to SOP for replies +; 7.5 bit times is 90 cycles. ...there is plenty of time + + +sendNakAndReti: + ldi x3, USBPID_NAK ;[-18] + rjmp sendX3AndReti ;[-17] +sendAckAndReti: + ldi cnt, USBPID_ACK ;[-17] +sendCntAndReti: + mov x3, cnt ;[-16] +sendX3AndReti: + ldi YL, 20 ;[-15] x3==r20 address is 20 + ldi YH, 0 ;[-14] + ldi cnt, 2 ;[-13] +; rjmp usbSendAndReti fallthrough + +;usbSend: +;pointer to data in 'Y' +;number of bytes in 'cnt' -- including sync byte [range 2 ... 12] +;uses: x1...x4, btcnt, shift, cnt, Y +;Numbers in brackets are time since first bit of sync pattern is sent + +usbSendAndReti: ; 12 cycles until SOP + in x2, USBDDR ;[-12] + ori x2, USBMASK ;[-11] + sbi USBOUT, USBMINUS;[-10] prepare idle state; D+ and D- must have been 0 (no pullups) + in x1, USBOUT ;[-8] port mirror for tx loop + out USBDDR, x2 ;[-6] <- acquire bus + ldi x2, 0 ;[-6] init x2 (bitstuff history) because sync starts with 0 + ldi x4, USBMASK ;[-5] exor mask + ldi shift, 0x80 ;[-4] sync byte is first byte sent +txByteLoop: + ldi bitcnt, 0x40 ;[-3]=[9] binary 01000000 +txBitLoop: ; the loop sends the first 7 bits of the byte + sbrs shift, 0 ;[-2]=[10] if we have to send a 1 don't change the line state + eor x1, x4 ;[-1]=[11] + out USBOUT, x1 ;[0] + ror shift ;[1] + ror x2 ;[2] transfers the last sent bit to the stuffing history +didStuffN: + nop ;[3] + nop ;[4] + cpi x2, 0xfc ;[5] if we sent six consecutive ones + brcc bitstuffN ;[6] + lsr bitcnt ;[7] + brne txBitLoop ;[8] restart the loop while the 1 is still in the bitcount + +; transmit bit 7 + sbrs shift, 0 ;[9] + eor x1, x4 ;[10] +didStuff7: + ror shift ;[11] + out USBOUT, x1 ;[0] transfer bit 7 to the pins + ror x2 ;[1] move the bit into the stuffing history + cpi x2, 0xfc ;[2] + brcc bitstuff7 ;[3] + ld shift, y+ ;[4] get next byte to transmit + dec cnt ;[5] decrement byte counter + brne txByteLoop ;[7] if we have more bytes start next one + ;[8] branch delay + +;make SE0: + cbr x1, USBMASK ;[8] prepare SE0 [spec says EOP may be 25 to 30 cycles] + lds x2, usbNewDeviceAddr;[9] + lsl x2 ;[11] we compare with left shifted address + out USBOUT, x1 ;[0] <-- out SE0 -- from now 2 bits = 24 cycles until bus idle + subi YL, 20 + 2 ;[1] Only assign address on data packets, not ACK/NAK in x3 + sbci YH, 0 ;[2] +;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm: +;set address only after data packet was sent, not after handshake + breq skipAddrAssign ;[3] + sts usbDeviceAddr, x2 ; if not skipped: SE0 is one cycle longer +skipAddrAssign: +;end of usbDeviceAddress transfer + ldi x2, 1< +int main (int argc, char **argv) +{ + int i, j; + for (i=0; i<512; i++){ + unsigned short crc = i & 0xff; + for(j=0; j<8; j++) crc = (crc >> 1) ^ ((crc & 1) ? 0xa001 : 0); + if((i & 7) == 0) printf("\n.byte "); + printf("0x%02x, ", (i > 0xff ? (crc >> 8) : crc) & 0xff); + if(i == 255) printf("\n"); + } + return 0; +} + +// Use the following algorithm to compute CRC values: +ushort computeCrc(uchar *msg, uchar msgLen) +{ + uchar i; + ushort crc = 0xffff; + for(i = 0; i < msgLen; i++) + crc = usbCrcTable16[lo8(crc) ^ msg[i]] ^ hi8(crc); + return crc; +} +*/ + +.balign 256 +usbCrcTableLow: +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41 +.byte 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 + +; .balign 256 +usbCrcTableHigh: +.byte 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2 +.byte 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04 +.byte 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E +.byte 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8 +.byte 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A +.byte 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC +.byte 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6 +.byte 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10 +.byte 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32 +.byte 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4 +.byte 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE +.byte 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38 +.byte 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA +.byte 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C +.byte 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26 +.byte 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0 +.byte 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62 +.byte 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4 +.byte 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE +.byte 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68 +.byte 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA +.byte 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C +.byte 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76 +.byte 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0 +.byte 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92 +.byte 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54 +.byte 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E +.byte 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98 +.byte 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A +.byte 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C +.byte 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86 +.byte 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 + diff --git a/protocol/vusb/usbdrv/usbdrvasm20.inc b/protocol/vusb/usbdrv/usbdrvasm20.inc new file mode 100644 index 000000000..303abaf64 --- /dev/null +++ b/protocol/vusb/usbdrv/usbdrvasm20.inc @@ -0,0 +1,360 @@ +/* Name: usbdrvasm20.inc + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Jeroen Benschop + * Based on usbdrvasm16.inc from Christian Starkjohann + * Creation Date: 2008-03-05 + * Tabsize: 4 + * Copyright: (c) 2008 by Jeroen Benschop and OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * Revision: $Id: usbdrvasm20.inc 740 2009-04-13 18:23:31Z cs $ + */ + +/* Do not link this file! Link usbdrvasm.S instead, which includes the + * appropriate implementation! + */ + +/* +General Description: +This file is the 20 MHz version of the asssembler part of the USB driver. It +requires a 20 MHz crystal (not a ceramic resonator and not a calibrated RC +oscillator). + +See usbdrv.h for a description of the entire driver. + +Since almost all of this code is timing critical, don't change unless you +really know what you are doing! Many parts require not only a maximum number +of CPU cycles, but even an exact number of cycles! +*/ + +#define leap2 x3 +#ifdef __IAR_SYSTEMS_ASM__ +#define nextInst $+2 +#else +#define nextInst .+0 +#endif + +;max stack usage: [ret(2), YL, SREG, YH, bitcnt, shift, x1, x2, x3, x4, cnt] = 12 bytes +;nominal frequency: 20 MHz -> 13.333333 cycles per bit, 106.666667 cycles per byte +; Numbers in brackets are clocks counted from center of last sync bit +; when instruction starts +;register use in receive loop: +; shift assembles the byte currently being received +; x1 holds the D+ and D- line state +; x2 holds the previous line state +; x4 (leap) is used to add a leap cycle once every three bytes received +; X3 (leap2) is used to add a leap cycle once every three stuff bits received +; bitcnt is used to determine when a stuff bit is due +; cnt holds the number of bytes left in the receive buffer + +USB_INTR_VECTOR: +;order of registers pushed: YL, SREG YH, [sofError], bitcnt, shift, x1, x2, x3, x4, cnt + push YL ;[-28] push only what is necessary to sync with edge ASAP + in YL, SREG ;[-26] + push YL ;[-25] + push YH ;[-23] +;---------------------------------------------------------------------------- +; Synchronize with sync pattern: +;---------------------------------------------------------------------------- +;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K] +;sync up with J to K edge during sync pattern -- use fastest possible loops +;The first part waits at most 1 bit long since we must be in sync pattern. +;YL is guarenteed to be < 0x80 because I flag is clear. When we jump to +;waitForJ, ensure that this prerequisite is met. +waitForJ: + inc YL + sbis USBIN, USBMINUS + brne waitForJ ; just make sure we have ANY timeout +waitForK: +;The following code results in a sampling window of < 1/4 bit which meets the spec. + sbis USBIN, USBMINUS ;[-19] + rjmp foundK ;[-18] + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK + sbis USBIN, USBMINUS + rjmp foundK +#if USB_COUNT_SOF + lds YL, usbSofCount + inc YL + sts usbSofCount, YL +#endif /* USB_COUNT_SOF */ +#ifdef USB_SOF_HOOK + USB_SOF_HOOK +#endif + rjmp sofError +foundK: ;[-16] +;{3, 5} after falling D- edge, average delay: 4 cycles +;bit0 should be at 34 for center sampling. Currently at 4 so 30 cylces till bit 0 sample +;use 1 bit time for setup purposes, then sample again. Numbers in brackets +;are cycles from center of first sync (double K) bit after the instruction + push bitcnt ;[-16] +; [---] ;[-15] + lds YL, usbInputBufOffset;[-14] +; [---] ;[-13] + clr YH ;[-12] + subi YL, lo8(-(usbRxBuf));[-11] [rx loop init] + sbci YH, hi8(-(usbRxBuf));[-10] [rx loop init] + push shift ;[-9] +; [---] ;[-8] + ldi shift,0x40 ;[-7] set msb to "1" so processing bit7 can be detected + nop2 ;[-6] +; [---] ;[-5] + ldi bitcnt, 5 ;[-4] [rx loop init] + sbis USBIN, USBMINUS ;[-3] we want two bits K (sample 3 cycles too early) + rjmp haveTwoBitsK ;[-2] + pop shift ;[-1] undo the push from before + pop bitcnt ;[1] + rjmp waitForK ;[3] this was not the end of sync, retry +; The entire loop from waitForK until rjmp waitForK above must not exceed two +; bit times (= 27 cycles). + +;---------------------------------------------------------------------------- +; push more registers and initialize values while we sample the first bits: +;---------------------------------------------------------------------------- +haveTwoBitsK: + push x1 ;[0] + push x2 ;[2] + push x3 ;[4] (leap2) + ldi leap2, 0x55 ;[6] add leap cycle on 2nd,5th,8th,... stuff bit + push x4 ;[7] == leap + ldi leap, 0x55 ;[9] skip leap cycle on 2nd,5th,8th,... byte received + push cnt ;[10] + ldi cnt, USB_BUFSIZE ;[12] [rx loop init] + ldi x2, 1< +#ifndef __IAR_SYSTEMS_ASM__ +# include +#endif + +#define __attribute__(arg) /* not supported on IAR */ + +#ifdef __IAR_SYSTEMS_ASM__ +# define __ASSEMBLER__ /* IAR does not define standard macro for asm */ +#endif + +#ifdef __HAS_ELPM__ +# define PROGMEM __farflash +#else +# define PROGMEM __flash +#endif + +#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) + +/* The following definitions are not needed by the driver, but may be of some + * help if you port a gcc based project to IAR. + */ +#define cli() __disable_interrupt() +#define sei() __enable_interrupt() +#define wdt_reset() __watchdog_reset() +#define _BV(x) (1 << (x)) + +/* assembler compatibility macros */ +#define nop2 rjmp $+2 /* jump to next instruction */ +#define XL r26 +#define XH r27 +#define YL r28 +#define YH r29 +#define ZL r30 +#define ZH r31 +#define lo8(x) LOW(x) +#define hi8(x) (((x)>>8) & 0xff) /* not HIGH to allow XLINK to make a proper range check */ + +/* Depending on the device you use, you may get problems with the way usbdrv.h + * handles the differences between devices. Since IAR does not use #defines + * for MCU registers, we can't check for the existence of a particular + * register with an #ifdef. If the autodetection mechanism fails, include + * definitions for the required USB_INTR_* macros in your usbconfig.h. See + * usbconfig-prototype.h and usbdrv.h for details. + */ + +/* ------------------------------------------------------------------------- */ +#elif __CODEVISIONAVR__ /* check for CodeVision AVR */ +/* ------------------------------------------------------------------------- */ +/* This port is not working (yet) */ + +/* #define F_CPU _MCU_CLOCK_FREQUENCY_ seems to be defined automatically */ + +#include +#include + +#define __attribute__(arg) /* not supported on IAR */ + +#define PROGMEM __flash +#define USB_READ_FLASH(addr) (*(PROGMEM char *)(addr)) + +#ifndef __ASSEMBLER__ +static inline void cli(void) +{ + #asm("cli"); +} +static inline void sei(void) +{ + #asm("sei"); +} +#endif +#define _delay_ms(t) delay_ms(t) +#define _BV(x) (1 << (x)) +#define USB_CFG_USE_SWITCH_STATEMENT 1 /* macro for if() cascase fails for unknown reason */ + +#define macro .macro +#define endm .endmacro +#define nop2 rjmp .+0 /* jump to next instruction */ + +/* ------------------------------------------------------------------------- */ +#else /* default development environment is avr-gcc/avr-libc */ +/* ------------------------------------------------------------------------- */ + +#include +#ifdef __ASSEMBLER__ +# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */ +#else +# include +#endif + +#if USB_CFG_DRIVER_FLASH_PAGE +# define USB_READ_FLASH(addr) pgm_read_byte_far(((long)USB_CFG_DRIVER_FLASH_PAGE << 16) | (long)(addr)) +#else +# define USB_READ_FLASH(addr) pgm_read_byte(addr) +#endif + +#define macro .macro +#define endm .endm +#define nop2 rjmp .+0 /* jump to next instruction */ + +#endif /* development environment */ + +/* for conveniecne, ensure that PRG_RDB exists */ +#ifndef PRG_RDB +# define PRG_RDB(addr) USB_READ_FLASH(addr) +#endif +#endif /* __usbportability_h_INCLUDED__ */ diff --git a/protocol/vusb/vusb.c b/protocol/vusb/vusb.c new file mode 100644 index 000000000..7d0292ed1 --- /dev/null +++ b/protocol/vusb/vusb.c @@ -0,0 +1,496 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include "usbdrv.h" +#include "usbconfig.h" +#include "host.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "host_driver.h" +#include "vusb.h" + + +static uint8_t vusb_keyboard_leds = 0; +static uint8_t vusb_idle_rate = 0; + +/* Keyboard report send buffer */ +#define KBUF_SIZE 16 +static report_keyboard_t kbuf[KBUF_SIZE]; +static uint8_t kbuf_head = 0; +static uint8_t kbuf_tail = 0; + +typedef struct { + uint8_t modifier; + uint8_t reserved; + uint8_t keycode[6]; +} keyboard_report_t; + +static keyboard_report_t keyboard_report; // sent to PC + +/* transfer keyboard report from buffer */ +void vusb_transfer_keyboard(void) +{ + if (usbInterruptIsReady()) { + if (kbuf_head != kbuf_tail) { + usbSetInterrupt((void *)&kbuf[kbuf_tail], sizeof(report_keyboard_t)); + kbuf_tail = (kbuf_tail + 1) % KBUF_SIZE; + if (debug_keyboard) { + print("V-USB: kbuf["); pdec(kbuf_tail); print("->"); pdec(kbuf_head); print("]("); + phex((kbuf_head < kbuf_tail) ? (KBUF_SIZE - kbuf_tail + kbuf_head) : (kbuf_head - kbuf_tail)); + print(")\n"); + } + } + } +} + + +/*------------------------------------------------------------------* + * Host driver + *------------------------------------------------------------------*/ +static uint8_t keyboard_leds(void); +static void send_keyboard(report_keyboard_t *report); +static void send_mouse(report_mouse_t *report); +static void send_system(uint16_t data); +static void send_consumer(uint16_t data); + +static host_driver_t driver = { + keyboard_leds, + send_keyboard, + send_mouse, + send_system, + send_consumer +}; + +host_driver_t *vusb_driver(void) +{ + return &driver; +} + +static uint8_t keyboard_leds(void) { + return vusb_keyboard_leds; +} + +static void send_keyboard(report_keyboard_t *report) +{ + uint8_t next = (kbuf_head + 1) % KBUF_SIZE; + if (next != kbuf_tail) { + kbuf[kbuf_head] = *report; + kbuf_head = next; + } else { + debug("kbuf: full\n"); + } + + // NOTE: send key strokes of Macro + usbPoll(); + vusb_transfer_keyboard(); +} + + +typedef struct { + uint8_t report_id; + report_mouse_t report; +} __attribute__ ((packed)) vusb_mouse_report_t; + +static void send_mouse(report_mouse_t *report) +{ + vusb_mouse_report_t r = { + .report_id = REPORT_ID_MOUSE, + .report = *report + }; + if (usbInterruptIsReady3()) { + usbSetInterrupt3((void *)&r, sizeof(vusb_mouse_report_t)); + } +} + + +typedef struct { + uint8_t report_id; + uint16_t usage; +} __attribute__ ((packed)) report_extra_t; + +static void send_system(uint16_t data) +{ + static uint16_t last_data = 0; + if (data == last_data) return; + last_data = data; + + report_extra_t report = { + .report_id = REPORT_ID_SYSTEM, + .usage = data + }; + if (usbInterruptIsReady3()) { + usbSetInterrupt3((void *)&report, sizeof(report)); + } +} + +static void send_consumer(uint16_t data) +{ + static uint16_t last_data = 0; + if (data == last_data) return; + last_data = data; + + report_extra_t report = { + .report_id = REPORT_ID_CONSUMER, + .usage = data + }; + if (usbInterruptIsReady3()) { + usbSetInterrupt3((void *)&report, sizeof(report)); + } +} + + + +/*------------------------------------------------------------------* + * Request from host * + *------------------------------------------------------------------*/ +static struct { + uint16_t len; + enum { + NONE, + SET_LED + } kind; +} last_req; + +usbMsgLen_t usbFunctionSetup(uchar data[8]) +{ +usbRequest_t *rq = (void *)data; + + if((rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_CLASS){ /* class request type */ + if(rq->bRequest == USBRQ_HID_GET_REPORT){ + debug("GET_REPORT:"); + /* we only have one report type, so don't look at wValue */ + usbMsgPtr = (void *)&keyboard_report; + return sizeof(keyboard_report); + }else if(rq->bRequest == USBRQ_HID_GET_IDLE){ + debug("GET_IDLE: "); + //debug_hex(vusb_idle_rate); + usbMsgPtr = &vusb_idle_rate; + return 1; + }else if(rq->bRequest == USBRQ_HID_SET_IDLE){ + vusb_idle_rate = rq->wValue.bytes[1]; + debug("SET_IDLE: "); + debug_hex(vusb_idle_rate); + }else if(rq->bRequest == USBRQ_HID_SET_REPORT){ + debug("SET_REPORT: "); + // Report Type: 0x02(Out)/ReportID: 0x00(none) && Interface: 0(keyboard) + if (rq->wValue.word == 0x0200 && rq->wIndex.word == 0) { + debug("SET_LED: "); + last_req.kind = SET_LED; + last_req.len = rq->wLength.word; + } + return USB_NO_MSG; // to get data in usbFunctionWrite + } else { + debug("UNKNOWN:"); + } + }else{ + debug("VENDOR:"); + /* no vendor specific requests implemented */ + } + debug("\n"); + return 0; /* default for not implemented requests: return no data back to host */ +} + +uchar usbFunctionWrite(uchar *data, uchar len) +{ + if (last_req.len == 0) { + return -1; + } + switch (last_req.kind) { + case SET_LED: + debug("SET_LED: "); + debug_hex(data[0]); + debug("\n"); + vusb_keyboard_leds = data[0]; + last_req.len = 0; + return 1; + break; + case NONE: + default: + return -1; + break; + } + return 1; +} + + + +/*------------------------------------------------------------------* + * Descriptors * + *------------------------------------------------------------------*/ + +/* + * Report Descriptor for keyboard + * + * from an example in HID spec appendix + */ +const PROGMEM uchar keyboard_hid_report[] = { + 0x05, 0x01, // Usage Page (Generic Desktop), + 0x09, 0x06, // Usage (Keyboard), + 0xA1, 0x01, // Collection (Application), + 0x75, 0x01, // Report Size (1), + 0x95, 0x08, // Report Count (8), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0xE0, // Usage Minimum (224), + 0x29, 0xE7, // Usage Maximum (231), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0x01, // Logical Maximum (1), + 0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte + 0x95, 0x01, // Report Count (1), + 0x75, 0x08, // Report Size (8), + 0x81, 0x03, // Input (Constant), ;Reserved byte + 0x95, 0x05, // Report Count (5), + 0x75, 0x01, // Report Size (1), + 0x05, 0x08, // Usage Page (LEDs), + 0x19, 0x01, // Usage Minimum (1), + 0x29, 0x05, // Usage Maximum (5), + 0x91, 0x02, // Output (Data, Variable, Absolute), ;LED report + 0x95, 0x01, // Report Count (1), + 0x75, 0x03, // Report Size (3), + 0x91, 0x03, // Output (Constant), ;LED report padding + 0x95, 0x06, // Report Count (6), + 0x75, 0x08, // Report Size (8), + 0x15, 0x00, // Logical Minimum (0), + 0x25, 0xFF, // Logical Maximum(255), + 0x05, 0x07, // Usage Page (Key Codes), + 0x19, 0x00, // Usage Minimum (0), + 0x29, 0xFF, // Usage Maximum (255), + 0x81, 0x00, // Input (Data, Array), + 0xc0 // End Collection +}; + +/* + * Report Descriptor for mouse + * + * Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension + * http://www.microchip.com/forums/tm.aspx?high=&m=391435&mpage=1#391521 + * http://www.keil.com/forum/15671/ + * http://www.microsoft.com/whdc/device/input/wheel.mspx + */ +const PROGMEM uchar mouse_hid_report[] = { + /* mouse */ + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x02, // USAGE (Mouse) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, REPORT_ID_MOUSE, // REPORT_ID (1) + 0x09, 0x01, // USAGE (Pointer) + 0xa1, 0x00, // COLLECTION (Physical) + // ---------------------------- Buttons + 0x05, 0x09, // USAGE_PAGE (Button) + 0x19, 0x01, // USAGE_MINIMUM (Button 1) + 0x29, 0x05, // USAGE_MAXIMUM (Button 5) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x05, // REPORT_COUNT (5) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x75, 0x03, // REPORT_SIZE (3) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x03, // INPUT (Cnst,Var,Abs) + // ---------------------------- X,Y position + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x30, // USAGE (X) + 0x09, 0x31, // USAGE (Y) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x02, // REPORT_COUNT (2) + 0x81, 0x06, // INPUT (Data,Var,Rel) + // ---------------------------- Vertical wheel + 0x09, 0x38, // USAGE (Wheel) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical + 0x45, 0x00, // PHYSICAL_MAXIMUM (0) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x06, // INPUT (Data,Var,Rel) + // ---------------------------- Horizontal wheel + 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) + 0x0a, 0x38, 0x02, // USAGE (AC Pan) + 0x15, 0x81, // LOGICAL_MINIMUM (-127) + 0x25, 0x7f, // LOGICAL_MAXIMUM (127) + 0x75, 0x08, // REPORT_SIZE (8) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x06, // INPUT (Data,Var,Rel) + 0xc0, // END_COLLECTION + 0xc0, // END_COLLECTION + /* system control */ + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x80, // USAGE (System Control) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, REPORT_ID_SYSTEM, // REPORT_ID (2) + 0x15, 0x01, // LOGICAL_MINIMUM (0x1) + 0x25, 0xb7, // LOGICAL_MAXIMUM (0xb7) + 0x19, 0x01, // USAGE_MINIMUM (0x1) + 0x29, 0xb7, // USAGE_MAXIMUM (0xb7) + 0x75, 0x10, // REPORT_SIZE (16) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x00, // INPUT (Data,Array,Abs) + 0xc0, // END_COLLECTION + /* consumer */ + 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) + 0x09, 0x01, // USAGE (Consumer Control) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, REPORT_ID_CONSUMER, // REPORT_ID (3) + 0x15, 0x01, // LOGICAL_MINIMUM (0x1) + 0x26, 0x9c, 0x02, // LOGICAL_MAXIMUM (0x29c) + 0x19, 0x01, // USAGE_MINIMUM (0x1) + 0x2a, 0x9c, 0x02, // USAGE_MAXIMUM (0x29c) + 0x75, 0x10, // REPORT_SIZE (16) + 0x95, 0x01, // REPORT_COUNT (1) + 0x81, 0x00, // INPUT (Data,Array,Abs) + 0xc0, // END_COLLECTION +}; + + +/* + * Descriptor for compite device: Keyboard + Mouse + * + * contains: device, interface, HID and endpoint descriptors + */ +#if USB_CFG_DESCR_PROPS_CONFIGURATION +const PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */ + 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */ + USBDESCR_CONFIG, /* descriptor type */ + 9 + (9 + 9 + 7) + (9 + 9 + 7), 0, + //18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0, + /* total length of data returned (including inlined descriptors) */ + 2, /* number of interfaces in this configuration */ + 1, /* index of this configuration */ + 0, /* configuration name string index */ +#if USB_CFG_IS_SELF_POWERED + (1 << 7) | USBATTR_SELFPOWER, /* attributes */ +#else + (1 << 7), /* attributes */ +#endif + USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */ + + /* + * Keyboard interface + */ + /* Interface descriptor */ + 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */ + USBDESCR_INTERFACE, /* descriptor type */ + 0, /* index of this interface */ + 0, /* alternate setting for this interface */ + USB_CFG_HAVE_INTRIN_ENDPOINT, /* endpoints excl 0: number of endpoint descriptors to follow */ + USB_CFG_INTERFACE_CLASS, + USB_CFG_INTERFACE_SUBCLASS, + USB_CFG_INTERFACE_PROTOCOL, + 0, /* string index for interface */ + /* HID descriptor */ + 9, /* sizeof(usbDescrHID): length of descriptor in bytes */ + USBDESCR_HID, /* descriptor type: HID */ + 0x01, 0x01, /* BCD representation of HID version */ + 0x00, /* target country code */ + 0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */ + 0x22, /* descriptor type: report */ + sizeof(keyboard_hid_report), 0, /* total length of report descriptor */ + /* Endpoint descriptor */ +#if USB_CFG_HAVE_INTRIN_ENDPOINT /* endpoint descriptor for endpoint 1 */ + 7, /* sizeof(usbDescrEndpoint) */ + USBDESCR_ENDPOINT, /* descriptor type = endpoint */ + (char)0x81, /* IN endpoint number 1 */ + 0x03, /* attrib: Interrupt endpoint */ + 8, 0, /* maximum packet size */ + USB_CFG_INTR_POLL_INTERVAL, /* in ms */ +#endif + + /* + * Mouse interface + */ + /* Interface descriptor */ + 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */ + USBDESCR_INTERFACE, /* descriptor type */ + 1, /* index of this interface */ + 0, /* alternate setting for this interface */ + USB_CFG_HAVE_INTRIN_ENDPOINT3, /* endpoints excl 0: number of endpoint descriptors to follow */ + 0x03, /* CLASS: HID */ + 0, /* SUBCLASS: none */ + 0, /* PROTOCOL: none */ + 0, /* string index for interface */ + /* HID descriptor */ + 9, /* sizeof(usbDescrHID): length of descriptor in bytes */ + USBDESCR_HID, /* descriptor type: HID */ + 0x01, 0x01, /* BCD representation of HID version */ + 0x00, /* target country code */ + 0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */ + 0x22, /* descriptor type: report */ + sizeof(mouse_hid_report), 0, /* total length of report descriptor */ +#if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */ + /* Endpoint descriptor */ + 7, /* sizeof(usbDescrEndpoint) */ + USBDESCR_ENDPOINT, /* descriptor type = endpoint */ + (char)(0x80 | USB_CFG_EP3_NUMBER), /* IN endpoint number 3 */ + 0x03, /* attrib: Interrupt endpoint */ + 8, 0, /* maximum packet size */ + USB_CFG_INTR_POLL_INTERVAL, /* in ms */ +#endif +}; +#endif + + +USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) +{ + usbMsgLen_t len = 0; + +/* + debug("usbFunctionDescriptor: "); + debug_hex(rq->bmRequestType); debug(" "); + debug_hex(rq->bRequest); debug(" "); + debug_hex16(rq->wValue.word); debug(" "); + debug_hex16(rq->wIndex.word); debug(" "); + debug_hex16(rq->wLength.word); debug("\n"); +*/ + switch (rq->wValue.bytes[1]) { +#if USB_CFG_DESCR_PROPS_CONFIGURATION + case USBDESCR_CONFIG: + usbMsgPtr = (unsigned char *)usbDescriptorConfiguration; + len = sizeof(usbDescriptorConfiguration); + break; +#endif + case USBDESCR_HID: + switch (rq->wValue.bytes[0]) { + case 0: + usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + 9); + len = 9; + break; + case 1: + usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + (9 + 9 + 7) + 9); + len = 9; + break; + } + break; + case USBDESCR_HID_REPORT: + /* interface index */ + switch (rq->wIndex.word) { + case 0: + usbMsgPtr = keyboard_hid_report; + len = sizeof(keyboard_hid_report); + break; + case 1: + usbMsgPtr = mouse_hid_report; + len = sizeof(mouse_hid_report); + break; + } + break; + } + //debug("desc len: "); debug_hex(len); debug("\n"); + return len; +} diff --git a/protocol/vusb/vusb.h b/protocol/vusb/vusb.h new file mode 100644 index 000000000..5accf233b --- /dev/null +++ b/protocol/vusb/vusb.h @@ -0,0 +1,27 @@ +/* +Copyright 2011 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef VUSB_H +#define VUSB_H + +#include "host_driver.h" + + +host_driver_t *vusb_driver(void); +void vusb_transfer_keyboard(void); + +#endif diff --git a/rules.mk b/rules.mk new file mode 100644 index 000000000..d06756638 --- /dev/null +++ b/rules.mk @@ -0,0 +1,619 @@ +# Hey Emacs, this is a -*- makefile -*- +#---------------------------------------------------------------------------- +# WinAVR Makefile Template written by Eric B. Weddington, Jg Wunsch, et al. +# +# 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 +# +#---------------------------------------------------------------------------- +# 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. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# 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 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". +#---------------------------------------------------------------------------- + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = obj_$(TARGET) + + +# 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 = $(subst :, ,$(VPATH)) + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL +CDEFS += $(OPT_DEFS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) +ADEFS += $(OPT_DEFS) + + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS +CPPDEFS += $(OPT_DEFS) + + + +#---------------- 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=$(@:%.o=%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) +ifdef CONFIG_H + CFLAGS += -include $(CONFIG_H) +endif + + +#---------------- 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 += -ffunction-sections +CPPFLAGS += -fdata-sections +# to supress "warning: only initialized variables can be placed into program memory area" +CPPFLAGS += -w +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=$(@:%.o=%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) +ifdef CONFIG_H + CPPFLAGS += -include $(CONFIG_H) +endif + + +#---------------- 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=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 +ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +ifdef CONFIG_H + ASFLAGS += -include $(CONFIG_H) +endif + + +#---------------- 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 +# +# Comennt out "--relax" option to avoid a error such: +# (.vectors+0x30): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_12' +# +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 +# You can give EXTRALDFLAGS at 'make' command line. +LDFLAGS += $(EXTRALDFLAGS) + + + +#---------------- 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 +REMOVE = rm -f +REMOVEDIR = rmdir +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 = $(patsubst %.c,$(OBJDIR)/%.o,$(patsubst %.cpp,$(OBJDIR)/%.o,$(patsubst %.S,$(OBJDIR)/%.o,$(SRC)))) + +# Define all listing files. +LST = $(patsubst %.c,$(OBJDIR)/%.lst,$(patsubst %.cpp,$(OBJDIR)/%.lst,$(patsubst %.S,$(OBJDIR)/%.lst,$(SRC)))) + + +# Compiler flags to generate dependency files. +#GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d +GENDEPFLAGS = -MMD -MP -MF .dep/$(subst /,_,$@).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +# You can give extra flags at 'make' command line like: make EXTRAFLAGS=-DFOO=bar +ALL_CFLAGS = -mmcu=$(MCU) $(CFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -x c++ $(CPPFLAGS) $(GENDEPFLAGS) $(EXTRAFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) + + + + + +# 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=$(MCU) --format=avr $(TARGET).elf +ELFSIZE = $(SIZE) $(TARGET).elf + +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 + $(PROGRAM_CMD) + +teensy: $(TARGET).hex + teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex + +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 +ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) + dfu-programmer $(MCU) erase --force +else + dfu-programmer $(MCU) erase +endif + dfu-programmer $(MCU) erase + dfu-programmer $(MCU) flash $(TARGET).hex + dfu-programmer $(MCU) reset + +dfu-start: + dfu-programmer $(MCU) reset + dfu-programmer $(MCU) start + +flip-ee: $(TARGET).hex $(TARGET).eep + $(COPY) $(TARGET).eep $(TARGET)eep.hex + batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase + batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program + batchisp -hardware usb -device $(MCU) -operation start reset 0 + $(REMOVE) $(TARGET)eep.hex + +dfu-ee: $(TARGET).hex $(TARGET).eep + dfu-programmer $(MCU) eeprom-flash $(TARGET).eep + dfu-programmer $(MCU) reset + + +# Generate avr-gdb config/init file which does the following: +# define the reset signal, load the target file, connect to target, and set +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -z $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + mkdir -p $(@D) + @echo $(MSG_COMPILING) $< + $(CC) -c $(ALL_CFLAGS) $< -o $@ + + +# Compile: create object files from C++ source files. +$(OBJDIR)/%.o : %.cpp + @echo + mkdir -p $(@D) + @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 + mkdir -p $(@D) + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) $(CFLAGS) $< -o $@ + + +# Target: clean project. +clean: begin clean_list end + +clean_list : + @echo + $(REMOVE) $(TARGET).hex + $(REMOVE) $(TARGET).eep + $(REMOVE) $(TARGET).cof + $(REMOVE) $(TARGET).elf + $(REMOVE) $(TARGET).map + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(OBJ) + $(REMOVE) $(LST) + $(REMOVE) $(OBJ:.o=.s) + $(REMOVE) $(OBJ:.o=.i) + $(REMOVE) -r .dep + $(REMOVE) -r $(OBJDIR) + +show_path: + @echo VPATH=$(VPATH) + @echo SRC=$(SRC) + + +# 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 \ +clean clean_list debug gdb-config show_path \ +program teensy dfu flip dfu-ee flip-ee dfu-start diff --git a/tool/mbed/common.mk b/tool/mbed/common.mk new file mode 100644 index 000000000..77bf7c3e4 --- /dev/null +++ b/tool/mbed/common.mk @@ -0,0 +1,81 @@ +OBJECTS += \ + $(OBJDIR)/common/action.o \ + $(OBJDIR)/common/action_tapping.o \ + $(OBJDIR)/common/action_macro.o \ + $(OBJDIR)/common/action_layer.o \ + $(OBJDIR)/common/action_util.o \ + $(OBJDIR)/common/host.o \ + $(OBJDIR)/common/keymap.o \ + $(OBJDIR)/common/keyboard.o \ + $(OBJDIR)/common/print.o \ + $(OBJDIR)/common/debug.o \ + $(OBJDIR)/common/util.o \ + $(OBJDIR)/common/mbed/suspend.o \ + $(OBJDIR)/common/mbed/timer.o \ + $(OBJDIR)/common/mbed/xprintf.o \ + $(OBJDIR)/common/mbed/bootloader.o \ + +INCLUDE_PATHS += \ + -I$(TMK_DIR)/common \ + -I$(TMK_DIR)/protocol + +CC_FLAGS += -include $(CONFIG_H) + + + +# Option modules +ifdef BOOTMAGIC_ENABLE + $(error Not Supported) + OBJECTS += $(OBJDIR)/common/bootmagic.o + OBJECTS += $(OBJDIR)/common/mbed/eeprom.o + OPT_DEFS += -DBOOTMAGIC_ENABLE +endif + +ifdef MOUSEKEY_ENABLE + OBJECTS += $(OBJDIR)/common/mousekey.o + OPT_DEFS += -DMOUSEKEY_ENABLE + OPT_DEFS += -DMOUSE_ENABLE +endif + +ifdef EXTRAKEY_ENABLE + $(error Not Supported) + OPT_DEFS += -DEXTRAKEY_ENABLE +endif + +ifdef CONSOLE_ENABLE + $(error Not Supported) + OPT_DEFS += -DCONSOLE_ENABLE +else + OPT_DEFS += -DNO_PRINT + OPT_DEFS += -DNO_DEBUG +endif + +ifdef COMMAND_ENABLE + $(error Not Supported) + SRC += common/command.c + OPT_DEFS += -DCOMMAND_ENABLE +endif + +ifdef NKRO_ENABLE + $(error Not Supported) + OPT_DEFS += -DNKRO_ENABLE +endif + +ifdef SLEEP_LED_ENABLE + $(error Not Supported) + SRC += common/sleep_led.c + OPT_DEFS += -DSLEEP_LED_ENABLE + OPT_DEFS += -DNO_SUSPEND_POWER_DOWN +endif + +ifdef BACKLIGHT_ENABLE + $(error Not Supported) + SRC += common/backlight.c + OPT_DEFS += -DBACKLIGHT_ENABLE +endif + +ifdef KEYMAP_SECTION_ENABLE + $(error Not Supported) + OPT_DEFS += -DKEYMAP_SECTION_ENABLE + EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr5.x +endif diff --git a/tool/mbed/gcc.mk b/tool/mbed/gcc.mk new file mode 100644 index 000000000..b8c7336b4 --- /dev/null +++ b/tool/mbed/gcc.mk @@ -0,0 +1,89 @@ +# based on Makefile exported form mbed.org +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +GCC_BIN = +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump +SIZE = $(GCC_BIN)arm-none-eabi-size +CHKSUM = $(TMK_DIR)/tool/mbed/lpc-vector-checksum + +CC_FLAGS += \ + $(CPU) \ + -c \ + -g \ + -fno-common \ + -fmessage-length=0 \ + -Wall \ + -fno-exceptions \ + -ffunction-sections \ + -fdata-sections \ + -fomit-frame-pointer +CC_FLAGS += -MMD -MP + +LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs +#LD_FLAGS += -u _printf_float -u _scanf_float +LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + +all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex + +clean: + rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS) + rm -fr $(OBJDIR) + +$(OBJDIR)/%.o: %.s + mkdir -p $(@D) + $(AS) $(CPU) -o $@ $< + +$(OBJDIR)/%.o: %.c + mkdir -p $(@D) + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +$(OBJDIR)/%.o: %.cpp + mkdir -p $(@D) + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< + + +$(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + $(SIZE) $@ + +$(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf + @$(OBJCOPY) -O binary $< $@ +ifneq (,$(findstring TARGET_NXP,$(CC_SYMBOLS))) + @echo + @echo "For NXP writing vector checksum value into $@ ..." + @$(CHKSUM) $@ + @echo +endif + +$(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf + @$(OBJCOPY) -O ihex $< $@ + +$(OBJDIR)/$(PROJECT).lst: $(OBJDIR)/$(PROJECT).elf + @$(OBJDUMP) -Sdh $< > $@ + +lst: $(OBJDIR)/$(PROJECT).lst + +size: + $(SIZE) $(OBJDIR)/$(PROJECT).elf + +prog: $(OBJDIR)/$(PROJECT).bin + @echo "Program..." +ifneq ($(shell mount | grep 'CRP DISABLD'),) + umount /dev/nxpisp >/dev/null 2>&1 +endif + dd if=$< of=/dev/nxpisp seek=4 + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) diff --git a/tool/mbed/lpc-vector-checksum.c b/tool/mbed/lpc-vector-checksum.c new file mode 100644 index 000000000..316a1253a --- /dev/null +++ b/tool/mbed/lpc-vector-checksum.c @@ -0,0 +1,99 @@ +/*************************************************************************** +* https://github.com/dhylands/projects/blob/master/lpc/lpc-vector-checksum/lpc-vector-checksum.c +* +* Copyright (c) 2012 by Dave Hylands +* All Rights Reserved +* +* Permission is granted to any individual or institution to use, copy, +* modify, or redistribute this file so long as it is not sold for profit, +* and that this copyright notice is retained. +* +*************************************************************************** +* +* This program calculates the vector checksum used in LPC17xx binary +* images. +* +* Usage: lpc-vector-checksum file +* +***************************************************************************/ + +#include +#include +#include +#include +#include + +/***************************************************************************/ +/** +* update_vector_checksum +* +* The algorithim is to write the checksum such that the checksum of the +* first 8 words is equal to zero. +* +* The LPC1768 uses little-endian, and this particular routine assumes +* that it's running on a little-endian architecture. +*/ +static int update_vector_checksum( const char *filename ) +{ + uint32_t sum; + uint32_t header[8]; + FILE *fs; + int i; + + if (( fs = fopen( filename, "r+b" )) == NULL ) + { + fprintf( stderr, "Unable to open '%s' for reading/writing (%d): %s\n", + filename, errno, strerror( errno )); + return 0; + } + + if ( fread( header, sizeof( header ), 1, fs ) != 1 ) + { + fprintf( stderr, "Failed to read header from '%s' (perhaps the file is too small?)", + filename ); + fclose( fs ); + return 0; + } + + sum = 0; + for ( i = 0; i < 7; i++ ) + { + sum += header[i]; + } + printf( "sum = 0x%08x, value to write = 0x%08x\n", sum, -sum ); + + /* write back the checksum to location 7 + * http://sigalrm.blogspot.jp/2011/10/cortex-m3-exception-vector-checksum.html + */ + fseek(fs, 0x1c, SEEK_SET); + sum = -sum; + fwrite(&sum, 4, 1, fs); + + fclose( fs ); + + return 1; +} + +/***************************************************************************/ +/** +* main +*/ +int main( int argc, char **argv ) +{ + int arg; + + if ( argc < 2) + { + fprintf( stderr, "Usage: lpc-vector-checksum file ...\n" ); + exit( 1 ); + } + + for ( arg = 1; arg < argc; arg++ ) + { + update_vector_checksum( argv[ arg ]); + } + + exit( 0 ); + return 0; +} + diff --git a/tool/mbed/lpc11u35_501.mk b/tool/mbed/lpc11u35_501.mk new file mode 100644 index 000000000..328d03d66 --- /dev/null +++ b/tool/mbed/lpc11u35_501.mk @@ -0,0 +1,50 @@ +# based on Makefile exported form mbed.org +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +CPU = -mcpu=cortex-m0 -mthumb + +CC_SYMBOLS = \ + -DTARGET_LPC11U35_501 \ + -DTARGET_M0 \ + -DTARGET_CORTEX_M \ + -DTARGET_NXP \ + -DTARGET_LPC11UXX \ + -DTARGET_MCU_LPC11U35_501 \ + -DTOOLCHAIN_GCC_ARM \ + -DTOOLCHAIN_GCC \ + -D__CORTEX_M0 \ + -DARM_MATH_CM0 \ + -D__MBED__=1 + +OBJECTS += \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \ + $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \ + $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \ + $(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/PeripheralPins.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_irq_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \ + $(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o + +INCLUDE_PATHS += \ + -I$(MBED_DIR)/libraries/mbed/targets \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM \ + -I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_501 \ + -I$(MBED_DIR)/libraries/mbed/targets/hal \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501 \ + -I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/TARGET_LPC11U35_501 + +LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_501/LPC11U35.ld diff --git a/tool/mbed/mbed.mk b/tool/mbed/mbed.mk new file mode 100644 index 000000000..2657a0fd3 --- /dev/null +++ b/tool/mbed/mbed.mk @@ -0,0 +1,85 @@ +# based on Makefile exported form mbed.org +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +OBJECTS += \ + $(OBJDIR)/libraries/mbed/common/gpio.o \ + $(OBJDIR)/libraries/mbed/common/us_ticker_api.o \ + $(OBJDIR)/libraries/mbed/common/wait_api.o \ + $(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o + + +# $(OBJDIR)/libraries/mbed/common/assert.o \ +# $(OBJDIR)/libraries/mbed/common/board.o \ +# $(OBJDIR)/libraries/mbed/common/BusIn.o \ +# $(OBJDIR)/libraries/mbed/common/BusInOut.o \ +# $(OBJDIR)/libraries/mbed/common/BusOut.o \ +# $(OBJDIR)/libraries/mbed/common/CallChain.o \ +# $(OBJDIR)/libraries/mbed/common/CAN.o \ +# $(OBJDIR)/libraries/mbed/common/error.o \ +# $(OBJDIR)/libraries/mbed/common/Ethernet.o \ +# $(OBJDIR)/libraries/mbed/common/exit.o \ +# $(OBJDIR)/libraries/mbed/common/FileBase.o \ +# $(OBJDIR)/libraries/mbed/common/FileLike.o \ +# $(OBJDIR)/libraries/mbed/common/FilePath.o \ +# $(OBJDIR)/libraries/mbed/common/FileSystemLike.o \ +# $(OBJDIR)/libraries/mbed/common/FunctionPointer.o \ +# $(OBJDIR)/libraries/mbed/common/gpio.o \ +# $(OBJDIR)/libraries/mbed/common/I2C.o \ +# $(OBJDIR)/libraries/mbed/common/I2CSlave.o \ +# $(OBJDIR)/libraries/mbed/common/InterruptIn.o \ +# $(OBJDIR)/libraries/mbed/common/InterruptManager.o \ +# $(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \ +# $(OBJDIR)/libraries/mbed/common/mbed_interface.o \ +# $(OBJDIR)/libraries/mbed/common/pinmap_common.o \ +# $(OBJDIR)/libraries/mbed/common/RawSerial.o \ +# $(OBJDIR)/libraries/mbed/common/retarget.o \ +# $(OBJDIR)/libraries/mbed/common/rtc_time.o \ +# $(OBJDIR)/libraries/mbed/common/semihost_api.o \ +# $(OBJDIR)/libraries/mbed/common/SerialBase.o \ +# $(OBJDIR)/libraries/mbed/common/Serial.o \ +# $(OBJDIR)/libraries/mbed/common/SPI.o \ +# $(OBJDIR)/libraries/mbed/common/SPISlave.o \ +# $(OBJDIR)/libraries/mbed/common/Stream.o \ +# $(OBJDIR)/libraries/mbed/common/Ticker.o \ +# $(OBJDIR)/libraries/mbed/common/Timeout.o \ +# $(OBJDIR)/libraries/mbed/common/TimerEvent.o \ +# $(OBJDIR)/libraries/mbed/common/Timer.o \ +# $(OBJDIR)/libraries/mbed/common/us_ticker_api.o \ +# $(OBJDIR)/libraries/mbed/common/wait_api.o \ +# $(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.o \ +# $(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \ +# $(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \ +# $(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \ +# $(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \ +# $(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \ +# $(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o \ +# $(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \ +# $(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \ +# $(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o + +INCLUDE_PATHS += \ + -I$(MBED_DIR)/libraries/mbed \ + -I$(MBED_DIR)/libraries/mbed/api \ + -I$(MBED_DIR)/libraries/mbed/common \ + -I$(MBED_DIR)/libraries/mbed/hal \ + -I$(MBED_DIR)/libraries/USBDevice \ + -I$(MBED_DIR)/libraries/USBDevice/USBAudio \ + -I$(MBED_DIR)/libraries/USBDevice/USBDevice \ + -I$(MBED_DIR)/libraries/USBDevice/USBHID \ + -I$(MBED_DIR)/libraries/USBDevice/USBMIDI \ + -I$(MBED_DIR)/libraries/USBDevice/USBMSD \ + -I$(MBED_DIR)/libraries/USBDevice/USBSerial + +# TMK mbed protocol +OBJECTS += \ + $(OBJDIR)/protocol/mbed/mbed_driver.o \ + $(OBJDIR)/protocol/mbed/HIDKeyboard.o + +INCLUDE_PATHS += \ + -I$(TMK_DIR)/protocol/mbed