--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_BuildLibrary Building as a Linkable Library\r
+ *\r
+ * The LUFA library can be built as a proper linkable library (with the extention .a) under AVR-GCC, so that\r
+ * the library does not need to be recompiled with each revision of a user project. Instructions for creating\r
+ * a library from a given source tree can be found in the AVR-GCC user manual included in the WinAVR install\r
+ * /Docs/ directory.\r
+ *\r
+ * However, building the library is <b>not recommended</b>, as the static (compile-time) options will be\r
+ * unable to be changed without a recompilation of the LUFA code. Therefore, if the library is to be built\r
+ * from the LUFA source, it should be made to be application-specific and compiled with the static options\r
+ * that are required for each project (which should be recorded along with the library).\r
+ *\r
+ * Normal library use has the library components compiled in at the same point as the application code, as\r
+ * demonstrated in the library demos and applications. This is the preferred method, as the library is recompiled\r
+ * each time to ensure that all static options for a particular application are applied.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+ \r
+ /** \page Page_ChangeLog Project Changelog\r
+ *\r
+ * \section Sec_ChangeLogXXXXXX Version XXXXXX\r
+ *\r
+ * - Added new BluetoothHost demo\r
+ * - Changed AVRISP Programmer descriptors to use a newly allocated 0x204F PID value\r
+ * - Fixed MagStripe project configuration descriptor containing an unused (blank) endpoint descriptor\r
+ * - Incorporated makefile changes by Denver Gingerich to retain compatibility with stock (non-WinAVR) AVR-GCC installations\r
+ * - Fixed makefile EEPROM programming targets programming FLASH data in addition to EEPROM data\r
+ * - LUFA devices now enumerate correctly with LUFA hosts\r
+ * - Fixed Configuration Descriptor search routine freezing when a comparitor returned a failure\r
+ * - Removed HID report item serial dump in the MouseHostWithParser and KeyboardHostWithParser - useful only for debugging, and\r
+ * slowed down the enumeration of HID devices too much\r
+ * - Increased the number of bits per track which can be read in the MagStripe project to 20480 when compiled for the AT90USBXXX6/7\r
+ * - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request\r
+ *\r
+ * \section Sec_ChangeLog090209 Version 090209\r
+ *\r
+ * - PWM timer mode in AudioOut demo changed to Fast PWM for speed\r
+ * - Updated Magstripe project to work with the latest hardware revision\r
+ * - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups\r
+ * - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface\r
+ * - Fixed serious data corruption issue in MassStorage demo dataflash write routine\r
+ * - Added new NO_CLEARSET_FEATURE_REQUEST compile time token\r
+ * - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled\r
+ * - Fixed USB_DeviceEnumerationComplete event firing after each configuration change, rather than once after the initial configuration\r
+ * - Added ENDPOINT_DOUBLEBANK_SUPPORTED() macros to Endpoint.h, altered ENDPOINT_MAX_SIZE() to allow user to specify endpoint\r
+ * - ENDPOINT_MAX_ENDPOINTS changed to ENDPOINT_TOTAL_ENDPOINTS, PIPE_MAX_PIPES changed to PIPE_TOTAL_PIPES\r
+ * - Endpoint and Pipe non-control stream functions now ensure endpoint or pipe is ready before reading or writing\r
+ * - Changed Teensy bootloader to use a watchdog reset when exiting rather than a software jump\r
+ * - Fixed integer promotion error in MassStorage and MassStorageHost demos, corrupting read/write transfers\r
+ * - SPI_SendByte is now SPI_TransferByte, added new SPI_SendByte and SPI_ReceiveByte functions for fast one-way transfer\r
+ * - MassStorage demo changed to use new fast one-way SPI transfers to increase throughput\r
+ * - MassStorage handling of Mass Storage Reset class request improved\r
+ * - Altered MassStorage demo dataflash block read code for speed\r
+ * - Added USB_IsSuspended global flag\r
+ * - Simplified internal Dual Mode (OTG) USB library code to reduce code size\r
+ * - Extended stream timeout period to 100ms from 50ms\r
+ * - Mass Storage Host demo commands now all return an error code from the Pipe_Stream_RW_ErrorCodes_t enum\r
+ * - Added SubErrorCode parameter to the USB_DeviceEnumerationFailed event\r
+ * - VBUS drop interrupt now disabled during the manual-to-auto VBUS delivery handoff\r
+ * - Simplified low level backend so that device/host mode initialization uses the same code paths\r
+ * - Added workaround for faulty Mass Storage devices which do not implement the required GET_MAX_LUN request\r
+ * - Removed buggy Telnet application from the RNDIS demo\r
+ * - Moved Mass Storage class requests in the Mass Storage Host demo to wrapper functions in MassStoreCommands.c\r
+ * - Fixed incorrect SCSI command size value in the Request Sense command in MassStoreCommands.c\r
+ * - Added SetProtocol request to HID class non-parser Mouse and Keyboard demos to force devices to use the correct Boot Protocol\r
+ * - Added new "dfu" and "flip" programming targets to project makefiles\r
+ * - HID_PARSE_Sucessful enum member typo corrected to HID_PARSE_Successful\r
+ * - Changed COLLECTION item strucutres in the HID descriptor parser to include the collection's Usage Page value\r
+ * - Serial driver now sets Tx line as output, enables pullup on Rx line\r
+ * - Fixed smaller USB AVRs raising multiple connection and disconnection events when NO_LIMITED_CONTROLLER_CONNECT is disabled\r
+ * - Added HOST_DEVICE_SETTLE_DELAY_MS to give the host delay after a device is connected before it is enumerated\r
+ * - Fixed KeyboardHostWithParser demo linking against the wrong global variables\r
+ * - Completed doxygen documentation of remaining library bootloaders, demos and projects\r
+ * - Fixed incorrect bootloader start address in the TeensyHID bootloader\r
+ * - Added HWB button whole-disk ASCII dump functionality to MassStoreHost demo\r
+ * - Replaced printf_P(PSTR("%c"), {Variable}) calls with putchar(<Variable>) for speed and size savings\r
+ * - Serial driver now accepts baud rates over 16-bits in size, added double speed flag option\r
+ * - Fixed incorrect callback abort return value in Pipe.c\r
+ * - Added new flip-ee and dfu-ee makefile targets (courtesy of Opendous Inc.)\r
+ * - Removed reboot-on-disconnect code from the TeensyHID bootloader, caused problems on some systems\r
+ * - Fixed AudioOutput and AudioInput demos looping on the endpoint data, rather than processing a sample at a time and returning\r
+ * each time the task runs to allow for other tasks to execute\r
+ * - Added support for the Atmel ATAVRUSBRF01 board\r
+ * - Added AVRISP Programmer Project, courtesy of Opendous Inc.\r
+ * - Fixed CDC Host demo not searching through both CDC interfaces for endpoints\r
+ * - Fixed incorrect Product String descriptor length in the DFU class bootloader\r
+ *\r
+ * \section Sec_ChangeLog081224 Version 081224\r
+ *\r
+ * - MyUSB name changed to LUFA, the Lightweight USB Framework for AVRs\r
+ * - Fixed Mass Storage Host demo's MassStore_SendCommand() delay in the incorrect place\r
+ * - Fixed USBtoSerial demo not calling ReconfigureUSART() after a change in the line encoding\r
+ * - Fixed infinite loop in host mode Host-to-Device control transfers with data stages\r
+ * - HID report parser now supports devices with multiple reports in one interface via Report IDs\r
+ * - Fixed RZUSBSTICK board LED driver header incorrect macro definition order causing compile errors\r
+ * - Calling USB_Init() when the USB interface is already configured now forces a complete interface reset\r
+ * and re-enumeration - fixes MyUSB DFU bootloader not switching to app code correctly when soft reset used\r
+ * - Fixed "No newline at end of file" warning when stream callbacks are enabled\r
+ * - DFU bootloader now uses fixed signature bytes per device, rather than reading them out dynamically for size\r
+ * - Added new FIXED_CONTROL_ENDPOINT_SIZE and USE_SINGLE_DEVICE_CONFIGURATION switches to statically define certain values to\r
+ * reduce compiled binary size\r
+ * - Added new NO_LIMITED_CONTROLLER_CONNECT switch to prevent the library from trying to determine bus connection\r
+ * state from the suspension and wake up events on the smaller USB AVRs\r
+ * - Added summary of all library compile time tokens to the documentation\r
+ * - Added overview of the LUFA scheduler to the documentation\r
+ * - Removed MANUAL_PLL_CONTROL compile time token, replaced with a mask for the USB_Init() Options parameter\r
+ * - CDC bootloader now uses the correct non-far or far versions of the pgm_* functions depending on if RAMPZ is defined\r
+ * - Doxygen documentation now contains documentation on all the projects, bootloaders and most demos included with the library\r
+ * - CDC bootloader now runs user application when USB disconnected rather than waiting for a hard reset\r
+ * - MouseHostWithParser and KeyboardHostWithParser now support multiple-report devices\r
+ * - RNDIS demo can now close connections correctly using the new TCP_APP_CLOSECONNECTION() macro - used in Webserver \r
+ * - Fixed the DFU bootloader, no longer freezes up when certain files are programmed into an AVR, made reading/writing faster\r
+ * - Fixed mouse/joystick up/down movements reversed - HID mouse X/Y coordinates use a left-handed coordinate system, not a normal \r
+ * right-handed system\r
+ * - Added stub code to the CDC and USBtoSerial demos showing how to read and set the RS-232 handshake lines - not currently used in\r
+ * the demos, but the example code and supporting defines are now in place\r
+ * - Interrupts are now disabled when processing a control request in device mode, to avoid exceeding the strict control request\r
+ * timing requirements.\r
+ * - All demos now use a central StatusUpdate() function rather than direct calls to the board LED functions, so that the demos can\r
+ * easily be altered to show different LED combinations (or do something else entirely) as the demo's status changes\r
+ * - Removed LED commands from the CDC bootloader, unused by most AVR910 programming software\r
+ * - Fixed RNDIS demo ICMP ping requests echoing back incorrect data\r
+ * - Added DHCP server code to RNDIS demo, allowing for hands-free autoconfiguration on any PC\r
+ * - Fixed DFU bootloader PID value for the ATMEGA16U4 AVR\r
+ * - Endpoint and Pipe configuration functions now return an error code indicating success or failure\r
+ * - USB Reset in device mode now resets and disables all device endpoints\r
+ * - Added intermediate states to the host mode state machine, reducing the USB task blocking time to no more than 1ms explicitly per\r
+ * invocation when in host mode\r
+ * - Added support for the ATMEGA32U6 microcontroller\r
+ * - Added STATIC_ENDPOINT_CONFIGURATION compile time option, enabled in the bootloaders to minimize space usage\r
+ * - Removed redudant code from the USB device GetStatus() chapter 9 processing routine\r
+ * - Added new TeensyHID bootloader, compatible with the Teensy HID protocol (http://www.pjrc.com/teensy/)\r
+ * - Versions are now numbered by release dates, rather than arbitrary major/minor revision numbers\r
+ * - USB_RemoteWakeupEnabled is now correctly set and cleared by SetFeature and ClearFeature requests from the host\r
+ * - Changed prototype of GetDescriptor, so that it now returns the descriptor size (or zero if the descriptor doesn't exist)\r
+ * rather than passing the size back to the caller through a parameter and returning a boolean\r
+ *\r
+ * \section Sec_ChangeLog153 Version 1.5.3 - Released 2nd October, 2008\r
+ *\r
+ * - Fixed CDC bootloader using pgmspace macros for some descriptors inappropriately\r
+ * - Updated all Mouse and Keyboard device demos to include boot protocol support (now works in BIOS)\r
+ * - Renamed bootloader directories to remove spaces, which were causing build problems on several OSes\r
+ * - Removed serial number strings from all but the MassStore demo where it is required - users were not\r
+ * modifing the code to either ommit the descriptor or use a unique serial per device causing problems\r
+ * when multiple units of the same device were plugged in at the same time\r
+ * - AudioOutput and AudioInput demos now correctly silence endpoints when not enabled by the host\r
+ * - Added KeyboardMouse demo (Keyboard and Mouse functionality combined into a single demo)\r
+ * - Added DriverStubs directory to house board level driver templates, to make MyUSB compatible custom board\r
+ * driver creation easier\r
+ * - Extended MassStorage demo to support multiple LUNs, 2 by default\r
+ * - Fixed incorrect device address mask, preventing the device from enumerating with addresses larger than 63\r
+ * - Fixed incorrect data direction mask in the GetStatus standard request, preventing it from being handled\r
+ * - Fixed incorrect GetStatus standard request for endpoints, now returns the endpoint STALL status correctly\r
+ * - Added in new USB_RemoteWakeupEnabled and USB_CurrentlySelfPowered flags rather than using fixed values\r
+ * - Added DualCDC demo to demonstrate the use of Interface Association Descriptors\r
+ * - Added pipe NAK detection and clearing API\r
+ * - Added pipe status change (NAK, STALL, etc.) interrupt API\r
+ * - Fixed MassStorageHost demo so that it no longer freezes randomly when issuing several commands in a row\r
+ * - Host demos configuration descriptor routines now return a unique error code when the returned data does\r
+ * not have a valid configuration descriptor header\r
+ * - Added Endpoint_WaitUntilReady() and Pipe_WaitUntilReady() functions\r
+ * - Stream functions now have software timeouts, timeout period can be set by the USB_STREAM_TIMEOUT_MS token\r
+ * - All demos now pass the USB.org automated Chapter 9 device compliance tests\r
+ * - All HID demos now pass the USB.org automated HID compliance tests\r
+ * - Polling interval of the interrupt endpoint in the CDC based demos changed to 0xFF to fix problems on Linux systems\r
+ * - Changed stream functions to accept a new callback function, with NO_STREAM_CALLBACKS used to disable all callbacks\r
+ * - Mass Storage demo dataflash management routines changed to use the endpoint stream functions \r
+ * - Added AVRStudio project files for each demo in addition to the existing Programmer's Notepad master project file\r
+ * - Re-added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes\r
+ * are reflected in the hardware (change was previously lost)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog152 Version 1.5.2 - Released 31st July, 2008\r
+ *\r
+ * - Fixed SwapEndian_32() function in Common.h so that it now works correctly (wrong parameter types)\r
+ * - Updated RNDIS demo - notification endpoint is no longer blocking so that it works with faulty Linux RNDIS\r
+ * implementations (where the notification endpoint is ignored in favour of polling the control endpoint)\r
+ * - Fixed incorrect Vendor Description string return size in RNDIS demo for the OID_GEN_VENDOR_DESCRIPTION OID token\r
+ * - Added very basic TCP/IP stack and HTTP/TELNET servers to RNDIS demo\r
+ * - Fixed DFU bootloader exit causing programming software to complain about failed writes\r
+ * - Fixed DFU bootloader EEPROM programming mode wiping first flash page\r
+ * - Fixed Clear/Set Feature device standard request processing code (fixing MassStorage demo in the process)\r
+ * - Added support for the ATMEGA16U4 AVR microcontroller\r
+ * - Library licence changed from LGPLv3 to MIT license\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog151 Version 1.5.1 - Released 31st July, 2008\r
+ *\r
+ * - Changed host demos to enable the host function task on the firing of the USB_DeviceEnumerationComplete event\r
+ * rather than the USB_DeviceAttached event\r
+ * - HID Usage Stack now forcefully cleared after an IN/OUT/FEATURE item has been completely processed to remove\r
+ * any referenced but not created usages\r
+ * - Changed USB_INT_DisableAllInterrupts() and USB_INT_ClearAllInterrupts(), USB_Host_GetNextDescriptorOfType(),\r
+ * USB_Host_GetNextDescriptorOfTypeBefore(), USB_Host_GetNextDescriptorOfTypeAfter() to normal functions (from inline)\r
+ * - Fixed USBtoSerial demo not sending data, only receiving\r
+ * - Fixed main makefile to make all by default, fixed MagStripe directory case to prevent case-sensitive path problems\r
+ * - ConfigDescriptor functions made normal, instead of static inline\r
+ * - Pipe/Endpoint *_Ignore_* functions changed to *_Discard_*, old names still present as aliases\r
+ * - Fixed ENDPOINT_MAX_SIZE define to be correct on limited USB controller AVRs\r
+ * - Changed endpoint and pipe size translation routines to use previous IF/ELSE IF cascade code, new algorithmic\r
+ * approach was buggy and caused problems\r
+ * - Bootloaders now compile with -fno-inline-small-functions option to reduce code size\r
+ * - Audio demos now use correct endpoint sizes for full and limited controller USB AVRs, double banking in all cases\r
+ * to be in line with the specification (isochronous endpoints MUST be double banked)\r
+ * - Added Interface Association descriptor to StdDescriptors.h, based on the relevant USB2.0 ECN\r
+ * - Fixed MIDI demo, corrected Audio Streaming descriptor to follow the MIDI-specific AS structure\r
+ * - Fixed HID class demo descriptors so that the HID interface's protocol is 0x00 (required for non-boot protocol HID\r
+ * devices) to prevent problems on hosts expecting the boot protocol functions to be supported\r
+ * - Added read/write control stream functions to Endpoint.h\r
+ * - Fixed AudioOut demo not setting port pins to inputs on USB disconnect properly\r
+ * - Added RNDISEthernet demo application\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog150 Version 1.5.0 - Released 10 June, 2008\r
+ *\r
+ * - Fixed MIDI demo, now correctly waits for the endpoint to be ready between multiple note messages\r
+ * - Added CDC Host demo application\r
+ * - Added KeyboardFullInt demo application\r
+ * - Endpoint and Pipe creation routines now mask endpoint/pipe size with the size mask, to remove transaction\r
+ * size bits not required for the routines (improves compatibility with devices)\r
+ * - Fixed AudioInput demo - now correctly sends sampled audio to the host PC\r
+ * - Fixed AudioOutput demo oncemore -- apparently Windows requires endpoint packets to be >=192 bytes\r
+ * - Shrunk round-robbin scheduler code slightly via the use of struct pointers rather than array indexes\r
+ * - Fixed off-by-one error when determining if the Usage Stack is full inside the HID Report parser\r
+ * - Renamed Magstripe.h to MagstripeHW.h and moved driver out of the library and into the MagStripe demo folder\r
+ * - Added preprocessor checks to enable C linkage on the library components when used with a C++ compiler\r
+ * - Added Still Image Host demo application\r
+ * - The USB device task now restores the previously selected endpoint, allowing control requests to be transparently\r
+ * handled via interrupts while other endpoints are serviced through polling\r
+ * - Fixed device signature being sent in reverse order in the CDC bootloader\r
+ * - Host demos now have a seperate ConfigDescriptor.c/.h file for configuration descriptor processing\r
+ * - HostWithParser demos now have a seperate HIDReport.c/.h file for HID report processing and dumping\r
+ * - Removed non-mandatory commands from MassStorage demo to save space, fixed SENSE ResponseCode value\r
+ * - CDC demos now send empty packets after sending a full one to prevent buffering issues on the host\r
+ * - Updated demo descriptors to use VID/PID values donated by Atmel\r
+ * - Added DoxyGen documentation to the source files\r
+ * - Fixed Serial_IsCharRecieved() definition, was previously reversed\r
+ * - Removed seperate USB_Descriptor_Language_t descriptor, USB_Descriptor_String_t is used instead\r
+ * - Removed unused Device Qualifier descriptor structure\r
+ * - Renamed the USB_CreateEndpoints event to the more appropriate USB_ConfigurationChanged\r
+ * - Fixed MassStorageHost demo reading in the block data in reverse\r
+ * - Removed outdated typedefs in StdRequestType.h, superceeded by the macro masks\r
+ * - Corrected OTG.h is now included when the AVR supports both Host and Device modes, for creating OTG products\r
+ * - USB_DeviceEnumerationComplete event is now also fired when in device mode and the host has finished its enumeration\r
+ * - Interrupt driven demos now properly restore previously selected endpoint when ISR is complete\r
+ * - USB_HOST_TIMEOUT_MS is now overridable in the user project makefile to a custom fixed timeout value\r
+ * - Renamed USB_Host_SOFGeneration_* macros to more friendly USB_Host_SuspendBus(), USB_Host_ResumeBus()\r
+ * and USB_Host_IsBusSuspended()\r
+ * - Renamed *_*_Is* macros to *_Is* to make all flag checking macros consistant, Pipe_SetInterruptFreq() is now\r
+ * Pipe_SetInterruptPeriod() to use the correct terminology\r
+ * - UnicodeString member of USB_Descriptor_String_t struct changed to an ordinary int array type, so that the GCC\r
+ * Unicode strings (prefixed with an L before the opening quotation mark) can be used instead of explicit arrays\r
+ * of ASCII characters\r
+ * - Fixed Endpoint/Pipes being configured incorrectly if the maximum endpoint/pipe size for the selected USB AVR\r
+ * model was given as the bank size\r
+ * - HID device demos now use a true raw array for the HID report descriptor rather than a struct wrapped array\r
+ * - Added VERSION_BCD() macro, fixed reported HID and USB version numbers in demo descriptors\r
+ * - Cleaned up GetDescriptor device chapter 9 handler function\r
+ * - Added GET_REPORT class specific request to HID demos to make them complaint to the HID class\r
+ * - Cleaned up setting of USB_IsInitialized and USB_IsConnected values to only when needed\r
+ * - Removed Atomic.c and ISRMacro.h; the library was already only compatible with recent avr-lib-c for other reasons\r
+ * - All demos and library functions now use USB standardized names for the USB data (bRequest, wLength, etc.)\r
+ * - Added USE_NONSTANDARD_DESCRIPTOR_NAMES token to switch back to the non-standard descriptor element names\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog141 Version 1.4.1 - Released 5 May, 2008\r
+ *\r
+ * - Enhanced KeyboardWithParser demo, now prints out pressed alphanumeric characters like the standard demo\r
+ * - Fixed MassStorage demo, read/writes using non mode-10 commands now work correctly\r
+ * - Corrected version number in Version.h\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog140 Version 1.4.0 - Released 5 May, 2008\r
+ *\r
+ * - Added HID Report Parser API to the library\r
+ * - Added Mouse and Keyboard host demo applications, using the new HID report parser engine\r
+ * - Added MouseFullInt demo, which demonstrates a fully interrupt (including control requests) mouse device\r
+ * - Fixed incorrect length value in the audio control descriptor of the AudioOutput and AudioInput demos\r
+ * - Added MIDI device demo application to the library\r
+ * - Fixed problem preventing USB devices from being resumed from a suspended state\r
+ * - Added new CDC class bootloader to the library, based on the AVR109 bootloader protocol\r
+ * - Added header to each demo application indicating the mode, class, subclass, standards used and supported speed\r
+ * - Functions expecting endpoint/pipe numbers are no longer automatically masked against ENDPOINT_EPNUM_MASK or\r
+ * PIPE_PIPENUM_MASK - this should be manually added to code which requires it\r
+ * - Fixed DFU class bootloader - corrected frequency of flash page writes, greatly reducing programming time\r
+ * - Renamed AVR_HOST_GetDeviceConfigDescriptor() to USB_Host_GetDeviceConfigDescriptor() and AVR_HOST_GetNextDescriptor()\r
+ * to USB_Host_GetNextDescriptor()\r
+ * - Added new USB_Host_GetNextDescriptorOfTypeBefore() and USB_Host_GetNextDescriptorOfTypeAfter() routines\r
+ * - Moved configuration descriptor routines to MyUSB/Drivers/USB/Class/, new accompanying ConfigDescriptors.c file\r
+ * - Added new configuration descriptor comparator API for more powerful descriptor parsing, updated host demos to use the\r
+ * new comparator API\r
+ * - Fixed MassStorageHost demo capacity printout, and changed data read/write mode from little-endian to the correct\r
+ * big-endian for SCSI devices\r
+ * - Fixed macro/function naming consistancy; USB_HOST is now USB_Host, USB_DEV is now USB_Device\r
+ * - Added better error reporting to host demos\r
+ * - Added 10 microsecond delay after addressing devices in host mode, to prevent control stalls\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog132 Version 1.3.2 - Released April 1st, 2008\r
+ *\r
+ * - Added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes\r
+ * are reflected in the hardware\r
+ * - Fixed CDC and USBtoSerial demos - Stream commands do not work for control endpoints, and the \r
+ * GetLineCoding request had an incorrect RequestType mask preventing it from being processed\r
+ * - Improved reliability of the USBtoSerial demo, adding a busy wait while the buffer is full\r
+ * - Device control endpoint size is now determined from the device's descriptors rather than being fixed\r
+ * - Seperated out SPI code into new SPI driver in AT90USBXXX driver directory\r
+ * - Bootloader now returns correct PID for the selected USB AVR model, not just the AT90USB128X PID\r
+ * - Added support for the RZUSBSTICK board\r
+ * - Bicolour driver removed in favour of generic LEDs driver\r
+ * - Added support for the ATMEGA32U4 AVR\r
+ * - Added MANUAL_PLL_CONTROL compile time option to prevent the USB library from manipulating the PLL\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog131 Version 1.3.1 - Released March 19th 2008\r
+ *\r
+ * - Fixed USB to Serial demo - class value in the descriptors was incorrect\r
+ * - Control endpoint size changed from 64 bytes to 8 bytes to save on USB FIFO RAM and to allow low\r
+ * speed mode devices to enumerate properly\r
+ * - USB to Serial demo data endpoints changed to dual-banked 16 byte to allow the demo to work\r
+ * on USB AVRs with limited USB FIFO RAM\r
+ * - Changed demo endpoint numbers to use endpoints 3 and 4 for double banking, to allow limited\r
+ * USB device controller AVRs (AT90USB162, AT90USB82) to function correctly\r
+ * - Updated Audio Out demo to use timer 1 for AVRs lacking a timer 3 for the PWM output\r
+ * - Fixed incorrect USB_DEV_OPT_HIGHSPEED entry in the Mass Storage device demo makefile\r
+ * - Optimized Mass Storage demo for a little extra transfer speed\r
+ * - Added LED indicators to the Keyboard demo for Caps Lock, Num Lock and Scroll Lock\r
+ * - Added Endpoint_Read_Stream, Endpoint_Write_Stream, Pipe_Read_Stream and Pipe_Write_Stream functions\r
+ * (including Big and Little Endian variants)\r
+ * - Made Dataflash functions inline for speed, removed now empty Dataflash.c driver file\r
+ * - Added new SetSystemClockPrescaler() macro - thanks to Joerg Wunsch\r
+ * - Fixed Endpoint_ClearStall() to function correctly on full USB controller AVRs (AT90USBXXX6/7)\r
+ * - Endpoint_Setup_In_Clear() and Endpoint_Setup_Out_Clear() no longer set FIFOCON, in line with the\r
+ * directives in the datasheet\r
+ * - Fixed PLL prescaler defines for all AVR models and frequencies\r
+ * - Fixed ENDPOINT_INT_IN and ENDPOINT_INT_OUT definitions\r
+ * - Added interrupt driven keyboard and mouse device demos\r
+ * - Combined USB_Device_ClearFeature and USB_Device_SetFeature requests into a single routine for code\r
+ * size savings\r
+ * - Added missing Pipe_GetCurrentPipe() macro to Pipe.h\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog130 Version 1.3.0 - Released March 7th 2008\r
+ *\r
+ * - Unneccesary control endpoint config removed from device mode\r
+ * - Fixed device standard request interpreter accidentally processing some class-specific requests\r
+ * - Added USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS compile time options to instruct the library\r
+ * to use descriptors stored in RAM or EEPROM rather than flash memory\r
+ * - All demos now disable watchdog on startup, in case it has been enabled by fuses or the bootloader\r
+ * - USB_DEV_OPT_LOWSPEED option now works correctly\r
+ * - Added ability to set the USB options statically for a binary size reduction via the USE_STATIC_OPTIONS\r
+ * compile time define\r
+ * - USB_Init no longer takes a Mode parameter if compiled for a USB device with no host mode option, or\r
+ * if forced to a particular mode via the USB_HOST_ONLY or USB_DEVICE_ONLY compile time options\r
+ * - USB_Init no longer takes an Options parameter if options statically configured by USE_STATIC_OPTIONS\r
+ * - Endpoint_Ignore_* and Pipe_Ignore_* made smaller by making the dummy variable non-volatile so that the\r
+ * compiler can throw away the result more efficiently\r
+ * - Added in an optional GroupID value to each scheduler entry, so that groups of tasks can once again be\r
+ * controlled by the new Scheduler_SetGroupTaskMode() routine\r
+ * - Added support for AT90USB162 and AT90USB82 AVR models\r
+ * - Added support for the STK525 and STK526 boards\r
+ * - Added support for custom board drivers to be supplied by selecting the board type as BOARD_USER, and\r
+ * placing board drivers in {Application Directory}/Board/\r
+ * - PLL is now stopped and USB clock is frozen when detatched from host in device mode, to save power\r
+ * - Joystick defines are now in synch with the schematics - orientation will be rotated for the USBKEY\r
+ * - Fixed USB_DEV_IsUSBSuspended() - now checks the correct register\r
+ * - Fixed data transfers to devices when in host mode\r
+ * - Renamed USB_DEV_OPT_HIGHSPEED to USB_DEV_OPT_FULLSPEED and USB_HOST_IsDeviceHighSpeed() to\r
+ * USB_HOST_IsDeviceFullSpeed() to be in line with the official USB speed names (to avoid confusion with\r
+ * the real high speed mode, which is unavailable on the USB AVRs)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog120 Version 1.2.0 - Released February 4th, 2008\r
+ *\r
+ * - Added USB_DeviceEnumerationComplete event for host mode\r
+ * - Added new Scheduler_Init routine to preprepare the scheduler, so that tasks can be started and\r
+ * stopped before the scheduler has been started (via Scheduler_Start)\r
+ * - Connection events in both Device and Host mode are now interrupt-driven, allowing the USB management\r
+ * task to be stopped when the USB is not connected to a host or device\r
+ * - All demos updated to stop the USB task when not in use via the appropriate USB events\r
+ * - Mass Storage Host demo application updated to function correctly with all USB flash disks\r
+ * - Mass Storage Host demo application now prints out the capacity and number of LUNs in the attached\r
+ * device, and prints the first block as hexadecimal numbers rather than ASCII characters\r
+ * - Endpoint and Pipe clearing routines now clear the Endpoint/Pipe interrupt and status flags\r
+ * - Shifted error handling code in the host enum state machine to a single block, to reduce code complexity\r
+ * - Added in DESCRIPTOR_TYPE, DESCRIPTOR_SIZE and DESCRIPTOR_CAST macros to make config descriptor processing\r
+ * clearer in USB hosts and DESCRIPTOR_ADDRESS for convenience in USB devices\r
+ * - Added in alloca macro to common.h, in case the user is using an old version of avr-lib-c missing the macro\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog130 Version 1.1.0 - Released January 25th 2008\r
+ *\r
+ * - Fixed DCONNI interrupt being enabled accidentally after a USB reset\r
+ * - Fixed DDISCI interrupt not being disabled when a device is not connected\r
+ * - Added workaround for powerless pullup devices causing false disconnect interrupts\r
+ * - Added USB_DeviceEnumerationFailed event for Host mode\r
+ * - AVR_HOST_GetDeviceConfigDescriptor routine no longer modifies ConfigSizePtr if a valid buffer\r
+ * pointer is passed\r
+ * - Added ALLOCABLE_BYTES to DynAlloc, and added code to make the size of key storage variables\r
+ * dependant on size of memory parameters passed in via the user project's makefile\r
+ * - Fixed incorrect device reset routine being called in USBTask\r
+ * - Devices which do not connect within the standard 300mS are now supported\r
+ * - Removed incorrect ATTR_PURE from Scheduler_SetTaskMode(), which was preventing tasks from being\r
+ * started/stopped, as well as USB_InitTaskPointer(), which was breaking dual device/host USB projects\r
+ * - Changed scheduler to use the task name rather than IDs for setting the task mode, eliminating the\r
+ * need to have a task ID list\r
+ * - ID transistion interrupt now raises the appropriate device/host disconnect event if device attached\r
+ * - Fixed double VBUS change (and VBUS -) event when detatching in device mode\r
+ * - Added ability to disable ANSI terminal codes by the defining of DISABLE_TERMINAL_CODES in makefile\r
+ * - Removed return from ConfigurePipe and ConfigureEndpoint functions - use Pipe_IsConfigured() and \r
+ * Endpoint_IsConfigured() after calling the config functions to determine success\r
+ */
\ No newline at end of file
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file contains constants which can be passed to the compiler (via setting the macro BOARD) in the\r
+ * user project makefile using the -D option to configure the library board-specific drivers.\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+ \r
+#ifndef __BOARDTYPES_H__\r
+#define __BOARDTYPES_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__COMMON_H__)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Selects the USBKEY specific board drivers, including Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_USBKEY 0\r
+\r
+ /** Selects the STK525 specific board drivers, including Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_STK525 1\r
+\r
+ /** Selects the STK526 specific board drivers, including Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_STK526 2\r
+\r
+ /** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */\r
+ #define BOARD_RZUSBSTICK 3\r
+ \r
+ /** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_ATAVRUSBRF01 4\r
+\r
+ /** Selects the user-defined board drivers, which should be placed in the user project's folder\r
+ * under a directory named /Board/. Each board driver should be named identically to the LUFA\r
+ * master board driver (i.e., driver in the LUFA/Drivers/Board director) so that the library\r
+ * can correctly identify it.\r
+ */\r
+ #define BOARD_USER 5\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file contains macros for the embedding of compile-time strings into the resultant project binary for\r
+ * identification purposes. It is designed to prefix "tags" with the magic string of "@(#)" so that the tags\r
+ * can easily be identified in the binary data.\r
+ *\r
+ * These tags are compatible with the ButtLoad project at http://www.fourwalledcubicle.com/ButtLoad.php .\r
+ */\r
+\r
+#ifndef __BUTTLOADTAG_H__\r
+#define __BUTTLOADTAG_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <avr/pgmspace.h>\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Creates a new tag in the resultant binary, containing the specified data array. The macro id\r
+ * parameter is only for identification purposes (so that the tag data can be referenced in code)\r
+ * and is not visible in the compiled binary.\r
+ */\r
+ #define BUTTLOADTAG(id, data) const struct ButtLoadTagData BUTTTAG_##id \\r
+ PROGMEM __attribute__((used, externally_visible)) = \\r
+ {MagicString: BT_TAGHEADER, TagData: data}\r
+ \r
+ /** Macro for retrieving a reference to the specified tag's contents. The tag data is located in\r
+ * the program memory (FLASH) space, and so must be read out with the macros in avr-libc which\r
+ * deal with embedded data.\r
+ */\r
+ #define BUTTLOADTAG_DATA(id) BUTTTAG_##id.TagData\r
+\r
+ /* Structures: */\r
+ /** Structure for ButtLoad compatible binary tags. */\r
+ struct ButtLoadTagData\r
+ {\r
+ char MagicString[4]; /**< Magic tag header, containing the string "@(#)". */\r
+ char TagData[]; /**< Tag contents as a char array. */\r
+ }; \r
+\r
+ /* Private Interface - For use in library only: */ \r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define BT_TAGHEADER {'@','(','#',')'}\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file contains macros which are common to all library elements, and which may be useful in user code. It\r
+ * also includes other common headees, such as Atomic.h, FunctionAttributes.h and BoardTypes.h.\r
+ */\r
+\r
+#ifndef __COMMON_H__\r
+#define __COMMON_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdio.h>\r
+ #include <avr/version.h>\r
+ \r
+ #include "FunctionAttributes.h"\r
+ #include "BoardTypes.h"\r
+ \r
+ #include <alloca.h>\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */ \r
+ /** Macro for encasing other multi-statment macros. This should be used along with an opening brace\r
+ * before the start of any multi-statement macro, so that the macros contents as a whole are treated\r
+ * as a discreete block and not as a list of seperate statements which may cause problems when used as\r
+ * a block (such as inline IF statments).\r
+ */\r
+ #define MACROS do\r
+\r
+ /** Macro for encasing other multi-statment macros. This should be used along with a preceeding closing\r
+ * brace at the end of any multi-statement macro, so that the macros contents as a whole are treated\r
+ * as a discreete block and not as a list of seperate statements which may cause problems when used as\r
+ * a block (such as inline IF statments).\r
+ */\r
+ #define MACROE while (0)\r
+ \r
+ /** Defines a volatile NOP statment which cannot be optimized out by the compiler, and thus can always\r
+ * be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer\r
+ * removes/reorders code to the point where break points cannot reliably be set.\r
+ */\r
+ #define JTAG_DEBUG_POINT() asm volatile ("NOP" ::)\r
+\r
+ /** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statment. When\r
+ * a JTAG is used, this causes the program execution to halt when reached until manually resumed. */\r
+ #define JTAG_DEBUG_BREAK() asm volatile ("BREAK" ::)\r
+ \r
+ /** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false. */\r
+ #define JTAG_DEBUG_ASSERT(x) MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE\r
+\r
+ /** Macro for testing condition "x" and writing debug data to the serial stream if false. As a\r
+ * prerequisite for this macro, the serial stream should be configured via the Serial_Stream driver.\r
+ *\r
+ * The serial output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion\r
+ * {x} failed."\r
+ */\r
+ #define SERIAL_STREAM_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \\r
+ "Assertion \"%s\" failed.\r\n"), \\r
+ __FILE__, __func__, __LINE__, #x); \\r
+ } }MACROE\r
+\r
+ /* Inline Functions: */\r
+ /** Function for reliably setting the AVR's system clock prescaler, using inline assembly. This function\r
+ * is guaranteed to operate reliably regardless of optimization setting or other compile time options. \r
+ *\r
+ * \param PrescalerMask The mask of the new prescaler setting for CLKPR\r
+ */\r
+ static inline void SetSystemClockPrescaler(uint8_t PrescalerMask)\r
+ {\r
+ uint8_t tmp = (1 << CLKPCE);\r
+ __asm__ __volatile__ (\r
+ "in __tmp_reg__,__SREG__" "\n\t"\r
+ "cli" "\n\t"\r
+ "sts %1, %0" "\n\t"\r
+ "sts %1, %2" "\n\t"\r
+ "out __SREG__, __tmp_reg__"\r
+ : /* no outputs */\r
+ : "d" (tmp),\r
+ "M" (_SFR_MEM_ADDR(CLKPR)),\r
+ "d" (PrescalerMask)\r
+ : "r0");\r
+ }\r
+\r
+ /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,\r
+ * etc.\r
+ *\r
+ * \param Byte Byte of data whose bits are to be reversed\r
+ */\r
+ static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
+ static inline uint8_t BitReverse(uint8_t Byte)\r
+ {\r
+ Byte = (((Byte & 0xF0) >> 4) | ((Byte & 0x0F) << 4));\r
+ Byte = (((Byte & 0xCC) >> 2) | ((Byte & 0x33) << 2));\r
+ Byte = (((Byte & 0xAA) >> 1) | ((Byte & 0x55) << 1));\r
+\r
+ return Byte;\r
+ }\r
+ \r
+ /** Function to reverse the byte ordering of the individual bytes in a 16 bit number.\r
+ *\r
+ * \param Word Word of data whose bytes are to be swapped\r
+ */\r
+ static inline uint16_t SwapEndian_16(uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
+ static inline uint16_t SwapEndian_16(uint16_t Word)\r
+ {\r
+ return ((Word >> 8) | (Word << 8)); \r
+ }\r
+\r
+ /** Function to reverse the byte ordering of the individual bytes in a 32 bit number.\r
+ *\r
+ * \param DWord Double word of data whose bytes are to be swapped\r
+ */\r
+ static inline uint32_t SwapEndian_32(uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
+ static inline uint32_t SwapEndian_32(uint32_t DWord)\r
+ {\r
+ return (((DWord & 0xFF000000) >> 24) |\r
+ ((DWord & 0x00FF0000) >> 8) |\r
+ ((DWord & 0x0000FF00) << 8) |\r
+ ((DWord & 0x000000FF) << 24));\r
+ }\r
+\r
+ /** Function to reverse the byte ordering of the individual bytes in a n byte number.\r
+ *\r
+ * \param Data Pointer to a number containing an even number of bytes to be reversed\r
+ * \param Bytes Length of the data in bytes\r
+ */\r
+ static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes);\r
+ static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes)\r
+ {\r
+ uint8_t Temp;\r
+ \r
+ while (Bytes)\r
+ {\r
+ Temp = *Data;\r
+ *Data = *(Data + Bytes - 1);\r
+ *(Data + Bytes) = Temp;\r
+\r
+ Data++;\r
+ Bytes -= 2;\r
+ }\r
+ }\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file contains macros for applying GCC specific attributes to functions to control various optimizer\r
+ * and code generation features of the compiler. Attributes may be placed in the function prototype in any\r
+ * order, and multiple attributes can be specified for a single function via a space seperated list.\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+\r
+#ifndef __FUNCATTR_H__\r
+#define __FUNCATTR_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__COMMON_H__)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates to the compiler that the function can not ever return, so that any stack restoring or\r
+ * return code may be ommited by the compiler in the resulting binary.\r
+ */\r
+ #define ATTR_NO_RETURN __attribute__ ((noreturn))\r
+\r
+ /** Places the function in one of the initilization sections, which execute before the main function\r
+ * of the application. The init function number can be specified as "x", as an integer. Refer to the\r
+ * avr-libc manual for more information on the initialization sections.\r
+ */\r
+ #define ATTR_INIT_SECTION(x) __attribute__ ((naked, section (".init" #x )))\r
+ \r
+ /** Indicates that the function returns a value which should not be ignored by the user code. When\r
+ * applied, any ignored return value from calling the function will produce a compiler warning.\r
+ */\r
+ #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))\r
+\r
+ /** Indicates that the specified parameters of the function are pointers which should never be NULL.\r
+ * When applied as a 1-based comma seperated list the compiler will emmit a warning if the specified\r
+ * parameters are known at compiler time to be NULL at the point of calling the function.\r
+ */\r
+ #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__)))\r
+\r
+ /** Removes any preample or postample from the function. When used, the function will not have any\r
+ * register or stack saving code. This should be used with caution, and when used the programmer\r
+ * is responsible for maintaining stack and register integrity.\r
+ */\r
+ #define ATTR_NAKED __attribute__ ((naked))\r
+ \r
+ /** Prevents the compiler from considering a specified function for inlining. When applied, the given\r
+ * function will not be inlined under any circumstances.\r
+ */\r
+ #define ATTR_NOINLINE __attribute__ ((noinline))\r
+\r
+ /** Forces the compiler to inline the specified function. When applied, the given function will be\r
+ * inlined under all circumstances.\r
+ */\r
+ #define ATTR_ALWAYSINLINE __attribute__ ((always_inline))\r
+ \r
+ /** Indicates that the specified function is pure, in that it has no side-effects other than global\r
+ * or parameter variable access.\r
+ */\r
+ #define ATTR_PURE __attribute__ ((pure))\r
+ \r
+ /** Indicates that the specified function is constant, in that it has no side effects other than\r
+ * parameter access.\r
+ */\r
+ #define ATTR_CONST __attribute__ ((const))\r
+ \r
+ /** Marks a given function as deprecated, which produces a warning if the function is called. */\r
+ #define ATTR_DEPRECATED __attribute__ ((deprecated))\r
+ \r
+ /** Marks a function as a weak reference, which can be overridden by other functions with an\r
+ * identical name (in which case the weak reference is discarded at link time).\r
+ */\r
+ #define ATTR_WEAK __attribute__ ((weak))\r
+ \r
+ /** Marks a function as an alias for another function of name "x". */\r
+ #define ATTR_ALIAS(x) __attribute__ ((alias( #x )))\r
+ \r
+#endif\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page TokenSummary Summary of Compile Tokens\r
+ *\r
+ * The following lists all the possible tokens which can be defined in a project makefile, and passed to the\r
+ * compiler via the -D switch, to alter the LUFA library code. These tokens may alter the library behaviour,\r
+ * or remove features unused by a given application in order to save flash space.\r
+ *\r
+ * \section Sec_SummaryNonUSBTokens Non USB Related Tokens\r
+ * This section describes compile tokens which affect non-USB sections of the LUFA library.\r
+ *\r
+ * <b>DISABLE_TERMINAL_CODES</b> - TerminalCodes.h \n\r
+ * If an application contains ANSI terminal control codes listed in TerminalCodes.h, it might be desired to remove them\r
+ * at compile time for use with a terminal which is non-ANSI control code aware, without modifying the source code. If\r
+ * this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from\r
+ * the source code at compile time.\r
+ *\r
+ * <b>NUM_BLOCKS</b> - DynAlloc.h \n\r
+ * Sets the number of allocable blocks in the psudo-heap of the dynamic memory allocation driver. This should be\r
+ * defined as a constant larger than zero.\r
+ *\r
+ * <b>BLOCK_SIZE</b> - DynAlloc.h \n\r
+ * Sets the size of each allocable block in the psudo-heap of the dynamic memory allocation driver. This should be\r
+ * defined as a constant larger than zero.\r
+ *\r
+ * <b>NUM_HANDLES</b> - DynAlloc.h \n\r
+ * Sets the maximum number of managed memory handles which can be handed out by the dynamic memory allocation driver\r
+ * simultaneously, before a handle (and its associated allocated memory) must be freed.\r
+ *\r
+ * \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens\r
+ * This section describes compile tokens which affect USB class-specific drivers in the LUFA library.\r
+ *\r
+ * <b>HID_ENABLE_FEATURE_PROCESSING</b> - HIDParser.h \n\r
+ * Define this token to enable the processing of FEATURE HID report items, if any, into the processed HID structure.\r
+ * By default FEATURE items (which are device features settable by the host but not directly visible by the user) are\r
+ * skipped when processing a device HID report.\r
+ *\r
+ * <b>HID_INCLUDE_CONSTANT_DATA_ITEMS</b> - HIDParser.h \n\r
+ * By default, constant data items (usually used as spacers to align seperate report items to a byte or word boundary)\r
+ * in the HID report are skipped during report processing. It is highly unusual for an application to make any use of\r
+ * constant data items (as they do not carry any useful data and only occupy limited RAM) however if required defining\r
+ * this switch will put constant data items into the processed HID report structure.\r
+ *\r
+ * <b>HID_STATETABLE_STACK_DEPTH</b> - HIDParser.h \n\r
+ * HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This\r
+ * allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous\r
+ * state table in a compact manner. This token may be defined to a non-zero value to give the maximum depth of the state\r
+ * table stack. If not defined, this defaults to the value indicated in the HID.h file documentation.\r
+ *\r
+ * <b>HID_USAGE_STACK_DEPTH</b> - HIDParser.h \n\r
+ * HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession\r
+ * when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with\r
+ * different usages in a compact manner. This token may be defined to a non-zero value to set the maximum depth of the\r
+ * usage stack, indicating the maximum number of USAGE items which can be stored tempoarily until the next INPUT, OUTPUT\r
+ * and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation.\r
+ *\r
+ * <b>HID_MAX_COLLECTIONS</b> - HIDParser.h \n\r
+ * HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information\r
+ * is stored seperately in the processed usage structure (and referred to by the data elements in the structure) to save space.\r
+ * This token may be defined to a non-zero value to set the maximum number of COLLECTION items which can be processed by the\r
+ * parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file\r
+ * documentation.\r
+ *\r
+ * <b>HID_MAX_REPORTITEMS</b> - HIDParser.h \n\r
+ * All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID\r
+ * device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which\r
+ * the report data should be interpreted by the host. This token may be defined to a non-zero value to set the maximum number of\r
+ * data elements which can be stored in the processed HID report strucuture, including INPUT, OUTPUT and (if enabled) FEATURE items.\r
+ * If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed seperately in the\r
+ * processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation.\r
+ *\r
+ * \section Sec_SummaryUSBTokens USB Driver Related Tokens\r
+ * This section describes compile tokens which affect USB driver stack as a whole in the LUFA library.\r
+ *\r
+ * <b>USE_RAM_DESCRIPTORS</b> - StdDescriptors.h \n\r
+ * Define this token to indicate to the USB driver that device descriptors are stored in RAM, rather than the default of\r
+ * the AVR's flash. RAM descriptors may be desirable in applications where speed or minimizing flash usage is more important\r
+ * than RAM usage, or applications where the descriptors need to be modified at runtime.\r
+ *\r
+ * <b>USE_EEPROM_DESCRIPTORS</b> - StdDescriptors.h \n\r
+ * Similar to USE_RAM_DESCRIPTORS, but descriptors are stored in the AVR's EEPROM memory rather than RAM.\r
+ *\r
+ * <b>USE_NONSTANDARD_DESCRIPTOR_NAMES</b> - StdDescriptors.h \n\r
+ * The USB 2.0 standard gives some rather obscure names for the elements in the standard descriptor types (device, configuration,\r
+ * string, endpoint, etc.). By default the LUFA library uses these names in its predefined descriptor structure types for\r
+ * compatibility. If this token is defined, the structure element names are switched to the LUFA-specific but more descriptive\r
+ * names documented in the StdDescriptors.h source file.\r
+ *\r
+ * <b>FIXED_CONTROL_ENDPOINT_SIZE</b> - Endpoint.h \n\r
+ * By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor.\r
+ * Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if\r
+ * descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be\r
+ * defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled\r
+ * binary at the expense of flexibility.\r
+ *\r
+ * <b>STATIC_ENDPOINT_CONFIGURATION</b> - Endpoint.h \n\r
+ * By default, the endpoint configuration routine is designed to accept dynamic inputs, so that the endpoints can be configured\r
+ * using variable values known only at runtime. This allows for a great deal of flexibility, however uses a small amount of binary\r
+ * space which may be wasted if all endpoint configurations are static and known at compile time. Define this token via the -D switch\r
+ * to optimize the endpoint configuration routine for constant inputs, to reduce the size of the compiled binary at the expense of\r
+ * flexibility. Note that with this option dynamic values may still be used, but will result in many times more code to be generated than\r
+ * if the option was disabled. This is designed to be used only if the FIXED_CONTROL_ENDPOINT_SIZE option is also used.\r
+ *\r
+ * <b>USE_SINGLE_DEVICE_CONFIGURATION</b> - DevChapter9.h \n\r
+ * By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces\r
+ * the amount of configuration required to set up the library, and allows the value to change dynamically (if descriptors are stored in\r
+ * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration.\r
+ * Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility.\r
+ *\r
+ * <b>NO_CLEARSET_FEATURE_REQUEST</b> - DevChapter9.h \n\r
+ * In some limited USB device applications, the Get Feature and Set Feature requests are not used - this is when the device does not have\r
+ * device level features (such as remote wakeup) nor any data endpoints beyond the mandatory control endpoint. In such limited situations,\r
+ * this token may be defined to remove the handling of the Get Feature and Set Feature Chapter 9 requests to save space. Generally, this\r
+ * is usually only useful in (some) bootloaders.\r
+ *\r
+ * <b>NO_STREAM_CALLBACKS</b> - Endpoint.h, Pipe.h \n\r
+ * Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the\r
+ * host easily via a single function call (rather than complex routines worrying about sending full packets, waiting for the endpoint/\r
+ * pipe to become ready, etc.). By default, these stream functions require a callback function which is executed after each byte processed,\r
+ * allowing for early-aborts of stream transfers by the application. If callbacks are not required in an application, they can be removed\r
+ * by defining this token, reducing the compiled binary size. When removed, the stream functions no longer accept a callback function as\r
+ * a parameter.\r
+ *\r
+ * <b>USB_HOST_TIMEOUT_MS</b> - Host.h \n\r
+ * When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached\r
+ * device fails to respond within the timeout period. This token may be defined to a non-zero value to set the timeout period for\r
+ * control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.\r
+ *\r
+ * <b>HOST_DEVICE_SETTLE_DELAY_MS</b> - Host.h \n\r
+ * Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or\r
+ * they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled\r
+ * back to a known idle state before communications occur with the device. This token may be defined to a non-zero value to set the\r
+ * device settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.\r
+ *\r
+ * <b>USE_STATIC_OPTIONS</b> - LowLevel.h \n\r
+ * By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad\r
+ * voltage regulator is enabled, and the device speed when in device mode. By defining this token to a mask comprised of the USB options\r
+ * mask defines usually passed as the Options parameter to USB_Init(), the resulting compiled binary can be decreased in size by removing\r
+ * the dynamic options code, and replacing it with the statically set options. When defined, the USB_Init() function no longer accepts an\r
+ * Options parameter.\r
+ *\r
+ * <b>USB_DEVICE_ONLY</b> - LowLevel.h \n\r
+ * For the USB AVR models supporting both device and host USB modes, the USB_Init() function contains a Mode parameter which specifies the\r
+ * mode the library should be initialized to. If only device mode is required, the code for USB host mode can be removed from the binary to\r
+ * save space. When defined, the USB_Init() function no longer accepts a Mode parameter. This define is irrelevent on smaller USB AVRs which\r
+ * do not support host mode.\r
+ *\r
+ * <b>USB_HOST_ONLY</b> - LowLevel.h \n\r
+ * Same as USB_DEVICE_ONLY, except the library is fixed to USB host mode rather than USB device mode. Not available on some USB AVR models.\r
+ *\r
+ * <b>USB_STREAM_TIMEOUT_MS</b> - LowLevel.h \n\r
+ * When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host\r
+ * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero value to set the timeout\r
+ * period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead.\r
+ *\r
+ * <b>NO_LIMITED_CONTROLLER_CONNECT</b> - Events.h \n\r
+ * On the smaller USB AVRs, the USB controller lacks VBUS events to determine the physical connection state of the USB bus to a host. In lieu of\r
+ * VBUS events, the library attempts to determine the connection state via the bus suspension and wake up events instead. This however may be\r
+ * slightly inaccurate due to the possibility of the host suspending the bus while the device is still connected. If accurate connection status is\r
+ * required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_IsConnected global\r
+ * can be accurately set and the USB_Connect and USB_Disconnect events manually raised by the RAISE_EVENT macro. When defined, this token disables\r
+ * the library's auto-detection of the connection state by the aformentioned suspension and wake up events.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \dir Common\r
+ * \brief Common library header files.\r
+ * \r
+ * This folder contains header files which are common to all parts of the LUFA library. They may be used freely in\r
+ * user applications.\r
+ *\r
+ * \dir MemoryAllocator\r
+ * \brief Auto-defragmenting dynamic memory allocation library.\r
+ * \r
+ * This folder contains a simple handle-based dynamic memory allocation library, capable of handing out memory in\r
+ * block chunks. As new memory is allocated, the library will defragment the already allocated memory to ensure\r
+ * optimal memory usage. It is not used within the LUFA library, and is provided as a convenience for user applications.\r
+ *\r
+ * \dir Scheduler\r
+ * \brief Simple round-robbin scheduler.\r
+ * \r
+ * This folder contains the simple LUFA round-robbin scheduler, provided as a convenience for user applications. It\r
+ * is very simple in design, and is intended to make code easier to read, rather than providing a complete RTOS kernel.\r
+ *\r
+ * \dir Drivers\r
+ * \brief Library hardware and software drivers.\r
+ * \r
+ * This folder contains all the library hardware and software drivers for each supported board and USB AVR\r
+ * microcontroller model.\r
+ * \r
+ * \dir Drivers/Misc\r
+ * \brief Miscellaneous driver files.\r
+ * \r
+ * This folder contains drivers for aspects other than the USB interface, board hardware or AVR peripherals.\r
+ * \r
+ * \dir Drivers/AT90USBXXX\r
+ * \brief USB AVR peripheral driver files.\r
+ * \r
+ * This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible with\r
+ * all USB AVR models.\r
+ *\r
+ * \dir Drivers/AT90USBXXX/AT90USBXXX67\r
+ * \brief AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 AVR model peripheral driver files. Its original name is due to legacy\r
+ * reasons.\r
+ * \r
+ * This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible only with\r
+ * the AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 USB AVR models, such as the AT90USB1287. Its contents should <b>not</b> be\r
+ * included by the user application - the dispatch header file located in the parent AT90USBXXX directory should be used\r
+ * instead.\r
+ *\r
+ * \dir Drivers/USB\r
+ * \brief USB controller peripheral driver files.\r
+ * \r
+ * This folder contains the main header files required to implement the USB interface in the USB supporting AVR models.\r
+ * The header files contained directly in this folder should be included in the user application in order to gain USB\r
+ * functionality, and the appropriate C source files in the LowLevel and HighLevel driver folders added to the compile\r
+ * and link stages.\r
+ *\r
+ * \dir Drivers/USB/LowLevel\r
+ * \brief Low level USB driver files.\r
+ * \r
+ * This folder contains low level USB driver source files required to implement USB functionality on the USB AVR microcontrollers.\r
+ *\r
+ * \dir Drivers/USB/HighLevel\r
+ * \brief High level USB driver files.\r
+ * \r
+ * This folder contains high level USB driver source files required to implement USB functionality on the USB AVR microcontrollers.\r
+ *\r
+ * \dir Drivers/USB/Class\r
+ * \brief USB Class helper driver files.\r
+ * \r
+ * This folder contains drivers for implementing functionality of standardized USB classes. These are not used directly by the library,\r
+ * but provide a standard and library-maintained way of implementing functionality from some of the defined USB classes without extensive\r
+ * development effort. Is is recommended that these drivers be used where possible to reduce maintenance of user applications.\r
+ *\r
+ * \dir Drivers/Board\r
+ * \brief Board hardware driver files.\r
+ * \r
+ * This folder contains drivers for interfacing with the physical hardware on supported commercial boards, primarily from\r
+ * the Atmel corporation. Header files in this folder should be included in user applications requring the functionality of\r
+ * hardware placed on supported boards.\r
+ *\r
+ * \dir Drivers/Board/USBKEY\r
+ * \brief USBKEY board hardware driver files.\r
+ * \r
+ * This folder contains drivers for hardware on the Atmel USBKEY demonstration board. The header files in this folder should\r
+ * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory\r
+ * should be included instead.\r
+ *\r
+ * \dir Drivers/Board/STK526\r
+ * \brief STK526 board hardware driver files.\r
+ * \r
+ * This folder contains drivers for hardware on the Atmel STK526 development board. The header files in this folder should\r
+ * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory\r
+ * should be included instead.\r
+ *\r
+ * \dir Drivers/Board/STK525\r
+ * \brief STK525 board hardware driver files.\r
+ * \r
+ * This folder contains drivers for hardware on the Atmel STK525 development board. The header files in this folder should\r
+ * not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory\r
+ * should be included instead.\r
+ *\r
+ * \dir Drivers/Board/RZUSBSTICK\r
+ * \brief RZUSBSTICK board hardware driver files.\r
+ * \r
+ * This folder contains drivers for hardware on the Atmel RZUSBSTICK board, as used in the Atmel "Raven" wireless kits. The header\r
+ * files in this folder should not be included directly in user applications; the similarly named dispatch header files located in\r
+ * the parent Board directory should be included instead.\r
+ *\r
+ * \dir DriverStubs\r
+ * \brief Driver stub header files for custom boards, to allow the LUFA board drivers to operate.\r
+ * \r
+ * This contains stub files for the LUFA board drivers. If the LUFA board drivers are used with board hardare other than those\r
+ * directly supported by the library, the BOARD parameter of the application's makefile can be set to "USER", and these stub files\r
+ * copied to the "/Board/" directory of the application's folder. When fleshed out with working driver code for the custom board,\r
+ * the corresponding LUFA board APIs will work correctly with the non-standard board hardware.\r
+ */\r
--- /dev/null
+# Doxyfile 1.5.7.1\r
+\r
+# This file describes the settings to be used by the documentation system\r
+# doxygen (www.doxygen.org) for a project\r
+#\r
+# All text after a hash (#) is considered a comment and will be ignored\r
+# The format is:\r
+# TAG = value [value, ...]\r
+# For lists items can also be appended using:\r
+# TAG += value [value, ...]\r
+# Values that contain spaces should be placed between quotes (" ")\r
+\r
+#---------------------------------------------------------------------------\r
+# Project related configuration options\r
+#---------------------------------------------------------------------------\r
+\r
+# This tag specifies the encoding used for all characters in the config file \r
+# that follow. The default is UTF-8 which is also the encoding used for all \r
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the \r
+# iconv built into libc) for the transcoding. See \r
+# http://www.gnu.org/software/libiconv for the list of possible encodings.\r
+\r
+DOXYFILE_ENCODING = UTF-8\r
+\r
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded \r
+# by quotes) that should identify the project.\r
+\r
+PROJECT_NAME = "LUFA Library"\r
+\r
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. \r
+# This could be handy for archiving the generated documentation or \r
+# if some version control system is used.\r
+\r
+PROJECT_NUMBER = 000000\r
+\r
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) \r
+# base path where the generated documentation will be put. \r
+# If a relative path is entered, it will be relative to the location \r
+# where doxygen was started. If left blank the current directory will be used.\r
+\r
+OUTPUT_DIRECTORY = ./Documentation/\r
+\r
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create \r
+# 4096 sub-directories (in 2 levels) under the output directory of each output \r
+# format and will distribute the generated files over these directories. \r
+# Enabling this option can be useful when feeding doxygen a huge amount of \r
+# source files, where putting all generated files in the same directory would \r
+# otherwise cause performance problems for the file system.\r
+\r
+CREATE_SUBDIRS = YES\r
+\r
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all \r
+# documentation generated by doxygen is written. Doxygen will use this \r
+# information to generate all constant output in the proper language. \r
+# The default language is English, other supported languages are: \r
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, \r
+# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, \r
+# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), \r
+# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, \r
+# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, \r
+# Spanish, Swedish, and Ukrainian.\r
+\r
+OUTPUT_LANGUAGE = English\r
+\r
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will \r
+# include brief member descriptions after the members that are listed in \r
+# the file and class documentation (similar to JavaDoc). \r
+# Set to NO to disable this.\r
+\r
+BRIEF_MEMBER_DESC = YES\r
+\r
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend \r
+# the brief description of a member or function before the detailed description. \r
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the \r
+# brief descriptions will be completely suppressed.\r
+\r
+REPEAT_BRIEF = YES\r
+\r
+# This tag implements a quasi-intelligent brief description abbreviator \r
+# that is used to form the text in various listings. Each string \r
+# in this list, if found as the leading text of the brief description, will be \r
+# stripped from the text and the result after processing the whole list, is \r
+# used as the annotated text. Otherwise, the brief description is used as-is. \r
+# If left blank, the following values are used ("$name" is automatically \r
+# replaced with the name of the entity): "The $name class" "The $name widget" \r
+# "The $name file" "is" "provides" "specifies" "contains" \r
+# "represents" "a" "an" "the"\r
+\r
+ABBREVIATE_BRIEF = "The $name class" \\r
+ "The $name widget" \\r
+ "The $name file" \\r
+ is \\r
+ provides \\r
+ specifies \\r
+ contains \\r
+ represents \\r
+ a \\r
+ an \\r
+ the\r
+\r
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then \r
+# Doxygen will generate a detailed section even if there is only a brief \r
+# description.\r
+\r
+ALWAYS_DETAILED_SEC = NO\r
+\r
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all \r
+# inherited members of a class in the documentation of that class as if those \r
+# members were ordinary class members. Constructors, destructors and assignment \r
+# operators of the base classes will not be shown.\r
+\r
+INLINE_INHERITED_MEMB = NO\r
+\r
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full \r
+# path before files name in the file list and in the header files. If set \r
+# to NO the shortest path that makes the file name unique will be used.\r
+\r
+FULL_PATH_NAMES = YES\r
+\r
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag \r
+# can be used to strip a user-defined part of the path. Stripping is \r
+# only done if one of the specified strings matches the left-hand part of \r
+# the path. The tag can be used to show relative paths in the file list. \r
+# If left blank the directory from which doxygen is run is used as the \r
+# path to strip.\r
+\r
+STRIP_FROM_PATH = \r
+\r
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of \r
+# the path mentioned in the documentation of a class, which tells \r
+# the reader which header file to include in order to use a class. \r
+# If left blank only the name of the header file containing the class \r
+# definition is used. Otherwise one should specify the include paths that \r
+# are normally passed to the compiler using the -I flag.\r
+\r
+STRIP_FROM_INC_PATH = \r
+\r
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter \r
+# (but less readable) file names. This can be useful is your file systems \r
+# doesn't support long names like on DOS, Mac, or CD-ROM.\r
+\r
+SHORT_NAMES = YES\r
+\r
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen \r
+# will interpret the first line (until the first dot) of a JavaDoc-style \r
+# comment as the brief description. If set to NO, the JavaDoc \r
+# comments will behave just like regular Qt-style comments \r
+# (thus requiring an explicit @brief command for a brief description.)\r
+\r
+JAVADOC_AUTOBRIEF = NO\r
+\r
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will \r
+# interpret the first line (until the first dot) of a Qt-style \r
+# comment as the brief description. If set to NO, the comments \r
+# will behave just like regular Qt-style comments (thus requiring \r
+# an explicit \brief command for a brief description.)\r
+\r
+QT_AUTOBRIEF = NO\r
+\r
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen \r
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// \r
+# comments) as a brief description. This used to be the default behaviour. \r
+# The new default is to treat a multi-line C++ comment block as a detailed \r
+# description. Set this tag to YES if you prefer the old behaviour instead.\r
+\r
+MULTILINE_CPP_IS_BRIEF = NO\r
+\r
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented \r
+# member inherits the documentation from any documented member that it \r
+# re-implements.\r
+\r
+INHERIT_DOCS = YES\r
+\r
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce \r
+# a new page for each member. If set to NO, the documentation of a member will \r
+# be part of the file/class/namespace that contains it.\r
+\r
+SEPARATE_MEMBER_PAGES = NO\r
+\r
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. \r
+# Doxygen uses this value to replace tabs by spaces in code fragments.\r
+\r
+TAB_SIZE = 4\r
+\r
+# This tag can be used to specify a number of aliases that acts \r
+# as commands in the documentation. An alias has the form "name=value". \r
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to \r
+# put the command \sideeffect (or @sideeffect) in the documentation, which \r
+# will result in a user-defined paragraph with heading "Side Effects:". \r
+# You can put \n's in the value part of an alias to insert newlines.\r
+\r
+ALIASES = \r
+\r
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C \r
+# sources only. Doxygen will then generate output that is more tailored for C. \r
+# For instance, some of the names that are used will be different. The list \r
+# of all members will be omitted, etc.\r
+\r
+OPTIMIZE_OUTPUT_FOR_C = YES\r
+\r
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java \r
+# sources only. Doxygen will then generate output that is more tailored for \r
+# Java. For instance, namespaces will be presented as packages, qualified \r
+# scopes will look different, etc.\r
+\r
+OPTIMIZE_OUTPUT_JAVA = NO\r
+\r
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran \r
+# sources only. Doxygen will then generate output that is more tailored for \r
+# Fortran.\r
+\r
+OPTIMIZE_FOR_FORTRAN = NO\r
+\r
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL \r
+# sources. Doxygen will then generate output that is tailored for \r
+# VHDL.\r
+\r
+OPTIMIZE_OUTPUT_VHDL = NO\r
+\r
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want \r
+# to include (a tag file for) the STL sources as input, then you should \r
+# set this tag to YES in order to let doxygen match functions declarations and \r
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. \r
+# func(std::string) {}). This also make the inheritance and collaboration \r
+# diagrams that involve STL classes more complete and accurate.\r
+\r
+BUILTIN_STL_SUPPORT = NO\r
+\r
+# If you use Microsoft's C++/CLI language, you should set this option to YES to\r
+# enable parsing support.\r
+\r
+CPP_CLI_SUPPORT = NO\r
+\r
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. \r
+# Doxygen will parse them like normal C++ but will assume all classes use public \r
+# instead of private inheritance when no explicit protection keyword is present.\r
+\r
+SIP_SUPPORT = NO\r
+\r
+# For Microsoft's IDL there are propget and propput attributes to indicate getter \r
+# and setter methods for a property. Setting this option to YES (the default) \r
+# will make doxygen to replace the get and set methods by a property in the \r
+# documentation. This will only work if the methods are indeed getting or \r
+# setting a simple type. If this is not the case, or you want to show the \r
+# methods anyway, you should set this option to NO.\r
+\r
+IDL_PROPERTY_SUPPORT = YES\r
+\r
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC \r
+# tag is set to YES, then doxygen will reuse the documentation of the first \r
+# member in the group (if any) for the other members of the group. By default \r
+# all members of a group must be documented explicitly.\r
+\r
+DISTRIBUTE_GROUP_DOC = NO\r
+\r
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of \r
+# the same type (for instance a group of public functions) to be put as a \r
+# subgroup of that type (e.g. under the Public Functions section). Set it to \r
+# NO to prevent subgrouping. Alternatively, this can be done per class using \r
+# the \nosubgrouping command.\r
+\r
+SUBGROUPING = YES\r
+\r
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum \r
+# is documented as struct, union, or enum with the name of the typedef. So \r
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct \r
+# with name TypeT. When disabled the typedef will appear as a member of a file, \r
+# namespace, or class. And the struct will be named TypeS. This can typically \r
+# be useful for C code in case the coding convention dictates that all compound \r
+# types are typedef'ed and only the typedef is referenced, never the tag name.\r
+\r
+TYPEDEF_HIDES_STRUCT = NO\r
+\r
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to \r
+# determine which symbols to keep in memory and which to flush to disk.\r
+# When the cache is full, less often used symbols will be written to disk.\r
+# For small to medium size projects (<1000 input files) the default value is \r
+# probably good enough. For larger projects a too small cache size can cause \r
+# doxygen to be busy swapping symbols to and from disk most of the time \r
+# causing a significant performance penality. \r
+# If the system has enough physical memory increasing the cache will improve the \r
+# performance by keeping more symbols in memory. Note that the value works on \r
+# a logarithmic scale so increasing the size by one will rougly double the \r
+# memory usage. The cache size is given by this formula: \r
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, \r
+# corresponding to a cache size of 2^16 = 65536 symbols\r
+\r
+SYMBOL_CACHE_SIZE = 0\r
+\r
+#---------------------------------------------------------------------------\r
+# Build related configuration options\r
+#---------------------------------------------------------------------------\r
+\r
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in \r
+# documentation are documented, even if no documentation was available. \r
+# Private class members and static file members will be hidden unless \r
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES\r
+\r
+EXTRACT_ALL = YES\r
+\r
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class \r
+# will be included in the documentation.\r
+\r
+EXTRACT_PRIVATE = YES\r
+\r
+# If the EXTRACT_STATIC tag is set to YES all static members of a file \r
+# will be included in the documentation.\r
+\r
+EXTRACT_STATIC = YES\r
+\r
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) \r
+# defined locally in source files will be included in the documentation. \r
+# If set to NO only classes defined in header files are included.\r
+\r
+EXTRACT_LOCAL_CLASSES = YES\r
+\r
+# This flag is only useful for Objective-C code. When set to YES local \r
+# methods, which are defined in the implementation section but not in \r
+# the interface are included in the documentation. \r
+# If set to NO (the default) only methods in the interface are included.\r
+\r
+EXTRACT_LOCAL_METHODS = NO\r
+\r
+# If this flag is set to YES, the members of anonymous namespaces will be \r
+# extracted and appear in the documentation as a namespace called \r
+# 'anonymous_namespace{file}', where file will be replaced with the base \r
+# name of the file that contains the anonymous namespace. By default \r
+# anonymous namespace are hidden.\r
+\r
+EXTRACT_ANON_NSPACES = NO\r
+\r
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all \r
+# undocumented members of documented classes, files or namespaces. \r
+# If set to NO (the default) these members will be included in the \r
+# various overviews, but no documentation section is generated. \r
+# This option has no effect if EXTRACT_ALL is enabled.\r
+\r
+HIDE_UNDOC_MEMBERS = NO\r
+\r
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all \r
+# undocumented classes that are normally visible in the class hierarchy. \r
+# If set to NO (the default) these classes will be included in the various \r
+# overviews. This option has no effect if EXTRACT_ALL is enabled.\r
+\r
+HIDE_UNDOC_CLASSES = NO\r
+\r
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all \r
+# friend (class|struct|union) declarations. \r
+# If set to NO (the default) these declarations will be included in the \r
+# documentation.\r
+\r
+HIDE_FRIEND_COMPOUNDS = NO\r
+\r
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any \r
+# documentation blocks found inside the body of a function. \r
+# If set to NO (the default) these blocks will be appended to the \r
+# function's detailed documentation block.\r
+\r
+HIDE_IN_BODY_DOCS = NO\r
+\r
+# The INTERNAL_DOCS tag determines if documentation \r
+# that is typed after a \internal command is included. If the tag is set \r
+# to NO (the default) then the documentation will be excluded. \r
+# Set it to YES to include the internal documentation.\r
+\r
+INTERNAL_DOCS = NO\r
+\r
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate \r
+# file names in lower-case letters. If set to YES upper-case letters are also \r
+# allowed. This is useful if you have classes or files whose names only differ \r
+# in case and if your file system supports case sensitive file names. Windows \r
+# and Mac users are advised to set this option to NO.\r
+\r
+CASE_SENSE_NAMES = NO\r
+\r
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen \r
+# will show members with their full class and namespace scopes in the \r
+# documentation. If set to YES the scope will be hidden.\r
+\r
+HIDE_SCOPE_NAMES = NO\r
+\r
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen \r
+# will put a list of the files that are included by a file in the documentation \r
+# of that file.\r
+\r
+SHOW_INCLUDE_FILES = YES\r
+\r
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] \r
+# is inserted in the documentation for inline members.\r
+\r
+INLINE_INFO = YES\r
+\r
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen \r
+# will sort the (detailed) documentation of file and class members \r
+# alphabetically by member name. If set to NO the members will appear in \r
+# declaration order.\r
+\r
+SORT_MEMBER_DOCS = YES\r
+\r
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the \r
+# brief documentation of file, namespace and class members alphabetically \r
+# by member name. If set to NO (the default) the members will appear in \r
+# declaration order.\r
+\r
+SORT_BRIEF_DOCS = NO\r
+\r
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the \r
+# hierarchy of group names into alphabetical order. If set to NO (the default) \r
+# the group names will appear in their defined order.\r
+\r
+SORT_GROUP_NAMES = NO\r
+\r
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be \r
+# sorted by fully-qualified names, including namespaces. If set to \r
+# NO (the default), the class list will be sorted only by class name, \r
+# not including the namespace part. \r
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\r
+# Note: This option applies only to the class list, not to the \r
+# alphabetical list.\r
+\r
+SORT_BY_SCOPE_NAME = NO\r
+\r
+# The GENERATE_TODOLIST tag can be used to enable (YES) or \r
+# disable (NO) the todo list. This list is created by putting \todo \r
+# commands in the documentation.\r
+\r
+GENERATE_TODOLIST = NO\r
+\r
+# The GENERATE_TESTLIST tag can be used to enable (YES) or \r
+# disable (NO) the test list. This list is created by putting \test \r
+# commands in the documentation.\r
+\r
+GENERATE_TESTLIST = NO\r
+\r
+# The GENERATE_BUGLIST tag can be used to enable (YES) or \r
+# disable (NO) the bug list. This list is created by putting \bug \r
+# commands in the documentation.\r
+\r
+GENERATE_BUGLIST = NO\r
+\r
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or \r
+# disable (NO) the deprecated list. This list is created by putting \r
+# \deprecated commands in the documentation.\r
+\r
+GENERATE_DEPRECATEDLIST= YES\r
+\r
+# The ENABLED_SECTIONS tag can be used to enable conditional \r
+# documentation sections, marked by \if sectionname ... \endif.\r
+\r
+ENABLED_SECTIONS = \r
+\r
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines \r
+# the initial value of a variable or define consists of for it to appear in \r
+# the documentation. If the initializer consists of more lines than specified \r
+# here it will be hidden. Use a value of 0 to hide initializers completely. \r
+# The appearance of the initializer of individual variables and defines in the \r
+# documentation can be controlled using \showinitializer or \hideinitializer \r
+# command in the documentation regardless of this setting.\r
+\r
+MAX_INITIALIZER_LINES = 30\r
+\r
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated \r
+# at the bottom of the documentation of classes and structs. If set to YES the \r
+# list will mention the files that were used to generate the documentation.\r
+\r
+SHOW_USED_FILES = YES\r
+\r
+# If the sources in your project are distributed over multiple directories \r
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy \r
+# in the documentation. The default is NO.\r
+\r
+SHOW_DIRECTORIES = YES\r
+\r
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.\r
+# This will remove the Files entry from the Quick Index and from the \r
+# Folder Tree View (if specified). The default is YES.\r
+\r
+SHOW_FILES = YES\r
+\r
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the \r
+# Namespaces page. This will remove the Namespaces entry from the Quick Index\r
+# and from the Folder Tree View (if specified). The default is YES.\r
+\r
+SHOW_NAMESPACES = YES\r
+\r
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that \r
+# doxygen should invoke to get the current version for each file (typically from \r
+# the version control system). Doxygen will invoke the program by executing (via \r
+# popen()) the command <command> <input-file>, where <command> is the value of \r
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file \r
+# provided by doxygen. Whatever the program writes to standard output \r
+# is used as the file version. See the manual for examples.\r
+\r
+FILE_VERSION_FILTER = \r
+\r
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by \r
+# doxygen. The layout file controls the global structure of the generated output files \r
+# in an output format independent way. The create the layout file that represents \r
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a \r
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name \r
+# of the layout file.\r
+\r
+LAYOUT_FILE = \r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to warning and progress messages\r
+#---------------------------------------------------------------------------\r
+\r
+# The QUIET tag can be used to turn on/off the messages that are generated \r
+# by doxygen. Possible values are YES and NO. If left blank NO is used.\r
+\r
+QUIET = YES\r
+\r
+# The WARNINGS tag can be used to turn on/off the warning messages that are \r
+# generated by doxygen. Possible values are YES and NO. If left blank \r
+# NO is used.\r
+\r
+WARNINGS = YES\r
+\r
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings \r
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will \r
+# automatically be disabled.\r
+\r
+WARN_IF_UNDOCUMENTED = YES\r
+\r
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for \r
+# potential errors in the documentation, such as not documenting some \r
+# parameters in a documented function, or documenting parameters that \r
+# don't exist or using markup commands wrongly.\r
+\r
+WARN_IF_DOC_ERROR = YES\r
+\r
+# This WARN_NO_PARAMDOC option can be abled to get warnings for \r
+# functions that are documented, but have no documentation for their parameters \r
+# or return value. If set to NO (the default) doxygen will only warn about \r
+# wrong or incomplete parameter documentation, but not about the absence of \r
+# documentation.\r
+\r
+WARN_NO_PARAMDOC = YES\r
+\r
+# The WARN_FORMAT tag determines the format of the warning messages that \r
+# doxygen can produce. The string should contain the $file, $line, and $text \r
+# tags, which will be replaced by the file and line number from which the \r
+# warning originated and the warning text. Optionally the format may contain \r
+# $version, which will be replaced by the version of the file (if it could \r
+# be obtained via FILE_VERSION_FILTER)\r
+\r
+WARN_FORMAT = "$file:$line: $text"\r
+\r
+# The WARN_LOGFILE tag can be used to specify a file to which warning \r
+# and error messages should be written. If left blank the output is written \r
+# to stderr.\r
+\r
+WARN_LOGFILE = \r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the input files\r
+#---------------------------------------------------------------------------\r
+\r
+# The INPUT tag can be used to specify the files and/or directories that contain \r
+# documented source files. You may enter file names like "myfile.cpp" or \r
+# directories like "/usr/src/myproject". Separate the files or directories \r
+# with spaces.\r
+\r
+INPUT = ./\r
+\r
+# This tag can be used to specify the character encoding of the source files \r
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is \r
+# also the default input encoding. Doxygen uses libiconv (or the iconv built \r
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for \r
+# the list of possible encodings.\r
+\r
+INPUT_ENCODING = UTF-8\r
+\r
+# If the value of the INPUT tag contains directories, you can use the \r
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp \r
+# and *.h) to filter out the source-files in the directories. If left \r
+# blank the following patterns are tested: \r
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx \r
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90\r
+\r
+FILE_PATTERNS = *.h \\r
+ *.c \\r
+ *.txt\r
+\r
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories \r
+# should be searched for input files as well. Possible values are YES and NO. \r
+# If left blank NO is used.\r
+\r
+RECURSIVE = YES\r
+\r
+# The EXCLUDE tag can be used to specify files and/or directories that should \r
+# excluded from the INPUT source files. This way you can easily exclude a \r
+# subdirectory from a directory tree whose root is specified with the INPUT tag.\r
+\r
+EXCLUDE = \r
+\r
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or \r
+# directories that are symbolic links (a Unix filesystem feature) are excluded \r
+# from the input.\r
+\r
+EXCLUDE_SYMLINKS = NO\r
+\r
+# If the value of the INPUT tag contains directories, you can use the \r
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude \r
+# certain files from those directories. Note that the wildcards are matched \r
+# against the file with absolute path, so to exclude all test directories \r
+# for example use the pattern */test/*\r
+\r
+EXCLUDE_PATTERNS = */LowLevel/USBMode.h\r
+\r
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names \r
+# (namespaces, classes, functions, etc.) that should be excluded from the \r
+# output. The symbol name can be a fully qualified name, a word, or if the \r
+# wildcard * is used, a substring. Examples: ANamespace, AClass, \r
+# AClass::ANamespace, ANamespace::*Test\r
+\r
+EXCLUDE_SYMBOLS = __*\r
+\r
+# The EXAMPLE_PATH tag can be used to specify one or more files or \r
+# directories that contain example code fragments that are included (see \r
+# the \include command).\r
+\r
+EXAMPLE_PATH = \r
+\r
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the \r
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp \r
+# and *.h) to filter out the source-files in the directories. If left \r
+# blank all files are included.\r
+\r
+EXAMPLE_PATTERNS = *\r
+\r
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be \r
+# searched for input files to be used with the \include or \dontinclude \r
+# commands irrespective of the value of the RECURSIVE tag. \r
+# Possible values are YES and NO. If left blank NO is used.\r
+\r
+EXAMPLE_RECURSIVE = NO\r
+\r
+# The IMAGE_PATH tag can be used to specify one or more files or \r
+# directories that contain image that are included in the documentation (see \r
+# the \image command).\r
+\r
+IMAGE_PATH = \r
+\r
+# The INPUT_FILTER tag can be used to specify a program that doxygen should \r
+# invoke to filter for each input file. Doxygen will invoke the filter program \r
+# by executing (via popen()) the command <filter> <input-file>, where <filter> \r
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an \r
+# input file. Doxygen will then use the output that the filter program writes \r
+# to standard output. If FILTER_PATTERNS is specified, this tag will be \r
+# ignored.\r
+\r
+INPUT_FILTER = \r
+\r
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern \r
+# basis. Doxygen will compare the file name with each pattern and apply the \r
+# filter if there is a match. The filters are a list of the form: \r
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further \r
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER \r
+# is applied to all files.\r
+\r
+FILTER_PATTERNS = \r
+\r
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using \r
+# INPUT_FILTER) will be used to filter the input files when producing source \r
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).\r
+\r
+FILTER_SOURCE_FILES = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to source browsing\r
+#---------------------------------------------------------------------------\r
+\r
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will \r
+# be generated. Documented entities will be cross-referenced with these sources. \r
+# Note: To get rid of all source code in the generated output, make sure also \r
+# VERBATIM_HEADERS is set to NO.\r
+\r
+SOURCE_BROWSER = NO\r
+\r
+# Setting the INLINE_SOURCES tag to YES will include the body \r
+# of functions and classes directly in the documentation.\r
+\r
+INLINE_SOURCES = NO\r
+\r
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct \r
+# doxygen to hide any special comment blocks from generated source code \r
+# fragments. Normal C and C++ comments will always remain visible.\r
+\r
+STRIP_CODE_COMMENTS = YES\r
+\r
+# If the REFERENCED_BY_RELATION tag is set to YES \r
+# then for each documented function all documented \r
+# functions referencing it will be listed.\r
+\r
+REFERENCED_BY_RELATION = NO\r
+\r
+# If the REFERENCES_RELATION tag is set to YES \r
+# then for each documented function all documented entities \r
+# called/used by that function will be listed.\r
+\r
+REFERENCES_RELATION = NO\r
+\r
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)\r
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from\r
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will\r
+# link to the source code. Otherwise they will link to the documentstion.\r
+\r
+REFERENCES_LINK_SOURCE = NO\r
+\r
+# If the USE_HTAGS tag is set to YES then the references to source code \r
+# will point to the HTML generated by the htags(1) tool instead of doxygen \r
+# built-in source browser. The htags tool is part of GNU's global source \r
+# tagging system (see http://www.gnu.org/software/global/global.html). You \r
+# will need version 4.8.6 or higher.\r
+\r
+USE_HTAGS = NO\r
+\r
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen \r
+# will generate a verbatim copy of the header file for each class for \r
+# which an include is specified. Set to NO to disable this.\r
+\r
+VERBATIM_HEADERS = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the alphabetical class index\r
+#---------------------------------------------------------------------------\r
+\r
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index \r
+# of all compounds will be generated. Enable this if the project \r
+# contains a lot of classes, structs, unions or interfaces.\r
+\r
+ALPHABETICAL_INDEX = YES\r
+\r
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then \r
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns \r
+# in which this list will be split (can be a number in the range [1..20])\r
+\r
+COLS_IN_ALPHA_INDEX = 5\r
+\r
+# In case all classes in a project start with a common prefix, all \r
+# classes will be put under the same header in the alphabetical index. \r
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that \r
+# should be ignored while generating the index headers.\r
+\r
+IGNORE_PREFIX = \r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the HTML output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will \r
+# generate HTML output.\r
+\r
+GENERATE_HTML = YES\r
+\r
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. \r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be \r
+# put in front of it. If left blank `html' will be used as the default path.\r
+\r
+HTML_OUTPUT = html\r
+\r
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for \r
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank \r
+# doxygen will generate files with .html extension.\r
+\r
+HTML_FILE_EXTENSION = .html\r
+\r
+# The HTML_HEADER tag can be used to specify a personal HTML header for \r
+# each generated HTML page. If it is left blank doxygen will generate a \r
+# standard header.\r
+\r
+HTML_HEADER = \r
+\r
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for \r
+# each generated HTML page. If it is left blank doxygen will generate a \r
+# standard footer.\r
+\r
+HTML_FOOTER = \r
+\r
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading \r
+# style sheet that is used by each HTML page. It can be used to \r
+# fine-tune the look of the HTML output. If the tag is left blank doxygen \r
+# will generate a default style sheet. Note that doxygen will try to copy \r
+# the style sheet file to the HTML output directory, so don't put your own \r
+# stylesheet in the HTML output directory as well, or it will be erased!\r
+\r
+HTML_STYLESHEET = \r
+\r
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, \r
+# files or namespaces will be aligned in HTML using tables. If set to \r
+# NO a bullet list will be used.\r
+\r
+HTML_ALIGN_MEMBERS = YES\r
+\r
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML \r
+# documentation will contain sections that can be hidden and shown after the \r
+# page has loaded. For this to work a browser that supports \r
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox \r
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).\r
+\r
+HTML_DYNAMIC_SECTIONS = YES\r
+\r
+# If the GENERATE_DOCSET tag is set to YES, additional index files \r
+# will be generated that can be used as input for Apple's Xcode 3 \r
+# integrated development environment, introduced with OSX 10.5 (Leopard). \r
+# To create a documentation set, doxygen will generate a Makefile in the \r
+# HTML output directory. Running make will produce the docset in that \r
+# directory and running "make install" will install the docset in \r
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find \r
+# it at startup. \r
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.\r
+\r
+GENERATE_DOCSET = NO\r
+\r
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the \r
+# feed. A documentation feed provides an umbrella under which multiple \r
+# documentation sets from a single provider (such as a company or product suite) \r
+# can be grouped.\r
+\r
+DOCSET_FEEDNAME = "Doxygen generated docs"\r
+\r
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that \r
+# should uniquely identify the documentation set bundle. This should be a \r
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen \r
+# will append .docset to the name.\r
+\r
+DOCSET_BUNDLE_ID = org.doxygen.Project\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files \r
+# will be generated that can be used as input for tools like the \r
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) \r
+# of the generated HTML documentation.\r
+\r
+GENERATE_HTMLHELP = NO\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can \r
+# be used to specify the file name of the resulting .chm file. You \r
+# can add a path in front of the file if the result should not be \r
+# written to the html output directory.\r
+\r
+CHM_FILE = \r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can \r
+# be used to specify the location (absolute path including file name) of \r
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run \r
+# the HTML help compiler on the generated index.hhp.\r
+\r
+HHC_LOCATION = \r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag \r
+# controls if a separate .chi index file is generated (YES) or that \r
+# it should be included in the master .chm file (NO).\r
+\r
+GENERATE_CHI = NO\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING\r
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file\r
+# content.\r
+\r
+CHM_INDEX_ENCODING = \r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag \r
+# controls whether a binary table of contents is generated (YES) or a \r
+# normal table of contents (NO) in the .chm file.\r
+\r
+BINARY_TOC = NO\r
+\r
+# The TOC_EXPAND flag can be set to YES to add extra items for group members \r
+# to the contents of the HTML help documentation and to the tree view.\r
+\r
+TOC_EXPAND = YES\r
+\r
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER \r
+# are set, an additional index file will be generated that can be used as input for \r
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated \r
+# HTML documentation.\r
+\r
+GENERATE_QHP = NO\r
+\r
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can \r
+# be used to specify the file name of the resulting .qch file. \r
+# The path specified is relative to the HTML output folder.\r
+\r
+QCH_FILE = \r
+\r
+# The QHP_NAMESPACE tag specifies the namespace to use when generating \r
+# Qt Help Project output. For more information please see \r
+# <a href="http://doc.trolltech.com/qthelpproject.html#namespace">Qt Help Project / Namespace</a>.\r
+\r
+QHP_NAMESPACE = org.doxygen.Project\r
+\r
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating \r
+# Qt Help Project output. For more information please see \r
+# <a href="http://doc.trolltech.com/qthelpproject.html#virtual-folders">Qt Help Project / Virtual Folders</a>.\r
+\r
+QHP_VIRTUAL_FOLDER = doc\r
+\r
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can \r
+# be used to specify the location of Qt's qhelpgenerator. \r
+# If non-empty doxygen will try to run qhelpgenerator on the generated \r
+# .qhp file .\r
+\r
+QHG_LOCATION = \r
+\r
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at \r
+# top of each HTML page. The value NO (the default) enables the index and \r
+# the value YES disables it.\r
+\r
+DISABLE_INDEX = NO\r
+\r
+# This tag can be used to set the number of enum values (range [1..20]) \r
+# that doxygen will group on one line in the generated HTML documentation.\r
+\r
+ENUM_VALUES_PER_LINE = 1\r
+\r
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\r
+# structure should be generated to display hierarchical information.\r
+# If the tag value is set to FRAME, a side panel will be generated\r
+# containing a tree-like index structure (just like the one that \r
+# is generated for HTML Help). For this to work a browser that supports \r
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, \r
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are \r
+# probably better off using the HTML help feature. Other possible values \r
+# for this tag are: HIERARCHIES, which will generate the Groups, Directories,\r
+# and Class Hierarchy pages using a tree view instead of an ordered list;\r
+# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which\r
+# disables this behavior completely. For backwards compatibility with previous\r
+# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE\r
+# respectively.\r
+\r
+GENERATE_TREEVIEW = YES\r
+\r
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be \r
+# used to set the initial width (in pixels) of the frame in which the tree \r
+# is shown.\r
+\r
+TREEVIEW_WIDTH = 250\r
+\r
+# Use this tag to change the font size of Latex formulas included \r
+# as images in the HTML documentation. The default is 10. Note that \r
+# when you change the font size after a successful doxygen run you need \r
+# to manually remove any form_*.png images from the HTML output directory \r
+# to force them to be regenerated.\r
+\r
+FORMULA_FONTSIZE = 10\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the LaTeX output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will \r
+# generate Latex output.\r
+\r
+GENERATE_LATEX = NO\r
+\r
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. \r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be \r
+# put in front of it. If left blank `latex' will be used as the default path.\r
+\r
+LATEX_OUTPUT = latex\r
+\r
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be \r
+# invoked. If left blank `latex' will be used as the default command name.\r
+\r
+LATEX_CMD_NAME = latex\r
+\r
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to \r
+# generate index for LaTeX. If left blank `makeindex' will be used as the \r
+# default command name.\r
+\r
+MAKEINDEX_CMD_NAME = makeindex\r
+\r
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact \r
+# LaTeX documents. This may be useful for small projects and may help to \r
+# save some trees in general.\r
+\r
+COMPACT_LATEX = NO\r
+\r
+# The PAPER_TYPE tag can be used to set the paper type that is used \r
+# by the printer. Possible values are: a4, a4wide, letter, legal and \r
+# executive. If left blank a4wide will be used.\r
+\r
+PAPER_TYPE = a4wide\r
+\r
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX \r
+# packages that should be included in the LaTeX output.\r
+\r
+EXTRA_PACKAGES = \r
+\r
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for \r
+# the generated latex document. The header should contain everything until \r
+# the first chapter. If it is left blank doxygen will generate a \r
+# standard header. Notice: only use this tag if you know what you are doing!\r
+\r
+LATEX_HEADER = \r
+\r
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated \r
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will \r
+# contain links (just like the HTML output) instead of page references \r
+# This makes the output suitable for online browsing using a pdf viewer.\r
+\r
+PDF_HYPERLINKS = YES\r
+\r
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of \r
+# plain latex in the generated Makefile. Set this option to YES to get a \r
+# higher quality PDF documentation.\r
+\r
+USE_PDFLATEX = YES\r
+\r
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. \r
+# command to the generated LaTeX files. This will instruct LaTeX to keep \r
+# running if errors occur, instead of asking the user for help. \r
+# This option is also used when generating formulas in HTML.\r
+\r
+LATEX_BATCHMODE = NO\r
+\r
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not \r
+# include the index chapters (such as File Index, Compound Index, etc.) \r
+# in the output.\r
+\r
+LATEX_HIDE_INDICES = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the RTF output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output \r
+# The RTF output is optimized for Word 97 and may not look very pretty with \r
+# other RTF readers or editors.\r
+\r
+GENERATE_RTF = NO\r
+\r
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. \r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be \r
+# put in front of it. If left blank `rtf' will be used as the default path.\r
+\r
+RTF_OUTPUT = rtf\r
+\r
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact \r
+# RTF documents. This may be useful for small projects and may help to \r
+# save some trees in general.\r
+\r
+COMPACT_RTF = NO\r
+\r
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated \r
+# will contain hyperlink fields. The RTF file will \r
+# contain links (just like the HTML output) instead of page references. \r
+# This makes the output suitable for online browsing using WORD or other \r
+# programs which support those fields. \r
+# Note: wordpad (write) and others do not support links.\r
+\r
+RTF_HYPERLINKS = NO\r
+\r
+# Load stylesheet definitions from file. Syntax is similar to doxygen's \r
+# config file, i.e. a series of assignments. You only have to provide \r
+# replacements, missing definitions are set to their default value.\r
+\r
+RTF_STYLESHEET_FILE = \r
+\r
+# Set optional variables used in the generation of an rtf document. \r
+# Syntax is similar to doxygen's config file.\r
+\r
+RTF_EXTENSIONS_FILE = \r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the man page output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will \r
+# generate man pages\r
+\r
+GENERATE_MAN = NO\r
+\r
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. \r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be \r
+# put in front of it. If left blank `man' will be used as the default path.\r
+\r
+MAN_OUTPUT = man\r
+\r
+# The MAN_EXTENSION tag determines the extension that is added to \r
+# the generated man pages (default is the subroutine's section .3)\r
+\r
+MAN_EXTENSION = .3\r
+\r
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, \r
+# then it will generate one additional man file for each entity \r
+# documented in the real man page(s). These additional files \r
+# only source the real man page, but without them the man command \r
+# would be unable to find the correct page. The default is NO.\r
+\r
+MAN_LINKS = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the XML output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_XML tag is set to YES Doxygen will \r
+# generate an XML file that captures the structure of \r
+# the code including all documentation.\r
+\r
+GENERATE_XML = NO\r
+\r
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. \r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be \r
+# put in front of it. If left blank `xml' will be used as the default path.\r
+\r
+XML_OUTPUT = xml\r
+\r
+# The XML_SCHEMA tag can be used to specify an XML schema, \r
+# which can be used by a validating XML parser to check the \r
+# syntax of the XML files.\r
+\r
+XML_SCHEMA = \r
+\r
+# The XML_DTD tag can be used to specify an XML DTD, \r
+# which can be used by a validating XML parser to check the \r
+# syntax of the XML files.\r
+\r
+XML_DTD = \r
+\r
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will \r
+# dump the program listings (including syntax highlighting \r
+# and cross-referencing information) to the XML output. Note that \r
+# enabling this will significantly increase the size of the XML output.\r
+\r
+XML_PROGRAMLISTING = YES\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options for the AutoGen Definitions output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will \r
+# generate an AutoGen Definitions (see autogen.sf.net) file \r
+# that captures the structure of the code including all \r
+# documentation. Note that this feature is still experimental \r
+# and incomplete at the moment.\r
+\r
+GENERATE_AUTOGEN_DEF = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the Perl module output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will \r
+# generate a Perl module file that captures the structure of \r
+# the code including all documentation. Note that this \r
+# feature is still experimental and incomplete at the \r
+# moment.\r
+\r
+GENERATE_PERLMOD = NO\r
+\r
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate \r
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able \r
+# to generate PDF and DVI output from the Perl module output.\r
+\r
+PERLMOD_LATEX = NO\r
+\r
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be \r
+# nicely formatted so it can be parsed by a human reader. This is useful \r
+# if you want to understand what is going on. On the other hand, if this \r
+# tag is set to NO the size of the Perl module output will be much smaller \r
+# and Perl will parse it just the same.\r
+\r
+PERLMOD_PRETTY = YES\r
+\r
+# The names of the make variables in the generated doxyrules.make file \r
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. \r
+# This is useful so different doxyrules.make files included by the same \r
+# Makefile don't overwrite each other's variables.\r
+\r
+PERLMOD_MAKEVAR_PREFIX = \r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration options related to the preprocessor \r
+#---------------------------------------------------------------------------\r
+\r
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will \r
+# evaluate all C-preprocessor directives found in the sources and include \r
+# files.\r
+\r
+ENABLE_PREPROCESSING = YES\r
+\r
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro \r
+# names in the source code. If set to NO (the default) only conditional \r
+# compilation will be performed. Macro expansion can be done in a controlled \r
+# way by setting EXPAND_ONLY_PREDEF to YES.\r
+\r
+MACRO_EXPANSION = YES\r
+\r
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES \r
+# then the macro expansion is limited to the macros specified with the \r
+# PREDEFINED and EXPAND_AS_DEFINED tags.\r
+\r
+EXPAND_ONLY_PREDEF = YES\r
+\r
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files \r
+# in the INCLUDE_PATH (see below) will be search if a #include is found.\r
+\r
+SEARCH_INCLUDES = YES\r
+\r
+# The INCLUDE_PATH tag can be used to specify one or more directories that \r
+# contain include files that are not input files but should be processed by \r
+# the preprocessor.\r
+\r
+INCLUDE_PATH = \r
+\r
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard \r
+# patterns (like *.h and *.hpp) to filter out the header-files in the \r
+# directories. If left blank, the patterns specified with FILE_PATTERNS will \r
+# be used.\r
+\r
+INCLUDE_FILE_PATTERNS = \r
+\r
+# The PREDEFINED tag can be used to specify one or more macro names that \r
+# are defined before the preprocessor is started (similar to the -D option of \r
+# gcc). The argument of the tag is a list of macros of the form: name \r
+# or name=definition (no spaces). If the definition and the = are \r
+# omitted =1 is assumed. To prevent a macro definition from being \r
+# undefined via #undef or recursively expanded use the := operator \r
+# instead of the = operator.\r
+\r
+PREDEFINED = __DOXYGEN__\r
+\r
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then \r
+# this tag can be used to specify a list of macro names that should be expanded. \r
+# The macro definition that is found in the sources will be used. \r
+# Use the PREDEFINED tag if you want to use a different macro definition.\r
+\r
+EXPAND_AS_DEFINED = BUTTLOADTAG\r
+\r
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then \r
+# doxygen's preprocessor will remove all function-like macros that are alone \r
+# on a line, have an all uppercase name, and do not end with a semicolon. Such \r
+# function macros are typically used for boiler-plate code, and will confuse \r
+# the parser if not removed.\r
+\r
+SKIP_FUNCTION_MACROS = YES\r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration::additions related to external references \r
+#---------------------------------------------------------------------------\r
+\r
+# The TAGFILES option can be used to specify one or more tagfiles. \r
+# Optionally an initial location of the external documentation \r
+# can be added for each tagfile. The format of a tag file without \r
+# this location is as follows: \r
+# TAGFILES = file1 file2 ... \r
+# Adding location for the tag files is done as follows: \r
+# TAGFILES = file1=loc1 "file2 = loc2" ... \r
+# where "loc1" and "loc2" can be relative or absolute paths or \r
+# URLs. If a location is present for each tag, the installdox tool \r
+# does not have to be run to correct the links.\r
+# Note that each tag file must have a unique name\r
+# (where the name does NOT include the path)\r
+# If a tag file is not located in the directory in which doxygen \r
+# is run, you must also specify the path to the tagfile here.\r
+\r
+TAGFILES = \r
+\r
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create \r
+# a tag file that is based on the input files it reads.\r
+\r
+GENERATE_TAGFILE = \r
+\r
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed \r
+# in the class index. If set to NO only the inherited external classes \r
+# will be listed.\r
+\r
+ALLEXTERNALS = NO\r
+\r
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed \r
+# in the modules index. If set to NO, only the current project's groups will \r
+# be listed.\r
+\r
+EXTERNAL_GROUPS = YES\r
+\r
+# The PERL_PATH should be the absolute path and name of the perl script \r
+# interpreter (i.e. the result of `which perl').\r
+\r
+PERL_PATH = /usr/bin/perl\r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration options related to the dot tool \r
+#---------------------------------------------------------------------------\r
+\r
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will \r
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base \r
+# or super classes. Setting the tag to NO turns the diagrams off. Note that \r
+# this option is superseded by the HAVE_DOT option below. This is only a \r
+# fallback. It is recommended to install and use dot, since it yields more \r
+# powerful graphs.\r
+\r
+CLASS_DIAGRAMS = NO\r
+\r
+# You can define message sequence charts within doxygen comments using the \msc \r
+# command. Doxygen will then run the mscgen tool (see \r
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the \r
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where \r
+# the mscgen tool resides. If left empty the tool is assumed to be found in the \r
+# default search path.\r
+\r
+MSCGEN_PATH = \r
+\r
+# If set to YES, the inheritance and collaboration graphs will hide \r
+# inheritance and usage relations if the target is undocumented \r
+# or is not a class.\r
+\r
+HIDE_UNDOC_RELATIONS = YES\r
+\r
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is \r
+# available from the path. This tool is part of Graphviz, a graph visualization \r
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section \r
+# have no effect if this option is set to NO (the default)\r
+\r
+HAVE_DOT = NO\r
+\r
+# By default doxygen will write a font called FreeSans.ttf to the output \r
+# directory and reference it in all dot files that doxygen generates. This \r
+# font does not include all possible unicode characters however, so when you need \r
+# these (or just want a differently looking font) you can specify the font name \r
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font, \r
+# which can be done by putting it in a standard location or by setting the \r
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory \r
+# containing the font.\r
+\r
+DOT_FONTNAME = FreeSans\r
+\r
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. \r
+# The default size is 10pt.\r
+\r
+DOT_FONTSIZE = 10\r
+\r
+# By default doxygen will tell dot to use the output directory to look for the \r
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a \r
+# different font using DOT_FONTNAME you can set the path where dot \r
+# can find it using this tag.\r
+\r
+DOT_FONTPATH = \r
+\r
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen \r
+# will generate a graph for each documented class showing the direct and \r
+# indirect inheritance relations. Setting this tag to YES will force the \r
+# the CLASS_DIAGRAMS tag to NO.\r
+\r
+CLASS_GRAPH = NO\r
+\r
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen \r
+# will generate a graph for each documented class showing the direct and \r
+# indirect implementation dependencies (inheritance, containment, and \r
+# class references variables) of the class with other documented classes.\r
+\r
+COLLABORATION_GRAPH = NO\r
+\r
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen \r
+# will generate a graph for groups, showing the direct groups dependencies\r
+\r
+GROUP_GRAPHS = NO\r
+\r
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and \r
+# collaboration diagrams in a style similar to the OMG's Unified Modeling \r
+# Language.\r
+\r
+UML_LOOK = NO\r
+\r
+# If set to YES, the inheritance and collaboration graphs will show the \r
+# relations between templates and their instances.\r
+\r
+TEMPLATE_RELATIONS = NO\r
+\r
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT \r
+# tags are set to YES then doxygen will generate a graph for each documented \r
+# file showing the direct and indirect include dependencies of the file with \r
+# other documented files.\r
+\r
+INCLUDE_GRAPH = NO\r
+\r
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and \r
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each \r
+# documented header file showing the documented files that directly or \r
+# indirectly include this file.\r
+\r
+INCLUDED_BY_GRAPH = NO\r
+\r
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then \r
+# doxygen will generate a call dependency graph for every global function \r
+# or class method. Note that enabling this option will significantly increase \r
+# the time of a run. So in most cases it will be better to enable call graphs \r
+# for selected functions only using the \callgraph command.\r
+\r
+CALL_GRAPH = NO\r
+\r
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then \r
+# doxygen will generate a caller dependency graph for every global function \r
+# or class method. Note that enabling this option will significantly increase \r
+# the time of a run. So in most cases it will be better to enable caller \r
+# graphs for selected functions only using the \callergraph command.\r
+\r
+CALLER_GRAPH = NO\r
+\r
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen \r
+# will graphical hierarchy of all classes instead of a textual one.\r
+\r
+GRAPHICAL_HIERARCHY = NO\r
+\r
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES \r
+# then doxygen will show the dependencies a directory has on other directories \r
+# in a graphical way. The dependency relations are determined by the #include\r
+# relations between the files in the directories.\r
+\r
+DIRECTORY_GRAPH = NO\r
+\r
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images \r
+# generated by dot. Possible values are png, jpg, or gif\r
+# If left blank png will be used.\r
+\r
+DOT_IMAGE_FORMAT = png\r
+\r
+# The tag DOT_PATH can be used to specify the path where the dot tool can be \r
+# found. If left blank, it is assumed the dot tool can be found in the path.\r
+\r
+DOT_PATH = "C:/Program Files/Graphviz2.18/bin"\r
+\r
+# The DOTFILE_DIRS tag can be used to specify one or more directories that \r
+# contain dot files that are included in the documentation (see the \r
+# \dotfile command).\r
+\r
+DOTFILE_DIRS = \r
+\r
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of \r
+# nodes that will be shown in the graph. If the number of nodes in a graph \r
+# becomes larger than this value, doxygen will truncate the graph, which is \r
+# visualized by representing a node as a red box. Note that doxygen if the \r
+# number of direct children of the root node in a graph is already larger than \r
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note \r
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\r
+\r
+DOT_GRAPH_MAX_NODES = 15\r
+\r
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the \r
+# graphs generated by dot. A depth value of 3 means that only nodes reachable \r
+# from the root by following a path via at most 3 edges will be shown. Nodes \r
+# that lay further from the root node will be omitted. Note that setting this \r
+# option to 1 or 2 may greatly reduce the computation time needed for large \r
+# code bases. Also note that the size of a graph can be further restricted by \r
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\r
+\r
+MAX_DOT_GRAPH_DEPTH = 2\r
+\r
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent \r
+# background. This is disabled by default, because dot on Windows does not \r
+# seem to support this out of the box. Warning: Depending on the platform used, \r
+# enabling this option may lead to badly anti-aliased labels on the edges of \r
+# a graph (i.e. they become hard to read).\r
+\r
+DOT_TRANSPARENT = YES\r
+\r
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output \r
+# files in one run (i.e. multiple -o and -T options on the command line). This \r
+# makes dot run faster, but since only newer versions of dot (>1.8.10) \r
+# support this, this feature is disabled by default.\r
+\r
+DOT_MULTI_TARGETS = NO\r
+\r
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will \r
+# generate a legend page explaining the meaning of the various boxes and \r
+# arrows in the dot generated graphs.\r
+\r
+GENERATE_LEGEND = YES\r
+\r
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will \r
+# remove the intermediate dot files that are used to generate \r
+# the various graphs.\r
+\r
+DOT_CLEANUP = YES\r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration::additions related to the search engine \r
+#---------------------------------------------------------------------------\r
+\r
+# The SEARCHENGINE tag specifies whether or not a search engine should be \r
+# used. If set to NO the values of all tags below this one will be ignored.\r
+\r
+SEARCHENGINE = NO\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/*\r
+ This is a stub driver header file, for implementing custom board\r
+ layout hardware with compatible LUFA board specific drivers. If\r
+ the library is configured to use the BOARD_USER board mode, this\r
+ driver file should be completed and copied into the "/Board/" folder\r
+ inside the application's folder.\r
+\r
+ This stub is for the board-specific component of the LUFA Dataflash\r
+ driver.\r
+*/\r
+\r
+#ifndef __DATAFLASH_USER_H__\r
+#define __DATAFLASH_USER_H__\r
+\r
+ /* Includes: */\r
+ // TODO: Add any required includes here\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK // TODO: Replace this with a mask of all the /CS pins of all dataflashes\r
+ #define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs\r
+ #define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS // TODO: Replace with the number of dataflashes on the board, max 2\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 // TODO: Replace with mask to select the first Dataflash chip\r
+\r
+ /** Mask for the second dataflash chip selected. */\r
+ #define DATAFLASH_CHIP2 // TODO: Replace with mask to select the second Dataflash chip, if available\r
+ \r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/*\r
+ This is a stub driver header file, for implementing custom board\r
+ layout hardware with compatible LUFA board specific drivers. If\r
+ the library is configured to use the BOARD_USER board mode, this\r
+ driver file should be completed and copied into the "/Board/" folder\r
+ inside the application's folder.\r
+\r
+ This stub is for the board-specific component of the LUFA HWB (Hardware\r
+ Button, a physical button on most Atmel USB boards) driver. This could\r
+ alternately be driven from any button connected to the USB AVR.\r
+*/\r
+ \r
+#ifndef __HWB_USER_H__\r
+#define __HWB_USER_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ // TODO: Add any required includes here\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_HWB_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void HWB_Init(void)\r
+ {\r
+ // TODO: Initialize the appropriate port pin as an input here, with pullup\r
+ }\r
+\r
+ static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool HWB_GetStatus(void)\r
+ {\r
+ // TODO: Return current button status here, debounced if required\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/*\r
+ This is a stub driver header file, for implementing custom board\r
+ layout hardware with compatible LUFA board specific drivers. If\r
+ the library is configured to use the BOARD_USER board mode, this\r
+ driver file should be completed and copied into the "/Board/" folder\r
+ inside the application's folder.\r
+\r
+ This stub is for the board-specific component of the LUFA Joystick\r
+ driver, a small surface mount four-way (plus button) digital joystick\r
+ on most USB AVR boards.\r
+*/\r
+ \r
+#ifndef __JOYSTICK_USER_H__\r
+#define __JOYSTICK_USER_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ // TODO: Add any required includes here\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT // TODO: Add mask to indicate joystick left position here\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP // TODO: Add mask to indicate joystick up position here\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN // TODO: Add mask to indicate joystick down position here\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here\r
+ \r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ // TODO: Initialize joystick port pins as inputs with pullups\r
+ };\r
+ \r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/*\r
+ This is a stub driver header file, for implementing custom board\r
+ layout hardware with compatible LUFA board specific drivers. If\r
+ the library is configured to use the BOARD_USER board mode, this\r
+ driver file should be completed and copied into the "/Board/" folder\r
+ inside the application's folder.\r
+\r
+ This stub is for the board-specific component of the LUFA LEDs driver,\r
+ for the LEDs (up to four) mounted on most USB AVR boards.\r
+*/\r
+\r
+#ifndef __LEDS_USER_H__\r
+#define __LEDS_USER_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ // TODO: Add any required includes here\r
+\r
+/* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 // TODO: Add mask for first board LED here\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 // TODO: Add mask for second board LED here\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 // TODO: Add mask for third board LED here\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 // TODO: Add mask for fourth board LED here\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ // TODO: Add code to initialize LED port pins as outputs here\r
+ }\r
+ \r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+ {\r
+ // TODO: Add code to turn on LEDs given in the LedMask mask here, leave others as-is\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+ {\r
+ // TODO: Add code to turn off LEDs given in the LedMask mask here, leave others as-is\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+ {\r
+ // TODO: Add code to turn on only LEDs given in the LedMask mask here, all others off\r
+ }\r
+ \r
+ static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+ {\r
+ // TODO: Add code to set the Leds in the given LedMask to the status given in ActiveMask here\r
+ }\r
+ \r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ // TODO: Add code to return the current LEDs status' here which can be masked against LED_LED* macros\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC.\r
+ *\r
+ * User code should include this file, which will in turn include the correct ADC driver header file for the\r
+ * currently selected AVR model.\r
+ */\r
+ \r
+#ifndef __ADC_H__\r
+#define __ADC_H__\r
+\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define INCLUDE_FROM_ADC_H\r
+ #define INCLUDE_FROM_CHIP_DRIVER\r
+ #endif\r
+\r
+ /* Includes: */\r
+ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \\r
+ defined(__AVR_ATmega32U6__))\r
+ #include "AT90USBXXX67/ADC.h"\r
+ #else\r
+ #error "ADC is not available for the currently selected AVR model."\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * ADC driver for the AT90USB1287, AT90USB1286, AT90USB647, AT90USB646, ATMEGA16U4 and ATMEGA32U4 AVRs.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver\r
+ * dispatch header located in LUFA/Drivers/AT90USBXXX/ADC.h.\r
+ */\r
+\r
+#ifndef __ADC_AT90USBXXX67_H__\r
+#define __ADC_AT90USBXXX67_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include "../../../Common/Common.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_ADC_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/AT90USBXXX/ADC.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Initializes the ADC, ready for conversions. This must be called before any other ADC operations.\r
+ * The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and\r
+ * prescaler masks.\r
+ */\r
+ #define ADC_Init(mode) MACROS{ ADCSRA = ((1 << ADEN) | mode); }MACROE\r
+\r
+ /** Turns off the ADC. If this is called, any further ADC operations will require a call to the\r
+ * ADC_Init() macro before the ADC can be used again.\r
+ */\r
+ #define ADC_Off() MACROS{ ADCSRA = 0; }MACROE\r
+ \r
+ /** Indicates if the ADC is enabled. This macro will return boolean true if the ADC subsystem is\r
+ * currently enabled, or false otherwise.\r
+ */\r
+ #define ADC_GetStatus() ((ADCSRA & (1 << ADEN)) ? true : false)\r
+\r
+ /** Indicates if the current ADC conversion is completed, or still in progress. This returns boolean\r
+ * false if the reading is still taking place, or true if the conversion is complete and ready to be\r
+ * read out with ADC_GetResult().\r
+ */\r
+ #define ADC_IsReadingComplete() (!(ADCSRA & (1 << ADSC)))\r
+ \r
+ /** Returns the result of the last conversion, as a 16-bit wide integer. */\r
+ #define ADC_GetResult() ADC\r
+ \r
+ /** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */\r
+ #define ADC_REFERENCE_AREF 0\r
+\r
+ /** Reference mask, for using the voltage present at the AVR's AVCC pin for the ADC reference. */\r
+ #define ADC_REFERENCE_AVCC (1 << REFS0)\r
+\r
+ /** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */\r
+ #define ADC_REFERENCE_INT2560MV ((1 << REFS1)| (1 << REFS0))\r
+ \r
+ /** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the\r
+ * ADC_GetResult() macro contain the 8 most significant bits of the result. */\r
+ #define ADC_LEFT_ADJUSTED (1 << ADLAR)\r
+\r
+ /** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the\r
+ * ADC_GetResult() macro contain the 8 least significant bits of the result. */\r
+ #define ADC_RIGHT_ADJUSTED (0 << ADLAR)\r
+ \r
+ /** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC\r
+ * is capable of at the given input clock speed. */\r
+ #define ADC_FREE_RUNNING (1 << ADATE)\r
+\r
+ /** Sets the ADC mode to single conversion, so that only a single conversion will take place before\r
+ * the ADC returns to idle. */\r
+ #define ADC_SINGLE_CONVERSION (0 << ADATE)\r
+ \r
+ /** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */\r
+ #define ADC_PRESCALE_2 (1 << ADPS0)\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 4 the AVR's system clock. */\r
+ #define ADC_PRESCALE_4 (1 << ADPS1)\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 8 the AVR's system clock. */\r
+ #define ADC_PRESCALE_8 ((1 << ADPS0) | (1 << ADPS1))\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 16 the AVR's system clock. */\r
+ #define ADC_PRESCALE_16 (1 << ADPS2)\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 32 the AVR's system clock. */\r
+ #define ADC_PRESCALE_32 ((1 << ADPS2) | (1 << ADPS0))\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 64 the AVR's system clock. */\r
+ #define ADC_PRESCALE_64 ((1 << ADPS2) | (1 << ADPS1))\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */\r
+ #define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))\r
+\r
+ /* Inline Functions: */\r
+ /** Configures the given ADC channel, ready for ADC conversions. This function sets the\r
+ * associated port pin as an input and disables the digital portion of the I/O to reduce\r
+ * power consumption.\r
+ *\r
+ * \param Channel ADC channel number to set up for conversions\r
+ */\r
+ static inline void ADC_SetupChannel(const uint8_t Channel)\r
+ {\r
+ DDRD &= ~(1 << Channel);\r
+ DIDR0 |= (1 << Channel);\r
+ }\r
+ \r
+ /** Starts the reading of the given channel, but does not wait until the conversion has completed.\r
+ * Once executed, the conversion status can be determined via the ADC_IsReadingComplete() macro and\r
+ * the result read via the ADC_GetResult() macro.\r
+ *\r
+ * \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask\r
+ */\r
+ static inline void ADC_StartReading(const uint8_t MUXMask)\r
+ {\r
+ ADMUX = MUXMask;\r
+ \r
+ ADCSRA |= (1 << ADSC);\r
+ }\r
+\r
+ /** Performs a complete single reading from channel, including a polling spinloop to wait for the\r
+ * conversion to complete, and the returning of the converted value.\r
+ *\r
+ * \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask\r
+ */\r
+ static inline uint16_t ADC_GetChannelReading(const uint8_t MUXMask) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t ADC_GetChannelReading(const uint8_t MUXMask)\r
+ {\r
+ ADC_StartReading(MUXMask);\r
+ \r
+ while (!(ADC_IsReadingComplete()));\r
+ \r
+ return ADC_GetResult();\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Hardware SPI subsystem driver for the supported USB AVRs models.\r
+ */\r
+\r
+#ifndef __SPI_H__\r
+#define __SPI_H__\r
+\r
+ /* Includes: */\r
+ #include <stdbool.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define SPI_USE_DOUBLESPEED (1 << 7)\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 2. */\r
+ #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED\r
+\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 4. */\r
+ #define SPI_SPEED_FCPU_DIV_4 0\r
+\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 8. */\r
+ #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPR0))\r
+\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 16. */\r
+ #define SPI_SPEED_FCPU_DIV_16 (1 << SPR0)\r
+\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 32. */\r
+ #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (1 << SPR1))\r
+\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 64. */\r
+ #define SPI_SPEED_FCPU_DIV_64 (SPI_USE_DOUBLESPEED | (1 << SPR1) | (1 < SPR0))\r
+\r
+ /** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 128. */\r
+ #define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 < SPR0))\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the SPI subsystem, ready for transfers. Must be called before calling any other\r
+ * SPI routines.\r
+ *\r
+ * \param PrescalerMask Prescaler mask to set the SPI clock speed\r
+ * \param Master If true, sets the SPI system to use master mode, slave if false\r
+ */\r
+ static inline void SPI_Init(const uint8_t PrescalerMask, const bool Master)\r
+ {\r
+ DDRB |= ((1 << 1) | (1 << 2));\r
+ PORTB |= ((1 << 0) | (1 << 3));\r
+ \r
+ SPCR = ((1 << SPE) | (Master << MSTR) | (1 << CPOL) | (1 << CPHA) |\r
+ (PrescalerMask & ~SPI_USE_DOUBLESPEED));\r
+ \r
+ if (PrescalerMask & SPI_USE_DOUBLESPEED)\r
+ SPSR = (1 << SPI2X);\r
+ }\r
+ \r
+ /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.\r
+ *\r
+ * \param Byte Byte to send through the SPI interface\r
+ *\r
+ * \return Response byte from the attached SPI device\r
+ */\r
+ static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYSINLINE;\r
+ static inline uint8_t SPI_TransferByte(const uint8_t Byte)\r
+ {\r
+ SPDR = Byte;\r
+ while (!(SPSR & (1 << SPIF)));\r
+ return SPDR;\r
+ }\r
+\r
+ /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response\r
+ * byte sent to from the attached SPI device is ignored.\r
+ *\r
+ * \param Byte Byte to send through the SPI interface\r
+ */\r
+ static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYSINLINE;\r
+ static inline void SPI_SendByte(const uint8_t Byte)\r
+ {\r
+ SPDR = Byte;\r
+ while (!(SPSR & (1 << SPIF)));\r
+ }\r
+\r
+ /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response\r
+ * byte from the attached SPI device is returned.\r
+ *\r
+ * \return The response byte from the attached SPI device\r
+ */\r
+ static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYSINLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t SPI_ReceiveByte(void)\r
+ {\r
+ SPDR = 0x00;\r
+ while (!(SPSR & (1 << SPIF)));\r
+ return SPDR;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "Serial.h"\r
+\r
+void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)\r
+{\r
+ UCSR1A = ((DoubleSpeed) ? (1 << U2X1) : 0);\r
+ UCSR1B = ((1 << RXEN1) | (1 << TXEN1));\r
+ UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));\r
+ \r
+ DDRD |= (1 << 3); \r
+ PORTD |= (1 << 2);\r
+ \r
+ UBRR1 = SERIAL_UBBRVAL(BaudRate);\r
+}\r
+\r
+void Serial_TxString_P(const char *FlashStringPtr)\r
+{\r
+ uint8_t CurrByte;\r
+\r
+ while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)\r
+ {\r
+ Serial_TxByte(CurrByte);\r
+ FlashStringPtr++;\r
+ }\r
+}\r
+\r
+void Serial_TxString(const char *StringPtr)\r
+{\r
+ uint8_t CurrByte;\r
+\r
+ while ((CurrByte = *StringPtr) != 0x00)\r
+ {\r
+ Serial_TxByte(CurrByte);\r
+ StringPtr++;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Driver for the USART subsystem on supported USB AVRs.\r
+ */\r
+ \r
+#ifndef __SERIAL_H__\r
+#define __SERIAL_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <avr/pgmspace.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include "../../Common/Common.h"\r
+ #include "../Misc/TerminalCodes.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */ \r
+ /** Indicates whether a character has been received through the USART - boolean false if no character\r
+ * has been received, or non-zero if a character is waiting to be read from the reception buffer.\r
+ */\r
+ #define Serial_IsCharReceived() ((UCSR1A & (1 << RXC1)) ? true : false)\r
+\r
+ /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is\r
+ * not set.\r
+ */\r
+ #define SERIAL_UBBRVAL(baud) (((F_CPU / 16) / baud) - 1)\r
+\r
+ /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is\r
+ * set.\r
+ */\r
+ #define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / baud) - 1)\r
+\r
+ /* Function Prototypes: */\r
+ /** Initializes the USART, ready for serial data transmission and reception.\r
+ *\r
+ * \param BaudRate Baud rate to configure the USART to\r
+ * \param DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate\r
+ */\r
+ void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed);\r
+\r
+ /** Transmits a given string located in program space (FLASH) through the USART.\r
+ *\r
+ * \param FlashStringPtr Pointer to a string located in program space\r
+ */\r
+ void Serial_TxString_P(const char *FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Transmits a given string located in SRAM memory through the USART.\r
+ *\r
+ * \param StringPtr Pointer to a string located in SRAM space\r
+ */\r
+ void Serial_TxString(const char *StringPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /* Inline Functions: */\r
+ /** Transmits a given byte through the USART.\r
+ *\r
+ * \param DataByte Byte to transmit through the USART\r
+ */\r
+ static inline void Serial_TxByte(const char DataByte)\r
+ {\r
+ while (!(UCSR1A & (1 << UDRE1)));\r
+ UDR1 = DataByte;\r
+ }\r
+\r
+ /** Receives a byte from the USART.\r
+ *\r
+ * \return Byte received from the USART\r
+ */\r
+ static inline char Serial_RxByte(void)\r
+ {\r
+ while (!(UCSR1A & (1 << RXC1)));\r
+ return UDR1; \r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "Serial_Stream.h"\r
+\r
+FILE USARTStream = FDEV_SETUP_STREAM(SerialStream_TxByte, SerialStream_RxByte, _FDEV_SETUP_RW);\r
+\r
+int SerialStream_TxByte(char DataByte, FILE *Stream)\r
+{\r
+ Serial_TxByte(DataByte);\r
+\r
+ return 0;\r
+}\r
+\r
+int SerialStream_RxByte(FILE *Stream)\r
+{\r
+ return Serial_RxByte();\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Serial stream driver for the USART subsystem on supported USB AVRs. This makes use of the functions in the\r
+ * regular USART driver, but allows the avr-libc standard stream functions (printf, puts, etc.) to work with the\r
+ * USART.\r
+ **/\r
+\r
+#ifndef __SERIAL_STREAM_H__\r
+#define __SERIAL_STREAM_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdio.h>\r
+ \r
+ #include "Serial.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */ \r
+ #if !defined(__DOXYGEN__)\r
+ /* External Variables: */\r
+ extern FILE USARTStream;\r
+\r
+ /* Function Prototypes: */\r
+ int SerialStream_TxByte(char DataByte, FILE *Stream) ATTR_NON_NULL_PTR_ARG(2);\r
+ int SerialStream_RxByte(FILE *Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Inline Functions: */\r
+ /** Initializes the serial stream (and regular USART driver) so that both the stream and regular\r
+ * USART driver functions can be used. Must be called before any stream or regular USART functions.\r
+ *\r
+ * \param BaudRate Baud rate to configure the USART to\r
+ * \param DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate\r
+ */\r
+ static inline void SerialStream_Init(const uint32_t BaudRate, const bool DoubleSpeed)\r
+ {\r
+ Serial_Init(BaudRate, DoubleSpeed);\r
+ \r
+ stdout = &USARTStream;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the ATAVRUSBRF01.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the HWB driver\r
+ * dispatch header located in LUFA/Drivers/Board/HWB.h.\r
+ */\r
+ \r
+#ifndef __HWB_ATAVRUSBRF01_H__\r
+#define __HWB_ATAVRUSBRF01_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_HWB_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void HWB_Init(void)\r
+ {\r
+ DDRD &= ~(1 << 7);\r
+ PORTD |= (1 << 7);\r
+ }\r
+\r
+ static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool HWB_GetStatus(void)\r
+ {\r
+ return (!(PIND & (1 << 7)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific LED driver header for the ATAVRUSBRF01.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+ \r
+#ifndef __LEDS_ATAVRUSBRF01_H__\r
+#define __LEDS_ATAVRUSBRF01_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2)\r
+ #define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4)\r
+ \r
+ #define LEDS_PORTE_MASK_SHIFT 4\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 0)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 1)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+ \r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= (LEDMask & LEDS_ALL_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~(LEDMask & LEDS_ALL_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = (PORTD & ~LEDS_ALL_LEDS) | (LEDMask & LEDS_ALL_LEDS);\r
+ }\r
+ \r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTD = (PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS))\r
+ }\r
+ \r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file is the master dispatch header file for the board-specific dataflash driver, for boards containing\r
+ * dataflash ICs for external non-volatile storage.\r
+ *\r
+ * User code should include this file, which will in turn include the correct dataflash driver header file for\r
+ * the currently selected board.\r
+ *\r
+ * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project\r
+ * directory.\r
+ */\r
+ \r
+#ifndef __DATAFLASH_H__\r
+#define __DATAFLASH_H__\r
+\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define INCLUDE_FROM_DATAFLASH_H\r
+ #define INCLUDE_FROM_BOARD_DRIVER\r
+ #endif\r
+\r
+ /* Includes: */\r
+ #include "../AT90USBXXX/SPI.h"\r
+ #include "../../Common/Common.h"\r
+ \r
+ #if !defined(BOARD)\r
+ #error BOARD must be set in makefile to a value specified in BoardTypes.h.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "USBKEY/Dataflash.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "STK525/Dataflash.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "STK526/Dataflash.h"\r
+ #elif (BOARD == BOARD_USER)\r
+ #include "Board/Dataflash.h"\r
+ #else\r
+ #error The selected board does not contain a dataflash IC.\r
+ #endif\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Returns the mask of the currently selected Dataflash chip, either DATAFLASH_NO_CHIP or a\r
+ * DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ #define Dataflash_GetSelectedChip() (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK)\r
+\r
+ /** Selects the dataflash chip given as a chip mask, in the form of DATAFLASH_CHIPn (where n\r
+ * is the chip number).\r
+ */\r
+ #define Dataflash_SelectChip(mask) MACROS{ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT \\r
+ & ~DATAFLASH_CHIPCS_MASK) | mask); }MACROE\r
+ \r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ #define Dataflash_DeselectChip() Dataflash_SelectChip(DATAFLASH_NO_CHIP)\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver (including the SPI driver) so that commands and data may be\r
+ * sent to an attached dataflash IC.\r
+ *\r
+ * \param PrescalerMask SPI prescaler mask, see SPI.h documentation\r
+ */\r
+ static inline void Dataflash_Init(const uint8_t PrescalerMask)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+\r
+ SPI_Init(PrescalerMask, true);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYSINLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SPI_TransferByte(Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYSINLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SPI_SendByte(Byte);\r
+ }\r
+ \r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYSINLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SPI_ReceiveByte();\r
+ }\r
+ \r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ #if (DATAFLASH_TOTALCHIPS == 2)\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+ \r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ #else\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1); \r
+ #endif\r
+ }\r
+\r
+ /** Spinloops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside the total number\r
+ * of pages contained in the boards dataflash ICs, all dataflash ICs are deselected.\r
+ *\r
+ * \param PageAddress Address of the page to manipulate, ranging from\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+ \r
+ if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))\r
+ return;\r
+\r
+ #if (DATAFLASH_TOTALCHIPS == 2)\r
+ if (PageAddress & 0x01)\r
+ Dataflash_SelectChip(DATAFLASH_CHIP2);\r
+ else\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ #else\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ #endif\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-byte address.\r
+ *\r
+ * \param PageAddress Page address within the selected dataflash IC\r
+ * \param BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)\r
+ { \r
+ #if (DATAFLASH_TOTALCHIPS == 2)\r
+ PageAddress >>= 1;\r
+ #endif\r
+\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file is the master dispatch header file for the board-specific HWB driver, for boards containing a\r
+ * physical pushbutton connected to the AVR's HWB IO pin.\r
+ *\r
+ * User code should include this file, which will in turn include the correct HWB driver header file for the\r
+ * currently selected board.\r
+ *\r
+ * If the BOARD value is set to BOARD_USER, this will include the /Board/HWB.h file in the user project\r
+ * directory.\r
+ */\r
+ \r
+#ifndef __HWB_H__\r
+#define __HWB_H__\r
+\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define INCLUDE_FROM_HWB_H\r
+ #define INCLUDE_FROM_BOARD_DRIVER\r
+ #endif\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+ \r
+ #if !defined(BOARD)\r
+ #error BOARD must be set in makefile to a value specified in BoardTypes.h.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "USBKEY/HWB.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "STK525/HWB.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "STK526/HWB.h"\r
+ #elif (BOARD == BOARD_ATAVRUSBRF01)\r
+ #include "ATAVRUSBRF01/HWB.h"\r
+ #elif (BOARD == BOARD_USER)\r
+ #include "Board/HWB.h" \r
+ #else\r
+ #error The selected board does not contain a HWB.\r
+ #endif\r
+ \r
+ /* Psudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Initializes the HWB driver, so that the current button position can be read. This sets the appropriate\r
+ * I/O pin to an input with pull-up enabled.\r
+ *\r
+ * This must be called before any HWB functions are used.\r
+ */\r
+ static inline void HWB_Init(void);\r
+ \r
+ /** Returns the current position of the HWB button on the board.\r
+ *\r
+ * \return Boolean true if the button is currently pressed, false otherwise\r
+ */\r
+ static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file is the master dispatch header file for the board-specific Joystick driver, for boards containing a\r
+ * 5-way joystick.\r
+ *\r
+ * User code should include this file, which will in turn include the correct joystick driver header file for the\r
+ * currently selected board.\r
+ *\r
+ * If the BOARD value is set to BOARD_USER, this will include the /Board/Joystick.h file in the user project\r
+ * directory.\r
+ */\r
+ \r
+#ifndef __JOYSTICK_H__\r
+#define __JOYSTICK_H__\r
+\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define INCLUDE_FROM_JOYSTICK_H\r
+ #define INCLUDE_FROM_BOARD_DRIVER\r
+ #endif\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+ \r
+ #if !defined(BOARD)\r
+ #error BOARD must be set in makefile to a value specified in BoardTypes.h.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "USBKEY/Joystick.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "STK525/Joystick.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "STK526/Joystick.h"\r
+ #elif (BOARD == BOARD_USER)\r
+ #include "Board/Joystick.h" \r
+ #else\r
+ #error The selected board does not contain a joystick.\r
+ #endif\r
+\r
+ /* Psudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Initializes the joystick driver so that the joystick position can be read. This sets the appropriate\r
+ * I/O pins to inputs with their pull-ups enabled.\r
+ */\r
+ static inline void Joystick_Init(void);\r
+\r
+ /** Returns the current status of the joystick, as a mask indicating the direction the joystick is\r
+ * currently facing in (multiple bits can be set).\r
+ *\r
+ * \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file\r
+ * for direction masks\r
+ */\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * This file is the master dispatch header file for the board-specific LED driver, for boards containing user\r
+ * controllable LEDs.\r
+ *\r
+ * User code should include this file, which will in turn include the correct LED driver header file for the\r
+ * currently selected board.\r
+ *\r
+ * If the BOARD value is set to BOARD_USER, this will include the /Board/LEDs.h file in the user project\r
+ * directory.\r
+ */\r
+ \r
+#ifndef __LEDS_H__\r
+#define __LEDS_H__\r
+\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define INCLUDE_FROM_LEDS_H\r
+ #define INCLUDE_FROM_BOARD_DRIVER\r
+ #endif\r
+ \r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ #if !defined(BOARD)\r
+ #error BOARD must be set in makefile to a value specified in BoardTypes.h.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "USBKEY/LEDs.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "STK525/LEDs.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "STK526/LEDs.h"\r
+ #elif (BOARD == BOARD_RZUSBSTICK)\r
+ #include "RZUSBSTICK/LEDs.h"\r
+ #elif (BOARD == BOARD_ATAVRUSBRF01)\r
+ #include "ATAVRUSBRF01/LEDs.h"\r
+ #elif (BOARD == BOARD_USER)\r
+ #include "Board/LEDs.h"\r
+ #endif\r
+ \r
+ /* Psudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Initializes the board LED driver so that the LEDs can be controlled. This sets the appropriate port\r
+ * I/O pins as outputs, and sets the LEDs to default to off.\r
+ */\r
+ static inline void LEDs_Init(void);\r
+\r
+ /** Turns on the LEDs specified in the given LED mask.\r
+ *\r
+ * \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)\r
+ */\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask);\r
+\r
+ /** Turns off the LEDs specified in the given LED mask.\r
+ *\r
+ * \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)\r
+ */\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask);\r
+\r
+ /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED\r
+ * mask.\r
+ *\r
+ * \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)\r
+ */\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask);\r
+\r
+ /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs\r
+ * specified in both the LED and active masks.\r
+ *\r
+ * \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)\r
+ * \param ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off\r
+ */\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask);\r
+\r
+ /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the\r
+ * corresponding LED is on.\r
+ *\r
+ * \return Mask of the board LEDs which are currently turned on\r
+ */\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific LED driver header for the RZUSBSTICK.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+ \r
+#ifndef __LEDS_RZUSBSTICK_H__\r
+#define __LEDS_RZUSBSTICK_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2)\r
+ #define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4)\r
+ \r
+ #define LEDS_PORTE_MASK_SHIFT 4\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 7)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 ((1 << 6) >> LEDS_PORTE_MASK_SHIFT)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 ((1 << 7) >> LEDS_PORTE_MASK_SHIFT)\r
+
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+ \r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_PORTD_LEDS;\r
+ PORTD &= ~LEDS_LED1;\r
+ PORTD |= LEDS_LED2;\r
+\r
+ DDRE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ PORTE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+ \r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= (LEDMask & LEDS_LED1);\r
+ PORTD &= ~(LEDMask & LEDS_LED2); \r
+ PORTE &= ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~(LEDMask & LEDS_LED1);\r
+ PORTD |= (LEDMask & LEDS_LED2);\r
+ PORTE |= ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = (((PORTD & ~LEDS_LED1) | (LEDMask & LEDS_LED1)) |\r
+ ((PORTD | LEDS_LED2) & ~(LEDMask & LEDS_LED2)));\r
+ PORTE = ((PORTE | (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) &\r
+ ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
+ }\r
+ \r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTD = (((PORTD & ~(LEDMask & LEDS_LED1)) | (ActiveMask & LEDS_LED1)) |\r
+ ((PORTD | (LEDMask & LEDS_LED2)) & ~(ActiveMask & LEDS_LED2)));\r
+ PORTE = ((PORTE | ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)) &\r
+ ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
+ }\r
+ \r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (((PORTD & LEDS_LED1) | (~PORTD & LEDS_LED2)) |\r
+ ((~PORTE & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) >> LEDS_PORTE_MASK_SHIFT));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific Dataflash commands header for the AT45DB321C as mounted on the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+#ifndef __DATAFLASH_CMDS_H__\r
+#define __DATAFLASH_CMDS_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #define DF_STATUS_READY (1 << 7)\r
+ #define DF_STATUS_COMPMISMATCH (1 << 6)\r
+ #define DF_STATUS_SECTORPROTECTION_ON (1 << 1)\r
+ \r
+ #define DF_MANUFACTURER_ATMEL 0x1F\r
+ \r
+ #define DF_CMD_GETSTATUS 0xD7\r
+\r
+ #define DF_CMD_MAINMEMTOBUFF1 0x53\r
+ #define DF_CMD_MAINMEMTOBUFF2 0x55\r
+ #define DF_CMD_MAINMEMTOBUFF1COMP 0x60\r
+ #define DF_CMD_MAINMEMTOBUFF2COMP 0x61\r
+ #define DF_CMD_AUTOREWRITEBUFF1 0x58\r
+ #define DF_CMD_AUTOREWRITEBUFF2 0x59\r
+ \r
+ #define DF_CMD_MAINMEMPAGEREAD 0xD2\r
+ #define DF_CMD_CONTARRAYREAD_LF 0xE8\r
+ #define DF_CMD_BUFF1READ_LF 0xD4\r
+ #define DF_CMD_BUFF2READ_LF 0xD6\r
+ \r
+ #define DF_CMD_BUFF1WRITE 0x84\r
+ #define DF_CMD_BUFF2WRITE 0x87\r
+ #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83\r
+ #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86\r
+ #define DF_CMD_BUFF1TOMAINMEM 0x88\r
+ #define DF_CMD_BUFF2TOMAINMEM 0x89\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85\r
+ \r
+ #define DF_CMD_PAGEERASE 0x81\r
+ #define DF_CMD_BLOCKERASE 0x50\r
+\r
+ #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF})\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF\r
+ \r
+ #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+#ifndef __DATAFLASH_STK525_H__\r
+#define __DATAFLASH_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include "AT45DB321C.h" \r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 4)\r
+ #define DATAFLASH_CHIPCS_DDR DDRB\r
+ #define DATAFLASH_CHIPCS_PORT PORTB\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 0\r
+ \r
+ /** Internal main memory page size for the board's dataflash IC. */\r
+ #define DATAFLASH_PAGE_SIZE 512\r
+\r
+ /** Total number of pages inside the board's dataflash IC. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the HWB driver\r
+ * dispatch header located in LUFA/Drivers/Board/HWB.h.\r
+ */\r
+ \r
+#ifndef __HWB_STK525_H__\r
+#define __HWB_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_HWB_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void HWB_Init(void)\r
+ {\r
+ DDRE &= ~(1 << 2);\r
+ PORTE |= (1 << 2);\r
+ }\r
+\r
+ static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool HWB_GetStatus(void)\r
+ {\r
+ return (!(PINE & (1 << 2)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific joystick driver header for the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+ \r
+#ifndef __JOYSTICK_STK525_H__\r
+#define __JOYSTICK_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7))\r
+ #define JOY_EMASK ((1 << 4) | (1 << 5))\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 6)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT ((1 << 4) >> 1)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN ((1 << 5) >> 1)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 5)\r
+ \r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRB &= ~(JOY_BMASK);\r
+ DDRE &= ~(JOY_EMASK);\r
+\r
+ PORTB |= JOY_BMASK;\r
+ PORTE |= JOY_EMASK; \r
+ };\r
+ \r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific LED driver header for the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+ \r
+#ifndef __LEDS_STK525_H__\r
+#define __LEDS_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+ \r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+ \r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD |= LedMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD &= ~LedMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);\r
+ }\r
+ \r
+ static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LedMask) | ActiveMask);\r
+ }\r
+ \r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific Dataflash commands header for the AT45DB642D as mounted on the STK526.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+#ifndef __DATAFLASH_CMDS_H__\r
+#define __DATAFLASH_CMDS_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #define DF_STATUS_READY (1 << 7)\r
+ #define DF_STATUS_COMPMISMATCH (1 << 6)\r
+ #define DF_STATUS_SECTORPROTECTION_ON (1 << 1)\r
+ #define DF_STATUS_BINARYPAGESIZE_ON (1 << 0)\r
+ \r
+ #define DF_MANUFACTURER_ATMEL 0x1F\r
+ \r
+ #define DF_CMD_GETSTATUS 0xD7\r
+ #define DF_CMD_POWERDOWN 0xB9\r
+ #define DF_CMD_WAKEUP 0xAB\r
+\r
+ #define DF_CMD_MAINMEMTOBUFF1 0x53\r
+ #define DF_CMD_MAINMEMTOBUFF2 0x55\r
+ #define DF_CMD_MAINMEMTOBUFF1COMP 0x60\r
+ #define DF_CMD_MAINMEMTOBUFF2COMP 0x61\r
+ #define DF_CMD_AUTOREWRITEBUFF1 0x58\r
+ #define DF_CMD_AUTOREWRITEBUFF2 0x59\r
+ \r
+ #define DF_CMD_MAINMEMPAGEREAD 0xD2\r
+ #define DF_CMD_CONTARRAYREAD_LF 0x03\r
+ #define DF_CMD_BUFF1READ_LF 0xD1\r
+ #define DF_CMD_BUFF2READ_LF 0xD3\r
+ \r
+ #define DF_CMD_BUFF1WRITE 0x84\r
+ #define DF_CMD_BUFF2WRITE 0x87\r
+ #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83\r
+ #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86\r
+ #define DF_CMD_BUFF1TOMAINMEM 0x88\r
+ #define DF_CMD_BUFF2TOMAINMEM 0x89\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85\r
+ \r
+ #define DF_CMD_PAGEERASE 0x81\r
+ #define DF_CMD_BLOCKERASE 0x50\r
+ #define DF_CMD_SECTORERASE 0x7C\r
+\r
+ #define DF_CMD_CHIPERASE ((char[]){0xC7, 0x94, 0x80, 0x9A})\r
+ #define DF_CMD_CHIPERASE_BYTE1 0xC7\r
+ #define DF_CMD_CHIPERASE_BYTE2 0x94\r
+ #define DF_CMD_CHIPERASE_BYTE3 0x80\r
+ #define DF_CMD_CHIPERASE_BYTE4 0x9A\r
+ \r
+ #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0x9A})\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0x9A\r
+ \r
+ #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+#ifndef __DATAFLASH_STK526_H__\r
+#define __DATAFLASH_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include "AT45DB642D.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 2)\r
+ #define DATAFLASH_CHIPCS_DDR DDRC\r
+ #define DATAFLASH_CHIPCS_PORT PORTC\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 0\r
+ \r
+ /** Internal main memory page size for the board's dataflash IC. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside the board's dataflash IC. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the STK526.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the HWB driver\r
+ * dispatch header located in LUFA/Drivers/Board/HWB.h.\r
+ */\r
+ \r
+#ifndef __HWB_STK526_H__\r
+#define __HWB_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_HWB_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void HWB_Init(void)\r
+ {\r
+ DDRD &= ~(1 << 7);\r
+ PORTD |= (1 << 7);\r
+ }\r
+\r
+ static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool HWB_GetStatus(void)\r
+ {\r
+ return (!(PIND & (1 << 7)));\r
+ }\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific joystick driver header for the STK526.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+ \r
+#ifndef __JOYSTICK_STK526_H__\r
+#define __JOYSTICK_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_BMASK ((1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7))\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 4)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT (1 << 6)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 5)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 0)\r
+ \r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+\r
+ PORTB |= JOY_BMASK;\r
+ };\r
+ \r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return ((uint8_t)~PINB & JOY_BMASK);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific LED driver header for the STK526.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+ \r
+#ifndef __LEDS_STK526_H__\r
+#define __LEDS_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 1)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 0)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 5)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+ \r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD |= LedMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD &= ~LedMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);\r
+ }\r
+ \r
+ static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LedMask) | ActiveMask);\r
+ }\r
+ \r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "Temperature.h"\r
+\r
+static const uint16_t PROGMEM Temperature_Lookup[] = {\r
+ 0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373,\r
+ 0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307,\r
+ 0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C,\r
+ 0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7,\r
+ 0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161,\r
+ 0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7,\r
+ 0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA,\r
+ 0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074,\r
+ 0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050,\r
+ 0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038\r
+ };\r
+\r
+int8_t Temperature_GetTemperature(void)\r
+{\r
+ uint16_t Temp_ADC = ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | TEMP_ADC_CHANNEL);\r
+\r
+ if (Temp_ADC > pgm_read_word(&Temperature_Lookup[0]))\r
+ return TEMP_MIN_TEMP;\r
+\r
+ for (uint16_t Index = 0; Index < TEMP_TABLE_SIZE; Index++)\r
+ {\r
+ if (Temp_ADC > pgm_read_word(&Temperature_Lookup[Index]))\r
+ return (Index + TEMP_TABLE_OFFSET);\r
+ }\r
+\r
+ return TEMP_MAX_TEMP;\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Temperature sensor board driver for the USB boards which contain a temperature sensor.\r
+ */\r
+\r
+#ifndef __TEMPERATURE_H__\r
+#define __TEMPERATURE_H__\r
+\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define INCLUDE_FROM_BOARD_DRIVER\r
+ #endif\r
+ \r
+ /* Includes: */\r
+ #include <avr/pgmspace.h>\r
+\r
+ #include "../AT90USBXXX/ADC.h"\r
+ #include "../../Common/Common.h"\r
+ \r
+ #if !defined(BOARD)\r
+ #error #error BOARD must be set in makefile to a value specified in BoardTypes.h. \r
+ #elif (BOARD != BOARD_USBKEY) && (BOARD != BOARD_STK525) && (BOARD != BOARD_STK526)\r
+ #error The selected board does not contain a temperature sensor.\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** ADC channel number for the temperature sensor. */\r
+ #define TEMP_ADC_CHANNEL 0\r
+ \r
+ /** Minimum returnable temperature from the Temperature_GetTemperature() function. */\r
+ #define TEMP_MIN_TEMP TEMP_TABLE_OFFSET\r
+\r
+ /** Maximum returnable temperature from the Temperature_GetTemperature() function. */\r
+ #define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET)\r
+ \r
+ /** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.\r
+ * This must be called before any other temperature sensor routines.\r
+ *\r
+ * The ADC itself (not the ADC channel) must be configured seperately before calling the temperature\r
+ * sensor functions.\r
+ */\r
+ #define Temperature_Init() ADC_SetupChannel(TEMP_ADC_CHANNEL);\r
+\r
+ /* Function Prototypes: */\r
+ /** Performs a complete ADC on the temperature sensor channel, and converts the result into a\r
+ * valid temperature between TEMP_MIN_TEMP and TEMP_MAX_TEMP in degrees Celcius.\r
+ *\r
+ * \return Signed temperature in degrees Celcius\r
+ */\r
+ int8_t Temperature_GetTemperature(void) ATTR_WARN_UNUSED_RESULT;\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define TEMP_TABLE_SIZE (sizeof(Temperature_Lookup) / sizeof(Temperature_Lookup[0]))\r
+ #define TEMP_TABLE_OFFSET -21\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific Dataflash commands header for the AT45DB642D as mounted on the USBKEY.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+#ifndef __DATAFLASH_CMDS_H__\r
+#define __DATAFLASH_CMDS_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #define DF_STATUS_READY (1 << 7)\r
+ #define DF_STATUS_COMPMISMATCH (1 << 6)\r
+ #define DF_STATUS_SECTORPROTECTION_ON (1 << 1)\r
+ #define DF_STATUS_BINARYPAGESIZE_ON (1 << 0)\r
+ \r
+ #define DF_MANUFACTURER_ATMEL 0x1F\r
+ \r
+ #define DF_CMD_GETSTATUS 0xD7\r
+ #define DF_CMD_POWERDOWN 0xB9\r
+ #define DF_CMD_WAKEUP 0xAB\r
+\r
+ #define DF_CMD_MAINMEMTOBUFF1 0x53\r
+ #define DF_CMD_MAINMEMTOBUFF2 0x55\r
+ #define DF_CMD_MAINMEMTOBUFF1COMP 0x60\r
+ #define DF_CMD_MAINMEMTOBUFF2COMP 0x61\r
+ #define DF_CMD_AUTOREWRITEBUFF1 0x58\r
+ #define DF_CMD_AUTOREWRITEBUFF2 0x59\r
+ \r
+ #define DF_CMD_MAINMEMPAGEREAD 0xD2\r
+ #define DF_CMD_CONTARRAYREAD_LF 0x03\r
+ #define DF_CMD_BUFF1READ_LF 0xD1\r
+ #define DF_CMD_BUFF2READ_LF 0xD3\r
+ \r
+ #define DF_CMD_BUFF1WRITE 0x84\r
+ #define DF_CMD_BUFF2WRITE 0x87\r
+ #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83\r
+ #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86\r
+ #define DF_CMD_BUFF1TOMAINMEM 0x88\r
+ #define DF_CMD_BUFF2TOMAINMEM 0x89\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85\r
+ \r
+ #define DF_CMD_PAGEERASE 0x81\r
+ #define DF_CMD_BLOCKERASE 0x50\r
+ #define DF_CMD_SECTORERASE 0x7C\r
+\r
+ #define DF_CMD_CHIPERASE ((char[]){0xC7, 0x94, 0x80, 0x9A})\r
+ #define DF_CMD_CHIPERASE_BYTE1 0xC7\r
+ #define DF_CMD_CHIPERASE_BYTE2 0x94\r
+ #define DF_CMD_CHIPERASE_BYTE3 0x80\r
+ #define DF_CMD_CHIPERASE_BYTE4 0x9A\r
+ \r
+ #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0x9A})\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0x9A\r
+ \r
+ #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the STK525.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+#ifndef __DATAFLASH_USBKEY_H__\r
+#define __DATAFLASH_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include "AT45DB642D.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK ((1 << 1) | (1 << 0))\r
+ #define DATAFLASH_CHIPCS_DDR DDRE\r
+ #define DATAFLASH_CHIPCS_PORT PORTE\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 2\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 (1 << 1)\r
+\r
+ /** Mask for the second dataflash chip selected. */\r
+ #define DATAFLASH_CHIP2 (1 << 0)\r
+ \r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific HWB driver header for the USBKEY.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the HWB driver\r
+ * dispatch header located in LUFA/Drivers/Board/HWB.h.\r
+ */\r
+ \r
+#ifndef __HWB_USBKEY_H__\r
+#define __HWB_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_HWB_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void HWB_Init(void)\r
+ {\r
+ DDRE &= ~(1 << 2);\r
+ PORTE |= (1 << 2);\r
+ }\r
+\r
+ static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool HWB_GetStatus(void)\r
+ {\r
+ return (!(PINE & (1 << 2)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific joystick driver header for the USBKEY.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+ \r
+#ifndef __JOYSTICK_USBKEY_H__\r
+#define __JOYSTICK_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7))\r
+ #define JOY_EMASK ((1 << 4) | (1 << 5))\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 6)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT ((1 << 4) >> 1)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN ((1 << 5) >> 1)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 5)\r
+ \r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRB &= ~(JOY_BMASK);\r
+ DDRE &= ~(JOY_EMASK);\r
+\r
+ PORTB |= JOY_BMASK;\r
+ PORTE |= JOY_EMASK; \r
+ };\r
+ \r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Board specific LED driver header for the USBKEY.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+#ifndef __LEDS_USBKEY_H__\r
+#define __LEDS_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+ \r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD |= LedMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD &= ~LedMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LedMask);\r
+ }\r
+ \r
+ static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LedMask) | ActiveMask);\r
+ }\r
+ \r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * ANSI terminal compatible escape sequences. These escape sequences are designed to be concatenated with existing\r
+ * strings to modify their display on a compatible terminal application.\r
+ *\r
+ * \note If desired, the macro DISABLE_TERMINAL_CODES can be defined in the project makefile and passed to the GCC\r
+ * compiler via the -D switch to disable the terminal codes without modifying the source, for use with non\r
+ * compatible terminals (any terminal code then equate to empty strings).\r
+ *\r
+ * Example Usage:\r
+ * \code\r
+ * printf("Some String, " ESC_BOLD_ON " Some bold string");\r
+ * \endcode\r
+ */\r
+ \r
+#ifndef __TERMINALCODES_H__\r
+#define __TERMINALCODES_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if !defined(DISABLE_TERMINAL_CODES)\r
+ /** Creates an ANSII escape sequence with the payload specified by "c". */\r
+ #define ANSI_ESCAPE_SEQUENCE(c) "\33[" c\r
+ #else\r
+ #define ANSI_ESCAPE_SEQUENCE(c)\r
+ #endif\r
+\r
+ /** Resets any escape sequence modifiers back to their defaults. */\r
+ #define ESC_RESET ANSI_ESCAPE_SEQUENCE("0m")\r
+\r
+ /** Turns on bold so that any following text is printed to the terminal in bold. */\r
+ #define ESC_BOLD_ON ANSI_ESCAPE_SEQUENCE("1m")\r
+\r
+ /** Turns on italics so that any following text is printed to the terminal in italics. */\r
+ #define ESC_ITALICS_ON ANSI_ESCAPE_SEQUENCE("3m")\r
+\r
+ /** Turns on underline so that any following text is printed to the terminal underlined. */\r
+ #define ESC_UNDERLINE_ON ANSI_ESCAPE_SEQUENCE("4m")\r
+\r
+ /** Turns on inverse so that any following text is printed to the terminal in inverted colours. */\r
+ #define ESC_INVERSE_ON ANSI_ESCAPE_SEQUENCE("7m")\r
+\r
+ /** Turns on strikethrough so that any following text is printed to the terminal with a line through the\r
+ * center.\r
+ */\r
+ #define ESC_STRIKETHROUGH_ON ANSI_ESCAPE_SEQUENCE("9m")\r
+\r
+ /** Turns off bold so that any following text is printed to the terminal in non bold. */\r
+ #define ESC_BOLD_OFF ANSI_ESCAPE_SEQUENCE("22m")\r
+\r
+ /** Turns off italics so that any following text is printed to the terminal in non italics. */\r
+ #define ESC_ITALICS_OFF ANSI_ESCAPE_SEQUENCE("23m")\r
+ \r
+ /** Turns off underline so that any following text is printed to the terminal non underlined. */ \r
+ #define ESC_UNDERLINE_OFF ANSI_ESCAPE_SEQUENCE("24m")\r
+\r
+ /** Turns off inverse so that any following text is printed to the terminal in non inverted colours. */\r
+ #define ESC_INVERSE_OFF ANSI_ESCAPE_SEQUENCE("27m")\r
+\r
+ /** Turns off strikethrough so that any following text is printed to the terminal without a line through\r
+ * the center.\r
+ */\r
+ #define ESC_STRIKETHROUGH_OFF ANSI_ESCAPE_SEQUENCE("29m")\r
+\r
+ /** Sets the foreground (text) colour to black. */\r
+ #define ESC_FG_BLACK ANSI_ESCAPE_SEQUENCE("30m")\r
+\r
+ /** Sets the foreground (text) colour to red. */\r
+ #define ESC_FG_RED ANSI_ESCAPE_SEQUENCE("31m")\r
+\r
+ /** Sets the foreground (text) colour to green. */\r
+ #define ESC_FG_GREEN ANSI_ESCAPE_SEQUENCE("32m")\r
+\r
+ /** Sets the foreground (text) colour to yellow. */\r
+ #define ESC_FG_YELLOW ANSI_ESCAPE_SEQUENCE("33m")\r
+\r
+ /** Sets the foreground (text) colour to blue. */\r
+ #define ESC_FG_BLUE ANSI_ESCAPE_SEQUENCE("34m")\r
+\r
+ /** Sets the foreground (text) colour to magenta. */\r
+ #define ESC_FG_MAGENTA ANSI_ESCAPE_SEQUENCE("35m")\r
+\r
+ /** Sets the foreground (text) colour to cyan. */\r
+ #define ESC_FG_CYAN ANSI_ESCAPE_SEQUENCE("36m")\r
+\r
+ /** Sets the foreground (text) colour to white. */\r
+ #define ESC_FG_WHITE ANSI_ESCAPE_SEQUENCE("37m")\r
+\r
+ /** Sets the foreground (text) colour to the terminal's default. */\r
+ #define ESC_FG_DEFAULT ANSI_ESCAPE_SEQUENCE("39m")\r
+\r
+ /** Sets the text background colour to black. */\r
+ #define ESC_BG_BLACK ANSI_ESCAPE_SEQUENCE("40m")\r
+\r
+ /** Sets the text background colour to red. */\r
+ #define ESC_BG_RED ANSI_ESCAPE_SEQUENCE("41m")\r
+\r
+ /** Sets the text background colour to green. */\r
+ #define ESC_BG_GREEN ANSI_ESCAPE_SEQUENCE("42m")\r
+\r
+ /** Sets the text background colour to yellow. */\r
+ #define ESC_BG_YELLOW ANSI_ESCAPE_SEQUENCE("43m")\r
+\r
+ /** Sets the text background colour to blue. */\r
+ #define ESC_BG_BLUE ANSI_ESCAPE_SEQUENCE("44m")\r
+\r
+ /** Sets the text background colour to magenta. */\r
+ #define ESC_BG_MAGENTA ANSI_ESCAPE_SEQUENCE("45m")\r
+\r
+ /** Sets the text background colour to cyan. */\r
+ #define ESC_BG_CYAN ANSI_ESCAPE_SEQUENCE("46m")\r
+\r
+ /** Sets the text background colour to white. */\r
+ #define ESC_BG_WHITE ANSI_ESCAPE_SEQUENCE("47m")\r
+\r
+ /** Sets the text background colour to the terminal's default. */\r
+ #define ESC_BG_DEFAULT ANSI_ESCAPE_SEQUENCE("49m")\r
+ \r
+ /** Sets the cursor position to the given line and column. */\r
+ #define ESC_CURSOR_POS(L, C) ANSI_ESCAPE_SEQUENCE(#L ";" #C "H")\r
+\r
+ /** Moves the cursor up the given number of lines. */\r
+ #define ESC_CURSOR_UP(L) ANSI_ESCAPE_SEQUENCE(#L "A")\r
+\r
+ /** Moves the cursor down the given number of lines. */\r
+ #define ESC_CURSOR_DOWN(L) ANSI_ESCAPE_SEQUENCE(#L "B")\r
+\r
+ /** Moves the cursor to the right the given number of columns. */\r
+ #define ESC_CURSOR_FORWARD(C) ANSI_ESCAPE_SEQUENCE(#C "C")\r
+\r
+ /** Moves the cursor to the left the given number of columns. */\r
+ #define ESC_CURSOR_BACKWARD(C) ANSI_ESCAPE_SEQUENCE(#C "D")\r
+\r
+ /** Saves the current cursor position so that it may be restored with ESC_CURSOR_POS_RESTORE. */\r
+ #define ESC_CURSOR_POS_SAVE ANSI_ESCAPE_SEQUENCE("s")\r
+\r
+ /** Restores the cursor position to the last position saved with ESC_CURSOR_POS_SAVE. */\r
+ #define ESC_CURSOR_POS_RESTORE ANSI_ESCAPE_SEQUENCE("u")\r
+ \r
+ /** Erases the entire display, returning the cursor to the top left. */\r
+ #define ESC_ERASE_DISPLAY ANSI_ESCAPE_SEQUENCE("2J")\r
+\r
+ /** Erases the current line, returning the cursor to the far left. */\r
+ #define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K")\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "ConfigDescriptor.h"\r
+\r
+uint8_t USB_Host_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ USB_HostRequest = (USB_Host_Request_Header_t)\r
+ {\r
+ bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ bRequest: REQ_GetDescriptor,\r
+ wValue: (DTYPE_Configuration << 8),\r
+ wIndex: 0,\r
+ wLength: sizeof(USB_Descriptor_Configuration_Header_t),\r
+ };\r
+ \r
+ if (BufferPtr == NULL)\r
+ {\r
+ uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)];\r
+\r
+ ErrorCode = USB_Host_SendControlRequest(ConfigHeader);\r
+\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)\r
+ *ConfigSizePtr = DESCRIPTOR_CAST(ConfigHeader, USB_Descriptor_Configuration_Header_t).TotalConfigurationSize;\r
+ #else\r
+ *ConfigSizePtr = DESCRIPTOR_CAST(ConfigHeader, USB_Descriptor_Configuration_Header_t).wTotalLength; \r
+ #endif\r
+ }\r
+ else\r
+ {\r
+ USB_HostRequest.wLength = *ConfigSizePtr;\r
+ \r
+ ErrorCode = USB_Host_SendControlRequest(BufferPtr); \r
+ }\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+void USB_Host_GetNextDescriptorOfType(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc,\r
+ const uint8_t Type)\r
+{\r
+ while (*BytesRem)\r
+ {\r
+ USB_Host_GetNextDescriptor(BytesRem, CurrConfigLoc); \r
+\r
+ if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)\r
+ return;\r
+ }\r
+}\r
+\r
+void USB_Host_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t BeforeType)\r
+{\r
+ while (*BytesRem)\r
+ {\r
+ USB_Host_GetNextDescriptor(BytesRem, CurrConfigLoc);\r
+\r
+ if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)\r
+ {\r
+ return;\r
+ }\r
+ else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType)\r
+ {\r
+ *BytesRem = 0;\r
+ return;\r
+ }\r
+ }\r
+}\r
+\r
+void USB_Host_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t AfterType)\r
+{\r
+ USB_Host_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);\r
+ \r
+ if (*BytesRem)\r
+ USB_Host_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);\r
+}\r
+ \r
+uint8_t USB_Host_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc,\r
+ uint8_t (* const ComparatorRoutine)(void*))\r
+{\r
+ uint8_t ErrorCode;\r
+ \r
+ while (*BytesRem)\r
+ {\r
+ uint8_t* PrevDescLoc = *CurrConfigLoc;\r
+ uint16_t PrevBytesRem = *BytesRem;\r
+\r
+ USB_Host_GetNextDescriptor(BytesRem, CurrConfigLoc);\r
+\r
+ if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != Descriptor_Search_NotFound)\r
+ {\r
+ if (ErrorCode == Descriptor_Search_Fail)\r
+ {\r
+ *CurrConfigLoc = PrevDescLoc;\r
+ *BytesRem = PrevBytesRem;\r
+ }\r
+ \r
+ return ErrorCode;\r
+ }\r
+ }\r
+ \r
+ return Descriptor_Search_Comp_EndOfDescriptor;\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Configuration descriptor parser API. This section of the library gives a friendly API which can be used in\r
+ * host applications to easily parse an attached device's configuration descriptor so that endpoint, interface\r
+ * and other descriptor data can be extracted and used as needed.\r
+ */\r
+\r
+#ifndef __CONFIGDESCRIPTOR_H__\r
+#define __CONFIGDESCRIPTOR_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ \r
+ #include "../../../Common/Common.h"\r
+ #include "../LowLevel/HostChapter9.h"\r
+ #include "../HighLevel/StdDescriptors.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given\r
+ * descriptor type.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header\r
+ * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor,\r
+ * USB_Descriptor_Configuration_Header_t);\r
+ *\r
+ * // Can now access elements of the configuration header struct using the -> indirection operator\r
+ * \endcode\r
+ */\r
+ #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)DescriptorPtr)\r
+\r
+ /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor\r
+ * type (as an actual struct instance rather than a pointer to a struct).\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header\r
+ * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor,\r
+ * USB_Descriptor_Configuration_Header_t);\r
+ *\r
+ * // Can now access elements of the configuration header struct using the . operator\r
+ * \endcode\r
+ */\r
+ #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type))\r
+\r
+ /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor.\r
+ * This value's meaning depends on the descriptor's placement in the descriptor, but standard type\r
+ * values can be accessed in the DescriptorTypes_t enum located in USB/HighLevel/StdDescriptors.h.\r
+ */\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Type\r
+ #else\r
+ #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bDescriptorType \r
+ #endif\r
+ \r
+ /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).Size\r
+ #else\r
+ #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_CAST(DescriptorPtr, USB_Descriptor_Header_t).bLength\r
+ #endif\r
+ \r
+ /** Creates a prototype for or begins a descriptor comparitor routine. Descriptor comparitor routines are \r
+ * small search routines which are passed a pointer to the current sub descriptor in the configuration\r
+ * descriptor, and which analyse the sub descriptor to determine whether or not it matches the routine's\r
+ * search parameters. Comparitor routines provide a powerful way to scan through the config descriptor\r
+ * for certain descriptors matching unique criteria.\r
+ *\r
+ * Comparitor routines are passed in a single pointer named CurrentDescriptor, and should return a value\r
+ * of a member of the DSEARCH_Return_ErrorCodes_t enum.\r
+ */\r
+ #define DESCRIPTOR_COMPARATOR(name) uint8_t DCOMP_##name (void* const CurrentDescriptor)\r
+\r
+ /** Searches for the next descriptor in the given configuration descriptor using a premade comparator\r
+ * function. The routine updates the position and remaining configuration descriptor bytes values\r
+ * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back\r
+ * so that the next descriptor search invocation will start from the descriptor which first caused the\r
+ * original search to fail. This behaviour allows for one comparator to be used immediately after another\r
+ * has failed, starting the second search from the descriptor which failed the first.\r
+ *\r
+ * \param DSize Pointer to an int storing the remaining bytes in the configuration descriptor\r
+ * \param DPos Pointer to the current position in the configuration descriptor\r
+ * \param DSearch Name of the comparitor search function to use on the configuration descriptor\r
+ *\r
+ * \return Value of one of the members of the DSEARCH_Comp_Return_ErrorCodes_t enum\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * DESCRIPTOR_COMPARATOR(EndpointSearcher); // Comparator Prototype\r
+ *\r
+ * DESCRIPTOR_COMPARATOR(EndpointSearcher)\r
+ * {\r
+ * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)\r
+ * return Descriptor_Search_Found;\r
+ * else\r
+ * return Descriptor_Search_NotFound;\r
+ * }\r
+ *\r
+ * //...\r
+ * // After retrieving configuration descriptor:\r
+ * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &ConfigDescriptorData, EndpointSearcher) ==\r
+ * Descriptor_Search_Comp_Found)\r
+ * {\r
+ * // Do something with the endpoint descriptor\r
+ * }\r
+ * \endcode\r
+ */\r
+ #define USB_Host_GetNextDescriptorComp(DSize, DPos, DSearch) \\r
+ USB_Host_GetNextDescriptorComp_P(DSize, DPos, DCOMP_##DSearch)\r
+ /* Enums: */\r
+ /** Enum for return values of a descriptor comparator made with DESCRIPTOR_COMPARATOR. */\r
+ enum DSEARCH_Return_ErrorCodes_t\r
+ {\r
+ Descriptor_Search_Found = 0, /**< Current descriptor matches comparator criteria. */\r
+ Descriptor_Search_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */\r
+ Descriptor_Search_NotFound = 2, /**< Current descriptor does not match comparator criteria. */\r
+ };\r
+\r
+ /** Enum for return values of USB_Host_GetNextDescriptorComp() */\r
+ enum DSEARCH_Comp_Return_ErrorCodes_t\r
+ {\r
+ Descriptor_Search_Comp_Found = 0, /**< Configuration descriptor now points to decriptor which matches\r
+ * search criteria of the given comparator function. */\r
+ Descriptor_Search_Comp_Fail = 1, /**< Comparator function returned Descriptor_Search_Fail. */\r
+ Descriptor_Search_Comp_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */\r
+ };\r
+ \r
+ /* Function Prototypes: */\r
+ /** Retrieves the configuration descriptor data or size from an attached device via a standard request.\r
+ *\r
+ * \param ConfigSizePtr Pointer to a uint16_t for either storing or retrieving the configuration\r
+ * descriptor size\r
+ *\r
+ * \param BufferPtr Pointer to the buffer for storing the configuration descriptor data. If this is\r
+ * NULL, the size of the configuration descriptor will be retrieved instead and\r
+ * placed in the variable pointed to by ConfigSizePtr. If this is non-NULL, the number\r
+ * of bytes indicated by ConfigSizePtr of the configuration descriptor will be loaded\r
+ * into the buffer\r
+ */\r
+ uint8_t USB_Host_GetDeviceConfigDescriptor(uint16_t* const ConfigSizePtr, void* BufferPtr)\r
+ ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /* Inline Functions: */\r
+ /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then\r
+ points to the next sub-descriptor. The bytes remaining value is automatically decremented.\r
+ *\r
+ * \param BytesRem Pointer to the number of bytes remaining of the configuration descriptor\r
+ * \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor\r
+ */\r
+ static inline void USB_Host_GetNextDescriptor(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc) \r
+ ATTR_NON_NULL_PTR_ARG(1, 2); \r
+ static inline void USB_Host_GetNextDescriptor(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc)\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)\r
+ uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;\r
+ #else\r
+ uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).bLength; \r
+ #endif\r
+\r
+ *CurrConfigLoc += CurrDescriptorSize;\r
+ *BytesRem -= CurrDescriptorSize;\r
+ }\r
+\r
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value.\r
+ * The bytes remaining value is automatically decremented.\r
+ *\r
+ * \param BytesRem Pointer to the number of bytes remaining of the configuration descriptor\r
+ * \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor\r
+ * \param Type Descriptor type value to search for\r
+ */\r
+ void USB_Host_GetNextDescriptorOfType(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc,\r
+ const uint8_t Type)\r
+ ATTR_NON_NULL_PTR_ARG(1, 2);\r
+\r
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,\r
+ * which must come before a descriptor of the second given type value. If the BeforeType type\r
+ * descriptor is reached first, the number of bytes remaining to process is set to zero and the\r
+ * function exits. The bytes remaining value is automatically decremented.\r
+ *\r
+ * \param BytesRem Pointer to the number of bytes remaining of the configuration descriptor\r
+ * \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor\r
+ * \param Type Descriptor type value to search for\r
+ * \param BeforeType Descriptor type value which must not be reached before the given Type descriptor\r
+ */\r
+ void USB_Host_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t BeforeType)\r
+ ATTR_NON_NULL_PTR_ARG(1, 2);\r
+\r
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,\r
+ * which must come after a descriptor of the second given type value. The bytes remaining value is\r
+ * automatically decremented.\r
+ *\r
+ * \param BytesRem Pointer to the number of bytes remaining of the configuration descriptor\r
+ * \param CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor\r
+ * \param Type Descriptor type value to search for\r
+ * \param AfterType Descriptor type value which must be reached before the given Type descriptor\r
+ */\r
+ void USB_Host_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,\r
+ uint8_t** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t AfterType)\r
+ ATTR_NON_NULL_PTR_ARG(1, 2);\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ uint8_t USB_Host_GetNextDescriptorComp_P(uint16_t* BytesRem, uint8_t** CurrConfigLoc,\r
+ uint8_t (* const ComparatorRoutine)(void* const));\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "HIDParser.h"\r
+\r
+uint8_t ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID_ReportInfo_t* const ParserData)\r
+{\r
+ HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];\r
+ HID_StateTable_t* CurrStateTable = &StateTable[0];\r
+ uint16_t UsageStack[HID_USAGE_STACK_DEPTH];\r
+ uint8_t UsageStackSize = 0;\r
+ uint16_t BitOffsetIn = 0;\r
+ uint16_t BitOffsetOut = 0;\r
+#if defined(HID_ENABLE_FEATURE_PROCESSING)\r
+ uint16_t BitOffsetFeature = 0;\r
+#endif\r
+ HID_CollectionPath_t* CurrCollectionPath = NULL;\r
+\r
+ memset((void*)ParserData, 0x00, sizeof(HID_ReportInfo_t));\r
+ memset((void*)StateTable, 0x00, sizeof(StateTable));\r
+\r
+ while (ReportSize)\r
+ {\r
+ uint32_t ReportItemData = 0;\r
+ \r
+ switch (*ReportData & DATA_SIZE_MASK)\r
+ {\r
+ case DATA_SIZE_4:\r
+ ReportItemData = *((uint32_t*)(ReportData + 1));\r
+ break;\r
+ case DATA_SIZE_2:\r
+ ReportItemData = *((uint16_t*)(ReportData + 1));\r
+ break;\r
+ case DATA_SIZE_1:\r
+ ReportItemData = *((uint8_t*)(ReportData + 1));\r
+ break;\r
+ }\r
+\r
+ switch (*ReportData & (TYPE_MASK | TAG_MASK))\r
+ {\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_PUSH):\r
+ if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH])\r
+ return HID_PARSE_HIDStackOverflow;\r
+ \r
+ memcpy((CurrStateTable - 1),\r
+ CurrStateTable,\r
+ sizeof(HID_ReportItem_t));\r
+\r
+ CurrStateTable++;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_POP):\r
+ if (CurrStateTable == &StateTable[0])\r
+ return HID_PARSE_HIDStackUnderflow;\r
+ \r
+ CurrStateTable--;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_USAGEPAGE):\r
+ CurrStateTable->Attributes.Usage.Page = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMIN):\r
+ CurrStateTable->Attributes.Logical.Minimum = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_LOGICALMAX):\r
+ CurrStateTable->Attributes.Logical.Maximum = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMIN):\r
+ CurrStateTable->Attributes.Physical.Minimum = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_PHYSMAX):\r
+ CurrStateTable->Attributes.Physical.Maximum = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_UNITEXP):\r
+ CurrStateTable->Attributes.Unit.Exponent = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_UNIT):\r
+ CurrStateTable->Attributes.Unit.Type = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_REPORTSIZE):\r
+ CurrStateTable->Attributes.BitSize = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_REPORTCOUNT):\r
+ CurrStateTable->ReportCount = ReportItemData;\r
+ break;\r
+ case (TYPE_GLOBAL | TAG_GLOBAL_REPORTID):\r
+ CurrStateTable->ReportID = ReportItemData;\r
+ break;\r
+ case (TYPE_LOCAL | TAG_LOCAL_USAGE):\r
+ if (UsageStackSize == HID_USAGE_STACK_DEPTH)\r
+ return HID_PARSE_UsageStackOverflow;\r
+ \r
+ UsageStack[UsageStackSize++] = ReportItemData;\r
+ break;\r
+ case (TYPE_LOCAL | TAG_LOCAL_USAGEMIN):\r
+ CurrStateTable->Attributes.Usage.MinMax.Minimum = ReportItemData;\r
+ break;\r
+ case (TYPE_LOCAL | TAG_LOCAL_USAGEMAX):\r
+ CurrStateTable->Attributes.Usage.MinMax.Maximum = ReportItemData;\r
+ break;\r
+ case (TYPE_MAIN | TAG_MAIN_COLLECTION):\r
+ if (CurrCollectionPath == NULL)\r
+ {\r
+ CurrCollectionPath = &ParserData->CollectionPaths[0];\r
+ }\r
+ else\r
+ {\r
+ HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath;\r
+ \r
+ CurrCollectionPath = &ParserData->CollectionPaths[1];\r
+\r
+ while (CurrCollectionPath->Parent != NULL);\r
+ {\r
+ if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS])\r
+ return HID_PARSE_InsufficientCollectionPaths;\r
+ \r
+ CurrCollectionPath++;\r
+ }\r
+\r
+ CurrCollectionPath->Parent = ParentCollectionPath;\r
+ }\r
+ \r
+ CurrCollectionPath->Type = ReportItemData;\r
+ CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page;\r
+ \r
+ if (UsageStackSize)\r
+ {\r
+ CurrCollectionPath->Usage.Usage = UsageStack[0];\r
+\r
+ for (uint8_t i = 0; i < UsageStackSize; i++)\r
+ UsageStack[i] = UsageStack[i + 1];\r
+ \r
+ UsageStackSize--;\r
+ }\r
+ else\r
+ {\r
+ CurrCollectionPath->Usage.Usage = 0;\r
+ }\r
+ \r
+ break;\r
+ case (TYPE_MAIN | TAG_MAIN_ENDCOLLECTION):\r
+ if (CurrCollectionPath == NULL)\r
+ return HID_PARSE_UnexpectedEndCollection;\r
+ \r
+ CurrCollectionPath = CurrCollectionPath->Parent;\r
+\r
+ break;\r
+ case (TYPE_MAIN | TAG_MAIN_INPUT):\r
+ case (TYPE_MAIN | TAG_MAIN_OUTPUT):\r
+#if defined(HID_ENABLE_FEATURE_PROCESSING)\r
+ case (TYPE_MAIN | TAG_MAIN_FEATURE):\r
+#endif\r
+ for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++)\r
+ {\r
+ HID_ReportItem_t* CurrReportItem = &ParserData->ReportItems[ParserData->TotalReportItems];\r
+ \r
+ if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)\r
+ return HID_PARSE_InsufficientReportItems;\r
+ \r
+ memcpy(&CurrReportItem->Attributes,\r
+ &CurrStateTable->Attributes,\r
+ sizeof(HID_ReportItem_Attributes_t));\r
+\r
+ CurrReportItem->ItemFlags = ReportItemData;\r
+ CurrReportItem->CollectionPath = CurrCollectionPath;\r
+ CurrReportItem->ReportID = CurrStateTable->ReportID;\r
+\r
+ if (UsageStackSize)\r
+ {\r
+ CurrReportItem->Attributes.Usage.Usage = UsageStack[0];\r
+\r
+ for (uint8_t i = 0; i < UsageStackSize; i++)\r
+ UsageStack[i] = UsageStack[i + 1];\r
+ \r
+ UsageStackSize--;\r
+ }\r
+ else\r
+ {\r
+ CurrReportItem->Attributes.Usage.Usage = 0;\r
+ }\r
+ \r
+ switch (*ReportData & TAG_MASK)\r
+ {\r
+ case TAG_MAIN_INPUT:\r
+ CurrReportItem->ItemType = REPORT_ITEM_TYPE_In;\r
+ CurrReportItem->BitOffset = BitOffsetIn;\r
+ \r
+ BitOffsetIn += CurrStateTable->Attributes.BitSize;\r
+ \r
+ break;\r
+ case TAG_MAIN_OUTPUT:\r
+ CurrReportItem->ItemType = REPORT_ITEM_TYPE_Out;\r
+ CurrReportItem->BitOffset = BitOffsetOut;\r
+ \r
+ BitOffsetOut += CurrStateTable->Attributes.BitSize;\r
+ \r
+ break;\r
+#if defined(HID_ENABLE_FEATURE_PROCESSING)\r
+ case TAG_MAIN_FEATURE:\r
+ CurrReportItem->ItemType = REPORT_ITEM_TYPE_Feature; \r
+ CurrReportItem->BitOffset = BitOffsetFeature;\r
+ \r
+ BitOffsetFeature += CurrStateTable->Attributes.BitSize; \r
+\r
+ break;\r
+#endif\r
+ }\r
+ \r
+#if !defined(HID_INCLUDE_CONSTANT_DATA_ITEMS)\r
+ if (!(ReportItemData & IOF_CONSTANT))\r
+ ParserData->TotalReportItems++;\r
+#else\r
+ ParserData->TotalReportItems++;\r
+#endif\r
+ }\r
+ \r
+ UsageStackSize = 0;\r
+ \r
+ break;\r
+ }\r
+ \r
+ if ((*ReportData & TYPE_MASK) == TYPE_MAIN)\r
+ {\r
+ CurrStateTable->Attributes.Usage.MinMax.Minimum = 0;\r
+ CurrStateTable->Attributes.Usage.MinMax.Maximum = 0;\r
+ UsageStackSize = 0;\r
+ }\r
+ \r
+ switch (*ReportData & DATA_SIZE_MASK)\r
+ {\r
+ case DATA_SIZE_4:\r
+ ReportSize -= 5;\r
+ ReportData += 5;\r
+ break;\r
+ case DATA_SIZE_2:\r
+ ReportSize -= 3;\r
+ ReportData += 3;\r
+ break;\r
+ case DATA_SIZE_1:\r
+ ReportSize -= 2;\r
+ ReportData += 2;\r
+ break;\r
+ case DATA_SIZE_0:\r
+ ReportSize -= 1;\r
+ ReportData += 1;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ return HID_PARSE_Successful;\r
+}\r
+\r
+bool GetReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const ReportItem)\r
+{\r
+ uint16_t DataBitsRem = ReportItem->Attributes.BitSize;\r
+ uint16_t CurrentBit = ReportItem->BitOffset;\r
+ uint32_t BitMask = (1 << 0);\r
+\r
+ ReportItem->Value = 0;\r
+ \r
+ if (ReportItem->ReportID)\r
+ {\r
+ if (ReportItem->ReportID != ReportData[0])\r
+ return false;\r
+\r
+ ReportData++;\r
+ }\r
+\r
+ while (DataBitsRem--)\r
+ {\r
+ if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))\r
+ ReportItem->Value |= BitMask;\r
+ \r
+ CurrentBit++;\r
+ BitMask <<= 1;\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
+void SetReportItemInfo(uint8_t* ReportData, const HID_ReportItem_t* ReportItem)\r
+{\r
+ uint16_t DataBitsRem = ReportItem->Attributes.BitSize;\r
+ uint16_t CurrentBit = ReportItem->BitOffset;\r
+ uint32_t BitMask = (1 << 0);\r
+\r
+ if (ReportItem->ReportID)\r
+ {\r
+ ReportData[0] = ReportItem->ReportID;\r
+ ReportData++;\r
+ }\r
+\r
+ while (DataBitsRem--)\r
+ {\r
+ if (ReportItem->Value & (1 << (CurrentBit % 8)))\r
+ ReportData[CurrentBit / 8] |= BitMask;\r
+\r
+ CurrentBit++;\r
+ BitMask <<= 1;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * USB Human Interface Device (HID) Class report descriptor processing routines. This file allows for the easy\r
+ * parsing of the complex HID report descriptor, which describes the data that the device transmits to the host.\r
+ *\r
+ * The processed report is presented back to the user application as a flat structure containing each report\r
+ * item's IN, OUT and FEATURE (if desired) items along with each item's attributes.\r
+ *\r
+ * This library portion also allows for easy setting and retrieval of data from a HID report, including devices\r
+ * with multiple reports on the one HID interface.\r
+ *\r
+ * By default, FEATURE reports and IN/OUT reports with constant data are ignored in the HID report when processed\r
+ * to save on memory. This can be overridden by defining the HID_ENABLE_FEATURE_PROCESSING or\r
+ * HID_INCLUDE_CONSTANT_DATA_ITEMS tokens in the user project makefile, passing them to the compiler via the -D\r
+ * switch.\r
+ */\r
+\r
+#ifndef __HIDPARSER_H__\r
+#define __HIDPARSER_H__\r
+\r
+ /* Includes: */\r
+ #include <string.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "HIDReportData.h"\r
+\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor checks and defines: */\r
+ #if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum stack depth of the state table. A larger state table\r
+ * allows for more PUSH/POP report items to be nested, but consumes more memory. By default\r
+ * this is set to 3 levels (allowing for two PUSHes to be nested) but this can be overridden by\r
+ * defining HID_STATETABLE_STACK_DEPTH to another value in the user project makefile, passing the\r
+ * define to the compiler using the -D compiler switch.\r
+ */\r
+ #define HID_STATETABLE_STACK_DEPTH 3\r
+ #endif\r
+ \r
+ #if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum stack depth of the usage table. A larger usage table\r
+ * allows for more USAGE items to be indicated sequentially for REPORT COUNT entries of more than\r
+ * one, but requires more stack space. By default this is set to 8 levels (allowing for a report\r
+ * item with a count of 8) but this can be overridden by defining HID_USAGE_STACK_DEPTH to another\r
+ * value in the user project makefile, passing the define to the compiler using the -D compiler\r
+ * switch.\r
+ */\r
+ #define HID_USAGE_STACK_DEPTH 8\r
+ #endif\r
+\r
+ #if !defined(HID_MAX_COLLECTIONS) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum number of COLLECTION items (nested or unnested) that can be\r
+ * processed in the report item descriptor. A large value allows for more COLLECTION items to be\r
+ * processed, but consumes more memory. By default this is set to 5 collections, but this can be\r
+ * overridden by defining HID_MAX_COLLECTIONS to another value in the user project makefile, passing\r
+ * the define to the compiler using the -D compiler switch.\r
+ */\r
+ #define HID_MAX_COLLECTIONS 5\r
+ #endif\r
+ \r
+ #if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum number of report items (IN, OUT or FEATURE if enabled) that can be\r
+ * processed in the report item descriptor. A large value allows for more report items to be\r
+ * processed, but consumes more memory. By default this is set to 30 items, but this can be\r
+ * overridden by defining HID_MAX_REPORTITEMS to another value in the user project makefile, passing\r
+ * the define to the compiler using the -D compiler switch.\r
+ */\r
+ #define HID_MAX_REPORTITEMS 30\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ /** Enum for indicating what type of report item an entry in a HID_ReportInfo_t ReportItem array is */\r
+ enum HID_ReportItemTypes_t\r
+ {\r
+ REPORT_ITEM_TYPE_In = 0, /**< Indicates that the item is an IN report type. */\r
+ REPORT_ITEM_TYPE_Out = 1, /**< Indicates that the item is an OUT report type. */\r
+ REPORT_ITEM_TYPE_Feature = 2, /**< Indicates that the item is a FEATURE report type. */\r
+ };\r
+ \r
+ /** Enum for the possible error codes in the return value of the ProcessHIDReport() function */\r
+ enum HID_Parse_ErrorCodes_t\r
+ {\r
+ HID_PARSE_Successful = 0, /**< Successful parse of the HID report descriptor, no error. */\r
+ HID_PARSE_HIDStackOverflow = 1, /**< More than HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */ \r
+ HID_PARSE_HIDStackUnderflow = 2, /**< A POP was found when the state table stack was empty. */\r
+ HID_PARSE_InsufficientReportItems = 3, /**< More than HID_MAX_REPORTITEMS report items in the report. */\r
+ HID_PARSE_UnexpectedEndCollection = 4, /**< END COLLECTION found without matching COLLECTION item. */\r
+ HID_PARSE_InsufficientCollectionPaths = 5, /**< More than HID_MAX_COLLECTIONS collections in the report. */\r
+ HID_PARSE_UsageStackOverflow = 6, /**< More than HID_USAGE_STACK_DEPTH usages listed in a row. */\r
+ };\r
+ \r
+ /* Type Defines: */ \r
+ /** Type define for an attribute with both minimum and maximum values (e.g. Logical Min/Max). */\r
+ typedef struct\r
+ {\r
+ uint32_t Minimum; /**< Minimum value for the attribute. */\r
+ uint32_t Maximum; /**< Maximum value for the attribute. */\r
+ } HID_MinMax_t;\r
+\r
+ /** Type define for the Unit attributes of a report item. */\r
+ typedef struct\r
+ {\r
+ uint32_t Type; /**< Unit type (refer to HID specifications for details). */\r
+ uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */\r
+ } HID_Unit_t;\r
+ \r
+ /** Type define for the Usage attributes of a report item. */\r
+ typedef struct\r
+ {\r
+ uint16_t Page; /**< Usage page of the report item. */\r
+ uint16_t Usage; /**< Usage of the report item. */\r
+ HID_MinMax_t MinMax; /**< Usage minimum and maximum of the report item. */\r
+ } HID_Usage_t;\r
+\r
+ /** Type define for a COLLECTION object. Contains the collection attributes and a reference to the\r
+ * parent collection if any.\r
+ */\r
+ typedef struct CollectionPath\r
+ {\r
+ uint8_t Type; /**< Collection type (for example "Generic Desktop"). */\r
+ HID_Usage_t Usage; /**< Collection usage. */\r
+ struct CollectionPath* Parent; /**< Reference to parent collection, or NULL if root collection. */\r
+ } HID_CollectionPath_t;\r
+\r
+ /** Type define for all the data attributes of a report item, except flags. */\r
+ typedef struct\r
+ {\r
+ uint8_t BitSize; /**< Size in bits of the report item's data. */\r
+ \r
+ HID_Usage_t Usage; /**< Usage of the report item. */\r
+ HID_Unit_t Unit; /**< Unit type and exponent of the report item. */\r
+ HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */\r
+ HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */\r
+ } HID_ReportItem_Attributes_t;\r
+ \r
+ /** Type define for a report item (IN, OUT or FEATURE) attributes and other details. */\r
+ typedef struct\r
+ {\r
+ uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */\r
+ uint8_t ItemType; /**< Report item type, a value in HID_Types_t. */\r
+ uint16_t ItemFlags; /**< Item data flags, such as constant/variable, etc. */\r
+ uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */\r
+ HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */\r
+\r
+ HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */\r
+ \r
+ uint32_t Value; /**< Current value of the report item. */\r
+ } HID_ReportItem_t;\r
+\r
+ /** Type define for a complete processed HID report, including all report item data and collections. */\r
+ typedef struct\r
+ {\r
+ uint8_t TotalReportItems; /**< Total number of report items stored in the\r
+ * ReportItems array. */\r
+\r
+ HID_ReportItem_t ReportItems[HID_MAX_REPORTITEMS]; /**< Report items array, including\r
+ * all IN, OUT and FEATURE items. */\r
+\r
+ HID_CollectionPath_t CollectionPaths[HID_MAX_COLLECTIONS]; /**< All collection items, referenced\r
+ * by the report items. */\r
+ } HID_ReportInfo_t;\r
+ \r
+ /* Function Prototypes: */\r
+ /** Function to process a given HID report returned from an attached device, and store it into a given\r
+ * HID_ReportInfo_t structure.\r
+ *\r
+ * \param ReportData Buffer containing the device's HID report table\r
+ * \param ReportSize Size in bytes of the HID report table\r
+ * \param ParserData Pointer to a HID_ReportInfo_t instance for the parser output\r
+ *\r
+ * \return A value in the HID_Parse_ErrorCodes_t enum\r
+ */\r
+ uint8_t ProcessHIDReport(const uint8_t* ReportData, uint16_t ReportSize, HID_ReportInfo_t* const ParserData)\r
+ ATTR_NON_NULL_PTR_ARG(1, 3);\r
+\r
+ /** Extracts the given report item's value out of the given HID report and places it into the Value\r
+ * member of the report item's HID_ReportItem_t structure.\r
+ *\r
+ * \param ReportData Buffer containing an IN or FEATURE report from an attached device\r
+ * \param ReportItem Pointer to the report item of interest in a HID_ReportInfo_t ReportItem array\r
+ *\r
+ * \returns Boolean true if the item to retrieve was located in the given report, false otherwise\r
+ */\r
+ bool GetReportItemInfo(const uint8_t* ReportData, HID_ReportItem_t* const ReportItem)\r
+ ATTR_NON_NULL_PTR_ARG(1, 2);\r
+\r
+ /** Retreives the given report item's value out of the Value member of the report item's\r
+ * HID_ReportItem_t structure and places it into the correct position in the HID report\r
+ * buffer. The report buffer is assumed to have the appropriate bits cleared before calling\r
+ * this function (i.e., the buffer should be explicitly cleared before report values are added).\r
+ *\r
+ * If the device has multiple HID reports, the report ID is set to the report ID of the given item.\r
+ *\r
+ * \param ReportData Buffer holding the current OUT report data\r
+ * \param ReportItem Pointer to the report item of interest in a HID_ReportInfo_t ReportItem array\r
+ */\r
+ void SetReportItemInfo(uint8_t* ReportData, const HID_ReportItem_t* ReportItem)\r
+ ATTR_NON_NULL_PTR_ARG(1, 2);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Type Defines: */\r
+ typedef struct\r
+ {\r
+ HID_ReportItem_Attributes_t Attributes;\r
+ uint8_t ReportCount;\r
+ uint8_t ReportID;\r
+ } HID_StateTable_t;\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Constants for HID report item attributes. Refer to the HID specification for details on each\r
+ * flag's meaning when applied to an IN, OUT or FEATURE item.\r
+ */\r
+\r
+#ifndef __HIDREPORTDATA_H__\r
+#define __HIDREPORTDATA_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** HID_ReportItem_t.ItemFlags flag for constant data. */\r
+ #define IOF_CONSTANT (1 << 0)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for data. */\r
+ #define IOF_DATA (0 << 0)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for variable data. */\r
+ #define IOF_VARIABLE (1 << 1)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for array data. */\r
+ #define IOF_ARRAY (0 << 1)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for relative data. */\r
+ #define IOF_RELATIVE (1 << 2)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for absolute data. */\r
+ #define IOF_ABSOLUTE (0 << 2)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for wrapped value data. */\r
+ #define IOF_WRAP (1 << 3)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for non-wrapped value data. */\r
+ #define IOF_NOWRAP (0 << 3)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for non linear data. */\r
+ #define IOF_NONLINEAR (1 << 4)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for linear data. */\r
+ #define IOF_LINEAR (0 << 4)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for no preferred state. */\r
+ #define IOF_NOPREFERRED (1 << 5)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for preferred state items. */\r
+ #define IOF_PREFERREDSTATE (0 << 5)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for null state items. */\r
+ #define IOF_NULLSTATE (1 << 6)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for no null position data. */\r
+ #define IOF_NONULLPOSITION (0 << 6)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for buffered bytes. */\r
+ #define IOF_BUFFEREDBYTES (1 << 8)\r
+\r
+ /** HID_ReportItem_t.ItemFlags flag for bitfield data. */\r
+ #define IOF_BITFIELD (0 << 8)\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATA_SIZE_MASK 0b00000011\r
+ #define TYPE_MASK 0b00001100\r
+ #define TAG_MASK 0b11110000\r
+\r
+ #define DATA_SIZE_0 0b00000000\r
+ #define DATA_SIZE_1 0b00000001\r
+ #define DATA_SIZE_2 0b00000010\r
+ #define DATA_SIZE_4 0b00000011\r
+ \r
+ #define TYPE_MAIN 0b00000000\r
+ #define TYPE_GLOBAL 0b00000100\r
+ #define TYPE_LOCAL 0b00001000\r
+ \r
+ #define TAG_MAIN_INPUT 0b10000000\r
+ #define TAG_MAIN_OUTPUT 0b10010000\r
+ #define TAG_MAIN_COLLECTION 0b10100000\r
+ #define TAG_MAIN_FEATURE 0b10110000\r
+ #define TAG_MAIN_ENDCOLLECTION 0b11000000\r
+ #define TAG_GLOBAL_USAGEPAGE 0b00000000\r
+ #define TAG_GLOBAL_LOGICALMIN 0b00010000\r
+ #define TAG_GLOBAL_LOGICALMAX 0b00100000\r
+ #define TAG_GLOBAL_PHYSMIN 0b00110000\r
+ #define TAG_GLOBAL_PHYSMAX 0b01000000\r
+ #define TAG_GLOBAL_UNITEXP 0b01010000\r
+ #define TAG_GLOBAL_UNIT 0b01100000\r
+ #define TAG_GLOBAL_REPORTSIZE 0b01110000\r
+ #define TAG_GLOBAL_REPORTID 0b10000000\r
+ #define TAG_GLOBAL_REPORTCOUNT 0b10010000\r
+ #define TAG_GLOBAL_PUSH 0b10100000\r
+ #define TAG_GLOBAL_POP 0b10110000\r
+ #define TAG_LOCAL_USAGE 0b00000000\r
+ #define TAG_LOCAL_USAGEMIN 0b00010000\r
+ #define TAG_LOCAL_USAGEMAX 0b00100000\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../LowLevel/USBMode.h"\r
+\r
+#define INCLUDE_FROM_EVENTS_C\r
+#include "Events.h"\r
+\r
+void USB_Event_Stub(void)\r
+{\r
+\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** Library events module. This module contains macros and functions relating to the management of library\r
+ * events, which are small pieces of code similar to ISRs which are run when a given condition is met. Each\r
+ * event can be fired from multiple places in the user or library code, which may or may not be inside an ISR,\r
+ * thus each handler should be written to be as small and fast as possible to prevent possible problems.\r
+ *\r
+ * Events can be hooked by the user application using the EVENT_HANDLER() and HANDLES_EVENT() macros. If an\r
+ * event with no associated handler is fired within the library, it by default fires an internal empty stub\r
+ * function. This is achieved through the use of the GCC compiler's "alias" attribute.\r
+ *\r
+ * Each event must only have one associated event handler, but can be raised by multiple sources.\r
+ */\r
+ \r
+#ifndef __USBEVENTS_H__\r
+#define __USBEVENTS_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ \r
+ #include "../../../Common/Common.h"\r
+ #include "../LowLevel/USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Raises a given event name, with the specified parameters. For events with no parameters the\r
+ * only argument to the macro is the event name, events with parameters list the parameter values\r
+ * after the name as a comma seperated list.\r
+ *\r
+ * When a given event is fired, its corresponding event handler code is executed.\r
+ *\r
+ * Usage Examples:\r
+ * \code\r
+ * // Raise the USB_VBUSChange event, which takes no parameters\r
+ * RAISE_EVENT(USB_VBUSChange);\r
+ *\r
+ * // Raise the USB_UnhandledControlPacket event which takes two parameters\r
+ * RAISE_EVENT(USB_UnhandledControlPacket, 0, 1);\r
+ * \endcode\r
+ *\r
+ * \see RAISES_EVENT()\r
+ */\r
+ #define RAISE_EVENT(e, ...) Event_ ## e (__VA_ARGS__)\r
+\r
+ /** Indicates that a given module can raise a given event. This is the equivelent of putting the\r
+ * event function's prototype into the module, but in a cleaner way. Each event which may be\r
+ * fired via the RAISE_EVENT macro in the module should have an accompanying RAISES_EVENT\r
+ * prototype in the module's header file.\r
+ *\r
+ * Usage Examples:\r
+ * \code\r
+ * // Module can raise the USB_VBUSChange event\r
+ * RAISES_EVENT(USB_VBUSChange);\r
+ *\r
+ * // ...\r
+ * // Inside a block of code in a function of the module, raise the USB_VBUSChange event\r
+ * RAISE_EVENT(USB_VBUSChange);\r
+ * \endcode\r
+ *\r
+ * \see RAISE_EVENT()\r
+ */\r
+ #define RAISES_EVENT(e) HANDLES_EVENT(e)\r
+\r
+ /** Defines an event handler for the given event. Event handlers should be short in length, as they\r
+ * may be raised from inside an ISR. The user application can react to each event as it sees fit,\r
+ * such as logging the event, indicating the change to the user or performing some other action.\r
+ *\r
+ * Only one event handler may be defined in any user project for each individual event. Events may\r
+ * or may not have parameters - for each event, refer to its documentation elsewhere in this module\r
+ * to determine the presense and purpose of any event parameters.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * // Create an event handler for the USB_VBUSChange event\r
+ * EVENT_HANDLER(USB_VBUSChange)\r
+ * {\r
+ * // Code to execute when the VBUS level changes\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \see HANDLES_EVENT()\r
+ */\r
+ #define EVENT_HANDLER(e) void Event_ ## e e ## _P\r
+ \r
+ /** Indicates that a given module handles an event. This is the equivelent of putting the\r
+ * event function's prototype into the module, but in a cleaner way. Each event which may be\r
+ * handled via the EVENT_HANDLER macro in the module should have an accompanying HANDLES_EVENT\r
+ * prototype in the module's header file.\r
+ *\r
+ * Usage Examples:\r
+ * \code\r
+ * // Module handles the USB_VBUSChange event\r
+ * HANDLES_EVENT(USB_VBUSChange);\r
+ *\r
+ * // Create the USB_VBUSChange event handler\r
+ * EVENT_HANDLER(USB_VBUSChange)\r
+ * {\r
+ * // Event handler code here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \see EVENT_HANDLER()\r
+ */\r
+ #define HANDLES_EVENT(e) EVENT_HANDLER(e)\r
+ \r
+ /* Psudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Event for VBUS level change. This event fires when the VBUS line of the USB AVR changes from\r
+ * high to low or vice-versa.\r
+ *\r
+ * \note This event is only available on USB AVR models which support VBUS notification interrupts.\r
+ */\r
+ void USB_VBUSChange(void);\r
+\r
+ /** Event for VBUS attachment. This event fires when the VBUS line of the USB AVR changes from\r
+ * low to high, signalling the attachment of the USB device to a host, before the enumeration\r
+ * process has begun.\r
+ *\r
+ * \note This event is only available on USB AVR models which support VBUS notification interrupts.\r
+ */\r
+ void USB_VBUSConnect(void);\r
+\r
+ /** Event for VBUS detachment. This event fires when the VBUS line of the USB AVR changes from\r
+ * high to low, signalling the USB device has been removed from a host whether it has been enumerated\r
+ * or not.\r
+ *\r
+ * \note This event is only available on USB AVR models which support VBUS notification interrupts.\r
+ */\r
+ void USB_VBUSDisconnect(void);\r
+\r
+ /** Event for USB device connection. This event fires when the AVR is in USB host mode and a device\r
+ * has been attached (but not yet fully enumerated), or when in device mode and the device is connected\r
+ * to a host, beginning the enumeration process.\r
+ *\r
+ * When in device mode, this can be used to progmatically start the USB management task to reduce\r
+ * CPU usage.\r
+ *\r
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by\r
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually.\r
+ *\r
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void USB_Connect(void);\r
+\r
+ /** Event for USB device disconnection. This event fires when the AVR is in USB host mode and an\r
+ * attached and enumerated device has been disconnected, or when in device mode and the device is\r
+ * disconnected from the host.\r
+ *\r
+ * When in device mode, this can be used to progmatically stop the USB management task to reduce\r
+ * CPU usage.\r
+ *\r
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by\r
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually.\r
+ *\r
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void USB_Disconnect(void);\r
+ \r
+ /** Event for USB device power on failure. This event fires when the USB interface fails to\r
+ * initialize correctly due to a hardware or software fault.\r
+ *\r
+ * \param ErrorCode Error code indicating the failure reason, a value in USB_PowerOnErrorCodes_t\r
+ * located in LowLevel.h.\r
+ */\r
+ void USB_PowerOnFail(const uint8_t ErrorCode);\r
+\r
+ /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role\r
+ * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires\r
+ * before the mode is switched to the newly indicated mode.\r
+ *\r
+ * \note This event only exists on USB AVR models which support dual role modes.\r
+ *\r
+ * \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied\r
+ * to the compiler (see LowLevel.h documentation).\r
+ */\r
+ void USB_UIDChange(void);\r
+\r
+ /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB\r
+ * interface is in host mode.\r
+ *\r
+ * \param ErrorCode Error code indicating the failure reason, a value in USB_Host_ErrorCodes_t\r
+ * located in Host.h.\r
+ *\r
+ * \note This event only exists on USB AVR models which supports host mode.\r
+ *\r
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ */\r
+ void USB_HostError(const uint8_t ErrorCode);\r
+ \r
+ /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and\r
+ * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before\r
+ * the standard USB_DeviceConnect event and so can be used to programatically start the USB management\r
+ * task to reduce CPU consumption.\r
+ *\r
+ * \note This event only exists on USB AVR models which supports host mode.\r
+ *\r
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ *\r
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void USB_DeviceAttached(void);\r
+\r
+ /** Event for USB device removal. This event fires when a the USB interface is in host mode, and\r
+ * a USB device has been removed the USB interface whether or not it has been enumerated. This\r
+ * can be used to programatically stop the USB management task to reduce CPU consumption.\r
+ *\r
+ * \note This event only exists on USB AVR models which supports host mode.\r
+ *\r
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ *\r
+ * \see USBTask.h for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void USB_DeviceUnattached(void);\r
+ \r
+ /** Event for USB device enumeration failure. This event fires when a the USB interface is\r
+ * in host mode, and an attached USB device has failed to enumerate completely.\r
+ *\r
+ * \param ErrorCode Error code indicating the failure reason, a value in \r
+ * USB_Host_EnumerationErrorCodes_t located in Host.h.\r
+ *\r
+ * \param SubErrorCode Sub error code indicating the reason for failure - for example, if the\r
+ * ErrorCode parameter indicates a control error, this will give the error\r
+ * code returned by the USB_Host_SendControlRequest() function.\r
+ *\r
+ * \note This event only exists on USB AVR models which supports host mode.\r
+ *\r
+ * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ */\r
+ void USB_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode);\r
+\r
+ /** Event for USB device enumeration completion. This event fires when a the USB interface is\r
+ * in host mode and an attached USB device has been completely enumerated and is ready to be\r
+ * controlled by the user application, or when the library is in device mode, and the Host\r
+ * has finished enumerating the device.\r
+ */\r
+ void USB_DeviceEnumerationComplete(void);\r
+\r
+ /** Event for unhandled control requests. This event fires when a the USB host issues a control\r
+ * request to the control endpoint (address 0) that the library does not handle. This may either\r
+ * be a standard request that the library has no handler code for, or a class specific request\r
+ * issued to the device which must be handled appropriately. Due to the strict timing requirements\r
+ * on control transfers, interrupts are disabled during control request processing.\r
+ *\r
+ * \param bRequest Request value, indicating what command the host has issued.\r
+ * \param bmRequestType Mask indicating the request data direction (if any), type and recipient.\r
+ *\r
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ *\r
+ * \note Requests should be handled in the same manner as described in the USB 2.0 Specification,\r
+ * or appropriate class' specification. In all instances, the library has already read the\r
+ * request bmRequestType and bRequest values out (into the Request and RequestType parameters\r
+ * respectively) so that it can correctly determine if it is able to handle the request\r
+ * internally, or hand off the request to the user application via this event. Other request\r
+ * parameters (wValue, wIndex, wLength, and Data) remain in the control endpoint bank until\r
+ * read out by the user application for processing.\r
+ */\r
+ void USB_UnhandledControlPacket(const uint8_t bRequest, const uint8_t bmRequestType);\r
+\r
+ /** Event for USB configuration number changed. This event fires when a the USB host changes the\r
+ * selected configuration number while in device mode. This event should be hooked in device\r
+ * applications to create the endpoints and configure the device for the selected configuration.\r
+ *\r
+ * This event fires after the value of USB_ConfigurationNumber has been changed.\r
+ *\r
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ */\r
+ void USB_ConfigurationChanged(void);\r
+\r
+ /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its\r
+ * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move\r
+ * the device over to a low power state until the host wakes up the device.\r
+ *\r
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ *\r
+ * \see USB_WakeUp() event for accompanying Wake Up event.\r
+ */\r
+ void USB_Suspend(void);\r
+\r
+ /** Event for USB wake up. This event fires when a the USB interface is suspended while in device\r
+ * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally\r
+ * hooked to pull the user application out of a lowe power state and back into normal operating\r
+ * mode.\r
+ *\r
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ *\r
+ * \see USB_Suspend() event for accompanying Suspend event.\r
+ */\r
+ void USB_WakeUp(void);\r
+\r
+ /** Event for USB interface reset. This event fires when a the USB interface is in device mode, and\r
+ * a the USB host requests that the device reset its interface. This is generally hooked so that\r
+ * the USB control endpoint can be switched to interrupt driven mode, by selecting it and calling\r
+ * USB_INT_Enable(ENDPOINT_INT_SETUP). Before this event fires, all device endpoints are reset and\r
+ * disabled.\r
+ *\r
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ */\r
+ void USB_Reset(void);\r
+ \r
+ /** Event for USB device mode error. This event fires when the USB interface is in device mode,\r
+ * and an error occurs which prevents it from operating normally.\r
+ *\r
+ * \param ErrorCode Error code indicating the source of the error. One of the values in the\r
+ * USB_Device_ErrorCodes_t enum located in Device.h.\r
+ *\r
+ * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see\r
+ * LowLevel.h documentation).\r
+ */\r
+ void USB_DeviceError(const uint8_t ErrorCode);\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define ALIAS_STUB(e) EVENT_HANDLER(e) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub)\r
+ \r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ #define USB_VBUSChange_P (void)\r
+ #define USB_VBUSConnect_P (void)\r
+ #define USB_VBUSDisconnect_P (void)\r
+ #endif\r
+ \r
+ #define USB_Connect_P (void)\r
+ #define USB_Disconnect_P (void)\r
+ #define USB_DeviceEnumerationComplete_P (void)\r
+ \r
+ #if defined(USB_CAN_BE_BOTH)\r
+ #define USB_PowerOnFail_P (const uint8_t ErrorCode)\r
+ #define USB_UIDChange_P (void)\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #define USB_HostError_P (const uint8_t ErrorCode)\r
+ #define USB_DeviceAttached_P (void)\r
+ #define USB_DeviceUnattached_P (void)\r
+ #define USB_DeviceEnumerationFailed_P (const uint8_t ErrorCode, const uint8_t SubErrorCode)\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #define USB_UnhandledControlPacket_P (const uint8_t bRequest, const uint8_t bmRequestType)\r
+ #define USB_ConfigurationChanged_P (void)\r
+ #define USB_Suspend_P (void)\r
+ #define USB_WakeUp_P (void)\r
+ #define USB_Reset_P (void)\r
+ #define USB_DeviceError_P (const uint8_t ErrorCode)\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ #if defined(INCLUDE_FROM_EVENTS_C)\r
+ void USB_Event_Stub (void) ATTR_CONST;\r
+\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ ALIAS_STUB(USB_VBUSChange);\r
+ ALIAS_STUB(USB_VBUSConnect);\r
+ ALIAS_STUB(USB_VBUSDisconnect);\r
+ #endif\r
+ \r
+ ALIAS_STUB(USB_Connect);\r
+ ALIAS_STUB(USB_Disconnect);\r
+ ALIAS_STUB(USB_DeviceEnumerationComplete);\r
+ \r
+ #if defined(USB_CAN_BE_BOTH)\r
+ ALIAS_STUB(USB_PowerOnFail);\r
+ ALIAS_STUB(USB_UIDChange);\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_HOST)\r
+ ALIAS_STUB(USB_HostError);\r
+ ALIAS_STUB(USB_DeviceAttached);\r
+ ALIAS_STUB(USB_DeviceUnattached);\r
+ ALIAS_STUB(USB_DeviceEnumerationFailed);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ ALIAS_STUB(USB_UnhandledControlPacket);\r
+ ALIAS_STUB(USB_ConfigurationChanged);\r
+ ALIAS_STUB(USB_Suspend);\r
+ ALIAS_STUB(USB_WakeUp);\r
+ ALIAS_STUB(USB_Reset);\r
+ ALIAS_STUB(USB_DeviceError);\r
+ #endif\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../LowLevel/USBMode.h"\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "StdDescriptors.h"\r
+\r
+uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
+{\r
+ RAISE_EVENT(USB_DeviceError, DEVICE_ERROR_GetDescriptorNotHooked);\r
+\r
+ return 0;\r
+};\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains\r
+ * strucutures and macros for the easy creation of standard USB descriptors in USB device projects.\r
+ *\r
+ * All standard descriptors have their elements named in an identical manner to the official USB specification,\r
+ * however slightly more verbose alternate (non-standard) names are also supplied if the macro\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES is defined in the user project makefile and passed to the compiler at\r
+ * compilation time using the -D option.\r
+ *\r
+ * The non-standard names are documented here - if USE_NONSTANDARD_DESCRIPTOR_NAMES is not defined, then all\r
+ * descriptors will contain elements named identically to the official USB specification. The alternately\r
+ * named descriptor elements are placed in the same order inside the descriptor structures as their officially\r
+ * named counterparts, thus they can be correlated easily with the official USB specification.\r
+ */\r
+\r
+#ifndef __USBDESCRIPTORS_H__\r
+#define __USBDESCRIPTORS_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/pgmspace.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+ #include "../LowLevel/USBMode.h"\r
+ #include "Events.h"\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "../LowLevel/Device.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors\r
+ * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified\r
+ * descriptor does not exist.\r
+ */\r
+ #define NO_DESCRIPTOR 0\r
+ \r
+ /** Macro to calculate the power value for the device descriptor, from a given number of milliamps. */\r
+ #define USB_CONFIG_POWER_MA(x) (x >> 1)\r
+\r
+ /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.\r
+ * Should be used in string descriptor's headers for giving the string descriptor's byte length.\r
+ */\r
+ #define USB_STRING_LEN(x) (sizeof(USB_Descriptor_Header_t) + (x << 1))\r
+ \r
+ /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded\r
+ * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the\r
+ * standard device descriptor.\r
+ */\r
+ #define VERSION_BCD(x) ((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \\r
+ ((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))\r
+\r
+ /** String language ID for the English language. Should be used in USB_Descriptor_Language_t descriptors\r
+ * to indicate that the English language is supported by the device in its string descriptors.\r
+ */\r
+ #define LANGUAGE_ID_ENG 0x0409\r
+\r
+ /** Can be masked with an endpoint address for a USB_Descriptor_Endpoint_t endpoint descriptor's\r
+ * EndpointAddress value to indicate to the host that the endpoint is of the IN direction (i.e, from\r
+ * device to host).\r
+ */\r
+ #define ENDPOINT_DESCRIPTOR_DIR_IN 0x80\r
+\r
+ /** Can be masked with an endpoint address for a USB_Descriptor_Endpoint_t endpoint descriptor's\r
+ * EndpointAddress value to indicate to the host that the endpoint is of the OUT direction (i.e, from\r
+ * host to device).\r
+ */\r
+ #define ENDPOINT_DESCRIPTOR_DIR_OUT 0x00 \r
+\r
+ /** Can be masked with other configuration descriptor attributes for a USB_Descriptor_Configuration_Header_t\r
+ * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power\r
+ * from the host's VBUS line.\r
+ */\r
+ #define USB_CONFIG_ATTR_BUSPOWERED 0b10000000\r
+\r
+ /** Can be masked with other configuration descriptor attributes for a USB_Descriptor_Configuration_Header_t\r
+ * descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power\r
+ * from the device's own power source.\r
+ */\r
+ #define USB_CONFIG_ATTR_SELFPOWERED 0b11000000\r
+\r
+ /** Can be masked with other configuration descriptor attributes for a USB_Descriptor_Configuration_Header_t\r
+ * descriptor's ConfigAttributes value to indicate that the specified configuration supports the\r
+ * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon\r
+ * request.\r
+ */\r
+ #define USB_CONFIG_ATTR_REMOTEWAKEUP 0b10100000\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is not synchronized.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_NO_SYNC (0b00 << 2)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is asynchronous.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_ASYNC (0b01 << 2)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is adaptive.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_ADAPTIVE (0b10 << 2)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is synchronized.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_SYNC (0b11 << 2)\r
+ \r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is used for data transfers.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint usage attributes.\r
+ */\r
+ #define ENDPOINT_USAGE_DATA (0b00 << 4)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is used for feedback.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint usage attributes.\r
+ */\r
+ #define ENDPOINT_USAGE_FEEDBACK (0b01 << 4)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a USB_Descriptor_Endpoint_t descriptor's\r
+ * Attributes value to indicate that the specified endpoint is used for implicit feedback.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint usage attributes.\r
+ */\r
+ #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (0b10 << 4)\r
+\r
+ /** Gives a void pointer to the specified descriptor (of any type). */\r
+ #define DESCRIPTOR_ADDRESS(Descriptor) ((void*)&Descriptor)\r
+\r
+ /* Events: */\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ /** This module raises the Device Error event while in device mode, if the USB_GetDescriptor()\r
+ * routine is not hooked in the user application to properly return descriptors to the library.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceError);\r
+ #endif\r
+ \r
+ /* Enums: */\r
+ /** Enum for the possible standard descriptor types, as given in each descriptor's header. */\r
+ enum USB_DescriptorTypes_t\r
+ {\r
+ DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */\r
+ DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */\r
+ DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */\r
+ DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */\r
+ DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */\r
+ DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */\r
+ DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */\r
+ DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */\r
+ DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** Type define for all descriptor's header, indicating the descriptor's length and type.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ uint8_t Size; /**< Size of the descriptor, in bytes. */\r
+ uint8_t Type; /**< Type of the descriptor, either a value in DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ #endif\r
+ } USB_Descriptor_Header_t;\r
+ \r
+ /** Type define for a standard device descriptor.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint16_t USBSpecification; /**< BCD of the supported USB specification. */\r
+ uint8_t Class; /**< USB device class. */\r
+ uint8_t SubClass; /**< USB device subclass. */\r
+ uint8_t Protocol; /**< USB device protocol. */\r
+ \r
+ uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */\r
+ \r
+ uint16_t VendorID; /**< Vendor ID for the USB product. */\r
+ uint16_t ProductID; /**< Unique product ID for the USB product. */\r
+ uint16_t ReleaseNumber; /**< Product release (version) number. */\r
+ \r
+ uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The\r
+ * host will request this string via a seperate\r
+ * control request for the string descriptor.\r
+ *\r
+ * \note If no string supplied, use NO_DESCRIPTOR.\r
+ */\r
+ uint8_t ProductStrIndex; /**< String index for the product name/details.\r
+ *\r
+ * \see ManufacturerStrIndex structure entry.\r
+ */\r
+ uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal\r
+ * serial number, in uppercase Unicoded ASCII.\r
+ *\r
+ * \see ManufacturerStrIndex structure entry.\r
+ */\r
+\r
+ uint8_t NumberOfConfigurations; /**< Total number of configurations supported by\r
+ * the device.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ uint16_t bcdUSB;\r
+ uint8_t bDeviceClass;\r
+ uint8_t bDeviceSubClass;\r
+ uint8_t bDeviceProtocol;\r
+ uint8_t bMaxPacketSize0;\r
+ uint16_t idVendor;\r
+ uint16_t idProduct;\r
+ uint16_t bcdDevice;\r
+ uint8_t iManufacturer;\r
+ uint8_t iProduct;\r
+ uint8_t iSerialNumber;\r
+ uint8_t bNumConfigurations;\r
+ #endif\r
+ } USB_Descriptor_Device_t;\r
+\r
+ /** Type define for a standard configuration descriptor.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+ \r
+ uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,\r
+ * and all sub descriptors inside the configuration.\r
+ */\r
+ uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */\r
+\r
+ uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */\r
+ uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */\r
+ \r
+ uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of zero or\r
+ * more USB_CONFIG_ATTR_* masks.\r
+ */\r
+ \r
+ uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the\r
+ * current configuration, calculated by the USB_CONFIG_POWER_MA()\r
+ * macro.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ uint16_t wTotalLength;\r
+ uint8_t bNumInterfaces;\r
+ uint8_t bConfigurationValue;\r
+ uint8_t iConfiguration;\r
+ uint8_t bmAttributes;\r
+ uint8_t bMaxPower;\r
+ #endif\r
+ } USB_Descriptor_Configuration_Header_t;\r
+\r
+ /** Type define for a standard interface descriptor.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */\r
+ uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same\r
+ * interface number can have multiple alternate settings\r
+ * with different endpoint configurations, which can be\r
+ * selected by the host.\r
+ */\r
+ uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */\r
+ \r
+ uint8_t Class; /**< Interface class ID. */\r
+ uint8_t SubClass; /**< Interface subclass ID. */\r
+ uint8_t Protocol; /**< Interface protocol ID. */\r
+\r
+ uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the\r
+ * interface.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ uint8_t bInterfaceNumber;\r
+ uint8_t bAlternateSetting;\r
+ uint8_t bNumEndpoints;\r
+ uint8_t bInterfaceClass;\r
+ uint8_t bInterfaceSubClass;\r
+ uint8_t bInterfaceProtocol;\r
+ uint8_t iInterface;\r
+ #endif\r
+ } USB_Descriptor_Interface_t;\r
+\r
+ /** Type define for a standard interface association descriptor.\r
+ *\r
+ * This descriptor has been added as a suppliment to the USB2.0 standard, in the ECN located at\r
+ * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound\r
+ * devices with multiple interfaces related to the same function to have the multiple interfaces bound\r
+ * together at the point of enumeration, loading one generic driver for all the interfaces in the single\r
+ * function. Read the ECN for more information.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+ \r
+ uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */\r
+ uint8_t TotalInterfaces; /** Total number of associated interfaces. */\r
+\r
+ uint8_t Class; /**< Interface class ID. */\r
+ uint8_t SubClass; /**< Interface subclass ID. */\r
+ uint8_t Protocol; /**< Interface protocol ID. */\r
+\r
+ uint8_t IADStrIndex; /**< Index of the string descriptor describing the\r
+ * interface association.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ uint8_t bFirstInterface;\r
+ uint8_t bInterfaceCount;\r
+ uint8_t bFunctionClass;\r
+ uint8_t bFunctionSubClass;\r
+ uint8_t bFunctionProtocol;\r
+ uint8_t iFunction;\r
+ #endif\r
+ } USB_Descriptor_Interface_Association_t;\r
+\r
+ /** Type define for a standard endpoint descriptor.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint8_t EndpointAddress; /**< Logical address of the endpoint within the device\r
+ * for the current configuration, including direction\r
+ * mask.\r
+ */\r
+ uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the\r
+ * endpoint type (EP_TYPE_*) and attributes (ENDPOINT_ATTR_*)\r
+ * masks.\r
+ */\r
+ uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the\r
+ * maximum packet size that the endpoint can receive at a time.\r
+ */\r
+ \r
+ uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpont\r
+ * if it is an INTERRUPT or ISOCHRONOUS type.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ uint8_t bEndpointAddress;\r
+ uint8_t bmAttributes;\r
+ uint16_t wMaxPacketSize;\r
+ uint8_t bInterval;\r
+ #endif\r
+ } USB_Descriptor_Endpoint_t;\r
+\r
+ /** Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
+ * of the descriptor for placement in the descriptor header must be determined by the USB_STRING_LEN()\r
+ * macro rather than by the size of the descriptor structure, as the length is not fixed.\r
+ *\r
+ * This structure should also be used for string index 0, which contains the supported language IDs for\r
+ * the device as an array.\r
+ *\r
+ * \note The non-standard structure element names are documented here - see the StdDescriptors.h file\r
+ * documentation for more information on the two descriptor naming schemes. If the\r
+ * USE_NONSTANDARD_DESCRIPTOR_NAMES token is not set, this structure contains elements with names\r
+ * identical to those listed in the USB standard.\r
+ */\r
+ typedef struct\r
+ {\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES) || defined(__DOXYGEN__)\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+ \r
+ int16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,\r
+ * string language IDs). If normal ASCII characters are\r
+ * to be used, they must be added as an array of characters\r
+ * rather than a normal C string so that they are widened to\r
+ * Unicode size.\r
+ *\r
+ * Under GCC, strings prefixed with the "L" character (before\r
+ * the opening string quotation mark) are considered to be\r
+ * Unicode strings, and may be used instead of an explicit\r
+ * array of ASCII characters.\r
+ */\r
+ #else\r
+ uint8_t bLength;\r
+ uint8_t bDescriptorType;\r
+ int16_t bString[];\r
+ #endif\r
+ } USB_Descriptor_String_t;\r
+ \r
+ typedef struct\r
+ {\r
+ uint16_t Size;\r
+ void* Address;\r
+ } USB_Descriptor_Details_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,\r
+ * index and language ID. This function MUST be overridden in the user application (added with full, identical \r
+ * prototype and name except for the ATTR_WEAK attribute) so that the library can call it to retrieve descriptor \r
+ * data.\r
+ *\r
+ * \param wValue The type of the descriptor to retrieve in the upper byte, and the index in the \r
+ * lower byte (when more than one descriptor of the given type exists, such as the\r
+ * case of string descriptors). The type may be one of the standard types defined\r
+ * in the DescriptorTypes_t enum, or may be a class-specific descriptor type value.\r
+ * \param wIndex The language ID of the string to return if the wValue type indicates DTYPE_String,\r
+ * otherwise zero for standard descriptors, or as defined in a class-specific\r
+ * standards.\r
+ * \param DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to\r
+ * the location of the descriptor, found by the DESCRIPTOR_ADDRESS macro.\r
+ *\r
+ * \note By default, the library expects all descriptors to be located in flash memory via the PROGMEM attribute.\r
+ * If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to\r
+ * allow the descriptors to be changed dynamically at runtime) either the USE_SRAM_DESCRIPTORS or the \r
+ * USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D\r
+ * switch.\r
+ *\r
+ * \return Size in bytes of the descriptor if it exists, zero or NO_DESCRIPTOR otherwise\r
+ */\r
+ uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_WEAK ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define VERSION_TENS(x) (int)(x / 10)\r
+ #define VERSION_ONES(x) (int)(x - (10 * VERSION_TENS(x)))\r
+ #define VERSION_TENTHS(x) (int)((x - (int)x) * 10)\r
+ #define VERSION_HUNDREDTHS(x) (int)(((x - (int)x) * 100) - (10 * VERSION_TENTHS(x)))\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../LowLevel/USBMode.h"\r
+#include "USBInterrupt.h"\r
+\r
+void USB_INT_DisableAllInterrupts(void)\r
+{\r
+ #if defined(USB_FULL_CONTROLLER)\r
+ USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); \r
+ #elif defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ USBCON &= ~(1 << VBUSTE); \r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHIEN = 0;\r
+ OTGIEN = 0;\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ UDIEN = 0;\r
+ #endif\r
+}\r
+\r
+void USB_INT_ClearAllInterrupts(void)\r
+{\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ USBINT = 0;\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHINT = 0;\r
+ OTGINT = 0;\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ UDINT = 0;\r
+ #endif\r
+}\r
+\r
+ISR(USB_GEN_vect, ISR_BLOCK)\r
+{\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBUS);\r
+\r
+ RAISE_EVENT(USB_VBUSChange);\r
+\r
+ if (USB_VBUS_GetStatus())\r
+ {\r
+ RAISE_EVENT(USB_VBUSConnect);\r
+ \r
+ if (USB_IsConnected)\r
+ RAISE_EVENT(USB_Disconnect);\r
+ \r
+ USB_ResetInterface();\r
+ \r
+ USB_IsConnected = true;\r
+\r
+ RAISE_EVENT(USB_Connect);\r
+ }\r
+ else\r
+ {\r
+ RAISE_EVENT(USB_Disconnect);\r
+ \r
+ USB_Detach();\r
+ USB_CLK_Freeze();\r
+ USB_PLL_Off();\r
+ USB_REG_Off();\r
+\r
+ USB_IsConnected = false;\r
+\r
+ RAISE_EVENT(USB_VBUSDisconnect);\r
+ \r
+ USB_INT_Clear(USB_INT_VBUS);\r
+ }\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_SUSPEND) && USB_INT_IsEnabled(USB_INT_SUSPEND))\r
+ {\r
+ USB_INT_Clear(USB_INT_SUSPEND);\r
+\r
+ USB_INT_Disable(USB_INT_SUSPEND);\r
+ USB_INT_Enable(USB_INT_WAKEUP);\r
+ \r
+ USB_CLK_Freeze();\r
+ \r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ USB_PLL_Off();\r
+\r
+ USB_IsSuspended = true;\r
+\r
+ RAISE_EVENT(USB_Suspend);\r
+\r
+ #if defined(USB_LIMITED_CONTROLLER) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ if (USB_IsConnected)\r
+ {\r
+ USB_IsConnected = false;\r
+ RAISE_EVENT(USB_Disconnect);\r
+ }\r
+ #endif\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_WAKEUP) && USB_INT_IsEnabled(USB_INT_WAKEUP))\r
+ {\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ }\r
+\r
+ USB_CLK_Unfreeze();\r
+\r
+ USB_INT_Clear(USB_INT_WAKEUP);\r
+\r
+ USB_INT_Disable(USB_INT_WAKEUP);\r
+ USB_INT_Enable(USB_INT_SUSPEND);\r
+ \r
+ #if defined(USB_LIMITED_CONTROLLER) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ if (!(USB_IsConnected))\r
+ {\r
+ USB_IsConnected = true;\r
+ RAISE_EVENT(USB_Connect);\r
+ }\r
+ #endif\r
+\r
+ USB_IsSuspended = false;\r
+\r
+ RAISE_EVENT(USB_WakeUp);\r
+ }\r
+ \r
+ if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_EORSTI);\r
+\r
+ USB_ConfigurationNumber = 0;\r
+\r
+ USB_INT_Clear(USB_INT_SUSPEND);\r
+ USB_INT_Disable(USB_INT_SUSPEND);\r
+ USB_INT_Enable(USB_INT_WAKEUP);\r
+\r
+ Endpoint_ClearEndpoints();\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ ENDPOINT_DIR_OUT, USB_ControlEndpointSize,\r
+ ENDPOINT_BANK_SINGLE);\r
+\r
+ RAISE_EVENT(USB_Reset);\r
+ }\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_HOST)\r
+ if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Disable(USB_INT_DDISCI);\r
+ \r
+ RAISE_EVENT(USB_DeviceUnattached);\r
+ RAISE_EVENT(USB_Disconnect);\r
+\r
+ USB_ResetInterface();\r
+ }\r
+ \r
+ if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBERRI);\r
+\r
+ USB_Host_VBUS_Manual_Off();\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ RAISE_EVENT(USB_HostError, HOST_ERROR_VBusVoltageDip);\r
+ RAISE_EVENT(USB_DeviceUnattached);\r
+\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SRPI);\r
+ USB_INT_Disable(USB_INT_SRPI);\r
+ \r
+ RAISE_EVENT(USB_DeviceAttached);\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+ \r
+ USB_HostState = HOST_STATE_Attached;\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))\r
+ {\r
+ USB_INT_Clear(USB_INT_BCERRI);\r
+ \r
+ RAISE_EVENT(USB_DeviceEnumerationFailed, HOST_ENUMERROR_NoDeviceDetected, 0);\r
+ RAISE_EVENT(USB_DeviceUnattached);\r
+ \r
+ if (USB_IsConnected)\r
+ RAISE_EVENT(USB_Disconnect);\r
+\r
+ USB_ResetInterface();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))\r
+ { \r
+ USB_INT_Clear(USB_INT_IDTI);\r
+\r
+ if (USB_IsConnected)\r
+ {\r
+ if (USB_CurrentMode == USB_MODE_HOST)\r
+ RAISE_EVENT(USB_DeviceUnattached);\r
+ else\r
+ RAISE_EVENT(USB_Disconnect);\r
+ }\r
+\r
+ RAISE_EVENT(USB_UIDChange);\r
+ \r
+ USB_ResetInterface();\r
+ }\r
+ #endif\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Main USB interrupt vector handler. This file manages the main USB interrupt vector, for handling such\r
+ * events as VBUS interrupts (on supported USB AVR models), device connections and disconnections, etc.\r
+ */\r
+\r
+#ifndef __USBINTERRUPT_H__\r
+#define __USBINTERRUPT_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include "../../../Common/Common.h"\r
+ #include "../LowLevel/LowLevel.h"\r
+ #include "../LowLevel/USBMode.h"\r
+ #include "Events.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Vector name for the common endpoint and pipe vector. This can be used to write an ISR handler\r
+ * for the endpoint and pipe events, to make certain USB functions interrupt rather than poll\r
+ * driven.\r
+ */\r
+ #define ENDPOINT_PIPE_vect USB_COM_vect\r
+ \r
+ /** Enables the given USB interrupt vector (such as the ENDPOINT_INT_* and PIPE_INT_* vectors in\r
+ * Endpoint.h and Pipe.h).\r
+ */\r
+ #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE\r
+\r
+ /** Disables the given USB interrupt vector.\r
+ *\r
+ * \see USB_INT_Enable()\r
+ */\r
+ #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE\r
+\r
+ /** Resets the given USB interrupt flag, so that the interrupt is re-primed for the next firing. */\r
+ #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
+ \r
+ /** Returns boolean false if the given USB interrupt is disabled, or true if the interrupt is currently\r
+ * enabled.\r
+ */\r
+ #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)\r
+\r
+ /** Returns boolean true if the given interrupt flag is set (i.e. the condition for the interrupt has occurred,\r
+ * but the interrupt vector is not neccesarily enabled), otherwise returns false.\r
+ */\r
+ #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)\r
+ \r
+ /* Throwable Events: */\r
+ /** This module raises the USB Connected interrupt when the AVR is attached to a host while in device\r
+ * USB mode.\r
+ *\r
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by\r
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually.\r
+ */\r
+ RAISES_EVENT(USB_Connect);\r
+\r
+ /** This module raises the USB Disconnected interrupt when the AVR is removed from a host while in\r
+ * device USB mode.\r
+ *\r
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by\r
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually.\r
+ */\r
+ RAISES_EVENT(USB_Disconnect);\r
+\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)\r
+ /** This module raises the VBUS Change event when the current VBUS status (present or not present) has\r
+ * changed.\r
+ *\r
+ * \note Not all USB AVR models support VBUS interrupts; this event only exists on supported AVRs.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_VBUSChange);\r
+\r
+ /** This module raises the VBUS Connect event when the VBUS line is powered.\r
+ *\r
+ * \note Not all USB AVR models support VBUS interrupts; this event only exists on supported AVRs.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_VBUSConnect);\r
+\r
+ /** This module raises the VBUS Disconnect event when power is removed from the VBUS line.\r
+ *\r
+ * \note Not all USB AVR models support VBUS interrupts; this event only exists on supported AVRs.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_VBUSDisconnect);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ /** This module raises the Suspended event when the host suspends the USB interface of the AVR\r
+ * whilst running in device mode.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_Suspend);\r
+\r
+ /** This module raises the Wake Up event when the host resumes the USB interface of the AVR\r
+ * whilst running in device mode.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_WakeUp);\r
+\r
+ /** This module raises the USB Reset event when the host resets the USB interface of the AVR\r
+ * whilst running in device mode.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_Reset);\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ /** This module raises the Host Error event when the VBUS line voltage dips below the minimum threshold\r
+ * while running in host mode.\r
+ *\r
+ * \note Not all USB AVR models support host mode; this event only exists on supported AVRs.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_HostError);\r
+\r
+ /** This module raises the Device Unattached event when an attached device is removed from the AVR whilst\r
+ * running in host mode.\r
+ *\r
+ * \note Not all USB AVR models support host mode; this event only exists on supported AVRs.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceUnattached);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ /** This module raises the UID Change event when the UID line changes in value on dual-role devices.\r
+ *\r
+ * \note Not all USB AVR models support host mode and thus the UID pin; this event only exists on\r
+ * supported AVRs.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_UIDChange);\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define USB_INT_GET_EN_REG(a, b, c, d) a\r
+ #define USB_INT_GET_EN_MASK(a, b, c, d) b\r
+ #define USB_INT_GET_INT_REG(a, b, c, d) c\r
+ #define USB_INT_GET_INT_MASK(a, b, c, d) d\r
+\r
+ #define USB_INT_VBUS USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI)\r
+ #define USB_INT_IDTI USBCON, (1 << IDTE) , USBINT, (1 << IDTI)\r
+ #define USB_INT_WAKEUP UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)\r
+ #define USB_INT_SUSPEND UDIEN , (1 << SUSPE) , UDINT , (1 << SUSPI)\r
+ #define USB_INT_EORSTI UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI)\r
+ #define USB_INT_DCONNI UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI)\r
+ #define USB_INT_DDISCI UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI)\r
+ #define USB_INT_BCERRI OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI)\r
+ #define USB_INT_VBERRI OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI)\r
+ #define USB_INT_SOFI UDIEN, (1 << SOFE) , UDINT , (1 << SOFI)\r
+ #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI)\r
+ #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI)\r
+ #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI)\r
+ \r
+ /* Function Prototypes: */\r
+ void USB_INT_ClearAllInterrupts(void);\r
+ void USB_INT_DisableAllInterrupts(void);\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../LowLevel/USBMode.h"\r
+\r
+#define INCLUDE_FROM_USBTASK_C\r
+#include "USBTask.h"\r
+\r
+volatile bool USB_IsSuspended;\r
+volatile bool USB_IsConnected;\r
+volatile bool USB_IsInitialized;\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+volatile uint8_t USB_HostState;\r
+#endif\r
+\r
+TASK(USB_USBTask)\r
+{\r
+ #if defined(USB_HOST_ONLY)\r
+ USB_HostTask();\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ USB_DeviceTask();\r
+ #else\r
+ if (USB_CurrentMode == USB_MODE_DEVICE)\r
+ USB_DeviceTask();\r
+ else if (USB_CurrentMode == USB_MODE_HOST)\r
+ USB_HostTask();\r
+ #endif\r
+}\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+static void USB_DeviceTask(void)\r
+{\r
+ if (USB_IsConnected)\r
+ {\r
+ uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();\r
+ \r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+\r
+ if (Endpoint_IsSetupReceived())\r
+ {\r
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
+ {\r
+ USB_Device_ProcessControlPacket();\r
+ }\r
+ }\r
+ \r
+ Endpoint_SelectEndpoint(PrevEndpoint);\r
+ }\r
+}\r
+#endif\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+static void USB_HostTask(void)\r
+{\r
+ uint8_t ErrorCode = HOST_ENUMERROR_NoError;\r
+ uint8_t SubErrorCode = HOST_ENUMERROR_NoError;\r
+ \r
+ static uint16_t WaitMSRemaining;\r
+ static uint8_t PostWaitState;\r
+\r
+ switch (USB_HostState)\r
+ {\r
+ case HOST_STATE_WaitForDevice:\r
+ if (WaitMSRemaining)\r
+ {\r
+ if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ {\r
+ USB_HostState = PostWaitState;\r
+ ErrorCode = HOST_ENUMERROR_WaitStage;\r
+ break;\r
+ }\r
+ \r
+ WaitMSRemaining--;\r
+ }\r
+ else\r
+ {\r
+ USB_HostState = PostWaitState;\r
+ }\r
+ \r
+ break;\r
+ case HOST_STATE_Attached:\r
+ WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;\r
+ \r
+ USB_HostState = HOST_STATE_Attached_WaitForDeviceSettle;\r
+ break;\r
+ case HOST_STATE_Attached_WaitForDeviceSettle:\r
+ _delay_ms(1);\r
+\r
+ if (!(WaitMSRemaining--))\r
+ {\r
+ USB_Host_VBUS_Manual_Off();\r
+\r
+ USB_OTGPAD_On();\r
+ USB_Host_VBUS_Auto_Enable();\r
+ USB_Host_VBUS_Auto_On();\r
+ \r
+ USB_HostState = HOST_STATE_Attached_WaitForConnect;\r
+ }\r
+ \r
+ break;\r
+ case HOST_STATE_Attached_WaitForConnect: \r
+ if (USB_INT_HasOccurred(USB_INT_DCONNI))\r
+ { \r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+\r
+ USB_INT_Clear(USB_INT_VBERRI);\r
+ USB_INT_Enable(USB_INT_VBERRI);\r
+\r
+ USB_IsConnected = true;\r
+ RAISE_EVENT(USB_Connect);\r
+ \r
+ USB_Host_ResumeBus();\r
+ Pipe_ClearPipes();\r
+ \r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Attached_DoReset);\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Attached_DoReset:\r
+ USB_Host_ResetDevice();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered);\r
+ break;\r
+ case HOST_STATE_Powered:\r
+ Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,\r
+ PIPE_TOKEN_SETUP, PIPE_CONTROLPIPE,\r
+ PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE); \r
+ \r
+ if (!(Pipe_IsConfigured()))\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;\r
+ SubErrorCode = 0;\r
+ break;\r
+ }\r
+\r
+ USB_HostState = HOST_STATE_Default;\r
+ break;\r
+ case HOST_STATE_Default:\r
+ USB_HostRequest = (USB_Host_Request_Header_t)\r
+ {\r
+ bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ bRequest: REQ_GetDescriptor,\r
+ wValue: (DTYPE_Device << 8),\r
+ wIndex: 0,\r
+ wLength: PIPE_CONTROLPIPE_DEFAULT_SIZE,\r
+ };\r
+\r
+ uint8_t DataBuffer[PIPE_CONTROLPIPE_DEFAULT_SIZE];\r
+\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ #if defined(USE_NONSTANDARD_DESCRIPTOR_NAMES)\r
+ USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];\r
+ #else\r
+ USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, bMaxPacketSize0)]; \r
+ #endif\r
+ \r
+ USB_Host_ResetDevice();\r
+ \r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);\r
+ break;\r
+ case HOST_STATE_Default_PostReset:\r
+ Pipe_DisablePipe();\r
+ Pipe_DeallocateMemory(); \r
+ Pipe_ResetPipe(PIPE_CONTROLPIPE);\r
+ \r
+ Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,\r
+ PIPE_TOKEN_SETUP, PIPE_CONTROLPIPE,\r
+ USB_ControlPipeSize, PIPE_BANK_SINGLE);\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;\r
+ SubErrorCode = 0;\r
+ break;\r
+ }\r
+\r
+ Pipe_SetInfiniteINRequests();\r
+ \r
+ USB_HostRequest = (USB_Host_Request_Header_t)\r
+ {\r
+ bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ bRequest: REQ_SetAddress,\r
+ wValue: USB_HOST_DEVICEADDRESS,\r
+ wIndex: 0,\r
+ wLength: 0,\r
+ };\r
+\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);\r
+ break;\r
+ case HOST_STATE_Default_PostAddressSet:\r
+ USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);\r
+\r
+ RAISE_EVENT(USB_DeviceEnumerationComplete);\r
+ USB_HostState = HOST_STATE_Addressed;\r
+\r
+ break;\r
+ }\r
+\r
+ if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))\r
+ {\r
+ RAISE_EVENT(USB_DeviceEnumerationFailed, ErrorCode, SubErrorCode);\r
+\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ RAISE_EVENT(USB_DeviceUnattached);\r
+ \r
+ if (USB_IsConnected)\r
+ RAISE_EVENT(USB_Disconnect);\r
+\r
+ USB_ResetInterface();\r
+ }\r
+}\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Main library USB management task for both Host and Device mode operations. This contains the master\r
+ * USB_USBTask task which should be periodically run to service both host and device USB projects.\r
+ */\r
+ \r
+#ifndef __USBTASK_H__\r
+#define __USBTASK_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <avr/interrupt.h>\r
+ #include <util/atomic.h>\r
+ #include <stdbool.h>\r
+ #include <stddef.h>\r
+ \r
+ #include "../../../Scheduler/Scheduler.h"\r
+ #include "../LowLevel/LowLevel.h"\r
+ #include "../LowLevel/HostChapter9.h"\r
+ #include "../LowLevel/USBMode.h"\r
+ #include "Events.h"\r
+ #include "StdDescriptors.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Global Variables: */\r
+ /** Indicates if the USB interface is currently connected to a host if in device mode, or to a\r
+ * device while running in host mode.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \note For the smaller USB AVRs (AT90USBXX2) with limited USB controllers, VBUS is not available to the USB controller.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by\r
+ * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired by RAISE_EVENT(), and the USB_IsConnected global changed manually.\r
+ */\r
+ extern volatile bool USB_IsConnected;\r
+\r
+ /** Indicates if the USB interface is currently initialized but not neccesarily connected to a host\r
+ * or device (i.e. if USB_Init() has been run). If this is false, all other library globals are invalid.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern volatile bool USB_IsInitialized;\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ /** Indicates if the USB interface is currently suspended by the host when in device mode. When suspended,\r
+ * the device should consume minimal power, and cannot communicate to the host. If Remote Wakeup is\r
+ * supported by the device and USB_RemoteWakeupEnabled is true, suspension can be terminated by the device\r
+ * by issuing a Remote Wakup request.\r
+ *\r
+ * \note This global is only present if the user application can be a USB device.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern volatile bool USB_IsSuspended;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ /** Indicates the current host state machine state. When in host mode, this indicates the state\r
+ * via one of the values of the USB_Host_States_t enum values in Host.h.\r
+ *\r
+ * This value may be altered by the user application to implement the HOST_STATE_Addressed,\r
+ * HOST_STATE_Configured, HOST_STATE_Ready and HOST_STATE_Suspended states which are not implemented\r
+ * by the library.\r
+ *\r
+ * \note This global is only present if the user application can be a USB host.\r
+ */\r
+ extern volatile uint8_t USB_HostState;\r
+ #endif\r
+\r
+ /* Throwable Events: */\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ /** This module raises the USB Connect event when a USB device has been connected whilst in host\r
+ * mode, but not yet enumerated.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_Connect);\r
+\r
+ /** This module raises the USB Device Attached event when in host mode, and a device is attached\r
+ * to the AVR's USB interface.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceAttached);\r
+\r
+ /** This module raises the USB Device Unattached event when in host mode, and a device is removed\r
+ * from the AVR's USB interface.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceUnattached);\r
+ \r
+ /** This module raises the USB Device Enumeration Failed event when in host mode, and an\r
+ * attached USB device has failed to successfully enumerated.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceEnumerationFailed);\r
+\r
+ /** This module raises the USB Device Enumeration Complete event when in host mode, and an\r
+ * attached USB device has been successfully enumerated and ready to be used by the user\r
+ * application.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceEnumerationComplete);\r
+\r
+ /** This module raises the USB Disconnect event when an attached USB device is removed from the USB\r
+ * bus.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_Disconnect);\r
+ #endif\r
+\r
+ /* Tasks: */\r
+ /** This is the main USB management task. The USB driver requires that this task be executed\r
+ * continuously when the USB system is active (device attached in host mode, or attached to a host\r
+ * in device mode) in order to manage USB communications. This task may be executed inside an RTOS,\r
+ * scheduler (e.g. the simple LUFA Scheduler), fast timer ISR or the main user application loop.\r
+ *\r
+ * The USB task must be serviced within 50mS in all modes, when needed. The task may be serviced \r
+ * at all times, or (for minimum CPU consumption):\r
+ *\r
+ * - In device mode, it may be disabled at startup, enabled on the firing of the USB_Connect event\r
+ * and disabled again on the firing of the USB_Disconnect event.\r
+ *\r
+ * - In host mode, it may be disabled at startup, enabled on the firing of the USB_DeviceAttached\r
+ * event and disabled again on the firing of the USB_DeviceUnattached event.\r
+ *\r
+ * \see Events.h for more information on the USB events.\r
+ */\r
+ TASK(USB_USBTask);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(INCLUDE_FROM_USBTASK_C)\r
+ #if defined(USB_CAN_BE_HOST)\r
+ static void USB_HostTask(void);\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ static void USB_DeviceTask(void);\r
+ #endif\r
+ #endif\r
+ \r
+ /* Macros: */\r
+ #define HOST_TASK_NONBLOCK_WAIT(duration, nextstate) {USB_HostState = HOST_STATE_WaitForDevice; WaitMSRemaining = duration; PostWaitState = nextstate; }\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "USBMode.h"\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define INCLUDE_FROM_DEVCHAPTER9_C\r
+#include "DevChapter9.h"\r
+\r
+uint8_t USB_ConfigurationNumber;\r
+bool USB_RemoteWakeupEnabled;\r
+bool USB_CurrentlySelfPowered;\r
+\r
+void USB_Device_ProcessControlPacket(void)\r
+{\r
+ uint8_t bmRequestType = Endpoint_Read_Byte();\r
+ uint8_t bRequest = Endpoint_Read_Byte();\r
+ bool RequestHandled = false; \r
+ \r
+ switch (bRequest)\r
+ {\r
+ case REQ_GetStatus:\r
+ if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+ (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))\r
+ {\r
+ USB_Device_GetStatus(bmRequestType);\r
+ RequestHandled = true;\r
+ }\r
+\r
+ break;\r
+#if !defined(NO_CLEARSET_FEATURE_REQUEST)\r
+ case REQ_ClearFeature:\r
+ case REQ_SetFeature:\r
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT))\r
+ {\r
+ USB_Device_ClearSetFeature(bRequest, bmRequestType);\r
+ RequestHandled = true;\r
+ }\r
+\r
+ break;\r
+#endif\r
+ case REQ_SetAddress:\r
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
+ {\r
+ USB_Device_SetAddress();\r
+ RequestHandled = true;\r
+ }\r
+\r
+ break;\r
+ case REQ_GetDescriptor:\r
+ if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+ (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))\r
+ {\r
+ USB_Device_GetDescriptor();\r
+ RequestHandled = true;\r
+ }\r
+ \r
+ break;\r
+ case REQ_GetConfiguration:\r
+ if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))\r
+ {\r
+ USB_Device_GetConfiguration();\r
+ RequestHandled = true;\r
+ }\r
+\r
+ break;\r
+ case REQ_SetConfiguration:\r
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
+ {\r
+ USB_Device_SetConfiguration();\r
+ RequestHandled = true;\r
+ }\r
+\r
+ break;\r
+ }\r
+\r
+ if (!(RequestHandled))\r
+ RAISE_EVENT(USB_UnhandledControlPacket, bRequest, bmRequestType);\r
+ \r
+ if (Endpoint_IsSetupReceived())\r
+ {\r
+ Endpoint_StallTransaction();\r
+ Endpoint_ClearSetupReceived(); \r
+ }\r
+}\r
+\r
+static void USB_Device_SetAddress(void)\r
+{\r
+ uint8_t wValue_LSB = Endpoint_Read_Byte();\r
+\r
+ Endpoint_ClearSetupReceived();\r
+ \r
+ while (!(Endpoint_IsSetupINReady()));\r
+ \r
+ Endpoint_ClearSetupIN();\r
+ \r
+ while (!(Endpoint_IsSetupINReady()));\r
+\r
+ UDADDR = ((1 << ADDEN) | (wValue_LSB & 0x7F));\r
+\r
+ return;\r
+}\r
+\r
+static void USB_Device_SetConfiguration(void)\r
+{\r
+ uint8_t wValue_LSB = Endpoint_Read_Byte();\r
+ bool AlreadyConfigured = (USB_ConfigurationNumber != 0);\r
+\r
+#if defined(USE_SINGLE_DEVICE_CONFIGURATION)\r
+ if (wValue_LSB > 1)\r
+#else\r
+ USB_Descriptor_Device_t* DevDescriptorPtr;\r
+\r
+ if ((USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr) == NO_DESCRIPTOR) ||\r
+ #if defined(USE_RAM_DESCRIPTORS)\r
+ (wValue_LSB > DevDescriptorPtr->NumberOfConfigurations))\r
+ #elif defined (USE_EEPROM_DESCRIPTORS)\r
+ (wValue_LSB > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ #else\r
+ (wValue_LSB > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ #endif\r
+#endif\r
+ {\r
+ return;\r
+ }\r
+ \r
+ Endpoint_ClearSetupReceived();\r
+\r
+ USB_ConfigurationNumber = wValue_LSB;\r
+\r
+ Endpoint_ClearSetupIN();\r
+\r
+ if (!(AlreadyConfigured) && USB_ConfigurationNumber)\r
+ RAISE_EVENT(USB_DeviceEnumerationComplete);\r
+\r
+ RAISE_EVENT(USB_ConfigurationChanged);\r
+}\r
+\r
+void USB_Device_GetConfiguration(void)\r
+{\r
+ Endpoint_ClearSetupReceived(); \r
+\r
+ Endpoint_Write_Byte(USB_ConfigurationNumber);\r
+ \r
+ Endpoint_ClearSetupIN();\r
+\r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+ Endpoint_ClearSetupOUT();\r
+}\r
+\r
+static void USB_Device_GetDescriptor(void)\r
+{\r
+ uint16_t wValue = Endpoint_Read_Word_LE();\r
+ uint16_t wIndex = Endpoint_Read_Word_LE();\r
+ uint16_t wLength = Endpoint_Read_Word_LE();\r
+ \r
+ void* DescriptorPointer;\r
+ uint16_t DescriptorSize;\r
+ \r
+ bool SendZLP;\r
+ \r
+ if ((DescriptorSize = USB_GetDescriptor(wValue, wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)\r
+ return;\r
+ \r
+ Endpoint_ClearSetupReceived();\r
+ \r
+ if (wLength > DescriptorSize)\r
+ wLength = DescriptorSize;\r
+ \r
+ while (wLength)\r
+ {\r
+ while (!(Endpoint_IsSetupINReady()))\r
+ {\r
+ if (Endpoint_IsSetupOUTReceived())\r
+ {\r
+ Endpoint_ClearSetupOUT();\r
+ return;\r
+ } \r
+ }\r
+ \r
+ while (wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
+ {\r
+ #if defined(USE_RAM_DESCRIPTORS)\r
+ Endpoint_Write_Byte(*((uint8_t*)DescriptorPointer++));\r
+ #elif defined (USE_EEPROM_DESCRIPTORS)\r
+ Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++)); \r
+ #else\r
+ Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++));\r
+ #endif\r
+ \r
+ wLength--;\r
+ }\r
+ \r
+ SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+ \r
+ if (SendZLP)\r
+ {\r
+ while (!(Endpoint_IsSetupINReady()));\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+\r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+ Endpoint_ClearSetupOUT();\r
+}\r
+\r
+static void USB_Device_GetStatus(const uint8_t bmRequestType)\r
+{\r
+ uint8_t CurrentStatus = 0;\r
+\r
+ Endpoint_Discard_Word();\r
+\r
+ uint8_t wIndex_LSB = Endpoint_Read_Byte();\r
+ \r
+ switch (bmRequestType)\r
+ {\r
+ case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE):\r
+ if (USB_CurrentlySelfPowered)\r
+ CurrentStatus |= FEATURE_SELFPOWERED_ENABLED;\r
+ \r
+ if (USB_RemoteWakeupEnabled)\r
+ CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;\r
+ \r
+ break;\r
+ case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):\r
+ Endpoint_SelectEndpoint(wIndex_LSB);\r
+\r
+ CurrentStatus = Endpoint_IsStalled();\r
+\r
+ break;\r
+ }\r
+ \r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP); \r
+ Endpoint_ClearSetupReceived();\r
+ Endpoint_Write_Word_LE(CurrentStatus);\r
+\r
+ Endpoint_ClearSetupIN();\r
+ \r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+ Endpoint_ClearSetupOUT();\r
+}\r
+\r
+#if !defined(NO_CLEARSET_FEATURE_REQUEST)\r
+static void USB_Device_ClearSetFeature(const uint8_t bRequest, const uint8_t bmRequestType)\r
+{\r
+ uint16_t wValue = Endpoint_Read_Word_LE();\r
+ uint16_t wIndex = Endpoint_Read_Word_LE();\r
+ \r
+ switch (bmRequestType & CONTROL_REQTYPE_RECIPIENT)\r
+ {\r
+ case REQREC_ENDPOINT:\r
+ if (wValue == FEATURE_ENDPOINT_HALT)\r
+ {\r
+ uint8_t EndpointIndex = (wIndex & ENDPOINT_EPNUM_MASK);\r
+ \r
+ if (EndpointIndex != ENDPOINT_CONTROLEP)\r
+ {\r
+ Endpoint_SelectEndpoint(EndpointIndex);\r
+\r
+ if (Endpoint_IsEnabled())\r
+ { \r
+ if (bRequest == REQ_ClearFeature)\r
+ {\r
+ Endpoint_ClearStall();\r
+ Endpoint_ResetFIFO(EndpointIndex);\r
+ Endpoint_ResetDataToggle();\r
+ }\r
+ else\r
+ {\r
+ Endpoint_StallTransaction(); \r
+ }\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ Endpoint_ClearSetupReceived();\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+ }\r
+ \r
+ break;\r
+ }\r
+}\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Module for device mode request processing. This module allows for the processing of standard control\r
+ * requests to the default control endpoint while in device mode.\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 specification.\r
+ */\r
+\r
+#ifndef __DEVCHAPTER9_H__\r
+#define __DEVCHAPTER9_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <avr/pgmspace.h>\r
+ #include <avr/eeprom.h>\r
+ \r
+ #include "../HighLevel/StdDescriptors.h"\r
+ #include "../HighLevel/Events.h"\r
+ #include "LowLevel.h"\r
+ #include "StdRequestType.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Global Variables: */\r
+ /** Indicates the currently set configuration number of the device. USB devices may have several\r
+ * different configurations which the host can select between; this indicates the currently selected\r
+ * value, or 0 if no configuration has been selected.\r
+ *\r
+ * If a device has only one single configuration, the token USE_SINGLE_DEVICE_CONFIGURATION may be\r
+ * defined in the project makefile and passed to the compiler using the -D switch. This optimize for\r
+ * a single configuration, saving a small amount of space in the resulting compiled binary.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern uint8_t USB_ConfigurationNumber;\r
+ \r
+ /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this\r
+ * flag is cleared, the device should not issue remote wakeup events to the host.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern bool USB_RemoteWakeupEnabled;\r
+ \r
+ /** Indicates if the device is currently being powered by its own power supply, rather than being\r
+ * powered by the host's USB supply. This flag should remain cleared if the device does not\r
+ * support self powered mode, as indicated in the device descriptors.\r
+ */\r
+ extern bool USB_CurrentlySelfPowered;\r
+\r
+ /* Throwable Events: */\r
+ /** This module raises the USB_UnhandledControlPacket event when a request to the default control\r
+ * endpoint has been received, but the library does not implement an internal handler for it.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_UnhandledControlPacket);\r
+\r
+ /** This module raises the USB_ConfigurationChanged event when the host issues a REQ_SetConfiguration\r
+ * device request, to change the currently selected configuration number.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_ConfigurationChanged);\r
+\r
+ /** This module raises the USB_DeviceEnumerationComplete event when the host has completed its\r
+ * enumeration of the device (i.e. when a REQ_SetConfiguration request changes the current configuration\r
+ * number from 0 to a non-zero value).\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_DeviceEnumerationComplete);\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)\r
+ #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+ \r
+ /* Function Prototypes: */\r
+ void USB_Device_ProcessControlPacket(void);\r
+ \r
+ #if defined(INCLUDE_FROM_DEVCHAPTER9_C)\r
+ static void USB_Device_SetAddress(void);\r
+ static void USB_Device_SetConfiguration(void);\r
+ static void USB_Device_GetConfiguration(void);\r
+ static void USB_Device_GetDescriptor(void);\r
+ static void USB_Device_GetStatus(const uint8_t bmRequestType);\r
+ #if !defined(NO_CLEARSET_FEATURE_REQUEST)\r
+ static void USB_Device_ClearSetFeature(const uint8_t bRequest, const uint8_t bmRequestType);\r
+ #endif\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * USB Device mode related macros and enums. This module contains macros and enums which are used when\r
+ * the USB controller is initialized in device mode.\r
+ */\r
+\r
+#ifndef __USBDEVICE_H__\r
+#define __USBDEVICE_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/pgmspace.h>\r
+ #include <avr/eeprom.h>\r
+\r
+ #include "../../../Common/Common.h" \r
+ #include "../HighLevel/StdDescriptors.h"\r
+ #include "Endpoint.h"\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)\r
+ /** Mask for the Options parameter of the USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in low speed (1.5Mb/s) mode.\r
+ *\r
+ * \note Low Speed mode is not available on all USB AVR models.\r
+ *\r
+ * \note Restrictions apply on the number, size and type of endpoints which can be used\r
+ * when running in low speed mode -- refer to the USB 2.0 standard.\r
+ */\r
+ #define USB_DEVICE_OPT_LOWSPEED (1 << 0)\r
+ #endif\r
+ \r
+ /** Mask for the Options parameter of the USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in full speed (12Mb/s) mode.\r
+ */\r
+ #define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
+ \r
+ /** Sends a Remote Wakeup request to the host. This signals to the host that the device should\r
+ * be taken out of suspended mode, and communications should resume.\r
+ *\r
+ * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the\r
+ * host computer when the host has suspended all USB devices to enter a low power state.\r
+ *\r
+ * \note This macro should only be used if the device has indicated to the host that it\r
+ * supports the Remote Wakeup feature in the device descriptors, and should only be\r
+ * issued if the host is currently allowing remote wakeup events from the device (i.e.,\r
+ * the USB_RemoteWakeupEnabled flag is set, see DevChapter9.h documentation).\r
+ *\r
+ * \see StdDescriptors.h for more information on the RMWAKEUP feature and device descriptors.\r
+ */\r
+ #define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE\r
+\r
+ /** Indicates if a Remote Wakeup request is being sent to the host. This returns true if a\r
+ * remote wakeup is currently being sent, false otherwise.\r
+ *\r
+ * This can be used in conjunction with the USB_Device_IsUSBSuspended() macro to determine if\r
+ * a sent RMWAKEUP request was accepted or rejected by the host.\r
+ *\r
+ * \note This macro should only be used if the device has indicated to the host that it\r
+ * supports the Remote Wakeup feature in the device descriptors.\r
+ *\r
+ * \see StdDescriptors.h for more information on the RMWAKEUP feature and device descriptors.\r
+ */\r
+ #define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)\r
+\r
+ /** Indicates if the device is currently suspended by the host. While suspended, the device is\r
+ * to enter a low power state until resumed by the host. While suspended no USB traffic to or\r
+ * from the device can ocurr (except for Remote Wakeup requests).\r
+ *\r
+ * This macro returns true if the USB communications have been suspended by the host, false\r
+ * otherwise.\r
+ */\r
+ #define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false)\r
+\r
+ /* Enums: */\r
+ /** Enum for the ErrorCode parameter of the USB_DeviceError event.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ enum USB_Device_ErrorCodes_t\r
+ {\r
+ DEVICE_ERROR_GetDescriptorNotHooked = 0, /**< Indicates that the GetDescriptor() method\r
+ * has not been hooked by the user application.\r
+ *\r
+ * \see StdDescriptors.h for more information on\r
+ * the GetDescriptor() method.\r
+ */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */ \r
+ #define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE\r
+ #define USB_Device_SetHighSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "USBMode.h"\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define INCLUDE_FROM_ENDPOINT_C\r
+#include "Endpoint.h"\r
+\r
+#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
+#endif\r
+\r
+#if !defined(STATIC_ENDPOINT_CONFIGURATION)\r
+bool Endpoint_ConfigureEndpoint(const uint8_t Number, const uint8_t Type, const uint8_t Direction,\r
+ const uint16_t Size, const uint8_t Banks)\r
+{\r
+ Endpoint_SelectEndpoint(Number);\r
+ Endpoint_EnableEndpoint();\r
+\r
+ UECFG1X = 0; \r
+\r
+ UECFG0X = ((Type << EPTYPE0) | Direction);\r
+ UECFG1X = ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size));\r
+\r
+ return Endpoint_IsConfigured();\r
+}\r
+#else\r
+bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData)\r
+{\r
+ Endpoint_SelectEndpoint(Number);\r
+ Endpoint_EnableEndpoint();\r
+\r
+ UECFG1X = 0; \r
+\r
+ UECFG0X = UECFG0XData;\r
+ UECFG1X = UECFG1XData;\r
+\r
+ return Endpoint_IsConfigured();\r
+}\r
+#endif\r
+\r
+void Endpoint_ClearEndpoints(void)\r
+{\r
+ UEINT = 0;\r
+\r
+ for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ Endpoint_SelectEndpoint(EPNum); \r
+ UEIENX = 0;\r
+ UEINTX = 0;\r
+ Endpoint_DeallocateMemory();\r
+ Endpoint_DisableEndpoint();\r
+ }\r
+}\r
+\r
+uint8_t Endpoint_WaitUntilReady(void)\r
+{\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+\r
+ USB_INT_Clear(USB_INT_SOFI);\r
+\r
+ while (!(Endpoint_ReadWriteAllowed()))\r
+ {\r
+ if (!(USB_IsConnected))\r
+ return ENDPOINT_READYWAIT_DeviceDisconnected;\r
+ else if (Endpoint_IsStalled())\r
+ return ENDPOINT_READYWAIT_EndpointStalled;\r
+ \r
+ if (USB_INT_HasOccurred(USB_INT_SOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SOFI);\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return ENDPOINT_READYWAIT_Timeout;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_READYWAIT_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Discard_Stream(uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Endpoint_ReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearCurrentBank();\r
+\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return ENDPOINT_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ Endpoint_Discard_Byte();\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)Buffer;\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Endpoint_ReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearCurrentBank();\r
+ \r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return ENDPOINT_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ Endpoint_Write_Byte(*(DataStream++));\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Endpoint_ReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearCurrentBank();\r
+\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return ENDPOINT_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ Endpoint_Write_Byte(*(DataStream--));\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)Buffer;\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Endpoint_ReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearCurrentBank();\r
+\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return ENDPOINT_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ \r
+ *(DataStream++) = Endpoint_Read_Byte();\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Endpoint_ReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearCurrentBank();\r
+\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return ENDPOINT_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ \r
+ *(DataStream--) = Endpoint_Read_Byte();\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)\r
+{\r
+ uint8_t* DataStream = (uint8_t*)Buffer;\r
+ bool SendZLP = true;\r
+ \r
+ while (Length && !(Endpoint_IsSetupOUTReceived()))\r
+ {\r
+ while (!(Endpoint_IsSetupINReady()));\r
+ \r
+ while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
+ {\r
+ Endpoint_Write_Byte(*(DataStream++));\r
+ \r
+ Length--;\r
+ }\r
+ \r
+ SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+ \r
+ if (Endpoint_IsSetupOUTReceived())\r
+ return ENDPOINT_RWCSTREAM_ERROR_HostAborted;\r
+ \r
+ if (SendZLP)\r
+ {\r
+ while (!(Endpoint_IsSetupINReady()));\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+ \r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+\r
+ return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)\r
+{\r
+ uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
+ bool SendZLP = true;\r
+ \r
+ while (Length && !(Endpoint_IsSetupOUTReceived()))\r
+ {\r
+ while (!(Endpoint_IsSetupINReady()));\r
+ \r
+ while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))\r
+ {\r
+ Endpoint_Write_Byte(*(DataStream--));\r
+ \r
+ Length--;\r
+ }\r
+ \r
+ SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+ \r
+ if (Endpoint_IsSetupOUTReceived())\r
+ return ENDPOINT_RWCSTREAM_ERROR_HostAborted;\r
+ \r
+ if (SendZLP)\r
+ {\r
+ while (!(Endpoint_IsSetupINReady()));\r
+ Endpoint_ClearSetupIN();\r
+ }\r
+ \r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+\r
+ return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)\r
+{\r
+ uint8_t* DataStream = (uint8_t*)Buffer;\r
+ \r
+ while (Length)\r
+ {\r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+ \r
+ while (Length && Endpoint_BytesInEndpoint())\r
+ {\r
+ *(DataStream++) = Endpoint_Read_Byte();\r
+ \r
+ Length--;\r
+ }\r
+ \r
+ Endpoint_ClearSetupOUT();\r
+ }\r
+ \r
+ while (!(Endpoint_IsSetupINReady()));\r
+ \r
+ return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)\r
+{\r
+ uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
+ \r
+ while (Length)\r
+ {\r
+ while (!(Endpoint_IsSetupOUTReceived()));\r
+ \r
+ while (Length && Endpoint_BytesInEndpoint())\r
+ {\r
+ *(DataStream--) = Endpoint_Read_Byte();\r
+ \r
+ Length--;\r
+ }\r
+ \r
+ Endpoint_ClearSetupOUT();\r
+ }\r
+ \r
+ while (!(Endpoint_IsSetupINReady()));\r
+\r
+ return ENDPOINT_RWCSTREAM_ERROR_NoError;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Functions, macros and enums related to endpoint management when in USB Device mode. This\r
+ * module contains the endpoint management macros, as well as endpoint interrupt and data\r
+ * send/recieve functions for various datatypes.\r
+ */\r
+ \r
+#ifndef __ENDPOINT_H__\r
+#define __ENDPOINT_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+ #include "../HighLevel/USBTask.h"\r
+\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ #include "StreamCallbacks.h"\r
+ #endif\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Endpoint data direction mask for Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
+ * should be initialized in the OUT direction - i.e. data flows from host to device.\r
+ */\r
+ #define ENDPOINT_DIR_OUT 0\r
+\r
+ /** Endpoint data direction mask for Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
+ * should be initialized in the IN direction - i.e. data flows from device to host.\r
+ */\r
+ #define ENDPOINT_DIR_IN (1 << EPDIR)\r
+\r
+ /** Mask for the bank mode selection for the Endpoint_ConfigureEndpoint() macro. This indicates\r
+ * that the endpoint should have one single bank, which requires less USB FIFO memory but results\r
+ * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's\r
+ * bank at the one time.\r
+ */\r
+ #define ENDPOINT_BANK_SINGLE 0\r
+\r
+ /** Mask for the bank mode selection for the Endpoint_ConfigureEndpoint() macro. This indicates\r
+ * that the endpoint should have two banks, which requires more USB FIFO memory but results\r
+ * in faster transfers as one USB device (the AVR or the host) can access one bank while the other\r
+ * accesses the second bank.\r
+ */\r
+ #define ENDPOINT_BANK_DOUBLE (1 << EPBK0)\r
+ \r
+ /** Endpoint address for the default control endpoint, which always resides in address 0. This is\r
+ * defined for convenience to give more readable code when used with the endpoint macros.\r
+ */\r
+ #define ENDPOINT_CONTROLEP 0\r
+\r
+ /** Default size of the default control endpoint's bank, until altered by the Endpoint0Size value \r
+ * in the device descriptor. Not available if the FIXED_CONTROL_ENDPOINT_SIZE token is defined.\r
+ */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8\r
+ #endif\r
+ \r
+ /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * numerical address in the device.\r
+ */\r
+ #define ENDPOINT_EPNUM_MASK 0b111\r
+\r
+ /** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * bank size in the device.\r
+ */\r
+ #define ENDPOINT_EPSIZE_MASK 0x7FF\r
+ \r
+ /** Maximum size in bytes of a given endpoint.\r
+ *\r
+ * \param n Endpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1)\r
+ */ \r
+ #define ENDPOINT_MAX_SIZE(n) _ENDPOINT_GET_MAXSIZE(n)\r
+\r
+ /** Indicates if the given endpoint supports double banking.\r
+ *\r
+ * \param n Endpoint number, a value between 0 and (ENDPOINT_TOTAL_ENDPOINTS - 1)\r
+ */ \r
+ #define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n)\r
+\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)\r
+ /** Total number of endpoints (including the default control endpoint at address 0) which may\r
+ * be used in the device. Different USB AVR models support different amounts of endpoints,\r
+ * this value reflects the maximum number of endpoints for the currently selected AVR model.\r
+ */\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 7\r
+ #else\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 5 \r
+ #endif\r
+\r
+ /** Interrupt definition for the endpoint SETUP interrupt (for CONTROL type endpoints). Should be\r
+ * used with the USB_INT_* macros located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on a CONTROL type endpoint if a new control packet is\r
+ * received from the host.\r
+ */\r
+ #define ENDPOINT_INT_SETUP UEIENX, (1 << RXSTPE), UEINTX, (1 << RXSTPI)\r
+\r
+ /** Interrupt definition for the endpoint IN interrupt (for INTERRUPT type endpoints). Should be\r
+ * used with the USB_INT_* macros located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on an INTERRUPT type endpoint if a the endpoint interrupt\r
+ * period has elapsed and the endpoint is ready for a new packet to be written to its FIFO buffer\r
+ * (if required).\r
+ */\r
+ #define ENDPOINT_INT_IN UEIENX, (1 << TXINE) , UEINTX, (1 << TXINI)\r
+\r
+ /** Interrupt definition for the endpoint OUT interrupt (for INTERRUPT type endpoints). Should be\r
+ * used with the USB_INT_* macros located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on an INTERRUPT type endpoint if a the endpoint interrupt\r
+ * period has elapsed and the endpoint is ready for a packet from the host to be read from its\r
+ * FIFO buffer (if received).\r
+ */\r
+ #define ENDPOINT_INT_OUT UEIENX, (1 << RXOUTE), UEINTX, (1 << RXOUTI)\r
+ \r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)\r
+ /** Indicates the number of bytes currently stored in the current endpoint's selected bank. */\r
+ #define Endpoint_BytesInEndpoint() UEBCX\r
+ #else\r
+ #define Endpoint_BytesInEndpoint() UEBCLX\r
+ #endif\r
+ \r
+ /** Returns the endpoint address of the currently selected endpoint. This is typically used to save\r
+ * the currently selected endpoint number so that it can be restored after another endpoint has\r
+ * been manipulated.\r
+ */\r
+ #define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)\r
+ \r
+ /** Selects the given endpoint number. If the address from the device descriptors is used, the\r
+ * value should be masked with the ENDPOINT_EPNUM_MASK constant to extract only the endpoint\r
+ * number (and discarding the endpoint direction bit).\r
+ *\r
+ * Any endpoint operations which do not require the endpoint number to be indicated will operate on\r
+ * the currently selected endpoint.\r
+ */\r
+ #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = epnum; }MACROE\r
+\r
+ /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's\r
+ * In and Out pointers to the bank's contents.\r
+ */\r
+ #define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE\r
+\r
+ /** Enables the currently selected endpoint so that data can be sent and received through it to\r
+ * and from a host.\r
+ *\r
+ * \note Endpoints must first be configured properly rather than just being enabled via the\r
+ * Endpoint_ConfigureEndpoint() macro, which calls Endpoint_EnableEndpoint() automatically.\r
+ */\r
+ #define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE\r
+\r
+ /** Disables the currently selected endpoint so that data cannot be sent and received through it\r
+ * to and from a host.\r
+ */\r
+ #define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE\r
+\r
+ /** Returns true if the currently selected endpoint is enabled, false otherwise. */\r
+ #define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)\r
+\r
+ /** Returns true if the currently selected endpoint may be read from (if data is waiting in the endpoint\r
+ * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an\r
+ * IN direction). This function will return false if an error has occured in the endpoint, or if\r
+ * the endpoint is an OUT direction and no packet has been received, or if the endpoint is an IN\r
+ * direction and the endpoint bank is full.\r
+ */\r
+ #define Endpoint_ReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)\r
+\r
+ /** Returns true if the currently selected endpoint is configured, false otherwise. */\r
+ #define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)\r
+\r
+ /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their\r
+ * interrupt duration has elapsed. Which endpoints have interrupted can be determined by\r
+ * masking the return value against (1 << {Endpoint Number}).\r
+ */\r
+ #define Endpoint_GetEndpointInterrupts() UEINT\r
+\r
+ /** Clears the endpoint interrupt flag. This clears the specified endpoint number's interrupt\r
+ * mask in the endpoint interrupt flag register.\r
+ */\r
+ #define Endpoint_ClearEndpointInterrupt(n) MACROS{ UEINT &= ~(1 << n); }MACROE\r
+\r
+ /** Returns true if the specified endpoint number has interrupted (valid only for INTERRUPT type\r
+ * endpoints), false otherwise.\r
+ */\r
+ #define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << n)) ? true : false)\r
+\r
+ /** Clears the currently selected endpoint bank, and switches to the alternate bank if the currently\r
+ * selected endpoint is dual-banked. When cleared, this either frees the bank up for the next packet\r
+ * from the host (if the endpoint is of the OUT direction) or sends the packet contents to the host\r
+ * (if the endpoint is of the IN direction).\r
+ */\r
+ #define Endpoint_ClearCurrentBank() MACROS{ UEINTX &= ~(1 << FIFOCON); }MACROE\r
+ \r
+ /** Returns true if the current CONTROL type endpoint is ready for an IN packet, false otherwise. */\r
+ #define Endpoint_IsSetupINReady() ((UEINTX & (1 << TXINI)) ? true : false)\r
+\r
+ /** Returns true if the current CONTROL type endpoint is ready for an OUT packet, false otherwise. */\r
+ #define Endpoint_IsSetupOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false)\r
+\r
+ /** Returns true if the current CONTROL type endpoint is ready for a SETUP packet, false otherwise. */\r
+ #define Endpoint_IsSetupReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)\r
+\r
+ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint. */\r
+ #define Endpoint_ClearSetupReceived() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
+\r
+ /** Sends an IN packet to the host on the currently selected CONTROL type endpoint. */\r
+ #define Endpoint_ClearSetupIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
+\r
+ /** Acknowedges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing\r
+ * up the endpoint for the next packet.\r
+ */\r
+ #define Endpoint_ClearSetupOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE\r
+\r
+ /** Stalls the current endpoint, indicating to the host that a logical problem occured with the\r
+ * indicated endpoint and that the current transfer sequence should be aborted. This provides a\r
+ * way for devices to indicate invalid commands to the host so that the current transfer can be\r
+ * aborted and the host can begin its own recovery seqeuence.\r
+ *\r
+ * The currently selected endpoint remains stalled until either the Endpoint_ClearStall() macro\r
+ * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected\r
+ * endpoint.\r
+ */\r
+ #define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE\r
+\r
+ /** Clears the stall on the currently selected endpoint. */\r
+ #define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE\r
+\r
+ /** Returns true if the currently selected endpoint is stalled, false othewise. */\r
+ #define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false)\r
+\r
+ /** Resets the data toggle of the currently selected endpoint. */\r
+ #define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the Endpoint_WaitUntilReady function */\r
+ enum Endpoint_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */\r
+ ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream\r
+ * transfer by the host or device.\r
+ */\r
+ ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while\r
+ * waiting for the endpoint to become ready.\r
+ */ \r
+ ENDPOINT_READYWAIT_Timeout = 3, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+ \r
+ /** Enum for the possible error return codes of the Endpoint_*_Stream_* functions. */\r
+ enum Endpoint_Stream_RW_ErrorCodes_t\r
+ {\r
+ ENDPOINT_RWSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */\r
+ ENDPOINT_RWSTREAM_ERROR_EndpointStalled = 1, /**< The endpoint was stalled during the stream\r
+ * transfer by the host or device.\r
+ */\r
+ ENDPOINT_RWSTREAM_ERROR_DeviceDisconnected = 1, /**< Device was disconnected from the host during\r
+ * the transfer.\r
+ */\r
+ ENDPOINT_RWSTREAM_ERROR_Timeout = 2, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ ENDPOINT_RWSTREAM_ERROR_CallbackAborted = 3, /**< Indicates that the stream's callback function\r
+ * aborted the transfer early.\r
+ */\r
+ };\r
+ \r
+ /** Enum for the possible error return codes of the Endpoint_*_Control_Stream_* functions. */\r
+ enum Endpoint_ControlStream_RW_ErrorCodes_t\r
+ {\r
+ ENDPOINT_RWCSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */\r
+ ENDPOINT_RWCSTREAM_ERROR_HostAborted = 1, /**< The aborted the transfer prematurely. */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints. */\r
+ static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Endpoint_Read_Byte(void)\r
+ {\r
+ return UEDATX;\r
+ }\r
+\r
+ /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints. */\r
+ static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
+ {\r
+ UEDATX = Byte;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. */\r
+ static inline void Endpoint_Discard_Byte(void)\r
+ {\r
+ uint8_t Dummy;\r
+ \r
+ Dummy = UEDATX;\r
+ }\r
+ \r
+ /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ */\r
+ static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t Endpoint_Read_Word_LE(void)\r
+ {\r
+ uint16_t Data;\r
+ \r
+ Data = UEDATX;\r
+ Data |= (((uint16_t)UEDATX) << 8);\r
+ \r
+ return Data;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ */\r
+ static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t Endpoint_Read_Word_BE(void)\r
+ {\r
+ uint16_t Data;\r
+ \r
+ Data = (((uint16_t)UEDATX) << 8);\r
+ Data |= UEDATX;\r
+ \r
+ return Data;\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ */\r
+ static inline void Endpoint_Write_Word_LE(const uint16_t Word)\r
+ {\r
+ UEDATX = (Word & 0xFF);\r
+ UEDATX = (Word >> 8);\r
+ }\r
+ \r
+ /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ */\r
+ static inline void Endpoint_Write_Word_BE(const uint16_t Word)\r
+ {\r
+ UEDATX = (Word >> 8);\r
+ UEDATX = (Word & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints. */\r
+ static inline void Endpoint_Discard_Word(void)\r
+ {\r
+ uint8_t Dummy;\r
+ \r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ */\r
+ static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Endpoint_Read_DWord_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t DWord;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+ \r
+ Data.Bytes[0] = UEDATX;\r
+ Data.Bytes[1] = UEDATX;\r
+ Data.Bytes[2] = UEDATX;\r
+ Data.Bytes[3] = UEDATX;\r
+ \r
+ return Data.DWord;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ */\r
+ static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Endpoint_Read_DWord_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t DWord;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+ \r
+ Data.Bytes[3] = UEDATX;\r
+ Data.Bytes[2] = UEDATX;\r
+ Data.Bytes[1] = UEDATX;\r
+ Data.Bytes[0] = UEDATX;\r
+ \r
+ return Data.DWord;\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ */\r
+ static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)\r
+ {\r
+ Endpoint_Write_Word_LE(DWord);\r
+ Endpoint_Write_Word_LE(DWord >> 16);\r
+ }\r
+ \r
+ /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ */\r
+ static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)\r
+ {\r
+ Endpoint_Write_Word_BE(DWord >> 16);\r
+ Endpoint_Write_Word_BE(DWord);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. */\r
+ static inline void Endpoint_Discard_DWord(void)\r
+ {\r
+ uint8_t Dummy;\r
+ \r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control endpoint located at address\r
+ * 0 in the device. This value is set to the value indicated in the device descriptor in the user\r
+ * project once the USB interface is initialized into device mode.\r
+ *\r
+ * If space is an issue, it is possible to fix this to a static value by defining the control\r
+ * endpoint size in the FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile\r
+ * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically\r
+ * read from the descriptors at runtime and instead fixed to the given value. When used, it is\r
+ * important that the descriptor control endpoint size value matches the size given as the\r
+ * FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the FIXED_CONTROL_ENDPOINT_SIZE token\r
+ * be used in the descriptors to ensure this.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ extern uint8_t USB_ControlEndpointSize;\r
+ #else\r
+ #define USB_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the specified endpoint number with the given endpoint type, direction, bank size\r
+ * and banking mode. Endpoints should be allocated in ascending order by their address in the\r
+ * device (i.e. endpoint 1 should be configured before endpoint 2 and so on).\r
+ *\r
+ * The endpoint type may be one of the EP_TYPE_* macros listed in LowLevel.h and the direction\r
+ * may be either ENDPOINT_DIR_OUT or ENDPOINT_DIR_IN.\r
+ *\r
+ * The bank size must indicate the maximum packet size that the endpoint can handle. Different\r
+ * endpoint numbers can handle different maximum packet sizes - refer to the chosen USB AVR's\r
+ * datasheet to determine the maximum bank size for each endpoint.\r
+ *\r
+ * The banking mode may be either ENDPOINT_BANK_SINGLE or ENDPOINT_BANK_DOUBLE.\r
+ *\r
+ * The success of this routine can be determined via the Endpoint_IsConfigured() macro.\r
+ *\r
+ * By default, the routine is entirely dynamic, and will accept both constant and variable inputs.\r
+ * If dynamic configuration is unused, a small space savings can be made by defining the\r
+ * STATIC_ENDPOINT_CONFIGURATION macro via the -D switch to the compiler, to optimize for constant\r
+ * input values.\r
+ *\r
+ * \note This routine will select the specified endpoint, and the endpoint will remain selected\r
+ * once the routine completes regardless of if the endpoint configuration succeeds.\r
+ *\r
+ * \return Boolean true if the configuration succeeded, false otherwise\r
+ */\r
+ bool Endpoint_ConfigureEndpoint(const uint8_t Number, const uint8_t Type, const uint8_t Direction,\r
+ const uint16_t Size, const uint8_t Banks);\r
+\r
+ /** Spinloops until the currently selected non-control endpoint is ready for the next packet of data\r
+ * to be read or written to it.\r
+ *\r
+ * \note This routine should not be called on CONTROL type endpoints.\r
+ *\r
+ * \return A value from the Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_WaitUntilReady(void);\r
+\r
+ /** Reads and discards the given number of bytes from the endpoint from the given buffer,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the Endpoint_ClearCurrentBank() macro. Between\r
+ * each USB packet, the given stream callback function is executed repeatedly until the next\r
+ * packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param Length Number of bytes to send via the currently selected endpoint.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Discard_Stream(uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ );\r
+\r
+ /** Writes the given number of bytes to the endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * Endpoint_ClearCurrentBank() macro. Between each USB packet, the given stream callback function\r
+ * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early\r
+ * aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to read from.\r
+ * \param Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * Endpoint_ClearCurrentBank() macro. Between each USB packet, the given stream callback function\r
+ * is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early\r
+ * aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to read from.\r
+ * \param Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the Endpoint_ClearCurrentBank() macro. Between\r
+ * each USB packet, the given stream callback function is executed repeatedly until the endpoint\r
+ * is ready to accept the next packet, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param Buffer Pointer to the destination data buffer to write to.\r
+ * \param Length Number of bytes to send via the currently selected endpoint.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the Endpoint_ClearCurrentBank() macro. Between\r
+ * each USB packet, the given stream callback function is executed repeatedly until the endpoint\r
+ * is ready to accept the next packet, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param Buffer Pointer to the destination data buffer to write to.\r
+ * \param Length Number of bytes to send via the currently selected endpoint.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The host OUT acknowedgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the setup OUT to\r
+ * finalize the transfer via the Endpoint_ClearSetupOUT() macro.\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to read from.\r
+ * \param Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The host OUT acknowedgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the setup OUT to\r
+ * finalize the transfer via the Endpoint_ClearSetupOUT() macro.\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to read from.\r
+ * \param Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowedgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro.\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param Buffer Pointer to the destination data buffer to write to.\r
+ * \param Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowedgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * setup IN to finalize the transfer via the Endpoint_ClearSetupIN() macro.\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param Buffer Pointer to the destination data buffer to write to.\r
+ * \param Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /* Function Aliases: */\r
+ /** Alias for Endpoint_Discard_Byte().\r
+ */\r
+ #define Endpoint_Ignore_Byte() Endpoint_Discard_Byte()\r
+\r
+ /** Alias for Endpoint_Discard_Word().\r
+ */\r
+ #define Endpoint_Ignore_Word() Endpoint_Discard_Word() \r
+\r
+ /** Alias for Endpoint_Discard_DWord().\r
+ */\r
+ #define Endpoint_Ignore_DWord() Endpoint_Discard_DWord()\r
+ \r
+ /** Alias for Endpoint_Read_Word_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Endpoint_Read_Word() Endpoint_Read_Word_LE() \r
+\r
+ /** Alias for Endpoint_Write_Word_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Endpoint_Write_Word(Word) Endpoint_Write_Word_LE(Word)\r
+\r
+ /** Alias for Endpoint_Read_DWord_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Endpoint_Read_DWord() Endpoint_Read_DWord_LE()\r
+\r
+ /** Alias for Endpoint_Write_DWord_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Endpoint_Write_DWord(DWord) Endpoint_Write_DWord_LE(DWord)\r
+\r
+ /** Alias for Endpoint_Read_Stream_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ #define Endpoint_Read_Stream(Buffer, Length, Callback) Endpoint_Read_Stream_LE(Buffer, Length, Callback)\r
+ #else\r
+ #define Endpoint_Read_Stream(Buffer, Length) Endpoint_Read_Stream_LE(Buffer, Length)\r
+ #endif\r
+\r
+ /** Alias for Endpoint_Write_Stream_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ #define Endpoint_Write_Stream(Buffer, Length, Callback) Endpoint_Write_Stream_LE(Buffer, Length, Callback)\r
+ #else\r
+ #define Endpoint_Write_Stream(Buffer, Length) Endpoint_Write_Stream_LE(Buffer, Length)\r
+ #endif\r
+\r
+ /** Alias for Endpoint_Read_Control_Stream_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Endpoint_Read_Control_Stream(Data, Length) Endpoint_Read_Control_Stream_LE(Data, Length)\r
+\r
+ /** Alias for Endpoint_Write_Control_Stream_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Endpoint_Write_Control_Stream(Data, Length) Endpoint_Write_Control_Stream_LE(Data, Length) \r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define Endpoint_AllocateMemory() MACROS{ UECFG1X |= (1 << ALLOC); }MACROE\r
+ #define Endpoint_DeallocateMemory() MACROS{ UECFG1X &= ~(1 << ALLOC); }MACROE\r
+ \r
+ #define _ENDPOINT_GET_MAXSIZE(n) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## n)\r
+ #define _ENDPOINT_GET_MAXSIZE2(details) _ENDPOINT_GET_MAXSIZE3(details)\r
+ #define _ENDPOINT_GET_MAXSIZE3(maxsize, db) maxsize\r
+\r
+ #define _ENDPOINT_GET_DOUBLEBANK(n) _ENDPOINT_GET_DOUBLEBANK2(ENDPOINT_DETAILS_EP ## n)\r
+ #define _ENDPOINT_GET_DOUBLEBANK2(details) _ENDPOINT_GET_DOUBLEBANK3(details)\r
+ #define _ENDPOINT_GET_DOUBLEBANK3(maxsize, db) db\r
+ \r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ #define ENDPOINT_DETAILS_EP0 64, true\r
+ #define ENDPOINT_DETAILS_EP1 256, true\r
+ #define ENDPOINT_DETAILS_EP2 64, true\r
+ #define ENDPOINT_DETAILS_EP3 64, true\r
+ #define ENDPOINT_DETAILS_EP4 64, true\r
+ #define ENDPOINT_DETAILS_EP5 64, true\r
+ #define ENDPOINT_DETAILS_EP6 64, true\r
+ #else\r
+ #define ENDPOINT_DETAILS_EP0 64, true\r
+ #define ENDPOINT_DETAILS_EP1 64, false\r
+ #define ENDPOINT_DETAILS_EP2 64, false\r
+ #define ENDPOINT_DETAILS_EP3 64, true\r
+ #define ENDPOINT_DETAILS_EP4 64, true \r
+ #endif\r
+\r
+ #if defined(STATIC_ENDPOINT_CONFIGURATION)\r
+ #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \\r
+ Endpoint_ConfigureEndpointStatic(Number, \\r
+ ((Type << EPTYPE0) | Direction), \\r
+ ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size)));\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ void Endpoint_ClearEndpoints(void);\r
+ bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData);\r
+ \r
+ /* Inline Functions: */\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYSINLINE;\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ if (Bytes <= 8)\r
+ return (0 << EPSIZE0);\r
+ else if (Bytes <= 16)\r
+ return (1 << EPSIZE0);\r
+ else if (Bytes <= 32)\r
+ return (2 << EPSIZE0);\r
+ #if defined(USB_LIMITED_CONTROLLER)\r
+ else\r
+ return (3 << EPSIZE0);\r
+ #else\r
+ else if (Bytes <= 64)\r
+ return (3 << EPSIZE0);\r
+ else if (Bytes <= 128)\r
+ return (4 << EPSIZE0);\r
+ else\r
+ return (5 << EPSIZE0);\r
+ #endif\r
+ };\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "USBMode.h"\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#include "Host.h"\r
+\r
+uint8_t USB_Host_WaitMS(uint8_t MS)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+ uint8_t ErrorCode = HOST_WAITERROR_Successful;\r
+ \r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ USB_Host_ResumeBus();\r
+\r
+ while (MS)\r
+ {\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ MS--;\r
+ }\r
+ \r
+ if ((USB_IsConnected == false) || (USB_CurrentMode == USB_MODE_DEVICE))\r
+ {\r
+ ErrorCode = HOST_WAITERROR_DeviceDisconnect;\r
+ \r
+ break;\r
+ }\r
+\r
+ if (Pipe_IsError() == true)\r
+ {\r
+ Pipe_ClearError();\r
+ ErrorCode = HOST_WAITERROR_PipeError;\r
+ \r
+ break;\r
+ }\r
+ \r
+ if (Pipe_IsStalled() == true)\r
+ {\r
+ Pipe_ClearStall();\r
+ ErrorCode = HOST_WAITERROR_SetupStalled;\r
+ \r
+ break; \r
+ }\r
+ }\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+void USB_Host_ResetDevice(void)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+\r
+ USB_INT_Disable(USB_INT_DDISCI);\r
+ \r
+ USB_Host_ResetBus();\r
+ while (!(USB_Host_IsResetBusDone()));\r
+\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ USB_Host_ResumeBus(); \r
+ \r
+ for (uint8_t MSRem = 10; MSRem != 0; MSRem--)\r
+ {\r
+ /* Workaround for powerless-pullup devices. After a USB bus reset,\r
+ all disconnection interrupts are supressed while a USB frame is\r
+ looked for - if it is found within 10ms, the device is still\r
+ present. */\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ break;\r
+ }\r
+ \r
+ _delay_ms(1);\r
+ }\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+}\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * USB Host mode related macros and enums. This module contains macros and enums which are used when\r
+ * the USB controller is initialized in host mode.\r
+ */\r
+\r
+#ifndef __USBHOST_H__\r
+#define __USBHOST_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ #include <util/delay.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+ #include "../HighLevel/USBInterrupt.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates the fixed USB device address which any attached device is enumerated to when in\r
+ * host mode. As only one USB device may be attached to the AVR in host mode at any one time\r
+ * and that the address used is not important (other than the fact that it is non-zero), a\r
+ * fixed value is specified by the library.\r
+ */\r
+ #define USB_HOST_DEVICEADDRESS 1\r
+\r
+ #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the maximum software timeout period of sent USB control transactions to an attached\r
+ * device. If a device fails to respond to a sent control request within this period, the\r
+ * library will return a timeout error code.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the \r
+ * USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define USB_HOST_TIMEOUT_MS 1000\r
+ #endif\r
+ \r
+ #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the delay in milliseconds after a device is connected before the library\r
+ * will start the enumeration process. Some devices require a delay of up to 5 seconds\r
+ * after connection before the enumeration process can start or incorrect operation will\r
+ * occur.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the \r
+ * HOST_DEVICE_SETTLE_DELAY_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define HOST_DEVICE_SETTLE_DELAY_MS 1500\r
+ #endif\r
+ \r
+ /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.\r
+ * USB bus resets leave the default control pipe configured (if already configured).\r
+ *\r
+ * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be\r
+ * woken up automatically and the bus resumed after the reset has been correctly issued.\r
+ */\r
+ #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE\r
+\r
+ /** Determines if a previously issued bus reset (via the USB_Host_ResetBus() macro) has\r
+ * completed. This macro returns true if no bus reset is currently being sent, false\r
+ * otherwise.\r
+ */\r
+ #define USB_Host_IsResetBusDone() ((UHCON & (1 << RESET)) ? false : true)\r
+ \r
+ /** Resumes USB communications with an attached and enumerated device, by resuming the transmission\r
+ * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the\r
+ * host and attached device may occur.\r
+ */\r
+ #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE \r
+\r
+ /** Suspends the USB bus, preventing any communications from occuring between the host and attached\r
+ * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame\r
+ * messages to the device.\r
+ */\r
+ #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE \r
+ \r
+ /** Returns true if the USB bus has been suspended via the use of the USB_Host_SuspendBus() macro,\r
+ * false otherwise. While suspended, no USB communications can occur until the bus is resumed,\r
+ * except for the Remote Wakeup event from the device if supported.\r
+ */\r
+ #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)\r
+ \r
+ /** Returns true if the attached device is currently enumerated in Full Speed mode (12Mb/s), or\r
+ * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).\r
+ */\r
+ #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)\r
+\r
+ /** Returns true if the attached device is currently issuing a Remote Wakeup request, requesting\r
+ * that the host resume the USB bus and wake up the device, false otherwise.\r
+ */\r
+ #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)\r
+\r
+ /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached\r
+ * device.\r
+ */\r
+ #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE\r
+\r
+ /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to\r
+ * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to\r
+ * be resumed.\r
+ */\r
+ #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE\r
+ \r
+ /** Returns true if no resume from Remote Wakeup request is currently being sent to an attached\r
+ * device, false otherwise.\r
+ */\r
+ #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)\r
+\r
+ /* Enums: */\r
+ /** Enum for the various states of the USB Host state machine. Only some states are\r
+ * implemented in the LUFA library - other states are left to the user to implement.\r
+ *\r
+ * For information on each state, refer to the USB 2.0 specification. Some states have\r
+ *\r
+ * \see USBTask.h for information on the global variable USB_HostState, which stores the\r
+ * current host state machine state.\r
+ */\r
+ enum USB_Host_States_t\r
+ {\r
+ HOST_STATE_WaitForDevice = 0, /**< Internally implemented by the library. */\r
+ HOST_STATE_Unattached = 1, /**< Internally implemented by the library. */\r
+ HOST_STATE_Attached = 2, /**< Internally implemented by the library. */\r
+ HOST_STATE_Attached_WaitForDeviceSettle = 3, /**< Internally implemented by the library. */\r
+ HOST_STATE_Attached_WaitForConnect = 4, /**< Internally implemented by the library. */\r
+ HOST_STATE_Attached_DoReset = 5, /**< Internally implemented by the library. */\r
+ HOST_STATE_Powered = 6, /**< Internally implemented by the library. */\r
+ HOST_STATE_Default = 7, /**< Internally implemented by the library. */\r
+ HOST_STATE_Default_PostReset = 8, /**< Internally implemented by the library. */\r
+ HOST_STATE_Default_PostAddressSet = 9, /**< Internally implemented by the library. */\r
+ HOST_STATE_Addressed = 10, /**< May be implemented by the user project. */\r
+ HOST_STATE_Configured = 11, /**< May be implemented by the user project. */\r
+ HOST_STATE_Ready = 12, /**< May be implemented by the user project. */\r
+ HOST_STATE_Suspended = 13, /**< May be implemented by the user project. */\r
+ };\r
+ \r
+ /** Enum for the error codes for the USB_HostError event.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ enum USB_Host_ErrorCodes_t\r
+ {\r
+ HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This\r
+ * error may be the result of an attached device drawing\r
+ * too much current from the VBUS line, or due to the\r
+ * AVR's power source being unable to supply sufficient\r
+ * current.\r
+ */\r
+ };\r
+ \r
+ /** Enum for the error codes for the USB_DeviceEnumerationFailed event.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ enum USB_Host_EnumerationErrorCodes_t\r
+ {\r
+ HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid\r
+ * ErrorCode parameter value for the USB_DeviceEnumerationFailed\r
+ * event.\r
+ */\r
+ HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed\r
+ * to complete successfuly, due to a timeout or other\r
+ * error.\r
+ */\r
+ HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines\r
+ * indicating the attachment of a device.\r
+ */\r
+ HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to\r
+ * complete successfuly.\r
+ */\r
+ HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to\r
+ * configure correctly.\r
+ */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE\r
+ #define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE\r
+\r
+ #define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE\r
+ #define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
+\r
+ #define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE\r
+ #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE\r
+\r
+ #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE\r
+ #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE\r
+\r
+ #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = (addr & 0b01111111); }MACROE\r
+\r
+ /* Enums: */\r
+ enum USB_Host_WaitMSErrorCodes_t\r
+ {\r
+ HOST_WAITERROR_Successful = 0,\r
+ HOST_WAITERROR_DeviceDisconnect = 1,\r
+ HOST_WAITERROR_PipeError = 2,\r
+ HOST_WAITERROR_SetupStalled = 3,\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ uint8_t USB_Host_WaitMS(uint8_t MS);\r
+ void USB_Host_ResetDevice(void);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "USBMode.h"\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define INCLUDE_FROM_HOSTCHAPTER9_C\r
+#include "HostChapter9.h"\r
+\r
+USB_Host_Request_Header_t USB_HostRequest;\r
+\r
+uint8_t USB_Host_SendControlRequest(void* BufferPtr)\r
+{\r
+ uint8_t* HeaderStream = (uint8_t*)&USB_HostRequest;\r
+ uint8_t* DataStream = (uint8_t*)BufferPtr;\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+ uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;\r
+ uint16_t DataLen = USB_HostRequest.wLength;\r
+\r
+ USB_Host_ResumeBus();\r
+ \r
+ if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ return ReturnStatus;\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ Pipe_SetToken(PIPE_TOKEN_SETUP);\r
+ Pipe_ClearErrorFlags();\r
+ Pipe_ClearSetupSent();\r
+\r
+ Pipe_Unfreeze();\r
+\r
+ for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Host_Request_Header_t); HeaderByte++)\r
+ Pipe_Write_Byte(*(HeaderStream++));\r
+\r
+ Pipe_ClearSetupOUT();\r
+ \r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_SetupSent)))\r
+ goto End_Of_Control_Send;\r
+\r
+ Pipe_ClearSetupSent();\r
+ Pipe_Freeze();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ goto End_Of_Control_Send;\r
+\r
+ if ((USB_HostRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST)\r
+ {\r
+ Pipe_SetToken(PIPE_TOKEN_IN);\r
+ \r
+ if (DataStream != NULL)\r
+ {\r
+ while (DataLen)\r
+ {\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived)))\r
+ goto End_Of_Control_Send;\r
+ \r
+ if (!(Pipe_BytesInPipe()))\r
+ DataLen = 0;\r
+ \r
+ while (Pipe_BytesInPipe() && DataLen)\r
+ {\r
+ *(DataStream++) = Pipe_Read_Byte();\r
+ DataLen--;\r
+ }\r
+\r
+ Pipe_Freeze();\r
+ Pipe_ClearSetupIN();\r
+ }\r
+ }\r
+\r
+ Pipe_SetToken(PIPE_TOKEN_OUT);\r
+ Pipe_Unfreeze();\r
+ \r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))\r
+ goto End_Of_Control_Send;\r
+\r
+ Pipe_ClearSetupOUT();\r
+\r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))\r
+ goto End_Of_Control_Send;\r
+ }\r
+ else\r
+ {\r
+ if (DataStream != NULL)\r
+ {\r
+ Pipe_SetToken(PIPE_TOKEN_OUT);\r
+ Pipe_Unfreeze(); \r
+\r
+ while (DataLen)\r
+ {\r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))\r
+ goto End_Of_Control_Send;\r
+\r
+ while (DataLen && (Pipe_BytesInPipe() < USB_ControlPipeSize))\r
+ { \r
+ Pipe_Write_Byte(*(DataStream++));\r
+ DataLen--;\r
+ }\r
+ \r
+ Pipe_ClearSetupOUT();\r
+ }\r
+\r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))\r
+ goto End_Of_Control_Send;\r
+\r
+ Pipe_Freeze();\r
+ }\r
+ \r
+ Pipe_SetToken(PIPE_TOKEN_IN);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived)))\r
+ goto End_Of_Control_Send;\r
+\r
+ Pipe_ClearSetupIN();\r
+ }\r
+\r
+End_Of_Control_Send:\r
+ Pipe_Freeze();\r
+ \r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ Pipe_ResetPipe(PIPE_CONTROLPIPE);\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType)\r
+{\r
+ uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS;\r
+ \r
+ while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSetupSent()) ||\r
+ ((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsSetupINReceived()) ||\r
+ ((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsSetupOUTReady())))\r
+ {\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ return ErrorCode;\r
+ \r
+ if (!(TimeoutCounter--))\r
+ return HOST_SENDCONTROL_SoftwareTimeOut;\r
+ }\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Module for host mode request processing. This module allows for the transmission of standard, class and\r
+ * vendor control requests to the default control endpoint of an attached device while in host mode.\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 specification.\r
+ */\r
+\r
+#ifndef __HOSTCHAPTER9_H__\r
+#define __HOSTCHAPTER9_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include "LowLevel.h"\r
+ #include "StdRequestType.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** Type define for a standard USB control request.\r
+ *\r
+ * \see StdRequestType.h for information on the request type and data.\r
+ * \see The USB 2.0 specification for more information on standard control requests.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bmRequestType; /**< Type of the request. */\r
+ uint8_t bRequest; /**< Request command code. */\r
+ uint16_t wValue; /**< wValue parameter of the request. */\r
+ uint16_t wIndex; /**< wIndex parameter of the request. */\r
+ uint16_t wLength; /**< Length of the data to transfer in bytes. */\r
+ } USB_Host_Request_Header_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the USB_Host_SendControlRequest() return code, indicating the reason for the error\r
+ * if the transfer of the request is unsuccessful.\r
+ */\r
+ enum USB_Host_SendControlErrorCodes_t\r
+ {\r
+ HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */\r
+ HOST_SENDCONTROL_DeviceDisconnect = 1, /**< The attached device was disconnected during the\r
+ * request transfer.\r
+ */\r
+ HOST_SENDCONTROL_PipeError = 2, /**< An error occured in the pipe while sending the request. */\r
+ HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually\r
+ * indicating that the request is unsupported on the device.\r
+ */\r
+ HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */\r
+ };\r
+ \r
+ /* Global Variables: */\r
+ /** Global for the request to send via the USB_Host_SendControlRequest() function. This\r
+ * global should be filled with the correct control request data before sending the request to\r
+ * the attached device while in host mode.\r
+ */\r
+ extern USB_Host_Request_Header_t USB_HostRequest;\r
+ \r
+ /* Function Prototypes: */\r
+ /** Sends the request stored in the USB_HostRequest global structure to the attached device,\r
+ * and transfers the data stored in the buffer to the device, or from the device to the buffer\r
+ * as requested.\r
+ *\r
+ * \param BufferPtr Pointer to the start of the data buffer if the request has a data stage, or\r
+ * NULL if the request transfers no data to or from the device.\r
+ *\r
+ * \return A value from the USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_SendControlRequest(void* BufferPtr);\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Enums: */\r
+ enum USB_WaitForTypes_t\r
+ {\r
+ USB_HOST_WAITFOR_SetupSent,\r
+ USB_HOST_WAITFOR_InReceived,\r
+ USB_HOST_WAITFOR_OutReady,\r
+ };\r
+ \r
+ /* Function Prototypes: */\r
+ #if defined(INCLUDE_FROM_HOSTCHAPTER9_C)\r
+ static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "USBMode.h"\r
+\r
+#include "LowLevel.h"\r
+\r
+#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))\r
+volatile uint8_t USB_CurrentMode = USB_MODE_NONE;\r
+#endif\r
+\r
+#if !defined(USE_STATIC_OPTIONS)\r
+volatile uint8_t USB_Options;\r
+#endif\r
+\r
+void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+ \r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ const uint8_t Options\r
+ #endif\r
+ )\r
+{\r
+ USB_ShutDown();\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ USB_CurrentMode = Mode;\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ USB_Options = Options;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+ #endif\r
+ \r
+ #if defined(USB_DEVICE_ONLY) && defined(USB_FULL_CONTROLLER)\r
+ UHWCON |= (1 << UIMOD);\r
+ #elif defined(USB_HOST_ONLY)\r
+ UHWCON &= ~(1 << UIMOD);\r
+ #elif defined(USB_CAN_BE_BOTH)\r
+ if (Mode == USB_MODE_UID)\r
+ {\r
+ UHWCON |= (1 << UIDE);\r
+\r
+ USB_INT_Clear(USB_INT_IDTI);\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ \r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ }\r
+ else if (Mode == USB_MODE_DEVICE)\r
+ {\r
+ UHWCON |= (1 << UIMOD);\r
+ }\r
+ else if (Mode == USB_MODE_HOST) \r
+ {\r
+ UHWCON &= ~(1 << UIMOD);\r
+ }\r
+ else\r
+ {\r
+ RAISE_EVENT(USB_PowerOnFail, POWERON_ERROR_NoUSBModeSpecified);\r
+ return;\r
+ }\r
+ #endif\r
+ \r
+ USB_ResetInterface();\r
+\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ USB_OTGPAD_On();\r
+ #endif\r
+\r
+ USB_IsInitialized = true;\r
+\r
+ sei();\r
+}\r
+\r
+void USB_ShutDown(void)\r
+{\r
+ if (USB_IsConnected)\r
+ RAISE_EVENT(USB_Disconnect);\r
+\r
+ USB_Detach();\r
+\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_IsConnected = false;\r
+ USB_IsInitialized = false;\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ USB_ConfigurationNumber = 0;\r
+ #endif\r
+\r
+ #if defined(CAN_BE_BOTH)\r
+ USB_CurrentMode = USB_MODE_NONE;\r
+ #endif\r
+\r
+ USB_Interface_Disable();\r
+ USB_PLL_Off();\r
+ \r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ USB_OTGPAD_Off();\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ UHWCON &= ~(1 << UIDE);\r
+ #endif\r
+}\r
+\r
+void USB_ResetInterface(void)\r
+{\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_IsConnected = false;\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ USB_ConfigurationNumber = 0;\r
+ USB_IsSuspended = false;\r
+ USB_RemoteWakeupEnabled = false;\r
+ USB_CurrentlySelfPowered = false;\r
+ #endif\r
+ \r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ #if defined(USB_MODIFIED_FULL_CONTROLLER)\r
+ PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));\r
+ #endif\r
+\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ }\r
+ \r
+ USB_Interface_Reset();\r
+ \r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (UHWCON & (1 << UIDE))\r
+ {\r
+ USB_INT_Clear(USB_INT_IDTI);\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ }\r
+ #endif\r
+ \r
+ if (!(USB_Options & USB_OPT_REG_DISABLED))\r
+ USB_REG_On();\r
+ \r
+ USB_CLK_Unfreeze();\r
+\r
+ #if (defined(USB_CAN_BE_DEVICE) && (defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)))\r
+ if (USB_CurrentMode == USB_MODE_DEVICE)\r
+ {\r
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
+ USB_Device_SetLowSpeed();\r
+ else\r
+ USB_Device_SetHighSpeed();\r
+ \r
+ USB_INT_Enable(USB_INT_VBUS);\r
+ }\r
+ #endif\r
+ \r
+ #if (defined(USB_CAN_BE_DEVICE) && !defined(FIXED_CONTROL_ENDPOINT_SIZE))\r
+ if (USB_CurrentMode == USB_MODE_DEVICE)\r
+ {\r
+ USB_Descriptor_Device_t* DeviceDescriptorPtr;\r
+\r
+ if (USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)\r
+ { \r
+ #if defined(USE_RAM_DESCRIPTORS)\r
+ USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;\r
+ #elif defined(USE_EEPROM_DESCRIPTORS)\r
+ USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ #else\r
+ USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ #endif\r
+ }\r
+ }\r
+ #endif\r
+\r
+ USB_Attach();\r
+ \r
+ #if defined(USB_DEVICE_ONLY) \r
+ USB_INT_Enable(USB_INT_SUSPEND);\r
+ USB_INT_Enable(USB_INT_EORSTI); \r
+ #elif defined(USB_HOST_ONLY)\r
+ USB_Host_HostMode_On();\r
+ \r
+ USB_Host_VBUS_Auto_Off();\r
+ USB_OTGPAD_Off();\r
+\r
+ USB_Host_VBUS_Manual_Enable();\r
+ USB_Host_VBUS_Manual_On();\r
+ \r
+ USB_INT_Enable(USB_INT_SRPI);\r
+ USB_INT_Enable(USB_INT_BCERRI);\r
+ #else\r
+ if (USB_CurrentMode == USB_MODE_DEVICE)\r
+ {\r
+ USB_INT_Enable(USB_INT_SUSPEND);\r
+ USB_INT_Enable(USB_INT_EORSTI);\r
+ }\r
+ else if (USB_CurrentMode == USB_MODE_HOST)\r
+ {\r
+ USB_Host_HostMode_On();\r
+ \r
+ USB_Host_VBUS_Auto_Off();\r
+ USB_OTGPAD_Off();\r
+\r
+ USB_Host_VBUS_Manual_Enable();\r
+ USB_Host_VBUS_Manual_On();\r
+ \r
+ USB_INT_Enable(USB_INT_SRPI);\r
+ USB_INT_Enable(USB_INT_BCERRI);\r
+ }\r
+ #endif\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Main low level USB driver. This module manages the low level initialization and shut down of the USB AVR's\r
+ * USB interface in either device or (if supported) host mode.\r
+ */\r
+\r
+#ifndef __USBLOWLEVEL_H__\r
+#define __USBLOWLEVEL_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <avr/interrupt.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include "USBMode.h"\r
+ #include "../../../Common/Common.h"\r
+ #include "../HighLevel/Events.h"\r
+ #include "../HighLevel/USBTask.h"\r
+ #include "../HighLevel/USBInterrupt.h"\r
+ \r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #include "Host.h"\r
+ #include "Pipe.h"\r
+ #include "OTG.h"\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "Device.h"\r
+ #include "Endpoint.h"\r
+ #include "DevChapter9.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks and Defines: */\r
+ #if (F_CPU == 8000000)\r
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))\r
+ #define USB_PLL_PSC 0\r
+ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || \\r
+ defined(__AVR_ATmega32U6__))\r
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_PLL_PSC 0\r
+ #endif\r
+ #elif (F_CPU == 16000000)\r
+ #if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))\r
+ #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))\r
+ #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))\r
+ #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))\r
+ #elif (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))\r
+ #define USB_PLL_PSC (1 << PLLP0)\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_PLL_PSC (1 << PINDIV)\r
+ #endif\r
+ #endif\r
+ \r
+ #if !defined(USB_PLL_PSC)\r
+ #error No PLL prescale value available for chosen F_CPU value and AVR model.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mode mask for the USB_CurrentMode global. This indicates that the USB interface is currently not\r
+ * initialized into any mode.\r
+ */\r
+ #define USB_MODE_NONE 0\r
+\r
+ /** Mode mask for the USB_CurrentMode global and the USB_Init() function. This indicates that the\r
+ * USB interface is or should be initialized in the USB device mode.\r
+ */\r
+ #define USB_MODE_DEVICE 1\r
+\r
+ /** Mode mask for the USB_CurrentMode global and the USB_Init() function. This indicates that the\r
+ * USB interface is or should be initialized in the USB host mode.\r
+ *\r
+ * \note Not all USB AVRs support host mode.\r
+ */\r
+ #define USB_MODE_HOST 2\r
+\r
+ /** Mode mask for the the USB_Init() function. This indicates that the USB interface should be\r
+ * initialized into whatever mode the UID pin of the USB AVR indicates, and that the device\r
+ * should swap over its mode when the level of the UID pin changes during operation.\r
+ *\r
+ * \note Not all USB AVRs support host mode, and thus UID mode.\r
+ */\r
+ #define USB_MODE_UID 3\r
+ \r
+ /** Regulator disable option mask for USB_Init(). This indicates that the internal 3.3V USB data pad\r
+ * regulator should be enabled to regulate the data pin voltages to within the USB standard.\r
+ *\r
+ * \note See USB AVR data sheet for more information on the internal pad regulator.\r
+ */\r
+ #define USB_OPT_REG_DISABLED (1 << 1)\r
+\r
+ /** Regulator enable option mask for USB_Init(). This indicates that the internal 3.3V USB data pad\r
+ * regulator should be disabled and the AVR's VCC level used for the data pads.\r
+ *\r
+ * \note See USB AVR data sheet for more information on the internal pad regulator.\r
+ */\r
+ #define USB_OPT_REG_ENABLED (0 << 1)\r
+ \r
+ /** Manual PLL control option mask for USB_Init(). This indicates to the library that the user application\r
+ * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock\r
+ * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.\r
+ */\r
+ #define USB_OPT_MANUAL_PLL (1 << 2)\r
+\r
+ /** Automatic PLL control option mask for USB_Init(). This indicates to the library that the library should\r
+ * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock\r
+ * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.\r
+ */\r
+ #define USB_OPT_AUTO_PLL (0 << 2)\r
+\r
+ /** Mask for a CONTROL type endpoint or pipe.\r
+ *\r
+ * \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_CONTROL 0b00\r
+\r
+ /** Mask for an ISOCHRONOUS type endpoint or pipe.\r
+ *\r
+ * \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_ISOCHRONOUS 0b01\r
+\r
+ /** Mask for a BULK type endpoint or pipe.\r
+ *\r
+ * \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_BULK 0b10\r
+\r
+ /** Mask for an INTERRUPT type endpoint or pipe.\r
+ *\r
+ * \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_INTERRUPT 0b11\r
+\r
+ /** Mask for determining the type of an endpoint or pipe. This should then be compared with the\r
+ * EP_TYPE_* macros elsewhere in this module to determine the exact type of the endpoint or pipe.\r
+ *\r
+ * \note See Endpoint.h and Pipe.h headers for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_MASK 0b11\r
+\r
+ /** Returns boolean true if the VBUS line is currently high (i.e. the USB host is supplying power),\r
+ * otherwise returns false.\r
+ */\r
+ #define USB_VBUS_GetStatus() ((USBSTA & (1 << VBUS)) ? true : false)\r
+\r
+ /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
+ * host if, ceasing USB communications. If no host is present, this prevents any host from\r
+ * enumerating the device once attached until USB_Attach() is called.\r
+ */\r
+ #define USB_Detach() MACROS{ UDCON |= (1 << DETACH); }MACROE\r
+\r
+ /** Attaches the device to the USB bus. This announces the device's presence to any attached\r
+ * USB host, starting the enumeration process. If no host is present, attaching the device\r
+ * will allow for enumeration once a host is connected to the device.\r
+ *\r
+ * This is inexplicably also required for proper operation while in host mode, to enable the\r
+ * attachment of a device to the host. This is despite the bit being located in the device-mode\r
+ * register and despite the datasheet making no mention of its requirement in host mode.\r
+ */\r
+ #define USB_Attach() MACROS{ UDCON &= ~(1 << DETACH); }MACROE\r
+ \r
+ #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the maximum software timeout period of the USB data stream transfer functions\r
+ * (both control and standard) when in either device or host mode. If the next packet of a stream\r
+ * is not received or acknowedged within this time period, the stream function will fail.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the \r
+ * USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define USB_STREAM_TIMEOUT_MS 100\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Main function to initialize and start the USB interface. Once active, the USB interface will\r
+ * allow for device connection to a host when in device mode, or for device enumeration while in\r
+ * host mode.\r
+ *\r
+ * As the USB library relies on USB interrupts for some of its functionality, this routine will\r
+ * enable global interrupts.\r
+ *\r
+ * Calling this function when the USB interface is already initialized will cause a complete USB\r
+ * interface reset and re-enumeration.\r
+ *\r
+ * \param Mode This is a mask indicating what mode the USB interface is to be initialized to.\r
+ * Valid mode masks are USB_MODE_DEVICE, USB_MODE_HOST or USB_MODE_UID.\r
+ *\r
+ * \param Options Mask indicating the options which should be used when initializing the USB\r
+ * interface to control the USB interface's behaviour. This should be comprised of\r
+ * a USB_OPT_REG_* mask to control the regulator, a USB_OPT_*_PLL mask to control the\r
+ * PLL, and a USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device\r
+ * mode speed.\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only device or host mode is required, \r
+ * this can be statically set via defining the token USB_DEVICE_ONLY for device mode or \r
+ * USB_HOST_ONLY for host mode in the use project makefile, passing the token to the compiler \r
+ * via the -D switch. If the mode is statically set, this parameter does not exist in the\r
+ * function prototype.\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only fixed settings are are required,\r
+ * the options may be set statically in the same manner as the mode (see the Mode parameter of \r
+ * this function). To statically set the USB options, pass in the USE_STATIC_OPTIONS token,\r
+ * defined to the appropriate options masks. When the options are statically set, this\r
+ * parameter does not exist in the function prototype.\r
+ * \r
+ * \note The mode parameter does not exist on devices where only one mode is possible, such as USB \r
+ * AVR models which only implement the USB device mode in hardware.\r
+ *\r
+ * \see Device.h for the USB_DEVICE_OPT_* masks.\r
+ */\r
+ void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+ \r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ const uint8_t Options\r
+ #endif\r
+ );\r
+ \r
+ /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO\r
+ * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface\r
+ * is restarted with the USB_Init() function.\r
+ */\r
+ void USB_ShutDown(void);\r
+\r
+ /** Resets the interface, when already initialized. This will re-enumerate the device if already connected\r
+ * to a host, or re-enumerate an already attached device when in host mode.\r
+ */\r
+ void USB_ResetInterface(void);\r
+\r
+ /* Enums: */\r
+ /** Enum for error codes relating to the powering on of the USB interface. These error codes are\r
+ * used in the ErrorCode parameter value of the USB_PowerOnFail event.\r
+ */\r
+ enum USB_PowerOnErrorCodes_t\r
+ {\r
+ POWERON_ERROR_NoUSBModeSpecified = 0, /**< Indicates that USB_Init() was called with an\r
+ * invalid or missing Mode parameter.\r
+ */\r
+ };\r
+\r
+ /* Global Variables: */\r
+ #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)\r
+ /** Indicates the mode that the USB interface is currently initialized to. This value will be\r
+ * one of the USB_MODE_* masks defined elsewhere in this module.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern volatile uint8_t USB_CurrentMode;\r
+ #endif\r
+ \r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ extern volatile uint8_t USB_Options;\r
+ /** Indicates the current USB options that the USB interface was initialized with when USB_Init()\r
+ * was called. This value will be one of the USB_MODE_* masks defined elsewhere in this module.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ #endif\r
+\r
+ /* Throwable Events: */\r
+ /** This module raises the USB_Disconnect event if the USB interface is reset (such as during a mode\r
+ * change while in UID mode) while the USB interface is connected to a device when in host mode, or\r
+ * a host while in device mode.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_Disconnect);\r
+ \r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ /** This module raises the Power On Failure event when an error occurs while initializing the USB\r
+ * interface.\r
+ *\r
+ * \see Events.h for more information on this event.\r
+ */\r
+ RAISES_EVENT(USB_PowerOnFail);\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define USB_PLL_On() MACROS{ PLLCSR = USB_PLL_PSC; PLLCSR |= (1 << PLLE); }MACROE\r
+ #define USB_PLL_Off() MACROS{ PLLCSR = 0; }MACROE\r
+ #define USB_PLL_IsReady() ((PLLCSR & (1 << PLOCK)) ? true : false)\r
+\r
+ #if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) \r
+ #define USB_REG_On() MACROS{ UHWCON |= (1 << UVREGE); }MACROE\r
+ #define USB_REG_Off() MACROS{ UHWCON &= ~(1 << UVREGE); }MACROE\r
+ #else\r
+ #define USB_REG_On() MACROS{ REGCR &= ~(1 << REGDIS); }MACROE\r
+ #define USB_REG_Off() MACROS{ REGCR |= (1 << REGDIS); }MACROE \r
+ #endif\r
+ \r
+ #define USB_OTGPAD_On() MACROS{ USBCON |= (1 << OTGPADE); }MACROE\r
+ #define USB_OTGPAD_Off() MACROS{ USBCON &= ~(1 << OTGPADE); }MACROE\r
+\r
+ #define USB_CLK_Freeze() MACROS{ USBCON |= (1 << FRZCLK); }MACROE\r
+ #define USB_CLK_Unfreeze() MACROS{ USBCON &= ~(1 << FRZCLK); }MACROE\r
+\r
+ #define USB_Interface_Enable() MACROS{ USBCON |= (1 << USBE); }MACROE\r
+ #define USB_Interface_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE\r
+ #define USB_Interface_Reset() MACROS{ uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \\r
+ USBCON = (Temp | (1 << USBE)); }MACROE\r
+ \r
+ /* Inline Functions: */ \r
+ static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t USB_GetUSBModeFromUID(void)\r
+ {\r
+ #if (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__))\r
+ if (USBSTA & (1 << ID))\r
+ return USB_MODE_DEVICE;\r
+ else\r
+ return USB_MODE_HOST;\r
+ #else\r
+ return USB_MODE_DEVICE;\r
+ #endif\r
+ }\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Macros for embedded USB hosts with dual role On The Go capabilities, for managing role exchange. OTG\r
+ * is a way for two USB dual role devices to talk to one another directly without fixed device/host roles.\r
+ *\r
+ * \note These macros are only for AVRs which support the OTG protocol, and do not exist for device-only AVRs.\r
+ */\r
+\r
+#ifndef __USBOTG_H__\r
+#define __USBOTG_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device\r
+ * that the device wishes to change device/host roles.\r
+ */\r
+ #define USB_OTG_DEV_Request_HNP() MACROS{ OTGCON |= (1 << HNPREQ); }MACROE\r
+\r
+ /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other\r
+ * connected device.\r
+ */\r
+ #define USB_OTG_DEV_Cancel_HNP_Request() MACROS{ OTGCON &= ~(1 << HNPREQ); }MACROE\r
+\r
+ /** Returns boolean false if not currently sending a HNP to the other connected device, or true\r
+ * if a HNP is currently being issued.\r
+ */\r
+ #define USB_OTG_DEV_IsSendingHNP() ((OTGCON & (1 << HNPREQ)) ? true : false)\r
+ \r
+ /** Accepts a HNP from a connected device, indicating that both devices should exchange\r
+ * device/host roles.\r
+ */\r
+ #define USB_OTG_HOST_Accept_HNP() USB_OTG_DEV_Request_HNP()\r
+\r
+ /** Rejects a HNP from a connected device, indicating that both devices should remain in their\r
+ * current device/host roles.\r
+ */\r
+ #define USB_OTG_HOST_Reject_HNP() USB_OTG_DEV_Cancel_HNP_Request()\r
+ \r
+ /** Returns boolean false if the connected device is not currently sending a HNP request, or true\r
+ * if a HNP is currently being issued by the connected device.\r
+ */\r
+ #define USB_OTG_HOST_IsHNPReceived() ((OTGCON & (1 << HNPREQ)) ? true : false)\r
+ \r
+ /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB\r
+ * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in\r
+ * host mode indicates that VBUS should be applied and a session started.\r
+ *\r
+ * There are two different methods of sending a SRP - either pulses on the VBUS line, or by\r
+ * pulsing the Data + line via the internal pullup resistor. The SRP mode is given as the\r
+ * "type" parameter, and can be either USB_OTG_SRP_VBUS or USB_OTG_STP_DATA.\r
+ */\r
+ #define USB_OTG_DEV_Initiate_SRP(type) MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE\r
+\r
+ /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.\r
+ *\r
+ * \see USB_OTG_DEV_Initiate_SRP()\r
+ */ \r
+ #define USB_OTG_SRP_VBUS (1 << SRPSEL)\r
+\r
+ /** Mask for the Data + pulsing method of SRP, supported by some OTG devices.\r
+ *\r
+ * \see USB_OTG_DEV_Initiate_SRP()\r
+ */ \r
+ #define USB_OTG_STP_DATA 0\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+#include "USBMode.h"\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define INCLUDE_FROM_PIPE_C\r
+#include "Pipe.h"\r
+\r
+uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+bool Pipe_ConfigurePipe(const uint8_t Number, const uint8_t Type, const uint8_t Token, const uint8_t EndpointNumber,\r
+ const uint16_t Size, const uint8_t Banks)\r
+{\r
+ Pipe_SelectPipe(Number);\r
+ Pipe_EnablePipe();\r
+\r
+ UPCFG1X = 0;\r
+ \r
+ UPCFG0X = ((Type << EPTYPE0) | Token | (EndpointNumber << PEPNUM0));\r
+ UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
+\r
+ return Pipe_IsConfigured();\r
+}\r
+\r
+void Pipe_ClearPipes(void)\r
+{\r
+ UPINT = 0;\r
+\r
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ Pipe_ResetPipe(PNum);\r
+ Pipe_SelectPipe(PNum);\r
+ UPIENX = 0;\r
+ UPINTX = 0;\r
+ Pipe_ClearError();\r
+ Pipe_ClearErrorFlags();\r
+ Pipe_DeallocateMemory();\r
+ Pipe_DisablePipe();\r
+ }\r
+}\r
+\r
+uint8_t Pipe_WaitUntilReady(void)\r
+{\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ while (!(Pipe_ReadWriteAllowed()))\r
+ {\r
+ if (Pipe_IsStalled())\r
+ return PIPE_READYWAIT_PipeStalled;\r
+ else if (!(USB_IsConnected))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+ \r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return PIPE_READYWAIT_Timeout;\r
+ }\r
+ }\r
+ \r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)Data;\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Pipe_ReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearCurrentBank();\r
+ \r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return PIPE_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Write_Byte(*(DataStream++));\r
+ }\r
+\r
+ return PIPE_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)(Data + Length - 1);\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Pipe_ReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearCurrentBank();\r
+ \r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return PIPE_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Write_Byte(*(DataStream--));\r
+ }\r
+\r
+ return PIPE_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Pipe_Discard_Stream(uint16_t Length\r
+#if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Pipe_ReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearCurrentBank();\r
+ \r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return PIPE_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Discard_Byte();\r
+ }\r
+\r
+ return PIPE_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)Buffer;\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Pipe_ReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearCurrentBank();\r
+ \r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return PIPE_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ \r
+ *(DataStream++) = Pipe_Read_Byte();\r
+ }\r
+\r
+ return PIPE_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ , uint8_t (* const Callback)(void)\r
+#endif\r
+ )\r
+{\r
+ uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
+ uint8_t ErrorCode;\r
+ \r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(Pipe_ReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearCurrentBank();\r
+ \r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+ return PIPE_RWSTREAM_ERROR_CallbackAborted;\r
+ #endif\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+\r
+ *(DataStream--) = Pipe_Read_Byte();\r
+ }\r
+ \r
+ return PIPE_RWSTREAM_ERROR_NoError;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Functions, macros and enums related to pipe management when in USB Host mode. This\r
+ * module contains the pipe management macros, as well as pipe interrupt and data\r
+ * send/recieve functions for various datatypes.\r
+ */\r
+ \r
+#ifndef __PIPE_H__\r
+#define __PIPE_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+\r
+ #include "../../../Common/Common.h"\r
+ #include "../HighLevel/USBTask.h"\r
+\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ #include "StreamCallbacks.h"\r
+ #endif\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_CRC16 (1 << 4)\r
+\r
+ /** Mask for Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)\r
+\r
+ /** Mask for Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_PID (1 << 2)\r
+\r
+ /** Mask for Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATAPID (1 << 1)\r
+\r
+ /** Mask for Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATATGL (1 << 0)\r
+\r
+ /** Token mask for Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes),\r
+ * which will trigger a control request on the attached device when data is written to the pipe.\r
+ */\r
+ #define PIPE_TOKEN_SETUP (0b00 << PTOKEN0)\r
+\r
+ /** Token mask for Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from device to host.\r
+ */\r
+ #define PIPE_TOKEN_IN (0b01 << PTOKEN0)\r
+\r
+ /** Token mask for Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from host to device.\r
+ */\r
+ #define PIPE_TOKEN_OUT (0b10 << PTOKEN0)\r
+\r
+ /** Mask for the bank mode selection for the Pipe_ConfigurePipe() macro. This indicates that the pipe\r
+ * should have one single bank, which requires less USB FIFO memory but results in slower transfers as\r
+ * only one USB device (the AVR or the attached device) can access the pipe's bank at the one time.\r
+ */\r
+ #define PIPE_BANK_SINGLE 0\r
+\r
+ /** Mask for the bank mode selection for the Pipe_ConfigurePipe() macro. This indicates that the pipe\r
+ * should have two banks, which requires more USB FIFO memory but results in faster transfers as one\r
+ * USB device (the AVR or the attached device) can access one bank while the other accesses the second\r
+ * bank.\r
+ */\r
+ #define PIPE_BANK_DOUBLE (1 << EPBK0)\r
+ \r
+ /** Pipe address for the default control pipe, which always resides in address 0. This is\r
+ * defined for convenience to give more readable code when used with the pipe macros.\r
+ */\r
+ #define PIPE_CONTROLPIPE 0\r
+\r
+ /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value \r
+ * in the device descriptor of the attached device.\r
+ */\r
+ #define PIPE_CONTROLPIPE_DEFAULT_SIZE 8\r
+ \r
+ /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address\r
+ * in the device.\r
+ */\r
+ #define PIPE_PIPENUM_MASK 0x07\r
+\r
+ /** Total number of pipes (including the default control pipe at address 0) which may be used in\r
+ * the device. Different USB AVR models support different amounts of pipes, this value reflects\r
+ * the maximum number of pipes for the currently selected AVR model.\r
+ */\r
+ #define PIPE_TOTAL_PIPES 7\r
+\r
+ /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR\r
+ * model supports the largest bank size possible on the device; different pipe numbers support\r
+ * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the\r
+ * currently selected USB AVR model.\r
+ */\r
+ #define PIPE_MAX_SIZE 256\r
+\r
+ /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * numerical address in the attached device.\r
+ */\r
+ #define PIPE_EPNUM_MASK 0x07\r
+\r
+ /** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * bank size in the attached device.\r
+ */\r
+ #define PIPE_EPSIZE_MASK 0x7FF\r
+\r
+ /** Interrupt definition for the pipe IN interrupt (for INTERRUPT type pipes). Should be used with\r
+ * the USB_INT_* macros located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on an INTERRUPT type pipe if the pipe interrupt period has\r
+ * elapsed and the pipe is ready for the next packet from the attached device to be read out from its\r
+ * FIFO buffer (if received).\r
+ *\r
+ * This interrupt must be enabled on *each* pipe which requires it (after the pipe is selected), and\r
+ * will fire the common pipe interrupt vector.\r
+ *\r
+ * \see ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
+ */\r
+ #define PIPE_INT_IN UPIENX, (1 << RXINE) , UPINTX, (1 << RXINI)\r
+\r
+ /** Interrupt definition for the pipe OUT interrupt (for INTERRUPT type pipes). Should be used with\r
+ * the USB_INT_* macros located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on an INTERRUPT type endpoint if a the pipe interrupt period\r
+ * has elapsed and the pipe is ready for a packet to be written to the pipe's FIFO buffer and sent\r
+ * to the attached device (if required).\r
+ * \r
+ * This interrupt must be enabled on *each* pipe which requires it (after the pipe is selected), and\r
+ * will fire the common pipe interrupt vector.\r
+ *\r
+ * \see ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector. */\r
+ #define PIPE_INT_OUT UPIENX, (1 << TXOUTE), UPINTX, (1 << TXOUTI)\r
+\r
+ /** Interrupt definition for the pipe SETUP bank ready interrupt (for CONTROL type pipes). Should be\r
+ * used with the USB_INT_* macros located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on an CONTROL type pipe when the pipe is ready for a new\r
+ * control request.\r
+ *\r
+ * This interrupt must be enabled on *each* pipe which requires it (after the pipe is selected), and\r
+ * will fire the common pipe interrupt vector.\r
+ *\r
+ * \see ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
+ */\r
+ #define PIPE_INT_SETUP UPIENX, (1 << TXSTPE) , UPINTX, (1 << TXSTPI)\r
+\r
+ /** Interrupt definition for the pipe error interrupt. Should be used with the USB_INT_* macros\r
+ * located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on a particular pipe if an error occurs on that pipe, such\r
+ * as a CRC mismatch error.\r
+ *\r
+ * This interrupt must be enabled on *each* pipe which requires it (after the pipe is selected), and\r
+ * will fire the common pipe interrupt vector.\r
+ *\r
+ * \see ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
+ *\r
+ * \see Pipe_GetErrorFlags() for more information on the pipe errors.\r
+ */\r
+ #define PIPE_INT_ERROR UPIENX, (1 << PERRE), UPINTX, (1 << PERRI)\r
+\r
+ /** Interrupt definition for the pipe NAK received interrupt. Should be used with the USB_INT_* macros\r
+ * located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on a particular pipe if an attached device returns a NAK in\r
+ * response to a sent packet.\r
+ *\r
+ * This interrupt must be enabled on *each* pipe which requires it (after the pipe is selected), and\r
+ * will fire the common pipe interrupt vector.\r
+ *\r
+ * \see ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
+ *\r
+ * \see Pipe_IsNAKReceived() for more information on pipe NAKs.\r
+ */\r
+ #define PIPE_INT_NAK UPIENX, (1 << NAKEDE), UPINTX, (1 << NAKEDI)\r
+\r
+ /** Interrupt definition for the pipe STALL received interrupt. Should be used with the USB_INT_* macros\r
+ * located in USBInterrupt.h.\r
+ *\r
+ * This interrupt will fire if enabled on a particular pipe if an attached device returns a STALL on the\r
+ * currently selected pipe. This will also fire if the pipe is an isochronous pipe and a CRC error occurs.\r
+ *\r
+ * This interrupt must be enabled on *each* pipe which requires it (after the pipe is selected), and\r
+ * will fire the common pipe interrupt vector.\r
+ *\r
+ * \see ENDPOINT_PIPE_vect for more information on the common pipe and endpoint interrupt vector.\r
+ */\r
+ #define PIPE_INT_STALL UPIENX, (1 << RXSTALLE), UPINTX, (1 << RXSTALLI)\r
+\r
+ /** Indicates the number of bytes currently stored in the current pipe's selected bank. */\r
+ #define Pipe_BytesInPipe() UPBCX\r
+\r
+ /** Resets the desired pipe, including the pipe banks and flags. */\r
+ #define Pipe_ResetPipe(pipenum) MACROS{ UPRST = (1 << pipenum); UPRST = 0; }MACROE\r
+\r
+ /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be\r
+ * indicated will operate on the currently selected pipe.\r
+ */\r
+ #define Pipe_SelectPipe(pipenum) MACROS{ UPNUM = pipenum; }MACROE\r
+\r
+ /** Returns the pipe address of the currently selected pipe. This is typically used to save the\r
+ * currently selected pipe number so that it can be restored after another pipe has been manipulated.\r
+ */\r
+ #define Pipe_GetCurrentPipe() (UPNUM & PIPE_PIPENUM_MASK)\r
+\r
+ /** Enables the currently selected pipe so that data can be sent and received through it to and from\r
+ * an attached device.\r
+ *\r
+ * \note Pipes must first be configured properly rather than just being enabled via the\r
+ * Pipe_ConfigurePipe() macro, which calls Pipe_EnablePipe() automatically.\r
+ */\r
+ #define Pipe_EnablePipe() MACROS{ UPCONX |= (1 << PEN); }MACROE\r
+\r
+ /** Disables the currently selected pipe so that data cannot be sent and received through it to and\r
+ * from an attached device.\r
+ */\r
+ #define Pipe_DisablePipe() MACROS{ UPCONX &= ~(1 << PEN); }MACROE\r
+\r
+ /** Returns true if the currently selected pipe is enabled, false otherwise. */\r
+ #define Pipe_IsEnabled() ((UPCONX & (1 << PEN)) ? true : false)\r
+\r
+ /** Sets the token for the currently selected endpoint to one of the tokens specified by the PIPE_TOKEN_*\r
+ * masks. This should only be used on CONTROL type endpoints, to allow for bidirectional transfer of\r
+ * data during control requests.\r
+ */\r
+ #define Pipe_SetToken(token) MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | token); }MACROE\r
+ \r
+ /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */\r
+ #define Pipe_SetInfiniteINRequests() MACROS{ UPCONX |= (1 << INMODE); }MACROE\r
+\r
+ /** Configures the currently selected pipe to only allow the specified number of IN requests to be\r
+ * accepted by the pipe before it is automatically frozen.\r
+ */\r
+ #define Pipe_SetFiniteINRequests(n) MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = n; }MACROE\r
+\r
+ /** Returns true if the currently selected pipe is configured, false otherwise. */\r
+ #define Pipe_IsConfigured() ((UPSTAX & (1 << CFGOK)) ? true : false)\r
+\r
+ /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds. */\r
+ #define Pipe_SetInterruptPeriod(ms) MACROS{ UPCFG2X = ms; }MACROE\r
+\r
+ /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should\r
+ * be serviced.\r
+ */\r
+ #define Pipe_GetPipeInterrupts() UPINT\r
+\r
+ /** Clears the interrupt flag for the specified pipe number. */\r
+ #define Pipe_ClearPipeInterrupt(n) MACROS{ UPINT &= ~(1 << n); }MACROE\r
+\r
+ /** Returns true if the specified pipe's interrupt period has elapsed, false otherwise. */\r
+ #define Pipe_HasPipeInterrupted(n) ((UPINT & (1 << n)) ? true : false)\r
+ \r
+ /** Clears the pipe bank, and switches to the alternate bank if the currently selected pipe is\r
+ * dual-banked. When cleared, this either frees the bank up for the next packet from the host\r
+ * (if the endpoint is of the OUT direction) or sends the packet contents to the host (if the\r
+ * pipe is of the IN direction).\r
+ */\r
+ #define Pipe_ClearCurrentBank() MACROS{ UPINTX &= ~(1 << FIFOCON); }MACROE\r
+\r
+ /** Unfreezes the pipe, allowing it to communicate with an attached device. */\r
+ #define Pipe_Unfreeze() MACROS{ UPCONX &= ~(1 << PFREEZE); }MACROE\r
+\r
+ /** Freezes the pipe, preventing it from communicating with an attached device. */\r
+ #define Pipe_Freeze() MACROS{ UPCONX |= (1 << PFREEZE); }MACROE\r
+\r
+ /** Clears the master pipe error flag. */\r
+ #define Pipe_ClearError() MACROS{ UPINTX &= ~(1 << PERRI); }MACROE\r
+\r
+ /** Returns true if the master pipe error flag is set for the currently selected pipe, indicating that\r
+ * some sort of hardware error has occurred on the pipe.\r
+ *\r
+ * \see Pipe_GetErrorFlags() macro for information on retreiving the exact error flag.\r
+ */\r
+ #define Pipe_IsError() ((UPINTX & (1 << PERRI)) ? true : false)\r
+ \r
+ /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error\r
+ * flag for the pipe. */\r
+ #define Pipe_ClearErrorFlags() MACROS{ UPERRX = 0; }MACROE\r
+\r
+ /** Returns a mask of the hardware error flags which have occured on the currently selected pipe. This\r
+ * value can then be masked against the PIPE_ERRORFLAG_* masks to determine what error has occurred.\r
+ */\r
+ #define Pipe_GetErrorFlags() UPERRX\r
+\r
+ /** Returns true if the currently selected pipe may be read from (if data is waiting in the pipe\r
+ * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT\r
+ * direction). This function will return false if an error has occured in the pipe, or if the pipe\r
+ * is an IN direction and no packet has been received, or if the pipe is an OUT direction and the\r
+ * pipe bank is full.\r
+ */\r
+ #define Pipe_ReadWriteAllowed() ((UPINTX & (1 << RWAL)) ? true : false)\r
+\r
+ /** Clears the flag indicating that a SETUP request has been sent to the attached device from the\r
+ * currently selected CONTROL type pipe.\r
+ */\r
+ #define Pipe_ClearSetupSent() MACROS{ UPINTX &= ~(1 << TXSTPI); }MACROE\r
+\r
+ /** Returns true if no SETUP request is currently being sent to the attached device, false otherwise. */\r
+ #define Pipe_IsSetupSent() ((UPINTX & (1 << TXSTPI)) ? true : false)\r
+\r
+ /** Returns true if the currently selected pipe has been stalled by the attached device, false otherwise. */\r
+ #define Pipe_IsStalled() ((UPINTX & (1 << RXSTALLI)) ? true : false)\r
+\r
+ /** Clears the stall condition on the currently selected pipe. */\r
+ #define Pipe_ClearStall() MACROS{ UPINTX &= ~(1 << RXSTALLI); }MACROE \r
+\r
+ /** Returns true if an IN request has been received on the currently selected CONTROL type pipe, false\r
+ * otherwise.\r
+ */\r
+ #define Pipe_IsSetupINReceived() ((UPINTX & (1 << RXINI)) ? true : false)\r
+\r
+ /** Returns true if the currently selected CONTROL type pipe is ready to send an OUT request, false\r
+ * otherwise.\r
+ */\r
+ #define Pipe_IsSetupOUTReady() ((UPINTX & (1 << TXOUTI)) ? true : false)\r
+\r
+ /** Acknowedges the reception of a setup IN request from the attached device on the currently selected\r
+ * CONTROL type endpoint, allowing for the transmission of a setup OUT packet, or the reception of\r
+ * another setup IN packet.\r
+ */\r
+ #define Pipe_ClearSetupIN() MACROS{ UPINTX &= ~(1 << RXINI); UPINTX &= ~(1 << FIFOCON); }MACROE\r
+\r
+ /** Sends the currently selected CONTROL type pipe's contents to the device as a setup OUT packet. */\r
+ #define Pipe_ClearSetupOUT() MACROS{ UPINTX &= ~(1 << TXOUTI); UPINTX &= ~(1 << FIFOCON); }MACROE\r
+ \r
+ /** Returns true if the device sent a NAK (Negative Acknowedge) in response to the last sent packet on\r
+ * the currently selected pipe. This ocurrs when the host sends a packet to the device, but the device\r
+ * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been\r
+ * received, it must be cleard using Pipe_ClearNAKReceived() before the previous (or any other) packet\r
+ * can be re-sent.\r
+ */\r
+ #define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false)\r
+\r
+ /** Clears the NAK condition on the currently selected pipe.\r
+ *\r
+ * \see Pipe_IsNAKReceived() for more details.\r
+ */\r
+ #define Pipe_ClearNAKReceived() MACROS{ UPINTX &= ~(1 << NAKEDI); }MACROE\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the Pipe_WaitUntilReady function */\r
+ enum Pipe_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error */\r
+ PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */ \r
+ PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */\r
+ PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */\r
+ enum Pipe_Stream_RW_ErrorCodes_t\r
+ {\r
+ PIPE_RWSTREAM_ERROR_NoError = 0, /**< Command completed successfully, no error. */\r
+ PIPE_RWSTREAM_ERROR_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */ \r
+ PIPE_RWSTREAM_ERROR_DeviceDisconnected = 2, /**< Device was disconnected from the host during\r
+ * the transfer.\r
+ */ \r
+ PIPE_RWSTREAM_ERROR_Timeout = 3, /**< The device failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ PIPE_RWSTREAM_ERROR_CallbackAborted = 4, /**< Indicates that the stream's callback function aborted\r
+ * the transfer early.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes. */\r
+ static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Pipe_Read_Byte(void)\r
+ {\r
+ return UPDATX;\r
+ }\r
+\r
+ /** Writes one byte from the currently selected pipe's bank, for IN direction pipes. */\r
+ static inline void Pipe_Write_Byte(const uint8_t Byte)\r
+ {\r
+ UPDATX = Byte;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes. */\r
+ static inline void Pipe_Discard_Byte(void)\r
+ {\r
+ uint8_t Dummy;\r
+ \r
+ Dummy = UPDATX;\r
+ }\r
+ \r
+ /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT\r
+ * direction pipes.\r
+ */\r
+ static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t Pipe_Read_Word_LE(void)\r
+ {\r
+ uint16_t Data;\r
+ \r
+ Data = UPDATX;\r
+ Data |= (((uint16_t)UPDATX) << 8);\r
+ \r
+ return Data;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ */\r
+ static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t Pipe_Read_Word_BE(void)\r
+ {\r
+ uint16_t Data;\r
+ \r
+ Data = (((uint16_t)UPDATX) << 8);\r
+ Data |= UPDATX;\r
+ \r
+ return Data;\r
+ }\r
+ \r
+ /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ */\r
+ static inline void Pipe_Write_Word_LE(const uint16_t Word)\r
+ {\r
+ UPDATX = (Word & 0xFF);\r
+ UPDATX = (Word >> 8);\r
+ }\r
+ \r
+ /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ */\r
+ static inline void Pipe_Write_Word_BE(const uint16_t Word)\r
+ {\r
+ UPDATX = (Word >> 8);\r
+ UPDATX = (Word & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes. */\r
+ static inline void Pipe_Ignore_Word(void)\r
+ {\r
+ uint8_t Dummy;\r
+ \r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT\r
+ * direction pipes.\r
+ */\r
+ static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Pipe_Read_DWord_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t DWord;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+ \r
+ Data.Bytes[0] = UPDATX;\r
+ Data.Bytes[1] = UPDATX;\r
+ Data.Bytes[2] = UPDATX;\r
+ Data.Bytes[3] = UPDATX;\r
+ \r
+ return Data.DWord;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ */\r
+ static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Pipe_Read_DWord_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t DWord;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+ \r
+ Data.Bytes[3] = UPDATX;\r
+ Data.Bytes[2] = UPDATX;\r
+ Data.Bytes[1] = UPDATX;\r
+ Data.Bytes[0] = UPDATX;\r
+ \r
+ return Data.DWord;\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ */\r
+ static inline void Pipe_Write_DWord_LE(const uint32_t DWord)\r
+ {\r
+ Pipe_Write_Word_LE(DWord);\r
+ Pipe_Write_Word_LE(DWord >> 16);\r
+ }\r
+ \r
+ /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ */ \r
+ static inline void Pipe_Write_DWord_BE(const uint32_t DWord)\r
+ {\r
+ Pipe_Write_Word_BE(DWord >> 16);\r
+ Pipe_Write_Word_BE(DWord);\r
+ } \r
+ \r
+ /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. */\r
+ static inline void Pipe_Ignore_DWord(void)\r
+ {\r
+ uint8_t Dummy;\r
+ \r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control pipe located at address\r
+ * 0 in the device. This value is set to the value indicated in the attached device's device\r
+ * descriptor once the USB interface is initialized into host mode and a device is attached\r
+ * to the USB bus.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern uint8_t USB_ControlPipeSize;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the\r
+ * attached device, bank size and banking mode. Pipes should be allocated in ascending order by their\r
+ * address in the device (i.e. pipe 1 should be configured before pipe 2 and so on).\r
+ *\r
+ * The pipe type may be one of the EP_TYPE_* macros listed in LowLevel.h, the token may be one of the\r
+ * PIPE_TOKEN_* masks.\r
+ *\r
+ * The bank size must indicate the maximum packet size that the pipe can handle. Different pipe\r
+ * numbers can handle different maximum packet sizes - refer to the chosen USB AVR's datasheet to\r
+ * determine the maximum bank size for each pipe.\r
+ *\r
+ * The banking mode may be either PIPE_BANK_SINGLE or PIPE_BANK_DOUBLE.\r
+ *\r
+ * A newly configured pipe is frozen by default, and must be unfrozen before use via the Pipe_Unfreeze() macro.\r
+ *\r
+ * \note This routine will select the specified pipe, and the pipe will remain selected once the\r
+ * routine completes regardless of if the pipe configuration succeeds.\r
+ *\r
+ * \return Boolean true if the configuration is successful, false otherwise\r
+ */\r
+ bool Pipe_ConfigurePipe(const uint8_t Number, const uint8_t Type, const uint8_t Token, const uint8_t EndpointNumber,\r
+ const uint16_t Size, const uint8_t Banks);\r
+\r
+ /** Spinloops until the currently selected non-control pipe is ready for the next packed of data\r
+ * to be read or written to it.\r
+ *\r
+ * \note This routine should not be called on CONTROL type pipes.\r
+ *\r
+ * \return A value from the Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_WaitUntilReady(void); \r
+ \r
+ /** Writes the given number of bytes to the pipe from the given buffer in little endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to read from.\r
+ * \param Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_Stream_LE(const void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1); \r
+\r
+ /** Writes the given number of bytes to the pipe from the given buffer in big endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to read from.\r
+ * \param Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_Stream_BE(const void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
+ * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
+ * user is responsible for manually discarding the last packet from the host via the Pipe_ClearCurrentBank() macro.\r
+ * Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready,\r
+ * allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \param Length Number of bytes to send via the currently selected pipe.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Discard_Stream(uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ );\r
+\r
+ /** Reads the given number of bytes from the pipe into the given buffer in little endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to write to.\r
+ * \param Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the pipe into the given buffer in big endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * Pipe_ClearCurrentBank() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created using the STREAM_CALLBACK() macro. If the token\r
+ * NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are disabled\r
+ * and this function has the Callback parameter ommitted.\r
+ *\r
+ * \param Buffer Pointer to the source data buffer to write to.\r
+ * \param Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param Callback Name of a callback routine to call between sucessive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ , uint8_t (* const Callback)(void)\r
+ #endif\r
+ ) ATTR_NON_NULL_PTR_ARG(1); \r
+\r
+ /* Function Aliases: */\r
+ /** Alias for Pipe_Discard_Byte().\r
+ */\r
+ #define Pipe_Ignore_Byte() Pipe_Discard_Byte()\r
+\r
+ /** Alias for Pipe_Discard_Word().\r
+ */\r
+ #define Pipe_Ignore_Word() Pipe_Discard_Word() \r
+\r
+ /** Alias for Pipe_Discard_DWord().\r
+ */\r
+ #define Pipe_Ignore_DWord() Pipe_Discard_DWord()\r
+\r
+ /** Alias for Pipe_Read_Word_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Pipe_Read_Word() Pipe_Read_Word_LE()\r
+\r
+ /** Alias for Pipe_Write_Word_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Pipe_Write_Word(Word) Pipe_Write_Word_LE(Word)\r
+\r
+ /** Alias for Pipe_Read_DWord_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Pipe_Read_DWord() Pipe_Read_DWord_LE()\r
+\r
+ /** Alias for Pipe_Write_DWord_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #define Pipe_Write_DWord(DWord) Pipe_Write_DWord_LE(DWord)\r
+\r
+ /** Alias for Pipe_Read_Stream_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ #define Pipe_Read_Stream(Buffer, Length, Callback) Pipe_Read_Stream_LE(Buffer, Length, Callback)\r
+ #else\r
+ #define Pipe_Read_Stream(Buffer, Length) Pipe_Read_Stream_LE(Buffer, Length)\r
+ #endif\r
+\r
+ /** Alias for Pipe_Write_Stream_LE(). By default USB transfers use little endian format, thus\r
+ * the command with no endianness specifier indicates little endian mode.\r
+ */\r
+ #if !defined(NO_STREAM_CALLBACKS)\r
+ #define Pipe_Write_Stream(Buffer, Length, Callback) Pipe_Read_Stream_LE(Buffer, Length, Callback)\r
+ #else\r
+ #define Pipe_Write_Stream(Buffer, Length) Pipe_Read_Stream_LE(Buffer, Length)\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define PIPE_TOKEN_MASK (0x03 << PTOKEN0)\r
+\r
+ #define Pipe_AllocateMemory() MACROS{ UPCFG1X |= (1 << ALLOC); }MACROE\r
+ #define Pipe_DeallocateMemory() MACROS{ UPCFG1X &= ~(1 << ALLOC); }MACROE\r
+\r
+ /* Function Prototypes: */\r
+ void Pipe_ClearPipes(void);\r
+\r
+ /* Inline Functions: */\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYSINLINE;\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(uint16_t Bytes)\r
+ {\r
+ if (Bytes <= 8)\r
+ return (0 << EPSIZE0);\r
+ else if (Bytes <= 16)\r
+ return (1 << EPSIZE0);\r
+ else if (Bytes <= 32)\r
+ return (2 << EPSIZE0);\r
+ else if (Bytes <= 64)\r
+ return (3 << EPSIZE0);\r
+ else if (Bytes <= (8 << 4))\r
+ return (4 << EPSIZE0);\r
+ else\r
+ return (5 << EPSIZE0);\r
+ };\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Contains definitions for the various control request parameters, so that the request details (such as data\r
+ * direction, request recipient, etc.) can be extracted via masking.\r
+ */\r
+ \r
+#ifndef __STDREQTYPE_H__\r
+#define __STDREQTYPE_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device\r
+ * or Device to Host). The result of this mask should then be compared to the request direction masks.\r
+ *\r
+ * \see REQDIR_* macros for masks indicating the request data direction.\r
+ */\r
+ #define CONTROL_REQTYPE_DIRECTION 0b10000000\r
+\r
+ /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor\r
+ * Specific). The result of this mask should then be compared to the request type masks.\r
+ *\r
+ * \see REQTYPE_* macros for masks indicating the request type.\r
+ */\r
+ #define CONTROL_REQTYPE_TYPE 0b01100000\r
+\r
+ /** Mask for the request type parameter, to indicate the recipient of the request (Standard, Class\r
+ * or Vendor Specific). The result of this mask should then be compared to the request recipient\r
+ * masks.\r
+ *\r
+ * \see REQREC_* macros for masks indicating the request recipient.\r
+ */\r
+ #define CONTROL_REQTYPE_RECIPIENT 0b00011111\r
+\r
+ /** Request data direction mask, indicating that the request data will flow from host to device.\r
+ *\r
+ * \see CONTROL_REQTYPE_DIRECTION macro.\r
+ */\r
+ #define REQDIR_HOSTTODEVICE (0 << 7)\r
+\r
+ /** Request data direction mask, indicating that the request data will flow from device to host.\r
+ *\r
+ * \see CONTROL_REQTYPE_DIRECTION macro.\r
+ */\r
+ #define REQDIR_DEVICETOHOST (1 << 7)\r
+\r
+ /** Request type mask, indicating that the request is a standard request.\r
+ *\r
+ * \see CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_STANDARD (0 << 5)\r
+\r
+ /** Request type mask, indicating that the request is a class-specific request.\r
+ *\r
+ * \see CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_CLASS (1 << 5)\r
+\r
+ /** Request type mask, indicating that the request is a vendor specific request.\r
+ *\r
+ * \see CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_VENDOR (2 << 5)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to the device as a whole.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_DEVICE (0 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an interface in the\r
+ * currently selected configuration.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_INTERFACE (1 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an endpoint in the\r
+ * currently selected configuration.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_ENDPOINT (2 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an unspecified element\r
+ * in the currently selected configuration.\r
+ *\r
+ * \see CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_OTHER (3 << 0)\r
+ \r
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature\r
+ * request this indicates that an endpoint (whose address is given elsewhere in the request\r
+ * should have its stall condition cleared. If used in a similar manner inside a Set Feature\r
+ * request, this stalls an endpoint.\r
+ */\r
+ #define FEATURE_ENDPOINT_HALT 0x00\r
+\r
+ /** Feature indicator for Clear Feature or Set Feature commands. When used in a Clear Feature\r
+ * request this indicates that the remote wakeup enabled device should not issue remote\r
+ * wakeup requests until further notice. If used in a similar manner inside a Set Feature\r
+ * request, this re-enabled the remote wakeup feature on the device.\r
+ */\r
+ #define FEATURE_REMOTE_WAKEUP 0x01\r
+\r
+ /* Enums: */\r
+ /** Enumeration for the various standard request commands. These commands are applicable when the\r
+ * request type is REQTYPE_STANDARD (with the exception of REQ_GetDescriptor, which is always\r
+ * handled regardless of the request type value).\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 Specification.\r
+ */\r
+ enum USB_Control_Request_t\r
+ {\r
+ REQ_GetStatus = 0, /**< Implemented in the library for device, endpoint and interface\r
+ * recipients. Passed to the user application for other recipients\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_ClearFeature = 1, /**< Implemented in the library for device, endpoint and interface\r
+ * recipients. Passed to the user application for other recipients\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetFeature = 3, /**< Implemented in the library for device, endpoint and interface\r
+ * recipients. Passed to the user application for other recipients\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_GetDescriptor = 6, /**< Implemented in the library for all recipients and all request\r
+ * types. */\r
+ REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application\r
+ * via the USB_UnhandledControlPacket() event when received in\r
+ * device mode. */\r
+ };\r
+\r
+/* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define FEATURE_SELFPOWERED_ENABLED (1 << 0)\r
+ #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Macros and enums for the stream callback routines in Endpoint.h and Pipe.c. This module contains the\r
+ * code required to easily set up stream callback functions which can be used to force early abort of a\r
+ * stream read/write process.\r
+ */\r
+ \r
+#ifndef __STREAMCALLBACK_H__\r
+#define __STREAMCALLBACK_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Creates a prototype for or begins a stream callback routine. Stream callback routines are small\r
+ * routines which are executed during stream read or writes (if the callback-enabled versions of\r
+ * these functions are used) which allow the user application to abort the transfer when certain\r
+ * arbitrary conditions are met.\r
+ *\r
+ * Stream callback functions should return a value from the StreamCallback_Return_ErrorCodes_t\r
+ * enum.\r
+ *\r
+ * Usage Example (Device Endpoint, but applicable for Host pipes also):\r
+ * \code\r
+ * STREAM_CALLBACK(GlobalNotSet); // Callback Prototype\r
+ *\r
+ * STREAM_CALLBACK(GlobalNotSet)\r
+ * {\r
+ * if (MyGlobal == false)\r
+ * return ENDPOINT_STREAMCALLBACK_Continue;\r
+ * else\r
+ * return ENDPOINT_STREAMCALLBACK_Abort;\r
+ * }\r
+ *\r
+ * //...\r
+ * // Inside some routine:\r
+ * if (Endpoint_Write_CStream_LE(DataBuffer, sizeof(DataBuffer), GlobalNotSet) == \r
+ * ENDPOINT_RWSTREAM_ERROR_CallbackAborted)\r
+ * {\r
+ * // Do something when the callback aborted the transfer early\r
+ * }\r
+ * \endcode\r
+ */\r
+ #define STREAM_CALLBACK(name) uint8_t name (void)\r
+\r
+ /** Used with the Endpoint and Pipe stream functions as the callback function parameter, indicating that the stream\r
+ * call has no callback function to be called between USB packets.\r
+ */\r
+ #define NO_STREAM_CALLBACK NULL\r
+ \r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of a stream callback function */\r
+ enum StreamCallback_Return_ErrorCodes_t\r
+ {\r
+ STREAMCALLBACK_Continue = 0, /**< Continue sending or receiving the stream. */\r
+ STREAMCALLBACK_Abort = 1, /**< Abort the stream send or reciving process. */\r
+ };\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#ifndef __USBMODE_H__\r
+#define __USBMODE_H__\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #if ((defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \\r
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \\r
+ defined(__AVR_ATmega32U6__)) && !defined(USB_DEVICE_ONLY))\r
+ #define USB_DEVICE_ONLY\r
+ #endif\r
+ \r
+ #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__))\r
+ #define USB_LIMITED_CONTROLLER\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_MODIFIED_FULL_CONTROLLER\r
+ #else\r
+ #define USB_FULL_CONTROLLER\r
+ #endif \r
+\r
+ #if (!defined(USB_DEVICE_ONLY) && !defined(USB_HOST_ONLY))\r
+ #define USB_CAN_BE_BOTH\r
+ #define USB_CAN_BE_HOST\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif defined(USB_HOST_ONLY)\r
+ #define USB_CAN_BE_HOST\r
+ #define USB_CurrentMode USB_MODE_HOST\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CurrentMode USB_MODE_DEVICE\r
+ #endif\r
+ \r
+ #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))\r
+ #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.\r
+ #endif\r
+\r
+ #if (defined(USB_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))\r
+ #error USB_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ #if defined(USE_STATIC_OPTIONS)\r
+ #define USB_Options USE_STATIC_OPTIONS\r
+ #endif\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Master include file for the library USB functionality. This file should be included in all user projects making\r
+ * use of the USB portions of the library, instead of including any headers in the USB/LowLevel or USB/HighLevel\r
+ * directories.\r
+ *\r
+ * Class specific utility files in USB/Class/ must still be included manually, as they are not normally part of\r
+ * the USB library unless desired by the library user.\r
+ */\r
+\r
+#ifndef __USB_H__\r
+#define __USB_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if (!(defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__)) && defined(USB_HOST_ONLY))\r
+ #error USB_HOST_ONLY is not available for the currently selected USB AVR model.\r
+ #endif\r
+ \r
+ #if (!(defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \\r
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \\r
+ defined(__AVR_ATmega32U6__)))\r
+ #error The currently selected AVR model is not supported under the USB component of the LUFA library.\r
+ #endif\r
+ \r
+ /* Includes: */\r
+ #include "LowLevel/USBMode.h"\r
+ \r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #include "LowLevel/Host.h"\r
+ #include "LowLevel/HostChapter9.h"\r
+ #include "LowLevel/Pipe.h"\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "LowLevel/Device.h"\r
+ #include "LowLevel/DevChapter9.h"\r
+ #include "LowLevel/Endpoint.h"\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ #include "LowLevel/OTG.h"\r
+ #endif\r
+\r
+ #include "LowLevel/LowLevel.h"\r
+ #include "HighLevel/USBTask.h"\r
+ #include "HighLevel/USBInterrupt.h"\r
+ #include "HighLevel/Events.h"\r
+ #include "HighLevel/StdDescriptors.h"\r
+ \r
+#endif\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_GettingStarted Getting Started\r
+ *\r
+ * Out of the box, LUFA contains a large number of pre-made class demos for you to test, experiment with and\r
+ * ultimately build upon for your own projects. All the demos come pre-configured to build and run correctly\r
+ * on the AT90USB1287 AVR microcontroller, mounted on the Atmel USBKEY board and running at an 8MHz master clock.\r
+ * This is due to two reasons; one, it is the hardware the author posesses, and two, it is the most popular Atmel\r
+ * USB demonstration board to date.\r
+ *\r
+ * \section Sec_Prerequisites Prerequisites\r
+ * Before you can compile any of the LUFA library code or demos, you will need a recent distribution of avr-libc (1.6.2+)\r
+ * and the AVR-GCC (4.2+) compiler. For Windows users, the best way to obtain these is the WinAVR project\r
+ * (http://winavr.sourceforge.net) as this provides a single-file setup for everything required to compile your\r
+ * own AVR projects.\r
+ *\r
+ * \section Sec_Configuring Configuring the Demos, Bootloaders and Projects\r
+ * If the target AVR model, clock speed, board or other settings are different to the current settings, they must be changed\r
+ * and the project recompiled from the source code before being programmed into the AVR microcontroller. Most project\r
+ * configuration options are located in the "makefile" build script inside each LUFA application's folder, however some\r
+ * demo or application-specific configuration settings (such as the output format in the AudioOut demo) are located in the\r
+ * main .c source file of the project.\r
+ *\r
+ * Each project "makefile" contains all the script and configuration data required to compile each project. When opened with\r
+ * any regular basic text editor such as Notepad or Wordpad (ensure that the save format is a pure ASCII text format) the\r
+ * build configuration settings may be altered.\r
+ *\r
+ * Inside each makefile, a number of configuration variables are located, with the format "<VARIABLE NAME> = <VALUE>". For\r
+ * each application, the important variables which should be altered are:\r
+ *\r
+ * - <b>MCU</b>, the target AVR processor.\r
+ * - <b>BOARD</b>, the target board hardware\r
+ * - <b>F_CPU</b>, the target AVR master clock frequency\r
+ * - <b>CDEFS</b>, the C preprocessor defines which configure the source code\r
+ *\r
+ * These values should be changed to reflect the build hardware.\r
+ *\r
+ * \subsection SSec_MCU The MCU Parameter\r
+ * This parameter indicates the target AVR model for the compiled application. This should be set to the model of the target AVR\r
+ * (such as the AT90USB1287, or the ATMEGA32U4), in all lower-case (e.g. "at90usb1287"). Note that not all demos support all the\r
+ * USB AVR models, as they may make use of peripherals or modes only present in some devices.\r
+ *\r
+ * For supported library AVR models, see main documentation page.\r
+ *\r
+ * \subsection SSec_BOARD The BOARD Parameter\r
+ * This parameter indicates the target AVR board hardware for the compiled application. Some LUFA library drivers are board-specific,\r
+ * such as the LED driver, and the library needs to know the layout of the target board. If you are using one of the board models listed\r
+ * on the main library page, change this parameter to the board name in all UPPER-case.\r
+ *\r
+ * If you are not using any board-specific drivers in the LUFA library, or you are using a custom board layout, change this to read\r
+ * "USER" (no quotes) instead of a standard board name. If the USER board type is selected and the application makes use of one or more\r
+ * board-specific hardware drivers inside the LUFA library, then the appropriate stub drives files should be copied from the /BoardStubs/\r
+ * directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the\r
+ * custom board's hardware.\r
+ *\r
+ * \subsection SSec_F_CPU The F_CPU Parameter\r
+ * This parameter indicates the target AVR's master clock frequency, in Hz. Consult your AVR model's datasheet for allowable clock frequencies\r
+ * if the USB interface is to be operational.\r
+ *\r
+ * <b>Note that this value does not actually *alter* the AVR's clock frequency</b>, it is just a way to indicate to the library the clock frequency\r
+ * of the AVR as set by the AVR's fuses. If this value does not reflect the actual running frequency of the AVR, incorrect operation of one of more\r
+ * library components will ocurr.\r
+ *\r
+ * \subsection SSec_CDEFS The CDEFS Parameter\r
+ * Most applications will actually have multiple CDEF lines, which are concatenated together with the "+=" operator. This ensures that large\r
+ * numbers of configuration options remain readable by splitting up groups of options into seperate lines.\r
+ *\r
+ * Normally, these options do not need to be altered to allow an application to compile and run correctly on a different board or AVR to the\r
+ * current configuration - if the options are incorrect, then the demo is most likely incompatible with the chosen USB AVR model and cannot be\r
+ * made to function through the altering of the makefile settings alone (or at all). Settings such as the USB mode (device, host or both), the USB\r
+ * interface speed (Low or Full speed) and other LUFA configuration options can be set here - refer to the library documentation for details on the\r
+ * configuration parameters.\r
+ *\r
+ * \section Sec_Compiling Compiling a LUFA Application\r
+ * Compiling the LUFA demos, applications and/or bootloaders is very simple. LUFA comes with makefile scripts for\r
+ * each individual demo, bootloader and project folder, as well as scripts in the /Demos/, /Bootloaders/, /Projects/\r
+ * and the LUFA root directory. This means that compilation can be started from any of the above directories, with\r
+ * a build started from an upper directory in the directory structure executing build of all child directories under it.\r
+ * This means that while a build inside a particular demo directory will build only that particular demo, a build stated\r
+ * from the /Demos/ directory will build all LUFA demo projects sequentially.\r
+ *\r
+ * \subsection SSec_CommandLine Via the Command Line\r
+ * To build a project from the source via the command line, the command <b>"make all"</b> should be executed from the command line in the directory\r
+ * of interest. To remove compiled files (including the binary output, all intermediatary files and all diagnostic output\r
+ * files), execute <b>"make clean"</b>. Once a "make all" has been run and no errors were encountered, the resulting binary will\r
+ * be located in the generated ".HEX" file. If your project makes use of pre-initialized EEPROM variables, the generated ".EEP"\r
+ * file will contain the project's EEPROM data.\r
+ *\r
+ * \subsection SSec_AVRStudio Via AVRStudio\r
+ * Each demo, project and bootloader contains an AVRStudio project (.aps) which can be used to build each project. Once opened\r
+ * in AVRStudio, the project can be built and cleaned using the GUI buttons or menus. Note that the AVRStudio project files make\r
+ * use of the external project makefile, thus the procedure for configuring a demo remains the same regardless of the build environment.\r
+ *\r
+ * \section Sec_Programming Programming a USB AVR\r
+ * Once you have built an application, you will need a way to program in the resulting ".HEX" file (and, if your\r
+ * application uses EEPROM variables with initial values, also a ".EEP" file) into your USB AVR. Normally, the\r
+ * reprogramming an AVR device must be performed using a special piece of programming hardware, through one of the\r
+ * supported AVR programming protocols - ISP, HVSP, HVPP, JTAG or dW. This can be done through a custom programmer,\r
+ * a third party programmer, or an official Atmel AVR tool - for more information, see the Atmel.com website.\r
+ *\r
+ * Alternatively, you can use the bootloader. From the Atmel factory, each USB AVR comes preloaded with the Atmel\r
+ * DFU (Device Firmware Update) class bootloader, a small piece of AVR firmware which allows the remainder of the\r
+ * AVR to be programmed through a non-standard interface such as the serial USART port, SPI, or (in this case) USB.\r
+ * Bootloaders have the advantage of not requiring any special hardware for programming, and cannot usually be erased\r
+ * or broken without an external programming device. They have disadvantages however; they cannot change the fuses of\r
+ * the AVR (special configuration settings that control the operation of the chip itself) and a small portion of the\r
+ * AVR's FLASH program memory must be reserved to contain the bootloader firmware, and thus cannot be used by the\r
+ * loaded application. Atmel's DFU bootloader is either 4KB (for the smaller USB AVRs) or 8KB (for the larger USB AVRs).\r
+ *\r
+ * If you wish to use the DFU bootloader to program in your application, refer to your DFU programmer's documentation.\r
+ * Atmel provides a free utility called FLIP which is USB AVR compatible, and an open source (Linux compatible)\r
+ * alternative exists called "dfu-programmer".\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \mainpage About the LUFA (Formerly MyUSB) Library\r
+ *\r
+ * Lightweight USB Framework for AVRs Library, written by Dean Camera.\r
+ *\r
+ * \section Sec_About About this library\r
+ *\r
+ * Originally based on the AT90USBKEY from Atmel, it is an open-source, driver for the USB-enabled AVR\r
+ * microcontrollers, released under the MIT license. Currently, the AT90USB1286, AT90USB1287, AT90USB646,\r
+ * AT90USB647, AT90USB162, AT90USB82, ATMEGA16U4, ATMEGA32U6 and ATMEGA32U4 AVR microcontrollers are supported by the \r
+ * library. Supported premade boards are the USBKEY, STK525, STK526, RZUSBSTICK and ATAVRUSBRF01.\r
+ *\r
+ * The library is currently in a stable release, suitable for download and incorporation into user projects for\r
+ * both host and device modes. For information about the project progression, check out my blog.\r
+ *\r
+ * LUFA is written specifically for the free AVR-GCC compiler, and uses several GCC-only extensions to make the\r
+ * library API more streamlined and robust. You can download AVR-GCC for free in a convenient windows package, \r
+ * from the the WinAVR website.\r
+ *\r
+ * \section Sec_Links Library Links\r
+ * Project Homepage: http://www.fourwalledcubicle.com/LUFA.php \n\r
+ * Development Blog: http://www.fourwalledcubicle.com/blog \n\r
+ * Discussion Group: http://groups.google.com/group/myusb-support-list \n\r
+ * SVN Access, Bug Reports and Feature Requests: http://code.google.com/p/lufa-lib/ \n\r
+ * Author's Website: http://www.fourwalledcubicle.com \n\r
+ *\r
+ * WinAVR Website: http://winavr.sourceforge.net \n\r
+ * avr-libc Website: http://www.nongnu.org/avr-libc/ \n\r
+ *\r
+ * USB-IF Website: http://www.usb.org \n\r
+ *\r
+ * \section Sec_License License\r
+ * The LUFA library is currently released under the MIT licence, included below.\r
+ *\r
+ * \verbatim\r
+ * Permission to use, copy, modify, and distribute this software\r
+ * and its documentation for any purpose and without fee is hereby\r
+ * granted, provided that the above copyright notice appear in all\r
+ * copies and that both that the copyright notice and this\r
+ * permission notice and warranty disclaimer appear in supporting\r
+ * documentation, and that the name of the author not be used in\r
+ * advertising or publicity pertaining to distribution of the\r
+ * software without specific, written prior permission.\r
+ *\r
+ * The author disclaim all warranties with regard to this\r
+ * software, including all implied warranties of merchantability\r
+ * and fitness. In no event shall the author be liable for any\r
+ * special, indirect or consequential damages or any damages\r
+ * whatsoever resulting from loss of use, data or profits, whether\r
+ * in an action of contract, negligence or other tortious action,\r
+ * arising out of or in connection with the use or performance of\r
+ * this software.\r
+ * \endverbatim\r
+ *\r
+ * \section Sec_Demos Demos and Bootloaders\r
+ * The LUFA library ships with several different host and device demos, located in the /Demos/ subdirectory.\r
+ * If this directory is missing, please re-download the project from the project homepage.\r
+ *\r
+ * Also included with the library are two fully functional bootloaders, loacated in the /Bootloaders/ subdirectory.\r
+ * The DFU class bootloader is compatible with Atmel's FLIP software or the open source dfu-programmer project, and\r
+ * the CDC class (AVR109 protocol) is compatible with such open source software as AVRDUDE and AVR-OSP.\r
+ *\r
+ * \section Sec_Donations Donate\r
+ * I am a 20 year old University student studying for a double degree in Computer Science and Electronics\r
+ * Engineering. This leaves little time for any sort of work or leisure. Please consider donating a small amount\r
+ * to myself to support this and my future Open Source projects. You can donate any amount via PayPal on my\r
+ * website, http://www.fourwalledcubicle.com . All donations are greatly appreciated.\r
+ */\r
+
\ No newline at end of file
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define INCLUDE_FROM_DYNALLOC_C\r
+#include "DynAlloc.h"\r
+\r
+struct\r
+{\r
+ char Mem_Heap[NUM_BLOCKS * BLOCK_SIZE];\r
+ void* Mem_Handles[NUM_HANDLES];\r
+ uint8_t Mem_Block_Flags[(NUM_BLOCKS / 4) + ((NUM_BLOCKS % 4) ? 1 : 0)];\r
+ uint8_t FlagMaskLookupMask[4];\r
+ uint8_t FlagMaskLookupNum[4];\r
+} Mem_MemData = {FlagMaskLookupMask: {(3 << 0), (3 << 2), (3 << 4), (3 << 6)},\r
+ FlagMaskLookupNum: { 0, 2, 4, 6}};\r
+\r
+static uint8_t Mem_GetBlockFlags(const Block_Number_t BlockNum)\r
+{\r
+ const Block_Number_t BlockIndex = (BlockNum >> 2);\r
+ const uint8_t FlagMask = Mem_MemData.FlagMaskLookupMask[BlockNum & 0x03];\r
+ const uint8_t FlagMaskShift = Mem_MemData.FlagMaskLookupNum[BlockNum & 0x03];\r
+\r
+ return ((Mem_MemData.Mem_Block_Flags[BlockIndex] & FlagMask) >> FlagMaskShift);\r
+}\r
+\r
+static void Mem_SetBlockFlags(const Block_Number_t BlockNum, const uint8_t Flags)\r
+{\r
+ const Block_Number_t BlockIndex = (BlockNum >> 2);\r
+ const uint8_t FlagMask = Mem_MemData.FlagMaskLookupMask[BlockNum & 0x03];\r
+ const uint8_t FlagMaskShift = Mem_MemData.FlagMaskLookupNum[BlockNum & 0x03];\r
+\r
+ Mem_MemData.Mem_Block_Flags[BlockIndex] &= ~FlagMask;\r
+ Mem_MemData.Mem_Block_Flags[BlockIndex] |= (Flags << FlagMaskShift);\r
+}\r
+\r
+static inline void Mem_Defrag(void)\r
+{\r
+ Block_Number_t FreeStartBlock = 0;\r
+ char* FreeStartPtr = NULL;\r
+ char* UsedStartPtr = NULL;\r
+ Block_Number_t CurrBlock;\r
+ \r
+ for (CurrBlock = 0; CurrBlock < NUM_BLOCKS; CurrBlock++)\r
+ {\r
+ if (!(Mem_GetBlockFlags(CurrBlock) & BLOCK_USED_MASK))\r
+ {\r
+ FreeStartPtr = &Mem_MemData.Mem_Heap[CurrBlock * BLOCK_SIZE];\r
+ FreeStartBlock = CurrBlock;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if (FreeStartPtr == NULL)\r
+ return;\r
+\r
+ while (++CurrBlock < NUM_BLOCKS)\r
+ {\r
+ uint8_t CurrBlockFlags = Mem_GetBlockFlags(CurrBlock);\r
+ \r
+ if (CurrBlockFlags & BLOCK_USED_MASK)\r
+ {\r
+ UsedStartPtr = &Mem_MemData.Mem_Heap[CurrBlock * BLOCK_SIZE];\r
+ \r
+ for (Handle_Number_t HandleNum = 0; HandleNum < NUM_HANDLES; HandleNum++)\r
+ {\r
+ if (Mem_MemData.Mem_Handles[HandleNum] == UsedStartPtr)\r
+ {\r
+ Mem_MemData.Mem_Handles[HandleNum] = FreeStartPtr;\r
+ break;\r
+ }\r
+ }\r
+\r
+ memcpy(FreeStartPtr, UsedStartPtr, BLOCK_SIZE);\r
+ FreeStartPtr += BLOCK_SIZE;\r
+ \r
+ Mem_SetBlockFlags(FreeStartBlock++, CurrBlockFlags);\r
+ Mem_SetBlockFlags(CurrBlock, 0);\r
+ }\r
+ }\r
+}\r
+\r
+static inline bool Mem_FindFreeBlocks(Block_Number_t* const RetStartPtr, const Block_Number_t Blocks)\r
+{\r
+ Block_Number_t FreeInCurrSec = 0;\r
+\r
+ for (Block_Number_t CurrBlock = 0; CurrBlock < NUM_BLOCKS; CurrBlock++)\r
+ {\r
+ if (Mem_GetBlockFlags(CurrBlock) & BLOCK_USED_MASK)\r
+ FreeInCurrSec = 0;\r
+ else\r
+ FreeInCurrSec++;\r
+\r
+ if (FreeInCurrSec >= Blocks)\r
+ {\r
+ *RetStartPtr = CurrBlock;\r
+ return true;\r
+ }\r
+ }\r
+\r
+ return false;\r
+}\r
+\r
+Mem_Handle_t Mem_Alloc(const Alloc_Size_t Bytes)\r
+{\r
+ Block_Number_t ReqBlocks = (Bytes / BLOCK_SIZE);\r
+ Block_Number_t StartBlock;\r
+ \r
+ if (Bytes % BLOCK_SIZE)\r
+ ReqBlocks++;\r
+ \r
+ if (!(Mem_FindFreeBlocks(&StartBlock, ReqBlocks)))\r
+ {\r
+ Mem_Defrag();\r
+ \r
+ if (!(Mem_FindFreeBlocks(&StartBlock, ReqBlocks)))\r
+ return NULL; \r
+ }\r
+\r
+ for (Block_Number_t UsedBlock = 0; UsedBlock < (ReqBlocks - 1); UsedBlock++)\r
+ Mem_SetBlockFlags((StartBlock + UsedBlock), (BLOCK_USED_MASK | BLOCK_LINKED_MASK));\r
+\r
+ Mem_SetBlockFlags((StartBlock + (ReqBlocks - 1)), BLOCK_USED_MASK);\r
+ \r
+ for (Handle_Number_t AllocEntry = 0; AllocEntry < NUM_HANDLES; AllocEntry++)\r
+ {\r
+ Mem_Handle_t CurrHdl = (Mem_Handle_t)&Mem_MemData.Mem_Handles[AllocEntry];\r
+ \r
+ if (DEREF(CurrHdl, void*) == NULL)\r
+ {\r
+ DEREF(CurrHdl, void*) = &Mem_MemData.Mem_Heap[StartBlock * BLOCK_SIZE];\r
+ return CurrHdl;\r
+ }\r
+ }\r
+\r
+ return NULL;\r
+}\r
+\r
+Mem_Handle_t Mem_Realloc(Mem_Handle_t CurrAllocHdl, const Alloc_Size_t Bytes)\r
+{\r
+ Mem_Free(CurrAllocHdl);\r
+ return Mem_Alloc(Bytes);\r
+}\r
+\r
+Mem_Handle_t Mem_Calloc(const Alloc_Size_t Bytes)\r
+{\r
+ Mem_Handle_t AllocHdl = Mem_Alloc(Bytes);\r
+ \r
+ if (AllocHdl != NULL)\r
+ memset(DEREF(AllocHdl, void*), 0x00, Bytes);\r
+\r
+ return AllocHdl;\r
+}\r
+\r
+void Mem_Free(Mem_Handle_t CurrAllocHdl)\r
+{\r
+ char* MemBlockPtr = DEREF(CurrAllocHdl, char*);\r
+ Block_Number_t CurrBlock = ((uint16_t)(MemBlockPtr - Mem_MemData.Mem_Heap) / BLOCK_SIZE);\r
+ uint8_t CurrBlockFlags;\r
+\r
+ if ((CurrAllocHdl == NULL) || (MemBlockPtr == NULL))\r
+ return;\r
+\r
+ do\r
+ {\r
+ CurrBlockFlags = Mem_GetBlockFlags(CurrBlock);\r
+ Mem_SetBlockFlags(CurrBlock, 0);\r
+\r
+ CurrBlock++;\r
+ }\r
+ while (CurrBlockFlags & BLOCK_LINKED_MASK);\r
+ \r
+ DEREF(CurrAllocHdl, void*) = NULL;\r
+}\r
+\r
+Block_Number_t Mem_TotalFreeBlocks(void)\r
+{\r
+ Block_Number_t FreeBlocks = 0;\r
+ \r
+ for (Block_Number_t CurrBlock = 0; CurrBlock < NUM_BLOCKS; CurrBlock++)\r
+ {\r
+ if (!(Mem_GetBlockFlags(CurrBlock) & BLOCK_USED_MASK))\r
+ FreeBlocks++;\r
+ }\r
+ \r
+ return FreeBlocks;\r
+}\r
+\r
+Handle_Number_t Mem_TotalFreeHandles(void)\r
+{\r
+ Handle_Number_t FreeHandles = 0;\r
+ \r
+ for (Handle_Number_t CurrHandle = 0; CurrHandle < NUM_HANDLES; CurrHandle++)\r
+ {\r
+ if (Mem_MemData.Mem_Handles[CurrHandle] == NULL)\r
+ FreeHandles++;\r
+ }\r
+ \r
+ return FreeHandles;\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Dynamic, auto-defragmenting block memory allocator library. This library provides a convenient replacement for\r
+ * the standard avr-libc dynamic memory allocation routines. Memory is handed out in block chunks, to reduce the\r
+ * management memory overhead.\r
+ *\r
+ * Unlike the normal memory allocation routines, this library gives out handles to memory which must be dereferenced\r
+ * at the exact time of use, rather than handing back direct memory pointers. By using library managed handles\r
+ * instead of pointers, allocated memory blocks can be shifted around as needed transparently to defragment the\r
+ * memory as more blocks are requested.\r
+ *\r
+ * The memory heap is static, thus the total memory usage of the compiled application (as reported by the avr-size\r
+ * tool of the AVR-GCC toolchain) includes the dynamic memory heap.\r
+ *\r
+ * The constants NUM_BLOCKS, BLOCK_SIZE and NUM_HANDLES must be defined in the project makefile (and passed to the\r
+ * preprocessor via the -D GCC switch) for this library to compile.\r
+ *\r
+ * NUM_BLOCKS indicates the number of memory blocks in the memory psudoheap which can be chaned together and handed\r
+ * to the application via a memory handle. NUM_HANDLES is the maximum number of memory handles (pointing to one or\r
+ * more chained memory blocks) which can be handed out simultaneously before requring a handle (and its associated\r
+ * memory) to be freed. BLOCK_SIZE gives the number of bytes in each memory block.\r
+ */\r
+\r
+#ifndef __DYN_ALLOC__\r
+#define __DYN_ALLOC__\r
+\r
+ /* Includes : */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ #include <string.h>\r
+ \r
+ /* Preprocessor Checks: */\r
+ #if (!defined(NUM_BLOCKS) || !defined(BLOCK_SIZE) || !defined(NUM_HANDLES))\r
+ #error NUM_BLOCKS, BLOCK_SIZE and NUM_HANDLES must be defined before use via makefile.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Macro to dereference a given memory handle into the given type. The given type should be a pointer\r
+ * if the memory is to contain an array of items, or should be a standard type (such as a primative or\r
+ * structure) if the memory is to hold a single item of a single type. */\r
+ #define DEREF(handle, type) (*(type*)handle)\r
+ \r
+ /** Constant, giving the total heap size in bytes. */\r
+ #define ALLOCABLE_BYTES (1UL * NUM_BLOCKS * BLOCK_SIZE)\r
+ \r
+ /* Type Defines: */\r
+ /** Memory handle type, used to store handles given by the library functions. */\r
+ typedef const void** Mem_Handle_t;\r
+ \r
+ #if (ALLOCABLE_BYTES > 0xFFFF) || defined(__DOXYGEN__)\r
+ /** Type define for the size (in bytes) for an allocation for passing to the library functions.\r
+ * The exact type width varies depending on the value of ALLOCABLE_BYTES to ensure that a single\r
+ * allocation can request the entire heap if needed.\r
+ */\r
+ typedef uint32_t Alloc_Size_t;\r
+ #elif (ALLOCABLE_BYTES > 0xFF)\r
+ typedef uint16_t Alloc_Size_t;\r
+ #else \r
+ typedef uint8_t Alloc_Size_t;\r
+ #endif\r
+\r
+ #if (NUM_BLOCKS > 0xFFFF) || defined(__DOXYGEN__)\r
+ /** Type define for a block number in the heap. The exact type width varies depending on the\r
+ * value of NUM_BLOCKS to ensure that the type can store an index to any block in the block pool.\r
+ */\r
+ typedef uint32_t Block_Number_t;\r
+ #elif (NUM_BLOCKS > 0xFF)\r
+ typedef uint16_t Block_Number_t;\r
+ #else\r
+ typedef uint8_t Block_Number_t;\r
+ #endif\r
+\r
+ #if (NUM_HANDLES > 0xFFFF) || defined(__DOXYGEN__)\r
+ /** Type define for a handle number. The exact type width varies depending on the value of NUM_HANDLES\r
+ * to ensure that the type can store the index of any handle in the handle pool.\r
+ */\r
+ typedef uint32_t Handle_Number_t;\r
+ #elif (NUM_HANDLES > 0xFF)\r
+ typedef uint16_t Handle_Number_t;\r
+ #else \r
+ typedef uint8_t Handle_Number_t;\r
+ #endif\r
+ \r
+ /* Function Prototypes: */\r
+ /** Allocates a given number of blocks from the heap (calculated from the requested number of bytes) and\r
+ * returns a handle to the newly allocated memory.\r
+ *\r
+ * \param Bytes The number of bytes requested to be allocated from the heap\r
+ *\r
+ * \return NULL handle if the allocation fails, or handle to the allocated memory if the allocation succeeds\r
+ */\r
+ Mem_Handle_t Mem_Alloc(const Alloc_Size_t Bytes);\r
+ \r
+ /** Allocates a given number of blocks from the heap (calculated from the requested number of bytes) and\r
+ * returns a handle to the newly allocated memory. Calloced memory is automatically cleared to all 0x00\r
+ * values at the time of allocation.\r
+ *\r
+ * \param Bytes The number of pre-cleared bytes requested to be allocated from the heap\r
+ *\r
+ * \return NULL handle if the allocation fails, or handle to the allocated memory if the allocation succeeds\r
+ */\r
+ Mem_Handle_t Mem_Calloc(const Alloc_Size_t Bytes);\r
+\r
+ /** Deallocates a given memory handle, and attempts to allocates the given number of blocks from the heap\r
+ * (calculated from the requested number of bytes) immediately following the deallocation. The new memory\r
+ * may be located in the same area as the previous memory, but this is not guaranteed.\r
+ *\r
+ * \param CurrAllocHdl Handle to an already allocated section of memory in the heap to deallocate\r
+ * \param Bytes The number of bytes requested to be allocated from the heap following the\r
+ * deallocation\r
+ *\r
+ * \return NULL handle if the allocation fails, or handle to the allocated memory if the allocation succeeds\r
+ *\r
+ * \warning Even if the allocation fails, the deallocation will still occur. Care should be taken to ensure\r
+ * that the previously allocated memory is not used following an unsuccessful realloc().\r
+ */\r
+ Mem_Handle_t Mem_Realloc(Mem_Handle_t CurrAllocHdl, const Alloc_Size_t Bytes);\r
+ \r
+ /** Deallocates a given previously allocated section of memory from the heap.\r
+ *\r
+ * \param CurrAllocHdl Handle to a previously allocated section of memory in the heap\r
+ */\r
+ void Mem_Free(Mem_Handle_t CurrAllocHdl);\r
+ \r
+ /** Returns the total number of unallocated blocks in the heap.\r
+ *\r
+ * \return Number of free blocks in the heap, as a Block_Number_t integer\r
+ */\r
+ Block_Number_t Mem_TotalFreeBlocks(void);\r
+\r
+ /** Returns the total number of unallocated handles in the handle pool.\r
+ *\r
+ * \return Number of free handles in the handle pool, as a Handle_Number_t integer\r
+ */\r
+ Handle_Number_t Mem_TotalFreeHandles(void);\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define BLOCK_USED_MASK (1 << 0)\r
+ #define BLOCK_LINKED_MASK (1 << 1)\r
+ \r
+ /* Function Prototypes: */\r
+ #if defined(INCLUDE_FROM_DYNALLOC_C)\r
+ static uint8_t Mem_GetBlockFlags(const Block_Number_t BlockNum);\r
+ static void Mem_SetBlockFlags(const Block_Number_t BlockNum, const uint8_t Flags);\r
+ static void Mem_Defrag(void);\r
+ #endif\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_Migration Migrating from Older Versions\r
+ *\r
+ * Below is migration information for updating existing projects based on previous versions of the LUFA library\r
+ * to the next version released. It does not indicate all new additions to the library in each version change, only\r
+ * areas relevant to making older projects compatible with the API changes of each new release.\r
+ *\r
+ * \section Sec_MigrationXXXXXX Migrating from 090209 to XXXXXX\r
+ *\r
+ *\r
+ * \section Sec_Migration090209 Migrating from 081217 to 090209\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The ENDPOINT_MAX_ENDPOINTS constant has been renamed to the more appropriate name of ENDPOINT_TOTAL_ENDPOINTS.\r
+ * - The USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user\r
+ * makefile if desired to restore the previous 50ms timeout.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The PIPE_MAX_ENDPOINTS constant has been renamed to the more appropriate name of PIPE_TOTAL_ENDPOINTS.\r
+ * - The USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user\r
+ * makefile if desired to restore the previous 50ms timeout.\r
+ * - The USB_DeviceEnumerationFailed event now contains a second "SubErrorCode" parameter, giving the error code of the function\r
+ * which failed.\r
+ * - The HID_PARSE_Sucessful enum member constant has been corrected to HID_PARSE_Successful.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The previous SPI_SendByte() functionality is now located in SPI_TransferByte(). SPI_SendByte() now discards the return byte\r
+ * for speed, to compliment the new SPI_ReceiveByte() function. If two-way SPI transfers are required, calls to SPI_SendByte()\r
+ * should be changed to SPI_TransferByte().\r
+ * - The serial driver now sets the Tx line as an output explicitly, and enables the pullup of the Rx line.\r
+ * - The Serial_Init() and SerialStream_Init() functions now take a second DoubleSpeed parameter, which indicates if the USART\r
+ * should be initialized in double speed mode - useful in some circumstances for attaining baud rates not usually possible at\r
+ * the given AVR clock speed.\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - Most library demos have been enhanced and/or had errors corrected. All users of all demos should upgrade their codebase to\r
+ * the latest demo versions.\r
+ *\r
+ * \section Sec_Migration171208 Migrating from V1.5.3 to 081217\r
+ *\r
+ * <b>All</b>\r
+ * - The MyUSB project name has been changed to LUFA (Lightweight Framework for USB AVRs). All references to MyUSB, including macro names,\r
+ * have been changed to LUFA.\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The ReconfigureUSART() routine in the USBtoSerial demo was not being called after new line encoding\r
+ * parameters were set by the host. Projects built on the USBtoSerial code should update to the latest version.\r
+ * - The HID Parser now supports multiple report (on a single endpoint) HID devices. The MouseHostWithParser and\r
+ * KeyboardHostWithPaser demos use the updated API functions to function correctly on such devices. Projects\r
+ * built on either "WithParser" demo should update to the latest code.\r
+ * - The RNDIS demo TCP stack has been modified so that connections can be properly closed. It is still not\r
+ * recommended that the MyUSB RNDIS demo TCP/IP stack be used for anything other than demonstration purposes,\r
+ * as it is neither a full nor a standards compliant implementation.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The Serial_IsCharRecieved() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask\r
+ * to be used in the Options parameter of the USB_Init() function.\r
+ * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is\r
+ * currently initialized.\r
+ * - Interrupts are now disabled when processing control requests, to avoid problems with interrupts causing the library\r
+ * or user request processing code to exceed the strict USB timing requirements on control transfers.\r
+ * - The USB Reset event now resets and disables all device endpoints. If user code depends on endpoints remaining configured\r
+ * after a Reset event, it should be altered to explicitly re-initialize all user endpoints.\r
+ * - The prototype for the GetDescriptor function has been changed, as the return value was redundant. The function now\r
+ * returns the size of the descriptor, rather than passing it back via a parameter, or returns NO_DESCRIPTOR if the specified\r
+ * descriptor does not exist.\r
+ * - The NO_DESCRIPTOR_STRING macro has been renamed NO_DESCRIPTOR, and is now also used as a possible return value for the\r
+ * GetDescriptor function.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask\r
+ * to be used in the Options parameter of the USB_Init() function.\r
+ * - The HID report parser now supports multiple Report IDs. The HID report parser GetReportItemInfo() and\r
+ * SetReportItemInfo() routines now return a boolean, set if the requested report item was located in the\r
+ * current report. If sending a report to a multi-report device, the first byte of the report is automatically\r
+ * set to the report ID of the given report item.\r
+ * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is\r
+ * currently initialized.\r
+ *\r
+ *\r
+ * \section Sec_Migration152 Migrating from V1.5.2 to V1.5.3\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - Previously, all demos contained a serial number string descriptor, filled with all zeros. A serial number\r
+ * string is required in Mass Storage devices, or devices which are to retain settings when moved between\r
+ * ports on a machine. As people were not changing the serial number value, this was causing conflicts and so\r
+ * the serial number descriptor has been removed from all but the Mass Storage demo, which requires it.\r
+ * - The AudioOut and AudioIn demos did not previously silence their endpoints when the host has deactivated\r
+ * them. Projects built upon either demo should upgrade to the latest code.\r
+ * - The FEATURE_ENDPOINT macro has been renamed FEATURE_ENDPOINT_HALT, and is now correctly documented.\r
+ * - The MassStoreHost demo contained errors which caused it to lock up randomly on certain devices. Projects built\r
+ * on the MassStoreDemo code should update to the latest version.\r
+ * - The Interrupt type endpoint in the CDC based demos previously had a polling interval of 0x02, which caused\r
+ * problems on some Linux systems. This has been changed to 0xFF, projects built on the CDC demos should upgrade\r
+ * to the latest code.\r
+ * - The HID keyboard and mouse demos were not previously boot mode compatible. To enable boot mode support, projects\r
+ * built on the keyboard or mouse demos (or derivatives) should upgrade to the latest code.\r
+ * - The Mass Storage demo was not previously standards compliant. Projects built on the Mass Storage demo should\r
+ * upgrade to the latest code.\r
+ * - The USART was not being reconfigured after the host sent new encoding settings in the USBtoSerial demo. This was\r
+ * previously discovered and fixed, but the change was lost. Projects built on the USBtoSerial demo should update\r
+ * to the latest code.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The endpoint non-control stream functions now have a default timeout of 50ms between packets in the stream.\r
+ * If this timeout is exceeded, the function returns the new ENDPOINT_RWSTREAM_ERROR_Timeout error value. The\r
+ * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired\r
+ * timeout duration in ms.\r
+ * - Rather than returning fixed values, the flags indicating if the device has Remote Wakeup currently enabled\r
+ * and/or is self-powered are now accessed and set through the new USB_RemoteWakeupEnabled and\r
+ * USB_CurrentlySelfPowered macros. See the DevChapter9.h documentation for more details.\r
+ * - All endpoint stream functions now require an extra Callback function parameter. Existing code may be updated\r
+ * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by pasing\r
+ * the token NO_STREAM_CALLBACKS to the compiler using the -D switch.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The pipe non-control stream functions now have a default timeout of 50ms between packets in the stream.\r
+ * If this timeout is exceeded, the function returns the new PIPE_RWSTREAM_ERROR_Timeout error value. The\r
+ * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired\r
+ * timeout duration in ms.\r
+ * - CollectionPath_t has been renamed to HID_CollectionPath_t to be more in line with the other HID parser structures.\r
+ * - All pipe stream functions now require an extra Callback function parameter. Existing code may be updated\r
+ * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by pasing\r
+ * the token NO_STREAM_CALLBACKS to the compiler using the -D switch.\r
+ *\r
+ *\r
+ * \section Sec_Migration151 Migrating from V1.5.1 to V1.5.2\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The RNDIS demo application has been updated so that it is functional on Linux under earlier implementations\r
+ * of the RNDIS specification, which had non-standard behaviour. Projects built upon the demo should upgrade\r
+ * to the latest code.\r
+ * - The DFU class bootloader has had several bugs corrected in this release. It is recommended that where\r
+ * possible any existing devices upgrade to the latest bootloader code.\r
+ *\r
+ *\r
+ * \section Sec_Migration150 Migrating from V1.5.0 to V1.5.1\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The USBtoSerial demo was broken in the 1.5.0 release, due to incorrect register polling in place of the\r
+ * global "Transmitting" flag. The change has been reverted in this release. Projects built upon the demo\r
+ * should upgrade to the latest code.\r
+ * - The HID class demos did not implement the mandatory GetReport HID class request. Projects built upon the HID\r
+ * demos should upgrade to the latest code.\r
+ * - The HID class demos incorrectly reported themselves as boot-protocol enabled HID devices in their descriptors.\r
+ * Projects built upon the HID demos should upgrade to the latest code.\r
+ * - The MIDI device demo had incorrect AudioStreaming interface descriptors. Projects built upon the MIDI demo\r
+ * should upgrade to the latest code.\r
+ * - The AudioOut demo did not correctly tristate the speaker pins when USB was disconnected, wasting power.\r
+ * Projects built upon the AudioOut demo should upgrade to the latest code.\r
+ *\r
+ *\r
+ * \section Sec_Migration141 Migrating from V1.4.1 to V1.5.0\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - Previous versions of the library demos had incorrectly encoded BCD version numbers in the descriptors. To\r
+ * avoid such mistakes in the future, the VERSION_BCD macro has been added to StdDescriptors.h. Existing\r
+ * projects should at least manually correct the BCD version numbers, or preferably update the descriptors to\r
+ * encode the version number in BCD format using the new macro.\r
+ * - The mandatory GetReport class-specific request was accidentally ommitted from previous versions of the demos\r
+ * based on the Human Interface Device (HID) class. This has been corrected, and any user projects based on the\r
+ * HID demos should also be updated accordingly.\r
+ * - The CDC demos now correctly send an empty packet directly after a full packet, to end the transmission.\r
+ * Failure to do this on projects which always or frequently send full packets will cause buffering issues on\r
+ * the host OS. All CDC user projects are advised to update their transmission routines in the same manner as\r
+ * the library CDC demos.\r
+ * - The previous interrupt-driven Endpoint/Pipe demos did not properly save and restore the currently selected\r
+ * Endpoint/Pipe when the ISR fired. This has been corrected - user projects based on the interrupt driven\r
+ * demos should also update to properly save and restore the selected Endpoint/Pipe.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The Atomic.h and ISRMacro.h header files in MyUSB/Common have been removed, as the library is now only\r
+ * compatible with avr-libc library versions newer than the time before the functionality of the deleted\r
+ * headers was available.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The GetDescriptor function (see StdDescriptors.h) now has a new prototype, with altered parameter names and\r
+ * functions. Existing projects will need to update the GetDescriptor implementation to reflect the new API.\r
+ * The previously split Type and Index parameters are now passed as the original wValue parameter to the\r
+ * function, to make way for the USB specification wIndex parameter which is <i>not</i> the same as the\r
+ * previous Index parameter.\r
+ * - The USB_UnhandledControlPacket event (see Events.h) now has new parameter names, to be in line with the\r
+ * official USB specification. Existing code will need to be altered to use the new parameter names.\r
+ * - The USB_CreateEndpoints event (see Events.h) has been renamed to USB_ConfigurationChanged, which is more\r
+ * appropriate. It fires in an identical manner to the previously named event, thus the only change to be made\r
+ * is the event name itself in the user project.\r
+ * - The USB_Descriptor_Language_t structure no longer exists in StdDescriptors.h, as this was a\r
+ * psudo-descriptor modelled on the string descriptor. It is replaced by the true USB_Descriptor_String_t type\r
+ * descriptor as indicated in the USB specification, thus all device code must be updated accordingly.\r
+ * - The names of several Endpoint macros have been changed to be more consistant with the rest of the library,\r
+ * with no implementation changes. This means that existing code can be altered to use the new macro names\r
+ * with no other considerations required. See Endpoint.h for the new macro names.\r
+ * - The previous version of the MassStorage demo had an incorrect value in the SCSI_Request_Sense_Response_t\r
+ * strucuture named SenseData in SCSI.c which caused some problems with some hosts. User projects based on this\r
+ * demo should correct the structure value to maintain compatibility across multiple OS platforms.\r
+ * - By default, the descriptor structures use the official USB specification names for the elements. Previous\r
+ * versions of the library used non-standard (but more verbose) names, which are still usable in the current\r
+ * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file\r
+ * documentation for more details.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The USB_Host_Request_Header_t structure in HostChapter9.h (used for issuing control requests) has had its\r
+ * members renamed to the official USB specification names for requests. Existing code will need to be updated\r
+ * to use the new names.\r
+ * - The names of several Pipe macros have been changed to be more consistant with the rest of the library,\r
+ * with no implementation changes. This means that existing code can be altered to use the new macro names\r
+ * with no other considerations required. See Pipe.h for the new macro names.\r
+ * - By default, the descriptor structures use the official USB specification names for the elements. Previous\r
+ * versions of the library used non-standard (but more verbose) names, which are still usable in the current\r
+ * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file\r
+ * documentation for more details.\r
+ * - The names of the macros in Host.h for controlling the SOF generation have been renamed, see the Host.h\r
+ * module documentation for the new macro names.\r
+ *\r
+ * <b>Dual Role Mode</b>\r
+ * - The OTG.h header file has been corrected so that the macros now perform their stated functions. Any existing\r
+ * projects using custom headers to fix the broken OTG header should now be altered to once again use the OTG\r
+ * header inside the library.\r
+ * - The USB_DeviceEnumerationComplete event (see Events.h) now also fires in Device mode, when the host has\r
+ * finished enumerating the device. Projects relying on the event only firing in Host mode should be updated\r
+ * so that the event action only ocurrs when the USB_Mode global is set to USB_MODE_HOST.\r
+ */\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "Scheduler.h"\r
+\r
+volatile SchedulerDelayCounter_t Scheduler_TickCounter;\r
+volatile uint8_t Scheduler_TotalTasks;\r
+\r
+bool Scheduler_HasDelayElapsed(const uint16_t Delay, SchedulerDelayCounter_t* const DelayCounter)\r
+{\r
+ SchedulerDelayCounter_t CurrentTickValue_LCL;\r
+ SchedulerDelayCounter_t DelayCounter_LCL;\r
+ \r
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
+ {\r
+ CurrentTickValue_LCL = Scheduler_TickCounter;\r
+ }\r
+ \r
+ DelayCounter_LCL = *DelayCounter;\r
+ \r
+ if (CurrentTickValue_LCL >= DelayCounter_LCL)\r
+ {\r
+ if ((CurrentTickValue_LCL - DelayCounter_LCL) >= Delay)\r
+ {\r
+ *DelayCounter = CurrentTickValue_LCL;\r
+ return true;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if (((MAX_DELAYCTR_COUNT - DelayCounter_LCL) + CurrentTickValue_LCL) >= Delay)\r
+ {\r
+ *DelayCounter = CurrentTickValue_LCL;\r
+ return true;\r
+ } \r
+ }\r
+ \r
+ return false;\r
+}\r
+\r
+void Scheduler_SetTaskMode(const TaskPtr_t Task, const bool TaskStatus)\r
+{\r
+ TaskEntry_t* CurrTask = &Scheduler_TaskList[0];\r
+ \r
+ while (CurrTask != &Scheduler_TaskList[Scheduler_TotalTasks])\r
+ {\r
+ if (CurrTask->Task == Task)\r
+ {\r
+ CurrTask->TaskStatus = TaskStatus;\r
+ break;\r
+ }\r
+ \r
+ CurrTask++;\r
+ }\r
+}\r
+\r
+void Scheduler_SetGroupTaskMode(const uint8_t GroupID, const bool TaskStatus)\r
+{\r
+ TaskEntry_t* CurrTask = &Scheduler_TaskList[0];\r
+ \r
+ while (CurrTask != &Scheduler_TaskList[Scheduler_TotalTasks])\r
+ {\r
+ if (CurrTask->GroupID == GroupID)\r
+ CurrTask->TaskStatus = TaskStatus;\r
+ \r
+ CurrTask++;\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Simple round-robbin cooperative scheduler for use in basic projects where non realtime tasks need\r
+ * to be executed. Each task is executed in sequence, and can be enabled or disabled individually or as a group.\r
+ *\r
+ * For a task to yield it must return, thus each task should have persistant data marked with the static attribute.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * #include <LUFA/Scheduler/Scheduler.h>\r
+ * \r
+ * TASK(MyTask1);\r
+ * TASK(MyTask2);\r
+ * \r
+ * TASK_LIST\r
+ * {\r
+ * { Task: MyTask1, TaskStatus: TASK_RUN, GroupID: 1 },\r
+ * { Task: MyTask2, TaskStatus: TASK_RUN, GroupID: 1 },\r
+ * }\r
+ *\r
+ * int main(void)\r
+ * {\r
+ * Scheduler_Start();\r
+ * }\r
+ *\r
+ * TASK(MyTask1)\r
+ * {\r
+ * // Implementation Here\r
+ * }\r
+ *\r
+ * TASK(MyTask2)\r
+ * {\r
+ * // Implementation Here\r
+ * }\r
+ * \endcode\r
+ */\r
+ \r
+#ifndef __SCHEDULER_H__\r
+#define __SCHEDULER_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+ #include <stdbool.h>\r
+ \r
+ #include <util/atomic.h>\r
+\r
+ #include "../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Creates a new scheduler task body or prototype. Should be used in the form:\r
+ * \code\r
+ * TASK(TaskName); // Prototype\r
+ *\r
+ * TASK(TaskName)\r
+ * {\r
+ * // Task body\r
+ * }\r
+ * \endcode\r
+ */\r
+ #define TASK(name) void name (void)\r
+ \r
+ /** Defines a task list array, containing one or more task entries of the type TaskEntry_t. Each task list\r
+ * should be encased in curly braces and ended with a comma.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * TASK_LIST\r
+ * {\r
+ * { Task: MyTask1, TaskStatus: TASK_RUN, GroupID: 1 },\r
+ * // More task entries here\r
+ * }\r
+ * \endcode\r
+ */\r
+ #define TASK_LIST extern TaskEntry_t Scheduler_TaskList[]; TaskEntry_t Scheduler_TaskList[] = \r
+ \r
+ /** Constant, giving the maximum delay in scheduler ticks which can be stored in a variable of type\r
+ * SchedulerDelayCounter_t.\r
+ */\r
+ #define TASK_MAX_DELAY (MAX_DELAYCTR_COUNT - 1)\r
+\r
+ /** Task status mode constant, for passing to Scheduler_SetTaskMode() or Scheduler_SetGroupTaskMode(). */\r
+ #define TASK_RUN true\r
+\r
+ /** Task status mode constant, for passing to Scheduler_SetTaskMode() or Scheduler_SetGroupTaskMode(). */\r
+ #define TASK_STOP false\r
+ \r
+ /** Starts the scheduler in its infinite loop, executing running tasks. This should be placed at the end\r
+ * of the user application's main() function, as it can never return to the calling function.\r
+ */\r
+ #define Scheduler_Start() Scheduler_GoSchedule(TOTAL_TASKS);\r
+ \r
+ /** Initializes the scheduler so that the scheduler functions can be called before the scheduler itself\r
+ * is started. This must be exeucted before any scheduler function calls other than Scheduler_Start(),\r
+ * and can be ommitted if no such functions could be called before the scheduler is started.\r
+ */\r
+ #define Scheduler_Init() Scheduler_InitScheduler(TOTAL_TASKS);\r
+\r
+ /* Type Defines: */\r
+ /** Type define for a pointer to a scheduler task. */\r
+ typedef void (*TaskPtr_t)(void);\r
+ \r
+ /** Type define for a variable which can hold a tick delay value for the scheduler up to the maximum delay\r
+ * possible.\r
+ */\r
+ typedef uint16_t SchedulerDelayCounter_t;\r
+ \r
+ /** Structure for holding a single task's information in the scheduler task list. */\r
+ typedef struct\r
+ {\r
+ TaskPtr_t Task; /**< Pointer to the task to execute. */\r
+ bool TaskStatus; /**< Status of the task (either TASK_RUN or TASK_STOP). */\r
+ uint8_t GroupID; /**< Group ID of the task so that its status can be changed as a group. */\r
+ } TaskEntry_t; \r
+\r
+ /* Global Variables: */\r
+ /** Task entry list, containing the scheduler tasks, task statuses and group IDs. Each entry is of type\r
+ * TaskEntry_t and can be manipulated as desired, although it is preferential that the proper Scheduler\r
+ * functions should be used instead of direct manipulation.\r
+ */\r
+ extern TaskEntry_t Scheduler_TaskList[];\r
+ \r
+ /** Contains the total number of tasks in the task list, irrespective of if the task's status is set to\r
+ * TASK_RUN or TASK_STOP.\r
+ *\r
+ * \note This value should be treated as read-only, and never altered in user-code.\r
+ */\r
+ extern volatile uint8_t Scheduler_TotalTasks;\r
+\r
+ /** Contains the current scheduler tick count, for use with the delay functions. If the delay functions\r
+ * are used in the user code, this should be incremented each tick period so that the delays can be\r
+ * calculated.\r
+ */\r
+ extern volatile SchedulerDelayCounter_t Scheduler_TickCounter;\r
+\r
+ /* Inline Functions: */\r
+ /** Resets the delay counter value to the current tick count. This should be called to reset the period\r
+ * for a delay in a task which is dependant on the current tick value.\r
+ *\r
+ * \param DelayCounter Counter which is storing the starting tick count for a given delay.\r
+ */\r
+ static inline void Scheduler_ResetDelay(SchedulerDelayCounter_t* const DelayCounter)\r
+ ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void Scheduler_ResetDelay(SchedulerDelayCounter_t* const DelayCounter)\r
+ {\r
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
+ {\r
+ *DelayCounter = Scheduler_TickCounter;\r
+ }\r
+ }\r
+ \r
+ /* Function Prototypes: */\r
+ /** Determines if the given tick delay has elapsed, based on the given .\r
+ *\r
+ * \param Delay The delay to test for, measured in ticks\r
+ * \param DelayCounter The counter which is storing the starting tick value for the delay\r
+ *\r
+ * \return Boolean true if the delay has elapsed, false otherwise\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * static SchedulerDelayCounter_t DelayCounter = 10000; // Force immediate run on startup\r
+ * \r
+ * // Task runs every 10000 ticks, 10 seconds for this demo\r
+ * if (Scheduler_HasDelayElapsed(10000, &DelayCounter))\r
+ * {\r
+ * // Code to execute after delay interval elapsed here\r
+ * }\r
+ * \endcode\r
+ */\r
+ bool Scheduler_HasDelayElapsed(const uint16_t Delay,\r
+ SchedulerDelayCounter_t* const DelayCounter)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(2);\r
+ \r
+ /** Sets the task mode for a given task.\r
+ *\r
+ * \param Task Name of the task whose status is to be changed\r
+ * \param TaskStatus New task status for the task (TASK_RUN or TASK_STOP)\r
+ */\r
+ void Scheduler_SetTaskMode(const TaskPtr_t Task, const bool TaskStatus);\r
+ \r
+ /** Sets the task mode for a given task group ID, allowing for an entire group of tasks to have their\r
+ * statuses changed at once.\r
+ *\r
+ * \param GroupID Value of the task group ID whose status is to be changed\r
+ * \param TaskStatus New task status for tasks in the specified group (TASK_RUN or TASK_STOP)\r
+ */\r
+ void Scheduler_SetGroupTaskMode(const uint8_t GroupID, const bool TaskStatus);\r
+\r
+ /* Private Interface - For use in library only: */ \r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define TOTAL_TASKS (sizeof(Scheduler_TaskList) / sizeof(TaskEntry_t))\r
+ #define MAX_DELAYCTR_COUNT 0xFFFF\r
+\r
+ /* Inline Functions: */\r
+ static inline void Scheduler_InitScheduler(const uint8_t TotalTasks)\r
+ {\r
+ Scheduler_TotalTasks = TotalTasks;\r
+ }\r
+ \r
+ static inline void Scheduler_GoSchedule(const uint8_t TotalTasks) ATTR_NO_RETURN;\r
+ static inline void Scheduler_GoSchedule(const uint8_t TotalTasks)\r
+ {\r
+ Scheduler_InitScheduler(TotalTasks);\r
+\r
+ for (;;)\r
+ {\r
+ TaskEntry_t* CurrTask = &Scheduler_TaskList[0];\r
+ \r
+ while (CurrTask != &Scheduler_TaskList[TotalTasks])\r
+ {\r
+ if (CurrTask->TaskStatus == TASK_RUN)\r
+ CurrTask->Task();\r
+\r
+ CurrTask++;\r
+ }\r
+ }\r
+ }\r
+ #endif\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_SchedulerOverview LUFA Scheduler Overview\r
+ *\r
+ * The LUFA library comes with a small, basic round-robbin scheduler which allows for small "tasks" to be executed\r
+ * continuously in sequence, and enabled/disabled at runtime. Unlike a conventional, complex RTOS scheduler, the\r
+ * LUFA scheduler is very simple in design and operation and is essentially a loop conditionally executing a series\r
+ * of functions.\r
+ *\r
+ * Each LUFA scheduler task should be written similar to an ISR; it should execute quickly (so that no one task\r
+ * hogs the processor, preventing another from running before some sort of timeout is exceeded). Unlike normal RTOS\r
+ * tasks, each LUFA scheduler task is a regular function, and thus must be designed to be called, and designed to\r
+ * return to the calling scheduler function repeatedly. Data which must be preserved between task calls should be\r
+ * declared as global or (prefferably) as a static local variable inside the task.\r
+ *\r
+ * The scheduler consists of a task list, listing all the tasks which can be executed by the scheduler. Once started,\r
+ * each task is then called one after another, unless the task is stopped by another running task or interrupt.\r
+ *\r
+ *\r
+ * If desired, the LUFA scheduler <b>does not need to be used</b> in a LUFA powered application. A more conventional\r
+ * approach to application design can be used, or a proper scheduling RTOS inserted in the place of the LUFA scheduler.\r
+ * In the case of the former the USB task must be run manually repeatedly to maintain USB communications, and in the\r
+ * case of the latter a proper RTOS task must be set up to do the same.\r
+ *\r
+ *\r
+ * For more information on the LUFA scheduler, see the Scheduler.h file documentation.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_VIDPID VID and PID values\r
+ *\r
+ * The LUFA library uses VID/PID combinations generously donated by Atmel. The following VID/PID combinations\r
+ * are used within the LUFA demos, and thus may be re-used by derivations of each demo. Free PID values may be\r
+ * used by future LUFA demo projects.\r
+ *\r
+ * These VID/PID values should not be used in commercial designs under any circumstances. Private projects may\r
+ * use the following values freely, but must accept any collisions due to other LUFA derived private projects\r
+ * sharing identical values. It is suggested that private projects using interfaces compatible with existing\r
+ * demos share the save VID/PID value.\r
+ *\r
+ * <table>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * <b>VID</b>\r
+ * </td>\r
+ * <td>\r
+ * <b>PID</b>\r
+ * </td>\r
+ * <td>\r
+ * <b>Usage</b>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2040\r
+ * </td>\r
+ * <td>\r
+ * Test Application\r
+ * </td>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2041\r
+ * </td>\r
+ * <td>\r
+ * Mouse Demo Application (and derivatives)\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2042\r
+ * </td>\r
+ * <td>\r
+ * Keyboard Demo Application (and derivatives)\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2043\r
+ * </td>\r
+ * <td>\r
+ * Joystick Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2044\r
+ * </td>\r
+ * <td>\r
+ * CDC Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2045\r
+ * </td>\r
+ * <td>\r
+ * Mass Storage Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2046\r
+ * </td>\r
+ * <td>\r
+ * Audio Output Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2047\r
+ * </td>\r
+ * <td>\r
+ * Audio Input Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2048\r
+ * </td>\r
+ * <td>\r
+ * MIDI Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2049\r
+ * </td>\r
+ * <td>\r
+ * MagStripe Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204A\r
+ * </td>\r
+ * <td>\r
+ * CDC Bootloader\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204B\r
+ * </td>\r
+ * <td>\r
+ * USB to Serial Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204C\r
+ * </td>\r
+ * <td>\r
+ * RNDIS Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204D\r
+ * </td>\r
+ * <td>\r
+ * Keyboard and Mouse Combination Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204E\r
+ * </td>\r
+ * <td>\r
+ * Dual CDC Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204F\r
+ * </td>\r
+ * <td>\r
+ * AVRISP Programmer Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * </table>\r
+ */\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2009.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+ Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, and distribute this software\r
+ and its documentation for any purpose and without fee is hereby\r
+ granted, provided that the above copyright notice appear in all\r
+ copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Version constants for informational purposes and version-specific macro creation. This header file contains the\r
+ * current LUFA version number in several forms, for use in the user-application (for example, for printing out \r
+ * whilst debugging, or for testing for version compatibility).\r
+ */\r
+\r
+#ifndef __LUFA_VERSION_H__\r
+#define __LUFA_VERSION_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates the version number of the library, as an integer. */\r
+ #define LUFA_VERSION_INTEGER 000000\r
+\r
+ /** Indicates the version number of the library, as a string. */\r
+ #define LUFA_VERSION_STRING "000000"\r
+\r
+#endif\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_WritingBoardDrivers Writing LUFA Board Drivers\r
+ *\r
+ * LUFA ships with several basic pre-made board drivers, to control hardware present on the supported board\r
+ * hardware - such as Dataflash ICs, LEDs, Joysticks, or other hardware peripherals. When compiling an application\r
+ * which makes use of one or more board drivers located in LUFA/Drivers/Board, you must also indicate what board\r
+ * hardware you are using in your project makefile. This is done by defining the BOARD macro using the -D switch\r
+ * passed to the compiler, with a constant of BOARD_{Name}. For example <b>-DBOARD=BOARD_USBKEY</b> instructs the\r
+ * compiler to use the USBKEY board hardware drivers.\r
+ *\r
+ * If your application does not use *any* board level drivers, you can ommit the definition of the BOARD macro.\r
+ * However, some users may wish to write their own custom board hardware drivers which are to remain compatible\r
+ * with the LUFA hardware API. To do this, the BOARD macro should be defined to the value BOARD_USER. This indicates\r
+ * that the board level drivers should be located in a folder named "Board" located inside the application's folder.\r
+ *\r
+ * When used, the driver stub files located in the DriverStubs folder should be copied to the user Board directory,\r
+ * and fleshed out to include the values and code needed to control the custom board hardware. Once done, the existing\r
+ * LUFA board level APIs (accessed in the regular LUFA/Drivers/Board/ folder) will redirect to the user board drivers,\r
+ * maintaining code compatibility and allowing for a different board to be selected through the project makefile with\r
+ * no code changes.\r
+ */\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2009.\r
+# \r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.fourwalledcubicle.com\r
+#\r
+\r
+# Makefile for the LUFA library itself.\r
+\r
+LUFA_SRC_FILES = ./Drivers/USB/LowLevel/LowLevel.c \\r
+ ./Drivers/USB/LowLevel/Endpoint.c \\r
+ ./Drivers/USB/LowLevel/Pipe.c \\r
+ ./Drivers/USB/LowLevel/DevChapter9.c \\r
+ ./Drivers/USB/LowLevel/HostChapter9.c \\r
+ ./Drivers/USB/LowLevel/Host.c \\r
+ ./Drivers/USB/HighLevel/USBTask.c \\r
+ ./Drivers/USB/HighLevel/USBInterrupt.c \\r
+ ./Drivers/USB/HighLevel/Events.c \\r
+ ./Drivers/USB/HighLevel/StdDescriptors.c \\r
+ ./Drivers/USB/Class/HIDParser.c \\r
+ ./Drivers/USB/Class/ConfigDescriptor.c \\r
+ ./Scheduler/Scheduler.c \\r
+ ./MemoryAllocator/DynAlloc.c \\r
+ ./Drivers/Board/Temperature.c \\r
+ ./Drivers/AT90USBXXX/Serial.c \\r
+ ./Drivers/AT90USBXXX/Serial_Stream.c \\r
+\r
+all:\r
+ \r
+clean:\r
+ rm -f $(LUFA_SRC_FILES:%.c=%.o)\r
+ \r
+clean_list:\r
+\r
+doxygen:\r
+ @echo Generating Library Documentation...\r
+ @doxygen Doxygen.conf\r
+ @echo Documentation Generation Complete.\r
+\r
+clean_doxygen:\r
+ rm -rf Documentation\r