├── .gitignore ├── Bootloaders └── arduino-usbdfu │ ├── Arduino-usbdfu.c │ ├── Arduino-usbdfu.h │ ├── Board │ └── LEDs.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── README.md │ └── makefile ├── LICENSE ├── LUFA ├── Common │ ├── Attributes.h │ ├── BoardTypes.h │ └── Common.h ├── Doxygen.conf ├── DriverStubs │ ├── Buttons.h │ ├── Dataflash.h │ ├── Joystick.h │ └── LEDs.h ├── Drivers │ ├── Board │ │ ├── ATAVRUSBRF01 │ │ │ ├── Buttons.h │ │ │ └── LEDs.h │ │ ├── BENITO │ │ │ ├── Buttons.h │ │ │ └── LEDs.h │ │ ├── BUMBLEB │ │ │ ├── Buttons.h │ │ │ ├── Joystick.h │ │ │ └── LEDs.h │ │ ├── Buttons.h │ │ ├── Dataflash.h │ │ ├── EVK527 │ │ │ ├── AT45DB321C.h │ │ │ ├── Buttons.h │ │ │ ├── Dataflash.h │ │ │ ├── Joystick.h │ │ │ └── LEDs.h │ │ ├── JMDBU2 │ │ │ ├── Buttons.h │ │ │ └── LEDs.h │ │ ├── Joystick.h │ │ ├── LEDs.h │ │ ├── RZUSBSTICK │ │ │ └── LEDs.h │ │ ├── STK525 │ │ │ ├── AT45DB321C.h │ │ │ ├── Buttons.h │ │ │ ├── Dataflash.h │ │ │ ├── Joystick.h │ │ │ └── LEDs.h │ │ ├── STK526 │ │ │ ├── AT45DB642D.h │ │ │ ├── Buttons.h │ │ │ ├── Dataflash.h │ │ │ ├── Joystick.h │ │ │ └── LEDs.h │ │ ├── TEENSY │ │ │ └── LEDs.h │ │ ├── Temperature.c │ │ ├── Temperature.h │ │ ├── USBKEY │ │ │ ├── AT45DB642D.h │ │ │ ├── Buttons.h │ │ │ ├── Dataflash.h │ │ │ ├── Joystick.h │ │ │ └── LEDs.h │ │ ├── USBTINYMKII │ │ │ ├── Buttons.h │ │ │ └── LEDs.h │ │ └── XPLAIN │ │ │ ├── AT45DB642D.h │ │ │ ├── Dataflash.h │ │ │ └── LEDs.h │ ├── Misc │ │ └── TerminalCodes.h │ ├── Peripheral │ │ ├── ADC.h │ │ ├── AVRU4U6U7 │ │ │ ├── ADC.h │ │ │ └── TWI.h │ │ ├── SPI.h │ │ ├── Serial.c │ │ ├── Serial.h │ │ ├── SerialStream.c │ │ ├── SerialStream.h │ │ ├── TWI.c │ │ └── TWI.h │ └── USB │ │ ├── Class │ │ ├── Audio.h │ │ ├── CDC.h │ │ ├── Common │ │ │ ├── Audio.h │ │ │ ├── CDC.h │ │ │ ├── HID.h │ │ │ ├── MIDI.h │ │ │ ├── MassStorage.h │ │ │ ├── Printer.h │ │ │ ├── RNDIS.h │ │ │ ├── RNDISConstants.h │ │ │ └── StillImage.h │ │ ├── Device │ │ │ ├── Audio.c │ │ │ ├── Audio.h │ │ │ ├── CDC.c │ │ │ ├── CDC.h │ │ │ ├── HID.c │ │ │ ├── HID.h │ │ │ ├── MIDI.c │ │ │ ├── MIDI.h │ │ │ ├── MassStorage.c │ │ │ ├── MassStorage.h │ │ │ ├── RNDIS.c │ │ │ └── RNDIS.h │ │ ├── HID.h │ │ ├── Host │ │ │ ├── CDC.c │ │ │ ├── CDC.h │ │ │ ├── HID.c │ │ │ ├── HID.h │ │ │ ├── HIDParser.c │ │ │ ├── HIDParser.h │ │ │ ├── HIDReportData.h │ │ │ ├── MIDI.c │ │ │ ├── MIDI.h │ │ │ ├── MassStorage.c │ │ │ ├── MassStorage.h │ │ │ ├── Printer.c │ │ │ ├── Printer.h │ │ │ ├── RNDIS.c │ │ │ ├── RNDIS.h │ │ │ ├── StillImage.c │ │ │ └── StillImage.h │ │ ├── MIDI.h │ │ ├── MassStorage.h │ │ ├── Printer.h │ │ ├── RNDIS.h │ │ └── StillImage.h │ │ ├── HighLevel │ │ ├── ConfigDescriptor.c │ │ ├── ConfigDescriptor.h │ │ ├── DeviceStandardReq.c │ │ ├── DeviceStandardReq.h │ │ ├── Events.c │ │ ├── Events.h │ │ ├── HostStandardReq.c │ │ ├── HostStandardReq.h │ │ ├── StdDescriptors.h │ │ ├── StdRequestType.h │ │ ├── StreamCallbacks.h │ │ ├── USBMode.h │ │ ├── USBTask.c │ │ └── USBTask.h │ │ ├── LowLevel │ │ ├── Device.c │ │ ├── Device.h │ │ ├── Endpoint.c │ │ ├── Endpoint.h │ │ ├── Host.c │ │ ├── Host.h │ │ ├── OTG.h │ │ ├── Pipe.c │ │ ├── Pipe.h │ │ ├── Template │ │ │ ├── Template_Endpoint_Control_R.c │ │ │ ├── Template_Endpoint_Control_W.c │ │ │ ├── Template_Endpoint_RW.c │ │ │ └── Template_Pipe_RW.c │ │ ├── USBController.c │ │ ├── USBController.h │ │ ├── USBInterrupt.c │ │ └── USBInterrupt.h │ │ └── USB.h ├── License.txt ├── ManPages │ ├── AboutLUFA.txt │ ├── AlternativeStacks.txt │ ├── Author.jpg │ ├── BuildingLinkableLibraries.txt │ ├── ChangeLog.txt │ ├── CompileTimeTokens.txt │ ├── CompilingApps.txt │ ├── ConfiguringApps.txt │ ├── DevelopingWithLUFA.txt │ ├── DeviceSupport.txt │ ├── DirectorySummaries.txt │ ├── Donating.txt │ ├── FutureChanges.txt │ ├── GettingStarted.txt │ ├── Groups.txt │ ├── LUFA.png │ ├── LUFAPoweredProjects.txt │ ├── LUFAvsAtmelStack.txt │ ├── LibraryApps.txt │ ├── LibraryResources.txt │ ├── LicenseInfo.txt │ ├── MainPage.txt │ ├── MigrationInformation.txt │ ├── ProgrammingApps.txt │ ├── SchedulerOverview.txt │ ├── SoftwareBootloaderJump.txt │ ├── VIDAndPIDValues.txt │ ├── WhyUseLUFA.txt │ └── WritingBoardDrivers.txt ├── Scheduler │ ├── Scheduler.c │ └── Scheduler.h ├── Version.h └── makefile ├── Projects └── arduino-usbserial │ ├── Arduino-usbserial.c │ ├── Arduino-usbserial.h │ ├── Board │ └── LEDs.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── Lib │ └── LightweightRingBuff.h │ ├── README.md │ └── makefile ├── README.md └── hexfiles ├── Arduino-COMBINED-dfu-usbserial-atmega16u2-Uno-Rev3.hex ├── Arduino-flashimage-atmega16u2-Uno-Rev3.hex ├── Genuino-COMBINED-dfu-usbserial-atmega16u2-Uno-R3.hex └── optiboot_atmega328.hex /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.d 3 | *.elf 4 | *.hex 5 | *.eep 6 | *.sym 7 | *.bin 8 | *.lss 9 | *.map 10 | *.bak 11 | *.class 12 | Documentation/ 13 | LUFA/StudioIntegration/ProjectGenerator/* 14 | LUFA/StudioIntegration/DocBook/* 15 | !LUFA/StudioIntegration/Docbook/mshelp/* 16 | -------------------------------------------------------------------------------- /Bootloaders/arduino-usbdfu/Board/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /* 32 | Board LEDs driver for the Benito board, from www.dorkbotpdx.org. 33 | */ 34 | 35 | #ifndef __LEDS_ARDUINOUNO_H__ 36 | #define __LEDS_ARDUINOUNO_H__ 37 | 38 | /* Includes: */ 39 | #include 40 | 41 | /* Enable C linkage for C++ Compilers: */ 42 | #if defined(__cplusplus) 43 | extern "C" { 44 | #endif 45 | 46 | /* Preprocessor Checks: */ 47 | #if !defined(INCLUDE_FROM_LEDS_H) 48 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 49 | #endif 50 | 51 | /* Public Interface - May be used in end-application: */ 52 | /* Macros: */ 53 | /** LED mask for the first LED on the board. */ 54 | #define LEDS_LED1 (1 << 5) 55 | 56 | /** LED mask for the second LED on the board. */ 57 | #define LEDS_LED2 (1 << 4) 58 | 59 | /** LED mask for all the LEDs on the board. */ 60 | #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) 61 | 62 | /** LED mask for the none of the board LEDs */ 63 | #define LEDS_NO_LEDS 0 64 | 65 | /* Inline Functions: */ 66 | #if !defined(__DOXYGEN__) 67 | static inline void LEDs_Init(void) 68 | { 69 | DDRD |= LEDS_ALL_LEDS; 70 | PORTD |= LEDS_ALL_LEDS; 71 | } 72 | 73 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 74 | { 75 | PORTD &= ~LEDMask; 76 | } 77 | 78 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 79 | { 80 | PORTD |= LEDMask; 81 | } 82 | 83 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 84 | { 85 | PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); 86 | } 87 | 88 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) 89 | { 90 | PORTD = ((PORTD | ActiveMask) & ~LEDMask); 91 | } 92 | 93 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 94 | { 95 | PORTD ^= LEDMask; 96 | } 97 | 98 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 99 | static inline uint8_t LEDs_GetLEDs(void) 100 | { 101 | return (PORTD & LEDS_ALL_LEDS); 102 | } 103 | #endif 104 | 105 | /* Disable C linkage for C++ Compilers: */ 106 | #if defined(__cplusplus) 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Bootloaders/arduino-usbdfu/README.md: -------------------------------------------------------------------------------- 1 | # Arduino USB DFU bootloader 2 | 3 | To setup the project and program an ATmega16u2 with the Arduino USB DFU bootloader: 4 | 5 | 1. unpack the source into LUFA's Bootloader directory 6 | 2. set `ARDUINO_MODEL_PID` in the makefile as appropriate 7 | 3. do "make clean; make; make program" 8 | 9 | Check that the board enumerates as either `Arduino Uno DFU` or `Arduino Mega 2560 DFU`. Test by uploading the Arduino-usbserial application firmware (see instructions in Arduino-usbserial directory) 10 | 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright © 2016 Kenji Rikitake 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /LUFA/DriverStubs/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /* 32 | This is a stub driver header file, for implementing custom board 33 | layout hardware with compatible LUFA board specific drivers. If 34 | the library is configured to use the BOARD_USER board mode, this 35 | driver file should be completed and copied into the "/Board/" folder 36 | inside the application's folder. 37 | 38 | This stub is for the board-specific component of the LUFA Buttons driver, 39 | for the control of physical board-mounted GPIO pushbuttons. 40 | */ 41 | 42 | #ifndef __BUTTONS_USER_H__ 43 | #define __BUTTONS_USER_H__ 44 | 45 | /* Includes: */ 46 | #include 47 | #include 48 | 49 | // TODO: Add any required includes here 50 | 51 | /* Enable C linkage for C++ Compilers: */ 52 | #if defined(__cplusplus) 53 | extern "C" { 54 | #endif 55 | 56 | /* Preprocessor Checks: */ 57 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 58 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 59 | #endif 60 | 61 | /* Public Interface - May be used in end-application: */ 62 | /* Macros: */ 63 | /** Button mask for the first button on the board. */ 64 | #define BUTTONS_BUTTON1 // TODO: Add mask for first board button here 65 | 66 | /* Inline Functions: */ 67 | #if !defined(__DOXYGEN__) 68 | static inline void Buttons_Init(void) 69 | { 70 | // TODO: Initialize the appropriate port pins as an inputs here, with pull-ups 71 | } 72 | 73 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 74 | static inline uint8_t Buttons_GetStatus(void) 75 | { 76 | // TODO: Return current button status here, debounced if required 77 | } 78 | #endif 79 | 80 | /* Disable C linkage for C++ Compilers: */ 81 | #if defined(__cplusplus) 82 | } 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /LUFA/DriverStubs/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /* 32 | This is a stub driver header file, for implementing custom board 33 | layout hardware with compatible LUFA board specific drivers. If 34 | the library is configured to use the BOARD_USER board mode, this 35 | driver file should be completed and copied into the "/Board/" folder 36 | inside the application's folder. 37 | 38 | This stub is for the board-specific component of the LUFA Joystick 39 | driver, a small surface mount four-way (plus button) digital joystick 40 | on most USB AVR boards. 41 | */ 42 | 43 | #ifndef __JOYSTICK_USER_H__ 44 | #define __JOYSTICK_USER_H__ 45 | 46 | /* Includes: */ 47 | #include 48 | 49 | // TODO: Add any required includes here 50 | 51 | /* Enable C linkage for C++ Compilers: */ 52 | #if defined(__cplusplus) 53 | extern "C" { 54 | #endif 55 | 56 | /* Preprocessor Checks: */ 57 | #if !defined(__INCLUDE_FROM_JOYSTICK_H) 58 | #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. 59 | #endif 60 | 61 | /* Public Interface - May be used in end-application: */ 62 | /* Macros: */ 63 | /** Mask for the joystick being pushed in the left direction. */ 64 | #define JOY_LEFT // TODO: Add mask to indicate joystick left position here 65 | 66 | /** Mask for the joystick being pushed in the right direction. */ 67 | #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here 68 | 69 | /** Mask for the joystick being pushed in the upward direction. */ 70 | #define JOY_UP // TODO: Add mask to indicate joystick up position here 71 | 72 | /** Mask for the joystick being pushed in the downward direction. */ 73 | #define JOY_DOWN // TODO: Add mask to indicate joystick down position here 74 | 75 | /** Mask for the joystick being pushed inward. */ 76 | #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here 77 | 78 | /* Inline Functions: */ 79 | #if !defined(__DOXYGEN__) 80 | static inline void Joystick_Init(void) 81 | { 82 | // TODO: Initialize joystick port pins as inputs with pull-ups 83 | } 84 | 85 | static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 86 | static inline uint8_t Joystick_GetStatus(void) 87 | { 88 | // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros 89 | } 90 | #endif 91 | 92 | /* Disable C linkage for C++ Compilers: */ 93 | #if defined(__cplusplus) 94 | } 95 | #endif 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/ATAVRUSBRF01/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the ATAVRUSBRF01. 33 | * 34 | * Board specific Buttons driver header for the ATAVRUSBRF01. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_ATAVRUSBRF01 ATAVRUSBRF01 42 | * 43 | * Board specific Buttons driver header for the ATAVRUSBRF01. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_ATAVRUSBRF01_H__ 52 | #define __BUTTONS_ATAVRUSBRF01_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Enable C linkage for C++ Compilers: */ 61 | #if defined(__cplusplus) 62 | extern "C" { 63 | #endif 64 | 65 | /* Preprocessor Checks: */ 66 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 67 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 68 | #endif 69 | 70 | /* Public Interface - May be used in end-application: */ 71 | /* Macros: */ 72 | /** Button mask for the first button on the board. */ 73 | #define BUTTONS_BUTTON1 (1 << 7) 74 | 75 | /* Inline Functions: */ 76 | #if !defined(__DOXYGEN__) 77 | static inline void Buttons_Init(void) 78 | { 79 | DDRD &= ~BUTTONS_BUTTON1; 80 | PORTD |= BUTTONS_BUTTON1; 81 | } 82 | 83 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 84 | static inline uint8_t Buttons_GetStatus(void) 85 | { 86 | return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 87 | } 88 | #endif 89 | 90 | /* Disable C linkage for C++ Compilers: */ 91 | #if defined(__cplusplus) 92 | } 93 | #endif 94 | 95 | #endif 96 | 97 | /** @} */ 98 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/BENITO/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the Benito. 33 | * 34 | * Board specific Buttons driver header for the Benito (http://dorkbotpdx.org/wiki/benito). 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_BENITO BENITO 42 | * 43 | * Board specific Buttons driver header for the Benito (http://dorkbotpdx.org/wiki/benito). 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_BENITO_H__ 52 | #define __BUTTONS_BENITO_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Enable C linkage for C++ Compilers: */ 61 | #if defined(__cplusplus) 62 | extern "C" { 63 | #endif 64 | 65 | /* Preprocessor Checks: */ 66 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 67 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 68 | #endif 69 | 70 | /* Public Interface - May be used in end-application: */ 71 | /* Macros: */ 72 | /** Button mask for the first button on the board. */ 73 | #define BUTTONS_BUTTON1 (1 << 7) 74 | 75 | /* Inline Functions: */ 76 | #if !defined(__DOXYGEN__) 77 | static inline void Buttons_Init(void) 78 | { 79 | DDRD &= ~BUTTONS_BUTTON1; 80 | PORTD |= BUTTONS_BUTTON1; 81 | } 82 | 83 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 84 | static inline uint8_t Buttons_GetStatus(void) 85 | { 86 | return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 87 | } 88 | #endif 89 | 90 | /* Disable C linkage for C++ Compilers: */ 91 | #if defined(__cplusplus) 92 | } 93 | #endif 94 | 95 | #endif 96 | 97 | /** @} */ 98 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/BENITO/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific LED driver header for the Benito. 33 | * 34 | * Board specific LED driver header for the Benito (http://dorkbotpdx.org/wiki/benito). 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 37 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 38 | */ 39 | 40 | /** \ingroup Group_LEDs 41 | * @defgroup Group_LEDs_BENITO BENITO 42 | * 43 | * Board specific LED driver header for the Benito (http://dorkbotpdx.org/wiki/benito). 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 46 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __LEDS_BENITO_H__ 52 | #define __LEDS_BENITO_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | /* Enable C linkage for C++ Compilers: */ 58 | #if defined(__cplusplus) 59 | extern "C" { 60 | #endif 61 | 62 | /* Preprocessor Checks: */ 63 | #if !defined(INCLUDE_FROM_LEDS_H) 64 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 65 | #endif 66 | 67 | /* Public Interface - May be used in end-application: */ 68 | /* Macros: */ 69 | /** LED mask for the first LED on the board. */ 70 | #define LEDS_LED1 (1 << 7) 71 | 72 | /** LED mask for the second LED on the board. */ 73 | #define LEDS_LED2 (1 << 6) 74 | 75 | /** LED mask for all the LEDs on the board. */ 76 | #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) 77 | 78 | /** LED mask for the none of the board LEDs. */ 79 | #define LEDS_NO_LEDS 0 80 | 81 | /* Inline Functions: */ 82 | #if !defined(__DOXYGEN__) 83 | static inline void LEDs_Init(void) 84 | { 85 | DDRC |= LEDS_ALL_LEDS; 86 | PORTC |= LEDS_ALL_LEDS; 87 | } 88 | 89 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 90 | { 91 | PORTC &= ~LEDMask; 92 | } 93 | 94 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 95 | { 96 | PORTC |= LEDMask; 97 | } 98 | 99 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 100 | { 101 | PORTC = ((PORTC | LEDS_ALL_LEDS) & ~LEDMask); 102 | } 103 | 104 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, 105 | const uint8_t ActiveMask) 106 | { 107 | PORTC = ((PORTC | ActiveMask) & ~LEDMask); 108 | } 109 | 110 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 111 | { 112 | PORTC ^= LEDMask; 113 | } 114 | 115 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 116 | static inline uint8_t LEDs_GetLEDs(void) 117 | { 118 | return (PORTC & LEDS_ALL_LEDS); 119 | } 120 | #endif 121 | 122 | /* Disable C linkage for C++ Compilers: */ 123 | #if defined(__cplusplus) 124 | } 125 | #endif 126 | 127 | #endif 128 | 129 | /** @} */ 130 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/BUMBLEB/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the BUMBLEB. 33 | * 34 | * Board specific Buttons driver header for the BUMBLEB (http://fletchtronics.net/bumble-b). 35 | * 36 | * The BUMBLEB third-party board does not include any on-board peripherals, but does have an officially recommended 37 | * external peripheral layout for buttons, LEDs and a Joystick. 38 | * 39 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 40 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 41 | */ 42 | 43 | /** \ingroup Group_Buttons 44 | * @defgroup Group_Buttons_BUMBLEB BUMBLEB 45 | * 46 | * Board specific buttons driver header for the BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB third-party 47 | * board does not include any on-board peripherals, but does have an officially recommended external peripheral layout 48 | * for buttons, LEDs and a Joystick. 49 | * 50 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 51 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 52 | * 53 | * @{ 54 | */ 55 | 56 | #ifndef __BUTTONS_BUMBLEB_H__ 57 | #define __BUTTONS_BUMBLEB_H__ 58 | 59 | /* Includes: */ 60 | #include 61 | #include 62 | 63 | #include "../../../Common/Common.h" 64 | 65 | /* Enable C linkage for C++ Compilers: */ 66 | #if defined(__cplusplus) 67 | extern "C" { 68 | #endif 69 | 70 | /* Preprocessor Checks: */ 71 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 72 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 73 | #endif 74 | 75 | /* Public Interface - May be used in end-application: */ 76 | /* Macros: */ 77 | /** Button mask for the first button on the board. */ 78 | #define BUTTONS_BUTTON1 (1 << 7) 79 | 80 | /* Inline Functions: */ 81 | #if !defined(__DOXYGEN__) 82 | static inline void Buttons_Init(void) 83 | { 84 | DDRD &= ~BUTTONS_BUTTON1; 85 | PORTD |= BUTTONS_BUTTON1; 86 | } 87 | 88 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 89 | static inline uint8_t Buttons_GetStatus(void) 90 | { 91 | return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 92 | } 93 | #endif 94 | 95 | /* Disable C linkage for C++ Compilers: */ 96 | #if defined(__cplusplus) 97 | } 98 | #endif 99 | 100 | #endif 101 | 102 | /** @} */ 103 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/EVK527/AT45DB321C.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Dataflash commands header for the AT45DB321C as mounted on the EVK527. 33 | * 34 | * Board specific Dataflash commands header for the AT45DB321C as mounted on the EVK527. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the dataflash driver 37 | * dispatch header located in LUFA/Drivers/Board/Dataflash.h. 38 | */ 39 | 40 | /** \ingroup Group_Dataflash_EVK527 41 | * @defgroup Group_Dataflash_EVK527_AT45DB321C AT45DB321C 42 | * 43 | * Board specific Dataflash commands header for the AT45DB321C as mounted on the EVK527. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the dataflash driver 46 | * dispatch header located in LUFA/Drivers/Board/Dataflash.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __DATAFLASH_CMDS_H__ 52 | #define __DATAFLASH_CMDS_H__ 53 | 54 | /* Public Interface - May be used in end-application: */ 55 | /* Macros: */ 56 | #define DF_STATUS_READY (1 << 7) 57 | #define DF_STATUS_COMPMISMATCH (1 << 6) 58 | #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) 59 | 60 | #define DF_MANUFACTURER_ATMEL 0x1F 61 | 62 | #define DF_CMD_GETSTATUS 0xD7 63 | 64 | #define DF_CMD_MAINMEMTOBUFF1 0x53 65 | #define DF_CMD_MAINMEMTOBUFF2 0x55 66 | #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 67 | #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 68 | #define DF_CMD_AUTOREWRITEBUFF1 0x58 69 | #define DF_CMD_AUTOREWRITEBUFF2 0x59 70 | 71 | #define DF_CMD_MAINMEMPAGEREAD 0xD2 72 | #define DF_CMD_CONTARRAYREAD_LF 0xE8 73 | #define DF_CMD_BUFF1READ_LF 0xD4 74 | #define DF_CMD_BUFF2READ_LF 0xD6 75 | 76 | #define DF_CMD_BUFF1WRITE 0x84 77 | #define DF_CMD_BUFF2WRITE 0x87 78 | #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 79 | #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 80 | #define DF_CMD_BUFF1TOMAINMEM 0x88 81 | #define DF_CMD_BUFF2TOMAINMEM 0x89 82 | #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 83 | #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 84 | 85 | #define DF_CMD_PAGEERASE 0x81 86 | #define DF_CMD_BLOCKERASE 0x50 87 | 88 | #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF}) 89 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D 90 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A 91 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F 92 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF 93 | 94 | #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F 95 | 96 | #endif 97 | 98 | /** @} */ 99 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/EVK527/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the EVK527. 33 | * 34 | * Board specific Buttons driver header for the EVK527. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_EVK527 EVK527 42 | * 43 | * Board specific Buttons driver header for the EVK527. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_EVK527_H__ 52 | #define __BUTTONS_EVK527_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Includes: */ 61 | #include 62 | #include 63 | 64 | #include "../../../Common/Common.h" 65 | 66 | /* Enable C linkage for C++ Compilers: */ 67 | #if defined(__cplusplus) 68 | extern "C" { 69 | #endif 70 | 71 | /* Preprocessor Checks: */ 72 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 73 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 74 | #endif 75 | 76 | /* Public Interface - May be used in end-application: */ 77 | /* Macros: */ 78 | /** Button mask for the first button on the board. */ 79 | #define BUTTONS_BUTTON1 (1 << 2) 80 | 81 | /* Inline Functions: */ 82 | #if !defined(__DOXYGEN__) 83 | static inline void Buttons_Init(void) 84 | { 85 | DDRE &= ~BUTTONS_BUTTON1; 86 | PORTE |= BUTTONS_BUTTON1; 87 | } 88 | 89 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 90 | static inline uint8_t Buttons_GetStatus(void) 91 | { 92 | return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 93 | } 94 | #endif 95 | 96 | /* Disable C linkage for C++ Compilers: */ 97 | #if defined(__cplusplus) 98 | } 99 | #endif 100 | 101 | #endif 102 | 103 | /** @} */ 104 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/EVK527/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific joystick driver header for the EVK527. 33 | * 34 | * Board specific joystick driver header for the EVK527. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 37 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 38 | */ 39 | 40 | /** \ingroup Group_Joystick 41 | * @defgroup Group_Joystick_EVK527 EVK527 42 | * 43 | * Board specific joystick driver header for the EVK527. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 46 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __JOYSTICK_EVK527_H__ 52 | #define __JOYSTICK_EVK527_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_JOYSTICK_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. 67 | #endif 68 | 69 | /* Private Interface - For use in library only: */ 70 | #if !defined(__DOXYGEN__) 71 | /* Macros: */ 72 | #define JOY_FMASK ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7)) 73 | #define JOY_CMASK (1 << 6)) 74 | #endif 75 | 76 | /* Public Interface - May be used in end-application: */ 77 | /* Macros: */ 78 | /** Mask for the joystick being pushed in the left direction. */ 79 | #define JOY_LEFT (1 << 4) 80 | 81 | /** Mask for the joystick being pushed in the right direction. */ 82 | #define JOY_RIGHT (1 << 7) 83 | 84 | /** Mask for the joystick being pushed in the upward direction. */ 85 | #define JOY_UP (1 << 5) 86 | 87 | /** Mask for the joystick being pushed in the downward direction. */ 88 | #define JOY_DOWN ((1 << 6) >> 3) 89 | 90 | /** Mask for the joystick being pushed inward. */ 91 | #define JOY_PRESS (1 << 6) 92 | 93 | /* Inline Functions: */ 94 | #if !defined(__DOXYGEN__) 95 | static inline void Joystick_Init(void) 96 | { 97 | DDRF &= ~(JOY_FMASK); 98 | DDRC &= ~(JOY_CMASK); 99 | 100 | PORTF |= JOY_FMASK; 101 | PORTC |= JOY_CMASK; 102 | } 103 | 104 | static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 105 | static inline uint8_t Joystick_GetStatus(void) 106 | { 107 | return (((uint8_t)~PINF & JOY_FMASK) | (((uint8_t)~PINC & JOY_CMASK) >> 3)); 108 | } 109 | #endif 110 | 111 | /* Disable C linkage for C++ Compilers: */ 112 | #if defined(__cplusplus) 113 | } 114 | #endif 115 | 116 | #endif 117 | 118 | /** @} */ 119 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/JMDBU2/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the JM-DB-U2. 33 | * 34 | * Board specific Buttons driver header for the JM-DB-U2 (http://u2.mattair.net/index.html). 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_JMDBU2 JMDBU2 42 | * 43 | * Board specific Buttons driver header for the JM-DB-U2 (http://u2.mattair.net/index.html). 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_JMDBU2_H__ 52 | #define __BUTTONS_JMDBU2_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Enable C linkage for C++ Compilers: */ 61 | #if defined(__cplusplus) 62 | extern "C" { 63 | #endif 64 | 65 | /* Preprocessor Checks: */ 66 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 67 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 68 | #endif 69 | 70 | /* Public Interface - May be used in end-application: */ 71 | /* Macros: */ 72 | /** Button mask for the first button on the board. */ 73 | #define BUTTONS_BUTTON1 (1 << 7) 74 | 75 | /* Inline Functions: */ 76 | #if !defined(__DOXYGEN__) 77 | static inline void Buttons_Init(void) 78 | { 79 | DDRD &= ~BUTTONS_BUTTON1; 80 | PORTD |= BUTTONS_BUTTON1; 81 | } 82 | 83 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 84 | static inline uint8_t Buttons_GetStatus(void) 85 | { 86 | return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 87 | } 88 | #endif 89 | 90 | /* Disable C linkage for C++ Compilers: */ 91 | #if defined(__cplusplus) 92 | } 93 | #endif 94 | 95 | #endif 96 | 97 | /** @} */ 98 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/JMDBU2/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific LED driver header for the JM-DB-U2. 33 | * 34 | * Board specific LED driver header for the JM-DB-U2 (http://u2.mattair.net/index.html). 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 37 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 38 | */ 39 | 40 | /** \ingroup Group_LEDs 41 | * @defgroup Group_LEDs_JMDBU2 JMDBU2 42 | * 43 | * Board specific LED driver header for the JM-DB-U2 (http://u2.mattair.net/index.html). 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 46 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __LEDS_JMDBU2_H__ 52 | #define __LEDS_JMDBU2_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_LEDS_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 67 | #endif 68 | 69 | /* Public Interface - May be used in end-application: */ 70 | /* Macros: */ 71 | /** LED mask for the first LED on the board. */ 72 | #define LEDS_LED1 (1 << 4) 73 | 74 | /** LED mask for all the LEDs on the board. */ 75 | #define LEDS_ALL_LEDS LEDS_LED1 76 | 77 | /** LED mask for the none of the board LEDs. */ 78 | #define LEDS_NO_LEDS 0 79 | 80 | /* Inline Functions: */ 81 | #if !defined(__DOXYGEN__) 82 | static inline void LEDs_Init(void) 83 | { 84 | DDRD |= LEDS_ALL_LEDS; 85 | PORTD &= ~LEDS_ALL_LEDS; 86 | } 87 | 88 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 89 | { 90 | PORTD |= LEDMask; 91 | } 92 | 93 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 94 | { 95 | PORTD &= ~LEDMask; 96 | } 97 | 98 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 99 | { 100 | PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); 101 | } 102 | 103 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, 104 | const uint8_t ActiveMask) 105 | { 106 | PORTD = ((PORTD & ~LEDMask) | ActiveMask); 107 | } 108 | 109 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 110 | { 111 | PORTD = (PORTD ^ (LEDMask & LEDS_ALL_LEDS)); 112 | } 113 | 114 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 115 | static inline uint8_t LEDs_GetLEDs(void) 116 | { 117 | return (PORTD & LEDS_ALL_LEDS); 118 | } 119 | #endif 120 | 121 | /* Disable C linkage for C++ Compilers: */ 122 | #if defined(__cplusplus) 123 | } 124 | #endif 125 | 126 | #endif 127 | 128 | /** @} */ 129 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the board digital joystick driver. 33 | * 34 | * This file is the master dispatch header file for the board-specific Joystick driver, for boards containing a 35 | * 5-way joystick. 36 | * 37 | * User code should include this file, which will in turn include the correct joystick driver header file for the 38 | * currently selected board. 39 | * 40 | * If the BOARD value is set to BOARD_USER, this will include the /Board/Joystick.h file in the user project 41 | * directory. 42 | */ 43 | 44 | /** \ingroup Group_BoardDrivers 45 | * @defgroup Group_Joystick Joystick Driver - LUFA/Drivers/Board/Joystick.h 46 | * 47 | * \section Sec_Dependencies Module Source Dependencies 48 | * The following files must be built with any user project that uses this module: 49 | * - None 50 | * 51 | * \section Module Description 52 | * Hardware Joystick driver. This module provides an easy to use interface to control the hardware digital Joystick 53 | * located on many boards. 54 | * 55 | * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project 56 | * directory. Otherwise, it will include the appropriate built in board driver header file. 57 | * 58 | * @{ 59 | */ 60 | 61 | #ifndef __JOYSTICK_H__ 62 | #define __JOYSTICK_H__ 63 | 64 | /* Macros: */ 65 | #if !defined(__DOXYGEN__) 66 | #define __INCLUDE_FROM_JOYSTICK_H 67 | #define INCLUDE_FROM_JOYSTICK_H 68 | #endif 69 | 70 | /* Includes: */ 71 | #include "../../Common/Common.h" 72 | 73 | #if (BOARD == BOARD_NONE) 74 | #error The Board Joystick driver cannot be used if the makefile BOARD option is not set. 75 | #elif (BOARD == BOARD_USBKEY) 76 | #include "USBKEY/Joystick.h" 77 | #elif (BOARD == BOARD_STK525) 78 | #include "STK525/Joystick.h" 79 | #elif (BOARD == BOARD_STK526) 80 | #include "STK526/Joystick.h" 81 | #elif (BOARD == BOARD_BUMBLEB) 82 | #include "BUMBLEB/Joystick.h" 83 | #elif (BOARD == BOARD_EVK527) 84 | #include "EVK527/Joystick.h" 85 | #elif (BOARD == BOARD_USER) 86 | #include "Board/Joystick.h" 87 | #else 88 | #error The selected board does not contain a joystick. 89 | #endif 90 | 91 | /* Pseudo-Functions for Doxygen: */ 92 | #if defined(__DOXYGEN__) 93 | /** Initialises the joystick driver so that the joystick position can be read. This sets the appropriate 94 | * I/O pins to inputs with their pull-ups enabled. 95 | */ 96 | static inline void Joystick_Init(void); 97 | 98 | /** Returns the current status of the joystick, as a mask indicating the direction the joystick is 99 | * currently facing in (multiple bits can be set). 100 | * 101 | * \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file 102 | * for direction masks. 103 | */ 104 | static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 105 | #endif 106 | 107 | #endif 108 | 109 | /** @} */ 110 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/STK525/AT45DB321C.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Dataflash commands header for the AT45DB321C as mounted on the STK525. 33 | * 34 | * Board specific Dataflash commands header for the AT45DB321C as mounted on the STK525. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the dataflash driver 37 | * dispatch header located in LUFA/Drivers/Board/Dataflash.h. 38 | */ 39 | 40 | /** \ingroup Group_Dataflash_STK525 41 | * @defgroup Group_Dataflash_STK525_AT45DB321C AT45DB321C 42 | * 43 | * Board specific Dataflash commands header for the AT45DB321C as mounted on the STK525. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the dataflash driver 46 | * dispatch header located in LUFA/Drivers/Board/Dataflash.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __DATAFLASH_CMDS_H__ 52 | #define __DATAFLASH_CMDS_H__ 53 | 54 | /* Public Interface - May be used in end-application: */ 55 | /* Macros: */ 56 | #define DF_STATUS_READY (1 << 7) 57 | #define DF_STATUS_COMPMISMATCH (1 << 6) 58 | #define DF_STATUS_SECTORPROTECTION_ON (1 << 1) 59 | 60 | #define DF_MANUFACTURER_ATMEL 0x1F 61 | 62 | #define DF_CMD_GETSTATUS 0xD7 63 | 64 | #define DF_CMD_MAINMEMTOBUFF1 0x53 65 | #define DF_CMD_MAINMEMTOBUFF2 0x55 66 | #define DF_CMD_MAINMEMTOBUFF1COMP 0x60 67 | #define DF_CMD_MAINMEMTOBUFF2COMP 0x61 68 | #define DF_CMD_AUTOREWRITEBUFF1 0x58 69 | #define DF_CMD_AUTOREWRITEBUFF2 0x59 70 | 71 | #define DF_CMD_MAINMEMPAGEREAD 0xD2 72 | #define DF_CMD_CONTARRAYREAD_LF 0xE8 73 | #define DF_CMD_BUFF1READ_LF 0xD4 74 | #define DF_CMD_BUFF2READ_LF 0xD6 75 | 76 | #define DF_CMD_BUFF1WRITE 0x84 77 | #define DF_CMD_BUFF2WRITE 0x87 78 | #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83 79 | #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86 80 | #define DF_CMD_BUFF1TOMAINMEM 0x88 81 | #define DF_CMD_BUFF2TOMAINMEM 0x89 82 | #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82 83 | #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85 84 | 85 | #define DF_CMD_PAGEERASE 0x81 86 | #define DF_CMD_BLOCKERASE 0x50 87 | 88 | #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF}) 89 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D 90 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A 91 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F 92 | #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF 93 | 94 | #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F 95 | 96 | #endif 97 | 98 | /** @} */ 99 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/STK525/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the STK525. 33 | * 34 | * Board specific Buttons driver header for the STK525. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_STK525 STK525 42 | * 43 | * Board specific Buttons driver header for the STK525. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_STK525_H__ 52 | #define __BUTTONS_STK525_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Includes: */ 61 | #include 62 | #include 63 | 64 | #include "../../../Common/Common.h" 65 | 66 | /* Enable C linkage for C++ Compilers: */ 67 | #if defined(__cplusplus) 68 | extern "C" { 69 | #endif 70 | 71 | /* Preprocessor Checks: */ 72 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 73 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 74 | #endif 75 | 76 | /* Public Interface - May be used in end-application: */ 77 | /* Macros: */ 78 | /** Button mask for the first button on the board. */ 79 | #define BUTTONS_BUTTON1 (1 << 2) 80 | 81 | /* Inline Functions: */ 82 | #if !defined(__DOXYGEN__) 83 | static inline void Buttons_Init(void) 84 | { 85 | DDRE &= ~BUTTONS_BUTTON1; 86 | PORTE |= BUTTONS_BUTTON1; 87 | } 88 | 89 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 90 | static inline uint8_t Buttons_GetStatus(void) 91 | { 92 | return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 93 | } 94 | #endif 95 | 96 | /* Disable C linkage for C++ Compilers: */ 97 | #if defined(__cplusplus) 98 | } 99 | #endif 100 | 101 | #endif 102 | 103 | /** @} */ 104 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/STK525/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific joystick driver header for the STK525. 33 | * 34 | * Board specific joystick driver header for the STK525. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 37 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 38 | */ 39 | 40 | /** \ingroup Group_Joystick 41 | * @defgroup Group_Joystick_STK525 STK525 42 | * 43 | * Board specific joystick driver header for the STK525. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 46 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __JOYSTICK_STK525_H__ 52 | #define __JOYSTICK_STK525_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_JOYSTICK_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. 67 | #endif 68 | 69 | /* Private Interface - For use in library only: */ 70 | #if !defined(__DOXYGEN__) 71 | /* Macros: */ 72 | #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7)) 73 | #define JOY_EMASK ((1 << 4) | (1 << 5)) 74 | #endif 75 | 76 | /* Public Interface - May be used in end-application: */ 77 | /* Macros: */ 78 | /** Mask for the joystick being pushed in the left direction. */ 79 | #define JOY_LEFT (1 << 6) 80 | 81 | /** Mask for the joystick being pushed in the right direction. */ 82 | #define JOY_RIGHT ((1 << 4) >> 1) 83 | 84 | /** Mask for the joystick being pushed in the upward direction. */ 85 | #define JOY_UP (1 << 7) 86 | 87 | /** Mask for the joystick being pushed in the downward direction. */ 88 | #define JOY_DOWN ((1 << 5) >> 1) 89 | 90 | /** Mask for the joystick being pushed inward. */ 91 | #define JOY_PRESS (1 << 5) 92 | 93 | /* Inline Functions: */ 94 | #if !defined(__DOXYGEN__) 95 | static inline void Joystick_Init(void) 96 | { 97 | DDRB &= ~(JOY_BMASK); 98 | DDRE &= ~(JOY_EMASK); 99 | 100 | PORTB |= JOY_BMASK; 101 | PORTE |= JOY_EMASK; 102 | } 103 | 104 | static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 105 | static inline uint8_t Joystick_GetStatus(void) 106 | { 107 | return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1)); 108 | } 109 | #endif 110 | 111 | /* Disable C linkage for C++ Compilers: */ 112 | #if defined(__cplusplus) 113 | } 114 | #endif 115 | 116 | #endif 117 | 118 | /** @} */ 119 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/STK526/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the STK526. 33 | * 34 | * Board specific Buttons driver header for the STK526. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_STK526 STK526 42 | * 43 | * Board specific Buttons driver header for the STK526. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_STK526_H__ 52 | #define __BUTTONS_STK526_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Includes: */ 61 | #include 62 | #include 63 | 64 | #include "../../../Common/Common.h" 65 | 66 | /* Enable C linkage for C++ Compilers: */ 67 | #if defined(__cplusplus) 68 | extern "C" { 69 | #endif 70 | 71 | /* Preprocessor Checks: */ 72 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 73 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 74 | #endif 75 | 76 | /* Public Interface - May be used in end-application: */ 77 | /* Macros: */ 78 | /** Button mask for the first button on the board. */ 79 | #define BUTTONS_BUTTON1 (1 << 7) 80 | 81 | /* Inline Functions: */ 82 | #if !defined(__DOXYGEN__) 83 | static inline void Buttons_Init(void) 84 | { 85 | DDRD &= ~BUTTONS_BUTTON1; 86 | PORTD |= BUTTONS_BUTTON1; 87 | } 88 | 89 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 90 | static inline uint8_t Buttons_GetStatus(void) 91 | { 92 | return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 93 | } 94 | #endif 95 | 96 | /* Disable C linkage for C++ Compilers: */ 97 | #if defined(__cplusplus) 98 | } 99 | #endif 100 | 101 | #endif 102 | 103 | /** @} */ 104 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/STK526/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific joystick driver header for the STK526. 33 | * 34 | * Board specific joystick driver header for the STK526. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 37 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 38 | */ 39 | 40 | /** \ingroup Group_Joystick 41 | * @defgroup Group_Joystick_STK526 STK526 42 | * 43 | * Board specific joystick driver header for the STK526. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 46 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __JOYSTICK_STK526_H__ 52 | #define __JOYSTICK_STK526_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_JOYSTICK_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. 67 | #endif 68 | 69 | /* Private Interface - For use in library only: */ 70 | #if !defined(__DOXYGEN__) 71 | /* Macros: */ 72 | #define JOY_BMASK ((1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7)) 73 | #endif 74 | 75 | /* Public Interface - May be used in end-application: */ 76 | /* Macros: */ 77 | /** Mask for the joystick being pushed in the left direction. */ 78 | #define JOY_LEFT (1 << 4) 79 | 80 | /** Mask for the joystick being pushed in the right direction. */ 81 | #define JOY_RIGHT (1 << 6) 82 | 83 | /** Mask for the joystick being pushed in the upward direction. */ 84 | #define JOY_UP (1 << 5) 85 | 86 | /** Mask for the joystick being pushed in the downward direction. */ 87 | #define JOY_DOWN (1 << 7) 88 | 89 | /** Mask for the joystick being pushed inward. */ 90 | #define JOY_PRESS (1 << 0) 91 | 92 | /* Inline Functions: */ 93 | #if !defined(__DOXYGEN__) 94 | static inline void Joystick_Init(void) 95 | { 96 | DDRB &= ~JOY_BMASK; 97 | 98 | PORTB |= JOY_BMASK; 99 | } 100 | 101 | static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 102 | static inline uint8_t Joystick_GetStatus(void) 103 | { 104 | return ((uint8_t)~PINB & JOY_BMASK); 105 | } 106 | #endif 107 | 108 | /* Disable C linkage for C++ Compilers: */ 109 | #if defined(__cplusplus) 110 | } 111 | #endif 112 | 113 | #endif 114 | 115 | /** @} */ 116 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/TEENSY/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific LED driver header for the PJRC Teensy boards. 33 | * 34 | * Board specific LED driver header for the PJRC Teensy boards (http://www.pjrc.com/teensy/index.html). 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 37 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 38 | */ 39 | 40 | /** \ingroup Group_LEDs 41 | * @defgroup Group_LEDs_TEENSY TEENSY 42 | * 43 | * Board specific LED driver header for the PJRC Teensy boards (http://www.pjrc.com/teensy/index.html). 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 46 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __LEDS_TEENSY_H__ 52 | #define __LEDS_TEENSY_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_LEDS_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 67 | #endif 68 | 69 | /* Public Interface - May be used in end-application: */ 70 | /* Macros: */ 71 | /** LED mask for the first LED on the board. */ 72 | #define LEDS_LED1 (1 << 6) 73 | 74 | /** LED mask for all the LEDs on the board. */ 75 | #define LEDS_ALL_LEDS (1 << 6) 76 | 77 | /** LED mask for the none of the board LEDs. */ 78 | #define LEDS_NO_LEDS 0 79 | 80 | /* Inline Functions: */ 81 | #if !defined(__DOXYGEN__) 82 | static inline void LEDs_Init(void) 83 | { 84 | DDRD |= LEDS_ALL_LEDS; 85 | PORTD |= LEDS_ALL_LEDS; 86 | } 87 | 88 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 89 | { 90 | PORTD &= ~LEDMask; 91 | } 92 | 93 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 94 | { 95 | PORTD |= LEDMask; 96 | } 97 | 98 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 99 | { 100 | PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); 101 | } 102 | 103 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, 104 | const uint8_t ActiveMask) 105 | { 106 | PORTD = ((PORTD | LEDMask) & ~ActiveMask); 107 | } 108 | 109 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 110 | { 111 | PORTD ^= LEDMask; 112 | } 113 | 114 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 115 | static inline uint8_t LEDs_GetLEDs(void) 116 | { 117 | return (~PORTD & LEDS_ALL_LEDS); 118 | } 119 | #endif 120 | 121 | /* Disable C linkage for C++ Compilers: */ 122 | #if defined(__cplusplus) 123 | } 124 | #endif 125 | 126 | #endif 127 | 128 | /** @} */ 129 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/Temperature.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #include "Temperature.h" 32 | 33 | static const uint16_t PROGMEM Temperature_Lookup[] = { 34 | 0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373, 35 | 0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307, 36 | 0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C, 37 | 0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7, 38 | 0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161, 39 | 0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7, 40 | 0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA, 41 | 0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074, 42 | 0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050, 43 | 0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038 44 | }; 45 | 46 | int8_t Temperature_GetTemperature(void) 47 | { 48 | uint16_t Temp_ADC = ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | TEMP_ADC_CHANNEL_MASK); 49 | 50 | if (Temp_ADC > pgm_read_word(&Temperature_Lookup[0])) 51 | return TEMP_MIN_TEMP; 52 | 53 | for (uint16_t Index = 0; Index < TEMP_TABLE_SIZE; Index++) 54 | { 55 | if (Temp_ADC > pgm_read_word(&Temperature_Lookup[Index])) 56 | return (Index + TEMP_TABLE_OFFSET); 57 | } 58 | 59 | return TEMP_MAX_TEMP; 60 | } 61 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/USBKEY/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the USBKEY. 33 | * 34 | * Board specific Buttons driver header for the USBKEY. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_USBKEY USBKEY 42 | * 43 | * Board specific Buttons driver header for the USBKEY. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_USBKEY_H__ 52 | #define __BUTTONS_USBKEY_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Enable C linkage for C++ Compilers: */ 61 | #if defined(__cplusplus) 62 | extern "C" { 63 | #endif 64 | 65 | /* Preprocessor Checks: */ 66 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 67 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 68 | #endif 69 | 70 | /* Public Interface - May be used in end-application: */ 71 | /* Macros: */ 72 | /** Button mask for the first button on the board. */ 73 | #define BUTTONS_BUTTON1 (1 << 2) 74 | 75 | /* Inline Functions: */ 76 | #if !defined(__DOXYGEN__) 77 | static inline void Buttons_Init(void) 78 | { 79 | DDRE &= ~BUTTONS_BUTTON1; 80 | PORTE |= BUTTONS_BUTTON1; 81 | } 82 | 83 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 84 | static inline uint8_t Buttons_GetStatus(void) 85 | { 86 | return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 87 | } 88 | #endif 89 | 90 | /* Disable C linkage for C++ Compilers: */ 91 | #if defined(__cplusplus) 92 | } 93 | #endif 94 | 95 | #endif 96 | 97 | /** @} */ 98 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/USBKEY/Joystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific joystick driver header for the USBKEY. 33 | * 34 | * Board specific joystick driver header for the USBKEY. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 37 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 38 | */ 39 | 40 | /** \ingroup Group_Joystick 41 | * @defgroup Group_Joystick_USBKEY USBKEY 42 | * 43 | * Board specific joystick driver header for the USBKEY. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the joystick driver 46 | * dispatch header located in LUFA/Drivers/Board/Joystick.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __JOYSTICK_USBKEY_H__ 52 | #define __JOYSTICK_USBKEY_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_JOYSTICK_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. 67 | #endif 68 | 69 | /* Private Interface - For use in library only: */ 70 | #if !defined(__DOXYGEN__) 71 | /* Macros: */ 72 | #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7)) 73 | #define JOY_EMASK ((1 << 4) | (1 << 5)) 74 | #endif 75 | 76 | /* Public Interface - May be used in end-application: */ 77 | /* Macros: */ 78 | /** Mask for the joystick being pushed in the left direction. */ 79 | #define JOY_LEFT (1 << 6) 80 | 81 | /** Mask for the joystick being pushed in the right direction. */ 82 | #define JOY_RIGHT ((1 << 4) >> 1) 83 | 84 | /** Mask for the joystick being pushed in the upward direction. */ 85 | #define JOY_UP (1 << 7) 86 | 87 | /** Mask for the joystick being pushed in the downward direction. */ 88 | #define JOY_DOWN ((1 << 5) >> 1) 89 | 90 | /** Mask for the joystick being pushed inward. */ 91 | #define JOY_PRESS (1 << 5) 92 | 93 | /* Inline Functions: */ 94 | #if !defined(__DOXYGEN__) 95 | static inline void Joystick_Init(void) 96 | { 97 | DDRB &= ~(JOY_BMASK); 98 | DDRE &= ~(JOY_EMASK); 99 | 100 | PORTB |= JOY_BMASK; 101 | PORTE |= JOY_EMASK; 102 | } 103 | 104 | static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 105 | static inline uint8_t Joystick_GetStatus(void) 106 | { 107 | return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1)); 108 | } 109 | #endif 110 | 111 | /* Disable C linkage for C++ Compilers: */ 112 | #if defined(__cplusplus) 113 | } 114 | #endif 115 | 116 | #endif 117 | 118 | /** @} */ 119 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/USBTINYMKII/Buttons.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific Buttons driver header for the USBTINY MKII. 33 | * 34 | * Board specific Buttons driver header for the USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/). 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 37 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 38 | */ 39 | 40 | /** \ingroup Group_Buttons 41 | * @defgroup Group_Buttons_USBTINYMKII USBTINYMKII 42 | * 43 | * Board specific Buttons driver header for the USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/). 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the Buttons driver 46 | * dispatch header located in LUFA/Drivers/Board/Buttons.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __BUTTONS_USBTINYMKII_H__ 52 | #define __BUTTONS_USBTINYMKII_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | #include 57 | 58 | #include "../../../Common/Common.h" 59 | 60 | /* Enable C linkage for C++ Compilers: */ 61 | #if defined(__cplusplus) 62 | extern "C" { 63 | #endif 64 | 65 | /* Preprocessor Checks: */ 66 | #if !defined(__INCLUDE_FROM_BUTTONS_H) 67 | #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead. 68 | #endif 69 | 70 | /* Public Interface - May be used in end-application: */ 71 | /* Macros: */ 72 | /** Button mask for the first button on the board. */ 73 | #define BUTTONS_BUTTON1 (1 << 7) 74 | 75 | /* Inline Functions: */ 76 | #if !defined(__DOXYGEN__) 77 | static inline void Buttons_Init(void) 78 | { 79 | DDRD &= ~BUTTONS_BUTTON1; 80 | PORTD |= BUTTONS_BUTTON1; 81 | } 82 | 83 | static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; 84 | static inline uint8_t Buttons_GetStatus(void) 85 | { 86 | return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1); 87 | } 88 | #endif 89 | 90 | /* Disable C linkage for C++ Compilers: */ 91 | #if defined(__cplusplus) 92 | } 93 | #endif 94 | 95 | #endif 96 | 97 | /** @} */ 98 | -------------------------------------------------------------------------------- /LUFA/Drivers/Board/XPLAIN/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Board specific LED driver header for the XPLAIN. 33 | * 34 | * Board specific LED driver header for the XPLAIN. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 37 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 38 | */ 39 | 40 | /** \ingroup Group_LEDs 41 | * @defgroup Group_LEDs_XPLAIN XPLAIN 42 | * 43 | * Board specific LED driver header for the XPLAIN. 44 | * 45 | * \note This file should not be included directly. It is automatically included as needed by the LEDs driver 46 | * dispatch header located in LUFA/Drivers/Board/LEDs.h. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __LEDS_XPLAIN_H__ 52 | #define __LEDS_XPLAIN_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | #include "../../../Common/Common.h" 58 | 59 | /* Enable C linkage for C++ Compilers: */ 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | 64 | /* Preprocessor Checks: */ 65 | #if !defined(__INCLUDE_FROM_LEDS_H) 66 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 67 | #endif 68 | 69 | /* Public Interface - May be used in end-application: */ 70 | /* Macros: */ 71 | /** LED mask for the first LED on the board. */ 72 | #define LEDS_LED1 (1 << 6) 73 | 74 | /** LED mask for all the LEDs on the board. */ 75 | #define LEDS_ALL_LEDS LEDS_LED1 76 | 77 | /** LED mask for the none of the board LEDs. */ 78 | #define LEDS_NO_LEDS 0 79 | 80 | /* Inline Functions: */ 81 | #if !defined(__DOXYGEN__) 82 | static inline void LEDs_Init(void) 83 | { 84 | DDRB |= LEDS_ALL_LEDS; 85 | PORTB |= LEDS_ALL_LEDS; 86 | } 87 | 88 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 89 | { 90 | PORTB &= ~LEDMask; 91 | } 92 | 93 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 94 | { 95 | PORTB |= LEDMask; 96 | } 97 | 98 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 99 | { 100 | PORTB = ((PORTB | LEDS_ALL_LEDS) & ~LEDMask); 101 | } 102 | 103 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, 104 | const uint8_t ActiveMask) 105 | { 106 | PORTB = ((PORTB | (LEDMask & LEDS_ALL_LEDS)) & (~ActiveMask & LEDS_ALL_LEDS)); 107 | } 108 | 109 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 110 | { 111 | PORTD = (PORTB ^ (LEDMask & LEDS_ALL_LEDS)); 112 | } 113 | 114 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 115 | static inline uint8_t LEDs_GetLEDs(void) 116 | { 117 | return (~PORTB & LEDS_ALL_LEDS); 118 | } 119 | #endif 120 | 121 | /* Disable C linkage for C++ Compilers: */ 122 | #if defined(__cplusplus) 123 | } 124 | #endif 125 | 126 | #endif 127 | 128 | /** @} */ 129 | -------------------------------------------------------------------------------- /LUFA/Drivers/Peripheral/ADC.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the ADC peripheral driver. 33 | * 34 | * This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC. 35 | * 36 | * User code should include this file, which will in turn include the correct ADC driver header file for the 37 | * currently selected AVR model. 38 | */ 39 | 40 | /** \ingroup Group_PeripheralDrivers 41 | * @defgroup Group_ADC ADC Driver - LUFA/Drivers/Peripheral/ADC.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - None 46 | * 47 | * \section Module Description 48 | * Hardware ADC driver. This module provides an easy to use driver for the hardware 49 | * ADC present on many AVR models, for the conversion of analogue signals into the 50 | * digital domain. 51 | */ 52 | 53 | #ifndef __ADC_H__ 54 | #define __ADC_H__ 55 | 56 | /* Macros: */ 57 | #if !defined(__DOXYGEN__) 58 | #define __INCLUDE_FROM_ADC_H 59 | #endif 60 | 61 | /* Includes: */ 62 | #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ 63 | defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ 64 | defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ 65 | defined(__AVR_ATmega32U6__)) 66 | #include "AVRU4U6U7/ADC.h" 67 | #else 68 | #error "ADC is not available for the currently selected AVR model." 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /LUFA/Drivers/Peripheral/Serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #include "Serial.h" 32 | 33 | void Serial_TxString_P(const char* FlashStringPtr) 34 | { 35 | uint8_t CurrByte; 36 | 37 | while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00) 38 | { 39 | Serial_TxByte(CurrByte); 40 | FlashStringPtr++; 41 | } 42 | } 43 | 44 | void Serial_TxString(const char* StringPtr) 45 | { 46 | uint8_t CurrByte; 47 | 48 | while ((CurrByte = *StringPtr) != 0x00) 49 | { 50 | Serial_TxByte(CurrByte); 51 | StringPtr++; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /LUFA/Drivers/Peripheral/SerialStream.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #define __INCLUDE_FROM_SERIALSTREAM_C 32 | #include "SerialStream.h" 33 | 34 | FILE USARTStream = FDEV_SETUP_STREAM(SerialStream_TxByte, SerialStream_RxByte, _FDEV_SETUP_RW); 35 | 36 | static int SerialStream_TxByte(char DataByte, 37 | FILE *Stream) 38 | { 39 | (void)Stream; 40 | 41 | Serial_TxByte(DataByte); 42 | return 0; 43 | } 44 | 45 | static int SerialStream_RxByte(FILE *Stream) 46 | { 47 | (void)Stream; 48 | 49 | if (!(Serial_IsCharReceived())) 50 | return _FDEV_EOF; 51 | 52 | return Serial_RxByte(); 53 | } 54 | -------------------------------------------------------------------------------- /LUFA/Drivers/Peripheral/TWI.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) Dean Camera, 2010. 3 | 4 | dean [at] fourwalledcubicle [dot] com 5 | www.fourwalledcubicle.com 6 | */ 7 | 8 | #include "TWI.h" 9 | 10 | bool TWI_StartTransmission(const uint8_t SlaveAddress, 11 | const uint8_t TimeoutMS) 12 | { 13 | for (;;) 14 | { 15 | bool BusCaptured = false; 16 | uint16_t TimeoutRemaining; 17 | 18 | TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN)); 19 | 20 | TimeoutRemaining = (TimeoutMS * 100); 21 | while (TimeoutRemaining-- && !(BusCaptured)) 22 | { 23 | if (TWCR & (1 << TWINT)) 24 | { 25 | switch (TWSR & TW_STATUS_MASK) 26 | { 27 | case TW_START: 28 | case TW_REP_START: 29 | BusCaptured = true; 30 | break; 31 | case TW_MT_ARB_LOST: 32 | TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN)); 33 | continue; 34 | default: 35 | TWCR = (1 << TWEN); 36 | return false; 37 | } 38 | } 39 | 40 | _delay_us(10); 41 | } 42 | 43 | if (!(BusCaptured)) 44 | { 45 | TWCR = (1 << TWEN); 46 | return false; 47 | } 48 | 49 | TWDR = SlaveAddress; 50 | TWCR = ((1 << TWINT) | (1 << TWEN)); 51 | 52 | TimeoutRemaining = (TimeoutMS * 100); 53 | while (TimeoutRemaining--) 54 | { 55 | if (TWCR & (1 << TWINT)) 56 | break; 57 | 58 | _delay_us(10); 59 | } 60 | 61 | if (!(TimeoutRemaining)) 62 | return false; 63 | 64 | switch (TWSR & TW_STATUS_MASK) 65 | { 66 | case TW_MT_SLA_ACK: 67 | case TW_MR_SLA_ACK: 68 | return true; 69 | default: 70 | TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN)); 71 | return false; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /LUFA/Drivers/Peripheral/TWI.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the TWI peripheral driver. 33 | * 34 | * This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC. 35 | * 36 | * User code should include this file, which will in turn include the correct ADC driver header file for the 37 | * currently selected AVR model. 38 | */ 39 | 40 | /** \ingroup Group_PeripheralDrivers 41 | * @defgroup Group_TWI TWI Driver - LUFA/Drivers/Peripheral/TWI.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/Peripheral/TWI.c (Makefile source module name: LUFA_SRC_TWI) 46 | * 47 | * 48 | * \section Module Description 49 | * Master Mode Hardware TWI driver. This module provides an easy to use driver for the hardware 50 | * TWI present on many AVR models, for the transmission and reception of data on a TWI bus. 51 | */ 52 | 53 | #ifndef __TWI_H__ 54 | #define __TWI_H__ 55 | 56 | /* Macros: */ 57 | #if !defined(__DOXYGEN__) 58 | #define __INCLUDE_FROM_TWI_H 59 | #endif 60 | 61 | /* Includes: */ 62 | #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ 63 | defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ 64 | defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ 65 | defined(__AVR_ATmega32U6__)) 66 | #include "AVRU4U6U7/TWI.h" 67 | #else 68 | #error "TWI is not available for the currently selected AVR model." 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/Audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB Audio Class driver. 33 | * 34 | * Master include file for the library USB Audio Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassAudio Audio Class Driver - LUFA/Drivers/Class/Audio.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Device/Audio.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * 47 | * \section Module Description 48 | * Audio Class Driver module. This module contains an internal implementation of the USB Audio Class, for Device 49 | * USB mode only. User applications can use this class driver instead of implementing the Audio class manually via 50 | * the low-level LUFA APIs. 51 | * 52 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 53 | * Hosts or Devices using the USB Audio Class. 54 | * 55 | * @{ 56 | */ 57 | 58 | #ifndef _AUDIO_CLASS_H_ 59 | #define _AUDIO_CLASS_H_ 60 | 61 | /* Macros: */ 62 | #define __INCLUDE_FROM_AUDIO_DRIVER 63 | #define __INCLUDE_FROM_USB_DRIVER 64 | 65 | /* Includes: */ 66 | #include "../HighLevel/USBMode.h" 67 | 68 | #if defined(NO_STREAM_CALLBACKS) 69 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 70 | #endif 71 | 72 | #if defined(USB_CAN_BE_DEVICE) 73 | #include "Device/Audio.h" 74 | #endif 75 | 76 | #endif 77 | 78 | /** @} */ 79 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/CDC.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB CDC-ACM Class driver. 33 | * 34 | * Master include file for the library USB CDC Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassCDC CDC-ACM (Virtual Serial) Class Driver - LUFA/Drivers/Class/CDC.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Device/CDC.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * - LUFA/Drivers/USB/Class/Host/CDC.c (Makefile source module name: LUFA_SRC_USBCLASS) 47 | * 48 | * \section Module Description 49 | * CDC Class Driver module. This module contains an internal implementation of the USB CDC-ACM class Virtual Serial 50 | * Ports, for both Device and Host USB modes. User applications can use this class driver instead of implementing the 51 | * CDC class manually via the low-level LUFA APIs. 52 | * 53 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 54 | * Hosts or Devices using the USB CDC Class. 55 | * 56 | * @{ 57 | */ 58 | 59 | #ifndef _CDC_CLASS_H_ 60 | #define _CDC_CLASS_H_ 61 | 62 | /* Macros: */ 63 | #define __INCLUDE_FROM_CDC_DRIVER 64 | #define __INCLUDE_FROM_USB_DRIVER 65 | 66 | /* Includes: */ 67 | #include "../HighLevel/USBMode.h" 68 | 69 | #if defined(NO_STREAM_CALLBACKS) 70 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 71 | #endif 72 | 73 | #if defined(USB_CAN_BE_DEVICE) 74 | #include "Device/CDC.h" 75 | #endif 76 | 77 | #if defined(USB_CAN_BE_HOST) 78 | #include "Host/CDC.h" 79 | #endif 80 | 81 | #endif 82 | 83 | /** @} */ 84 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/Common/Printer.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Common definitions and declarations for the library USB Printer Class driver. 33 | * 34 | * Common definitions and declarations for the library USB Printer Class driver. 35 | * 36 | * \note This file should not be included directly. It is automatically included as needed by the class driver 37 | * dispatch header located in LUFA/Drivers/USB/Class/Printer.h. 38 | */ 39 | 40 | /** \ingroup Group_USBClassPrinter 41 | * @defgroup Group_USBClassPrinterCommon Common Class Definitions 42 | * 43 | * \section Module Description 44 | * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB 45 | * Printer Class. 46 | * 47 | * @{ 48 | */ 49 | 50 | #ifndef _PRINTER_CLASS_COMMON_H_ 51 | #define _PRINTER_CLASS_COMMON_H_ 52 | 53 | /* Includes: */ 54 | #include "../../USB.h" 55 | 56 | #include 57 | 58 | /* Enable C linkage for C++ Compilers: */ 59 | #if defined(__cplusplus) 60 | extern "C" { 61 | #endif 62 | 63 | /* Preprocessor Checks: */ 64 | #if !defined(__INCLUDE_FROM_PRINTER_DRIVER) 65 | #error Do not include this file directly. Include LUFA/Drivers/Class/Printer.h instead. 66 | #endif 67 | 68 | /* Macros: */ 69 | /** Port status mask for a printer device, indicating that an error has *not* occurred. */ 70 | #define PRNT_PORTSTATUS_NOTERROR (1 << 3) 71 | 72 | /** Port status mask for a printer device, indicating that the device is currently selected. */ 73 | #define PRNT_PORTSTATUS_SELECT (1 << 4) 74 | 75 | /** Port status mask for a printer device, indicating that the device is currently out of paper. */ 76 | #define PRNT_PORTSTATUS_PAPEREMPTY (1 << 5) 77 | 78 | /* Disable C linkage for C++ Compilers: */ 79 | #if defined(__cplusplus) 80 | } 81 | #endif 82 | 83 | #endif 84 | 85 | /** @} */ 86 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/Device/Audio.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #define __INCLUDE_FROM_USB_DRIVER 32 | #include "../../HighLevel/USBMode.h" 33 | #if defined(USB_CAN_BE_DEVICE) 34 | 35 | #define __INCLUDE_FROM_AUDIO_DRIVER 36 | #include "Audio.h" 37 | 38 | void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) 39 | { 40 | if (!(Endpoint_IsSETUPReceived())) 41 | return; 42 | 43 | if (USB_ControlRequest.wIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber) 44 | return; 45 | 46 | switch (USB_ControlRequest.bRequest) 47 | { 48 | case REQ_SetInterface: 49 | if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE)) 50 | { 51 | Endpoint_ClearSETUP(); 52 | 53 | AudioInterfaceInfo->State.InterfaceEnabled = ((USB_ControlRequest.wValue & 0xFF) != 0); 54 | 55 | Endpoint_ClearStatusStage(); 56 | } 57 | 58 | break; 59 | } 60 | } 61 | 62 | bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) 63 | { 64 | memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State)); 65 | 66 | if (AudioInterfaceInfo->Config.DataINEndpointNumber) 67 | { 68 | if (!(Endpoint_ConfigureEndpoint(AudioInterfaceInfo->Config.DataINEndpointNumber, EP_TYPE_ISOCHRONOUS, 69 | ENDPOINT_DIR_IN, AudioInterfaceInfo->Config.DataINEndpointSize, 70 | ENDPOINT_BANK_DOUBLE))) 71 | { 72 | return false; 73 | } 74 | } 75 | 76 | if (AudioInterfaceInfo->Config.DataOUTEndpointNumber) 77 | { 78 | if (!(Endpoint_ConfigureEndpoint(AudioInterfaceInfo->Config.DataOUTEndpointNumber, EP_TYPE_ISOCHRONOUS, 79 | ENDPOINT_DIR_OUT, AudioInterfaceInfo->Config.DataOUTEndpointSize, 80 | ENDPOINT_BANK_DOUBLE))) 81 | { 82 | return false; 83 | } 84 | } 85 | 86 | return true; 87 | } 88 | 89 | #endif -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/HID.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB HID Class driver. 33 | * 34 | * Master include file for the library USB HID Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassHID HID Class Driver - LUFA/Drivers/Class/HID.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Device/HID.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * - LUFA/Drivers/USB/Class/Host/HID.c (Makefile source module name: LUFA_SRC_USBCLASS) 47 | * - LUFA/Drivers/USB/Class/Host/HIDParser.c (Makefile source module name: LUFA_SRC_USB) 48 | * 49 | * \section Module Description 50 | * HID Class Driver module. This module contains an internal implementation of the USB HID Class, for both Device 51 | * and Host USB modes. User applications can use this class driver instead of implementing the HID class manually 52 | * via the low-level LUFA APIs. 53 | * 54 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 55 | * Hosts or Devices using the USB HID Class. 56 | * 57 | * @{ 58 | */ 59 | 60 | #ifndef _HID_CLASS_H_ 61 | #define _HID_CLASS_H_ 62 | 63 | /* Macros: */ 64 | #define __INCLUDE_FROM_HID_DRIVER 65 | #define __INCLUDE_FROM_USB_DRIVER 66 | 67 | /* Includes: */ 68 | #include "../HighLevel/USBMode.h" 69 | 70 | #if defined(NO_STREAM_CALLBACKS) 71 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 72 | #endif 73 | 74 | #if defined(USB_CAN_BE_DEVICE) 75 | #include "Device/HID.h" 76 | #endif 77 | 78 | #if defined(USB_CAN_BE_HOST) 79 | #include "Host/HID.h" 80 | #endif 81 | 82 | #endif 83 | 84 | /** @} */ 85 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/MIDI.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB MIDI Class driver. 33 | * 34 | * Master include file for the library USB MIDI Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassMIDI MIDI Class Driver - LUFA/Drivers/Class/MIDI.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Device/MIDI.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * - LUFA/Drivers/USB/Class/Host/MIDI.c (Makefile source module name: LUFA_SRC_USBCLASS) 47 | * 48 | * \section Module Description 49 | * MIDI Class Driver module. This module contains an internal implementation of the USB MIDI Class, for both Device 50 | * and Host USB modes. User applications can use this class driver instead of implementing the MIDI class manually 51 | * via the low-level LUFA APIs. 52 | * 53 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 54 | * Hosts or Devices using the USB MIDI Class. 55 | * 56 | * \note The USB MIDI class is actually a special case of the regular Audio class, thus this module depends on 57 | * structure definitions from the \ref Group_USBClassAudioDevice class driver module. 58 | * 59 | * @{ 60 | */ 61 | 62 | #ifndef _MIDI_CLASS_H_ 63 | #define _MIDI_CLASS_H_ 64 | 65 | /* Macros: */ 66 | #define __INCLUDE_FROM_MIDI_DRIVER 67 | #define __INCLUDE_FROM_USB_DRIVER 68 | 69 | /* Includes: */ 70 | #include "../HighLevel/USBMode.h" 71 | 72 | #if defined(NO_STREAM_CALLBACKS) 73 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 74 | #endif 75 | 76 | #if defined(USB_CAN_BE_DEVICE) 77 | #include "Device/MIDI.h" 78 | #endif 79 | 80 | #if defined(USB_CAN_BE_HOST) 81 | #include "Host/MIDI.h" 82 | #endif 83 | 84 | #endif 85 | 86 | /** @} */ 87 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/MassStorage.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB Mass Storage Class driver. 33 | * 34 | * Master include file for the library USB Mass Storage Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassMS Mass Storage Class Driver - LUFA/Drivers/Class/MassStorage.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Device/MassStorage.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * - LUFA/Drivers/USB/Class/Host/MassStorage.c (Makefile source module name: LUFA_SRC_USBCLASS) 47 | * 48 | * \section Module Description 49 | * Mass Storage Class Driver module. This module contains an internal implementation of the USB Mass Storage Class, for both 50 | * Device and Host USB modes. User applications can use this class driver instead of implementing the Mass Storage class 51 | * manually via the low-level LUFA APIs. 52 | * 53 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 54 | * Hosts or Devices using the USB Mass Storage Class. 55 | * 56 | * @{ 57 | */ 58 | 59 | #ifndef _MS_CLASS_H_ 60 | #define _MS_CLASS_H_ 61 | 62 | /* Macros: */ 63 | #define __INCLUDE_FROM_MS_DRIVER 64 | #define __INCLUDE_FROM_USB_DRIVER 65 | 66 | /* Includes: */ 67 | #include "../HighLevel/USBMode.h" 68 | 69 | #if defined(NO_STREAM_CALLBACKS) 70 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 71 | #endif 72 | 73 | #if defined(USB_CAN_BE_DEVICE) 74 | #include "Device/MassStorage.h" 75 | #endif 76 | 77 | #if defined(USB_CAN_BE_HOST) 78 | #include "Host/MassStorage.h" 79 | #endif 80 | 81 | #endif 82 | 83 | /** @} */ 84 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/Printer.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB Printer Class driver. 33 | * 34 | * Master include file for the library USB Printer Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassPrinter Printer Class Driver - LUFA/Drivers/Class/Printer.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Host/Printer.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * 47 | * \section Module Description 48 | * Printer Class Driver module. This module contains an internal implementation of the USB Printer Class, for the base 49 | * USB Printer transport layer for USB Host mode only. Note that printers are free to implement whatever printer language 50 | * they choose on top of this (e.g. Postscript), and so this driver exposes low level data transport functions only rather 51 | * than high level raster or text functions. User applications can use this class driver instead of implementing the Printer 52 | * class manually via the low-level LUFA APIs. 53 | * 54 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 55 | * Devices using the USB Printer Class. 56 | * 57 | * @{ 58 | */ 59 | 60 | #ifndef _PRINTER_CLASS_H_ 61 | #define _PRINTER_CLASS_H_ 62 | 63 | /* Macros: */ 64 | #define __INCLUDE_FROM_PRINTER_DRIVER 65 | #define __INCLUDE_FROM_USB_DRIVER 66 | 67 | /* Includes: */ 68 | #include "../HighLevel/USBMode.h" 69 | 70 | #if defined(NO_STREAM_CALLBACKS) 71 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 72 | #endif 73 | 74 | #if defined(USB_CAN_BE_HOST) 75 | #include "Host/Printer.h" 76 | #endif 77 | 78 | #endif 79 | 80 | /** @} */ 81 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/RNDIS.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB RNDIS Class driver. 33 | * 34 | * Master include file for the library USB RNDIS Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassRNDIS RNDIS (Networking) Class Driver - LUFA/Drivers/Class/RNDIS.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Device/RNDIS.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * - LUFA/Drivers/USB/Class/Host/RNDIS.c (Makefile source module name: LUFA_SRC_USBCLASS) 47 | * 48 | * \section Module Description 49 | * RNDIS Class Driver module. This module contains an internal implementation of the Microsoft USB RNDIS Networking 50 | * Class, for both Device and Host USB modes. User applications can use this class driver instead of implementing the 51 | * RNDIS class manually via the low-level LUFA APIs. 52 | * 53 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 54 | * Hosts using the USB RNDIS Class. 55 | * 56 | * @{ 57 | */ 58 | 59 | #ifndef _RNDIS_CLASS_H_ 60 | #define _RNDIS_CLASS_H_ 61 | 62 | /* Macros: */ 63 | #define __INCLUDE_FROM_RNDIS_DRIVER 64 | #define __INCLUDE_FROM_USB_DRIVER 65 | 66 | /* Includes: */ 67 | #include "../HighLevel/USBMode.h" 68 | 69 | #if defined(NO_STREAM_CALLBACKS) 70 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 71 | #endif 72 | 73 | #if defined(USB_CAN_BE_DEVICE) 74 | #include "Device/RNDIS.h" 75 | #endif 76 | 77 | #if defined(USB_CAN_BE_HOST) 78 | #include "Host/RNDIS.h" 79 | #endif 80 | 81 | #endif 82 | 83 | /** @} */ 84 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/Class/StillImage.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief Master include file for the library USB Still Image Class driver. 33 | * 34 | * Master include file for the library USB Still Image Class driver, for both host and device modes, where available. 35 | * 36 | * This file should be included in all user projects making use of this optional class driver, instead of 37 | * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories. 38 | */ 39 | 40 | /** \ingroup Group_USBClassDrivers 41 | * @defgroup Group_USBClassSI Still Image Class Driver - LUFA/Drivers/Class/StillImage.h 42 | * 43 | * \section Sec_Dependencies Module Source Dependencies 44 | * The following files must be built with any user project that uses this module: 45 | * - LUFA/Drivers/USB/Class/Host/StillImage.c (Makefile source module name: LUFA_SRC_USBCLASS) 46 | * 47 | * \section Module Description 48 | * Still Image Class Driver module. This module contains an internal implementation of the USB Still Image Class, 49 | * for USB Host mode only. User applications can use this class driver instead of implementing the Still Image class 50 | * manually via the low-level LUFA APIs. 51 | * 52 | * This module is designed to simplify the user code by exposing only the required interface needed to interface with 53 | * Devices using the USB Still Image Class. 54 | * 55 | * @{ 56 | */ 57 | 58 | #ifndef _SI_CLASS_H_ 59 | #define _SI_CLASS_H_ 60 | 61 | /* Macros: */ 62 | #define __INCLUDE_FROM_SI_DRIVER 63 | #define __INCLUDE_FROM_USB_DRIVER 64 | 65 | /* Includes: */ 66 | #include "../HighLevel/USBMode.h" 67 | 68 | #if defined(NO_STREAM_CALLBACKS) 69 | #error The NO_STREAM_CALLBACKS compile time option cannot be used in projects using the library Class drivers. 70 | #endif 71 | 72 | #if defined(USB_CAN_BE_HOST) 73 | #include "Host/StillImage.h" 74 | #endif 75 | 76 | #endif 77 | 78 | /** @} */ 79 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/HighLevel/Events.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #define __INCLUDE_FROM_EVENTS_C 32 | #define __INCLUDE_FROM_USB_DRIVER 33 | #include "Events.h" 34 | 35 | void USB_Event_Stub(void) 36 | { 37 | 38 | } 39 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/HighLevel/StreamCallbacks.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * \brief USB endpoint/pipe stream callback management. 33 | * 34 | * This file contains definitions for the creation of optional callback routines which can be passed to the 35 | * endpoint and/or pipe stream APIs, to abort the transfer currently in progress when a condition is met. 36 | * 37 | * \note This file should not be included directly. It is automatically included as needed by the USB driver 38 | * dispatch header located in LUFA/Drivers/USB/USB.h. 39 | */ 40 | 41 | /** \ingroup Group_USB 42 | * @defgroup Group_StreamCallbacks Endpoint and Pipe Stream Callbacks 43 | * 44 | * Macros and enums for the stream callback routines. This module contains the code required to easily set up 45 | * stream callback functions which can be used to force early abort of a stream read/write process. Each callback 46 | * should take no arguments, and return a value from the \ref StreamCallback_Return_ErrorCodes_t enum. 47 | * 48 | * @{ 49 | */ 50 | 51 | #ifndef __STREAMCALLBACK_H__ 52 | #define __STREAMCALLBACK_H__ 53 | 54 | /* Includes: */ 55 | #include 56 | 57 | /* Preprocessor Checks: */ 58 | #if !defined(__INCLUDE_FROM_USB_DRIVER) 59 | #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. 60 | #endif 61 | 62 | /* Public Interface - May be used in end-application: */ 63 | /* Macros: */ 64 | /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream 65 | * call has no callback function to be called between USB packets. 66 | */ 67 | #define NO_STREAM_CALLBACK NULL 68 | 69 | /* Enums: */ 70 | /** Enum for the possible error return codes of a stream callback function. */ 71 | enum StreamCallback_Return_ErrorCodes_t 72 | { 73 | STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */ 74 | STREAMCALLBACK_Abort = 1, /**< Abort the stream send or receiving process. */ 75 | }; 76 | 77 | /* Type Defines: */ 78 | /** Type define for a Stream Callback function (function taking no arguments and retuning a 79 | * uint8_t value). Stream callback functions should have an identical function signature if they 80 | * are to be used as the callback parameter of the stream functions. 81 | */ 82 | typedef uint8_t (* const StreamCallbackPtr_t)(void); 83 | 84 | #endif 85 | 86 | /** @} */ 87 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/HighLevel/USBTask.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #define __INCLUDE_FROM_USBTASK_C 32 | #define __INCLUDE_FROM_USB_DRIVER 33 | #include "USBTask.h" 34 | 35 | volatile bool USB_IsInitialized; 36 | USB_Request_Header_t USB_ControlRequest; 37 | 38 | #if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR) 39 | volatile uint8_t USB_HostState; 40 | #endif 41 | 42 | #if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR) 43 | volatile uint8_t USB_DeviceState; 44 | #endif 45 | 46 | void USB_USBTask(void) 47 | { 48 | #if defined(USB_HOST_ONLY) 49 | USB_HostTask(); 50 | #elif defined(USB_DEVICE_ONLY) 51 | USB_DeviceTask(); 52 | #else 53 | if (USB_CurrentMode == USB_MODE_DEVICE) 54 | USB_DeviceTask(); 55 | else if (USB_CurrentMode == USB_MODE_HOST) 56 | USB_HostTask(); 57 | #endif 58 | } 59 | 60 | #if defined(USB_CAN_BE_DEVICE) 61 | static void USB_DeviceTask(void) 62 | { 63 | if (USB_DeviceState != DEVICE_STATE_Unattached) 64 | { 65 | uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); 66 | 67 | Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); 68 | 69 | if (Endpoint_IsSETUPReceived()) 70 | USB_Device_ProcessControlRequest(); 71 | 72 | Endpoint_SelectEndpoint(PrevEndpoint); 73 | } 74 | } 75 | #endif 76 | 77 | #if defined(USB_CAN_BE_HOST) 78 | static void USB_HostTask(void) 79 | { 80 | uint8_t PrevPipe = Pipe_GetCurrentPipe(); 81 | 82 | Pipe_SelectPipe(PIPE_CONTROLPIPE); 83 | 84 | USB_Host_ProcessNextHostState(); 85 | 86 | Pipe_SelectPipe(PrevPipe); 87 | } 88 | #endif 89 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/LowLevel/Device.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #define __INCLUDE_FROM_USB_DRIVER 32 | #include "../HighLevel/USBMode.h" 33 | 34 | #if defined(USB_CAN_BE_DEVICE) 35 | 36 | #include "Device.h" 37 | 38 | void USB_Device_SendRemoteWakeup(void) 39 | { 40 | if (!(USB_Options & USB_OPT_MANUAL_PLL)) 41 | { 42 | USB_PLL_On(); 43 | while (!(USB_PLL_IsReady())); 44 | } 45 | 46 | USB_CLK_Unfreeze(); 47 | 48 | UDCON |= (1 << RMWKUP); 49 | while (!(UDCON & (1 << RMWKUP))); 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c: -------------------------------------------------------------------------------- 1 | uint8_t TEMPLATE_FUNC_NAME (void* Buffer, 2 | uint16_t Length) 3 | { 4 | uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); 5 | 6 | if (!(Length)) 7 | Endpoint_ClearOUT(); 8 | 9 | while (Length) 10 | { 11 | if (Endpoint_IsSETUPReceived()) 12 | return ENDPOINT_RWCSTREAM_HostAborted; 13 | 14 | if (USB_DeviceState == DEVICE_STATE_Unattached) 15 | return ENDPOINT_RWCSTREAM_DeviceDisconnected; 16 | else if (USB_DeviceState == DEVICE_STATE_Suspended) 17 | return ENDPOINT_RWCSTREAM_BusSuspended; 18 | 19 | if (Endpoint_IsOUTReceived()) 20 | { 21 | while (Length && Endpoint_BytesInEndpoint()) 22 | { 23 | TEMPLATE_TRANSFER_BYTE(DataStream); 24 | Length--; 25 | } 26 | 27 | Endpoint_ClearOUT(); 28 | } 29 | } 30 | 31 | while (!(Endpoint_IsINReady())) 32 | { 33 | if (USB_DeviceState == DEVICE_STATE_Unattached) 34 | return ENDPOINT_RWCSTREAM_DeviceDisconnected; 35 | else if (USB_DeviceState == DEVICE_STATE_Suspended) 36 | return ENDPOINT_RWCSTREAM_BusSuspended; 37 | } 38 | 39 | return ENDPOINT_RWCSTREAM_NoError; 40 | } 41 | 42 | 43 | #undef TEMPLATE_BUFFER_OFFSET 44 | #undef TEMPLATE_FUNC_NAME 45 | #undef TEMPLATE_TRANSFER_BYTE -------------------------------------------------------------------------------- /LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c: -------------------------------------------------------------------------------- 1 | uint8_t TEMPLATE_FUNC_NAME (const void* Buffer, 2 | uint16_t Length) 3 | { 4 | uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); 5 | bool LastPacketFull = false; 6 | 7 | if (Length > USB_ControlRequest.wLength) 8 | Length = USB_ControlRequest.wLength; 9 | else if (!(Length)) 10 | Endpoint_ClearIN(); 11 | 12 | while (Length || LastPacketFull) 13 | { 14 | if (Endpoint_IsSETUPReceived()) 15 | return ENDPOINT_RWCSTREAM_HostAborted; 16 | 17 | if (Endpoint_IsOUTReceived()) 18 | break; 19 | 20 | if (USB_DeviceState == DEVICE_STATE_Unattached) 21 | return ENDPOINT_RWCSTREAM_DeviceDisconnected; 22 | else if (USB_DeviceState == DEVICE_STATE_Suspended) 23 | return ENDPOINT_RWCSTREAM_BusSuspended; 24 | 25 | if (Endpoint_IsINReady()) 26 | { 27 | uint8_t BytesInEndpoint = Endpoint_BytesInEndpoint(); 28 | 29 | while (Length && (BytesInEndpoint < USB_ControlEndpointSize)) 30 | { 31 | TEMPLATE_TRANSFER_BYTE(DataStream); 32 | Length--; 33 | BytesInEndpoint++; 34 | } 35 | 36 | LastPacketFull = (BytesInEndpoint == USB_ControlEndpointSize); 37 | Endpoint_ClearIN(); 38 | } 39 | } 40 | 41 | while (!(Endpoint_IsOUTReceived())) 42 | { 43 | if (USB_DeviceState == DEVICE_STATE_Unattached) 44 | return ENDPOINT_RWCSTREAM_DeviceDisconnected; 45 | else if (USB_DeviceState == DEVICE_STATE_Suspended) 46 | return ENDPOINT_RWCSTREAM_BusSuspended; 47 | } 48 | 49 | return ENDPOINT_RWCSTREAM_NoError; 50 | } 51 | 52 | #undef TEMPLATE_BUFFER_OFFSET 53 | #undef TEMPLATE_FUNC_NAME 54 | #undef TEMPLATE_TRANSFER_BYTE -------------------------------------------------------------------------------- /LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_RW.c: -------------------------------------------------------------------------------- 1 | uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer, 2 | uint16_t Length 3 | __CALLBACK_PARAM) 4 | { 5 | uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); 6 | uint8_t ErrorCode; 7 | 8 | if ((ErrorCode = Endpoint_WaitUntilReady())) 9 | return ErrorCode; 10 | 11 | #if defined(FAST_STREAM_TRANSFERS) 12 | uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); 13 | 14 | if (Length >= 8) 15 | { 16 | Length -= BytesRemToAlignment; 17 | 18 | switch (BytesRemToAlignment) 19 | { 20 | default: 21 | do 22 | { 23 | if (!(Endpoint_IsReadWriteAllowed())) 24 | { 25 | TEMPLATE_CLEAR_ENDPOINT(); 26 | 27 | #if !defined(NO_STREAM_CALLBACKS) 28 | if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) 29 | return ENDPOINT_RWSTREAM_CallbackAborted; 30 | #endif 31 | 32 | if ((ErrorCode = Endpoint_WaitUntilReady())) 33 | return ErrorCode; 34 | } 35 | 36 | Length -= 8; 37 | 38 | TEMPLATE_TRANSFER_BYTE(DataStream); 39 | case 7: TEMPLATE_TRANSFER_BYTE(DataStream); 40 | case 6: TEMPLATE_TRANSFER_BYTE(DataStream); 41 | case 5: TEMPLATE_TRANSFER_BYTE(DataStream); 42 | case 4: TEMPLATE_TRANSFER_BYTE(DataStream); 43 | case 3: TEMPLATE_TRANSFER_BYTE(DataStream); 44 | case 2: TEMPLATE_TRANSFER_BYTE(DataStream); 45 | case 1: TEMPLATE_TRANSFER_BYTE(DataStream); 46 | } while (Length >= 8); 47 | } 48 | } 49 | #endif 50 | 51 | while (Length) 52 | { 53 | if (!(Endpoint_IsReadWriteAllowed())) 54 | { 55 | TEMPLATE_CLEAR_ENDPOINT(); 56 | 57 | #if !defined(NO_STREAM_CALLBACKS) 58 | if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) 59 | return ENDPOINT_RWSTREAM_CallbackAborted; 60 | #endif 61 | 62 | if ((ErrorCode = Endpoint_WaitUntilReady())) 63 | return ErrorCode; 64 | } 65 | else 66 | { 67 | TEMPLATE_TRANSFER_BYTE(DataStream); 68 | Length--; 69 | } 70 | } 71 | 72 | return ENDPOINT_RWSTREAM_NoError; 73 | } 74 | 75 | #undef TEMPLATE_FUNC_NAME 76 | #undef TEMPLATE_BUFFER_TYPE 77 | #undef TEMPLATE_TRANSFER_BYTE 78 | #undef TEMPLATE_CLEAR_ENDPOINT 79 | #undef TEMPLATE_BUFFER_OFFSET -------------------------------------------------------------------------------- /LUFA/Drivers/USB/LowLevel/Template/Template_Pipe_RW.c: -------------------------------------------------------------------------------- 1 | uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer, 2 | uint16_t Length 3 | __CALLBACK_PARAM) 4 | { 5 | uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length)); 6 | uint8_t ErrorCode; 7 | 8 | Pipe_SetPipeToken(TEMPLATE_TOKEN); 9 | 10 | if ((ErrorCode = Pipe_WaitUntilReady())) 11 | return ErrorCode; 12 | 13 | #if defined(FAST_STREAM_TRANSFERS) 14 | uint8_t BytesRemToAlignment = (Pipe_BytesInPipe() & 0x07); 15 | 16 | if (Length >= 8) 17 | { 18 | Length -= BytesRemToAlignment; 19 | 20 | switch (BytesRemToAlignment) 21 | { 22 | default: 23 | do 24 | { 25 | if (!(Pipe_IsReadWriteAllowed())) 26 | { 27 | TEMPLATE_CLEAR_PIPE(); 28 | 29 | #if !defined(NO_STREAM_CALLBACKS) 30 | if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) 31 | return PIPE_RWSTREAM_CallbackAborted; 32 | #endif 33 | 34 | if ((ErrorCode = Pipe_WaitUntilReady())) 35 | return ErrorCode; 36 | } 37 | 38 | Length -= 8; 39 | 40 | TEMPLATE_TRANSFER_BYTE(DataStream); 41 | case 7: TEMPLATE_TRANSFER_BYTE(DataStream); 42 | case 6: TEMPLATE_TRANSFER_BYTE(DataStream); 43 | case 5: TEMPLATE_TRANSFER_BYTE(DataStream); 44 | case 4: TEMPLATE_TRANSFER_BYTE(DataStream); 45 | case 3: TEMPLATE_TRANSFER_BYTE(DataStream); 46 | case 2: TEMPLATE_TRANSFER_BYTE(DataStream); 47 | case 1: TEMPLATE_TRANSFER_BYTE(DataStream); 48 | } while (Length >= 8); 49 | } 50 | } 51 | #endif 52 | 53 | while (Length) 54 | { 55 | if (!(Pipe_IsReadWriteAllowed())) 56 | { 57 | TEMPLATE_CLEAR_PIPE(); 58 | 59 | #if !defined(NO_STREAM_CALLBACKS) 60 | if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) 61 | return PIPE_RWSTREAM_CallbackAborted; 62 | #endif 63 | 64 | if ((ErrorCode = Pipe_WaitUntilReady())) 65 | return ErrorCode; 66 | } 67 | else 68 | { 69 | TEMPLATE_TRANSFER_BYTE(DataStream); 70 | Length--; 71 | } 72 | } 73 | 74 | return PIPE_RWSTREAM_NoError; 75 | } 76 | 77 | #undef TEMPLATE_FUNC_NAME 78 | #undef TEMPLATE_BUFFER_TYPE 79 | #undef TEMPLATE_TOKEN 80 | #undef TEMPLATE_TRANSFER_BYTE 81 | #undef TEMPLATE_CLEAR_PIPE 82 | #undef TEMPLATE_BUFFER_OFFSET 83 | -------------------------------------------------------------------------------- /LUFA/License.txt: -------------------------------------------------------------------------------- 1 | Permission to use, copy, modify, and distribute this software 2 | and its documentation for any purpose is hereby granted without 3 | fee, provided that the above copyright notice appear in all 4 | copies and that both that the copyright notice and this 5 | permission notice and warranty disclaimer appear in supporting 6 | documentation, and that the name of the author not be used in 7 | advertising or publicity pertaining to distribution of the 8 | software without specific, written prior permission. 9 | 10 | The author disclaim all warranties with regard to this 11 | software, including all implied warranties of merchantability 12 | and fitness. In no event shall the author be liable for any 13 | special, indirect or consequential damages or any damages 14 | whatsoever resulting from loss of use, data or profits, whether 15 | in an action of contract, negligence or other tortious action, 16 | arising out of or in connection with the use or performance of 17 | this software. 18 | -------------------------------------------------------------------------------- /LUFA/ManPages/AboutLUFA.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_AboutLUFA About LUFA 9 | * 10 | * This section of the manual contains information about the library as a whole, including its supported targets, 11 | * past and planned changes, and links to other projects incorporating LUFA. 12 | * 13 | * Subsections: 14 | * \li \subpage Page_DeviceSupport - Current Device and Hardware Support 15 | * \li \subpage Page_Resources - LUFA and USB Related Resources 16 | * \li \subpage Page_ChangeLog - Project Changelog 17 | * \li \subpage Page_FutureChanges - Planned Changes to the Library 18 | * \li \subpage Page_LUFAPoweredProjects - Other Projects Using LUFA 19 | */ 20 | -------------------------------------------------------------------------------- /LUFA/ManPages/AlternativeStacks.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_AlternativeStacks Alternative USB AVR Stacks 9 | * 10 | * LUFA is not the only stack available for the USB AVRs, although it is perhaps the best (see \ref Page_WhyUseLUFA). 11 | * In the interests of completeness and user choice, other known USB AVR stacks are listed here. 12 | * 13 | * \section Sec_HardwareStacks Hardware USB AVR Stacks 14 | * These are the known alternative USB stacks which are designed for and run exclusively on the USB AVR series microcontrollers, 15 | * which contain on-chip USB controller hardware for maximum features and speed. 16 | * 17 | * - Name: Atmel USB AVR Stack (Atmel Inc.) \n 18 | * Cost: Free \n 19 | * License: Atmel Limited License (see Atmel download for details) \n 20 | * Website: http://atmel.com/dyn/products/app_notes.asp?family_id=607#USB \n 21 | * Description: This is the official Atmel USB AVR stack, for their 8-bit USB AVR lineup. Each series of 22 | * USB AVR is separated into a separate download stack, which is both AVR-GCC and IAR compatible. 23 | * 24 | * - Name: Dr. Stefan Salewski's AT90USB1287 Stack (Dr. Stefan Salewski) \n 25 | * Cost: Free \n 26 | * License: GPL \n 27 | * Website: http://www.ssalewski.de/AT90USB_firmware.html.en \n 28 | * Description: This is a GPL'd library specifically designed for the AT90USB1287, by Dr. Stefan Salewski, a 29 | * German Physicist. It compiles for AVR-GCC and can potentially be modified to work on other USB 30 | * AVR models. 31 | * 32 | * - Name: PJRC Teensy Stack (Paul Stoffregen) \n 33 | * Cost: Free \n 34 | * License: BSD \n 35 | * Website: http://www.pjrc.com/teensy/usb_debug_only.html \n 36 | * Description: Not so much a complete stack as a collection of USB enabled demos, this library is specifically 37 | * designed for the PJRC Teensy line of USB AVRs, and thus may need to be modified for other USB AVR 38 | * chips. These minimal code samples shows the inner workings of the USB controller, without all the 39 | * abstraction present in most other USB AVR stacks. 40 | * 41 | * \section Sec_SoftwareStacks Software AVR Stacks 42 | * These are the known alternative USB stacks which can run on regular AVR models, lacking dedicated hardware USB controllers 43 | * via a bit-banged (emulated) version of the USB protocol. They are limited in their capabilities due to the cycles required 44 | * to be dedicated to managing the USB bus, but offer a cheap way to implement USB functionality into a design. 45 | * 46 | * - Name: AVR309: Software USB (Atmel) \n 47 | * Cost: Free \n 48 | * License: None Stated \n 49 | * Website: http://www.atmel.com/dyn/Products/app_notes.asp?family_id=607 \n 50 | * Description: Atmel's official software USB implementation, an Application Note containing work by Igor Cesko. This 51 | * is a minimal assembly-only implementation of software USB, providing HID functionality. Less compile 52 | * options than V-USB (see below). 53 | * 54 | * - Name: V-USB (Objective Development) \n 55 | * Cost: Free for some uses, see website for licensing \n 56 | * License: Dual GPL2/Custom \n 57 | * Website: http://www.obdev.at/products/vusb/index.html \n 58 | * Description: Well regarded and complete USB 1.1 software stack for several AVR models, implementing Low Speed HID. 59 | * Used in many commercial and non-commercial designs, with user-submitted projects available for viewing 60 | * on the company's website. Uses C language code mixed with assembly for time-critical sections. 61 | */ 62 | 63 | -------------------------------------------------------------------------------- /LUFA/ManPages/Author.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jj1bdx/arduino-atmega16u2/a5cd7019dbc114f72d0ff1079c4333b639307256/LUFA/ManPages/Author.jpg -------------------------------------------------------------------------------- /LUFA/ManPages/BuildingLinkableLibraries.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_BuildLibrary Building as a Linkable Library 8 | * 9 | * The LUFA library can be built as a proper linkable library (with the extention .a) under AVR-GCC, so that 10 | * the library does not need to be recompiled with each revision of a user project. Instructions for creating 11 | * a library from a given source tree can be found in the AVR-GCC user manual included in the WinAVR install 12 | * /Docs/ directory. 13 | * 14 | * However, building the library is not recommended, as the static (compile-time) options will be 15 | * unable to be changed without a recompilation of the LUFA code. Therefore, if the library is to be built 16 | * from the LUFA source, it should be made to be application-specific and compiled with the static options 17 | * that are required for each project (which should be recorded along with the library). 18 | * 19 | * Normal library use has the library components compiled in at the same point as the application code, as 20 | * demonstrated in the library demos and applications. This is the preferred method, as the library is recompiled 21 | * each time to ensure that all static options for a particular application are applied. 22 | */ 23 | -------------------------------------------------------------------------------- /LUFA/ManPages/ChangeLog.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jj1bdx/arduino-atmega16u2/a5cd7019dbc114f72d0ff1079c4333b639307256/LUFA/ManPages/ChangeLog.txt -------------------------------------------------------------------------------- /LUFA/ManPages/CompilingApps.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_CompilingApps Compiling the Demos, Bootloaders and Projects 8 | * 9 | * The following details how to compile the included LUFA demos, applications and bootloaders using AVR-GCC. 10 | * 11 | * \section Sec_Prerequisites Prerequisites 12 | * Before you can compile any of the LUFA library code or demos, you will need a recent distribution of avr-libc (1.6.2+) 13 | * and the AVR-GCC (4.2+) compiler. For Windows users, the best way to obtain these is the WinAVR project 14 | * (http://winavr.sourceforge.net) as this provides a single-file setup for everything required to compile your 15 | * own AVR projects. 16 | * 17 | * \section Sec_Compiling Compiling a LUFA Application 18 | * Compiling the LUFA demos, applications and/or bootloaders is very simple. LUFA comes with makefile scripts for 19 | * each individual demo, bootloader and project folder, as well as scripts in the /Demos/, /Bootloaders/, /Projects/ 20 | * and the LUFA root directory. This means that compilation can be started from any of the above directories, with 21 | * a build started from an upper directory in the directory structure executing build of all child directories under it. 22 | * This means that while a build inside a particular demo directory will build only that particular demo, a build stated 23 | * from the /Demos/ directory will build all LUFA demo projects sequentially. 24 | * 25 | * 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 26 | * of interest. To remove compiled files (including the binary output, all intermediately files and all diagnostic output 27 | * files), execute "make clean". Once a "make all" has been run and no errors were encountered, the resulting binary will 28 | * be located in the generated ".HEX" file. If your project makes use of pre-initialized EEPROM variables, the generated ".EEP" 29 | * file will contain the project's EEPROM data. 30 | */ -------------------------------------------------------------------------------- /LUFA/ManPages/DevelopingWithLUFA.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_DevelopingWithLUFA Developing With LUFA 9 | * 10 | * This section of the manual contains information on LUFA development, such as Getting Started information, 11 | * information on compile-time tuning of the library and other developer-related sections. 12 | * 13 | * Subsections: 14 | * \li \subpage Page_TokenSummary - Summary of Compile Time Tokens 15 | * \li \subpage Page_Migration - Migrating from an Older LUFA Version 16 | * \li \subpage Page_VIDPID - Allocated USB VID and PID Values 17 | * \li \subpage Page_BuildLibrary - Building as a Linkable Library 18 | * \li \subpage Page_WritingBoardDrivers - How to Write Custom Board Drivers 19 | * \li \subpage Page_SoftwareBootloaderStart - How to jump to the bootloader in software 20 | * \li \subpage Page_SchedulerOverview - Overview of the Simple LUFA Scheduler (DEPRECATED) 21 | */ 22 | -------------------------------------------------------------------------------- /LUFA/ManPages/DeviceSupport.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_DeviceSupport Device and Hardware Support 9 | * 10 | * Currently supported AVR models: 11 | * - AT90USB82 (USB Device Only) 12 | * - ATMEGA8U2 (USB Device Only) 13 | * - AT90USB162 (USB Device Only) 14 | * - ATMEGA16U2 (USB Device Only) 15 | * - ATMEGA16U4 (USB Device Only) 16 | * - ATMEGA32U2 (USB Device Only) 17 | * - ATMEGA32U4 (USB Device Only) 18 | * - ATMEGA32U6 (USB Device Only) 19 | * - AT90USB646 (USB Device Only) 20 | * - AT90USB647 (USB Host and Device) 21 | * - AT90USB1286 (USB Device Only) 22 | * - AT90USB1287 (USB Host and Device) 23 | * 24 | * Currently supported Atmel boards (see \ref Group_BoardTypes): 25 | * - AT90USBKEY 26 | * - ATAVRUSBRF01 27 | * - EVK527 28 | * - RZUSBSTICK 29 | * - STK525 30 | * - STK526 31 | * - XPLAIN (Both original first revision board, and newer boards with a different Dataflash model) 32 | * 33 | * Currently supported third-party boards (see \ref Group_BoardTypes): 34 | * - Bumble-B (using officially recommended peripheral layout) 35 | * - Benito 36 | * - JM-DB-U2 37 | * - Teensy (all revisions and versions) 38 | * - USBTINY MKII (all revisions and versions) 39 | * - Any Other Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers) 40 | */ 41 | -------------------------------------------------------------------------------- /LUFA/ManPages/Donating.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_Donating Donating to Support This Project 9 | * 10 | * \image html Author.jpg "Dean Camera, LUFA Developer" 11 | * 12 | * I am a 20 year old University student studying for a double degree in Computer Science and Electronics Engineering. 13 | * The development and support of this library requires much effort from myself, as I am the sole developer, maintainer 14 | * and supporter. Please consider donating a small amount to support this and my future Open Source projects - All 15 | * donations are greatly appreciated. 16 | * 17 | * Note that commercial entities can remove the attribution portion of the LUFA license by a one-time fee - see 18 | * \ref Page_LicenseInfo for more details (Note: Please do NOT pay this in advance through the donation link below - 19 | * contact author for payment details.). 20 | * 21 | * \image html "http://www.pledgie.com/campaigns/6927.png?skin_name=chrome" 22 | * Donate to this project via PayPal - Thanks in Advance! 23 | */ 24 | 25 | -------------------------------------------------------------------------------- /LUFA/ManPages/FutureChanges.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_FutureChanges Future Changes 8 | * 9 | * Below is a list of future changes which are proposed for the LUFA library, but not yet started/complete. 10 | * This gives an unordered list of future changes which will be available in future releases of the library. 11 | * If you have an item to add to this list, please contact the library author via email, the LUFA mailing list, 12 | * or post your suggestion as an enhancement request to the project bug tracker. 13 | * 14 | * Targeted for Future Releases: 15 | * - Code Features 16 | * -# Add hub support when in Host mode for multiple devices 17 | * -# Add ability to get number of bytes not written with pipe/endpoint write routines after an error 18 | * -# Add standardized descriptor names to class driver structures 19 | * -# Change makefiles to allow for absolute LUFA location to be used 20 | * - Documentation/Support 21 | * -# Add detailed overviews of how each demo works 22 | * -# Add board overviews 23 | * -# Write LUFA tutorials 24 | * - Demos/Projects 25 | * -# Multiple-Report HID device 26 | * -# Device/Host USB bridge 27 | * -# Alternative (USB-IF endorsed) USB-CDC Ethernet Class 28 | * -# Finish Test and Measurement Class demo 29 | * -# Finish BluetoothHost demo 30 | * -# Finish SideShow demo 31 | * -# Finish StandaloneProgrammer project 32 | * -# Finish MIDIToneGenerator project 33 | * -# Correct mishandling of error cases in Mass Storage demos 34 | * - Ports 35 | * -# AVR32 UC3B series microcontrollers 36 | * -# Atmel ARM7 series microcontrollers 37 | * -# Other (commercial) C compilers 38 | */ 39 | -------------------------------------------------------------------------------- /LUFA/ManPages/GettingStarted.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_GettingStarted Getting Started 8 | * 9 | * Out of the box, LUFA contains a large number of pre-made class demos for you to test, experiment with and 10 | * ultimately build upon for your own projects. All the demos (where possible) come pre-configured to build and 11 | * run correctly on the AT90USB1287 AVR microcontroller, mounted on the Atmel USBKEY board and running at an 8MHz 12 | * master clock. This is due to two reasons; one, it is the hardware the author possesses, and two, it is the most 13 | * popular Atmel USB demonstration board to date. To learn how to reconfigure, recompile and program the included 14 | * LUFA applications using different settings, see the subsections below. 15 | * 16 | * Most of the included demos in the /Demos/ folder come in both ClassDriver and LowLevel varieties. If you are new 17 | * to LUFA, it is highly recommended that you look at the ClassDriver versions first, which use the pre-made USB 18 | * Class Drivers (\ref Group_USBClassDrivers) to simplify the use of the standard USB classes in user applications. 19 | * 20 | * For an overview of the included library applications, bootloaders and demos, see \ref Page_LibraryApps. 21 | * 22 | * Subsections: 23 | * \li \subpage Page_ConfiguringApps - How to Configure the Included Demos, Projects and Bootloaders 24 | * \li \subpage Page_CompilingApps - How to Compile the Included Demos, Projects and Bootloaders 25 | * \li \subpage Page_ProgrammingApps - How to Program an AVR with the Included Demos, Projects and Bootloaders 26 | */ 27 | -------------------------------------------------------------------------------- /LUFA/ManPages/Groups.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** @defgroup Group_BoardDrivers Board Drivers 8 | * 9 | * Functions, macros, variables, enums and types related to the control of physical board hardware. 10 | */ 11 | 12 | /** @defgroup Group_PeripheralDrivers On-chip Peripheral Drivers 13 | * 14 | * Functions, macros, variables, enums and types related to the control of AVR subsystems. 15 | */ 16 | 17 | /** @defgroup Group_MiscDrivers Miscellaneous Drivers 18 | * 19 | * Miscellaneous driver Functions, macros, variables, enums and types. 20 | */ 21 | -------------------------------------------------------------------------------- /LUFA/ManPages/LUFA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jj1bdx/arduino-atmega16u2/a5cd7019dbc114f72d0ff1079c4333b639307256/LUFA/ManPages/LUFA.png -------------------------------------------------------------------------------- /LUFA/ManPages/LUFAvsAtmelStack.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_LUFAvsAtmelStack LUFA vs the Atmel Stack 9 | * 10 | * Atmel offers an official USB AVR stack, which may be incorporated into user projects and products. As LUFA and the Atmel 11 | * stack aims to give roughly the same functionality to a design, it is often asked what advantages LUFA carries over the 12 | * official Atmel USB stack. Below are just some of the advantages to choosing LUFA over the official stack. 13 | * 14 | * - Licensing: 15 | * LUFA is released under a very permissive MIT license (see \ref Page_LicenseInfo), while the Atmel stack carries several 16 | * restrictions as to how and where it can be used. LUFA's licensing should be suitable for both Commercial and Non-Commercial 17 | * entities alike. 18 | * 19 | * - Demos and Projects: 20 | * Unlike the Atmel stack, LUFA comes with many different Device and Host mode Demos and Projects ready to run out of the box. 21 | * Atmel favors separate downloads for each of their (small set) of USB AVR demos, which requires more time and offers less 22 | * to the end-user. LUFA also contains several open source Bootloaders, which can be modified as the user wishes to suit his or 23 | * her application, instead of being forced to use Atmel's single prebuilt (closed-source) DFU bootloader. 24 | * 25 | * - Central Library Code: 26 | * LUFA is designed to allow the central library core code to be shared amongst several projects, so long as the compiled object 27 | * files are cleaned between different projects. This is in direct contrast to the Atmel library, which is strongly coupled to the 28 | * project it is integrated with. Using LUFA allows for only one copy of the library core to be needed for all applications, and 29 | * makes updating the library used in all projects a trivial copy-and-paste process. 30 | * 31 | * - Clean API: 32 | * One of the main design goals of LUFA is to make the API easy to use. While LUFA is a fluid project which has undergone many 33 | * API improvements, the API is arguably much nicer to use and easier to understand than the equivalent Atmel stack code. LUFA's 34 | * API is also more complete than the Atmel stack, and contains many features to speed up application development. 35 | * 36 | * - Full Hardware Support: 37 | * LUFA supports the full range of Atmel's USB AVR microcontrollers (see \ref Page_DeviceSupport), with porting between chips being 38 | * as simple as a single compile switch in many cases. Atmel's stack requires different libraries to be used based on the USB AVR 39 | * microcontroller series, complicating the process of moving between USB AVR models. In addition, LUFA contains drivers for all the 40 | * hardware contained on Atmel's USB AVR based boards, so you can get started quickly and easily. 41 | * 42 | * - Better Library Support: 43 | * As many people are now using LUFA, there is a community being built around it. You can get answers to your LUFA related questions 44 | * quickly by either emailing the library author (subject to author's schedule) or by posting to the official LUFA support mailing list. 45 | */ 46 | 47 | -------------------------------------------------------------------------------- /LUFA/ManPages/LibraryResources.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_Resources Library Resources 9 | * 10 | * \section Sec_ProjectPages LUFA Related Webpages 11 | * Project Homepage: http://www.fourwalledcubicle.com/LUFA.php \n 12 | * Author's Website: http://www.fourwalledcubicle.com \n 13 | * Development Blog: http://www.fourwalledcubicle.com/blog \n 14 | * Commercial Licenses: http://fourwalledcubicle.com/PurchaseLUFA.php \n 15 | * 16 | * \section Sec_ProjectHelp Assistance With LUFA 17 | * Discussion Group: http://groups.google.com/group/myusb-support-list \n 18 | * Author's Email: dean [at] fourwalledcubicle [dot] com 19 | * Author's Skype: abcminiuser 20 | * 21 | * \section Sec_InDevelopment Latest In-Development Source Code 22 | * Official Releases, SVN Access, Issue Tracker: http://code.google.com/p/lufa-lib/ \n 23 | * Git Access: http://github.com/abcminiuser/lufa-lib \n 24 | * Mercurial Access: http://bitbucket.org/abcminiuser/lufa-lib \n 25 | * Latest Repository Source Archive: http://github.com/abcminiuser/lufa-lib/archives/master \n 26 | * Commit RSS Feed: http://github.com/feeds/abcminiuser/commits/lufa-lib/master \n 27 | * 28 | * \section Sec_Toolchain AVR Toolchain 29 | * WinAVR Website: http://winavr.sourceforge.net \n 30 | * avr-libc Website: http://www.nongnu.org/avr-libc/ \n 31 | * 32 | * \section Sec_USBResources USB Resources 33 | * USB-IF Website: http://www.usb.org \n 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /LUFA/ManPages/LicenseInfo.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_LicenseInfo Source Code License 9 | * 10 | * The LUFA library is currently released under the MIT license, included below. 11 | * 12 | * Commercial entities can opt out of the public disclosure clause in this license 13 | * for a one-time US$1500 payment. This provides a non-exclusive modified MIT licensed which 14 | * allows for the free use of the LUFA library, bootloaders and (where the sole copyright 15 | * is attributed to Dean Camera) demos without public disclosure within an organization, in 16 | * addition to three free hours of consultation with the library author, and priority support. 17 | * Please visit the Commercial License link on \ref Page_Resources for more information on 18 | * ordering a commercial license for your company. 19 | * 20 | * \verbinclude License.txt 21 | */ 22 | -------------------------------------------------------------------------------- /LUFA/ManPages/MainPage.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \mainpage 9 | * 10 | * \image html LUFA.png 11 | *
Logo design by Ryo - http://ryophotography.wordpress.com
12 | * \n 13 | * 14 | * LUFA is donationware. For author and donation information, see \ref Page_Donating. 15 | * 16 | * LUFA is an open-source USB library for the USB-enabled AVR microcontrollers, released under the MIT license (see \ref Page_LicenseInfo). 17 | * It supports a large number of USB AVR models and boards (see \ref Page_DeviceSupport). It is designed to provide an easy to use, 18 | * feature rich framework for the development of USB peripherals and hosts. 19 | * 20 | * LUFA focuses on the microcontroller side of USB development only; it includes no PC host USB driver development facilities - other projects 21 | * such as the Windows Driver Development Kit, Windows USB Device Mode Framework and libusb may be of interest for developing custom OS drivers. 22 | * 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 23 | * simplicity. 24 | * 25 | * The library is currently in a stable release, suitable for download and incorporation into user projects for 26 | * both host and device modes. For information about the project progression, see the blog link at \ref Page_Resources. 27 | * 28 | * LUFA is written specifically for the free AVR-GCC compiler, and uses several GCC-only extensions to make the 29 | * library API more streamlined and robust. You can download AVR-GCC for free in a convenient windows package, 30 | * from the the WinAVR website (see \ref Page_Resources). 31 | * 32 | * The only required AVR peripherals for LUFA is the USB controller itself and interrupts - LUFA does not require the use of the 33 | * microcontroller's timers or other hardware, leaving more hardware to the application developer. 34 | * 35 | * Accompanying LUFA in the download package is a set of example demo applications, plus several Bootloaders of different classes 36 | * and open source LUFA powered projects. 37 | * 38 | * Subsections: 39 | * \li \subpage Page_WhyUseLUFA - What are the advantages of using LUFA? 40 | * \li \subpage Page_LUFAvsAtmelStack - How does LUFA compare to the Atmel USB AVR stack? 41 | * \li \subpage Page_AlternativeStacks - Alternative USB AVR Stacks 42 | * \li \subpage Page_LicenseInfo - Project source license and commercial use information 43 | * \li \subpage Page_Donating - Donating to support this project 44 | * \li \subpage Page_LibraryApps - Overview of included Demos, Bootloaders and Projects 45 | */ 46 | -------------------------------------------------------------------------------- /LUFA/ManPages/ProgrammingApps.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_ProgrammingApps Programming an Application into a USB AVR 8 | * 9 | * Once you have built an application, you will need a way to program in the resulting ".HEX" file (and, if your 10 | * application uses EEPROM variables with initial values, also a ".EEP" file) into your USB AVR. Normally, the 11 | * reprogramming of an AVR device must be performed using a special piece of programming hardware, through one of the 12 | * supported AVR programming protocols - ISP, HVSP, HVPP, JTAG or dW. This can be done through a custom programmer, 13 | * a third party programmer, or an official Atmel AVR tool - for more information, see the Atmel.com website. 14 | * 15 | * Alternatively, you can use the bootloader. From the Atmel factory, each USB AVR comes preloaded with the Atmel 16 | * DFU (Device Firmware Update) class bootloader, a small piece of AVR firmware which allows the remainder of the 17 | * AVR to be programmed through a non-standard interface such as the serial USART port, SPI, or (in this case) USB. 18 | * Bootloaders have the advantage of not requiring any special hardware for programming, and cannot usually be erased 19 | * or broken without an external programming device. They have disadvantages however; they cannot change the fuses of 20 | * the AVR (special configuration settings that control the operation of the chip itself) and a small portion of the 21 | * AVR's FLASH program memory must be reserved to contain the bootloader firmware, and thus cannot be used by the 22 | * loaded application. Atmel's DFU bootloader is either 4KB (for the smaller USB AVRs) or 8KB (for the larger USB AVRs). 23 | * 24 | * If you wish to use the DFU bootloader to program in your application, refer to your DFU programmer's documentation. 25 | * Atmel provides a free utility called FLIP which is USB AVR compatible, and an open source (Linux compatible) 26 | * alternative exists called "dfu-programmer". 27 | */ -------------------------------------------------------------------------------- /LUFA/ManPages/SchedulerOverview.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_SchedulerOverview LUFA Scheduler Overview 8 | * 9 | * THE LUFA SCHEDULER IS NOW DEPRECATED AND WILL BE REMOVED IN A FUTURE RELEASE. EXISTING CODE SHOULD CONVERT 10 | * TO STANDARD LOOPS AS SHOWN IN THE CURRENT LIBRARY DEMOS. 11 | * 12 | * 13 | * The LUFA library comes with a small, basic round-robbin scheduler which allows for small "tasks" to be executed 14 | * continuously in sequence, and enabled/disabled at runtime. Unlike a conventional, complex RTOS scheduler, the 15 | * LUFA scheduler is very simple in design and operation and is essentially a loop conditionally executing a series 16 | * of functions. 17 | * 18 | * Each LUFA scheduler task should be written similar to an ISR; it should execute quickly (so that no one task 19 | * hogs the processor, preventing another from running before some sort of timeout is exceeded). Unlike normal RTOS 20 | * tasks, each LUFA scheduler task is a regular function, and thus must be designed to be called, and designed to 21 | * return to the calling scheduler function repeatedly. Data which must be preserved between task calls should be 22 | * declared as global or (preferably) as a static local variable inside the task. 23 | * 24 | * The scheduler consists of a task list, listing all the tasks which can be executed by the scheduler. Once started, 25 | * each task is then called one after another, unless the task is stopped by another running task or interrupt. 26 | * 27 | * 28 | * If desired, the LUFA scheduler does not need to be used in a LUFA powered application. A more conventional 29 | * approach to application design can be used, or a proper scheduling RTOS inserted in the place of the LUFA scheduler. 30 | * In the case of the former the USB task must be run manually repeatedly to maintain USB communications, and in the 31 | * case of the latter a proper RTOS task must be set up to do the same. 32 | * 33 | * 34 | * For more information on the LUFA scheduler, see the Scheduler.h file documentation. 35 | */ 36 | -------------------------------------------------------------------------------- /LUFA/ManPages/SoftwareBootloaderJump.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_SoftwareBootloaderStart Entering the Bootloader via Software 9 | * 10 | * A common requirement of many applications is the ability to jump to the programmed bootloader of a chip 11 | * on demand, via the code's firmware (i.e. not as a result of any physical user interaction with the 12 | * hardware). This might be required because the device does not have any physical user input, or simply 13 | * just to streamline the device upgrade process on the host PC. 14 | * 15 | * The following C code snippet may be used to enter the bootloader upon request by the user application. 16 | * By using the watchdog to physically reset the controller, it is ensured that all system hardware is 17 | * completely reset to their defaults before the bootloader is run. This is important; since bootloaders 18 | * are written to occupy a very limited space, they usually make assumptions about the register states based 19 | * on the default values after a hard-reset of the chip. 20 | * 21 | * \code 22 | * #include 23 | * #include 24 | * #include 25 | * 26 | * #include 27 | * #include 28 | * 29 | * uint32_t Boot_Key ATTR_NO_INIT; 30 | * 31 | * #define MAGIC_BOOT_KEY 0xDC42ACCA 32 | * #define BOOTLOADER_START_ADDRESS (FLASH_SIZE_BYTES - BOOTLOADER_SEC_SIZE_BYTES) 33 | * 34 | * void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3); 35 | * void Bootloader_Jump_Check(void) 36 | * { 37 | * // If the reset source was the bootloader and the key is correct, clear it and jump to the bootloader 38 | * if ((MCUSR & (1<FLASH_SIZE_BYTES and 65 | * BOOTLOADER_SEC_SIZE_BYTES tokens should be replaced with the total flash size of the AVR 66 | * in bytes, and the allocated size of the bootloader section for the target AVR. 67 | * 68 | */ 69 | -------------------------------------------------------------------------------- /LUFA/ManPages/WhyUseLUFA.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** 8 | * \page Page_WhyUseLUFA Why Use LUFA? 9 | * 10 | * The LUFA Library has many advantages over implementing the code required to drive the USB AVRs directly. 11 | * It is much more preferable to incorporate LUFA into your existing projects - or even make a new project 12 | * using LUFA - than it is to start from scratch and use the USB AVR registers directly. Some of these reasons 13 | * are: 14 | * 15 | * - Portability: 16 | * The LUFA stack is designed to run (at some capacity) on the entire Atmel range of USB AVRs, regardless of the 17 | * exact USB controller revision used. If you decide to implement your own USB stack, you will either need to 18 | * code around the differences between each USB AVR controller's implementation between different chip models, or 19 | * require your code to run on only one specific USB AVR model series. 20 | * 21 | * - Speed of Development: 22 | * LUFA ships with a wide range of pre-made demos, bootloaders and projects for you to try, learn and extend. Each 23 | * of these demos are tested (where possible) across as many USB AVRs and Operating Systems as possible, to ensure 24 | * that they work under as many conditions as possible. In addition, there are inbuilt class drivers for several of 25 | * the USB classes which you can make use of in your projects with minimal effort. 26 | * 27 | * - Maintainability: 28 | * As LUFA takes care of much of the USB implementation, you can be left to focusing on your actual project's 29 | * functionality, rather than being held back developing and debugging the USB stack code. Since LUFA uses clear APIs 30 | * for USB development, your code will be more readable than if it had the low level USB stack code integrated into 31 | * it directly. Updating the LUFA library is a simple folder-replacement and gives new features and bug fixes in 32 | * seconds each time a new release is made. 33 | * 34 | * - Size: 35 | * Not just requiring less code to make complex USB devices, LUFA (under most cases with the correct compile options) 36 | * requires less FLASH space than Atmel's stack, meaning more space for the user application*. 37 | * 38 | * - Support: 39 | * Since many people are now using LUFA in their own projects, you can take advantage of other's knowledge when you run 40 | * into difficulties or need some advice. In addition, you can also email the library author to receive personalized 41 | * support when you need it (subject to author's schedule). 42 | * 43 | * * Atmel Stack Mouse Device Demo 4292 bytes, LUFA Mouse Low Level Device Demo 3372 bytes, under identical build 44 | * environments 45 | */ 46 | 47 | -------------------------------------------------------------------------------- /LUFA/ManPages/WritingBoardDrivers.txt: -------------------------------------------------------------------------------- 1 | /** \file 2 | * 3 | * This file contains special DoxyGen information for the generation of the main page and other special 4 | * documentation pages. It is not a project source file. 5 | */ 6 | 7 | /** \page Page_WritingBoardDrivers Writing LUFA Board Drivers 8 | * 9 | * LUFA ships with several basic pre-made board drivers, to control hardware present on the supported board 10 | * hardware - such as Dataflash ICs, LEDs, Joysticks, or other hardware peripherals. When compiling an application 11 | * which makes use of one or more board drivers located in LUFA/Drivers/Board, you must also indicate what board 12 | * hardware you are using in your project makefile. This is done by defining the BOARD macro using the -D switch 13 | * passed to the compiler, with a constant of BOARD_{Name}. For example -DBOARD=BOARD_USBKEY instructs the 14 | * compiler to use the USBKEY board hardware drivers. 15 | * 16 | * If your application does not use *any* board level drivers, you can omit the definition of the BOARD macro. 17 | * However, some users may wish to write their own custom board hardware drivers which are to remain compatible 18 | * with the LUFA hardware API. To do this, the BOARD macro should be defined to the value BOARD_USER. This indicates 19 | * that the board level drivers should be located in a folder named "Board" located inside the application's folder. 20 | * 21 | * When used, the driver stub files located in the DriverStubs folder should be copied to the user Board directory, 22 | * and fleshed out to include the values and code needed to control the custom board hardware. Once done, the existing 23 | * LUFA board level APIs (accessed in the regular LUFA/Drivers/Board/ folder) will redirect to the user board drivers, 24 | * maintaining code compatibility and allowing for a different board to be selected through the project makefile with 25 | * no code changes. 26 | */ 27 | -------------------------------------------------------------------------------- /LUFA/Scheduler/Scheduler.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | #include "Scheduler.h" 32 | 33 | volatile SchedulerDelayCounter_t Scheduler_TickCounter; 34 | volatile uint8_t Scheduler_TotalTasks; 35 | 36 | bool Scheduler_HasDelayElapsed(const uint16_t Delay, 37 | SchedulerDelayCounter_t* const DelayCounter) 38 | { 39 | SchedulerDelayCounter_t CurrentTickValue_LCL; 40 | SchedulerDelayCounter_t DelayCounter_LCL; 41 | 42 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) 43 | { 44 | CurrentTickValue_LCL = Scheduler_TickCounter; 45 | } 46 | 47 | DelayCounter_LCL = *DelayCounter; 48 | 49 | if (CurrentTickValue_LCL >= DelayCounter_LCL) 50 | { 51 | if ((CurrentTickValue_LCL - DelayCounter_LCL) >= Delay) 52 | { 53 | *DelayCounter = CurrentTickValue_LCL; 54 | return true; 55 | } 56 | } 57 | else 58 | { 59 | if (((MAX_DELAYCTR_COUNT - DelayCounter_LCL) + CurrentTickValue_LCL) >= Delay) 60 | { 61 | *DelayCounter = CurrentTickValue_LCL; 62 | return true; 63 | } 64 | } 65 | 66 | return false; 67 | } 68 | 69 | void Scheduler_SetTaskMode(const TaskPtr_t Task, 70 | const bool TaskStatus) 71 | { 72 | TaskEntry_t* CurrTask = &Scheduler_TaskList[0]; 73 | 74 | while (CurrTask != &Scheduler_TaskList[Scheduler_TotalTasks]) 75 | { 76 | if (CurrTask->Task == Task) 77 | { 78 | CurrTask->TaskStatus = TaskStatus; 79 | break; 80 | } 81 | 82 | CurrTask++; 83 | } 84 | } 85 | 86 | void Scheduler_SetGroupTaskMode(const uint8_t GroupID, 87 | const bool TaskStatus) 88 | { 89 | TaskEntry_t* CurrTask = &Scheduler_TaskList[0]; 90 | 91 | while (CurrTask != &Scheduler_TaskList[Scheduler_TotalTasks]) 92 | { 93 | if (CurrTask->GroupID == GroupID) 94 | CurrTask->TaskStatus = TaskStatus; 95 | 96 | CurrTask++; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /LUFA/Version.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * \brief LUFA library version constants. 34 | * 35 | * Version constants for informational purposes and version-specific macro creation. This header file contains the 36 | * current LUFA version number in several forms, for use in the user-application (for example, for printing out 37 | * whilst debugging, or for testing for version compatibility). 38 | */ 39 | 40 | #ifndef __LUFA_VERSION_H__ 41 | #define __LUFA_VERSION_H__ 42 | 43 | /* Public Interface - May be used in end-application: */ 44 | /* Macros: */ 45 | /** Indicates the version number of the library, as an integer. */ 46 | #define LUFA_VERSION_INTEGER 0x100807 47 | 48 | /** Indicates the version number of the library, as a string. */ 49 | #define LUFA_VERSION_STRING "100807" 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /LUFA/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # LUFA Library 3 | # Copyright (C) Dean Camera, 2010. 4 | # 5 | # dean [at] fourwalledcubicle [dot] com 6 | # www.fourwalledcubicle.com 7 | # 8 | 9 | # Makefile for the LUFA library itself. This can be used to generate the library documentation. 10 | 11 | 12 | # Check to see if the LUFA_PATH variable has not been set (the makefile is not being included from a project makefile) 13 | ifeq ($(origin LUFA_PATH), undefined) 14 | LUFA_ROOT_PATH = . 15 | else 16 | LUFA_ROOT_PATH = $(LUFA_PATH)/LUFA 17 | endif 18 | 19 | # Define module source file lists 20 | LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Device.c \ 21 | $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Endpoint.c \ 22 | $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Host.c \ 23 | $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/Pipe.c \ 24 | $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/USBController.c \ 25 | $(LUFA_ROOT_PATH)/Drivers/USB/LowLevel/USBInterrupt.c \ 26 | $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/ConfigDescriptor.c \ 27 | $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/DeviceStandardReq.c \ 28 | $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/Events.c \ 29 | $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/HostStandardReq.c \ 30 | $(LUFA_ROOT_PATH)/Drivers/USB/HighLevel/USBTask.c \ 31 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDParser.c 32 | LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/Audio.c \ 33 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDC.c \ 34 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HID.c \ 35 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorage.c \ 36 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDI.c \ 37 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDIS.c \ 38 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDC.c \ 39 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HID.c \ 40 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorage.c \ 41 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDI.c \ 42 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/Printer.c \ 43 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDIS.c \ 44 | $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImage.c 45 | LUFA_SRC_TEMPERATURE = $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c 46 | LUFA_SRC_SERIAL = $(LUFA_ROOT_PATH)/Drivers/Peripheral/Serial.c 47 | LUFA_SRC_SERIALSTREAM = $(LUFA_ROOT_PATH)/Drivers/Peripheral/SerialStream.c 48 | LUFA_SRC_TWI = $(LUFA_ROOT_PATH)/Drivers/Peripheral/TWI.c 49 | LUFA_SRC_SCHEDULER = $(LUFA_ROOT_PATH)/Scheduler/Scheduler.c 50 | 51 | 52 | # Check to see if the LUFA_PATH variable has not been set (the makefile is not being included from a project makefile) 53 | ifeq ($(origin LUFA_PATH), undefined) 54 | LUFA_SRC_ALL_FILES = $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) \ 55 | $(LUFA_SRC_TEMPERATURE) $(LUFA_SRC_SERIAL) \ 56 | $(LUFA_SRC_SERIALSTREAM) $(LUFA_SRC_TWI) \ 57 | $(LUFA_SRC_SCHEDULER) 58 | 59 | all: 60 | 61 | clean: 62 | rm -f $(LUFA_SRC_ALL_FILES:%.c=%.o) 63 | 64 | clean_list: 65 | 66 | doxygen: 67 | @echo Generating Library Documentation... 68 | ( cat Doxygen.conf ; echo "PROJECT_NUMBER=`grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2`" ) | doxygen - 69 | @echo Documentation Generation Complete. 70 | 71 | clean_doxygen: 72 | rm -rf Documentation 73 | 74 | .PHONY: all clean clean_list doxygen clean_doxygen 75 | endif -------------------------------------------------------------------------------- /Projects/arduino-usbserial/Arduino-usbserial.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Arduino-usbserial.c. 34 | */ 35 | 36 | #ifndef _ARDUINO_USBSERIAL_H_ 37 | #define _ARDUINO_USBSERIAL_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "Descriptors.h" 46 | 47 | #include "Lib/LightweightRingBuff.h" 48 | 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | /* Macros: */ 56 | /** LED mask for the library LED driver, to indicate TX activity. */ 57 | #define LEDMASK_TX LEDS_LED1 58 | 59 | /** LED mask for the library LED driver, to indicate RX activity. */ 60 | #define LEDMASK_RX LEDS_LED2 61 | 62 | /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ 63 | #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) 64 | 65 | /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ 66 | #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) 67 | 68 | /* Function Prototypes: */ 69 | void SetupHardware(void); 70 | 71 | void EVENT_USB_Device_Connect(void); 72 | void EVENT_USB_Device_Disconnect(void); 73 | void EVENT_USB_Device_ConfigurationChanged(void); 74 | void EVENT_USB_Device_UnhandledControlRequest(void); 75 | 76 | void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); 77 | void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); 78 | 79 | #endif /* _ARDUINO_USBSERIAL_H_ */ 80 | -------------------------------------------------------------------------------- /Projects/arduino-usbserial/Board/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /* 32 | Board LEDs driver for the Benito board, from www.dorkbotpdx.org. 33 | */ 34 | 35 | #ifndef __LEDS_ARDUINOUNO_H__ 36 | #define __LEDS_ARDUINOUNO_H__ 37 | 38 | /* Includes: */ 39 | #include 40 | 41 | /* Enable C linkage for C++ Compilers: */ 42 | #if defined(__cplusplus) 43 | extern "C" { 44 | #endif 45 | 46 | /* Preprocessor Checks: */ 47 | #if !defined(INCLUDE_FROM_LEDS_H) 48 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 49 | #endif 50 | 51 | /* Public Interface - May be used in end-application: */ 52 | /* Macros: */ 53 | /** LED mask for the first LED on the board. */ 54 | #define LEDS_LED1 (1 << 5) 55 | 56 | /** LED mask for the second LED on the board. */ 57 | #define LEDS_LED2 (1 << 4) 58 | 59 | /** LED mask for all the LEDs on the board. */ 60 | #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) 61 | 62 | /** LED mask for the none of the board LEDs */ 63 | #define LEDS_NO_LEDS 0 64 | 65 | /* Inline Functions: */ 66 | #if !defined(__DOXYGEN__) 67 | static inline void LEDs_Init(void) 68 | { 69 | DDRD |= LEDS_ALL_LEDS; 70 | PORTD |= LEDS_ALL_LEDS; 71 | } 72 | 73 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 74 | { 75 | PORTD &= ~LEDMask; 76 | } 77 | 78 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 79 | { 80 | PORTD |= LEDMask; 81 | } 82 | 83 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 84 | { 85 | PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); 86 | } 87 | 88 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) 89 | { 90 | PORTD = ((PORTD | ActiveMask) & ~LEDMask); 91 | } 92 | 93 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 94 | { 95 | PORTD ^= LEDMask; 96 | } 97 | 98 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 99 | static inline uint8_t LEDs_GetLEDs(void) 100 | { 101 | return (PORTD & LEDS_ALL_LEDS); 102 | } 103 | #endif 104 | 105 | /* Disable C linkage for C++ Compilers: */ 106 | #if defined(__cplusplus) 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Projects/arduino-usbserial/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | /* Product-specific definitions: */ 46 | #define ARDUINO_UNO_PID 0x0001 47 | #define ARDUINO_MEGA2560_PID 0x0010 48 | 49 | /* Macros: */ 50 | /** Endpoint number of the CDC device-to-host notification IN endpoint. */ 51 | #define CDC_NOTIFICATION_EPNUM 2 52 | 53 | /** Endpoint number of the CDC device-to-host data IN endpoint. */ 54 | #define CDC_TX_EPNUM 3 55 | 56 | /** Endpoint number of the CDC host-to-device data OUT endpoint. */ 57 | #define CDC_RX_EPNUM 4 58 | 59 | /** Size in bytes of the CDC device-to-host notification IN endpoint. */ 60 | #define CDC_NOTIFICATION_EPSIZE 8 61 | 62 | /** Size in bytes of the CDC data IN and OUT endpoints. */ 63 | #define CDC_TXRX_EPSIZE 64 64 | 65 | /* Type Defines: */ 66 | /** Type define for the device configuration descriptor structure. This must be defined in the 67 | * application code, as the configuration descriptor contains several sub-descriptors which 68 | * vary between devices, and which describe the device's usage to the host. 69 | */ 70 | typedef struct 71 | { 72 | USB_Descriptor_Configuration_Header_t Config; 73 | USB_Descriptor_Interface_t CDC_CCI_Interface; 74 | CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader; 75 | CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_AbstractControlManagement; 76 | CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union; 77 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; 78 | USB_Descriptor_Interface_t CDC_DCI_Interface; 79 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 80 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 81 | } USB_Descriptor_Configuration_t; 82 | 83 | /* Function Prototypes: */ 84 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 85 | const uint8_t wIndex, 86 | void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Projects/arduino-usbserial/README.md: -------------------------------------------------------------------------------- 1 | # Arduino usbserial application firmware 2 | 3 | To setup the project and upload the Arduino usbserial application firmware to an ATmega16U2 using the Arduino USB DFU bootloader: 4 | 5 | 1. unpack the source into LUFA's Projects directory 6 | 2. set `ARDUINO_MODEL_PID` in the makefile as appropriate 7 | 3. do `make clean; make` 8 | 4. put the 16U2 into USB DFU mode (shown in a later section) 9 | 5. confirm that the board enumerates as either "Arduino Uno DFU" or "Arduino Mega 2560 DFU" 10 | 6. do `make dfu` (OS X or Linux - dfu-programmer must be installed first) or `make flip` (Windows - Flip must be installed first) 11 | 12 | Check that the board enumerates as either "Arduino Uno" or "Arduino Mega 2560". Test by uploading a new Arduino sketch from the Arduino IDE. 13 | 14 | ## How to put ATmega8u2/16u2 into USB DFU mode 15 | 16 | 1. assert and hold the 16U2's RESET line 17 | 2. assert and hold the 16U2's HWB line 18 | 3. release the 16U2's RESET line 19 | 4. release the 16U2's HWB line 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino ATmega16U2 USB chip firmware 2 | 3 | ## Sources 4 | 5 | * `hardware/arduino/avr/firmwares/atmegaxxu2` at 6 | * `firmware/atmega16u2` at 7 | 8 | ## Default settings 9 | 10 | * The makefile flags set for Uno Rev 3 11 | 12 | ## How to build 13 | 14 | # DFU bootloader 15 | (cd Bootloaders/arduino-usbdfu && make clean && make) 16 | # USB serial firmware 17 | (cd Projects/arduino-usbserial && make clean && make) 18 | 19 | ## Note very well 20 | 21 | * The LUFA version is 100807, as in the hardware-pinoccio repository. This version is required for both DFU and USB serial firmware. 22 | 23 | ## References 24 | 25 | * LUFA source: https://github.com/abcminiuser/lufa 26 | 27 | ## Notes excerpted from the Arduino firmware distribution 28 | 29 | See 30 | 31 | * The arduino-usbdfu directory contains the DFU bootloader on the 16U2 32 | * The arduino-usbserial directory contains the actual usb to serial firmware 33 | * Both should be compiled against LUFA 100807 34 | 35 | To burn a hex file: 36 | 37 | ``` 38 | avrdude -p atmega16u2 -F -P usb -c avrispmkii \ 39 | -U flash:w:output-file.hex \ 40 | -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m \ 41 | -U lock:w:0x0F:m 42 | ``` 43 | 44 | ## Notes on USB Vendor IDs (VID) and Product IDs (PID) 45 | 46 | The arduino-usbdfu project uses Atmel's VID and MCU-specific PIDs to maintain 47 | compatibility with their FLIP software. The source code to the 48 | arduino-usbserial project includes Atmel's VID and a PID donated by them to 49 | LUFA. This PID is used in LUFA's USBtoSerial project, which forms the basis 50 | for arduino-usbserial. 51 | 52 | According to the LUFA documentation, this VID/PID combination is: 53 | 54 | > "For use in testing of LUFA powered devices during development only, 55 | > by non-commercial entities. All devices must accept collisions on this 56 | > VID/PID range (from other in-development LUFA devices) to be resolved 57 | > by using a unique release number in the Device Descriptor. No devices 58 | > using this VID/PID combination may be released to the general public." 59 | 60 | The production version of the arduino-usbserial firmware uses the 61 | Arduino VID. This is only for use with official Arduino hardware and 62 | should not be used on other products. 63 | 64 | ## License 65 | 66 | MIT. See `LICENSE`. 67 | -------------------------------------------------------------------------------- /hexfiles/optiboot_atmega328.hex: -------------------------------------------------------------------------------- 1 | :107E0000112484B714BE81FFF0D085E080938100F7 2 | :107E100082E08093C00088E18093C10086E0809377 3 | :107E2000C20080E18093C4008EE0C9D0259A86E02C 4 | :107E300020E33CEF91E0309385002093840096BBD3 5 | :107E4000B09BFECF1D9AA8958150A9F7CC24DD24C4 6 | :107E500088248394B5E0AB2EA1E19A2EF3E0BF2EE7 7 | :107E6000A2D0813461F49FD0082FAFD0023811F036 8 | :107E7000013811F484E001C083E08DD089C08234E0 9 | :107E800011F484E103C0853419F485E0A6D080C0E4 10 | :107E9000853579F488D0E82EFF2485D0082F10E0AE 11 | :107EA000102F00270E291F29000F111F8ED06801E7 12 | :107EB0006FC0863521F484E090D080E0DECF843638 13 | :107EC00009F040C070D06FD0082F6DD080E0C81688 14 | :107ED00080E7D80618F4F601B7BEE895C0E0D1E017 15 | :107EE00062D089930C17E1F7F0E0CF16F0E7DF06D8 16 | :107EF00018F0F601B7BEE89568D007B600FCFDCFD4 17 | :107F0000A601A0E0B1E02C9130E011968C91119780 18 | :107F100090E0982F8827822B932B1296FA010C0160 19 | :107F200087BEE89511244E5F5F4FF1E0A038BF0790 20 | :107F300051F7F601A7BEE89507B600FCFDCF97BE46 21 | :107F4000E89526C08437B1F42ED02DD0F82E2BD052 22 | :107F50003CD0F601EF2C8F010F5F1F4F84911BD097 23 | :107F6000EA94F801C1F70894C11CD11CFA94CF0C13 24 | :107F7000D11C0EC0853739F428D08EE10CD085E9AC 25 | :107F80000AD08FE07ACF813511F488E018D01DD067 26 | :107F900080E101D065CF982F8091C00085FFFCCF94 27 | :107FA0009093C60008958091C00087FFFCCF809118 28 | :107FB000C00084FD01C0A8958091C6000895E0E648 29 | :107FC000F0E098E1908380830895EDDF803219F02E 30 | :107FD00088E0F5DFFFCF84E1DECF1F93182FE3DFCA 31 | :107FE0001150E9F7F2DF1F91089580E0E8DFEE27F6 32 | :047FF000FF270994CA 33 | :027FFE00040479 34 | :0400000300007E007B 35 | :00000001FF 36 | --------------------------------------------------------------------------------