-<Project name="LUFA"><Folder name="Demos"><Folder name="Device"><Folder name="ClassDriver"><Folder name="AudioInput"><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.c"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.h"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.txt"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioInput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioInput\makefile"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.aps"></File></Folder><Folder name="AudioOutput"><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.txt"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioOutput\makefile"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.aps"></File></Folder><Folder name="DualVirtualSerial"><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.txt"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\LUFA DualVirtualSerial.inf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\makefile"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.aps"></File></Folder><Folder name="GenericHID"><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.c"></File><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.h"></File><File path="Demos\Device\ClassDriver\GenericHID\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.c"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.h"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.txt"></File><File path="Demos\Device\ClassDriver\GenericHID\makefile"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.aps"></File></Folder><Folder name="Joystick"><File path="Demos\Device\ClassDriver\Joystick\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Joystick\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Joystick\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.c"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.h"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.txt"></File><File path="Demos\Device\ClassDriver\Joystick\makefile"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.aps"></File></Folder><Folder name="Keyboard"><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.txt"></File><File path="Demos\Device\ClassDriver\Keyboard\makefile"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.aps"></File></Folder><Folder name="KeyboardMouse"><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.txt"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\makefile"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.aps"></File></Folder><Folder name="KeyboardMouseMultiReport"><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.txt"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\makefile"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.aps"></File></Folder><Folder name="MassStorage"><Folder name="Lib"><File path="Demos\Device\ClassDriver\MassStorage\Lib\DataflashManager.c"></File><File path="Demos\Device\ClassDriver\MassStorage\Lib\DataflashManager.h"></File><File path="Demos\Device\ClassDriver\MassStorage\Lib\SCSI.c"></File><File path="Demos\Device\ClassDriver\MassStorage\Lib\SCSI.h"></File></Folder><File path="Demos\Device\ClassDriver\MassStorage\Descriptors.c"></File><File path="Demos\Device\ClassDriver\MassStorage\Descriptors.h"></File><File path="Demos\Device\ClassDriver\MassStorage\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\MassStorage\makefile"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.c"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.h"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.txt"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.aps"></File></Folder><Folder name="MassStorageKeyboard"><Folder name="Lib"><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\DataflashManager.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\DataflashManager.h"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\SCSI.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\SCSI.h"></File></Folder><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Descriptors.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Descriptors.h"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\makefile"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.h"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.txt"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.aps"></File></Folder><Folder name="MIDI"><File path="Demos\Device\ClassDriver\MIDI\Descriptors.c"></File><File path="Demos\Device\ClassDriver\MIDI\Descriptors.h"></File><File path="Demos\Device\ClassDriver\MIDI\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\MIDI\makefile"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.c"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.h"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.txt"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.aps"></File></Folder><Folder name="Mouse"><File path="Demos\Device\ClassDriver\Mouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Mouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Mouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Mouse\makefile"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.c"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.h"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.txt"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.aps"></File></Folder><Folder name="RNDISEthernet"><Folder name="Lib"><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Webserver.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ARP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ARP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\DHCP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\DHCP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Ethernet.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Ethernet.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\EthernetProtocols.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ICMP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ICMP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\IP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\IP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ProtocolDecoders.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ProtocolDecoders.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\TCP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\TCP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\UDP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\UDP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Webserver.c"></File></Folder><File path="Demos\Device\ClassDriver\RNDISEthernet\Descriptors.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Descriptors.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\LUFA RNDIS.inf"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\makefile"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.txt"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.aps"></File></Folder><Folder name="VirtualSerial"><File path="Demos\Device\ClassDriver\VirtualSerial\Descriptors.c"></File><File path="Demos\Device\ClassDriver\VirtualSerial\Descriptors.h"></File><File path="Demos\Device\ClassDriver\VirtualSerial\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\VirtualSerial\LUFA VirtualSerial.inf"></File><File path="Demos\Device\ClassDriver\VirtualSerial\makefile"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.c"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.h"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.txt"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.aps"></File></Folder><Folder name="VirtualSerialMouse"><File path="Demos\Device\ClassDriver\VirtualSerialMouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\LUFA VirtualSerialMouse.inf"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\makefile"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.c"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.h"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.txt"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.aps"></File></Folder><File path="Demos\Device\ClassDriver\makefile"></File></Folder><Folder name="LowLevel"><Folder name="AudioInput"><File path="Demos\Device\LowLevel\AudioInput\AudioInput.c"></File><File path="Demos\Device\LowLevel\AudioInput\AudioInput.h"></File><File path="Demos\Device\LowLevel\AudioInput\AudioInput.txt"></File><File path="Demos\Device\LowLevel\AudioInput\Descriptors.c"></File><File path="Demos\Device\LowLevel\AudioInput\Descriptors.h"></File><File path="Demos\Device\LowLevel\AudioInput\Doxygen.conf"></File><File path="Demos\Device\LowLevel\AudioInput\makefile"></File><File path="Demos\Device\LowLevel\AudioInput\AudioInput.aps"></File></Folder><Folder name="AudioOutput"><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.c"></File><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.h"></File><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.txt"></File><File path="Demos\Device\LowLevel\AudioOutput\Descriptors.c"></File><File path="Demos\Device\LowLevel\AudioOutput\Descriptors.h"></File><File path="Demos\Device\LowLevel\AudioOutput\Doxygen.conf"></File><File path="Demos\Device\LowLevel\AudioOutput\makefile"></File><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.aps"></File></Folder><Folder name="DualVirtualSerial"><File path="Demos\Device\LowLevel\DualVirtualSerial\Descriptors.c"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\Descriptors.h"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\Doxygen.conf"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.c"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.h"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.txt"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\LUFA DualVirtualSerial.inf"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\makefile"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.aps"></File></Folder><Folder name="GenericHID"><File path="Demos\Device\LowLevel\GenericHID\Descriptors.c"></File><File path="Demos\Device\LowLevel\GenericHID\Descriptors.h"></File><File path="Demos\Device\LowLevel\GenericHID\Doxygen.conf"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.c"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.h"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.txt"></File><File path="Demos\Device\LowLevel\GenericHID\makefile"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.aps"></File></Folder><Folder name="Joystick"><File path="Demos\Device\LowLevel\Joystick\Descriptors.c"></File><File path="Demos\Device\LowLevel\Joystick\Descriptors.h"></File><File path="Demos\Device\LowLevel\Joystick\Doxygen.conf"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.c"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.h"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.txt"></File><File path="Demos\Device\LowLevel\Joystick\makefile"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.aps"></File></Folder><Folder name="Keyboard"><File path="Demos\Device\LowLevel\Keyboard\Descriptors.c"></File><File path="Demos\Device\LowLevel\Keyboard\Descriptors.h"></File><File path="Demos\Device\LowLevel\Keyboard\Doxygen.conf"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.c"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.h"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.txt"></File><File path="Demos\Device\LowLevel\Keyboard\makefile"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.aps"></File></Folder><Folder name="KeyboardMouse"><File path="Demos\Device\LowLevel\KeyboardMouse\Descriptors.c"></File><File path="Demos\Device\LowLevel\KeyboardMouse\Descriptors.h"></File><File path="Demos\Device\LowLevel\KeyboardMouse\Doxygen.conf"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.c"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.h"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.txt"></File><File path="Demos\Device\LowLevel\KeyboardMouse\makefile"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.aps"></File></Folder><Folder name="MassStorage"><Folder name="Lib"><File path="Demos\Device\LowLevel\MassStorage\Lib\DataflashManager.c"></File><File path="Demos\Device\LowLevel\MassStorage\Lib\DataflashManager.h"></File><File path="Demos\Device\LowLevel\MassStorage\Lib\SCSI.c"></File><File path="Demos\Device\LowLevel\MassStorage\Lib\SCSI.h"></File></Folder><File path="Demos\Device\LowLevel\MassStorage\Descriptors.c"></File><File path="Demos\Device\LowLevel\MassStorage\Descriptors.h"></File><File path="Demos\Device\LowLevel\MassStorage\Doxygen.conf"></File><File path="Demos\Device\LowLevel\MassStorage\makefile"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.c"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.h"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.txt"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.aps"></File></Folder><Folder name="MIDI"><File path="Demos\Device\LowLevel\MIDI\Descriptors.c"></File><File path="Demos\Device\LowLevel\MIDI\Descriptors.h"></File><File path="Demos\Device\LowLevel\MIDI\Doxygen.conf"></File><File path="Demos\Device\LowLevel\MIDI\makefile"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.c"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.h"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.txt"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.aps"></File></Folder><Folder name="Mouse"><File path="Demos\Device\LowLevel\Mouse\Descriptors.c"></File><File path="Demos\Device\LowLevel\Mouse\Descriptors.h"></File><File path="Demos\Device\LowLevel\Mouse\Doxygen.conf"></File><File path="Demos\Device\LowLevel\Mouse\makefile"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.c"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.h"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.txt"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.aps"></File></Folder><Folder name="RNDISEthernet"><Folder name="Lib"><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Webserver.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ARP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ARP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\DHCP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\DHCP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Ethernet.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Ethernet.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\EthernetProtocols.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ICMP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ICMP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\IP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\IP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ProtocolDecoders.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ProtocolDecoders.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\RNDIS.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\RNDIS.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\TCP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\TCP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\UDP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\UDP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Webserver.c"></File></Folder><File path="Demos\Device\LowLevel\RNDISEthernet\Descriptors.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Descriptors.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Doxygen.conf"></File><File path="Demos\Device\LowLevel\RNDISEthernet\LUFA RNDIS.inf"></File><File path="Demos\Device\LowLevel\RNDISEthernet\makefile"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.txt"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.aps"></File></Folder><Folder name="VirtualSerial"><File path="Demos\Device\LowLevel\VirtualSerial\Descriptors.c"></File><File path="Demos\Device\LowLevel\VirtualSerial\Descriptors.h"></File><File path="Demos\Device\LowLevel\VirtualSerial\Doxygen.conf"></File><File path="Demos\Device\LowLevel\VirtualSerial\LUFA VirtualSerial.inf"></File><File path="Demos\Device\LowLevel\VirtualSerial\makefile"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.c"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.h"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.txt"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.aps"></File></Folder><File path="Demos\Device\LowLevel\makefile"></File></Folder><Folder name="Incomplete"><Folder name="SideShow"><Folder name="Lib"><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowApplications.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowApplications.h"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommands.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommands.h"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommon.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommon.h"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowContent.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowContent.h"></File></Folder><File path="Demos\Device\Incomplete\Sideshow\Descriptors.c"></File><File path="Demos\Device\Incomplete\Sideshow\Descriptors.h"></File><File path="Demos\Device\Incomplete\Sideshow\makefile"></File><File path="Demos\Device\Incomplete\Sideshow\Sideshow.c"></File><File path="Demos\Device\Incomplete\Sideshow\Sideshow.h"></File></Folder><Folder name="TestAndMeasurement"><File path="Demos\Device\Incomplete\TestAndMeasurement\Descriptors.c"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\Descriptors.h"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\TestAndMeasurement.c"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\TestAndMeasurement.h"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\makefile"></File></Folder></Folder><File path="Demos\Device\makefile"></File></Folder><Folder name="Host"><Folder name="ClassDriver"><Folder name="JoystickHostWithParser"><File path="Demos\Host\ClassDriver\JoystickHostWithParser\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.c"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.h"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.txt"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\makefile"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.aps"></File></Folder><Folder name="KeyboardHost"><File path="Demos\Host\ClassDriver\KeyboardHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.c"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.h"></File><File path="Demos\Host\ClassDriver\KeyboardHost\makefile"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.txt"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.aps"></File></Folder><Folder name="KeyboardHostWithParser"><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.c"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.h"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\makefile"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.txt"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.aps"></File></Folder><Folder name="MassStorageHost"><File path="Demos\Host\ClassDriver\MassStorageHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MassStorageHost\makefile"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.c"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.h"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.txt"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.aps"></File></Folder><Folder name="MIDIHost"><File path="Demos\Host\ClassDriver\MIDIHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MIDIHost\makefile"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.c"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.h"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.txt"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.aps"></File></Folder><Folder name="MouseHost"><File path="Demos\Host\ClassDriver\MouseHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MouseHost\makefile"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.c"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.h"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.txt"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.aps"></File></Folder><Folder name="MouseHostWithParser"><File path="Demos\Host\ClassDriver\MouseHostWithParser\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\makefile"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.txt"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.c"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.h"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.aps"></File></Folder><Folder name="PrinterHost"><File path="Demos\Host\ClassDriver\PrinterHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\PrinterHost\makefile"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.c"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.h"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.txt"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.aps"></File></Folder><Folder name="RNDISEthernetHost"><File path="Demos\Host\ClassDriver\RNDISEthernetHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\makefile"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.c"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.h"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.txt"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.aps"></File></Folder><Folder name="StillImageHost"><File path="Demos\Host\ClassDriver\StillImageHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\StillImageHost\makefile"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.c"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.h"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.txt"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.aps"></File></Folder><Folder name="VirtualSerialHost"><File path="Demos\Host\ClassDriver\VirtualSerialHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\makefile"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.c"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.h"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.txt"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.aps"></File></Folder><File path="Demos\Host\ClassDriver\makefile"></File></Folder><Folder name="LowLevel"><Folder name="GenericHIDHost"><File path="Demos\Host\LowLevel\GenericHIDHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\GenericHIDHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\GenericHIDHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.c"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.h"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.txt"></File><File path="Demos\Host\LowLevel\GenericHIDHost\makefile"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.aps"></File></Folder><Folder name="JoystickHostWithParser"><File path="Demos\Host\LowLevel\JoystickHostWithParser\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\Doxygen.conf"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\HIDReport.c"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\HIDReport.h"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.c"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.h"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.txt"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\makefile"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.aps"></File></Folder><Folder name="KeyboardHost"><File path="Demos\Host\LowLevel\KeyboardHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\KeyboardHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\KeyboardHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.c"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.h"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.txt"></File><File path="Demos\Host\LowLevel\KeyboardHost\makefile"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.aps"></File></Folder><Folder name="KeyboardHostWithParser"><File path="Demos\Host\LowLevel\KeyboardHostWithParser\makefile"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\Doxygen.conf"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\HIDReport.c"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\HIDReport.h"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.c"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.h"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.txt"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.aps"></File></Folder><Folder name="MassStorageHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\MassStorageHost\Lib\MassStoreCommands.c"></File><File path="Demos\Host\LowLevel\MassStorageHost\Lib\MassStoreCommands.h"></File></Folder><File path="Demos\Host\LowLevel\MassStorageHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MassStorageHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MassStorageHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MassStorageHost\makefile"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.c"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.h"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.txt"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.aps"></File></Folder><Folder name="MIDIHost"><File path="Demos\Host\LowLevel\MIDIHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MIDIHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MIDIHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MIDIHost\makefile"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.c"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.h"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.txt"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.aps"></File></Folder><Folder name="MouseHost"><File path="Demos\Host\LowLevel\MouseHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MouseHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MouseHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MouseHost\makefile"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.c"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.h"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.txt"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.aps"></File></Folder><Folder name="MouseHostWithParser"><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.txt"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\HIDReport.c"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\HIDReport.h"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\makefile"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.c"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.h"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.aps"></File></Folder><Folder name="PrinterHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\PrinterHost\Lib\PrinterCommands.c"></File><File path="Demos\Host\LowLevel\PrinterHost\Lib\PrinterCommands.h"></File></Folder><File path="Demos\Host\LowLevel\PrinterHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\PrinterHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\PrinterHost\makefile"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.c"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.h"></File><File path="Demos\Host\LowLevel\PrinterHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.txt"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.aps"></File></Folder><Folder name="RNDISEthernetHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\RNDISEthernetHost\Lib\RNDISCommands.c"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\Lib\RNDISCommands.h"></File></Folder><File path="Demos\Host\LowLevel\RNDISEthernetHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\makefile"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISEthernetHost.c"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISEthernetHost.h"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISHost.txt"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISEthernetHost.aps"></File></Folder><Folder name="StillImageHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\StillImageHost\Lib\StillImageCommands.c"></File><File path="Demos\Host\LowLevel\StillImageHost\Lib\StillImageCommands.h"></File><File path="Demos\Host\LowLevel\StillImageHost\Lib\PIMACodes.h"></File></Folder><File path="Demos\Host\LowLevel\StillImageHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\StillImageHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\StillImageHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\StillImageHost\makefile"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.c"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.h"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.txt"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.aps"></File></Folder><Folder name="VirtualSerialHost"><File path="Demos\Host\LowLevel\VirtualSerialHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\makefile"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.c"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.h"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.txt"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.aps"></File></Folder><File path="Demos\Host\LowLevel\makefile"></File></Folder><Folder name="Incomplete"><Folder name="BluetoothHost"><Folder name="Lib"><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothACLPackets.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothACLPackets.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothClassCodes.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothHCICommands.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothHCICommands.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothStack.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothStack.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDPServices.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDPServices.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMM.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMM.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDP.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDP.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMMControl.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMMControl.h"></File></Folder><File path="Demos\Host\Incomplete\BluetoothHost\makefile"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothHost.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothHost.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\ConfigDescriptor.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\ConfigDescriptor.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\DeviceDescriptor.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\DeviceDescriptor.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Doxygen.conf"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothEvents.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothEvents.h"></File></Folder></Folder><File path="Demos\Host\makefile"></File></Folder><Folder name="DualRole"><Folder name="ClassDriver"><Folder name="MouseHostDevice"><File path="Demos\DualRole\ClassDriver\MouseHostDevice\Doxygen.conf"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\makefile"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\Descriptors.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\Descriptors.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\DeviceFunctions.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\HostFunctions.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\HostFunctions.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\DeviceFunctions.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.txt"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.aps"></File></Folder><File path="Demos\DualRole\ClassDriver\makefile"></File></Folder><File path="Demos\DualRole\makefile"></File></Folder><File path="Demos\makefile"></File></Folder><Folder name="LUFA"><Folder name="Common"><File path="LUFA\Common\Common.h"></File><File path="LUFA\Common\BoardTypes.h"></File><File path="LUFA\Common\Attributes.h"></File><File path="LUFA\Common\Architectures.h"></File></Folder><Folder name="Drivers"><Folder name="USB"><Folder name="Core"><Folder name="AVR8"><File path="LUFA\Drivers\USB\Core\AVR8\Device.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Device.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\Endpoint.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Endpoint.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\Host.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Host.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\OTG.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\Pipe.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Pipe.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBController.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBController.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBInterrupt.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBInterrupt.h"></File></Folder><Folder name="UC3B"><File path="LUFA\Drivers\USB\Core\UC3B\Device.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Device.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\Endpoint.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Endpoint.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\Host.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Host.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\OTG.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\Pipe.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Pipe.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBController.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBController.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBInterrupt.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBInterrupt.h"></File></Folder><Folder name="Template"><File path="LUFA\Drivers\USB\Core\Template\Template_Endpoint_Control_R.c"></File><File path="LUFA\Drivers\USB\Core\Template\Template_Endpoint_Control_W.c"></File><File path="LUFA\Drivers\USB\Core\Template\Template_Endpoint_RW.c"></File><File path="LUFA\Drivers\USB\Core\Template\Template_Pipe_RW.c"></File></Folder><File path="LUFA\Drivers\USB\Core\ConfigDescriptor.c"></File><File path="LUFA\Drivers\USB\Core\ConfigDescriptor.h"></File><File path="LUFA\Drivers\USB\Core\DeviceStandardReq.c"></File><File path="LUFA\Drivers\USB\Core\DeviceStandardReq.h"></File><File path="LUFA\Drivers\USB\Core\EndpointStream.c"></File><File path="LUFA\Drivers\USB\Core\EndpointStream.h"></File><File path="LUFA\Drivers\USB\Core\Events.c"></File><File path="LUFA\Drivers\USB\Core\Events.h"></File><File path="LUFA\Drivers\USB\Core\HostStandardReq.c"></File><File path="LUFA\Drivers\USB\Core\HostStandardReq.h"></File><File path="LUFA\Drivers\USB\Core\PipeStream.c"></File><File path="LUFA\Drivers\USB\Core\PipeStream.h"></File><File path="LUFA\Drivers\USB\Core\StdDescriptors.h"></File><File path="LUFA\Drivers\USB\Core\StdRequestType.h"></File><File path="LUFA\Drivers\USB\Core\USBMode.h"></File><File path="LUFA\Drivers\USB\Core\USBTask.c"></File><File path="LUFA\Drivers\USB\Core\USBTask.h"></File><File path="LUFA\Drivers\USB\Core\Device.h"></File><File path="LUFA\Drivers\USB\Core\Endpoint.h"></File><File path="LUFA\Drivers\USB\Core\Host.h"></File><File path="LUFA\Drivers\USB\Core\OTG.h"></File><File path="LUFA\Drivers\USB\Core\Pipe.h"></File><File path="LUFA\Drivers\USB\Core\USBController.h"></File><File path="LUFA\Drivers\USB\Core\USBInterrupt.h"></File></Folder><Folder name="Class"><Folder name="Device"><File path="LUFA\Drivers\USB\Class\Device\HID.c"></File><File path="LUFA\Drivers\USB\Class\Device\HID.h"></File><File path="LUFA\Drivers\USB\Class\Device\CDC.c"></File><File path="LUFA\Drivers\USB\Class\Device\CDC.h"></File><File path="LUFA\Drivers\USB\Class\Device\RNDIS.c"></File><File path="LUFA\Drivers\USB\Class\Device\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\Device\MassStorage.c"></File><File path="LUFA\Drivers\USB\Class\Device\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\Device\Audio.c"></File><File path="LUFA\Drivers\USB\Class\Device\Audio.h"></File><File path="LUFA\Drivers\USB\Class\Device\MIDI.c"></File><File path="LUFA\Drivers\USB\Class\Device\MIDI.h"></File></Folder><Folder name="Host"><File path="LUFA\Drivers\USB\Class\Host\CDC.c"></File><File path="LUFA\Drivers\USB\Class\Host\CDC.h"></File><File path="LUFA\Drivers\USB\Class\Host\HID.c"></File><File path="LUFA\Drivers\USB\Class\Host\HID.h"></File><File path="LUFA\Drivers\USB\Class\Host\MassStorage.c"></File><File path="LUFA\Drivers\USB\Class\Host\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\Host\StillImage.c"></File><File path="LUFA\Drivers\USB\Class\Host\StillImage.h"></File><File path="LUFA\Drivers\USB\Class\Host\MIDI.c"></File><File path="LUFA\Drivers\USB\Class\Host\MIDI.h"></File><File path="LUFA\Drivers\USB\Class\Host\Printer.c"></File><File path="LUFA\Drivers\USB\Class\Host\Printer.h"></File><File path="LUFA\Drivers\USB\Class\Host\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\Host\RNDIS.c"></File></Folder><Folder name="Common"><File path="LUFA\Drivers\USB\Class\Common\Audio.h"></File><File path="LUFA\Drivers\USB\Class\Common\CDC.h"></File><File path="LUFA\Drivers\USB\Class\Common\HID.h"></File><File path="LUFA\Drivers\USB\Class\Common\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\Common\MIDI.h"></File><File path="LUFA\Drivers\USB\Class\Common\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\Common\StillImage.h"></File><File path="LUFA\Drivers\USB\Class\Common\Printer.h"></File><File path="LUFA\Drivers\USB\Class\Common\HIDParser.c"></File><File path="LUFA\Drivers\USB\Class\Common\HIDParser.h"></File><File path="LUFA\Drivers\USB\Class\Common\HIDReportData.h"></File></Folder><File path="LUFA\Drivers\USB\Class\Audio.h"></File><File path="LUFA\Drivers\USB\Class\CDC.h"></File><File path="LUFA\Drivers\USB\Class\HID.h"></File><File path="LUFA\Drivers\USB\Class\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\MIDI.h"></File><File path="LUFA\Drivers\USB\Class\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\StillImage.h"></File><File path="LUFA\Drivers\USB\Class\Printer.h"></File></Folder><File path="LUFA\Drivers\USB\USB.h"></File></Folder><Folder name="Misc"><File path="LUFA\Drivers\Misc\TerminalCodes.h"></File><File path="LUFA\Drivers\Misc\RingBuffer.h"></File><File path="LUFA\Drivers\Misc\AT45DB321C.h"></File><File path="LUFA\Drivers\Misc\AT45DB642D.h"></File></Folder><Folder name="Board"><Folder name="ADAFRUITU4"><File path="LUFA\Drivers\Board\ADAFRUITU4\LEDs.h"></File></Folder><Folder name="ATAVRUSBRF01"><File path="LUFA\Drivers\Board\ATAVRUSBRF01\LEDs.h"></File><File path="LUFA\Drivers\Board\ATAVRUSBRF01\Buttons.h"></File></Folder><Folder name="BENITO"><File path="LUFA\Drivers\Board\BENITO\LEDs.h"></File><File path="LUFA\Drivers\Board\BENITO\Buttons.h"></File></Folder><Folder name="BUMBLEB"><File path="LUFA\Drivers\Board\BUMBLEB\Buttons.h"></File><File path="LUFA\Drivers\Board\BUMBLEB\Joystick.h"></File><File path="LUFA\Drivers\Board\BUMBLEB\LEDs.h"></File></Folder><Folder name="BUI"><File path="LUFA\Drivers\Board\BUI\LEDs.h"></File></Folder><Folder name="BLACKCAT"><File path="LUFA\Drivers\Board\BLACKCAT\LEDs.h"></File></Folder><Folder name="CULV3"><File path="LUFA\Drivers\Board\CULV3\Buttons.h"></File><File path="LUFA\Drivers\Board\CULV3\LEDs.h"></File></Folder><Folder name="EVK527"><File path="LUFA\Drivers\Board\EVK527\Buttons.h"></File><File path="LUFA\Drivers\Board\EVK527\LEDs.h"></File><File path="LUFA\Drivers\Board\EVK527\Joystick.h"></File><File path="LUFA\Drivers\Board\EVK527\Dataflash.h"></File></Folder><Folder name="EVK1101"><File path="LUFA\Drivers\Board\EVK1101\Buttons.h"></File><File path="LUFA\Drivers\Board\EVK1101\Joystick.h"></File><File path="LUFA\Drivers\Board\EVK1101\LEDs.h"></File></Folder><Folder name="JMDBU2"><File path="LUFA\Drivers\Board\JMDBU2\Buttons.h"></File><File path="LUFA\Drivers\Board\JMDBU2\LEDs.h"></File></Folder><Folder name="MAXIMUS"><File path="LUFA\Drivers\Board\MAXIMUS\LEDs.h"></File></Folder><Folder name="MICROSIN162"><File path="LUFA\Drivers\Board\MICROSIN162\LEDs.h"></File><File path="LUFA\Drivers\Board\MICROSIN162\Buttons.h"></File></Folder><Folder name="MINIMUS"><File path="LUFA\Drivers\Board\MINIMUS\Buttons.h"></File><File path="LUFA\Drivers\Board\MINIMUS\LEDs.h"></File></Folder><Folder name="OLIMEX162"><File path="LUFA\Drivers\Board\OLIMEX162\LEDs.h"></File><File path="LUFA\Drivers\Board\OLIMEX162\Buttons.h"></File></Folder><Folder name="RZUSBSTICK"><File path="LUFA\Drivers\Board\RZUSBSTICK\LEDs.h"></File></Folder><Folder name="SPARKFUN8U2"><File path="LUFA\Drivers\Board\SPARKFUN8U2\LEDs.h"></File></Folder><Folder name="STK525"><File path="LUFA\Drivers\Board\STK525\Dataflash.h"></File><File path="LUFA\Drivers\Board\STK525\Joystick.h"></File><File path="LUFA\Drivers\Board\STK525\LEDs.h"></File><File path="LUFA\Drivers\Board\STK525\Buttons.h"></File></Folder><Folder name="STK526"><File path="LUFA\Drivers\Board\STK526\Dataflash.h"></File><File path="LUFA\Drivers\Board\STK526\Joystick.h"></File><File path="LUFA\Drivers\Board\STK526\LEDs.h"></File><File path="LUFA\Drivers\Board\STK526\Buttons.h"></File></Folder><Folder name="TEENSY"><File path="LUFA\Drivers\Board\TEENSY\LEDs.h"></File></Folder><Folder name="UDIP"><File path="LUFA\Drivers\Board\UDIP\LEDs.h"></File><File path="LUFA\Drivers\Board\UDIP\Buttons.h"></File></Folder><Folder name="UNO"><File path="LUFA\Drivers\Board\UNO\LEDs.h"></File></Folder><Folder name="USBFOO"><File path="LUFA\Drivers\Board\USBFOO\Buttons.h"></File><File path="LUFA\Drivers\Board\USBFOO\LEDS.h"></File></Folder><Folder name="USBKEY"><File path="LUFA\Drivers\Board\USBKEY\Dataflash.h"></File><File path="LUFA\Drivers\Board\USBKEY\Joystick.h"></File><File path="LUFA\Drivers\Board\USBKEY\LEDs.h"></File><File path="LUFA\Drivers\Board\USBKEY\Buttons.h"></File></Folder><Folder name="USBTINYMKII"><File path="LUFA\Drivers\Board\USBTINYMKII\LEDs.h"></File><File path="LUFA\Drivers\Board\USBTINYMKII\Buttons.h"></File></Folder><Folder name="XPLAIN"><File path="LUFA\Drivers\Board\XPLAIN\LEDs.h"></File><File path="LUFA\Drivers\Board\XPLAIN\Dataflash.h"></File></Folder><File path="LUFA\Drivers\Board\Temperature.h"></File><File path="LUFA\Drivers\Board\Dataflash.h"></File><File path="LUFA\Drivers\Board\Joystick.h"></File><File path="LUFA\Drivers\Board\Temperature.c"></File><File path="LUFA\Drivers\Board\LEDs.h"></File><File path="LUFA\Drivers\Board\Buttons.h"></File></Folder><Folder name="Peripheral"><Folder name="AVR8"><File path="LUFA\Drivers\Peripheral\AVR8\ADC.h"></File><File path="LUFA\Drivers\Peripheral\AVR8\Serial.c"></File><File path="LUFA\Drivers\Peripheral\AVR8\Serial.h"></File><File path="LUFA\Drivers\Peripheral\AVR8\SPI.h"></File><File path="LUFA\Drivers\Peripheral\AVR8\TWI.c"></File><File path="LUFA\Drivers\Peripheral\AVR8\TWI.h"></File></Folder><File path="LUFA\Drivers\Peripheral\ADC.h"></File><File path="LUFA\Drivers\Peripheral\TWI.h"></File><File path="LUFA\Drivers\Peripheral\Serial.h"></File><File path="LUFA\Drivers\Peripheral\SPI.h"></File></Folder></Folder><Folder name="ManPages"><File path="LUFA\ManPages\AboutLUFA.txt"></File><File path="LUFA\ManPages\BuildingLinkableLibraries.txt"></File><File path="LUFA\ManPages\ChangeLog.txt"></File><File path="LUFA\ManPages\CompileTimeTokens.txt"></File><File path="LUFA\ManPages\DevelopingWithLUFA.txt"></File><File path="LUFA\ManPages\DeviceSupport.txt"></File><File path="LUFA\ManPages\DirectorySummaries.txt"></File><File path="LUFA\ManPages\Donating.txt"></File><File path="LUFA\ManPages\FutureChanges.txt"></File><File path="LUFA\ManPages\GettingStarted.txt"></File><File path="LUFA\ManPages\Groups.txt"></File><File path="LUFA\ManPages\LibraryResources.txt"></File><File path="LUFA\ManPages\LUFAPoweredProjects.txt"></File><File path="LUFA\ManPages\MainPage.txt"></File><File path="LUFA\ManPages\MigrationInformation.txt"></File><File path="LUFA\ManPages\VIDAndPIDValues.txt"></File><File path="LUFA\ManPages\WritingBoardDrivers.txt"></File><File path="LUFA\ManPages\ConfiguringApps.txt"></File><File path="LUFA\ManPages\CompilingApps.txt"></File><File path="LUFA\ManPages\ProgrammingApps.txt"></File><File path="LUFA\ManPages\LibraryApps.txt"></File><File path="LUFA\ManPages\WhyUseLUFA.txt"></File><File path="LUFA\ManPages\LUFAvsAtmelStack.txt"></File><File path="LUFA\ManPages\AlternativeStacks.txt"></File><File path="LUFA\ManPages\SoftwareBootloaderJump.txt"></File><File path="LUFA\ManPages\LicenseInfo.txt"></File></Folder><Folder name="Scheduler"><File path="LUFA\Scheduler\Scheduler.c"></File><File path="LUFA\Scheduler\Scheduler.h"></File></Folder><Folder name="CodeTemplates"><Folder name="DriverStubs"><File path="LUFA\CodeTemplates\DriverStubs\Buttons.h"></File><File path="LUFA\CodeTemplates\DriverStubs\Dataflash.h"></File><File path="LUFA\CodeTemplates\DriverStubs\Joystick.h"></File><File path="LUFA\CodeTemplates\DriverStubs\LEDs.h"></File></Folder><File path="LUFA\CodeTemplates\makefile_template"></File></Folder><File path="LUFA\makefile"></File><File path="LUFA\Version.h"></File><File path="LUFA\Doxygen.conf"></File><File path="LUFA\License.txt"></File></Folder><Folder name="Bootloaders"><Folder name="CDC"><File path="Bootloaders\CDC\BootloaderCDC.c"></File><File path="Bootloaders\CDC\BootloaderCDC.h"></File><File path="Bootloaders\CDC\Descriptors.c"></File><File path="Bootloaders\CDC\Descriptors.h"></File><File path="Bootloaders\CDC\makefile"></File><File path="Bootloaders\CDC\LUFA CDC Bootloader.inf"></File><File path="Bootloaders\CDC\Doxygen.conf"></File><File path="Bootloaders\CDC\BootloaderCDC.txt"></File><File path="Bootloaders\CDC\BootloaderCDC.aps"></File></Folder><Folder name="DFU"><File path="Bootloaders\DFU\BootloaderDFU.c"></File><File path="Bootloaders\DFU\BootloaderDFU.h"></File><File path="Bootloaders\DFU\Descriptors.c"></File><File path="Bootloaders\DFU\Descriptors.h"></File><File path="Bootloaders\DFU\makefile"></File><File path="Bootloaders\DFU\BootloaderDFU.txt"></File><File path="Bootloaders\DFU\Doxygen.conf"></File><File path="Bootloaders\DFU\BootloaderDFU.aps"></File></Folder><Folder name="HID"><Folder name="HostLoaderApp"><File path="Bootloaders\HID\HostLoaderApp\gpl3.txt"></File><File path="Bootloaders\HID\HostLoaderApp\Makefile"></File><File path="Bootloaders\HID\HostLoaderApp\Makefile.bsd"></File><File path="Bootloaders\HID\HostLoaderApp\hid_bootloader_cli.c"></File></Folder><File path="Bootloaders\HID\Descriptors.c"></File><File path="Bootloaders\HID\Descriptors.h"></File><File path="Bootloaders\HID\makefile"></File><File path="Bootloaders\HID\BootloaderHID.txt"></File><File path="Bootloaders\HID\BootloaderHID.c"></File><File path="Bootloaders\HID\BootloaderHID.h"></File><File path="Bootloaders\HID\Doxygen.conf"></File><File path="Bootloaders\HID\BootloaderHID.aps"></File></Folder><File path="Bootloaders\makefile"></File></Folder><Folder name="Projects"><Folder name="AVRISP-MKII"><Folder name="Lib"><Folder name="ISP"><File path="Projects\AVRISP-MKII\Lib\ISP\ISPProtocol.c"></File><File path="Projects\AVRISP-MKII\Lib\ISP\ISPProtocol.h"></File><File path="Projects\AVRISP-MKII\Lib\ISP\ISPTarget.c"></File><File path="Projects\AVRISP-MKII\Lib\ISP\ISPTarget.h"></File></Folder><Folder name="XPROG"><File path="Projects\AVRISP-MKII\Lib\XPROG\TINYNVM.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\TINYNVM.h"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XMEGANVM.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XMEGANVM.h"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGProtocol.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGProtocol.h"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGTarget.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGTarget.h"></File></Folder><File path="Projects\AVRISP-MKII\Lib\V2Protocol.c"></File><File path="Projects\AVRISP-MKII\Lib\V2Protocol.h"></File><File path="Projects\AVRISP-MKII\Lib\V2ProtocolConstants.h"></File><File path="Projects\AVRISP-MKII\Lib\V2ProtocolParams.c"></File><File path="Projects\AVRISP-MKII\Lib\V2ProtocolParams.h"></File></Folder><File path="Projects\AVRISP-MKII\Descriptors.c"></File><File path="Projects\AVRISP-MKII\Descriptors.h"></File><File path="Projects\AVRISP-MKII\Doxygen.conf"></File><File path="Projects\AVRISP-MKII\makefile"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.c"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.h"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.txt"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.aps"></File></Folder><Folder name="Benito"><File path="Projects\Benito\Benito.c"></File><File path="Projects\Benito\Benito.h"></File><File path="Projects\Benito\Descriptors.c"></File><File path="Projects\Benito\Descriptors.h"></File><File path="Projects\Benito\Doxygen.conf"></File><File path="Projects\Benito\makefile"></File><File path="Projects\Benito\Benito.txt"></File><File path="Projects\Benito\Benito Programmer.inf"></File><File path="Projects\Benito\Benito.aps"></File></Folder><Folder name="LEDNotifier"><Folder name="CPUUsageApp"><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.cs"></File><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.csproj"></File><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.Designer.cs"></File><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.resx"></File><File path="Projects\LEDNotifier\CPUUsageApp\Program.cs"></File></Folder><Folder name="HotmailNotifierApp"><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.cs"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.csproj"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.Designer.cs"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.resx"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\Program.cs"></File></Folder><Folder name="LEDMixerApp"><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.cs"></File><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.csproj"></File><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.Designer.cs"></File><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.resx"></File><File path="Projects\LEDNotifier\LEDMixerApp\Program.cs"></File></Folder><File path="Projects\LEDNotifier\Descriptors.c"></File><File path="Projects\LEDNotifier\Descriptors.h"></File><File path="Projects\LEDNotifier\Doxygen.conf"></File><File path="Projects\LEDNotifier\LEDNotifier.c"></File><File path="Projects\LEDNotifier\LEDNotifier.h"></File><File path="Projects\LEDNotifier\LEDNotifier.txt"></File><File path="Projects\LEDNotifier\LUFA LED Notifier.inf"></File><File path="Projects\LEDNotifier\makefile"></File><File path="Projects\LEDNotifier\LEDNotifier.aps"></File></Folder><Folder name="MagStripe"><Folder name="Lib"><File path="Projects\Magstripe\Lib\CircularBitBuffer.c"></File><File path="Projects\Magstripe\Lib\CircularBitBuffer.h"></File><File path="Projects\Magstripe\Lib\MagstripeHW.h"></File></Folder><File path="Projects\Magstripe\Descriptors.c"></File><File path="Projects\Magstripe\Descriptors.h"></File><File path="Projects\Magstripe\Magstripe.c"></File><File path="Projects\Magstripe\Magstripe.h"></File><File path="Projects\Magstripe\makefile"></File><File path="Projects\Magstripe\Magstripe.txt"></File><File path="Projects\Magstripe\Doxygen.conf"></File><File path="Projects\Magstripe\Magstripe.aps"></File></Folder><Folder name="MIDIToneGenerator"><File path="Projects\MIDIToneGenerator\Descriptors.c"></File><File path="Projects\MIDIToneGenerator\Descriptors.h"></File><File path="Projects\MIDIToneGenerator\makefile"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.c"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.h"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.txt"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.aps"></File></Folder><Folder name="MissileLauncher"><File path="Projects\MissileLauncher\ConfigDescriptor.c"></File><File path="Projects\MissileLauncher\ConfigDescriptor.h"></File><File path="Projects\MissileLauncher\Doxygen.conf"></File><File path="Projects\MissileLauncher\makefile"></File><File path="Projects\MissileLauncher\MissileLauncher.c"></File><File path="Projects\MissileLauncher\MissileLauncher.h"></File><File path="Projects\MissileLauncher\MissileLauncher.txt"></File><File path="Projects\MissileLauncher\MissileLauncher.aps"></File></Folder><Folder name="RelayBoard"><File path="Projects\RelayBoard\Descriptors.c"></File><File path="Projects\RelayBoard\Descriptors.h"></File><File path="Projects\RelayBoard\Doxygen.conf"></File><File path="Projects\RelayBoard\makefile"></File><File path="Projects\RelayBoard\RelayBoard.c"></File><File path="Projects\RelayBoard\RelayBoard.h"></File><File path="Projects\RelayBoard\RelayBoard.txt"></File><File path="Projects\RelayBoard\RelayBoard.aps"></File></Folder><Folder name="TempDataLogger"><Folder name="Lib"><Folder name="FATFs"><File path="Projects\TempDataLogger\Lib\FATFs\diskio.c"></File><File path="Projects\TempDataLogger\Lib\FATFs\diskio.h"></File><File path="Projects\TempDataLogger\Lib\FATFs\ff.c"></File><File path="Projects\TempDataLogger\Lib\FATFs\ff.h"></File><File path="Projects\TempDataLogger\Lib\FATFs\ffconf.h"></File><File path="Projects\TempDataLogger\Lib\FATFs\integer.h"></File></Folder><File path="Projects\TempDataLogger\Lib\DataflashManager.c"></File><File path="Projects\TempDataLogger\Lib\DataflashManager.h"></File><File path="Projects\TempDataLogger\Lib\DS1307.c"></File><File path="Projects\TempDataLogger\Lib\DS1307.h"></File><File path="Projects\TempDataLogger\Lib\SCSI.c"></File><File path="Projects\TempDataLogger\Lib\SCSI.h"></File></Folder><Folder name="TempLogHostApp"><File path="Projects\TempDataLogger\TempLogHostApp\DataLoggerSettings.cs"></File><File path="Projects\TempDataLogger\TempLogHostApp\DataLoggerSettings.Designer.cs"></File><File path="Projects\TempDataLogger\TempLogHostApp\DataLoggerSettings.resx"></File><File path="Projects\TempDataLogger\TempLogHostApp\Program.cs"></File><File path="Projects\TempDataLogger\TempLogHostApp\TempLoggerHostApp.csproj"></File></Folder><File path="Projects\TempDataLogger\Descriptors.c"></File><File path="Projects\TempDataLogger\Descriptors.h"></File><File path="Projects\TempDataLogger\Doxygen.conf"></File><File path="Projects\TempDataLogger\makefile"></File><File path="Projects\TempDataLogger\TempDataLogger.c"></File><File path="Projects\TempDataLogger\TempDataLogger.h"></File><File path="Projects\TempDataLogger\TemperatureDataLogger.txt"></File><File path="Projects\TempDataLogger\TempDataLogger.aps"></File></Folder><Folder name="USBtoSerial"><File path="Projects\USBtoSerial\Descriptors.h"></File><File path="Projects\USBtoSerial\Doxygen.conf"></File><File path="Projects\USBtoSerial\LUFA USBtoSerial.inf"></File><File path="Projects\USBtoSerial\makefile"></File><File path="Projects\USBtoSerial\USBtoSerial.c"></File><File path="Projects\USBtoSerial\USBtoSerial.h"></File><File path="Projects\USBtoSerial\USBtoSerial.txt"></File><File path="Projects\USBtoSerial\USBtoSerial.aps"></File><File path="Projects\USBtoSerial\Descriptors.c"></File></Folder><Folder name="Webserver"><Folder name="Lib"><Folder name="uip"><File path="Projects\Webserver\Lib\uip\clock.c"></File><File path="Projects\Webserver\Lib\uip\clock.h"></File><File path="Projects\Webserver\Lib\uip\timer.c"></File><File path="Projects\Webserver\Lib\uip\timer.h"></File><File path="Projects\Webserver\Lib\uip\uip.c"></File><File path="Projects\Webserver\Lib\uip\uip.h"></File><File path="Projects\Webserver\Lib\uip\uip_arp.c"></File><File path="Projects\Webserver\Lib\uip\uip_arp.h"></File><File path="Projects\Webserver\Lib\uip\uipopt.h"></File><File path="Projects\Webserver\Lib\uip\uip-split.c"></File><File path="Projects\Webserver\Lib\uip\uip-split.h"></File></Folder><Folder name="FATFs"><File path="Projects\Webserver\Lib\FATFs\diskio.c"></File><File path="Projects\Webserver\Lib\FATFs\diskio.h"></File><File path="Projects\Webserver\Lib\FATFs\ff.c"></File><File path="Projects\Webserver\Lib\FATFs\ff.h"></File><File path="Projects\Webserver\Lib\FATFs\ffconf.h"></File><File path="Projects\Webserver\Lib\FATFs\integer.h"></File></Folder><File path="Projects\Webserver\Lib\DataflashManager.c"></File><File path="Projects\Webserver\Lib\DataflashManager.h"></File><File path="Projects\Webserver\Lib\uIPManagement.c"></File><File path="Projects\Webserver\Lib\uIPManagement.h"></File><File path="Projects\Webserver\Lib\HTTPServerApp.c"></File><File path="Projects\Webserver\Lib\HTTPServerApp.h"></File><File path="Projects\Webserver\Lib\SCSI.c"></File><File path="Projects\Webserver\Lib\SCSI.h"></File><File path="Projects\Webserver\Lib\DHCPClientApp.c"></File><File path="Projects\Webserver\Lib\DHCPClientApp.h"></File><File path="Projects\Webserver\Lib\TELNETServerApp.c"></File><File path="Projects\Webserver\Lib\TELNETServerApp.h"></File></Folder><File path="Projects\Webserver\makefile"></File><File path="Projects\Webserver\Webserver.c"></File><File path="Projects\Webserver\Webserver.h"></File><File path="Projects\Webserver\Doxygen.conf"></File><File path="Projects\Webserver\Webserver.txt"></File><File path="Projects\Webserver\Descriptors.c"></File><File path="Projects\Webserver\Descriptors.h"></File><File path="Projects\Webserver\USBHostMode.c"></File><File path="Projects\Webserver\USBHostMode.h"></File><File path="Projects\Webserver\USBDeviceMode.c"></File><File path="Projects\Webserver\USBDeviceMode.h"></File><File path="Projects\Webserver\Webserver.aps"></File></Folder><Folder name="XPLAINBridge"><Folder name="Lib"><File path="Projects\XPLAINBridge\Lib\SoftUART.c"></File><File path="Projects\XPLAINBridge\Lib\SoftUART.h"></File></Folder><File path="Projects\XPLAINBridge\XPLAINBridge.txt"></File><File path="Projects\XPLAINBridge\XPLAINBridge.h"></File><File path="Projects\XPLAINBridge\XPLAINBridge.c"></File><File path="Projects\XPLAINBridge\XPLAINBridge.aps"></File><File path="Projects\XPLAINBridge\USARTDescriptors.h"></File><File path="Projects\XPLAINBridge\USARTDescriptors.c"></File><File path="Projects\XPLAINBridge\makefile"></File><File path="Projects\XPLAINBridge\LUFA XPLAIN Bridge.inf"></File><File path="Projects\XPLAINBridge\Doxygen.conf"></File><File path="Projects\XPLAINBridge\AVRISPDescriptors.h"></File><File path="Projects\XPLAINBridge\AVRISPDescriptors.c"></File></Folder><Folder name="Incomplete"><Folder name="StandaloneProgrammer"><Folder name="Lib"><Folder name="PetiteFATFs"><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\diskio.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\diskio.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\integer.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\pff.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\pff.h"></File></Folder><File path="Projects\Incomplete\StandaloneProgrammer\Lib\DataflashManager.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\DataflashManager.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\SCSI.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\SCSI.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\ProgrammerConfig.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\ProgrammerConfig.h"></File></Folder><File path="Projects\Incomplete\StandaloneProgrammer\Descriptors.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Descriptors.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\makefile"></File><File path="Projects\Incomplete\StandaloneProgrammer\StandaloneProgrammer.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\StandaloneProgrammer.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskDevice.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskDevice.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskHost.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskHost.h"></File></Folder></Folder><File path="Projects\makefile"></File></Folder><File path="makefile"></File><File path="README.txt"></File></Project>
\ No newline at end of file
+<Project name="LUFA"><Folder name="Demos"><Folder name="Device"><Folder name="ClassDriver"><Folder name="AudioInput"><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.c"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.h"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.txt"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioInput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioInput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioInput\makefile"></File><File path="Demos\Device\ClassDriver\AudioInput\AudioInput.aps"></File></Folder><Folder name="AudioOutput"><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.txt"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.c"></File><File path="Demos\Device\ClassDriver\AudioOutput\Descriptors.h"></File><File path="Demos\Device\ClassDriver\AudioOutput\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\AudioOutput\makefile"></File><File path="Demos\Device\ClassDriver\AudioOutput\AudioOutput.aps"></File></Folder><Folder name="DualVirtualSerial"><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Descriptors.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.c"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.h"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.txt"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\LUFA DualVirtualSerial.inf"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\makefile"></File><File path="Demos\Device\ClassDriver\DualVirtualSerial\DualVirtualSerial.aps"></File></Folder><Folder name="GenericHID"><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.c"></File><File path="Demos\Device\ClassDriver\GenericHID\Descriptors.h"></File><File path="Demos\Device\ClassDriver\GenericHID\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.c"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.h"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.txt"></File><File path="Demos\Device\ClassDriver\GenericHID\makefile"></File><File path="Demos\Device\ClassDriver\GenericHID\GenericHID.aps"></File></Folder><Folder name="Joystick"><File path="Demos\Device\ClassDriver\Joystick\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Joystick\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Joystick\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.c"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.h"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.txt"></File><File path="Demos\Device\ClassDriver\Joystick\makefile"></File><File path="Demos\Device\ClassDriver\Joystick\Joystick.aps"></File></Folder><Folder name="Keyboard"><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.c"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.h"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.txt"></File><File path="Demos\Device\ClassDriver\Keyboard\makefile"></File><File path="Demos\Device\ClassDriver\Keyboard\Keyboard.aps"></File></Folder><Folder name="KeyboardMouse"><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.txt"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\makefile"></File><File path="Demos\Device\ClassDriver\KeyboardMouse\KeyboardMouse.aps"></File></Folder><Folder name="KeyboardMouseMultiReport"><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Descriptors.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.c"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.h"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.txt"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\makefile"></File><File path="Demos\Device\ClassDriver\KeyboardMouseMultiReport\KeyboardMouseMultiReport.aps"></File></Folder><Folder name="MassStorage"><Folder name="Lib"><File path="Demos\Device\ClassDriver\MassStorage\Lib\DataflashManager.c"></File><File path="Demos\Device\ClassDriver\MassStorage\Lib\DataflashManager.h"></File><File path="Demos\Device\ClassDriver\MassStorage\Lib\SCSI.c"></File><File path="Demos\Device\ClassDriver\MassStorage\Lib\SCSI.h"></File></Folder><File path="Demos\Device\ClassDriver\MassStorage\Descriptors.c"></File><File path="Demos\Device\ClassDriver\MassStorage\Descriptors.h"></File><File path="Demos\Device\ClassDriver\MassStorage\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\MassStorage\makefile"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.c"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.h"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.txt"></File><File path="Demos\Device\ClassDriver\MassStorage\MassStorage.aps"></File></Folder><Folder name="MassStorageKeyboard"><Folder name="Lib"><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\DataflashManager.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\DataflashManager.h"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\SCSI.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Lib\SCSI.h"></File></Folder><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Descriptors.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Descriptors.h"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\makefile"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.c"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.h"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.txt"></File><File path="Demos\Device\ClassDriver\MassStorageKeyboard\MassStorageKeyboard.aps"></File></Folder><Folder name="MIDI"><File path="Demos\Device\ClassDriver\MIDI\Descriptors.c"></File><File path="Demos\Device\ClassDriver\MIDI\Descriptors.h"></File><File path="Demos\Device\ClassDriver\MIDI\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\MIDI\makefile"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.c"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.h"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.txt"></File><File path="Demos\Device\ClassDriver\MIDI\MIDI.aps"></File></Folder><Folder name="Mouse"><File path="Demos\Device\ClassDriver\Mouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\Mouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\Mouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\Mouse\makefile"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.c"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.h"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.txt"></File><File path="Demos\Device\ClassDriver\Mouse\Mouse.aps"></File></Folder><Folder name="RNDISEthernet"><Folder name="Lib"><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Webserver.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ARP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ARP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\DHCP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\DHCP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Ethernet.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Ethernet.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\EthernetProtocols.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ICMP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ICMP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\IP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\IP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ProtocolDecoders.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\ProtocolDecoders.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\TCP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\TCP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\UDP.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\UDP.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Lib\Webserver.c"></File></Folder><File path="Demos\Device\ClassDriver\RNDISEthernet\Descriptors.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Descriptors.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\LUFA RNDIS.inf"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\makefile"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.c"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.h"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.txt"></File><File path="Demos\Device\ClassDriver\RNDISEthernet\RNDISEthernet.aps"></File></Folder><Folder name="VirtualSerial"><File path="Demos\Device\ClassDriver\VirtualSerial\Descriptors.c"></File><File path="Demos\Device\ClassDriver\VirtualSerial\Descriptors.h"></File><File path="Demos\Device\ClassDriver\VirtualSerial\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\VirtualSerial\LUFA VirtualSerial.inf"></File><File path="Demos\Device\ClassDriver\VirtualSerial\makefile"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.c"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.h"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.txt"></File><File path="Demos\Device\ClassDriver\VirtualSerial\VirtualSerial.aps"></File></Folder><Folder name="VirtualSerialMouse"><File path="Demos\Device\ClassDriver\VirtualSerialMouse\Descriptors.c"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\Descriptors.h"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\Doxygen.conf"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\LUFA VirtualSerialMouse.inf"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\makefile"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.c"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.h"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.txt"></File><File path="Demos\Device\ClassDriver\VirtualSerialMouse\VirtualSerialMouse.aps"></File></Folder><File path="Demos\Device\ClassDriver\makefile"></File></Folder><Folder name="LowLevel"><Folder name="AudioInput"><File path="Demos\Device\LowLevel\AudioInput\AudioInput.c"></File><File path="Demos\Device\LowLevel\AudioInput\AudioInput.h"></File><File path="Demos\Device\LowLevel\AudioInput\AudioInput.txt"></File><File path="Demos\Device\LowLevel\AudioInput\Descriptors.c"></File><File path="Demos\Device\LowLevel\AudioInput\Descriptors.h"></File><File path="Demos\Device\LowLevel\AudioInput\Doxygen.conf"></File><File path="Demos\Device\LowLevel\AudioInput\makefile"></File><File path="Demos\Device\LowLevel\AudioInput\AudioInput.aps"></File></Folder><Folder name="AudioOutput"><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.c"></File><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.h"></File><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.txt"></File><File path="Demos\Device\LowLevel\AudioOutput\Descriptors.c"></File><File path="Demos\Device\LowLevel\AudioOutput\Descriptors.h"></File><File path="Demos\Device\LowLevel\AudioOutput\Doxygen.conf"></File><File path="Demos\Device\LowLevel\AudioOutput\makefile"></File><File path="Demos\Device\LowLevel\AudioOutput\AudioOutput.aps"></File></Folder><Folder name="DualVirtualSerial"><File path="Demos\Device\LowLevel\DualVirtualSerial\Descriptors.c"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\Descriptors.h"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\Doxygen.conf"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.c"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.h"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.txt"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\LUFA DualVirtualSerial.inf"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\makefile"></File><File path="Demos\Device\LowLevel\DualVirtualSerial\DualVirtualSerial.aps"></File></Folder><Folder name="GenericHID"><File path="Demos\Device\LowLevel\GenericHID\Descriptors.c"></File><File path="Demos\Device\LowLevel\GenericHID\Descriptors.h"></File><File path="Demos\Device\LowLevel\GenericHID\Doxygen.conf"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.c"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.h"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.txt"></File><File path="Demos\Device\LowLevel\GenericHID\makefile"></File><File path="Demos\Device\LowLevel\GenericHID\GenericHID.aps"></File></Folder><Folder name="Joystick"><File path="Demos\Device\LowLevel\Joystick\Descriptors.c"></File><File path="Demos\Device\LowLevel\Joystick\Descriptors.h"></File><File path="Demos\Device\LowLevel\Joystick\Doxygen.conf"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.c"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.h"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.txt"></File><File path="Demos\Device\LowLevel\Joystick\makefile"></File><File path="Demos\Device\LowLevel\Joystick\Joystick.aps"></File></Folder><Folder name="Keyboard"><File path="Demos\Device\LowLevel\Keyboard\Descriptors.c"></File><File path="Demos\Device\LowLevel\Keyboard\Descriptors.h"></File><File path="Demos\Device\LowLevel\Keyboard\Doxygen.conf"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.c"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.h"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.txt"></File><File path="Demos\Device\LowLevel\Keyboard\makefile"></File><File path="Demos\Device\LowLevel\Keyboard\Keyboard.aps"></File></Folder><Folder name="KeyboardMouse"><File path="Demos\Device\LowLevel\KeyboardMouse\Descriptors.c"></File><File path="Demos\Device\LowLevel\KeyboardMouse\Descriptors.h"></File><File path="Demos\Device\LowLevel\KeyboardMouse\Doxygen.conf"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.c"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.h"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.txt"></File><File path="Demos\Device\LowLevel\KeyboardMouse\makefile"></File><File path="Demos\Device\LowLevel\KeyboardMouse\KeyboardMouse.aps"></File></Folder><Folder name="MassStorage"><Folder name="Lib"><File path="Demos\Device\LowLevel\MassStorage\Lib\DataflashManager.c"></File><File path="Demos\Device\LowLevel\MassStorage\Lib\DataflashManager.h"></File><File path="Demos\Device\LowLevel\MassStorage\Lib\SCSI.c"></File><File path="Demos\Device\LowLevel\MassStorage\Lib\SCSI.h"></File></Folder><File path="Demos\Device\LowLevel\MassStorage\Descriptors.c"></File><File path="Demos\Device\LowLevel\MassStorage\Descriptors.h"></File><File path="Demos\Device\LowLevel\MassStorage\Doxygen.conf"></File><File path="Demos\Device\LowLevel\MassStorage\makefile"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.c"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.h"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.txt"></File><File path="Demos\Device\LowLevel\MassStorage\MassStorage.aps"></File></Folder><Folder name="MIDI"><File path="Demos\Device\LowLevel\MIDI\Descriptors.c"></File><File path="Demos\Device\LowLevel\MIDI\Descriptors.h"></File><File path="Demos\Device\LowLevel\MIDI\Doxygen.conf"></File><File path="Demos\Device\LowLevel\MIDI\makefile"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.c"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.h"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.txt"></File><File path="Demos\Device\LowLevel\MIDI\MIDI.aps"></File></Folder><Folder name="Mouse"><File path="Demos\Device\LowLevel\Mouse\Descriptors.c"></File><File path="Demos\Device\LowLevel\Mouse\Descriptors.h"></File><File path="Demos\Device\LowLevel\Mouse\Doxygen.conf"></File><File path="Demos\Device\LowLevel\Mouse\makefile"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.c"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.h"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.txt"></File><File path="Demos\Device\LowLevel\Mouse\Mouse.aps"></File></Folder><Folder name="RNDISEthernet"><Folder name="Lib"><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Webserver.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ARP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ARP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\DHCP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\DHCP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Ethernet.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Ethernet.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\EthernetProtocols.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ICMP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ICMP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\IP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\IP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ProtocolDecoders.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\ProtocolDecoders.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\RNDIS.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\RNDIS.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\TCP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\TCP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\UDP.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\UDP.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Lib\Webserver.c"></File></Folder><File path="Demos\Device\LowLevel\RNDISEthernet\Descriptors.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Descriptors.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\Doxygen.conf"></File><File path="Demos\Device\LowLevel\RNDISEthernet\LUFA RNDIS.inf"></File><File path="Demos\Device\LowLevel\RNDISEthernet\makefile"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.c"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.h"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.txt"></File><File path="Demos\Device\LowLevel\RNDISEthernet\RNDISEthernet.aps"></File></Folder><Folder name="VirtualSerial"><File path="Demos\Device\LowLevel\VirtualSerial\Descriptors.c"></File><File path="Demos\Device\LowLevel\VirtualSerial\Descriptors.h"></File><File path="Demos\Device\LowLevel\VirtualSerial\Doxygen.conf"></File><File path="Demos\Device\LowLevel\VirtualSerial\LUFA VirtualSerial.inf"></File><File path="Demos\Device\LowLevel\VirtualSerial\makefile"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.c"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.h"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.txt"></File><File path="Demos\Device\LowLevel\VirtualSerial\VirtualSerial.aps"></File></Folder><File path="Demos\Device\LowLevel\makefile"></File></Folder><Folder name="Incomplete"><Folder name="SideShow"><Folder name="Lib"><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowApplications.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowApplications.h"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommands.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommands.h"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommon.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowCommon.h"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowContent.c"></File><File path="Demos\Device\Incomplete\Sideshow\Lib\SideshowContent.h"></File></Folder><File path="Demos\Device\Incomplete\Sideshow\Descriptors.c"></File><File path="Demos\Device\Incomplete\Sideshow\Descriptors.h"></File><File path="Demos\Device\Incomplete\Sideshow\makefile"></File><File path="Demos\Device\Incomplete\Sideshow\Sideshow.c"></File><File path="Demos\Device\Incomplete\Sideshow\Sideshow.h"></File></Folder><Folder name="TestAndMeasurement"><File path="Demos\Device\Incomplete\TestAndMeasurement\Descriptors.c"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\Descriptors.h"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\TestAndMeasurement.c"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\TestAndMeasurement.h"></File><File path="Demos\Device\Incomplete\TestAndMeasurement\makefile"></File></Folder></Folder><File path="Demos\Device\makefile"></File></Folder><Folder name="Host"><Folder name="ClassDriver"><Folder name="JoystickHostWithParser"><File path="Demos\Host\ClassDriver\JoystickHostWithParser\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.c"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.h"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.txt"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\makefile"></File><File path="Demos\Host\ClassDriver\JoystickHostWithParser\JoystickHostWithParser.aps"></File></Folder><Folder name="KeyboardHost"><File path="Demos\Host\ClassDriver\KeyboardHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.c"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.h"></File><File path="Demos\Host\ClassDriver\KeyboardHost\makefile"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.txt"></File><File path="Demos\Host\ClassDriver\KeyboardHost\KeyboardHost.aps"></File></Folder><Folder name="KeyboardHostWithParser"><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.c"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.h"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\makefile"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.txt"></File><File path="Demos\Host\ClassDriver\KeyboardHostWithParser\KeyboardHostWithParser.aps"></File></Folder><Folder name="MassStorageHost"><File path="Demos\Host\ClassDriver\MassStorageHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MassStorageHost\makefile"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.c"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.h"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.txt"></File><File path="Demos\Host\ClassDriver\MassStorageHost\MassStorageHost.aps"></File></Folder><Folder name="MIDIHost"><File path="Demos\Host\ClassDriver\MIDIHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MIDIHost\makefile"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.c"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.h"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.txt"></File><File path="Demos\Host\ClassDriver\MIDIHost\MIDIHost.aps"></File></Folder><Folder name="MouseHost"><File path="Demos\Host\ClassDriver\MouseHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MouseHost\makefile"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.c"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.h"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.txt"></File><File path="Demos\Host\ClassDriver\MouseHost\MouseHost.aps"></File></Folder><Folder name="MouseHostWithParser"><File path="Demos\Host\ClassDriver\MouseHostWithParser\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\makefile"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.txt"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.c"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.h"></File><File path="Demos\Host\ClassDriver\MouseHostWithParser\MouseHostWithParser.aps"></File></Folder><Folder name="PrinterHost"><File path="Demos\Host\ClassDriver\PrinterHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\PrinterHost\makefile"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.c"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.h"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.txt"></File><File path="Demos\Host\ClassDriver\PrinterHost\PrinterHost.aps"></File></Folder><Folder name="RNDISEthernetHost"><File path="Demos\Host\ClassDriver\RNDISEthernetHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\makefile"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.c"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.h"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.txt"></File><File path="Demos\Host\ClassDriver\RNDISEthernetHost\RNDISEthernetHost.aps"></File></Folder><Folder name="StillImageHost"><File path="Demos\Host\ClassDriver\StillImageHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\StillImageHost\makefile"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.c"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.h"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.txt"></File><File path="Demos\Host\ClassDriver\StillImageHost\StillImageHost.aps"></File></Folder><Folder name="VirtualSerialHost"><File path="Demos\Host\ClassDriver\VirtualSerialHost\Doxygen.conf"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\makefile"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.c"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.h"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.txt"></File><File path="Demos\Host\ClassDriver\VirtualSerialHost\VirtualSerialHost.aps"></File></Folder><File path="Demos\Host\ClassDriver\makefile"></File></Folder><Folder name="LowLevel"><Folder name="GenericHIDHost"><File path="Demos\Host\LowLevel\GenericHIDHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\GenericHIDHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\GenericHIDHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.c"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.h"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.txt"></File><File path="Demos\Host\LowLevel\GenericHIDHost\makefile"></File><File path="Demos\Host\LowLevel\GenericHIDHost\GenericHIDHost.aps"></File></Folder><Folder name="JoystickHostWithParser"><File path="Demos\Host\LowLevel\JoystickHostWithParser\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\Doxygen.conf"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\HIDReport.c"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\HIDReport.h"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.c"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.h"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.txt"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\makefile"></File><File path="Demos\Host\LowLevel\JoystickHostWithParser\JoystickHostWithParser.aps"></File></Folder><Folder name="KeyboardHost"><File path="Demos\Host\LowLevel\KeyboardHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\KeyboardHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\KeyboardHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.c"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.h"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.txt"></File><File path="Demos\Host\LowLevel\KeyboardHost\makefile"></File><File path="Demos\Host\LowLevel\KeyboardHost\KeyboardHost.aps"></File></Folder><Folder name="KeyboardHostWithParser"><File path="Demos\Host\LowLevel\KeyboardHostWithParser\makefile"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\Doxygen.conf"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\HIDReport.c"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\HIDReport.h"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.c"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.h"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.txt"></File><File path="Demos\Host\LowLevel\KeyboardHostWithParser\KeyboardHostWithParser.aps"></File></Folder><Folder name="MassStorageHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\MassStorageHost\Lib\MassStoreCommands.c"></File><File path="Demos\Host\LowLevel\MassStorageHost\Lib\MassStoreCommands.h"></File></Folder><File path="Demos\Host\LowLevel\MassStorageHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MassStorageHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MassStorageHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MassStorageHost\makefile"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.c"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.h"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.txt"></File><File path="Demos\Host\LowLevel\MassStorageHost\MassStorageHost.aps"></File></Folder><Folder name="MIDIHost"><File path="Demos\Host\LowLevel\MIDIHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MIDIHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MIDIHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MIDIHost\makefile"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.c"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.h"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.txt"></File><File path="Demos\Host\LowLevel\MIDIHost\MIDIHost.aps"></File></Folder><Folder name="MouseHost"><File path="Demos\Host\LowLevel\MouseHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MouseHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MouseHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MouseHost\makefile"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.c"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.h"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.txt"></File><File path="Demos\Host\LowLevel\MouseHost\MouseHost.aps"></File></Folder><Folder name="MouseHostWithParser"><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.txt"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\Doxygen.conf"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\HIDReport.c"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\HIDReport.h"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\makefile"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.c"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.h"></File><File path="Demos\Host\LowLevel\MouseHostWithParser\MouseHostWithParser.aps"></File></Folder><Folder name="PrinterHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\PrinterHost\Lib\PrinterCommands.c"></File><File path="Demos\Host\LowLevel\PrinterHost\Lib\PrinterCommands.h"></File></Folder><File path="Demos\Host\LowLevel\PrinterHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\PrinterHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\PrinterHost\makefile"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.c"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.h"></File><File path="Demos\Host\LowLevel\PrinterHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.txt"></File><File path="Demos\Host\LowLevel\PrinterHost\PrinterHost.aps"></File></Folder><Folder name="RNDISEthernetHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\RNDISEthernetHost\Lib\RNDISCommands.c"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\Lib\RNDISCommands.h"></File></Folder><File path="Demos\Host\LowLevel\RNDISEthernetHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\makefile"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISEthernetHost.c"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISEthernetHost.h"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISHost.txt"></File><File path="Demos\Host\LowLevel\RNDISEthernetHost\RNDISEthernetHost.aps"></File></Folder><Folder name="StillImageHost"><Folder name="Lib"><File path="Demos\Host\LowLevel\StillImageHost\Lib\StillImageCommands.c"></File><File path="Demos\Host\LowLevel\StillImageHost\Lib\StillImageCommands.h"></File><File path="Demos\Host\LowLevel\StillImageHost\Lib\PIMACodes.h"></File></Folder><File path="Demos\Host\LowLevel\StillImageHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\StillImageHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\StillImageHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\StillImageHost\makefile"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.c"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.h"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.txt"></File><File path="Demos\Host\LowLevel\StillImageHost\StillImageHost.aps"></File></Folder><Folder name="VirtualSerialHost"><File path="Demos\Host\LowLevel\VirtualSerialHost\ConfigDescriptor.c"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\ConfigDescriptor.h"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\Doxygen.conf"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\makefile"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.c"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.h"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.txt"></File><File path="Demos\Host\LowLevel\VirtualSerialHost\VirtualSerialHost.aps"></File></Folder><File path="Demos\Host\LowLevel\makefile"></File></Folder><Folder name="Incomplete"><Folder name="BluetoothHost"><Folder name="Lib"><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothACLPackets.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothACLPackets.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothClassCodes.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothHCICommands.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothHCICommands.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothStack.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\BluetoothStack.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDPServices.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDPServices.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMM.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMM.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDP.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\SDP.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMMControl.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\Lib\RFCOMMControl.h"></File></Folder><File path="Demos\Host\Incomplete\BluetoothHost\makefile"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothHost.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothHost.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\ConfigDescriptor.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\ConfigDescriptor.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\DeviceDescriptor.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\DeviceDescriptor.h"></File><File path="Demos\Host\Incomplete\BluetoothHost\Doxygen.conf"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothEvents.c"></File><File path="Demos\Host\Incomplete\BluetoothHost\BluetoothEvents.h"></File></Folder></Folder><File path="Demos\Host\makefile"></File></Folder><Folder name="DualRole"><Folder name="ClassDriver"><Folder name="MouseHostDevice"><File path="Demos\DualRole\ClassDriver\MouseHostDevice\Doxygen.conf"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\makefile"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\Descriptors.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\Descriptors.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\DeviceFunctions.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\HostFunctions.c"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\HostFunctions.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\DeviceFunctions.h"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.txt"></File><File path="Demos\DualRole\ClassDriver\MouseHostDevice\MouseHostDevice.aps"></File></Folder><File path="Demos\DualRole\ClassDriver\makefile"></File></Folder><File path="Demos\DualRole\makefile"></File></Folder><File path="Demos\makefile"></File></Folder><Folder name="LUFA"><Folder name="Common"><File path="LUFA\Common\Common.h"></File><File path="LUFA\Common\BoardTypes.h"></File><File path="LUFA\Common\Attributes.h"></File><File path="LUFA\Common\Architectures.h"></File></Folder><Folder name="Drivers"><Folder name="USB"><Folder name="Core"><Folder name="AVR8"><File path="LUFA\Drivers\USB\Core\AVR8\Device_AVR8.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Device_AVR8.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\Endpoint_AVR8.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Endpoint_AVR8.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\Host_AVR8.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Host_AVR8.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\OTG_AVR8.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\Pipe_AVR8.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\Pipe_AVR8.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBController_AVR8.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBController_AVR8.h"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBInterrupt_AVR8.c"></File><File path="LUFA\Drivers\USB\Core\AVR8\USBInterrupt_AVR8.h"></File></Folder><Folder name="UC3B"><File path="LUFA\Drivers\USB\Core\UC3B\Device_UC3B.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Device_UC3B.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\Endpoint_UC3B.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Endpoint_UC3B.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\Host_UC3B.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Host_UC3B.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\OTG_UC3B.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\Pipe_UC3B.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\Pipe_UC3B.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBController_UC3B.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBController_UC3B.h"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBInterrupt_UC3B.c"></File><File path="LUFA\Drivers\USB\Core\UC3B\USBInterrupt_UC3B.h"></File></Folder><Folder name="Template"><File path="LUFA\Drivers\USB\Core\Template\Template_Endpoint_Control_R.c"></File><File path="LUFA\Drivers\USB\Core\Template\Template_Endpoint_Control_W.c"></File><File path="LUFA\Drivers\USB\Core\Template\Template_Endpoint_RW.c"></File><File path="LUFA\Drivers\USB\Core\Template\Template_Pipe_RW.c"></File></Folder><File path="LUFA\Drivers\USB\Core\ConfigDescriptor.c"></File><File path="LUFA\Drivers\USB\Core\ConfigDescriptor.h"></File><File path="LUFA\Drivers\USB\Core\DeviceStandardReq.c"></File><File path="LUFA\Drivers\USB\Core\DeviceStandardReq.h"></File><File path="LUFA\Drivers\USB\Core\EndpointStream.c"></File><File path="LUFA\Drivers\USB\Core\EndpointStream.h"></File><File path="LUFA\Drivers\USB\Core\Events.c"></File><File path="LUFA\Drivers\USB\Core\Events.h"></File><File path="LUFA\Drivers\USB\Core\HostStandardReq.c"></File><File path="LUFA\Drivers\USB\Core\HostStandardReq.h"></File><File path="LUFA\Drivers\USB\Core\PipeStream.c"></File><File path="LUFA\Drivers\USB\Core\PipeStream.h"></File><File path="LUFA\Drivers\USB\Core\StdDescriptors.h"></File><File path="LUFA\Drivers\USB\Core\StdRequestType.h"></File><File path="LUFA\Drivers\USB\Core\USBMode.h"></File><File path="LUFA\Drivers\USB\Core\USBTask.c"></File><File path="LUFA\Drivers\USB\Core\USBTask.h"></File><File path="LUFA\Drivers\USB\Core\Device.h"></File><File path="LUFA\Drivers\USB\Core\Endpoint.h"></File><File path="LUFA\Drivers\USB\Core\Host.h"></File><File path="LUFA\Drivers\USB\Core\OTG.h"></File><File path="LUFA\Drivers\USB\Core\Pipe.h"></File><File path="LUFA\Drivers\USB\Core\USBController.h"></File><File path="LUFA\Drivers\USB\Core\USBInterrupt.h"></File></Folder><Folder name="Class"><Folder name="Device"><File path="LUFA\Drivers\USB\Class\Device\HID.c"></File><File path="LUFA\Drivers\USB\Class\Device\HID.h"></File><File path="LUFA\Drivers\USB\Class\Device\CDC.c"></File><File path="LUFA\Drivers\USB\Class\Device\CDC.h"></File><File path="LUFA\Drivers\USB\Class\Device\RNDIS.c"></File><File path="LUFA\Drivers\USB\Class\Device\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\Device\MassStorage.c"></File><File path="LUFA\Drivers\USB\Class\Device\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\Device\Audio.c"></File><File path="LUFA\Drivers\USB\Class\Device\Audio.h"></File><File path="LUFA\Drivers\USB\Class\Device\MIDI.c"></File><File path="LUFA\Drivers\USB\Class\Device\MIDI.h"></File></Folder><Folder name="Host"><File path="LUFA\Drivers\USB\Class\Host\CDC.c"></File><File path="LUFA\Drivers\USB\Class\Host\CDC.h"></File><File path="LUFA\Drivers\USB\Class\Host\HID.c"></File><File path="LUFA\Drivers\USB\Class\Host\HID.h"></File><File path="LUFA\Drivers\USB\Class\Host\MassStorage.c"></File><File path="LUFA\Drivers\USB\Class\Host\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\Host\StillImage.c"></File><File path="LUFA\Drivers\USB\Class\Host\StillImage.h"></File><File path="LUFA\Drivers\USB\Class\Host\MIDI.c"></File><File path="LUFA\Drivers\USB\Class\Host\MIDI.h"></File><File path="LUFA\Drivers\USB\Class\Host\Printer.c"></File><File path="LUFA\Drivers\USB\Class\Host\Printer.h"></File><File path="LUFA\Drivers\USB\Class\Host\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\Host\RNDIS.c"></File></Folder><Folder name="Common"><File path="LUFA\Drivers\USB\Class\Common\Audio.h"></File><File path="LUFA\Drivers\USB\Class\Common\CDC.h"></File><File path="LUFA\Drivers\USB\Class\Common\HID.h"></File><File path="LUFA\Drivers\USB\Class\Common\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\Common\MIDI.h"></File><File path="LUFA\Drivers\USB\Class\Common\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\Common\StillImage.h"></File><File path="LUFA\Drivers\USB\Class\Common\Printer.h"></File><File path="LUFA\Drivers\USB\Class\Common\HIDParser.c"></File><File path="LUFA\Drivers\USB\Class\Common\HIDParser.h"></File><File path="LUFA\Drivers\USB\Class\Common\HIDReportData.h"></File></Folder><File path="LUFA\Drivers\USB\Class\Audio.h"></File><File path="LUFA\Drivers\USB\Class\CDC.h"></File><File path="LUFA\Drivers\USB\Class\HID.h"></File><File path="LUFA\Drivers\USB\Class\MassStorage.h"></File><File path="LUFA\Drivers\USB\Class\MIDI.h"></File><File path="LUFA\Drivers\USB\Class\RNDIS.h"></File><File path="LUFA\Drivers\USB\Class\StillImage.h"></File><File path="LUFA\Drivers\USB\Class\Printer.h"></File></Folder><File path="LUFA\Drivers\USB\USB.h"></File></Folder><Folder name="Misc"><File path="LUFA\Drivers\Misc\TerminalCodes.h"></File><File path="LUFA\Drivers\Misc\RingBuffer.h"></File><File path="LUFA\Drivers\Misc\AT45DB321C.h"></File><File path="LUFA\Drivers\Misc\AT45DB642D.h"></File></Folder><Folder name="Board"><Folder name="ADAFRUITU4"><File path="LUFA\Drivers\Board\ADAFRUITU4\LEDs.h"></File></Folder><Folder name="ATAVRUSBRF01"><File path="LUFA\Drivers\Board\ATAVRUSBRF01\LEDs.h"></File><File path="LUFA\Drivers\Board\ATAVRUSBRF01\Buttons.h"></File></Folder><Folder name="BENITO"><File path="LUFA\Drivers\Board\BENITO\LEDs.h"></File><File path="LUFA\Drivers\Board\BENITO\Buttons.h"></File></Folder><Folder name="BUMBLEB"><File path="LUFA\Drivers\Board\BUMBLEB\Buttons.h"></File><File path="LUFA\Drivers\Board\BUMBLEB\Joystick.h"></File><File path="LUFA\Drivers\Board\BUMBLEB\LEDs.h"></File></Folder><Folder name="BUI"><File path="LUFA\Drivers\Board\BUI\LEDs.h"></File></Folder><Folder name="BLACKCAT"><File path="LUFA\Drivers\Board\BLACKCAT\LEDs.h"></File></Folder><Folder name="CULV3"><File path="LUFA\Drivers\Board\CULV3\Buttons.h"></File><File path="LUFA\Drivers\Board\CULV3\LEDs.h"></File></Folder><Folder name="EVK527"><File path="LUFA\Drivers\Board\EVK527\Buttons.h"></File><File path="LUFA\Drivers\Board\EVK527\LEDs.h"></File><File path="LUFA\Drivers\Board\EVK527\Joystick.h"></File><File path="LUFA\Drivers\Board\EVK527\Dataflash.h"></File></Folder><Folder name="EVK1101"><File path="LUFA\Drivers\Board\EVK1101\Buttons.h"></File><File path="LUFA\Drivers\Board\EVK1101\Joystick.h"></File><File path="LUFA\Drivers\Board\EVK1101\LEDs.h"></File></Folder><Folder name="JMDBU2"><File path="LUFA\Drivers\Board\JMDBU2\Buttons.h"></File><File path="LUFA\Drivers\Board\JMDBU2\LEDs.h"></File></Folder><Folder name="MAXIMUS"><File path="LUFA\Drivers\Board\MAXIMUS\LEDs.h"></File></Folder><Folder name="MICROSIN162"><File path="LUFA\Drivers\Board\MICROSIN162\LEDs.h"></File><File path="LUFA\Drivers\Board\MICROSIN162\Buttons.h"></File></Folder><Folder name="MINIMUS"><File path="LUFA\Drivers\Board\MINIMUS\Buttons.h"></File><File path="LUFA\Drivers\Board\MINIMUS\LEDs.h"></File></Folder><Folder name="OLIMEX162"><File path="LUFA\Drivers\Board\OLIMEX162\LEDs.h"></File><File path="LUFA\Drivers\Board\OLIMEX162\Buttons.h"></File></Folder><Folder name="RZUSBSTICK"><File path="LUFA\Drivers\Board\RZUSBSTICK\LEDs.h"></File></Folder><Folder name="SPARKFUN8U2"><File path="LUFA\Drivers\Board\SPARKFUN8U2\LEDs.h"></File></Folder><Folder name="STK525"><File path="LUFA\Drivers\Board\STK525\Dataflash.h"></File><File path="LUFA\Drivers\Board\STK525\Joystick.h"></File><File path="LUFA\Drivers\Board\STK525\LEDs.h"></File><File path="LUFA\Drivers\Board\STK525\Buttons.h"></File></Folder><Folder name="STK526"><File path="LUFA\Drivers\Board\STK526\Dataflash.h"></File><File path="LUFA\Drivers\Board\STK526\Joystick.h"></File><File path="LUFA\Drivers\Board\STK526\LEDs.h"></File><File path="LUFA\Drivers\Board\STK526\Buttons.h"></File></Folder><Folder name="TEENSY"><File path="LUFA\Drivers\Board\TEENSY\LEDs.h"></File></Folder><Folder name="UDIP"><File path="LUFA\Drivers\Board\UDIP\LEDs.h"></File><File path="LUFA\Drivers\Board\UDIP\Buttons.h"></File></Folder><Folder name="UNO"><File path="LUFA\Drivers\Board\UNO\LEDs.h"></File></Folder><Folder name="USBFOO"><File path="LUFA\Drivers\Board\USBFOO\Buttons.h"></File><File path="LUFA\Drivers\Board\USBFOO\LEDS.h"></File></Folder><Folder name="USBKEY"><File path="LUFA\Drivers\Board\USBKEY\Dataflash.h"></File><File path="LUFA\Drivers\Board\USBKEY\Joystick.h"></File><File path="LUFA\Drivers\Board\USBKEY\LEDs.h"></File><File path="LUFA\Drivers\Board\USBKEY\Buttons.h"></File></Folder><Folder name="USBTINYMKII"><File path="LUFA\Drivers\Board\USBTINYMKII\LEDs.h"></File><File path="LUFA\Drivers\Board\USBTINYMKII\Buttons.h"></File></Folder><Folder name="XPLAIN"><File path="LUFA\Drivers\Board\XPLAIN\LEDs.h"></File><File path="LUFA\Drivers\Board\XPLAIN\Dataflash.h"></File></Folder><File path="LUFA\Drivers\Board\Temperature.h"></File><File path="LUFA\Drivers\Board\Dataflash.h"></File><File path="LUFA\Drivers\Board\Joystick.h"></File><File path="LUFA\Drivers\Board\Temperature.c"></File><File path="LUFA\Drivers\Board\LEDs.h"></File><File path="LUFA\Drivers\Board\Buttons.h"></File></Folder><Folder name="Peripheral"><Folder name="AVR8"><File path="LUFA\Drivers\Peripheral\AVR8\ADC_AVR8.h"></File><File path="LUFA\Drivers\Peripheral\AVR8\Serial_AVR8.c"></File><File path="LUFA\Drivers\Peripheral\AVR8\Serial_AVR8.h"></File><File path="LUFA\Drivers\Peripheral\AVR8\SPI_AVR8.h"></File><File path="LUFA\Drivers\Peripheral\AVR8\TWI_AVR8.c"></File><File path="LUFA\Drivers\Peripheral\AVR8\TWI_AVR8.h"></File></Folder><File path="LUFA\Drivers\Peripheral\ADC.h"></File><File path="LUFA\Drivers\Peripheral\TWI.h"></File><File path="LUFA\Drivers\Peripheral\Serial.h"></File><File path="LUFA\Drivers\Peripheral\SPI.h"></File></Folder></Folder><Folder name="ManPages"><File path="LUFA\ManPages\AboutLUFA.txt"></File><File path="LUFA\ManPages\BuildingLinkableLibraries.txt"></File><File path="LUFA\ManPages\ChangeLog.txt"></File><File path="LUFA\ManPages\CompileTimeTokens.txt"></File><File path="LUFA\ManPages\DevelopingWithLUFA.txt"></File><File path="LUFA\ManPages\DeviceSupport.txt"></File><File path="LUFA\ManPages\DirectorySummaries.txt"></File><File path="LUFA\ManPages\Donating.txt"></File><File path="LUFA\ManPages\FutureChanges.txt"></File><File path="LUFA\ManPages\GettingStarted.txt"></File><File path="LUFA\ManPages\Groups.txt"></File><File path="LUFA\ManPages\LibraryResources.txt"></File><File path="LUFA\ManPages\LUFAPoweredProjects.txt"></File><File path="LUFA\ManPages\MainPage.txt"></File><File path="LUFA\ManPages\MigrationInformation.txt"></File><File path="LUFA\ManPages\VIDAndPIDValues.txt"></File><File path="LUFA\ManPages\WritingBoardDrivers.txt"></File><File path="LUFA\ManPages\ConfiguringApps.txt"></File><File path="LUFA\ManPages\CompilingApps.txt"></File><File path="LUFA\ManPages\ProgrammingApps.txt"></File><File path="LUFA\ManPages\LibraryApps.txt"></File><File path="LUFA\ManPages\WhyUseLUFA.txt"></File><File path="LUFA\ManPages\LUFAvsAtmelStack.txt"></File><File path="LUFA\ManPages\AlternativeStacks.txt"></File><File path="LUFA\ManPages\SoftwareBootloaderJump.txt"></File><File path="LUFA\ManPages\LicenseInfo.txt"></File></Folder><Folder name="Scheduler"><File path="LUFA\Scheduler\Scheduler.c"></File><File path="LUFA\Scheduler\Scheduler.h"></File></Folder><Folder name="CodeTemplates"><Folder name="DriverStubs"><File path="LUFA\CodeTemplates\DriverStubs\Buttons.h"></File><File path="LUFA\CodeTemplates\DriverStubs\Dataflash.h"></File><File path="LUFA\CodeTemplates\DriverStubs\Joystick.h"></File><File path="LUFA\CodeTemplates\DriverStubs\LEDs.h"></File></Folder><File path="LUFA\CodeTemplates\makefile_template"></File></Folder><File path="LUFA\makefile"></File><File path="LUFA\Version.h"></File><File path="LUFA\Doxygen.conf"></File><File path="LUFA\License.txt"></File></Folder><Folder name="Bootloaders"><Folder name="CDC"><File path="Bootloaders\CDC\BootloaderCDC.c"></File><File path="Bootloaders\CDC\BootloaderCDC.h"></File><File path="Bootloaders\CDC\Descriptors.c"></File><File path="Bootloaders\CDC\Descriptors.h"></File><File path="Bootloaders\CDC\makefile"></File><File path="Bootloaders\CDC\LUFA CDC Bootloader.inf"></File><File path="Bootloaders\CDC\Doxygen.conf"></File><File path="Bootloaders\CDC\BootloaderCDC.txt"></File><File path="Bootloaders\CDC\BootloaderCDC.aps"></File></Folder><Folder name="DFU"><File path="Bootloaders\DFU\BootloaderDFU.c"></File><File path="Bootloaders\DFU\BootloaderDFU.h"></File><File path="Bootloaders\DFU\Descriptors.c"></File><File path="Bootloaders\DFU\Descriptors.h"></File><File path="Bootloaders\DFU\makefile"></File><File path="Bootloaders\DFU\BootloaderDFU.txt"></File><File path="Bootloaders\DFU\Doxygen.conf"></File><File path="Bootloaders\DFU\BootloaderDFU.aps"></File></Folder><Folder name="HID"><Folder name="HostLoaderApp"><File path="Bootloaders\HID\HostLoaderApp\gpl3.txt"></File><File path="Bootloaders\HID\HostLoaderApp\Makefile"></File><File path="Bootloaders\HID\HostLoaderApp\Makefile.bsd"></File><File path="Bootloaders\HID\HostLoaderApp\hid_bootloader_cli.c"></File></Folder><File path="Bootloaders\HID\Descriptors.c"></File><File path="Bootloaders\HID\Descriptors.h"></File><File path="Bootloaders\HID\makefile"></File><File path="Bootloaders\HID\BootloaderHID.txt"></File><File path="Bootloaders\HID\BootloaderHID.c"></File><File path="Bootloaders\HID\BootloaderHID.h"></File><File path="Bootloaders\HID\Doxygen.conf"></File><File path="Bootloaders\HID\BootloaderHID.aps"></File></Folder><File path="Bootloaders\makefile"></File></Folder><Folder name="Projects"><Folder name="AVRISP-MKII"><Folder name="Lib"><Folder name="ISP"><File path="Projects\AVRISP-MKII\Lib\ISP\ISPProtocol.c"></File><File path="Projects\AVRISP-MKII\Lib\ISP\ISPProtocol.h"></File><File path="Projects\AVRISP-MKII\Lib\ISP\ISPTarget.c"></File><File path="Projects\AVRISP-MKII\Lib\ISP\ISPTarget.h"></File></Folder><Folder name="XPROG"><File path="Projects\AVRISP-MKII\Lib\XPROG\TINYNVM.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\TINYNVM.h"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XMEGANVM.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XMEGANVM.h"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGProtocol.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGProtocol.h"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGTarget.c"></File><File path="Projects\AVRISP-MKII\Lib\XPROG\XPROGTarget.h"></File></Folder><File path="Projects\AVRISP-MKII\Lib\V2Protocol.c"></File><File path="Projects\AVRISP-MKII\Lib\V2Protocol.h"></File><File path="Projects\AVRISP-MKII\Lib\V2ProtocolConstants.h"></File><File path="Projects\AVRISP-MKII\Lib\V2ProtocolParams.c"></File><File path="Projects\AVRISP-MKII\Lib\V2ProtocolParams.h"></File></Folder><File path="Projects\AVRISP-MKII\Descriptors.c"></File><File path="Projects\AVRISP-MKII\Descriptors.h"></File><File path="Projects\AVRISP-MKII\Doxygen.conf"></File><File path="Projects\AVRISP-MKII\makefile"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.c"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.h"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.txt"></File><File path="Projects\AVRISP-MKII\AVRISP-MKII.aps"></File></Folder><Folder name="Benito"><File path="Projects\Benito\Benito.c"></File><File path="Projects\Benito\Benito.h"></File><File path="Projects\Benito\Descriptors.c"></File><File path="Projects\Benito\Descriptors.h"></File><File path="Projects\Benito\Doxygen.conf"></File><File path="Projects\Benito\makefile"></File><File path="Projects\Benito\Benito.txt"></File><File path="Projects\Benito\Benito Programmer.inf"></File><File path="Projects\Benito\Benito.aps"></File></Folder><Folder name="LEDNotifier"><Folder name="CPUUsageApp"><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.cs"></File><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.csproj"></File><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.Designer.cs"></File><File path="Projects\LEDNotifier\CPUUsageApp\CPUMonitor.resx"></File><File path="Projects\LEDNotifier\CPUUsageApp\Program.cs"></File></Folder><Folder name="HotmailNotifierApp"><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.cs"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.csproj"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.Designer.cs"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\MailNotifier.resx"></File><File path="Projects\LEDNotifier\HotmailNotifierApp\Program.cs"></File></Folder><Folder name="LEDMixerApp"><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.cs"></File><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.csproj"></File><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.Designer.cs"></File><File path="Projects\LEDNotifier\LEDMixerApp\LEDMixer.resx"></File><File path="Projects\LEDNotifier\LEDMixerApp\Program.cs"></File></Folder><File path="Projects\LEDNotifier\Descriptors.c"></File><File path="Projects\LEDNotifier\Descriptors.h"></File><File path="Projects\LEDNotifier\Doxygen.conf"></File><File path="Projects\LEDNotifier\LEDNotifier.c"></File><File path="Projects\LEDNotifier\LEDNotifier.h"></File><File path="Projects\LEDNotifier\LEDNotifier.txt"></File><File path="Projects\LEDNotifier\LUFA LED Notifier.inf"></File><File path="Projects\LEDNotifier\makefile"></File><File path="Projects\LEDNotifier\LEDNotifier.aps"></File></Folder><Folder name="MagStripe"><Folder name="Lib"><File path="Projects\Magstripe\Lib\CircularBitBuffer.c"></File><File path="Projects\Magstripe\Lib\CircularBitBuffer.h"></File><File path="Projects\Magstripe\Lib\MagstripeHW.h"></File></Folder><File path="Projects\Magstripe\Descriptors.c"></File><File path="Projects\Magstripe\Descriptors.h"></File><File path="Projects\Magstripe\Magstripe.c"></File><File path="Projects\Magstripe\Magstripe.h"></File><File path="Projects\Magstripe\makefile"></File><File path="Projects\Magstripe\Magstripe.txt"></File><File path="Projects\Magstripe\Doxygen.conf"></File><File path="Projects\Magstripe\Magstripe.aps"></File></Folder><Folder name="MIDIToneGenerator"><File path="Projects\MIDIToneGenerator\Descriptors.c"></File><File path="Projects\MIDIToneGenerator\Descriptors.h"></File><File path="Projects\MIDIToneGenerator\makefile"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.c"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.h"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.txt"></File><File path="Projects\MIDIToneGenerator\MIDIToneGenerator.aps"></File></Folder><Folder name="MissileLauncher"><File path="Projects\MissileLauncher\ConfigDescriptor.c"></File><File path="Projects\MissileLauncher\ConfigDescriptor.h"></File><File path="Projects\MissileLauncher\Doxygen.conf"></File><File path="Projects\MissileLauncher\makefile"></File><File path="Projects\MissileLauncher\MissileLauncher.c"></File><File path="Projects\MissileLauncher\MissileLauncher.h"></File><File path="Projects\MissileLauncher\MissileLauncher.txt"></File><File path="Projects\MissileLauncher\MissileLauncher.aps"></File></Folder><Folder name="RelayBoard"><File path="Projects\RelayBoard\Descriptors.c"></File><File path="Projects\RelayBoard\Descriptors.h"></File><File path="Projects\RelayBoard\Doxygen.conf"></File><File path="Projects\RelayBoard\makefile"></File><File path="Projects\RelayBoard\RelayBoard.c"></File><File path="Projects\RelayBoard\RelayBoard.h"></File><File path="Projects\RelayBoard\RelayBoard.txt"></File><File path="Projects\RelayBoard\RelayBoard.aps"></File></Folder><Folder name="TempDataLogger"><Folder name="Lib"><Folder name="FATFs"><File path="Projects\TempDataLogger\Lib\FATFs\diskio.c"></File><File path="Projects\TempDataLogger\Lib\FATFs\diskio.h"></File><File path="Projects\TempDataLogger\Lib\FATFs\ff.c"></File><File path="Projects\TempDataLogger\Lib\FATFs\ff.h"></File><File path="Projects\TempDataLogger\Lib\FATFs\ffconf.h"></File><File path="Projects\TempDataLogger\Lib\FATFs\integer.h"></File></Folder><File path="Projects\TempDataLogger\Lib\DataflashManager.c"></File><File path="Projects\TempDataLogger\Lib\DataflashManager.h"></File><File path="Projects\TempDataLogger\Lib\DS1307.c"></File><File path="Projects\TempDataLogger\Lib\DS1307.h"></File><File path="Projects\TempDataLogger\Lib\SCSI.c"></File><File path="Projects\TempDataLogger\Lib\SCSI.h"></File></Folder><Folder name="TempLogHostApp"><File path="Projects\TempDataLogger\TempLogHostApp\DataLoggerSettings.cs"></File><File path="Projects\TempDataLogger\TempLogHostApp\DataLoggerSettings.Designer.cs"></File><File path="Projects\TempDataLogger\TempLogHostApp\DataLoggerSettings.resx"></File><File path="Projects\TempDataLogger\TempLogHostApp\Program.cs"></File><File path="Projects\TempDataLogger\TempLogHostApp\TempLoggerHostApp.csproj"></File></Folder><File path="Projects\TempDataLogger\Descriptors.c"></File><File path="Projects\TempDataLogger\Descriptors.h"></File><File path="Projects\TempDataLogger\Doxygen.conf"></File><File path="Projects\TempDataLogger\makefile"></File><File path="Projects\TempDataLogger\TempDataLogger.c"></File><File path="Projects\TempDataLogger\TempDataLogger.h"></File><File path="Projects\TempDataLogger\TemperatureDataLogger.txt"></File><File path="Projects\TempDataLogger\TempDataLogger.aps"></File></Folder><Folder name="USBtoSerial"><File path="Projects\USBtoSerial\Descriptors.h"></File><File path="Projects\USBtoSerial\Doxygen.conf"></File><File path="Projects\USBtoSerial\LUFA USBtoSerial.inf"></File><File path="Projects\USBtoSerial\makefile"></File><File path="Projects\USBtoSerial\USBtoSerial.c"></File><File path="Projects\USBtoSerial\USBtoSerial.h"></File><File path="Projects\USBtoSerial\USBtoSerial.txt"></File><File path="Projects\USBtoSerial\USBtoSerial.aps"></File><File path="Projects\USBtoSerial\Descriptors.c"></File></Folder><Folder name="Webserver"><Folder name="Lib"><Folder name="uip"><File path="Projects\Webserver\Lib\uip\clock.c"></File><File path="Projects\Webserver\Lib\uip\clock.h"></File><File path="Projects\Webserver\Lib\uip\timer.c"></File><File path="Projects\Webserver\Lib\uip\timer.h"></File><File path="Projects\Webserver\Lib\uip\uip.c"></File><File path="Projects\Webserver\Lib\uip\uip.h"></File><File path="Projects\Webserver\Lib\uip\uip_arp.c"></File><File path="Projects\Webserver\Lib\uip\uip_arp.h"></File><File path="Projects\Webserver\Lib\uip\uipopt.h"></File><File path="Projects\Webserver\Lib\uip\uip-split.c"></File><File path="Projects\Webserver\Lib\uip\uip-split.h"></File></Folder><Folder name="FATFs"><File path="Projects\Webserver\Lib\FATFs\diskio.c"></File><File path="Projects\Webserver\Lib\FATFs\diskio.h"></File><File path="Projects\Webserver\Lib\FATFs\ff.c"></File><File path="Projects\Webserver\Lib\FATFs\ff.h"></File><File path="Projects\Webserver\Lib\FATFs\ffconf.h"></File><File path="Projects\Webserver\Lib\FATFs\integer.h"></File></Folder><File path="Projects\Webserver\Lib\DataflashManager.c"></File><File path="Projects\Webserver\Lib\DataflashManager.h"></File><File path="Projects\Webserver\Lib\uIPManagement.c"></File><File path="Projects\Webserver\Lib\uIPManagement.h"></File><File path="Projects\Webserver\Lib\HTTPServerApp.c"></File><File path="Projects\Webserver\Lib\HTTPServerApp.h"></File><File path="Projects\Webserver\Lib\SCSI.c"></File><File path="Projects\Webserver\Lib\SCSI.h"></File><File path="Projects\Webserver\Lib\DHCPClientApp.c"></File><File path="Projects\Webserver\Lib\DHCPClientApp.h"></File><File path="Projects\Webserver\Lib\TELNETServerApp.c"></File><File path="Projects\Webserver\Lib\TELNETServerApp.h"></File></Folder><File path="Projects\Webserver\makefile"></File><File path="Projects\Webserver\Webserver.c"></File><File path="Projects\Webserver\Webserver.h"></File><File path="Projects\Webserver\Doxygen.conf"></File><File path="Projects\Webserver\Webserver.txt"></File><File path="Projects\Webserver\Descriptors.c"></File><File path="Projects\Webserver\Descriptors.h"></File><File path="Projects\Webserver\USBHostMode.c"></File><File path="Projects\Webserver\USBHostMode.h"></File><File path="Projects\Webserver\USBDeviceMode.c"></File><File path="Projects\Webserver\USBDeviceMode.h"></File><File path="Projects\Webserver\Webserver.aps"></File></Folder><Folder name="XPLAINBridge"><Folder name="Lib"><File path="Projects\XPLAINBridge\Lib\SoftUART.c"></File><File path="Projects\XPLAINBridge\Lib\SoftUART.h"></File></Folder><File path="Projects\XPLAINBridge\XPLAINBridge.txt"></File><File path="Projects\XPLAINBridge\XPLAINBridge.h"></File><File path="Projects\XPLAINBridge\XPLAINBridge.c"></File><File path="Projects\XPLAINBridge\XPLAINBridge.aps"></File><File path="Projects\XPLAINBridge\USARTDescriptors.h"></File><File path="Projects\XPLAINBridge\USARTDescriptors.c"></File><File path="Projects\XPLAINBridge\makefile"></File><File path="Projects\XPLAINBridge\LUFA XPLAIN Bridge.inf"></File><File path="Projects\XPLAINBridge\Doxygen.conf"></File><File path="Projects\XPLAINBridge\AVRISPDescriptors.h"></File><File path="Projects\XPLAINBridge\AVRISPDescriptors.c"></File></Folder><Folder name="Incomplete"><Folder name="StandaloneProgrammer"><Folder name="Lib"><Folder name="PetiteFATFs"><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\diskio.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\diskio.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\integer.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\pff.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\PetiteFATFs\pff.h"></File></Folder><File path="Projects\Incomplete\StandaloneProgrammer\Lib\DataflashManager.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\DataflashManager.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\SCSI.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\SCSI.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\ProgrammerConfig.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Lib\ProgrammerConfig.h"></File></Folder><File path="Projects\Incomplete\StandaloneProgrammer\Descriptors.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\Descriptors.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\makefile"></File><File path="Projects\Incomplete\StandaloneProgrammer\StandaloneProgrammer.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\StandaloneProgrammer.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskDevice.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskDevice.h"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskHost.c"></File><File path="Projects\Incomplete\StandaloneProgrammer\DiskHost.h"></File></Folder></Folder><File path="Projects\makefile"></File></Folder><File path="makefile"></File><File path="README.txt"></File></Project>
\ No newline at end of file
/* Includes: */
#if (ARCH == ARCH_AVR8)
- #include "AVR8/ADC.h"
+ #include "AVR8/ADC_AVR8.h"
#else
#error The ADC peripheral driver is not currently available for your selected architecture.
#endif
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief ADC Peripheral Driver (AVR8)
- *
- * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC
- * peripheral internally.
- *
- * \note This file should not be included directly. It is automatically included as needed by the ADC driver
- * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.
- */
-
-/** \ingroup Group_ADC
- * \defgroup Group_ADC_AVR8 ADC Peripheral Driver (AVR8)
- *
- * \section Sec_ModDescription Module Description
- * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC
- * peripheral internally.
- *
- * \note This file should not be included directly. It is automatically included as needed by the ADC driver
- * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.
- *
- * \section Sec_ExampleUsage Example Usage
- * The following snippet is an example of how this module may be used within a typical
- * application.
- *
- * \code
- * // Initialise the ADC driver before first use
- * ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32);
- *
- * // Must setup the ADC channel to read beforehand
- * ADC_SetupChannel(1);
- *
- * // Perform a single conversion of the ADC channel 1
- * ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1);
- * printf("Conversion Result: %d\r\n", ADC_GetResult());
- *
- * // Start reading ADC channel 1 in free running (continuous conversion) mode
- * ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1);
- * while (!(ADC_IsReadingComplete())) {};
- * printf("Conversion Result: %d\r\n", ADC_GetResult());
- * \endcode
- *
- * @{
- */
-
-#ifndef __ADC_AVR8_H__
-#define __ADC_AVR8_H__
-
- /* Includes: */
- #include "../../../Common/Common.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_ADC_H)
- #error Do not include this file directly. Include LUFA/Drivers/Peripheral/ADC.h instead.
- #endif
-
- #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
- defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
- defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
- defined(__AVR_ATmega32U6__))
- #error The ADC peripheral driver is not currently available for your selected microcontroller model.
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #define _ADC_GET_MUX_MASK2(y) ADC_CHANNEL ## y
- #define _ADC_GET_MUX_MASK(y) _ADC_GET_MUX_MASK2(y)
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** \name ADC Reference Configuration Masks */
- //@{
- /** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */
- #define ADC_REFERENCE_AREF 0
-
- /** Reference mask, for using the voltage present at the AVR's AVCC pin for the ADC reference. */
- #define ADC_REFERENCE_AVCC (1 << REFS0)
-
- /** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */
- #define ADC_REFERENCE_INT2560MV ((1 << REFS1) | (1 << REFS0))
- //@}
-
- /** \name ADC Result Adjustment Configuration Masks */
- //@{
- /** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the
- * \ref ADC_GetResult() macro contain the 8 most significant bits of the result.
- */
- #define ADC_LEFT_ADJUSTED (1 << ADLAR)
-
- /** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the
- * \ref ADC_GetResult() macro contain the 8 least significant bits of the result.
- */
- #define ADC_RIGHT_ADJUSTED (0 << ADLAR)
- //@}
-
- /** \name ADC Mode Configuration Masks */
- //@{
- /** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC
- * is capable of at the given input clock speed.
- */
- #define ADC_FREE_RUNNING (1 << ADATE)
-
- /** Sets the ADC mode to single conversion, so that only a single conversion will take place before
- * the ADC returns to idle.
- */
- #define ADC_SINGLE_CONVERSION (0 << ADATE)
- //@}
-
- /** \name ADC Prescaler Configuration Masks */
- //@{
- /** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */
- #define ADC_PRESCALE_2 (1 << ADPS0)
-
- /** Sets the ADC input clock to prescale by a factor of 4 the AVR's system clock. */
- #define ADC_PRESCALE_4 (1 << ADPS1)
-
- /** Sets the ADC input clock to prescale by a factor of 8 the AVR's system clock. */
- #define ADC_PRESCALE_8 ((1 << ADPS0) | (1 << ADPS1))
-
- /** Sets the ADC input clock to prescale by a factor of 16 the AVR's system clock. */
- #define ADC_PRESCALE_16 (1 << ADPS2)
-
- /** Sets the ADC input clock to prescale by a factor of 32 the AVR's system clock. */
- #define ADC_PRESCALE_32 ((1 << ADPS2) | (1 << ADPS0))
-
- /** Sets the ADC input clock to prescale by a factor of 64 the AVR's system clock. */
- #define ADC_PRESCALE_64 ((1 << ADPS2) | (1 << ADPS1))
-
- /** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */
- #define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))
- //@}
-
- /** \name ADC MUX Masks */
- //@{
- /** MUX mask define for the ADC0 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
- #define ADC_CHANNEL0 (0x00 << MUX0)
-
- /** MUX mask define for the ADC1 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
- #define ADC_CHANNEL1 (0x01 << MUX0)
-
- #if !(defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
- /** MUX mask define for the ADC2 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL2 (0x02 << MUX0)
-
- /** MUX mask define for the ADC3 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL3 (0x03 << MUX0)
- #endif
-
- /** MUX mask define for the ADC4 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
- #define ADC_CHANNEL4 (0x04 << MUX0)
-
- /** MUX mask define for the ADC5 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
- #define ADC_CHANNEL5 (0x05 << MUX0)
-
- /** MUX mask define for the ADC6 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
- #define ADC_CHANNEL6 (0x06 << MUX0)
-
- /** MUX mask define for the ADC7 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */
- #define ADC_CHANNEL7 (0x07 << MUX0)
-
- /** MUX mask define for the internal 1.1V bandgap channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
- #define ADC_1100MV_BANDGAP (0x1E << MUX0)
-
- #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
- /** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL8 ((1 << 8) | (0x00 << MUX0))
-
- /** MUX mask define for the ADC9 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL9 ((1 << 8) | (0x01 << MUX0))
-
- /** MUX mask define for the ADC10 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL10 ((1 << 8) | (0x02 << MUX0))
-
- /** MUX mask define for the ADC11 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL11 ((1 << 8) | (0x03 << MUX0))
-
- /** MUX mask define for the ADC12 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL12 ((1 << 8) | (0x04 << MUX0))
-
- /** MUX mask define for the ADC13 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_CHANNEL13 ((1 << 8) | (0x05 << MUX0))
-
- /** MUX mask define for the internal temperature sensor channel of the ADC. See \ref ADC_StartReading() and
- * \ref ADC_GetChannelReading().
- *
- * \note Not available on all AVR models.
- */
- #define ADC_INT_TEMP_SENS ((1 << 8) | (0x07 << MUX0))
- #endif
-
- /** Retrieves the ADC MUX mask for the given ADC channel number.
- *
- * \note This macro will only work correctly on channel numbers that are compile-time
- * constants defined by the preprocessor.
- *
- * \param[in] Channel Index of the ADC channel whose MUX mask is to be retrieved.
- */
- #define ADC_GET_CHANNEL_MASK(Channel) _ADC_GET_MUX_MASK(Channel)
- //@}
-
- /* Inline Functions: */
- /** Configures the given ADC channel, ready for ADC conversions. This function sets the
- * associated port pin as an input and disables the digital portion of the I/O to reduce
- * power consumption.
- *
- * \note This must only be called for ADC channels with are connected to a physical port
- * pin of the AVR, denoted by its special alternative function ADCx.
- * \n\n
- *
- * \note The channel number must be specified as an integer, and <b>not</b> a \c ADC_CHANNEL* mask.
- *
- * \param[in] ChannelIndex ADC channel number to set up for conversions.
- */
- static inline void ADC_SetupChannel(const uint8_t ChannelIndex)
- {
- #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
- defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
- defined(__AVR_ATmega32U6__))
- DDRF &= ~(1 << ChannelIndex);
- DIDR0 |= (1 << ChannelIndex);
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- if (ChannelIndex < 8)
- {
- DDRF &= ~(1 << ChannelIndex);
- DIDR0 |= (1 << ChannelIndex);
- }
- else if (ChannelIndex == 8)
- {
- DDRD &= ~(1 << 4);
- DIDR2 |= (1 << 0);
- }
- else if (ChannelIndex < 11)
- {
- DDRD &= ~(1 << (ChannelIndex - 3));
- DIDR2 |= (1 << (ChannelIndex - 8));
- }
- else
- {
- DDRB &= ~(1 << (ChannelIndex - 7));
- DIDR2 |= (1 << (ChannelIndex - 8));
- }
- #endif
- }
-
- /** De-configures the given ADC channel, re-enabling digital I/O mode instead of analog. This
- * function sets the associated port pin as an input and re-enabled the digital portion of
- * the I/O.
- *
- * \note This must only be called for ADC channels with are connected to a physical port
- * pin of the AVR, denoted by its special alternative function ADCx.
- * \n\n
- *
- * \note The channel number must be specified as an integer, and <b>not</b> a \c ADC_CHANNEL* mask.
- *
- * \param[in] ChannelIndex ADC channel number to set up for conversions.
- */
- static inline void ADC_DisableChannel(const uint8_t ChannelIndex)
- {
- #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
- defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
- defined(__AVR_ATmega32U6__))
- DDRF &= ~(1 << ChannelIndex);
- DIDR0 &= ~(1 << ChannelIndex);
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- if (ChannelIndex < 8)
- {
- DDRF &= ~(1 << ChannelIndex);
- DIDR0 &= ~(1 << ChannelIndex);
- }
- else if (ChannelIndex == 8)
- {
- DDRD &= ~(1 << 4);
- DIDR2 &= ~(1 << 0);
- }
- else if (ChannelIndex < 11)
- {
- DDRD &= ~(1 << (ChannelIndex - 3));
- DIDR2 &= ~(1 << (ChannelIndex - 8));
- }
- else
- {
- DDRB &= ~(1 << (ChannelIndex - 7));
- DIDR2 &= ~(1 << (ChannelIndex - 8));
- }
- #endif
- }
-
- /** Starts the reading of the given channel, but does not wait until the conversion has completed.
- * Once executed, the conversion status can be determined via the \ref ADC_IsReadingComplete() macro and
- * the result read via the \ref ADC_GetResult() macro.
- *
- * If the ADC has been initialized in free running mode, calling this function once will begin the repeated
- * conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed),
- * this function must be called each time a conversion is to take place.
- *
- * \param[in] MUXMask ADC channel mask, reference mask and adjustment mask.
- */
- static inline void ADC_StartReading(const uint16_t MUXMask)
- {
- ADMUX = MUXMask;
-
- #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
- if (MUXMask & (1 << 8))
- ADCSRB |= (1 << MUX5);
- else
- ADCSRB &= ~(1 << MUX5);
- #endif
-
- ADCSRA |= (1 << ADSC);
- }
-
- /** Indicates if the current ADC conversion is completed, or still in progress.
- *
- * \return Boolean false if the reading is still taking place, or true if the conversion is
- * complete and ready to be read out with \ref ADC_GetResult().
- */
- static inline bool ADC_IsReadingComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool ADC_IsReadingComplete(void)
- {
- return ((ADCSRA & (1 << ADIF)) ? true : false);
- }
-
- /** Retrieves the conversion value of the last completed ADC conversion and clears the reading
- * completion flag.
- *
- * \return The result of the last ADC conversion as an unsigned value.
- */
- static inline uint16_t ADC_GetResult(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t ADC_GetResult(void)
- {
- ADCSRA |= (1 << ADIF);
- return ADC;
- }
-
- /** Performs a complete single reading from channel, including a polling spin-loop to wait for the
- * conversion to complete, and the returning of the converted value.
- *
- * \note For free running mode, the automated conversions should be initialized with a single call
- * to \ref ADC_StartReading() to select the channel and begin the automated conversions, and
- * the results read directly from the \ref ADC_GetResult() instead to reduce overhead.
- *
- * \param[in] MUXMask Mask comprising of an ADC channel mask, reference mask and adjustment mask.
- */
- static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask) ATTR_WARN_UNUSED_RESULT;
- static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask)
- {
- ADC_StartReading(MUXMask);
-
- while (!(ADC_IsReadingComplete()));
-
- return ADC_GetResult();
- }
-
- /** Initialises the ADC, ready for conversions. This must be called before any other ADC operations.
- * The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and
- * prescaler masks.
- *
- * \param[in] Mode Mask of ADC prescale and mode settings.
- */
- static inline void ADC_Init(uint8_t Mode) ATTR_ALWAYS_INLINE;
- static inline void ADC_Init(uint8_t Mode)
- {
- ADCSRA = ((1 << ADEN) | Mode);
- }
-
- /** Turns off the ADC. If this is called, any further ADC operations will require a call to
- * \ref ADC_Init() before the ADC can be used again.
- */
- static inline void ADC_Disable(void) ATTR_ALWAYS_INLINE;
- static inline void ADC_Disable(void)
- {
- ADCSRA = 0;
- }
-
- /** Indicates if the ADC is currently enabled.
- *
- * \return Boolean \c true if the ADC subsystem is currently enabled, \c false otherwise.
- */
- static inline bool ADC_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool ADC_GetStatus(void)
- {
- return ((ADCSRA & (1 << ADEN)) ? true : false);
- }
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief ADC Peripheral Driver (AVR8)
+ *
+ * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC
+ * peripheral internally.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver
+ * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.
+ */
+
+/** \ingroup Group_ADC
+ * \defgroup Group_ADC_AVR8 ADC Peripheral Driver (AVR8)
+ *
+ * \section Sec_ModDescription Module Description
+ * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC
+ * peripheral internally.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver
+ * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.
+ *
+ * \section Sec_ExampleUsage Example Usage
+ * The following snippet is an example of how this module may be used within a typical
+ * application.
+ *
+ * \code
+ * // Initialise the ADC driver before first use
+ * ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32);
+ *
+ * // Must setup the ADC channel to read beforehand
+ * ADC_SetupChannel(1);
+ *
+ * // Perform a single conversion of the ADC channel 1
+ * ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1);
+ * printf("Conversion Result: %d\r\n", ADC_GetResult());
+ *
+ * // Start reading ADC channel 1 in free running (continuous conversion) mode
+ * ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1);
+ * while (!(ADC_IsReadingComplete())) {};
+ * printf("Conversion Result: %d\r\n", ADC_GetResult());
+ * \endcode
+ *
+ * @{
+ */
+
+#ifndef __ADC_AVR8_H__
+#define __ADC_AVR8_H__
+
+ /* Includes: */
+ #include "../../../Common/Common.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_ADC_H)
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/ADC.h instead.
+ #endif
+
+ #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
+ defined(__AVR_ATmega32U6__))
+ #error The ADC peripheral driver is not currently available for your selected microcontroller model.
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define _ADC_GET_MUX_MASK2(y) ADC_CHANNEL ## y
+ #define _ADC_GET_MUX_MASK(y) _ADC_GET_MUX_MASK2(y)
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** \name ADC Reference Configuration Masks */
+ //@{
+ /** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */
+ #define ADC_REFERENCE_AREF 0
+
+ /** Reference mask, for using the voltage present at the AVR's AVCC pin for the ADC reference. */
+ #define ADC_REFERENCE_AVCC (1 << REFS0)
+
+ /** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */
+ #define ADC_REFERENCE_INT2560MV ((1 << REFS1) | (1 << REFS0))
+ //@}
+
+ /** \name ADC Result Adjustment Configuration Masks */
+ //@{
+ /** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the
+ * \ref ADC_GetResult() macro contain the 8 most significant bits of the result.
+ */
+ #define ADC_LEFT_ADJUSTED (1 << ADLAR)
+
+ /** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the
+ * \ref ADC_GetResult() macro contain the 8 least significant bits of the result.
+ */
+ #define ADC_RIGHT_ADJUSTED (0 << ADLAR)
+ //@}
+
+ /** \name ADC Mode Configuration Masks */
+ //@{
+ /** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC
+ * is capable of at the given input clock speed.
+ */
+ #define ADC_FREE_RUNNING (1 << ADATE)
+
+ /** Sets the ADC mode to single conversion, so that only a single conversion will take place before
+ * the ADC returns to idle.
+ */
+ #define ADC_SINGLE_CONVERSION (0 << ADATE)
+ //@}
+
+ /** \name ADC Prescaler Configuration Masks */
+ //@{
+ /** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */
+ #define ADC_PRESCALE_2 (1 << ADPS0)
+
+ /** Sets the ADC input clock to prescale by a factor of 4 the AVR's system clock. */
+ #define ADC_PRESCALE_4 (1 << ADPS1)
+
+ /** Sets the ADC input clock to prescale by a factor of 8 the AVR's system clock. */
+ #define ADC_PRESCALE_8 ((1 << ADPS0) | (1 << ADPS1))
+
+ /** Sets the ADC input clock to prescale by a factor of 16 the AVR's system clock. */
+ #define ADC_PRESCALE_16 (1 << ADPS2)
+
+ /** Sets the ADC input clock to prescale by a factor of 32 the AVR's system clock. */
+ #define ADC_PRESCALE_32 ((1 << ADPS2) | (1 << ADPS0))
+
+ /** Sets the ADC input clock to prescale by a factor of 64 the AVR's system clock. */
+ #define ADC_PRESCALE_64 ((1 << ADPS2) | (1 << ADPS1))
+
+ /** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */
+ #define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))
+ //@}
+
+ /** \name ADC MUX Masks */
+ //@{
+ /** MUX mask define for the ADC0 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
+ #define ADC_CHANNEL0 (0x00 << MUX0)
+
+ /** MUX mask define for the ADC1 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
+ #define ADC_CHANNEL1 (0x01 << MUX0)
+
+ #if !(defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
+ /** MUX mask define for the ADC2 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL2 (0x02 << MUX0)
+
+ /** MUX mask define for the ADC3 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL3 (0x03 << MUX0)
+ #endif
+
+ /** MUX mask define for the ADC4 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
+ #define ADC_CHANNEL4 (0x04 << MUX0)
+
+ /** MUX mask define for the ADC5 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
+ #define ADC_CHANNEL5 (0x05 << MUX0)
+
+ /** MUX mask define for the ADC6 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
+ #define ADC_CHANNEL6 (0x06 << MUX0)
+
+ /** MUX mask define for the ADC7 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */
+ #define ADC_CHANNEL7 (0x07 << MUX0)
+
+ /** MUX mask define for the internal 1.1V bandgap channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */
+ #define ADC_1100MV_BANDGAP (0x1E << MUX0)
+
+ #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
+ /** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL8 ((1 << 8) | (0x00 << MUX0))
+
+ /** MUX mask define for the ADC9 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL9 ((1 << 8) | (0x01 << MUX0))
+
+ /** MUX mask define for the ADC10 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL10 ((1 << 8) | (0x02 << MUX0))
+
+ /** MUX mask define for the ADC11 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL11 ((1 << 8) | (0x03 << MUX0))
+
+ /** MUX mask define for the ADC12 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL12 ((1 << 8) | (0x04 << MUX0))
+
+ /** MUX mask define for the ADC13 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_CHANNEL13 ((1 << 8) | (0x05 << MUX0))
+
+ /** MUX mask define for the internal temperature sensor channel of the ADC. See \ref ADC_StartReading() and
+ * \ref ADC_GetChannelReading().
+ *
+ * \note Not available on all AVR models.
+ */
+ #define ADC_INT_TEMP_SENS ((1 << 8) | (0x07 << MUX0))
+ #endif
+
+ /** Retrieves the ADC MUX mask for the given ADC channel number.
+ *
+ * \note This macro will only work correctly on channel numbers that are compile-time
+ * constants defined by the preprocessor.
+ *
+ * \param[in] Channel Index of the ADC channel whose MUX mask is to be retrieved.
+ */
+ #define ADC_GET_CHANNEL_MASK(Channel) _ADC_GET_MUX_MASK(Channel)
+ //@}
+
+ /* Inline Functions: */
+ /** Configures the given ADC channel, ready for ADC conversions. This function sets the
+ * associated port pin as an input and disables the digital portion of the I/O to reduce
+ * power consumption.
+ *
+ * \note This must only be called for ADC channels with are connected to a physical port
+ * pin of the AVR, denoted by its special alternative function ADCx.
+ * \n\n
+ *
+ * \note The channel number must be specified as an integer, and <b>not</b> a \c ADC_CHANNEL* mask.
+ *
+ * \param[in] ChannelIndex ADC channel number to set up for conversions.
+ */
+ static inline void ADC_SetupChannel(const uint8_t ChannelIndex)
+ {
+ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
+ defined(__AVR_ATmega32U6__))
+ DDRF &= ~(1 << ChannelIndex);
+ DIDR0 |= (1 << ChannelIndex);
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+ if (ChannelIndex < 8)
+ {
+ DDRF &= ~(1 << ChannelIndex);
+ DIDR0 |= (1 << ChannelIndex);
+ }
+ else if (ChannelIndex == 8)
+ {
+ DDRD &= ~(1 << 4);
+ DIDR2 |= (1 << 0);
+ }
+ else if (ChannelIndex < 11)
+ {
+ DDRD &= ~(1 << (ChannelIndex - 3));
+ DIDR2 |= (1 << (ChannelIndex - 8));
+ }
+ else
+ {
+ DDRB &= ~(1 << (ChannelIndex - 7));
+ DIDR2 |= (1 << (ChannelIndex - 8));
+ }
+ #endif
+ }
+
+ /** De-configures the given ADC channel, re-enabling digital I/O mode instead of analog. This
+ * function sets the associated port pin as an input and re-enabled the digital portion of
+ * the I/O.
+ *
+ * \note This must only be called for ADC channels with are connected to a physical port
+ * pin of the AVR, denoted by its special alternative function ADCx.
+ * \n\n
+ *
+ * \note The channel number must be specified as an integer, and <b>not</b> a \c ADC_CHANNEL* mask.
+ *
+ * \param[in] ChannelIndex ADC channel number to set up for conversions.
+ */
+ static inline void ADC_DisableChannel(const uint8_t ChannelIndex)
+ {
+ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
+ defined(__AVR_ATmega32U6__))
+ DDRF &= ~(1 << ChannelIndex);
+ DIDR0 &= ~(1 << ChannelIndex);
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+ if (ChannelIndex < 8)
+ {
+ DDRF &= ~(1 << ChannelIndex);
+ DIDR0 &= ~(1 << ChannelIndex);
+ }
+ else if (ChannelIndex == 8)
+ {
+ DDRD &= ~(1 << 4);
+ DIDR2 &= ~(1 << 0);
+ }
+ else if (ChannelIndex < 11)
+ {
+ DDRD &= ~(1 << (ChannelIndex - 3));
+ DIDR2 &= ~(1 << (ChannelIndex - 8));
+ }
+ else
+ {
+ DDRB &= ~(1 << (ChannelIndex - 7));
+ DIDR2 &= ~(1 << (ChannelIndex - 8));
+ }
+ #endif
+ }
+
+ /** Starts the reading of the given channel, but does not wait until the conversion has completed.
+ * Once executed, the conversion status can be determined via the \ref ADC_IsReadingComplete() macro and
+ * the result read via the \ref ADC_GetResult() macro.
+ *
+ * If the ADC has been initialized in free running mode, calling this function once will begin the repeated
+ * conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed),
+ * this function must be called each time a conversion is to take place.
+ *
+ * \param[in] MUXMask ADC channel mask, reference mask and adjustment mask.
+ */
+ static inline void ADC_StartReading(const uint16_t MUXMask)
+ {
+ ADMUX = MUXMask;
+
+ #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))
+ if (MUXMask & (1 << 8))
+ ADCSRB |= (1 << MUX5);
+ else
+ ADCSRB &= ~(1 << MUX5);
+ #endif
+
+ ADCSRA |= (1 << ADSC);
+ }
+
+ /** Indicates if the current ADC conversion is completed, or still in progress.
+ *
+ * \return Boolean false if the reading is still taking place, or true if the conversion is
+ * complete and ready to be read out with \ref ADC_GetResult().
+ */
+ static inline bool ADC_IsReadingComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool ADC_IsReadingComplete(void)
+ {
+ return ((ADCSRA & (1 << ADIF)) ? true : false);
+ }
+
+ /** Retrieves the conversion value of the last completed ADC conversion and clears the reading
+ * completion flag.
+ *
+ * \return The result of the last ADC conversion as an unsigned value.
+ */
+ static inline uint16_t ADC_GetResult(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t ADC_GetResult(void)
+ {
+ ADCSRA |= (1 << ADIF);
+ return ADC;
+ }
+
+ /** Performs a complete single reading from channel, including a polling spin-loop to wait for the
+ * conversion to complete, and the returning of the converted value.
+ *
+ * \note For free running mode, the automated conversions should be initialized with a single call
+ * to \ref ADC_StartReading() to select the channel and begin the automated conversions, and
+ * the results read directly from the \ref ADC_GetResult() instead to reduce overhead.
+ *
+ * \param[in] MUXMask Mask comprising of an ADC channel mask, reference mask and adjustment mask.
+ */
+ static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask) ATTR_WARN_UNUSED_RESULT;
+ static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask)
+ {
+ ADC_StartReading(MUXMask);
+
+ while (!(ADC_IsReadingComplete()));
+
+ return ADC_GetResult();
+ }
+
+ /** Initialises the ADC, ready for conversions. This must be called before any other ADC operations.
+ * The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and
+ * prescaler masks.
+ *
+ * \param[in] Mode Mask of ADC prescale and mode settings.
+ */
+ static inline void ADC_Init(uint8_t Mode) ATTR_ALWAYS_INLINE;
+ static inline void ADC_Init(uint8_t Mode)
+ {
+ ADCSRA = ((1 << ADEN) | Mode);
+ }
+
+ /** Turns off the ADC. If this is called, any further ADC operations will require a call to
+ * \ref ADC_Init() before the ADC can be used again.
+ */
+ static inline void ADC_Disable(void) ATTR_ALWAYS_INLINE;
+ static inline void ADC_Disable(void)
+ {
+ ADCSRA = 0;
+ }
+
+ /** Indicates if the ADC is currently enabled.
+ *
+ * \return Boolean \c true if the ADC subsystem is currently enabled, \c false otherwise.
+ */
+ static inline bool ADC_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool ADC_GetStatus(void)
+ {
+ return ((ADCSRA & (1 << ADEN)) ? true : false);
+ }
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief SPI Peripheral Driver (AVR8)
- *
- * On-chip SPI driver for the 8-bit AVR microcontrollers.
- *
- * \note This file should not be included directly. It is automatically included as needed by the SPI driver
- * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.
- */
-
-/** \ingroup Group_SPI
- * \defgroup Group_SPI_AVR8 SPI Peripheral Driver (AVR8)
- *
- * \section Sec_ModDescription Module Description
- * Driver for the hardware SPI port available on most 8-bit AVR microcontroller models. This
- * module provides an easy to use driver for the setup and transfer of data over the
- * AVR's SPI port.
- *
- * \note This file should not be included directly. It is automatically included as needed by the SPI driver
- * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.
- *
- * \section Sec_ExampleUsage Example Usage
- * The following snippet is an example of how this module may be used within a typical
- * application.
- *
- * \code
- * // Initialise the SPI driver before first use
- * SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING |
- * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
- *
- * // Send several bytes, ignoring the returned data
- * SPI_SendByte(0x01);
- * SPI_SendByte(0x02);
- * SPI_SendByte(0x03);
- *
- * // Receive several bytes, sending a dummy 0x00 byte each time
- * uint8_t Byte1 = SPI_ReceiveByte();
- * uint8_t Byte2 = SPI_ReceiveByte();
- * uint8_t Byte3 = SPI_ReceiveByte();
- *
- * // Send a byte, and store the received byte from the same transaction
- * uint8_t ResponseByte = SPI_TransferByte(0xDC);
- * \endcode
- *
- * @{
- */
-
-#ifndef __SPI_AVR8_H__
-#define __SPI_AVR8_H__
-
- /* Includes: */
- #include "../../../Common/Common.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_SPI_H)
- #error Do not include this file directly. Include LUFA/Drivers/Peripheral/SPI.h instead.
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #define SPI_USE_DOUBLESPEED (1 << SPE)
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** \name SPI Prescaler Configuration Masks */
- //@{
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 2. */
- #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED
-
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 4. */
- #define SPI_SPEED_FCPU_DIV_4 0
-
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 8. */
- #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPR0))
-
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 16. */
- #define SPI_SPEED_FCPU_DIV_16 (1 << SPR0)
-
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 32. */
- #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (1 << SPR1))
-
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 64. */
- #define SPI_SPEED_FCPU_DIV_64 (SPI_USE_DOUBLESPEED | (1 << SPR1) | (1 << SPR0))
-
- /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 128. */
- #define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 << SPR0))
- //@}
-
- /** \name SPI SCK Polarity Configuration Masks */
- //@{
- /** SPI clock polarity mask for \c SPI_Init(). Indicates that the SCK should lead on the rising edge. */
- #define SPI_SCK_LEAD_RISING (0 << CPOL)
-
- /** SPI clock polarity mask for \c SPI_Init(). Indicates that the SCK should lead on the falling edge. */
- #define SPI_SCK_LEAD_FALLING (1 << CPOL)
- //@}
-
- /** \name SPI Sample Edge Configuration Masks */
- //@{
- /** SPI data sample mode mask for \c SPI_Init(). Indicates that the data should sampled on the leading edge. */
- #define SPI_SAMPLE_LEADING (0 << CPHA)
-
- /** SPI data sample mode mask for \c SPI_Init(). Indicates that the data should be sampled on the trailing edge. */
- #define SPI_SAMPLE_TRAILING (1 << CPHA)
- //@}
-
- /** \name SPI Data Ordering Configuration Masks */
- //@{
- /** SPI data order mask for \c SPI_Init(). Indicates that data should be shifted out MSB first. */
- #define SPI_ORDER_MSB_FIRST (0 << DORD)
-
- /** SPI data order mask for \c SPI_Init(). Indicates that data should be shifted out MSB first. */
- #define SPI_ORDER_LSB_FIRST (1 << DORD)
- //@}
-
- /** \name SPI Mode Configuration Masks */
- //@{
- /** SPI mode mask for \c SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */
- #define SPI_MODE_SLAVE (0 << MSTR)
-
- /** SPI mode mask for \c SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */
- #define SPI_MODE_MASTER (1 << MSTR)
- //@}
-
- /* Inline Functions: */
- /** Initialises the SPI subsystem, ready for transfers. Must be called before calling any other
- * SPI routines.
- *
- * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the \c SPI_SPEED_*,
- * \c SPI_SCK_*, \c SPI_SAMPLE_*, \c SPI_ORDER_* and \c SPI_MODE_* masks.
- */
- static inline void SPI_Init(const uint8_t SPIOptions)
- {
- DDRB |= ((1 << 1) | (1 << 2));
- DDRB &= ~((1 << 0) | (1 << 3));
- PORTB |= ((1 << 0) | (1 << 3));
-
- SPCR = ((1 << SPE) | SPIOptions);
-
- if (SPIOptions & SPI_USE_DOUBLESPEED)
- SPSR |= (1 << SPI2X);
- else
- SPSR &= ~(1 << SPI2X);
- }
-
- /** Turns off the SPI driver, disabling and returning used hardware to their default configuration. */
- static inline void SPI_Disable(void)
- {
- DDRB &= ~((1 << 1) | (1 << 2));
- PORTB &= ~((1 << 0) | (1 << 3));
-
- SPCR = 0;
- SPSR = 0;
- }
-
- /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.
- *
- * \param[in] Byte Byte to send through the SPI interface.
- *
- * \return Response byte from the attached SPI device.
- */
- static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
- static inline uint8_t SPI_TransferByte(const uint8_t Byte)
- {
- SPDR = Byte;
- while (!(SPSR & (1 << SPIF)));
- return SPDR;
- }
-
- /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response
- * byte sent to from the attached SPI device is ignored.
- *
- * \param[in] Byte Byte to send through the SPI interface.
- */
- static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
- static inline void SPI_SendByte(const uint8_t Byte)
- {
- SPDR = Byte;
- while (!(SPSR & (1 << SPIF)));
- }
-
- /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response
- * byte from the attached SPI device is returned.
- *
- * \return The response byte from the attached SPI device.
- */
- static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
- static inline uint8_t SPI_ReceiveByte(void)
- {
- SPDR = 0x00;
- while (!(SPSR & (1 << SPIF)));
- return SPDR;
- }
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief SPI Peripheral Driver (AVR8)
+ *
+ * On-chip SPI driver for the 8-bit AVR microcontrollers.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the SPI driver
+ * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.
+ */
+
+/** \ingroup Group_SPI
+ * \defgroup Group_SPI_AVR8 SPI Peripheral Driver (AVR8)
+ *
+ * \section Sec_ModDescription Module Description
+ * Driver for the hardware SPI port available on most 8-bit AVR microcontroller models. This
+ * module provides an easy to use driver for the setup and transfer of data over the
+ * AVR's SPI port.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the SPI driver
+ * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.
+ *
+ * \section Sec_ExampleUsage Example Usage
+ * The following snippet is an example of how this module may be used within a typical
+ * application.
+ *
+ * \code
+ * // Initialise the SPI driver before first use
+ * SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING |
+ * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
+ *
+ * // Send several bytes, ignoring the returned data
+ * SPI_SendByte(0x01);
+ * SPI_SendByte(0x02);
+ * SPI_SendByte(0x03);
+ *
+ * // Receive several bytes, sending a dummy 0x00 byte each time
+ * uint8_t Byte1 = SPI_ReceiveByte();
+ * uint8_t Byte2 = SPI_ReceiveByte();
+ * uint8_t Byte3 = SPI_ReceiveByte();
+ *
+ * // Send a byte, and store the received byte from the same transaction
+ * uint8_t ResponseByte = SPI_TransferByte(0xDC);
+ * \endcode
+ *
+ * @{
+ */
+
+#ifndef __SPI_AVR8_H__
+#define __SPI_AVR8_H__
+
+ /* Includes: */
+ #include "../../../Common/Common.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_SPI_H)
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/SPI.h instead.
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define SPI_USE_DOUBLESPEED (1 << SPE)
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** \name SPI Prescaler Configuration Masks */
+ //@{
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 2. */
+ #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED
+
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 4. */
+ #define SPI_SPEED_FCPU_DIV_4 0
+
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 8. */
+ #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPR0))
+
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 16. */
+ #define SPI_SPEED_FCPU_DIV_16 (1 << SPR0)
+
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 32. */
+ #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (1 << SPR1))
+
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 64. */
+ #define SPI_SPEED_FCPU_DIV_64 (SPI_USE_DOUBLESPEED | (1 << SPR1) | (1 << SPR0))
+
+ /** SPI prescaler mask for \c SPI_Init(). Divides the system clock by a factor of 128. */
+ #define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 << SPR0))
+ //@}
+
+ /** \name SPI SCK Polarity Configuration Masks */
+ //@{
+ /** SPI clock polarity mask for \c SPI_Init(). Indicates that the SCK should lead on the rising edge. */
+ #define SPI_SCK_LEAD_RISING (0 << CPOL)
+
+ /** SPI clock polarity mask for \c SPI_Init(). Indicates that the SCK should lead on the falling edge. */
+ #define SPI_SCK_LEAD_FALLING (1 << CPOL)
+ //@}
+
+ /** \name SPI Sample Edge Configuration Masks */
+ //@{
+ /** SPI data sample mode mask for \c SPI_Init(). Indicates that the data should sampled on the leading edge. */
+ #define SPI_SAMPLE_LEADING (0 << CPHA)
+
+ /** SPI data sample mode mask for \c SPI_Init(). Indicates that the data should be sampled on the trailing edge. */
+ #define SPI_SAMPLE_TRAILING (1 << CPHA)
+ //@}
+
+ /** \name SPI Data Ordering Configuration Masks */
+ //@{
+ /** SPI data order mask for \c SPI_Init(). Indicates that data should be shifted out MSB first. */
+ #define SPI_ORDER_MSB_FIRST (0 << DORD)
+
+ /** SPI data order mask for \c SPI_Init(). Indicates that data should be shifted out MSB first. */
+ #define SPI_ORDER_LSB_FIRST (1 << DORD)
+ //@}
+
+ /** \name SPI Mode Configuration Masks */
+ //@{
+ /** SPI mode mask for \c SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */
+ #define SPI_MODE_SLAVE (0 << MSTR)
+
+ /** SPI mode mask for \c SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */
+ #define SPI_MODE_MASTER (1 << MSTR)
+ //@}
+
+ /* Inline Functions: */
+ /** Initialises the SPI subsystem, ready for transfers. Must be called before calling any other
+ * SPI routines.
+ *
+ * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the \c SPI_SPEED_*,
+ * \c SPI_SCK_*, \c SPI_SAMPLE_*, \c SPI_ORDER_* and \c SPI_MODE_* masks.
+ */
+ static inline void SPI_Init(const uint8_t SPIOptions)
+ {
+ DDRB |= ((1 << 1) | (1 << 2));
+ DDRB &= ~((1 << 0) | (1 << 3));
+ PORTB |= ((1 << 0) | (1 << 3));
+
+ SPCR = ((1 << SPE) | SPIOptions);
+
+ if (SPIOptions & SPI_USE_DOUBLESPEED)
+ SPSR |= (1 << SPI2X);
+ else
+ SPSR &= ~(1 << SPI2X);
+ }
+
+ /** Turns off the SPI driver, disabling and returning used hardware to their default configuration. */
+ static inline void SPI_Disable(void)
+ {
+ DDRB &= ~((1 << 1) | (1 << 2));
+ PORTB &= ~((1 << 0) | (1 << 3));
+
+ SPCR = 0;
+ SPSR = 0;
+ }
+
+ /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.
+ *
+ * \param[in] Byte Byte to send through the SPI interface.
+ *
+ * \return Response byte from the attached SPI device.
+ */
+ static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
+ static inline uint8_t SPI_TransferByte(const uint8_t Byte)
+ {
+ SPDR = Byte;
+ while (!(SPSR & (1 << SPIF)));
+ return SPDR;
+ }
+
+ /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response
+ * byte sent to from the attached SPI device is ignored.
+ *
+ * \param[in] Byte Byte to send through the SPI interface.
+ */
+ static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
+ static inline void SPI_SendByte(const uint8_t Byte)
+ {
+ SPDR = Byte;
+ while (!(SPSR & (1 << SPIF)));
+ }
+
+ /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response
+ * byte from the attached SPI device is returned.
+ *
+ * \return The response byte from the attached SPI device.
+ */
+ static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
+ static inline uint8_t SPI_ReceiveByte(void)
+ {
+ SPDR = 0x00;
+ while (!(SPSR & (1 << SPIF)));
+ return SPDR;
+ }
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_SERIAL_C
-#include "Serial.h"
-
-FILE USARTSerialStream;
-
-int Serial_putchar(char DataByte,
- FILE *Stream)
-{
- (void)Stream;
-
- Serial_SendByte(DataByte);
- return 0;
-}
-
-int Serial_getchar(FILE *Stream)
-{
- (void)Stream;
-
- if (!(Serial_IsCharReceived()))
- return _FDEV_EOF;
-
- return Serial_ReceiveByte();
-}
-
-int Serial_getchar_Blocking(FILE *Stream)
-{
- (void)Stream;
-
- while (!(Serial_IsCharReceived()));
- return Serial_ReceiveByte();
-}
-
-void Serial_SendString_P(const char* FlashStringPtr)
-{
- uint8_t CurrByte;
-
- while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)
- {
- Serial_SendByte(CurrByte);
- FlashStringPtr++;
- }
-}
-
-void Serial_SendString(const char* StringPtr)
-{
- uint8_t CurrByte;
-
- while ((CurrByte = *StringPtr) != 0x00)
- {
- Serial_SendByte(CurrByte);
- StringPtr++;
- }
-}
-
-void Serial_SendData(const uint8_t* Buffer, uint16_t Length)
-{
- while (Length--)
- Serial_SendByte(*(Buffer++));
-}
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief Serial USART Peripheral Driver (AVR8)
- *
- * On-chip serial USART driver for the 8-bit AVR microcontrollers.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USART driver
- * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.
- */
-
-/** \ingroup Group_Serial
- * \defgroup Group_Serial_AVR8 Serial USART Peripheral Driver (AVR8)
- *
- * \section Sec_ModDescription Module Description
- * On-chip serial USART driver for the 8-bit AVR microcontrollers.
- *
- * \note This file should not be included directly. It is automatically included as needed by the ADC driver
- * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.
- *
- * \section Sec_ExampleUsage Example Usage
- * The following snippet is an example of how this module may be used within a typical
- * application.
- *
- * \code
- * // Initialise the serial USART driver before first use, with 9600 baud (and no double-speed mode)
- * Serial_Init(9600, false);
- *
- * // Send a string through the USART
- * Serial_TxString("Test String\r\n");
- *
- * // Receive a byte through the USART
- * uint8_t DataByte = Serial_RxByte();
- * \endcode
- *
- * @{
- */
-
-#ifndef __SERIAL_AVR8_H__
-#define __SERIAL_AVR8_H__
-
- /* Includes: */
- #include "../../../Common/Common.h"
- #include "../../Misc/TerminalCodes.h"
-
- #include <stdio.h>
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_SERIAL_H) && !defined(__INCLUDE_FROM_SERIAL_C)
- #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead.
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* External Variables: */
- extern FILE USARTSerialStream;
-
- /* Function Prototypes: */
- int Serial_putchar(char DataByte,
- FILE *Stream);
- int Serial_getchar(FILE *Stream);
- int Serial_getchar_Blocking(FILE *Stream);
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
- * not set.
- */
- #define SERIAL_UBBRVAL(baud) ((((F_CPU / 16) + (baud / 2)) / (baud)) - 1)
-
- /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
- * set.
- */
- #define SERIAL_2X_UBBRVAL(baud) ((((F_CPU / 8) + (baud / 2)) / (baud)) - 1)
-
- /* Function Prototypes: */
- /** Transmits a given string located in program space (FLASH) through the USART.
- *
- * \param[in] FlashStringPtr Pointer to a string located in program space.
- */
- void Serial_SendString_P(const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);
-
- /** Transmits a given string located in SRAM memory through the USART.
- *
- * \param[in] StringPtr Pointer to a string located in SRAM space.
- */
- void Serial_SendString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1);
-
- /** Transmits a given buffer located in SRAM memory through the USART.
- *
- * \param[in] Buffer Pointer to a buffer containing the data to send.
- * \param[in] Length Length of the data to send, in bytes.
- */
- void Serial_SendData(const uint8_t* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
-
- /* Inline Functions: */
- /** Initializes the USART, ready for serial data transmission and reception. This initializes the interface to
- * standard 8-bit, no parity, 1 stop bit settings suitable for most applications.
- *
- * \param[in] BaudRate Serial baud rate, in bits per second.
- * \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate.
- */
- static inline void Serial_Init(const uint32_t BaudRate,
- const bool DoubleSpeed)
- {
- UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));
-
- UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));
- UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);
- UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
-
- DDRD |= (1 << 3);
- PORTD |= (1 << 2);
- }
-
- /** Turns off the USART driver, disabling and returning used hardware to their default configuration. */
- static inline void Serial_Disable(void)
- {
- UCSR1B = 0;
- UCSR1A = 0;
- UCSR1C = 0;
-
- UBRR1 = 0;
-
- DDRD &= ~(1 << 3);
- PORTD &= ~(1 << 2);
- }
-
- /** Creates a standard character stream from the USART so that it can be used with all the regular functions
- * in the avr-libc \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
- * stream is bidirectional and can be used for both input and output functions.
- *
- * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
- * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
- * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
- * line buffering.
- *
- * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL stdio
- * and stdin will be configured to use the USART.
- *
- * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.
- */
- static inline void Serial_CreateStream(FILE* Stream)
- {
- if (!(Stream))
- {
- Stream = &USARTSerialStream;
- stdin = Stream;
- stdout = Stream;
- }
-
- *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW);
- }
-
- /** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates
- * the transfer.
- *
- * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL stdio
- * and stdin will be configured to use the USART.
- *
- * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.
- */
- static inline void Serial_CreateBlockingStream(FILE* Stream)
- {
- if (!(Stream))
- {
- Stream = &USARTSerialStream;
- stdin = Stream;
- stdout = Stream;
- }
-
- *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW);
- }
-
- /** Indicates whether a character has been received through the USART.
- *
- * \return Boolean \c true if a character has been received, \c false otherwise.
- */
- static inline bool Serial_IsCharReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Serial_IsCharReceived(void)
- {
- return ((UCSR1A & (1 << RXC1)) ? true : false);
- }
-
- /** Transmits a given byte through the USART.
- *
- * \param[in] DataByte Byte to transmit through the USART.
- */
- static inline void Serial_SendByte(const char DataByte) ATTR_ALWAYS_INLINE;
- static inline void Serial_SendByte(const char DataByte)
- {
- while (!(UCSR1A & (1 << UDRE1)));
- UDR1 = DataByte;
- }
-
- /** Receives the next byte from the USART.
- *
- * \return Next byte received from the USART, or a negative value if no byte has been received.
- */
- static inline int16_t Serial_ReceiveByte(void) ATTR_ALWAYS_INLINE;
- static inline int16_t Serial_ReceiveByte(void)
- {
- if (!(Serial_IsCharReceived()))
- return -1;
-
- return UDR1;
- }
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_SERIAL_C
+#include "Serial.h"
+
+FILE USARTSerialStream;
+
+int Serial_putchar(char DataByte,
+ FILE *Stream)
+{
+ (void)Stream;
+
+ Serial_SendByte(DataByte);
+ return 0;
+}
+
+int Serial_getchar(FILE *Stream)
+{
+ (void)Stream;
+
+ if (!(Serial_IsCharReceived()))
+ return _FDEV_EOF;
+
+ return Serial_ReceiveByte();
+}
+
+int Serial_getchar_Blocking(FILE *Stream)
+{
+ (void)Stream;
+
+ while (!(Serial_IsCharReceived()));
+ return Serial_ReceiveByte();
+}
+
+void Serial_SendString_P(const char* FlashStringPtr)
+{
+ uint8_t CurrByte;
+
+ while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)
+ {
+ Serial_SendByte(CurrByte);
+ FlashStringPtr++;
+ }
+}
+
+void Serial_SendString(const char* StringPtr)
+{
+ uint8_t CurrByte;
+
+ while ((CurrByte = *StringPtr) != 0x00)
+ {
+ Serial_SendByte(CurrByte);
+ StringPtr++;
+ }
+}
+
+void Serial_SendData(const uint8_t* Buffer, uint16_t Length)
+{
+ while (Length--)
+ Serial_SendByte(*(Buffer++));
+}
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief Serial USART Peripheral Driver (AVR8)
+ *
+ * On-chip serial USART driver for the 8-bit AVR microcontrollers.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USART driver
+ * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.
+ */
+
+/** \ingroup Group_Serial
+ * \defgroup Group_Serial_AVR8 Serial USART Peripheral Driver (AVR8)
+ *
+ * \section Sec_ModDescription Module Description
+ * On-chip serial USART driver for the 8-bit AVR microcontrollers.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver
+ * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.
+ *
+ * \section Sec_ExampleUsage Example Usage
+ * The following snippet is an example of how this module may be used within a typical
+ * application.
+ *
+ * \code
+ * // Initialise the serial USART driver before first use, with 9600 baud (and no double-speed mode)
+ * Serial_Init(9600, false);
+ *
+ * // Send a string through the USART
+ * Serial_TxString("Test String\r\n");
+ *
+ * // Receive a byte through the USART
+ * uint8_t DataByte = Serial_RxByte();
+ * \endcode
+ *
+ * @{
+ */
+
+#ifndef __SERIAL_AVR8_H__
+#define __SERIAL_AVR8_H__
+
+ /* Includes: */
+ #include "../../../Common/Common.h"
+ #include "../../Misc/TerminalCodes.h"
+
+ #include <stdio.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_SERIAL_H) && !defined(__INCLUDE_FROM_SERIAL_C)
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead.
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* External Variables: */
+ extern FILE USARTSerialStream;
+
+ /* Function Prototypes: */
+ int Serial_putchar(char DataByte,
+ FILE *Stream);
+ int Serial_getchar(FILE *Stream);
+ int Serial_getchar_Blocking(FILE *Stream);
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
+ * not set.
+ */
+ #define SERIAL_UBBRVAL(baud) ((((F_CPU / 16) + (baud / 2)) / (baud)) - 1)
+
+ /** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
+ * set.
+ */
+ #define SERIAL_2X_UBBRVAL(baud) ((((F_CPU / 8) + (baud / 2)) / (baud)) - 1)
+
+ /* Function Prototypes: */
+ /** Transmits a given string located in program space (FLASH) through the USART.
+ *
+ * \param[in] FlashStringPtr Pointer to a string located in program space.
+ */
+ void Serial_SendString_P(const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);
+
+ /** Transmits a given string located in SRAM memory through the USART.
+ *
+ * \param[in] StringPtr Pointer to a string located in SRAM space.
+ */
+ void Serial_SendString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1);
+
+ /** Transmits a given buffer located in SRAM memory through the USART.
+ *
+ * \param[in] Buffer Pointer to a buffer containing the data to send.
+ * \param[in] Length Length of the data to send, in bytes.
+ */
+ void Serial_SendData(const uint8_t* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
+
+ /* Inline Functions: */
+ /** Initializes the USART, ready for serial data transmission and reception. This initializes the interface to
+ * standard 8-bit, no parity, 1 stop bit settings suitable for most applications.
+ *
+ * \param[in] BaudRate Serial baud rate, in bits per second.
+ * \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate.
+ */
+ static inline void Serial_Init(const uint32_t BaudRate,
+ const bool DoubleSpeed)
+ {
+ UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));
+
+ UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));
+ UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);
+ UCSR1B = ((1 << TXEN1) | (1 << RXEN1));
+
+ DDRD |= (1 << 3);
+ PORTD |= (1 << 2);
+ }
+
+ /** Turns off the USART driver, disabling and returning used hardware to their default configuration. */
+ static inline void Serial_Disable(void)
+ {
+ UCSR1B = 0;
+ UCSR1A = 0;
+ UCSR1C = 0;
+
+ UBRR1 = 0;
+
+ DDRD &= ~(1 << 3);
+ PORTD &= ~(1 << 2);
+ }
+
+ /** Creates a standard character stream from the USART so that it can be used with all the regular functions
+ * in the avr-libc \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created
+ * stream is bidirectional and can be used for both input and output functions.
+ *
+ * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single
+ * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may
+ * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own
+ * line buffering.
+ *
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL stdio
+ * and stdin will be configured to use the USART.
+ *
+ * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.
+ */
+ static inline void Serial_CreateStream(FILE* Stream)
+ {
+ if (!(Stream))
+ {
+ Stream = &USARTSerialStream;
+ stdin = Stream;
+ stdout = Stream;
+ }
+
+ *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW);
+ }
+
+ /** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates
+ * the transfer.
+ *
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL stdio
+ * and stdin will be configured to use the USART.
+ *
+ * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.
+ */
+ static inline void Serial_CreateBlockingStream(FILE* Stream)
+ {
+ if (!(Stream))
+ {
+ Stream = &USARTSerialStream;
+ stdin = Stream;
+ stdout = Stream;
+ }
+
+ *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW);
+ }
+
+ /** Indicates whether a character has been received through the USART.
+ *
+ * \return Boolean \c true if a character has been received, \c false otherwise.
+ */
+ static inline bool Serial_IsCharReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Serial_IsCharReceived(void)
+ {
+ return ((UCSR1A & (1 << RXC1)) ? true : false);
+ }
+
+ /** Transmits a given byte through the USART.
+ *
+ * \param[in] DataByte Byte to transmit through the USART.
+ */
+ static inline void Serial_SendByte(const char DataByte) ATTR_ALWAYS_INLINE;
+ static inline void Serial_SendByte(const char DataByte)
+ {
+ while (!(UCSR1A & (1 << UDRE1)));
+ UDR1 = DataByte;
+ }
+
+ /** Receives the next byte from the USART.
+ *
+ * \return Next byte received from the USART, or a negative value if no byte has been received.
+ */
+ static inline int16_t Serial_ReceiveByte(void) ATTR_ALWAYS_INLINE;
+ static inline int16_t Serial_ReceiveByte(void)
+ {
+ if (!(Serial_IsCharReceived()))
+ return -1;
+
+ return UDR1;
+ }
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-#define __INCLUDE_FROM_TWI_C
-#include "TWI.h"
-
-uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
- const uint8_t TimeoutMS)
-{
- for (;;)
- {
- bool BusCaptured = false;
- uint16_t TimeoutRemaining;
-
- TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
-
- TimeoutRemaining = (TimeoutMS * 100);
- while (TimeoutRemaining-- && !(BusCaptured))
- {
- if (TWCR & (1 << TWINT))
- {
- switch (TWSR & TW_STATUS_MASK)
- {
- case TW_START:
- case TW_REP_START:
- BusCaptured = true;
- break;
- case TW_MT_ARB_LOST:
- TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
- continue;
- default:
- TWCR = (1 << TWEN);
- return TWI_ERROR_BusFault;
- }
- }
-
- _delay_us(10);
- }
-
- if (!(TimeoutRemaining))
- {
- TWCR = (1 << TWEN);
- return TWI_ERROR_BusCaptureTimeout;
- }
-
- TWDR = SlaveAddress;
- TWCR = ((1 << TWINT) | (1 << TWEN));
-
- TimeoutRemaining = (TimeoutMS * 100);
- while (TimeoutRemaining--)
- {
- if (TWCR & (1 << TWINT))
- break;
-
- _delay_us(10);
- }
-
- if (!(TimeoutRemaining))
- return TWI_ERROR_SlaveResponseTimeout;
-
- switch (TWSR & TW_STATUS_MASK)
- {
- case TW_MT_SLA_ACK:
- case TW_MR_SLA_ACK:
- return TWI_ERROR_NoError;
- default:
- TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN));
- return TWI_ERROR_SlaveNotReady;
- }
- }
-}
-
-uint8_t TWI_ReadPacket(const uint8_t SlaveAddress,
- const uint8_t TimeoutMS,
- const uint8_t* InternalAddress,
- uint8_t InternalAddressLen,
- uint8_t* Buffer,
- uint8_t Length)
-{
- uint8_t ErrorCode;
-
- if ((ErrorCode = TWI_WritePacket(SlaveAddress, TimeoutMS, InternalAddress, InternalAddressLen,
- NULL, 0)) != TWI_ERROR_NoError)
- {
- return ErrorCode;
- }
-
- if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_READ,
- TimeoutMS)) == TWI_ERROR_NoError)
- {
- while (Length--)
- {
- if (!(TWI_ReceiveByte(Buffer++, (Length == 0))))
- {
- ErrorCode = TWI_ERROR_SlaveNAK;
- break;
- }
- }
-
- TWI_StopTransmission();
- }
-
- return ErrorCode;
-}
-
-uint8_t TWI_WritePacket(const uint8_t SlaveAddress,
- const uint8_t TimeoutMS,
- const uint8_t* InternalAddress,
- uint8_t InternalAddressLen,
- const uint8_t* Buffer,
- uint8_t Length)
-{
- uint8_t ErrorCode;
-
- if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_WRITE,
- TimeoutMS)) == TWI_ERROR_NoError)
- {
- while (InternalAddressLen--)
- {
- if (!(TWI_SendByte(*(InternalAddress++))))
- {
- ErrorCode = TWI_ERROR_SlaveNAK;
- break;
- }
- }
-
- while (Length--)
- {
- if (!(TWI_SendByte(*(Buffer++))))
- {
- ErrorCode = TWI_ERROR_SlaveNAK;
- break;
- }
- }
-
- TWI_StopTransmission();
- }
-
- return ErrorCode;
-}
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief TWI Peripheral Driver (AVR8)
- *
- * On-chip TWI driver for the 8-bit AVR microcontrollers.
- *
- * \note This file should not be included directly. It is automatically included as needed by the TWI driver
- * dispatch header located in LUFA/Drivers/Peripheral/TWI.h.
- */
-
-/** \ingroup Group_TWI
- * \defgroup Group_TWI_AVR8 TWI Peripheral Driver (AVR8)
- *
- * \section Sec_ModDescription Module Description
- * Master mode TWI driver for the 8-bit AVR microcontrollers which contain a hardware TWI module.
- *
- * \note This file should not be included directly. It is automatically included as needed by the TWI driver
- * dispatch header located in LUFA/Drivers/Peripheral/TWI.h.
- *
- * \section Sec_ExampleUsage Example Usage
- * The following snippet is an example of how this module may be used within a typical
- * application.
- *
- * <b>Low Level API Example:</b>
- * \code
- * // Initialise the TWI driver before first use
- * TWI_Init();
- *
- * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout
- * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10))
- * {
- * TWI_SendByte(0xDC);
- *
- * TWI_SendByte(0x01);
- * TWI_SendByte(0x02);
- * TWI_SendByte(0x03);
- *
- * // Must stop transmission afterwards to release the bus
- * TWI_StopTransmission();
- * }
- *
- * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout
- * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10))
- * {
- * TWI_SendByte(0xDC);
- * TWI_StopTransmission();
- *
- * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_READ, 10))
- * {
- * uint8_t Byte1, Byte2, Byte3;
- *
- * // Read three bytes, acknowledge after the third byte is received
- * TWI_ReceiveByte(&Byte1, false);
- * TWI_ReceiveByte(&Byte2, false);
- * TWI_ReceiveByte(&Byte3, true);
- *
- * // Must stop transmission afterwards to release the bus
- * TWI_StopTransmission();
- * }
- * }
- * \endcode
- *
- * <b>High Level API Example:</b>
- * \code
- * // Initialise the TWI driver before first use
- * TWI_Init();
- *
- * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout
- * uint8_t InternalWriteAddress = 0xDC;
- * uint8_t WritePacket[3] = {0x01, 0x02, 0x03};
- *
- * TWI_WritePacket(0xA0, 10, &InternalWriteAddress, sizeof(InternalWriteAddress),
- * &WritePacket, sizeof(WritePacket);
- *
- * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout
- * uint8_t InternalReadAddress = 0xDC;
- * uint8_t ReadPacket[3];
- *
- * TWI_ReadPacket(0xA0, 10, &InternalReadAddress, sizeof(InternalReadAddress),
- * &ReadPacket, sizeof(ReadPacket);
- * \endcode
- *
- * @{
- */
-
-#ifndef __TWI_AVR8_H__
-#define __TWI_AVR8_H__
-
- /* Includes: */
- #include "../../../Common/Common.h"
-
- #include <stdio.h>
- #include <util/twi.h>
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_TWI_H) && !defined(__INCLUDE_FROM_TWI_C)
- #error Do not include this file directly. Include LUFA/Drivers/Peripheral/TWI.h instead.
- #endif
-
- #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
- defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
- defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
- defined(__AVR_ATmega32U6__))
- #error The TWI peripheral driver is not currently available for your selected microcontroller model.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** TWI slave device address mask for a read session. Mask with a slave device base address to obtain
- * the correct TWI bus address for the slave device when reading data from it.
- */
- #define TWI_ADDRESS_READ 0x00
-
- /** TWI slave device address mask for a write session. Mask with a slave device base address to obtain
- * the correct TWI bus address for the slave device when writing data to it.
- */
- #define TWI_ADDRESS_WRITE 0x01
-
- /** Mask to retrieve the base address for a TWI device, which can then be ORed with \ref TWI_ADDRESS_READ
- * or \ref TWI_ADDRESS_WRITE to obtain the device's read and write address respectively.
- */
- #define TWI_DEVICE_ADDRESS_MASK 0xFE
-
- /* Enums: */
- /** Enum for the possible return codes of the TWI transfer start routine and other dependant TWI functions. */
- enum TWI_ErrorCodes_t
- {
- TWI_ERROR_NoError = 0, /**< Indicates that the command completed sucessfully. */
- TWI_ERROR_BusFault = 1, /**< A TWI bus fault occurred while attempting to capture the bus. */
- TWI_ERROR_BusCaptureTimeout = 2, /**< A timeout occurred whilst waiting for the bus to be ready. */
- TWI_ERROR_SlaveResponseTimeout = 3, /**< No ACK received at the nominated slave address within the timeout period. */
- TWI_ERROR_SlaveNotReady = 4, /**< Slave NAKed the TWI bus START condition. */
- TWI_ERROR_SlaveNAK = 5, /**< Slave NAKed whilst attempting to send data to the device. */
- };
-
- /* Inline Functions: */
- /** Initialises the TWI hardware into master mode, ready for data transmission and reception. This must be
- * before any other TWI operations.
- */
- static inline void TWI_Init(void) ATTR_ALWAYS_INLINE;
- static inline void TWI_Init(void)
- {
- TWCR |= (1 << TWEN);
- }
-
- /** Turns off the TWI driver hardware. If this is called, any further TWI operations will require a call to
- * \ref TWI_Init() before the TWI can be used again.
- */
- static inline void TWI_Disable(void) ATTR_ALWAYS_INLINE;
- static inline void TWI_Disable(void)
- {
- TWCR &= ~(1 << TWEN);
- }
-
- /** Sends a TWI STOP onto the TWI bus, terminating communication with the currently addressed device. */
- static inline void TWI_StopTransmission(void) ATTR_ALWAYS_INLINE;
- static inline void TWI_StopTransmission(void)
- {
- TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN));
- }
-
- /** Sends a byte to the currently addressed device on the TWI bus.
- *
- * \param[in] Byte Byte to send to the currently addressed device
- *
- * \return Boolean \c true if the recipient ACKed the byte, \c false otherwise
- */
- static inline bool TWI_SendByte(const uint8_t Byte)
- {
- TWDR = Byte;
- TWCR = ((1 << TWINT) | (1 << TWEN));
- while (!(TWCR & (1 << TWINT)));
-
- return ((TWSR & TW_STATUS_MASK) == TW_MT_DATA_ACK);
- }
-
- /** Receives a byte from the currently addressed device on the TWI bus.
- *
- * \param[in] Byte Location where the read byte is to be stored
- * \param[in] LastByte Indicates if the byte should be ACKed if false, NAKed if true
- *
- * \return Boolean \c true if the byte reception successfully completed, \c false otherwise
- */
- static inline uint8_t TWI_ReceiveByte(uint8_t* const Byte,
- const bool LastByte)
- {
- uint8_t TWCRMask = ((1 << TWINT) | (1 << TWEN));
-
- if (!(LastByte))
- TWCRMask |= (1 << TWEA);
-
- TWCR = TWCRMask;
- while (!(TWCR & (1 << TWINT)));
- *Byte = TWDR;
-
- return ((TWSR & TW_STATUS_MASK) == TW_MR_DATA_ACK);
- }
-
- /* Function Prototypes: */
- /** Begins a master mode TWI bus communication with the given slave device address.
- *
- * \param[in] SlaveAddress Address of the slave TWI device to communicate with
- * \param[in] TimeoutMS Timeout period within which the slave must respond, in milliseconds
- *
- * \return A value from the \ref TWI_ErrorCodes_t enum
- */
- uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
- const uint8_t TimeoutMS);
-
- /** High level function to perform a complete packet transfer over the TWI bus to the specified
- * device.
- *
- * \param[in] SlaveAddress Base address of the TWI slave device to communicate with
- * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds
- * \param[in] InternalAddress Pointer to a location where the internal slave read start address is stored
- * \param[in] InternalAddressLen Size of the internal device address, in bytes
- * \param[in] Buffer Pointer to a buffer where the read packet data is to be stored
- * \param[in] Length Size of the packet to read, in bytes
- */
- uint8_t TWI_ReadPacket(const uint8_t SlaveAddress,
- const uint8_t TimeoutMS,
- const uint8_t* InternalAddress,
- uint8_t InternalAddressLen,
- uint8_t* Buffer,
- uint8_t Length);
-
- /** High level function to perform a complete packet transfer over the TWI bus from the specified
- * device.
- *
- * \param[in] SlaveAddress Base address of the TWI slave device to communicate with
- * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds
- * \param[in] InternalAddress Pointer to a location where the internal slave write start address is stored
- * \param[in] InternalAddressLen Size of the internal device address, in bytes
- * \param[in] Buffer Pointer to a buffer where the packet data to send is stored
- * \param[in] Length Size of the packet to send, in bytes
- */
- uint8_t TWI_WritePacket(const uint8_t SlaveAddress,
- const uint8_t TimeoutMS,
- const uint8_t* InternalAddress,
- uint8_t InternalAddressLen,
- const uint8_t* Buffer,
- uint8_t Length);
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+#define __INCLUDE_FROM_TWI_C
+#include "TWI.h"
+
+uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
+ const uint8_t TimeoutMS)
+{
+ for (;;)
+ {
+ bool BusCaptured = false;
+ uint16_t TimeoutRemaining;
+
+ TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
+
+ TimeoutRemaining = (TimeoutMS * 100);
+ while (TimeoutRemaining-- && !(BusCaptured))
+ {
+ if (TWCR & (1 << TWINT))
+ {
+ switch (TWSR & TW_STATUS_MASK)
+ {
+ case TW_START:
+ case TW_REP_START:
+ BusCaptured = true;
+ break;
+ case TW_MT_ARB_LOST:
+ TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));
+ continue;
+ default:
+ TWCR = (1 << TWEN);
+ return TWI_ERROR_BusFault;
+ }
+ }
+
+ _delay_us(10);
+ }
+
+ if (!(TimeoutRemaining))
+ {
+ TWCR = (1 << TWEN);
+ return TWI_ERROR_BusCaptureTimeout;
+ }
+
+ TWDR = SlaveAddress;
+ TWCR = ((1 << TWINT) | (1 << TWEN));
+
+ TimeoutRemaining = (TimeoutMS * 100);
+ while (TimeoutRemaining--)
+ {
+ if (TWCR & (1 << TWINT))
+ break;
+
+ _delay_us(10);
+ }
+
+ if (!(TimeoutRemaining))
+ return TWI_ERROR_SlaveResponseTimeout;
+
+ switch (TWSR & TW_STATUS_MASK)
+ {
+ case TW_MT_SLA_ACK:
+ case TW_MR_SLA_ACK:
+ return TWI_ERROR_NoError;
+ default:
+ TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN));
+ return TWI_ERROR_SlaveNotReady;
+ }
+ }
+}
+
+uint8_t TWI_ReadPacket(const uint8_t SlaveAddress,
+ const uint8_t TimeoutMS,
+ const uint8_t* InternalAddress,
+ uint8_t InternalAddressLen,
+ uint8_t* Buffer,
+ uint8_t Length)
+{
+ uint8_t ErrorCode;
+
+ if ((ErrorCode = TWI_WritePacket(SlaveAddress, TimeoutMS, InternalAddress, InternalAddressLen,
+ NULL, 0)) != TWI_ERROR_NoError)
+ {
+ return ErrorCode;
+ }
+
+ if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_READ,
+ TimeoutMS)) == TWI_ERROR_NoError)
+ {
+ while (Length--)
+ {
+ if (!(TWI_ReceiveByte(Buffer++, (Length == 0))))
+ {
+ ErrorCode = TWI_ERROR_SlaveNAK;
+ break;
+ }
+ }
+
+ TWI_StopTransmission();
+ }
+
+ return ErrorCode;
+}
+
+uint8_t TWI_WritePacket(const uint8_t SlaveAddress,
+ const uint8_t TimeoutMS,
+ const uint8_t* InternalAddress,
+ uint8_t InternalAddressLen,
+ const uint8_t* Buffer,
+ uint8_t Length)
+{
+ uint8_t ErrorCode;
+
+ if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_WRITE,
+ TimeoutMS)) == TWI_ERROR_NoError)
+ {
+ while (InternalAddressLen--)
+ {
+ if (!(TWI_SendByte(*(InternalAddress++))))
+ {
+ ErrorCode = TWI_ERROR_SlaveNAK;
+ break;
+ }
+ }
+
+ while (Length--)
+ {
+ if (!(TWI_SendByte(*(Buffer++))))
+ {
+ ErrorCode = TWI_ERROR_SlaveNAK;
+ break;
+ }
+ }
+
+ TWI_StopTransmission();
+ }
+
+ return ErrorCode;
+}
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief TWI Peripheral Driver (AVR8)
+ *
+ * On-chip TWI driver for the 8-bit AVR microcontrollers.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the TWI driver
+ * dispatch header located in LUFA/Drivers/Peripheral/TWI.h.
+ */
+
+/** \ingroup Group_TWI
+ * \defgroup Group_TWI_AVR8 TWI Peripheral Driver (AVR8)
+ *
+ * \section Sec_ModDescription Module Description
+ * Master mode TWI driver for the 8-bit AVR microcontrollers which contain a hardware TWI module.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the TWI driver
+ * dispatch header located in LUFA/Drivers/Peripheral/TWI.h.
+ *
+ * \section Sec_ExampleUsage Example Usage
+ * The following snippet is an example of how this module may be used within a typical
+ * application.
+ *
+ * <b>Low Level API Example:</b>
+ * \code
+ * // Initialise the TWI driver before first use
+ * TWI_Init();
+ *
+ * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout
+ * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10))
+ * {
+ * TWI_SendByte(0xDC);
+ *
+ * TWI_SendByte(0x01);
+ * TWI_SendByte(0x02);
+ * TWI_SendByte(0x03);
+ *
+ * // Must stop transmission afterwards to release the bus
+ * TWI_StopTransmission();
+ * }
+ *
+ * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout
+ * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10))
+ * {
+ * TWI_SendByte(0xDC);
+ * TWI_StopTransmission();
+ *
+ * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_READ, 10))
+ * {
+ * uint8_t Byte1, Byte2, Byte3;
+ *
+ * // Read three bytes, acknowledge after the third byte is received
+ * TWI_ReceiveByte(&Byte1, false);
+ * TWI_ReceiveByte(&Byte2, false);
+ * TWI_ReceiveByte(&Byte3, true);
+ *
+ * // Must stop transmission afterwards to release the bus
+ * TWI_StopTransmission();
+ * }
+ * }
+ * \endcode
+ *
+ * <b>High Level API Example:</b>
+ * \code
+ * // Initialise the TWI driver before first use
+ * TWI_Init();
+ *
+ * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout
+ * uint8_t InternalWriteAddress = 0xDC;
+ * uint8_t WritePacket[3] = {0x01, 0x02, 0x03};
+ *
+ * TWI_WritePacket(0xA0, 10, &InternalWriteAddress, sizeof(InternalWriteAddress),
+ * &WritePacket, sizeof(WritePacket);
+ *
+ * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout
+ * uint8_t InternalReadAddress = 0xDC;
+ * uint8_t ReadPacket[3];
+ *
+ * TWI_ReadPacket(0xA0, 10, &InternalReadAddress, sizeof(InternalReadAddress),
+ * &ReadPacket, sizeof(ReadPacket);
+ * \endcode
+ *
+ * @{
+ */
+
+#ifndef __TWI_AVR8_H__
+#define __TWI_AVR8_H__
+
+ /* Includes: */
+ #include "../../../Common/Common.h"
+
+ #include <stdio.h>
+ #include <util/twi.h>
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_TWI_H) && !defined(__INCLUDE_FROM_TWI_C)
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/TWI.h instead.
+ #endif
+
+ #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
+ defined(__AVR_ATmega32U6__))
+ #error The TWI peripheral driver is not currently available for your selected microcontroller model.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** TWI slave device address mask for a read session. Mask with a slave device base address to obtain
+ * the correct TWI bus address for the slave device when reading data from it.
+ */
+ #define TWI_ADDRESS_READ 0x00
+
+ /** TWI slave device address mask for a write session. Mask with a slave device base address to obtain
+ * the correct TWI bus address for the slave device when writing data to it.
+ */
+ #define TWI_ADDRESS_WRITE 0x01
+
+ /** Mask to retrieve the base address for a TWI device, which can then be ORed with \ref TWI_ADDRESS_READ
+ * or \ref TWI_ADDRESS_WRITE to obtain the device's read and write address respectively.
+ */
+ #define TWI_DEVICE_ADDRESS_MASK 0xFE
+
+ /* Enums: */
+ /** Enum for the possible return codes of the TWI transfer start routine and other dependant TWI functions. */
+ enum TWI_ErrorCodes_t
+ {
+ TWI_ERROR_NoError = 0, /**< Indicates that the command completed sucessfully. */
+ TWI_ERROR_BusFault = 1, /**< A TWI bus fault occurred while attempting to capture the bus. */
+ TWI_ERROR_BusCaptureTimeout = 2, /**< A timeout occurred whilst waiting for the bus to be ready. */
+ TWI_ERROR_SlaveResponseTimeout = 3, /**< No ACK received at the nominated slave address within the timeout period. */
+ TWI_ERROR_SlaveNotReady = 4, /**< Slave NAKed the TWI bus START condition. */
+ TWI_ERROR_SlaveNAK = 5, /**< Slave NAKed whilst attempting to send data to the device. */
+ };
+
+ /* Inline Functions: */
+ /** Initialises the TWI hardware into master mode, ready for data transmission and reception. This must be
+ * before any other TWI operations.
+ */
+ static inline void TWI_Init(void) ATTR_ALWAYS_INLINE;
+ static inline void TWI_Init(void)
+ {
+ TWCR |= (1 << TWEN);
+ }
+
+ /** Turns off the TWI driver hardware. If this is called, any further TWI operations will require a call to
+ * \ref TWI_Init() before the TWI can be used again.
+ */
+ static inline void TWI_Disable(void) ATTR_ALWAYS_INLINE;
+ static inline void TWI_Disable(void)
+ {
+ TWCR &= ~(1 << TWEN);
+ }
+
+ /** Sends a TWI STOP onto the TWI bus, terminating communication with the currently addressed device. */
+ static inline void TWI_StopTransmission(void) ATTR_ALWAYS_INLINE;
+ static inline void TWI_StopTransmission(void)
+ {
+ TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN));
+ }
+
+ /** Sends a byte to the currently addressed device on the TWI bus.
+ *
+ * \param[in] Byte Byte to send to the currently addressed device
+ *
+ * \return Boolean \c true if the recipient ACKed the byte, \c false otherwise
+ */
+ static inline bool TWI_SendByte(const uint8_t Byte)
+ {
+ TWDR = Byte;
+ TWCR = ((1 << TWINT) | (1 << TWEN));
+ while (!(TWCR & (1 << TWINT)));
+
+ return ((TWSR & TW_STATUS_MASK) == TW_MT_DATA_ACK);
+ }
+
+ /** Receives a byte from the currently addressed device on the TWI bus.
+ *
+ * \param[in] Byte Location where the read byte is to be stored
+ * \param[in] LastByte Indicates if the byte should be ACKed if false, NAKed if true
+ *
+ * \return Boolean \c true if the byte reception successfully completed, \c false otherwise
+ */
+ static inline uint8_t TWI_ReceiveByte(uint8_t* const Byte,
+ const bool LastByte)
+ {
+ uint8_t TWCRMask = ((1 << TWINT) | (1 << TWEN));
+
+ if (!(LastByte))
+ TWCRMask |= (1 << TWEA);
+
+ TWCR = TWCRMask;
+ while (!(TWCR & (1 << TWINT)));
+ *Byte = TWDR;
+
+ return ((TWSR & TW_STATUS_MASK) == TW_MR_DATA_ACK);
+ }
+
+ /* Function Prototypes: */
+ /** Begins a master mode TWI bus communication with the given slave device address.
+ *
+ * \param[in] SlaveAddress Address of the slave TWI device to communicate with
+ * \param[in] TimeoutMS Timeout period within which the slave must respond, in milliseconds
+ *
+ * \return A value from the \ref TWI_ErrorCodes_t enum
+ */
+ uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,
+ const uint8_t TimeoutMS);
+
+ /** High level function to perform a complete packet transfer over the TWI bus to the specified
+ * device.
+ *
+ * \param[in] SlaveAddress Base address of the TWI slave device to communicate with
+ * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds
+ * \param[in] InternalAddress Pointer to a location where the internal slave read start address is stored
+ * \param[in] InternalAddressLen Size of the internal device address, in bytes
+ * \param[in] Buffer Pointer to a buffer where the read packet data is to be stored
+ * \param[in] Length Size of the packet to read, in bytes
+ */
+ uint8_t TWI_ReadPacket(const uint8_t SlaveAddress,
+ const uint8_t TimeoutMS,
+ const uint8_t* InternalAddress,
+ uint8_t InternalAddressLen,
+ uint8_t* Buffer,
+ uint8_t Length);
+
+ /** High level function to perform a complete packet transfer over the TWI bus from the specified
+ * device.
+ *
+ * \param[in] SlaveAddress Base address of the TWI slave device to communicate with
+ * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds
+ * \param[in] InternalAddress Pointer to a location where the internal slave write start address is stored
+ * \param[in] InternalAddressLen Size of the internal device address, in bytes
+ * \param[in] Buffer Pointer to a buffer where the packet data to send is stored
+ * \param[in] Length Size of the packet to send, in bytes
+ */
+ uint8_t TWI_WritePacket(const uint8_t SlaveAddress,
+ const uint8_t TimeoutMS,
+ const uint8_t* InternalAddress,
+ uint8_t InternalAddressLen,
+ const uint8_t* Buffer,
+ uint8_t Length);
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
/* Includes: */
#if (ARCH == ARCH_AVR8)
- #include "AVR8/SPI.h"
+ #include "AVR8/SPI_AVR8.h"
#else
#error The SPI peripheral driver is not currently available for your selected architecture.
#endif
*
* \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module:
- * - LUFA/Drivers/Peripheral/<i>ARCH</i>/Serial.c <i>(Makefile source module name: LUFA_SRC_SERIAL)</i>
+ * - LUFA/Drivers/Peripheral/<i>ARCH</i>/Serial_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_SERIAL)</i>
*
* \section Sec_ModDescription Module Description
* Hardware serial USART driver. This module provides an easy to use driver for the setup and transfer
/* Includes: */
#if (ARCH == ARCH_AVR8)
- #include "AVR8/Serial.h"
+ #include "AVR8/Serial_AVR8.h"
#else
#error The Serial peripheral driver is not currently available for your selected architecture.
#endif
*
* \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module:
- * - LUFA/Drivers/Peripheral/<i>ARCH</i>/TWI.c <i>(Makefile source module name: LUFA_SRC_TWI)</i>
+ * - LUFA/Drivers/Peripheral/<i>ARCH</i>/TWI_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_TWI)</i>
*
* \section Sec_ModDescription Module Description
* Hardware TWI driver. This module provides an easy to use driver for the setup and transfer of data over
/* Includes: */
#if (ARCH == ARCH_AVR8)
- #include "AVR8/TWI.h"
+ #include "AVR8/TWI_AVR8.h"
#else
#error The TWI peripheral driver is not currently available for your selected architecture.
#endif
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#include "../USBMode.h"
-
-#if defined(USB_CAN_BE_DEVICE)
-
-#include "Device.h"
-
-void USB_Device_SendRemoteWakeup(void)
-{
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- {
- USB_PLL_On();
- while (!(USB_PLL_IsReady()));
- }
-
- USB_CLK_Unfreeze();
-
- UDCON |= (1 << RMWKUP);
- while (!(UDCON & (1 << RMWKUP)));
-}
-
-#endif
-
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB Device definitions for the AVR8 microcontrollers.
- * \copydetails Group_Device_AVR8
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_Device
- * \defgroup Group_Device_AVR8 Device Management (AVR8)
- * \brief USB Device definitions for the AVR8 microcontrollers.
- *
- * Architecture specific USB Device definitions for the Atmel 8-bit AVR microcontrollers.
- *
- * @{
- */
-
-#ifndef __USBDEVICE_AVR8_H__
-#define __USBDEVICE_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
- #include "../StdDescriptors.h"
- #include "../USBInterrupt.h"
- #include "../Endpoint.h"
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
- #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** \name USB Device Mode Option Masks */
- //@{
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
- /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
- * USB interface should be initialized in low speed (1.5Mb/s) mode.
- *
- * \note Low Speed mode is not available on all USB AVR models.
- * \n
- *
- * \note Restrictions apply on the number, size and type of endpoints which can be used
- * when running in low speed mode - refer to the USB 2.0 specification.
- */
- #define USB_DEVICE_OPT_LOWSPEED (1 << 0)
- #endif
-
- /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
- * USB interface should be initialized in full speed (12Mb/s) mode.
- */
- #define USB_DEVICE_OPT_FULLSPEED (0 << 0)
- //@}
-
- #if (!defined(NO_INTERNAL_SERIAL) && \
- (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \
- defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \
- defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
- /** String descriptor index for the device's unique serial number string descriptor within the device.
- * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
- * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
- * a unique serial number internally, and setting the device descriptors serial number string index to this value
- * will cause it to use the internal serial number.
- *
- * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
- * number for the device.
- */
- #define USE_INTERNAL_SERIAL 0xDC
- #else
- #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
- #endif
-
- /* Function Prototypes: */
- /** Sends a Remote Wakeup request to the host. This signals to the host that the device should
- * be taken out of suspended mode, and communications should resume.
- *
- * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the
- * host computer when the host has suspended all USB devices to enter a low power state.
- *
- * \note This macro should only be used if the device has indicated to the host that it
- * supports the Remote Wakeup feature in the device descriptors, and should only be
- * issued if the host is currently allowing remote wakeup events from the device (i.e.,
- * the \ref USB_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP compile
- * time option is used, this macro is unavailable.
- * \n\n
- *
- * \note The USB clock must be running for this function to operate. If the stack is initialized with
- * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
- * before attempting to call this function.
- *
- * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.
- */
- void USB_Device_SendRemoteWakeup(void);
-
- /* Type Defines: */
- enum USB_Device_States_t
- {
- DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates
- * that the device is not currently connected to a host.
- */
- DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates
- * that the device is connected to a host, but enumeration has not
- * yet begun.
- */
- DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates
- * that the device's USB bus has been reset by the host and it is
- * now waiting for the host to begin the enumeration process.
- */
- DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates
- * that the device has been addressed by the USB Host, but is not
- * yet configured.
- */
- DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates
- * that the device has been enumerated by the host and is ready
- * for USB communications to begin.
- */
- DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates
- * that the USB bus has been suspended by the host, and the device
- * should power down to a minimal power level until the bus is
- * resumed.
- */
- };
-
- /* Inline Functions: */
- /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
- * the frame number is incremented by one.
- */
- static inline uint16_t USB_Device_GetFrameNumber(void)
- {
- return UDFNUM;
- }
-
- #if !defined(NO_SOF_EVENTS)
- /** Enables the device mode Start Of Frame events. When enabled, this causes the
- * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
- * at the start of each USB frame when enumerated in device mode.
- *
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
- */
- static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Device_EnableSOFEvents(void)
- {
- USB_INT_Enable(USB_INT_SOFI);
- }
-
- /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
- * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
- *
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
- */
- static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Device_DisableSOFEvents(void)
- {
- USB_INT_Disable(USB_INT_SOFI);
- }
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Inline Functions: */
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Device_SetLowSpeed(void)
- {
- UDCON |= (1 << LSM);
- }
-
- static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Device_SetFullSpeed(void)
- {
- UDCON &= ~(1 << LSM);
- }
- #endif
-
- static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
- static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
- {
- UDADDR = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F));
- UDADDR |= (1 << ADDEN);
- }
-
- static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE;
- static inline bool USB_Device_IsAddressSet(void)
- {
- return (UDADDR & (1 << ADDEN));
- }
-
- static inline uint8_t USB_Device_GetSerialString(wchar_t* UnicodeString, const uint8_t MaxLen)
- {
- uint8_t SerialCharNum = 0;
-
- ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
- {
- uint8_t SigReadAddress = 0x0E;
-
- for (SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 20); SerialCharNum++)
- {
- if (SerialCharNum == MaxLen)
- break;
-
- uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
-
- if (SerialCharNum & 0x01)
- {
- SerialByte >>= 4;
- SigReadAddress++;
- }
-
- SerialByte &= 0x0F;
-
- UnicodeString[SerialCharNum] = (SerialByte >= 10) ?
- (('A' - 10) + SerialByte) : ('0' + SerialByte);
- }
- }
-
- return SerialCharNum;
- }
-
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#include "../USBMode.h"
+
+#if defined(USB_CAN_BE_DEVICE)
+
+#include "../Device.h"
+
+void USB_Device_SendRemoteWakeup(void)
+{
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))
+ {
+ USB_PLL_On();
+ while (!(USB_PLL_IsReady()));
+ }
+
+ USB_CLK_Unfreeze();
+
+ UDCON |= (1 << RMWKUP);
+ while (!(UDCON & (1 << RMWKUP)));
+}
+
+#endif
+
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB Device definitions for the AVR8 microcontrollers.
+ * \copydetails Group_Device_AVR8
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_Device
+ * \defgroup Group_Device_AVR8 Device Management (AVR8)
+ * \brief USB Device definitions for the AVR8 microcontrollers.
+ *
+ * Architecture specific USB Device definitions for the Atmel 8-bit AVR microcontrollers.
+ *
+ * @{
+ */
+
+#ifndef __USBDEVICE_AVR8_H__
+#define __USBDEVICE_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+ #include "../StdDescriptors.h"
+ #include "../USBInterrupt.h"
+ #include "../Endpoint.h"
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
+ #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** \name USB Device Mode Option Masks */
+ //@{
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
+ * USB interface should be initialized in low speed (1.5Mb/s) mode.
+ *
+ * \note Low Speed mode is not available on all USB AVR models.
+ * \n
+ *
+ * \note Restrictions apply on the number, size and type of endpoints which can be used
+ * when running in low speed mode - refer to the USB 2.0 specification.
+ */
+ #define USB_DEVICE_OPT_LOWSPEED (1 << 0)
+ #endif
+
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
+ * USB interface should be initialized in full speed (12Mb/s) mode.
+ */
+ #define USB_DEVICE_OPT_FULLSPEED (0 << 0)
+ //@}
+
+ #if (!defined(NO_INTERNAL_SERIAL) && \
+ (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \
+ defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \
+ defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
+ /** String descriptor index for the device's unique serial number string descriptor within the device.
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value
+ * will cause it to use the internal serial number.
+ *
+ * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial
+ * number for the device.
+ */
+ #define USE_INTERNAL_SERIAL 0xDC
+ #else
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
+ #endif
+
+ /* Function Prototypes: */
+ /** Sends a Remote Wakeup request to the host. This signals to the host that the device should
+ * be taken out of suspended mode, and communications should resume.
+ *
+ * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the
+ * host computer when the host has suspended all USB devices to enter a low power state.
+ *
+ * \note This macro should only be used if the device has indicated to the host that it
+ * supports the Remote Wakeup feature in the device descriptors, and should only be
+ * issued if the host is currently allowing remote wakeup events from the device (i.e.,
+ * the \ref USB_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP compile
+ * time option is used, this macro is unavailable.
+ * \n\n
+ *
+ * \note The USB clock must be running for this function to operate. If the stack is initialized with
+ * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running
+ * before attempting to call this function.
+ *
+ * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.
+ */
+ void USB_Device_SendRemoteWakeup(void);
+
+ /* Type Defines: */
+ enum USB_Device_States_t
+ {
+ DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates
+ * that the device is not currently connected to a host.
+ */
+ DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates
+ * that the device is connected to a host, but enumeration has not
+ * yet begun.
+ */
+ DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates
+ * that the device's USB bus has been reset by the host and it is
+ * now waiting for the host to begin the enumeration process.
+ */
+ DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates
+ * that the device has been addressed by the USB Host, but is not
+ * yet configured.
+ */
+ DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates
+ * that the device has been enumerated by the host and is ready
+ * for USB communications to begin.
+ */
+ DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates
+ * that the USB bus has been suspended by the host, and the device
+ * should power down to a minimal power level until the bus is
+ * resumed.
+ */
+ };
+
+ /* Inline Functions: */
+ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)
+ * the frame number is incremented by one.
+ */
+ static inline uint16_t USB_Device_GetFrameNumber(void)
+ {
+ return UDFNUM;
+ }
+
+ #if !defined(NO_SOF_EVENTS)
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
+ * at the start of each USB frame when enumerated in device mode.
+ *
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
+ */
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_EnableSOFEvents(void)
+ {
+ USB_INT_Enable(USB_INT_SOFI);
+ }
+
+ /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
+ *
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
+ */
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_DisableSOFEvents(void)
+ {
+ USB_INT_Disable(USB_INT_SOFI);
+ }
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Inline Functions: */
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_SetLowSpeed(void)
+ {
+ UDCON |= (1 << LSM);
+ }
+
+ static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_SetFullSpeed(void)
+ {
+ UDCON &= ~(1 << LSM);
+ }
+ #endif
+
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
+ {
+ UDADDR = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F));
+ UDADDR |= (1 << ADDEN);
+ }
+
+ static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE;
+ static inline bool USB_Device_IsAddressSet(void)
+ {
+ return (UDADDR & (1 << ADDEN));
+ }
+
+ static inline uint8_t USB_Device_GetSerialString(wchar_t* UnicodeString, const uint8_t MaxLen)
+ {
+ uint8_t SerialCharNum = 0;
+
+ ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
+ {
+ uint8_t SigReadAddress = 0x0E;
+
+ for (SerialCharNum = 0; SerialCharNum < MIN(MaxLen, 20); SerialCharNum++)
+ {
+ if (SerialCharNum == MaxLen)
+ break;
+
+ uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
+
+ if (SerialCharNum & 0x01)
+ {
+ SerialByte >>= 4;
+ SigReadAddress++;
+ }
+
+ SerialByte &= 0x0F;
+
+ UnicodeString[SerialCharNum] = (SerialByte >= 10) ?
+ (('A' - 10) + SerialByte) : ('0' + SerialByte);
+ }
+ }
+
+ return SerialCharNum;
+ }
+
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#include "../USBMode.h"
-
-#if defined(USB_CAN_BE_DEVICE)
-
-#include "Endpoint.h"
-
-#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
-uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
-#endif
-
-bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
- const uint8_t UECFG0XData,
- const uint8_t UECFG1XData)
-{
-#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)
- Endpoint_SelectEndpoint(Number);
- Endpoint_EnableEndpoint();
-
- UECFG1X = 0;
- UECFG0X = UECFG0XData;
- UECFG1X = UECFG1XData;
-
- return Endpoint_IsConfigured();
-#else
- for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
- {
- uint8_t UECFG0XTemp;
- uint8_t UECFG1XTemp;
- uint8_t UEIENXTemp;
-
- Endpoint_SelectEndpoint(EPNum);
-
- if (EPNum == Number)
- {
- UECFG0XTemp = UECFG0XData;
- UECFG1XTemp = UECFG1XData;
- UEIENXTemp = 0;
- }
- else
- {
- UECFG0XTemp = UECFG0X;
- UECFG1XTemp = UECFG1X;
- UEIENXTemp = UEIENX;
- }
-
- if (!(UECFG1XTemp & (1 << ALLOC)))
- continue;
-
- Endpoint_DisableEndpoint();
- UECFG1X &= (1 << ALLOC);
-
- Endpoint_EnableEndpoint();
- UECFG0X = UECFG0XTemp;
- UECFG1X = UECFG1XTemp;
- UEIENX = UEIENXTemp;
-
- if (!(Endpoint_IsConfigured()))
- return false;
- }
-
- Endpoint_SelectEndpoint(Number);
- return true;
-#endif
-}
-
-void Endpoint_ClearEndpoints(void)
-{
- UEINT = 0;
-
- for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
- {
- Endpoint_SelectEndpoint(EPNum);
- UEIENX = 0;
- UEINTX = 0;
- UECFG1X = 0;
- Endpoint_DisableEndpoint();
- }
-}
-
-void Endpoint_ClearStatusStage(void)
-{
- if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
- {
- while (!(Endpoint_IsOUTReceived()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
-
- Endpoint_ClearOUT();
- }
- else
- {
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return;
- }
-
- Endpoint_ClearIN();
- }
-}
-
-#if !defined(CONTROL_ONLY_DEVICE)
-uint8_t Endpoint_WaitUntilReady(void)
-{
- #if (USB_STREAM_TIMEOUT_MS < 0xFF)
- uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
- #else
- uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
- #endif
-
- uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();
-
- for (;;)
- {
- if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)
- {
- if (Endpoint_IsINReady())
- return ENDPOINT_READYWAIT_NoError;
- }
- else
- {
- if (Endpoint_IsOUTReceived())
- return ENDPOINT_READYWAIT_NoError;
- }
-
- uint8_t USB_DeviceState_LCL = USB_DeviceState;
-
- if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
- return ENDPOINT_READYWAIT_DeviceDisconnected;
- else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
- return ENDPOINT_READYWAIT_BusSuspended;
- else if (Endpoint_IsStalled())
- return ENDPOINT_READYWAIT_EndpointStalled;
-
- uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();
-
- if (CurrentFrameNumber != PreviousFrameNumber)
- {
- PreviousFrameNumber = CurrentFrameNumber;
-
- if (!(TimeoutMSRem--))
- return ENDPOINT_READYWAIT_Timeout;
- }
- }
-}
-#endif
-
-#endif
-
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB Endpoint definitions for the AVR8 microcontrollers.
- * \copydetails Group_EndpointManagement_AVR8
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_EndpointRW
- * \defgroup Group_EndpointRW_AVR8 Endpoint Data Reading and Writing (AVR8)
- * \brief Endpoint data read/write definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.
- */
-
-/** \ingroup Group_EndpointPrimitiveRW
- * \defgroup Group_EndpointPrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8)
- * \brief Endpoint primative read/write definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros, variables, enums and types related to data reading and writing of primitive data types
- * from and to endpoints.
- */
-
-/** \ingroup Group_EndpointPacketManagement
- * \defgroup Group_EndpointPacketManagement_AVR8 Endpoint Packet Management (AVR8)
- * \brief Endpoint packet management definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros, variables, enums and types related to packet management of endpoints.
- */
-
-/** \ingroup Group_EndpointManagement
- * \defgroup Group_EndpointManagement_AVR8 Endpoint Management (AVR8)
- * \brief Endpoint management definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros and enums related to endpoint management when in USB Device mode. This
- * module contains the endpoint management macros, as well as endpoint interrupt and data
- * send/receive functions for various data types.
- *
- * @{
- */
-
-#ifndef __ENDPOINT_AVR8_H__
-#define __ENDPOINT_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
- #include "../USBTask.h"
- #include "../USBInterrupt.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex)
- #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails)
- #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize)
-
- #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex)
- #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)
- #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)
-
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- #define ENDPOINT_DETAILS_MAXEP 7
-
- #define ENDPOINT_DETAILS_EP0 64, 2
- #define ENDPOINT_DETAILS_EP1 256, 2
- #define ENDPOINT_DETAILS_EP2 64, 2
- #define ENDPOINT_DETAILS_EP3 64, 2
- #define ENDPOINT_DETAILS_EP4 64, 2
- #define ENDPOINT_DETAILS_EP5 64, 2
- #define ENDPOINT_DETAILS_EP6 64, 2
- #else
- #define ENDPOINT_DETAILS_MAXEP 5
-
- #define ENDPOINT_DETAILS_EP0 64, 2
- #define ENDPOINT_DETAILS_EP1 64, 1
- #define ENDPOINT_DETAILS_EP2 64, 1
- #define ENDPOINT_DETAILS_EP3 64, 2
- #define ENDPOINT_DETAILS_EP4 64, 2
- #endif
-
- /* Inline Functions: */
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
- ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
- {
- uint8_t MaskVal = 0;
- uint16_t CheckBytes = 8;
-
- while (CheckBytes < Bytes)
- {
- MaskVal++;
- CheckBytes <<= 1;
- }
-
- return (MaskVal << EPSIZE0);
- }
-
- /* Function Prototypes: */
- void Endpoint_ClearEndpoints(void);
- bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
- const uint8_t UECFG0XData,
- const uint8_t UECFG1XData);
-
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** \name Endpoint Direction Masks */
- //@{
- /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
- * should be initialized in the OUT direction - i.e. data flows from host to device.
- */
- #define ENDPOINT_DIR_OUT (0 << EPDIR)
-
- /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
- * should be initialized in the IN direction - i.e. data flows from device to host.
- */
- #define ENDPOINT_DIR_IN (1 << EPDIR)
- //@}
-
- /** \name Endpoint Bank Mode Masks */
- //@{
- /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
- * that the endpoint should have one single bank, which requires less USB FIFO memory but results
- * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's
- * bank at the one time.
- */
- #define ENDPOINT_BANK_SINGLE (0 << EPBK0)
-
- /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
- * that the endpoint should have two banks, which requires more USB FIFO memory but results
- * in faster transfers as one USB device (the AVR or the host) can access one bank while the other
- * accesses the second bank.
- */
- #define ENDPOINT_BANK_DOUBLE (1 << EPBK0)
- //@}
-
- /** Endpoint address for the default control endpoint, which always resides in address 0. This is
- * defined for convenience to give more readable code when used with the endpoint macros.
- */
- #define ENDPOINT_CONTROLEP 0
-
- #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
- /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size
- * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.
- */
- #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8
- #endif
-
- /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
- * numerical address in the device.
- */
- #define ENDPOINT_EPNUM_MASK 0x07
-
- /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
- * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
- */
- #define ENDPOINT_EPDIR_MASK 0x80
-
- /** Retrives the maximum bank size in bytes of a given endpoint.
- *
- * \note This macro will only work correctly on endpoint indexes that are compile-time constants
- * defined by the preprocessor.
- *
- * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)
- */
- #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex)
-
- /** Retrieves the total number of banks supported by the given endpoint.
- *
- * \note This macro will only work correctly on endpoint indexes that are compile-time constants
- * defined by the preprocessor.
- *
- * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)
- */
- #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex)
-
- #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__)
- /** Total number of endpoints (including the default control endpoint at address 0) which may
- * be used in the device. Different USB AVR models support different amounts of endpoints,
- * this value reflects the maximum number of endpoints for the currently selected AVR model.
- */
- #define ENDPOINT_TOTAL_ENDPOINTS ENDPOINT_DETAILS_MAXEP
- #else
- #define ENDPOINT_TOTAL_ENDPOINTS 1
- #endif
-
- /* Enums: */
- /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.
- *
- * \ingroup Group_EndpointRW_AVR8
- */
- enum Endpoint_WaitUntilReady_ErrorCodes_t
- {
- ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */
- ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream
- * transfer by the host or device.
- */
- ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while
- * waiting for the endpoint to become ready.
- */
- ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and
- * no USB endpoint traffic can occur until the bus
- * has resumed.
- */
- ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet
- * within the software timeout period set by the
- * \ref USB_STREAM_TIMEOUT_MS macro.
- */
- };
-
- /* Inline Functions: */
- /** Configures the specified endpoint number with the given endpoint type, direction, bank size
- * and banking mode. Once configured, the endpoint may be read from or written to, depending
- * on its direction.
- *
- * \param[in] Number Endpoint number to configure. This must be more than 0 and less than
- * \ref ENDPOINT_TOTAL_ENDPOINTS.
- *
- * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types
- * are available on Low Speed USB devices - refer to the USB 2.0 specification.
- *
- * \param[in] Direction Endpoint data direction, either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN.
- * All endpoints (except Control type) are unidirectional - data may only be read
- * from or written to the endpoint bank based on its direction, not both.
- *
- * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted
- * to the USB host, or after they have been received from the USB host (depending on
- * the endpoint's data direction). The bank size must indicate the maximum packet size
- * that the endpoint can handle.
- *
- * \param[in] Banks Number of banks to use for the endpoint being configured, an \c ENDPOINT_BANK_* mask.
- * More banks uses more USB DPRAM, but offers better performance. Isochronous type
- * endpoints <b>must</b> have at least two banks.
- *
- * \note When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints <b>must</b> be configured in
- * ascending order, or bank corruption will occur.
- * \n\n
- *
- * \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's
- * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.
- * \n\n
- *
- * \note The default control endpoint should not be manually configured by the user application, as
- * it is automatically configured by the library internally.
- * \n\n
- *
- * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint
- * which failed to reconfigure correctly will be selected.
- *
- * \return Boolean \c true if the configuration succeeded, \c false otherwise.
- */
- static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,
- const uint8_t Type,
- const uint8_t Direction,
- const uint16_t Size,
- const uint8_t Banks) ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,
- const uint8_t Type,
- const uint8_t Direction,
- const uint16_t Size,
- const uint8_t Banks)
- {
- return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << EPTYPE0) | Direction),
- ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size)));
- }
-
- /** Indicates the number of bytes currently stored in the current endpoint's selected bank.
- *
- * \note The return width of this function may differ, depending on the maximum endpoint bank size
- * of the selected AVR model.
- *
- * \ingroup Group_EndpointRW_AVR8
- *
- * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.
- */
- static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t Endpoint_BytesInEndpoint(void)
- {
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- return UEBCX;
- #elif defined(USB_SERIES_4_AVR)
- return (((uint16_t)UEBCHX << 8) | UEBCLX);
- #elif defined(USB_SERIES_2_AVR)
- return UEBCLX;
- #endif
- }
-
- /** Get the endpoint address of the currently selected endpoint. This is typically used to save
- * the currently selected endpoint number so that it can be restored after another endpoint has
- * been manipulated.
- *
- * \return Index of the currently selected endpoint.
- */
- static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_GetCurrentEndpoint(void)
- {
- #if !defined(CONTROL_ONLY_DEVICE)
- return (UENUM & ENDPOINT_EPNUM_MASK);
- #else
- return ENDPOINT_CONTROLEP;
- #endif
- }
-
- /** Selects the given endpoint number. If the address from the device descriptors is used, the
- * value should be masked with the \ref ENDPOINT_EPNUM_MASK constant to extract only the endpoint
- * number (and discarding the endpoint direction bit).
- *
- * Any endpoint operations which do not require the endpoint number to be indicated will operate on
- * the currently selected endpoint.
- *
- * \param[in] EndpointNumber Endpoint number to select.
- */
- static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber)
- {
- #if !defined(CONTROL_ONLY_DEVICE)
- UENUM = EndpointNumber;
- #endif
- }
-
- /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's
- * data In and Out pointers to the bank's contents.
- *
- * \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset.
- */
- static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)
- {
- UERST = (1 << EndpointNumber);
- UERST = 0;
- }
-
- /** Enables the currently selected endpoint so that data can be sent and received through it to
- * and from a host.
- *
- * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint().
- */
- static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_EnableEndpoint(void)
- {
- UECONX |= (1 << EPEN);
- }
-
- /** Disables the currently selected endpoint so that data cannot be sent and received through it
- * to and from a host.
- */
- static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_DisableEndpoint(void)
- {
- UECONX &= ~(1 << EPEN);
- }
-
- /** Determines if the currently selected endpoint is enabled, but not necessarily configured.
- *
- * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.
- */
- static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsEnabled(void)
- {
- return ((UECONX & (1 << EPEN)) ? true : false);
- }
-
- /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for
- * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the
- * \ref Endpoint_ClearOUT() command.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \return Total number of busy banks in the selected endpoint.
- */
- static inline uint8_t Endpoint_GetBusyBanks(void)
- {
- return (UESTA0X & (0x03 << NBUSYBK0));
- }
-
- /** Aborts all pending IN transactions on the currently selected endpoint, once the bank
- * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function
- * will terminate all queued transactions, resetting the endpoint banks ready for a new
- * packet.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- */
- static inline void Endpoint_AbortPendingIN(void)
- {
- while (Endpoint_GetBusyBanks() != 0)
- {
- UEINTX |= (1 << RXOUTI);
- while (UEINTX & (1 << RXOUTI));
- }
- }
-
- /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint
- * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN
- * direction). This function will return false if an error has occurred in the endpoint, if the endpoint
- * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN
- * direction and the endpoint bank is full.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending
- * on its direction.
- */
- static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsReadWriteAllowed(void)
- {
- return ((UEINTX & (1 << RWAL)) ? true : false);
- }
-
- /** Determines if the currently selected endpoint is configured.
- *
- * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.
- */
- static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsConfigured(void)
- {
- return ((UESTA0X & (1 << CFGOK)) ? true : false);
- }
-
- /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their
- * interrupt duration has elapsed. Which endpoints have interrupted can be determined by
- * masking the return value against <tt>(1 << <i>{Endpoint Number}</i>)</tt>.
- *
- * \return Mask whose bits indicate which endpoints have interrupted.
- */
- static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_GetEndpointInterrupts(void)
- {
- return UEINT;
- }
-
- /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type
- * endpoints).
- *
- * \param[in] EndpointNumber Index of the endpoint whose interrupt flag should be tested.
- *
- * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise.
- */
- static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber)
- {
- return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false);
- }
-
- /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.
- */
- static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsINReady(void)
- {
- return ((UEINTX & (1 << TXINI)) ? true : false);
- }
-
- /** Determines if the selected OUT endpoint has received new packet from the host.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.
- */
- static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsOUTReceived(void)
- {
- return ((UEINTX & (1 << RXOUTI)) ? true : false);
- }
-
- /** Determines if the current CONTROL type endpoint has received a SETUP packet.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.
- */
- static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsSETUPReceived(void)
- {
- return ((UEINTX & (1 << RXSTPI)) ? true : false);
- }
-
- /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the
- * endpoint for the next packet.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \note This is not applicable for non CONTROL type endpoints.
- */
- static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearSETUP(void)
- {
- UEINTX &= ~(1 << RXSTPI);
- }
-
- /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the
- * next packet and switching to the alternative endpoint bank if double banked.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- */
- static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearIN(void)
- {
- #if !defined(CONTROL_ONLY_DEVICE)
- UEINTX &= ~((1 << TXINI) | (1 << FIFOCON));
- #else
- UEINTX &= ~(1 << TXINI);
- #endif
- }
-
- /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint
- * for the next packet and switching to the alternative endpoint bank if double banked.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- */
- static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearOUT(void)
- {
- #if !defined(CONTROL_ONLY_DEVICE)
- UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON));
- #else
- UEINTX &= ~(1 << RXOUTI);
- #endif
- }
-
- /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the
- * indicated endpoint and that the current transfer sequence should be aborted. This provides a
- * way for devices to indicate invalid commands to the host so that the current transfer can be
- * aborted and the host can begin its own recovery sequence.
- *
- * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro
- * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected
- * endpoint.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- */
- static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_StallTransaction(void)
- {
- UECONX |= (1 << STALLRQ);
- }
-
- /** Clears the STALL condition on the currently selected endpoint.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- */
- static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearStall(void)
- {
- UECONX |= (1 << STALLRQC);
- }
-
- /** Determines if the currently selected endpoint is stalled, false otherwise.
- *
- * \ingroup Group_EndpointPacketManagement_AVR8
- *
- * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.
- */
- static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsStalled(void)
- {
- return ((UECONX & (1 << STALLRQ)) ? true : false);
- }
-
- /** Resets the data toggle of the currently selected endpoint. */
- static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ResetDataToggle(void)
- {
- UECONX |= (1 << RSTDT);
- }
-
- /** Determines the currently selected endpoint's direction.
- *
- * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.
- */
- static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_GetEndpointDirection(void)
- {
- return (UECFG0X & ENDPOINT_DIR_IN);
- }
-
- /** Sets the direction of the currently selected endpoint.
- *
- * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask.
- */
- static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask)
- {
- UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | DirectionMask);
- }
-
- /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \return Next byte in the currently selected endpoint's FIFO buffer.
- */
- static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_Read_Byte(void)
- {
- return UEDATX;
- }
-
- /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \param[in] Byte Next byte to write into the the currently selected endpoint's FIFO buffer.
- */
- static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Write_Byte(const uint8_t Byte)
- {
- UEDATX = Byte;
- }
-
- /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- */
- static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Discard_Byte(void)
- {
- uint8_t Dummy;
-
- Dummy = UEDATX;
- }
-
- /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \return Next word in the currently selected endpoint's FIFO buffer.
- */
- static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t Endpoint_Read_Word_LE(void)
- {
- union
- {
- uint16_t Word;
- uint8_t Bytes[2];
- } Data;
-
- Data.Bytes[0] = UEDATX;
- Data.Bytes[1] = UEDATX;
-
- return Data.Word;
- }
-
- /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \return Next word in the currently selected endpoint's FIFO buffer.
- */
- static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t Endpoint_Read_Word_BE(void)
- {
- union
- {
- uint16_t Word;
- uint8_t Bytes[2];
- } Data;
-
- Data.Bytes[1] = UEDATX;
- Data.Bytes[0] = UEDATX;
-
- return Data.Word;
- }
-
- /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.
- */
- static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Write_Word_LE(const uint16_t Word)
- {
- UEDATX = (Word & 0xFF);
- UEDATX = (Word >> 8);
- }
-
- /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.
- */
- static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Write_Word_BE(const uint16_t Word)
- {
- UEDATX = (Word >> 8);
- UEDATX = (Word & 0xFF);
- }
-
- /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- */
- static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Discard_Word(void)
- {
- uint8_t Dummy;
-
- Dummy = UEDATX;
- Dummy = UEDATX;
- }
-
- /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \return Next double word in the currently selected endpoint's FIFO buffer.
- */
- static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint32_t Endpoint_Read_DWord_LE(void)
- {
- union
- {
- uint32_t DWord;
- uint8_t Bytes[4];
- } Data;
-
- Data.Bytes[0] = UEDATX;
- Data.Bytes[1] = UEDATX;
- Data.Bytes[2] = UEDATX;
- Data.Bytes[3] = UEDATX;
-
- return Data.DWord;
- }
-
- /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \return Next double word in the currently selected endpoint's FIFO buffer.
- */
- static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint32_t Endpoint_Read_DWord_BE(void)
- {
- union
- {
- uint32_t DWord;
- uint8_t Bytes[4];
- } Data;
-
- Data.Bytes[3] = UEDATX;
- Data.Bytes[2] = UEDATX;
- Data.Bytes[1] = UEDATX;
- Data.Bytes[0] = UEDATX;
-
- return Data.DWord;
- }
-
- /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.
- */
- static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)
- {
- UEDATX = (DWord & 0xFF);
- UEDATX = (DWord >> 8);
- UEDATX = (DWord >> 16);
- UEDATX = (DWord >> 24);
- }
-
- /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN
- * direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- *
- * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.
- */
- static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)
- {
- UEDATX = (DWord >> 24);
- UEDATX = (DWord >> 16);
- UEDATX = (DWord >> 8);
- UEDATX = (DWord & 0xFF);
- }
-
- /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.
- *
- * \ingroup Group_EndpointPrimitiveRW_AVR8
- */
- static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Discard_DWord(void)
- {
- uint8_t Dummy;
-
- Dummy = UEDATX;
- Dummy = UEDATX;
- Dummy = UEDATX;
- Dummy = UEDATX;
- }
-
- /* External Variables: */
- /** Global indicating the maximum packet size of the default control endpoint located at address
- * 0 in the device. This value is set to the value indicated in the device descriptor in the user
- * project once the USB interface is initialized into device mode.
- *
- * If space is an issue, it is possible to fix this to a static value by defining the control
- * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile
- * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically
- * read from the descriptors at runtime and instead fixed to the given value. When used, it is
- * important that the descriptor control endpoint size value matches the size given as the
- * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token
- * be used in the device descriptors to ensure this.
- *
- * \note This variable should be treated as read-only in the user application, and never manually
- * changed in value.
- */
- #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
- extern uint8_t USB_ControlEndpointSize;
- #else
- #define USB_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE
- #endif
-
- /* Function Prototypes: */
- /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,
- * with respect to the data direction. This is a convenience function which can be used to
- * simplify user control request handling.
- */
- void Endpoint_ClearStatusStage(void);
-
- /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data
- * to be read or written to it.
- *
- * \note This routine should not be called on CONTROL type endpoints.
- *
- * \ingroup Group_EndpointRW_AVR8
- *
- * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.
- */
- uint8_t Endpoint_WaitUntilReady(void);
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#include "../USBMode.h"
+
+#if defined(USB_CAN_BE_DEVICE)
+
+#include "../Endpoint.h"
+
+#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
+uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
+#endif
+
+bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
+ const uint8_t UECFG0XData,
+ const uint8_t UECFG1XData)
+{
+#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)
+ Endpoint_SelectEndpoint(Number);
+ Endpoint_EnableEndpoint();
+
+ UECFG1X = 0;
+ UECFG0X = UECFG0XData;
+ UECFG1X = UECFG1XData;
+
+ return Endpoint_IsConfigured();
+#else
+ for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
+ {
+ uint8_t UECFG0XTemp;
+ uint8_t UECFG1XTemp;
+ uint8_t UEIENXTemp;
+
+ Endpoint_SelectEndpoint(EPNum);
+
+ if (EPNum == Number)
+ {
+ UECFG0XTemp = UECFG0XData;
+ UECFG1XTemp = UECFG1XData;
+ UEIENXTemp = 0;
+ }
+ else
+ {
+ UECFG0XTemp = UECFG0X;
+ UECFG1XTemp = UECFG1X;
+ UEIENXTemp = UEIENX;
+ }
+
+ if (!(UECFG1XTemp & (1 << ALLOC)))
+ continue;
+
+ Endpoint_DisableEndpoint();
+ UECFG1X &= (1 << ALLOC);
+
+ Endpoint_EnableEndpoint();
+ UECFG0X = UECFG0XTemp;
+ UECFG1X = UECFG1XTemp;
+ UEIENX = UEIENXTemp;
+
+ if (!(Endpoint_IsConfigured()))
+ return false;
+ }
+
+ Endpoint_SelectEndpoint(Number);
+ return true;
+#endif
+}
+
+void Endpoint_ClearEndpoints(void)
+{
+ UEINT = 0;
+
+ for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
+ {
+ Endpoint_SelectEndpoint(EPNum);
+ UEIENX = 0;
+ UEINTX = 0;
+ UECFG1X = 0;
+ Endpoint_DisableEndpoint();
+ }
+}
+
+void Endpoint_ClearStatusStage(void)
+{
+ if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
+ {
+ while (!(Endpoint_IsOUTReceived()))
+ {
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return;
+ }
+
+ Endpoint_ClearOUT();
+ }
+ else
+ {
+ while (!(Endpoint_IsINReady()))
+ {
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return;
+ }
+
+ Endpoint_ClearIN();
+ }
+}
+
+#if !defined(CONTROL_ONLY_DEVICE)
+uint8_t Endpoint_WaitUntilReady(void)
+{
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
+ #else
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
+ #endif
+
+ uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();
+
+ for (;;)
+ {
+ if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)
+ {
+ if (Endpoint_IsINReady())
+ return ENDPOINT_READYWAIT_NoError;
+ }
+ else
+ {
+ if (Endpoint_IsOUTReceived())
+ return ENDPOINT_READYWAIT_NoError;
+ }
+
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;
+
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
+ return ENDPOINT_READYWAIT_DeviceDisconnected;
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
+ return ENDPOINT_READYWAIT_BusSuspended;
+ else if (Endpoint_IsStalled())
+ return ENDPOINT_READYWAIT_EndpointStalled;
+
+ uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();
+
+ if (CurrentFrameNumber != PreviousFrameNumber)
+ {
+ PreviousFrameNumber = CurrentFrameNumber;
+
+ if (!(TimeoutMSRem--))
+ return ENDPOINT_READYWAIT_Timeout;
+ }
+ }
+}
+#endif
+
+#endif
+
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB Endpoint definitions for the AVR8 microcontrollers.
+ * \copydetails Group_EndpointManagement_AVR8
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_EndpointRW
+ * \defgroup Group_EndpointRW_AVR8 Endpoint Data Reading and Writing (AVR8)
+ * \brief Endpoint data read/write definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.
+ */
+
+/** \ingroup Group_EndpointPrimitiveRW
+ * \defgroup Group_EndpointPrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8)
+ * \brief Endpoint primative read/write definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types
+ * from and to endpoints.
+ */
+
+/** \ingroup Group_EndpointPacketManagement
+ * \defgroup Group_EndpointPacketManagement_AVR8 Endpoint Packet Management (AVR8)
+ * \brief Endpoint packet management definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros, variables, enums and types related to packet management of endpoints.
+ */
+
+/** \ingroup Group_EndpointManagement
+ * \defgroup Group_EndpointManagement_AVR8 Endpoint Management (AVR8)
+ * \brief Endpoint management definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros and enums related to endpoint management when in USB Device mode. This
+ * module contains the endpoint management macros, as well as endpoint interrupt and data
+ * send/receive functions for various data types.
+ *
+ * @{
+ */
+
+#ifndef __ENDPOINT_AVR8_H__
+#define __ENDPOINT_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+ #include "../USBTask.h"
+ #include "../USBInterrupt.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex)
+ #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails)
+ #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize)
+
+ #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex)
+ #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)
+ #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)
+
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ #define ENDPOINT_DETAILS_MAXEP 7
+
+ #define ENDPOINT_DETAILS_EP0 64, 2
+ #define ENDPOINT_DETAILS_EP1 256, 2
+ #define ENDPOINT_DETAILS_EP2 64, 2
+ #define ENDPOINT_DETAILS_EP3 64, 2
+ #define ENDPOINT_DETAILS_EP4 64, 2
+ #define ENDPOINT_DETAILS_EP5 64, 2
+ #define ENDPOINT_DETAILS_EP6 64, 2
+ #else
+ #define ENDPOINT_DETAILS_MAXEP 5
+
+ #define ENDPOINT_DETAILS_EP0 64, 2
+ #define ENDPOINT_DETAILS_EP1 64, 1
+ #define ENDPOINT_DETAILS_EP2 64, 1
+ #define ENDPOINT_DETAILS_EP3 64, 2
+ #define ENDPOINT_DETAILS_EP4 64, 2
+ #endif
+
+ /* Inline Functions: */
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
+ ATTR_ALWAYS_INLINE;
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
+ {
+ uint8_t MaskVal = 0;
+ uint16_t CheckBytes = 8;
+
+ while (CheckBytes < Bytes)
+ {
+ MaskVal++;
+ CheckBytes <<= 1;
+ }
+
+ return (MaskVal << EPSIZE0);
+ }
+
+ /* Function Prototypes: */
+ void Endpoint_ClearEndpoints(void);
+ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
+ const uint8_t UECFG0XData,
+ const uint8_t UECFG1XData);
+
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** \name Endpoint Direction Masks */
+ //@{
+ /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
+ * should be initialized in the OUT direction - i.e. data flows from host to device.
+ */
+ #define ENDPOINT_DIR_OUT (0 << EPDIR)
+
+ /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
+ * should be initialized in the IN direction - i.e. data flows from device to host.
+ */
+ #define ENDPOINT_DIR_IN (1 << EPDIR)
+ //@}
+
+ /** \name Endpoint Bank Mode Masks */
+ //@{
+ /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
+ * that the endpoint should have one single bank, which requires less USB FIFO memory but results
+ * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's
+ * bank at the one time.
+ */
+ #define ENDPOINT_BANK_SINGLE (0 << EPBK0)
+
+ /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
+ * that the endpoint should have two banks, which requires more USB FIFO memory but results
+ * in faster transfers as one USB device (the AVR or the host) can access one bank while the other
+ * accesses the second bank.
+ */
+ #define ENDPOINT_BANK_DOUBLE (1 << EPBK0)
+ //@}
+
+ /** Endpoint address for the default control endpoint, which always resides in address 0. This is
+ * defined for convenience to give more readable code when used with the endpoint macros.
+ */
+ #define ENDPOINT_CONTROLEP 0
+
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
+ /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size
+ * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.
+ */
+ #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8
+ #endif
+
+ /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
+ * numerical address in the device.
+ */
+ #define ENDPOINT_EPNUM_MASK 0x07
+
+ /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
+ * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
+ */
+ #define ENDPOINT_EPDIR_MASK 0x80
+
+ /** Retrives the maximum bank size in bytes of a given endpoint.
+ *
+ * \note This macro will only work correctly on endpoint indexes that are compile-time constants
+ * defined by the preprocessor.
+ *
+ * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)
+ */
+ #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex)
+
+ /** Retrieves the total number of banks supported by the given endpoint.
+ *
+ * \note This macro will only work correctly on endpoint indexes that are compile-time constants
+ * defined by the preprocessor.
+ *
+ * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)
+ */
+ #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex)
+
+ #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__)
+ /** Total number of endpoints (including the default control endpoint at address 0) which may
+ * be used in the device. Different USB AVR models support different amounts of endpoints,
+ * this value reflects the maximum number of endpoints for the currently selected AVR model.
+ */
+ #define ENDPOINT_TOTAL_ENDPOINTS ENDPOINT_DETAILS_MAXEP
+ #else
+ #define ENDPOINT_TOTAL_ENDPOINTS 1
+ #endif
+
+ /* Enums: */
+ /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.
+ *
+ * \ingroup Group_EndpointRW_AVR8
+ */
+ enum Endpoint_WaitUntilReady_ErrorCodes_t
+ {
+ ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */
+ ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream
+ * transfer by the host or device.
+ */
+ ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while
+ * waiting for the endpoint to become ready.
+ */
+ ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and
+ * no USB endpoint traffic can occur until the bus
+ * has resumed.
+ */
+ ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet
+ * within the software timeout period set by the
+ * \ref USB_STREAM_TIMEOUT_MS macro.
+ */
+ };
+
+ /* Inline Functions: */
+ /** Configures the specified endpoint number with the given endpoint type, direction, bank size
+ * and banking mode. Once configured, the endpoint may be read from or written to, depending
+ * on its direction.
+ *
+ * \param[in] Number Endpoint number to configure. This must be more than 0 and less than
+ * \ref ENDPOINT_TOTAL_ENDPOINTS.
+ *
+ * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types
+ * are available on Low Speed USB devices - refer to the USB 2.0 specification.
+ *
+ * \param[in] Direction Endpoint data direction, either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN.
+ * All endpoints (except Control type) are unidirectional - data may only be read
+ * from or written to the endpoint bank based on its direction, not both.
+ *
+ * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted
+ * to the USB host, or after they have been received from the USB host (depending on
+ * the endpoint's data direction). The bank size must indicate the maximum packet size
+ * that the endpoint can handle.
+ *
+ * \param[in] Banks Number of banks to use for the endpoint being configured, an \c ENDPOINT_BANK_* mask.
+ * More banks uses more USB DPRAM, but offers better performance. Isochronous type
+ * endpoints <b>must</b> have at least two banks.
+ *
+ * \note When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints <b>must</b> be configured in
+ * ascending order, or bank corruption will occur.
+ * \n\n
+ *
+ * \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's
+ * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.
+ * \n\n
+ *
+ * \note The default control endpoint should not be manually configured by the user application, as
+ * it is automatically configured by the library internally.
+ * \n\n
+ *
+ * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint
+ * which failed to reconfigure correctly will be selected.
+ *
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.
+ */
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,
+ const uint8_t Type,
+ const uint8_t Direction,
+ const uint16_t Size,
+ const uint8_t Banks) ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,
+ const uint8_t Type,
+ const uint8_t Direction,
+ const uint16_t Size,
+ const uint8_t Banks)
+ {
+ return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << EPTYPE0) | Direction),
+ ((1 << ALLOC) | Banks | Endpoint_BytesToEPSizeMask(Size)));
+ }
+
+ /** Indicates the number of bytes currently stored in the current endpoint's selected bank.
+ *
+ * \note The return width of this function may differ, depending on the maximum endpoint bank size
+ * of the selected AVR model.
+ *
+ * \ingroup Group_EndpointRW_AVR8
+ *
+ * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.
+ */
+ static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t Endpoint_BytesInEndpoint(void)
+ {
+ #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ return UEBCX;
+ #elif defined(USB_SERIES_4_AVR)
+ return (((uint16_t)UEBCHX << 8) | UEBCLX);
+ #elif defined(USB_SERIES_2_AVR)
+ return UEBCLX;
+ #endif
+ }
+
+ /** Get the endpoint address of the currently selected endpoint. This is typically used to save
+ * the currently selected endpoint number so that it can be restored after another endpoint has
+ * been manipulated.
+ *
+ * \return Index of the currently selected endpoint.
+ */
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void)
+ {
+ #if !defined(CONTROL_ONLY_DEVICE)
+ return (UENUM & ENDPOINT_EPNUM_MASK);
+ #else
+ return ENDPOINT_CONTROLEP;
+ #endif
+ }
+
+ /** Selects the given endpoint number. If the address from the device descriptors is used, the
+ * value should be masked with the \ref ENDPOINT_EPNUM_MASK constant to extract only the endpoint
+ * number (and discarding the endpoint direction bit).
+ *
+ * Any endpoint operations which do not require the endpoint number to be indicated will operate on
+ * the currently selected endpoint.
+ *
+ * \param[in] EndpointNumber Endpoint number to select.
+ */
+ static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber)
+ {
+ #if !defined(CONTROL_ONLY_DEVICE)
+ UENUM = EndpointNumber;
+ #endif
+ }
+
+ /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's
+ * data In and Out pointers to the bank's contents.
+ *
+ * \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset.
+ */
+ static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)
+ {
+ UERST = (1 << EndpointNumber);
+ UERST = 0;
+ }
+
+ /** Enables the currently selected endpoint so that data can be sent and received through it to
+ * and from a host.
+ *
+ * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint().
+ */
+ static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_EnableEndpoint(void)
+ {
+ UECONX |= (1 << EPEN);
+ }
+
+ /** Disables the currently selected endpoint so that data cannot be sent and received through it
+ * to and from a host.
+ */
+ static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_DisableEndpoint(void)
+ {
+ UECONX &= ~(1 << EPEN);
+ }
+
+ /** Determines if the currently selected endpoint is enabled, but not necessarily configured.
+ *
+ * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.
+ */
+ static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsEnabled(void)
+ {
+ return ((UECONX & (1 << EPEN)) ? true : false);
+ }
+
+ /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for
+ * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the
+ * \ref Endpoint_ClearOUT() command.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \return Total number of busy banks in the selected endpoint.
+ */
+ static inline uint8_t Endpoint_GetBusyBanks(void)
+ {
+ return (UESTA0X & (0x03 << NBUSYBK0));
+ }
+
+ /** Aborts all pending IN transactions on the currently selected endpoint, once the bank
+ * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function
+ * will terminate all queued transactions, resetting the endpoint banks ready for a new
+ * packet.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ */
+ static inline void Endpoint_AbortPendingIN(void)
+ {
+ while (Endpoint_GetBusyBanks() != 0)
+ {
+ UEINTX |= (1 << RXOUTI);
+ while (UEINTX & (1 << RXOUTI));
+ }
+ }
+
+ /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint
+ * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN
+ * direction). This function will return false if an error has occurred in the endpoint, if the endpoint
+ * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN
+ * direction and the endpoint bank is full.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending
+ * on its direction.
+ */
+ static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsReadWriteAllowed(void)
+ {
+ return ((UEINTX & (1 << RWAL)) ? true : false);
+ }
+
+ /** Determines if the currently selected endpoint is configured.
+ *
+ * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.
+ */
+ static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsConfigured(void)
+ {
+ return ((UESTA0X & (1 << CFGOK)) ? true : false);
+ }
+
+ /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their
+ * interrupt duration has elapsed. Which endpoints have interrupted can be determined by
+ * masking the return value against <tt>(1 << <i>{Endpoint Number}</i>)</tt>.
+ *
+ * \return Mask whose bits indicate which endpoints have interrupted.
+ */
+ static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Endpoint_GetEndpointInterrupts(void)
+ {
+ return UEINT;
+ }
+
+ /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type
+ * endpoints).
+ *
+ * \param[in] EndpointNumber Index of the endpoint whose interrupt flag should be tested.
+ *
+ * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise.
+ */
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber)
+ {
+ return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false);
+ }
+
+ /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.
+ */
+ static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsINReady(void)
+ {
+ return ((UEINTX & (1 << TXINI)) ? true : false);
+ }
+
+ /** Determines if the selected OUT endpoint has received new packet from the host.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.
+ */
+ static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsOUTReceived(void)
+ {
+ return ((UEINTX & (1 << RXOUTI)) ? true : false);
+ }
+
+ /** Determines if the current CONTROL type endpoint has received a SETUP packet.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.
+ */
+ static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsSETUPReceived(void)
+ {
+ return ((UEINTX & (1 << RXSTPI)) ? true : false);
+ }
+
+ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the
+ * endpoint for the next packet.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \note This is not applicable for non CONTROL type endpoints.
+ */
+ static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_ClearSETUP(void)
+ {
+ UEINTX &= ~(1 << RXSTPI);
+ }
+
+ /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the
+ * next packet and switching to the alternative endpoint bank if double banked.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ */
+ static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_ClearIN(void)
+ {
+ #if !defined(CONTROL_ONLY_DEVICE)
+ UEINTX &= ~((1 << TXINI) | (1 << FIFOCON));
+ #else
+ UEINTX &= ~(1 << TXINI);
+ #endif
+ }
+
+ /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint
+ * for the next packet and switching to the alternative endpoint bank if double banked.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ */
+ static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_ClearOUT(void)
+ {
+ #if !defined(CONTROL_ONLY_DEVICE)
+ UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON));
+ #else
+ UEINTX &= ~(1 << RXOUTI);
+ #endif
+ }
+
+ /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the
+ * indicated endpoint and that the current transfer sequence should be aborted. This provides a
+ * way for devices to indicate invalid commands to the host so that the current transfer can be
+ * aborted and the host can begin its own recovery sequence.
+ *
+ * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro
+ * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected
+ * endpoint.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ */
+ static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_StallTransaction(void)
+ {
+ UECONX |= (1 << STALLRQ);
+ }
+
+ /** Clears the STALL condition on the currently selected endpoint.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ */
+ static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_ClearStall(void)
+ {
+ UECONX |= (1 << STALLRQC);
+ }
+
+ /** Determines if the currently selected endpoint is stalled, false otherwise.
+ *
+ * \ingroup Group_EndpointPacketManagement_AVR8
+ *
+ * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.
+ */
+ static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Endpoint_IsStalled(void)
+ {
+ return ((UECONX & (1 << STALLRQ)) ? true : false);
+ }
+
+ /** Resets the data toggle of the currently selected endpoint. */
+ static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_ResetDataToggle(void)
+ {
+ UECONX |= (1 << RSTDT);
+ }
+
+ /** Determines the currently selected endpoint's direction.
+ *
+ * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.
+ */
+ static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Endpoint_GetEndpointDirection(void)
+ {
+ return (UECFG0X & ENDPOINT_DIR_IN);
+ }
+
+ /** Sets the direction of the currently selected endpoint.
+ *
+ * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask.
+ */
+ static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask)
+ {
+ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | DirectionMask);
+ }
+
+ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \return Next byte in the currently selected endpoint's FIFO buffer.
+ */
+ static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Endpoint_Read_Byte(void)
+ {
+ return UEDATX;
+ }
+
+ /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \param[in] Byte Next byte to write into the the currently selected endpoint's FIFO buffer.
+ */
+ static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Write_Byte(const uint8_t Byte)
+ {
+ UEDATX = Byte;
+ }
+
+ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ */
+ static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Discard_Byte(void)
+ {
+ uint8_t Dummy;
+
+ Dummy = UEDATX;
+ }
+
+ /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \return Next word in the currently selected endpoint's FIFO buffer.
+ */
+ static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t Endpoint_Read_Word_LE(void)
+ {
+ union
+ {
+ uint16_t Word;
+ uint8_t Bytes[2];
+ } Data;
+
+ Data.Bytes[0] = UEDATX;
+ Data.Bytes[1] = UEDATX;
+
+ return Data.Word;
+ }
+
+ /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \return Next word in the currently selected endpoint's FIFO buffer.
+ */
+ static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t Endpoint_Read_Word_BE(void)
+ {
+ union
+ {
+ uint16_t Word;
+ uint8_t Bytes[2];
+ } Data;
+
+ Data.Bytes[1] = UEDATX;
+ Data.Bytes[0] = UEDATX;
+
+ return Data.Word;
+ }
+
+ /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.
+ */
+ static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Write_Word_LE(const uint16_t Word)
+ {
+ UEDATX = (Word & 0xFF);
+ UEDATX = (Word >> 8);
+ }
+
+ /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.
+ */
+ static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Write_Word_BE(const uint16_t Word)
+ {
+ UEDATX = (Word >> 8);
+ UEDATX = (Word & 0xFF);
+ }
+
+ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ */
+ static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Discard_Word(void)
+ {
+ uint8_t Dummy;
+
+ Dummy = UEDATX;
+ Dummy = UEDATX;
+ }
+
+ /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \return Next double word in the currently selected endpoint's FIFO buffer.
+ */
+ static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint32_t Endpoint_Read_DWord_LE(void)
+ {
+ union
+ {
+ uint32_t DWord;
+ uint8_t Bytes[4];
+ } Data;
+
+ Data.Bytes[0] = UEDATX;
+ Data.Bytes[1] = UEDATX;
+ Data.Bytes[2] = UEDATX;
+ Data.Bytes[3] = UEDATX;
+
+ return Data.DWord;
+ }
+
+ /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \return Next double word in the currently selected endpoint's FIFO buffer.
+ */
+ static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint32_t Endpoint_Read_DWord_BE(void)
+ {
+ union
+ {
+ uint32_t DWord;
+ uint8_t Bytes[4];
+ } Data;
+
+ Data.Bytes[3] = UEDATX;
+ Data.Bytes[2] = UEDATX;
+ Data.Bytes[1] = UEDATX;
+ Data.Bytes[0] = UEDATX;
+
+ return Data.DWord;
+ }
+
+ /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.
+ */
+ static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)
+ {
+ UEDATX = (DWord & 0xFF);
+ UEDATX = (DWord >> 8);
+ UEDATX = (DWord >> 16);
+ UEDATX = (DWord >> 24);
+ }
+
+ /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN
+ * direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ *
+ * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.
+ */
+ static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)
+ {
+ UEDATX = (DWord >> 24);
+ UEDATX = (DWord >> 16);
+ UEDATX = (DWord >> 8);
+ UEDATX = (DWord & 0xFF);
+ }
+
+ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.
+ *
+ * \ingroup Group_EndpointPrimitiveRW_AVR8
+ */
+ static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE;
+ static inline void Endpoint_Discard_DWord(void)
+ {
+ uint8_t Dummy;
+
+ Dummy = UEDATX;
+ Dummy = UEDATX;
+ Dummy = UEDATX;
+ Dummy = UEDATX;
+ }
+
+ /* External Variables: */
+ /** Global indicating the maximum packet size of the default control endpoint located at address
+ * 0 in the device. This value is set to the value indicated in the device descriptor in the user
+ * project once the USB interface is initialized into device mode.
+ *
+ * If space is an issue, it is possible to fix this to a static value by defining the control
+ * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile
+ * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically
+ * read from the descriptors at runtime and instead fixed to the given value. When used, it is
+ * important that the descriptor control endpoint size value matches the size given as the
+ * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token
+ * be used in the device descriptors to ensure this.
+ *
+ * \note This variable should be treated as read-only in the user application, and never manually
+ * changed in value.
+ */
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
+ extern uint8_t USB_ControlEndpointSize;
+ #else
+ #define USB_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE
+ #endif
+
+ /* Function Prototypes: */
+ /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,
+ * with respect to the data direction. This is a convenience function which can be used to
+ * simplify user control request handling.
+ */
+ void Endpoint_ClearStatusStage(void);
+
+ /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data
+ * to be read or written to it.
+ *
+ * \note This routine should not be called on CONTROL type endpoints.
+ *
+ * \ingroup Group_EndpointRW_AVR8
+ *
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.
+ */
+ uint8_t Endpoint_WaitUntilReady(void);
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#include "../USBMode.h"
-
-#if defined(USB_CAN_BE_HOST)
-
-#define __INCLUDE_FROM_HOST_C
-#include "Host.h"
-
-void USB_Host_ProcessNextHostState(void)
-{
- uint8_t ErrorCode = HOST_ENUMERROR_NoError;
- uint8_t SubErrorCode = HOST_ENUMERROR_NoError;
-
- static uint16_t WaitMSRemaining;
- static uint8_t PostWaitState;
-
- switch (USB_HostState)
- {
- case HOST_STATE_WaitForDevice:
- if (WaitMSRemaining)
- {
- if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
- {
- USB_HostState = PostWaitState;
- ErrorCode = HOST_ENUMERROR_WaitStage;
- break;
- }
-
- if (!(--WaitMSRemaining))
- USB_HostState = PostWaitState;
- }
-
- break;
- case HOST_STATE_Powered:
- WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;
-
- USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;
- break;
- case HOST_STATE_Powered_WaitForDeviceSettle:
- if (WaitMSRemaining--)
- {
- _delay_ms(1);
- break;
- }
- else
- {
- USB_Host_VBUS_Manual_Off();
-
- USB_OTGPAD_On();
- USB_Host_VBUS_Auto_Enable();
- USB_Host_VBUS_Auto_On();
-
- USB_HostState = HOST_STATE_Powered_WaitForConnect;
- }
-
- break;
- case HOST_STATE_Powered_WaitForConnect:
- if (USB_INT_HasOccurred(USB_INT_DCONNI))
- {
- USB_INT_Clear(USB_INT_DCONNI);
- USB_INT_Clear(USB_INT_DDISCI);
-
- USB_INT_Clear(USB_INT_VBERRI);
- USB_INT_Enable(USB_INT_VBERRI);
-
- USB_Host_ResumeBus();
- Pipe_ClearPipes();
-
- HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);
- }
-
- break;
- case HOST_STATE_Powered_DoReset:
- USB_Host_ResetDevice();
-
- HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);
- break;
- case HOST_STATE_Powered_ConfigPipe:
- Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
- PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
- PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE);
-
- if (!(Pipe_IsConfigured()))
- {
- ErrorCode = HOST_ENUMERROR_PipeConfigError;
- SubErrorCode = 0;
- break;
- }
-
- USB_HostState = HOST_STATE_Default;
- break;
- case HOST_STATE_Default:
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_GetDescriptor,
- .wValue = (DTYPE_Device << 8),
- .wIndex = 0,
- .wLength = 8,
- };
-
- uint8_t DataBuffer[8];
-
- if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)
- {
- ErrorCode = HOST_ENUMERROR_ControlError;
- break;
- }
-
- USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
-
- USB_Host_ResetDevice();
-
- HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);
- break;
- case HOST_STATE_Default_PostReset:
- Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
- PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
- USB_ControlPipeSize, PIPE_BANK_SINGLE);
-
- if (!(Pipe_IsConfigured()))
- {
- ErrorCode = HOST_ENUMERROR_PipeConfigError;
- SubErrorCode = 0;
- break;
- }
-
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_SetAddress,
- .wValue = USB_HOST_DEVICEADDRESS,
- .wIndex = 0,
- .wLength = 0,
- };
-
- if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
- {
- ErrorCode = HOST_ENUMERROR_ControlError;
- break;
- }
-
- HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);
- break;
- case HOST_STATE_Default_PostAddressSet:
- USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
-
- EVENT_USB_Host_DeviceEnumerationComplete();
- USB_HostState = HOST_STATE_Addressed;
- break;
- }
-
- if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
- {
- EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
-
- USB_Host_VBUS_Auto_Off();
-
- EVENT_USB_Host_DeviceUnattached();
-
- USB_ResetInterface();
- }
-}
-
-uint8_t USB_Host_WaitMS(uint8_t MS)
-{
- bool BusSuspended = USB_Host_IsBusSuspended();
- uint8_t ErrorCode = HOST_WAITERROR_Successful;
- bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
-
- USB_INT_Disable(USB_INT_HSOFI);
- USB_INT_Clear(USB_INT_HSOFI);
-
- USB_Host_ResumeBus();
-
- while (MS)
- {
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
- {
- USB_INT_Clear(USB_INT_HSOFI);
- MS--;
- }
-
- if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))
- {
- ErrorCode = HOST_WAITERROR_DeviceDisconnect;
-
- break;
- }
-
- if (Pipe_IsError() == true)
- {
- Pipe_ClearError();
- ErrorCode = HOST_WAITERROR_PipeError;
-
- break;
- }
-
- if (Pipe_IsStalled() == true)
- {
- Pipe_ClearStall();
- ErrorCode = HOST_WAITERROR_SetupStalled;
-
- break;
- }
- }
-
- if (BusSuspended)
- USB_Host_SuspendBus();
-
- if (HSOFIEnabled)
- USB_INT_Enable(USB_INT_HSOFI);
-
- return ErrorCode;
-}
-
-static void USB_Host_ResetDevice(void)
-{
- bool BusSuspended = USB_Host_IsBusSuspended();
-
- USB_INT_Disable(USB_INT_DDISCI);
-
- USB_Host_ResetBus();
- while (!(USB_Host_IsBusResetComplete()));
- USB_Host_ResumeBus();
-
- bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
-
- USB_INT_Disable(USB_INT_HSOFI);
- USB_INT_Clear(USB_INT_HSOFI);
-
- for (uint8_t MSRem = 10; MSRem != 0; MSRem--)
- {
- /* Workaround for powerless-pull-up devices. After a USB bus reset,
- all disconnection interrupts are suppressed while a USB frame is
- looked for - if it is found within 10ms, the device is still
- present. */
-
- if (USB_INT_HasOccurred(USB_INT_HSOFI))
- {
- USB_INT_Clear(USB_INT_HSOFI);
- USB_INT_Clear(USB_INT_DDISCI);
- break;
- }
-
- _delay_ms(1);
- }
-
- if (HSOFIEnabled)
- USB_INT_Enable(USB_INT_HSOFI);
-
- if (BusSuspended)
- USB_Host_SuspendBus();
-
- USB_INT_Enable(USB_INT_DDISCI);
-}
-
-uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_SetConfiguration,
- .wValue = ConfigNumber,
- .wIndex = 0,
- .wLength = 0,
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(NULL);
-}
-
-uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_GetDescriptor,
- .wValue = (DTYPE_Device << 8),
- .wIndex = 0,
- .wLength = sizeof(USB_Descriptor_Device_t),
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(DeviceDescriptorPtr);
-}
-
-uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
- void* const Buffer,
- const uint8_t BufferLength)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- .bRequest = REQ_GetDescriptor,
- .wValue = (DTYPE_String << 8) | Index,
- .wIndex = 0,
- .wLength = BufferLength,
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(Buffer);
-}
-
-uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)
-{
- USB_ControlRequest = (USB_Request_Header_t)
- {
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),
- .bRequest = REQ_ClearFeature,
- .wValue = FEATURE_SEL_EndpointHalt,
- .wIndex = EndpointNum,
- .wLength = 0,
- };
-
- Pipe_SelectPipe(PIPE_CONTROLPIPE);
-
- return USB_Host_SendControlRequest(NULL);
-}
-
-#endif
-
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB Host definitions for the AVR8 microcontrollers.
- * \copydetails Group_Host_AVR8
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_Host
- * \defgroup Group_Host_AVR8 Host Management (AVR8)
- * \brief USB Host definitions for the AVR8 microcontrollers.
- *
- * Architecture specific USB Host definitions for the Atmel 8-bit AVR microcontrollers.
- *
- * @{
- */
-
-#ifndef __USBHOST_AVR8_H__
-#define __USBHOST_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
- #include "../StdDescriptors.h"
- #include "../Pipe.h"
- #include "../USBInterrupt.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Indicates the fixed USB device address which any attached device is enumerated to when in
- * host mode. As only one USB device may be attached to the AVR in host mode at any one time
- * and that the address used is not important (other than the fact that it is non-zero), a
- * fixed value is specified by the library.
- */
- #define USB_HOST_DEVICEADDRESS 1
-
- #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)
- /** Constant for the maximum software timeout period of sent USB control transactions to an attached
- * device. If a device fails to respond to a sent control request within this period, the
- * library will return a timeout error code.
- *
- * This value may be overridden in the user project makefile as the value of the
- * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.
- */
- #define USB_HOST_TIMEOUT_MS 1000
- #endif
-
- #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)
- /** Constant for the delay in milliseconds after a device is connected before the library
- * will start the enumeration process. Some devices require a delay of up to 5 seconds
- * after connection before the enumeration process can start or incorrect operation will
- * occur.
- *
- * The default delay value may be overridden in the user project makefile by defining the
- * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the
- * compiler using the -D switch.
- */
- #define HOST_DEVICE_SETTLE_DELAY_MS 1000
- #endif
-
- /* Enums: */
- /** Enum for the various states of the USB Host state machine. Only some states are
- * implemented in the LUFA library - other states are left to the user to implement.
- *
- * For information on each possible USB host state, refer to the USB 2.0 specification.
- * Several of the USB host states are broken up further into multiple smaller sub-states,
- * so that they can be internally implemented inside the library in an efficient manner.
- *
- * \see \ref USB_HostState, which stores the current host state machine state.
- */
- enum USB_Host_States_t
- {
- HOST_STATE_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be
- * used by the library to wait until the attached device is
- * removed by the user - useful for when an error occurs or
- * further communication with the device is not needed. This
- * allows for other code to run while the state machine is
- * effectively disabled.
- */
- HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates
- * that the stack is waiting for an interval to elapse before
- * continuing with the next step of the device enumeration
- * process.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates
- * that the host state machine is waiting for a device to be
- * attached so that it can start the enumeration process.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates
- * that a device has been attached, and the library's internals
- * are being configured to begin the enumeration process.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates
- * that the stack is waiting for the initial settling period to
- * elapse before beginning the enumeration process.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. This state indicates
- * that the stack is waiting for a connection event from the USB
- * controller to indicate a valid USB device has been attached to
- * the bus and is ready to be enumerated.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates
- * that a valid USB device has been attached, and that it is
- * will now be reset to ensure it is ready for enumeration.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates
- * that the attached device is currently powered and reset, and
- * that the control pipe is now being configured by the stack.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Default = 8, /**< Internally implemented by the library. This state indicates
- * that the stack is currently retrieving the control endpoint's
- * size from the device, so that the control pipe can be altered
- * to match.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. This state indicates that
- * the control pipe is being reconfigured to match the retrieved
- * control endpoint size from the device, and the device's USB bus
- * address is being set.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. This state indicates that
- * the device's address has now been set, and the stack is has now
- * completed the device enumeration process. This state causes the
- * stack to change the current USB device address to that set for
- * the connected device, before progressing to the user-implemented
- * \ref HOST_STATE_Addressed state for further communications.
- *
- * \note Do not manually change to this state in the user code.
- */
- HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should
- * set the device configuration before progressing to the
- * \ref HOST_STATE_Configured state. Other processing (such as the
- * retrieval and processing of the device descriptor) should also
- * be placed in this state.
- */
- HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the
- * actual work performed on the attached device and changed to the
- * \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.
- */
- HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained
- * while the bus is suspended, and changed to either the \ref HOST_STATE_Configured
- * (after resuming the bus with the USB_Host_ResumeBus() macro) or the
- * \ref HOST_STATE_WaitForDeviceRemoval states as needed.
- */
- };
-
- /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
- *
- * \see \ref Group_Events for more information on this event.
- */
- enum USB_Host_ErrorCodes_t
- {
- HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This
- * error may be the result of an attached device drawing
- * too much current from the VBUS line, or due to the
- * AVR's power source being unable to supply sufficient
- * current.
- */
- };
-
- /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.
- *
- * \see \ref Group_Events for more information on this event.
- */
- enum USB_Host_EnumerationErrorCodes_t
- {
- HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
- * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()
- * event.
- */
- HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed
- * to complete successfully, due to a timeout or other
- * error.
- */
- HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines
- * indicating the attachment of a device.
- */
- HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to
- * complete successfully.
- */
- HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to
- * configure correctly.
- */
- };
-
- /* Inline Functions: */
- /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)
- * the frame number is incremented by one.
- */
- static inline uint16_t USB_Host_GetFrameNumber(void)
- {
- return UHFNUM;
- }
-
- #if !defined(NO_SOF_EVENTS)
- /** Enables the host mode Start Of Frame events. When enabled, this causes the
- * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
- * at the start of each USB frame when a device is enumerated while in host mode.
- *
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
- */
- static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_EnableSOFEvents(void)
- {
- USB_INT_Enable(USB_INT_HSOFI);
- }
-
- /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the
- * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.
- *
- * \note Not available when the NO_SOF_EVENTS compile time token is defined.
- */
- static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_DisableSOFEvents(void)
- {
- USB_INT_Disable(USB_INT_HSOFI);
- }
- #endif
-
- /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.
- * USB bus resets leave the default control pipe configured (if already configured).
- *
- * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be
- * woken up automatically and the bus resumed after the reset has been correctly issued.
- */
- static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_ResetBus(void)
- {
- UHCON |= (1 << RESET);
- }
-
- /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has
- * completed.
- *
- * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.
- */
- static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_Host_IsBusResetComplete(void)
- {
- return ((UHCON & (1 << RESET)) ? false : true);
- }
-
- /** Resumes USB communications with an attached and enumerated device, by resuming the transmission
- * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the
- * host and attached device may occur.
- */
- static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_ResumeBus(void)
- {
- UHCON |= (1 << SOFEN);
- }
-
- /** Suspends the USB bus, preventing any communications from occurring between the host and attached
- * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame
- * messages to the device.
- */
- static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_SuspendBus(void)
- {
- UHCON &= ~(1 << SOFEN);
- }
-
- /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,
- * false otherwise. While suspended, no USB communications can occur until the bus is resumed,
- * except for the Remote Wakeup event from the device if supported.
- *
- * \return Boolean \c true if the bus is currently suspended, \c false otherwise.
- */
- static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_Host_IsBusSuspended(void)
- {
- return ((UHCON & (1 << SOFEN)) ? false : true);
- }
-
- /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
- * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).
- *
- * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.
- */
- static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_Host_IsDeviceFullSpeed(void)
- {
- return ((USBSTA & (1 << SPEED)) ? true : false);
- }
-
- /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
- * that the host resume the USB bus and wake up the device, false otherwise.
- *
- * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.
- */
- static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_Host_IsRemoteWakeupSent(void)
- {
- return ((UHINT & (1 << RXRSMI)) ? true : false);
- }
-
- /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
- static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_ClearRemoteWakeupSent(void)
- {
- UHINT &= ~(1 << RXRSMI);
- }
-
- /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
- * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to
- * be resumed.
- */
- static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_ResumeFromWakeupRequest(void)
- {
- UHCON |= (1 << RESUME);
- }
-
- /** Determines if a resume from Remote Wakeup request is currently being sent to an attached
- * device.
- *
- * \return Boolean \c true if no resume request is currently being sent, \c false otherwise.
- */
- static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
- {
- return ((UHCON & (1 << RESUME)) ? false : true);
- }
-
- /* Function Prototypes: */
- /** Convenience function. This routine sends a SET CONFIGURATION standard request to the attached
- * device, with the given configuration index. This can be used to easily set the device
- * configuration without creating and sending the request manually.
- *
- * \note After this routine returns, the control pipe will be selected.
- *
- * \param[in] ConfigNumber Configuration index to send to the device.
- *
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
- */
- uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);
-
- /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached
- * device, requesting the device descriptor. This can be used to easily retrieve information
- * about the device such as its VID, PID and power requirements.
- *
- * \note After this routine returns, the control pipe will be selected.
- *
- * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where
- * the read data is to be stored.
- *
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
- */
- uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);
-
- /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached
- * device, requesting the string descriptor of the specified index. This can be used to easily
- * retrieve string descriptors from the device by index, after the index is obtained from the
- * Device or Configuration descriptors.
- *
- * \note After this routine returns, the control pipe will be selected.
- *
- * \param[in] Index Index of the string index to retrieve.
- * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is
- * to be stored.
- * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.
- *
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
- */
- uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
- void* const Buffer,
- const uint8_t BufferLength);
-
- /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device.
- *
- * \note After this routine returns, the control pipe will be selected.
- *
- * \param[in] EndpointIndex Index of the endpoint to clear, including the endpoint's direction.
- *
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
- */
- uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex);
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_HostMode_On(void)
- {
- USBCON |= (1 << HOST);
- }
-
- static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_HostMode_Off(void)
- {
- USBCON &= ~(1 << HOST);
- }
-
- static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_VBUS_Auto_Enable(void)
- {
- OTGCON &= ~(1 << VBUSHWC);
- UHWCON |= (1 << UVCONE);
- }
-
- static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_VBUS_Manual_Enable(void)
- {
- OTGCON |= (1 << VBUSHWC);
- UHWCON &= ~(1 << UVCONE);
-
- DDRE |= (1 << 7);
- }
-
- static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_VBUS_Auto_On(void)
- {
- OTGCON |= (1 << VBUSREQ);
- }
-
- static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_VBUS_Manual_On(void)
- {
- PORTE |= (1 << 7);
- }
-
- static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_VBUS_Auto_Off(void)
- {
- OTGCON |= (1 << VBUSRQC);
- }
-
- static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_VBUS_Manual_Off(void)
- {
- PORTE &= ~(1 << 7);
- }
-
- static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
- static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
- {
- UHADDR = (Address & 0x7F);
- }
-
- /* Enums: */
- enum USB_Host_WaitMSErrorCodes_t
- {
- HOST_WAITERROR_Successful = 0,
- HOST_WAITERROR_DeviceDisconnect = 1,
- HOST_WAITERROR_PipeError = 2,
- HOST_WAITERROR_SetupStalled = 3,
- };
-
- /* Function Prototypes: */
- void USB_Host_ProcessNextHostState(void);
- uint8_t USB_Host_WaitMS(uint8_t MS);
-
- #if defined(__INCLUDE_FROM_HOST_C)
- static void USB_Host_ResetDevice(void);
- #endif
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#include "../USBMode.h"
+
+#if defined(USB_CAN_BE_HOST)
+
+#define __INCLUDE_FROM_HOST_C
+#include "../Host.h"
+
+void USB_Host_ProcessNextHostState(void)
+{
+ uint8_t ErrorCode = HOST_ENUMERROR_NoError;
+ uint8_t SubErrorCode = HOST_ENUMERROR_NoError;
+
+ static uint16_t WaitMSRemaining;
+ static uint8_t PostWaitState;
+
+ switch (USB_HostState)
+ {
+ case HOST_STATE_WaitForDevice:
+ if (WaitMSRemaining)
+ {
+ if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
+ {
+ USB_HostState = PostWaitState;
+ ErrorCode = HOST_ENUMERROR_WaitStage;
+ break;
+ }
+
+ if (!(--WaitMSRemaining))
+ USB_HostState = PostWaitState;
+ }
+
+ break;
+ case HOST_STATE_Powered:
+ WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;
+
+ USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;
+ break;
+ case HOST_STATE_Powered_WaitForDeviceSettle:
+ if (WaitMSRemaining--)
+ {
+ _delay_ms(1);
+ break;
+ }
+ else
+ {
+ USB_Host_VBUS_Manual_Off();
+
+ USB_OTGPAD_On();
+ USB_Host_VBUS_Auto_Enable();
+ USB_Host_VBUS_Auto_On();
+
+ USB_HostState = HOST_STATE_Powered_WaitForConnect;
+ }
+
+ break;
+ case HOST_STATE_Powered_WaitForConnect:
+ if (USB_INT_HasOccurred(USB_INT_DCONNI))
+ {
+ USB_INT_Clear(USB_INT_DCONNI);
+ USB_INT_Clear(USB_INT_DDISCI);
+
+ USB_INT_Clear(USB_INT_VBERRI);
+ USB_INT_Enable(USB_INT_VBERRI);
+
+ USB_Host_ResumeBus();
+ Pipe_ClearPipes();
+
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);
+ }
+
+ break;
+ case HOST_STATE_Powered_DoReset:
+ USB_Host_ResetDevice();
+
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);
+ break;
+ case HOST_STATE_Powered_ConfigPipe:
+ Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
+ PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
+ PIPE_CONTROLPIPE_DEFAULT_SIZE, PIPE_BANK_SINGLE);
+
+ if (!(Pipe_IsConfigured()))
+ {
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;
+ SubErrorCode = 0;
+ break;
+ }
+
+ USB_HostState = HOST_STATE_Default;
+ break;
+ case HOST_STATE_Default:
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_GetDescriptor,
+ .wValue = (DTYPE_Device << 8),
+ .wIndex = 0,
+ .wLength = 8,
+ };
+
+ uint8_t DataBuffer[8];
+
+ if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)
+ {
+ ErrorCode = HOST_ENUMERROR_ControlError;
+ break;
+ }
+
+ USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];
+
+ USB_Host_ResetDevice();
+
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);
+ break;
+ case HOST_STATE_Default_PostReset:
+ Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,
+ PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,
+ USB_ControlPipeSize, PIPE_BANK_SINGLE);
+
+ if (!(Pipe_IsConfigured()))
+ {
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;
+ SubErrorCode = 0;
+ break;
+ }
+
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_SetAddress,
+ .wValue = USB_HOST_DEVICEADDRESS,
+ .wIndex = 0,
+ .wLength = 0,
+ };
+
+ if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
+ {
+ ErrorCode = HOST_ENUMERROR_ControlError;
+ break;
+ }
+
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);
+ break;
+ case HOST_STATE_Default_PostAddressSet:
+ USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
+
+ EVENT_USB_Host_DeviceEnumerationComplete();
+ USB_HostState = HOST_STATE_Addressed;
+ break;
+ }
+
+ if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
+ {
+ EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
+
+ USB_Host_VBUS_Auto_Off();
+
+ EVENT_USB_Host_DeviceUnattached();
+
+ USB_ResetInterface();
+ }
+}
+
+uint8_t USB_Host_WaitMS(uint8_t MS)
+{
+ bool BusSuspended = USB_Host_IsBusSuspended();
+ uint8_t ErrorCode = HOST_WAITERROR_Successful;
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
+
+ USB_INT_Disable(USB_INT_HSOFI);
+ USB_INT_Clear(USB_INT_HSOFI);
+
+ USB_Host_ResumeBus();
+
+ while (MS)
+ {
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ {
+ USB_INT_Clear(USB_INT_HSOFI);
+ MS--;
+ }
+
+ if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))
+ {
+ ErrorCode = HOST_WAITERROR_DeviceDisconnect;
+
+ break;
+ }
+
+ if (Pipe_IsError() == true)
+ {
+ Pipe_ClearError();
+ ErrorCode = HOST_WAITERROR_PipeError;
+
+ break;
+ }
+
+ if (Pipe_IsStalled() == true)
+ {
+ Pipe_ClearStall();
+ ErrorCode = HOST_WAITERROR_SetupStalled;
+
+ break;
+ }
+ }
+
+ if (BusSuspended)
+ USB_Host_SuspendBus();
+
+ if (HSOFIEnabled)
+ USB_INT_Enable(USB_INT_HSOFI);
+
+ return ErrorCode;
+}
+
+static void USB_Host_ResetDevice(void)
+{
+ bool BusSuspended = USB_Host_IsBusSuspended();
+
+ USB_INT_Disable(USB_INT_DDISCI);
+
+ USB_Host_ResetBus();
+ while (!(USB_Host_IsBusResetComplete()));
+ USB_Host_ResumeBus();
+
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
+
+ USB_INT_Disable(USB_INT_HSOFI);
+ USB_INT_Clear(USB_INT_HSOFI);
+
+ for (uint8_t MSRem = 10; MSRem != 0; MSRem--)
+ {
+ /* Workaround for powerless-pull-up devices. After a USB bus reset,
+ all disconnection interrupts are suppressed while a USB frame is
+ looked for - if it is found within 10ms, the device is still
+ present. */
+
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))
+ {
+ USB_INT_Clear(USB_INT_HSOFI);
+ USB_INT_Clear(USB_INT_DDISCI);
+ break;
+ }
+
+ _delay_ms(1);
+ }
+
+ if (HSOFIEnabled)
+ USB_INT_Enable(USB_INT_HSOFI);
+
+ if (BusSuspended)
+ USB_Host_SuspendBus();
+
+ USB_INT_Enable(USB_INT_DDISCI);
+}
+
+uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_SetConfiguration,
+ .wValue = ConfigNumber,
+ .wIndex = 0,
+ .wLength = 0,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(NULL);
+}
+
+uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_GetDescriptor,
+ .wValue = (DTYPE_Device << 8),
+ .wIndex = 0,
+ .wLength = sizeof(USB_Descriptor_Device_t),
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(DeviceDescriptorPtr);
+}
+
+uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
+ void* const Buffer,
+ const uint8_t BufferLength)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_GetDescriptor,
+ .wValue = (DTYPE_String << 8) | Index,
+ .wIndex = 0,
+ .wLength = BufferLength,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(Buffer);
+}
+
+uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)
+{
+ USB_ControlRequest = (USB_Request_Header_t)
+ {
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),
+ .bRequest = REQ_ClearFeature,
+ .wValue = FEATURE_SEL_EndpointHalt,
+ .wIndex = EndpointNum,
+ .wLength = 0,
+ };
+
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);
+
+ return USB_Host_SendControlRequest(NULL);
+}
+
+#endif
+
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB Host definitions for the AVR8 microcontrollers.
+ * \copydetails Group_Host_AVR8
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_Host
+ * \defgroup Group_Host_AVR8 Host Management (AVR8)
+ * \brief USB Host definitions for the AVR8 microcontrollers.
+ *
+ * Architecture specific USB Host definitions for the Atmel 8-bit AVR microcontrollers.
+ *
+ * @{
+ */
+
+#ifndef __USBHOST_AVR8_H__
+#define __USBHOST_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+ #include "../StdDescriptors.h"
+ #include "../Pipe.h"
+ #include "../USBInterrupt.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Indicates the fixed USB device address which any attached device is enumerated to when in
+ * host mode. As only one USB device may be attached to the AVR in host mode at any one time
+ * and that the address used is not important (other than the fact that it is non-zero), a
+ * fixed value is specified by the library.
+ */
+ #define USB_HOST_DEVICEADDRESS 1
+
+ #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)
+ /** Constant for the maximum software timeout period of sent USB control transactions to an attached
+ * device. If a device fails to respond to a sent control request within this period, the
+ * library will return a timeout error code.
+ *
+ * This value may be overridden in the user project makefile as the value of the
+ * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.
+ */
+ #define USB_HOST_TIMEOUT_MS 1000
+ #endif
+
+ #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)
+ /** Constant for the delay in milliseconds after a device is connected before the library
+ * will start the enumeration process. Some devices require a delay of up to 5 seconds
+ * after connection before the enumeration process can start or incorrect operation will
+ * occur.
+ *
+ * The default delay value may be overridden in the user project makefile by defining the
+ * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the
+ * compiler using the -D switch.
+ */
+ #define HOST_DEVICE_SETTLE_DELAY_MS 1000
+ #endif
+
+ /* Enums: */
+ /** Enum for the various states of the USB Host state machine. Only some states are
+ * implemented in the LUFA library - other states are left to the user to implement.
+ *
+ * For information on each possible USB host state, refer to the USB 2.0 specification.
+ * Several of the USB host states are broken up further into multiple smaller sub-states,
+ * so that they can be internally implemented inside the library in an efficient manner.
+ *
+ * \see \ref USB_HostState, which stores the current host state machine state.
+ */
+ enum USB_Host_States_t
+ {
+ HOST_STATE_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be
+ * used by the library to wait until the attached device is
+ * removed by the user - useful for when an error occurs or
+ * further communication with the device is not needed. This
+ * allows for other code to run while the state machine is
+ * effectively disabled.
+ */
+ HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates
+ * that the stack is waiting for an interval to elapse before
+ * continuing with the next step of the device enumeration
+ * process.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates
+ * that the host state machine is waiting for a device to be
+ * attached so that it can start the enumeration process.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates
+ * that a device has been attached, and the library's internals
+ * are being configured to begin the enumeration process.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates
+ * that the stack is waiting for the initial settling period to
+ * elapse before beginning the enumeration process.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. This state indicates
+ * that the stack is waiting for a connection event from the USB
+ * controller to indicate a valid USB device has been attached to
+ * the bus and is ready to be enumerated.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates
+ * that a valid USB device has been attached, and that it is
+ * will now be reset to ensure it is ready for enumeration.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates
+ * that the attached device is currently powered and reset, and
+ * that the control pipe is now being configured by the stack.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Default = 8, /**< Internally implemented by the library. This state indicates
+ * that the stack is currently retrieving the control endpoint's
+ * size from the device, so that the control pipe can be altered
+ * to match.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. This state indicates that
+ * the control pipe is being reconfigured to match the retrieved
+ * control endpoint size from the device, and the device's USB bus
+ * address is being set.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. This state indicates that
+ * the device's address has now been set, and the stack is has now
+ * completed the device enumeration process. This state causes the
+ * stack to change the current USB device address to that set for
+ * the connected device, before progressing to the user-implemented
+ * \ref HOST_STATE_Addressed state for further communications.
+ *
+ * \note Do not manually change to this state in the user code.
+ */
+ HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should
+ * set the device configuration before progressing to the
+ * \ref HOST_STATE_Configured state. Other processing (such as the
+ * retrieval and processing of the device descriptor) should also
+ * be placed in this state.
+ */
+ HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the
+ * actual work performed on the attached device and changed to the
+ * \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.
+ */
+ HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained
+ * while the bus is suspended, and changed to either the \ref HOST_STATE_Configured
+ * (after resuming the bus with the USB_Host_ResumeBus() macro) or the
+ * \ref HOST_STATE_WaitForDeviceRemoval states as needed.
+ */
+ };
+
+ /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.
+ *
+ * \see \ref Group_Events for more information on this event.
+ */
+ enum USB_Host_ErrorCodes_t
+ {
+ HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This
+ * error may be the result of an attached device drawing
+ * too much current from the VBUS line, or due to the
+ * AVR's power source being unable to supply sufficient
+ * current.
+ */
+ };
+
+ /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.
+ *
+ * \see \ref Group_Events for more information on this event.
+ */
+ enum USB_Host_EnumerationErrorCodes_t
+ {
+ HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
+ * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()
+ * event.
+ */
+ HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed
+ * to complete successfully, due to a timeout or other
+ * error.
+ */
+ HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines
+ * indicating the attachment of a device.
+ */
+ HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to
+ * complete successfully.
+ */
+ HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to
+ * configure correctly.
+ */
+ };
+
+ /* Inline Functions: */
+ /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)
+ * the frame number is incremented by one.
+ */
+ static inline uint16_t USB_Host_GetFrameNumber(void)
+ {
+ return UHFNUM;
+ }
+
+ #if !defined(NO_SOF_EVENTS)
+ /** Enables the host mode Start Of Frame events. When enabled, this causes the
+ * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
+ * at the start of each USB frame when a device is enumerated while in host mode.
+ *
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.
+ */
+ static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_EnableSOFEvents(void)
+ {
+ USB_INT_Enable(USB_INT_HSOFI);
+ }
+
+ /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the
+ * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.
+ *
+ * \note Not available when the NO_SOF_EVENTS compile time token is defined.
+ */
+ static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_DisableSOFEvents(void)
+ {
+ USB_INT_Disable(USB_INT_HSOFI);
+ }
+ #endif
+
+ /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.
+ * USB bus resets leave the default control pipe configured (if already configured).
+ *
+ * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be
+ * woken up automatically and the bus resumed after the reset has been correctly issued.
+ */
+ static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_ResetBus(void)
+ {
+ UHCON |= (1 << RESET);
+ }
+
+ /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has
+ * completed.
+ *
+ * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.
+ */
+ static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_Host_IsBusResetComplete(void)
+ {
+ return ((UHCON & (1 << RESET)) ? false : true);
+ }
+
+ /** Resumes USB communications with an attached and enumerated device, by resuming the transmission
+ * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the
+ * host and attached device may occur.
+ */
+ static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_ResumeBus(void)
+ {
+ UHCON |= (1 << SOFEN);
+ }
+
+ /** Suspends the USB bus, preventing any communications from occurring between the host and attached
+ * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame
+ * messages to the device.
+ */
+ static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_SuspendBus(void)
+ {
+ UHCON &= ~(1 << SOFEN);
+ }
+
+ /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,
+ * false otherwise. While suspended, no USB communications can occur until the bus is resumed,
+ * except for the Remote Wakeup event from the device if supported.
+ *
+ * \return Boolean \c true if the bus is currently suspended, \c false otherwise.
+ */
+ static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_Host_IsBusSuspended(void)
+ {
+ return ((UHCON & (1 << SOFEN)) ? false : true);
+ }
+
+ /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
+ * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).
+ *
+ * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.
+ */
+ static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_Host_IsDeviceFullSpeed(void)
+ {
+ return ((USBSTA & (1 << SPEED)) ? true : false);
+ }
+
+ /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
+ * that the host resume the USB bus and wake up the device, false otherwise.
+ *
+ * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.
+ */
+ static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_Host_IsRemoteWakeupSent(void)
+ {
+ return ((UHINT & (1 << RXRSMI)) ? true : false);
+ }
+
+ /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
+ static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_ClearRemoteWakeupSent(void)
+ {
+ UHINT &= ~(1 << RXRSMI);
+ }
+
+ /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
+ * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to
+ * be resumed.
+ */
+ static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_ResumeFromWakeupRequest(void)
+ {
+ UHCON |= (1 << RESUME);
+ }
+
+ /** Determines if a resume from Remote Wakeup request is currently being sent to an attached
+ * device.
+ *
+ * \return Boolean \c true if no resume request is currently being sent, \c false otherwise.
+ */
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
+ {
+ return ((UHCON & (1 << RESUME)) ? false : true);
+ }
+
+ /* Function Prototypes: */
+ /** Convenience function. This routine sends a SET CONFIGURATION standard request to the attached
+ * device, with the given configuration index. This can be used to easily set the device
+ * configuration without creating and sending the request manually.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param[in] ConfigNumber Configuration index to send to the device.
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);
+
+ /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached
+ * device, requesting the device descriptor. This can be used to easily retrieve information
+ * about the device such as its VID, PID and power requirements.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where
+ * the read data is to be stored.
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);
+
+ /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached
+ * device, requesting the string descriptor of the specified index. This can be used to easily
+ * retrieve string descriptors from the device by index, after the index is obtained from the
+ * Device or Configuration descriptors.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param[in] Index Index of the string index to retrieve.
+ * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is
+ * to be stored.
+ * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
+ void* const Buffer,
+ const uint8_t BufferLength);
+
+ /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device.
+ *
+ * \note After this routine returns, the control pipe will be selected.
+ *
+ * \param[in] EndpointIndex Index of the endpoint to clear, including the endpoint's direction.
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
+ */
+ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex);
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_HostMode_On(void)
+ {
+ USBCON |= (1 << HOST);
+ }
+
+ static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_HostMode_Off(void)
+ {
+ USBCON &= ~(1 << HOST);
+ }
+
+ static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_VBUS_Auto_Enable(void)
+ {
+ OTGCON &= ~(1 << VBUSHWC);
+ UHWCON |= (1 << UVCONE);
+ }
+
+ static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_VBUS_Manual_Enable(void)
+ {
+ OTGCON |= (1 << VBUSHWC);
+ UHWCON &= ~(1 << UVCONE);
+
+ DDRE |= (1 << 7);
+ }
+
+ static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_VBUS_Auto_On(void)
+ {
+ OTGCON |= (1 << VBUSREQ);
+ }
+
+ static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_VBUS_Manual_On(void)
+ {
+ PORTE |= (1 << 7);
+ }
+
+ static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_VBUS_Auto_Off(void)
+ {
+ OTGCON |= (1 << VBUSRQC);
+ }
+
+ static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_VBUS_Manual_Off(void)
+ {
+ PORTE &= ~(1 << 7);
+ }
+
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
+ {
+ UHADDR = (Address & 0x7F);
+ }
+
+ /* Enums: */
+ enum USB_Host_WaitMSErrorCodes_t
+ {
+ HOST_WAITERROR_Successful = 0,
+ HOST_WAITERROR_DeviceDisconnect = 1,
+ HOST_WAITERROR_PipeError = 2,
+ HOST_WAITERROR_SetupStalled = 3,
+ };
+
+ /* Function Prototypes: */
+ void USB_Host_ProcessNextHostState(void);
+ uint8_t USB_Host_WaitMS(uint8_t MS);
+
+ #if defined(__INCLUDE_FROM_HOST_C)
+ static void USB_Host_ResetDevice(void);
+ #endif
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB OTG definitions for the AVR8 microcontrollers.
- * \copydetails Group_OTG_AVR8
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_OTG
- * \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8)
- * \brief USB OTG definitions for the AVR8 microcontrollers.
- *
- * Architecture specific USB OTG definitions for the Atmel 8-bit AVR microcontrollers.
- *
- * @{
- */
-
-#ifndef __USBOTG_AVR8_H__
-#define __USBOTG_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.
- *
- * \see \ref USB_OTG_Device_InitiateSRP().
- */
- #define USB_OTG_SRP_VBUS (1 << SRPSEL)
-
- /** Mask for the Data + pulsing method of SRP, supported by some OTG devices.
- *
- * \see \ref USB_OTG_Device_InitiateSRP().
- */
- #define USB_OTG_STP_DATA 0
-
- /* Inline Functions: */
- /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device
- * that the device wishes to change device/host roles.
- */
- static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Device_RequestHNP(void)
- {
- OTGCON |= (1 << HNPREQ);
- }
-
- /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other
- * connected device.
- */
- static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Device_CancelHNPRequest(void)
- {
- OTGCON &= ~(1 << HNPREQ);
- }
-
- /** Determines if the device is currently sending a HNP to an attached host.
- *
- * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise
- */
- static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE;
- static inline bool USB_OTG_Device_IsSendingHNP(void)
- {
- return ((OTGCON & (1 << HNPREQ)) ? true : false);
- }
-
- /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB
- * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in
- * host mode indicates that VBUS should be applied and a session started.
- *
- * There are two different methods of sending a SRP - either pulses on the VBUS line, or by
- * pulsing the Data + line via the internal pull-up resistor.
- *
- * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or
- * \ref USB_OTG_STP_DATA.
- */
- static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)
- {
- OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));
- }
-
- /** Accepts a HNP from a connected device, indicating that both devices should exchange
- * device/host roles.
- */
- static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Host_AcceptHNP(void)
- {
- OTGCON |= (1 << HNPREQ);
- }
-
- /** Rejects a HNP from a connected device, indicating that both devices should remain in their
- * current device/host roles.
- */
- static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Host_RejectHNP(void)
- {
- OTGCON &= ~(1 << HNPREQ);
- }
-
- /** Indicates if the connected device is not currently sending a HNP request.
- *
- * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.
- */
- static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_OTG_Host_IsHNPReceived(void)
- {
- return ((OTGCON & (1 << HNPREQ)) ? true : false);
- }
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB OTG definitions for the AVR8 microcontrollers.
+ * \copydetails Group_OTG_AVR8
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_OTG
+ * \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8)
+ * \brief USB OTG definitions for the AVR8 microcontrollers.
+ *
+ * Architecture specific USB OTG definitions for the Atmel 8-bit AVR microcontrollers.
+ *
+ * @{
+ */
+
+#ifndef __USBOTG_AVR8_H__
+#define __USBOTG_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.
+ *
+ * \see \ref USB_OTG_Device_InitiateSRP().
+ */
+ #define USB_OTG_SRP_VBUS (1 << SRPSEL)
+
+ /** Mask for the Data + pulsing method of SRP, supported by some OTG devices.
+ *
+ * \see \ref USB_OTG_Device_InitiateSRP().
+ */
+ #define USB_OTG_STP_DATA 0
+
+ /* Inline Functions: */
+ /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device
+ * that the device wishes to change device/host roles.
+ */
+ static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTG_Device_RequestHNP(void)
+ {
+ OTGCON |= (1 << HNPREQ);
+ }
+
+ /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other
+ * connected device.
+ */
+ static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTG_Device_CancelHNPRequest(void)
+ {
+ OTGCON &= ~(1 << HNPREQ);
+ }
+
+ /** Determines if the device is currently sending a HNP to an attached host.
+ *
+ * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise
+ */
+ static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE;
+ static inline bool USB_OTG_Device_IsSendingHNP(void)
+ {
+ return ((OTGCON & (1 << HNPREQ)) ? true : false);
+ }
+
+ /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB
+ * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in
+ * host mode indicates that VBUS should be applied and a session started.
+ *
+ * There are two different methods of sending a SRP - either pulses on the VBUS line, or by
+ * pulsing the Data + line via the internal pull-up resistor.
+ *
+ * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or
+ * \ref USB_OTG_STP_DATA.
+ */
+ static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)
+ {
+ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));
+ }
+
+ /** Accepts a HNP from a connected device, indicating that both devices should exchange
+ * device/host roles.
+ */
+ static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTG_Host_AcceptHNP(void)
+ {
+ OTGCON |= (1 << HNPREQ);
+ }
+
+ /** Rejects a HNP from a connected device, indicating that both devices should remain in their
+ * current device/host roles.
+ */
+ static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTG_Host_RejectHNP(void)
+ {
+ OTGCON &= ~(1 << HNPREQ);
+ }
+
+ /** Indicates if the connected device is not currently sending a HNP request.
+ *
+ * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.
+ */
+ static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_OTG_Host_IsHNPReceived(void)
+ {
+ return ((OTGCON & (1 << HNPREQ)) ? true : false);
+ }
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#include "../USBMode.h"
-
-#if defined(USB_CAN_BE_HOST)
-
-#include "Pipe.h"
-
-uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
-
-bool Pipe_ConfigurePipe(const uint8_t Number,
- const uint8_t Type,
- const uint8_t Token,
- const uint8_t EndpointNumber,
- const uint16_t Size,
- const uint8_t Banks)
-{
-#if defined(ORDERED_EP_CONFIG)
- Pipe_SelectPipe(Number);
- Pipe_EnablePipe();
-
- UPCFG1X = 0;
-
- UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
- UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
-
- Pipe_SetInfiniteINRequests();
-
- return Pipe_IsConfigured();
-#else
- for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)
- {
- uint8_t UPCFG0XTemp;
- uint8_t UPCFG1XTemp;
- uint8_t UPCFG2XTemp;
- uint8_t UPCONXTemp;
- uint8_t UPINRQXTemp;
- uint8_t UPIENXTemp;
-
- Pipe_SelectPipe(PNum);
-
- if (PNum == Number)
- {
- UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
- UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
- UPCFG2XTemp = 0;
- UPCONXTemp = ((1 << PEN) | (1 << INMODE));
- UPINRQXTemp = 0;
- UPIENXTemp = 0;
- }
- else
- {
- UPCFG0XTemp = UPCFG0X;
- UPCFG1XTemp = UPCFG1X;
- UPCFG2XTemp = UPCFG2X;
- UPCONXTemp = UPCONX;
- UPINRQXTemp = UPINRQX;
- UPIENXTemp = UPIENX;
- }
-
- if (!(UPCFG1XTemp & (1 << ALLOC)))
- continue;
-
- Pipe_DisablePipe();
- UPCFG1X &= (1 << ALLOC);
-
- Pipe_EnablePipe();
- UPCFG0X = UPCFG0XTemp;
- UPCFG1X = UPCFG1XTemp;
- UPCFG2X = UPCFG2XTemp;
- UPCONX = UPCONXTemp;
- UPINRQX = UPINRQXTemp;
- UPIENX = UPIENXTemp;
-
- if (!(Pipe_IsConfigured()))
- return false;
- }
-
- Pipe_SelectPipe(Number);
- return true;
-#endif
-}
-
-void Pipe_ClearPipes(void)
-{
- UPINT = 0;
-
- for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
- {
- Pipe_SelectPipe(PNum);
- UPIENX = 0;
- UPINTX = 0;
- UPCFG1X = 0;
- Pipe_DisablePipe();
- }
-}
-
-bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)
-{
- uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();
-
- for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
- {
- Pipe_SelectPipe(PNum);
-
- if (!(Pipe_IsConfigured()))
- continue;
-
- uint8_t PipeToken = Pipe_GetPipeToken();
- bool PipeTokenCorrect = true;
-
- if (PipeToken != PIPE_TOKEN_SETUP)
- PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));
-
- if (PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))
- return true;
- }
-
- Pipe_SelectPipe(PrevPipeNumber);
- return false;
-}
-
-uint8_t Pipe_WaitUntilReady(void)
-{
- #if (USB_STREAM_TIMEOUT_MS < 0xFF)
- uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
- #else
- uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
- #endif
-
- uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
-
- for (;;)
- {
- if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
- {
- if (Pipe_IsINReceived())
- return PIPE_READYWAIT_NoError;
- }
- else
- {
- if (Pipe_IsOUTReady())
- return PIPE_READYWAIT_NoError;
- }
-
- if (Pipe_IsStalled())
- return PIPE_READYWAIT_PipeStalled;
- else if (USB_HostState == HOST_STATE_Unattached)
- return PIPE_READYWAIT_DeviceDisconnected;
-
- uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
-
- if (CurrentFrameNumber != PreviousFrameNumber)
- {
- PreviousFrameNumber = CurrentFrameNumber;
-
- if (!(TimeoutMSRem--))
- return PIPE_READYWAIT_Timeout;
- }
- }
-}
-
-#endif
-
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB Pipe definitions for the AVR8 microcontrollers.
- * \copydetails Group_PipeManagement_AVR8
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_PipeRW
- * \defgroup Group_PipeRW_AVR8 Pipe Data Reading and Writing (AVR8)
- * \brief Pipe data read/write definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.
- */
-
-/** \ingroup Group_PipePrimitiveRW
- * \defgroup Group_PipePrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8)
- * \brief Pipe primative data read/write definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros, variables, enums and types related to data reading and writing of primitive data types
- * from and to pipes.
- */
-
-/** \ingroup Group_PipePacketManagement
- * \defgroup Group_PipePacketManagement_AVR8 Pipe Packet Management (AVR8)
- * \brief Pipe packet management definitions for the Atmel AVR8 architecture.
- *
- * Functions, macros, variables, enums and types related to packet management of pipes.
- */
-
-/** \ingroup Group_PipeControlReq
- * \defgroup Group_PipeControlReq_AVR8 Pipe Control Request Management (AVR8)
- * \brief Pipe control request management definitions for the Atmel AVR8 architecture.
- *
- * Module for host mode request processing. This module allows for the transmission of standard, class and
- * vendor control requests to the default control endpoint of an attached device while in host mode.
- *
- * \see Chapter 9 of the USB 2.0 specification.
- */
-
-/** \ingroup Group_PipeManagement
- * \defgroup Group_PipeManagement_AVR8 Pipe Management (AVR8)
- * \brief Pipe management definitions for the Atmel AVR8 architecture.
- *
- * This module contains functions, macros and enums related to pipe management when in USB Host mode. This
- * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions
- * for various data types.
- *
- * @{
- */
-
-#ifndef __PIPE_AVR8_H__
-#define __PIPE_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
- #include "../USBTask.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** \name Pipe Error Flag Masks */
- //@{
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */
- #define PIPE_ERRORFLAG_OVERFLOW (1 << 6)
-
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */
- #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5)
-
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */
- #define PIPE_ERRORFLAG_CRC16 (1 << 4)
-
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */
- #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)
-
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */
- #define PIPE_ERRORFLAG_PID (1 << 2)
-
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */
- #define PIPE_ERRORFLAG_DATAPID (1 << 1)
-
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */
- #define PIPE_ERRORFLAG_DATATGL (1 << 0)
- //@}
-
- /** \name Pipe Token Masks */
- //@{
- /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes),
- * which will trigger a control request on the attached device when data is written to the pipe.
- */
- #define PIPE_TOKEN_SETUP (0 << PTOKEN0)
-
- /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),
- * indicating that the pipe data will flow from device to host.
- */
- #define PIPE_TOKEN_IN (1 << PTOKEN0)
-
- /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes),
- * indicating that the pipe data will flow from host to device.
- */
- #define PIPE_TOKEN_OUT (2 << PTOKEN0)
- //@}
-
- /** \name Pipe Bank Mode Masks */
- //@{
- /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe
- * should have one single bank, which requires less USB FIFO memory but results in slower transfers as
- * only one USB device (the AVR or the attached device) can access the pipe's bank at the one time.
- */
- #define PIPE_BANK_SINGLE (0 << EPBK0)
-
- /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe
- * should have two banks, which requires more USB FIFO memory but results in faster transfers as one
- * USB device (the AVR or the attached device) can access one bank while the other accesses the second
- * bank.
- */
- #define PIPE_BANK_DOUBLE (1 << EPBK0)
- //@}
-
- /** Pipe address for the default control pipe, which always resides in address 0. This is
- * defined for convenience to give more readable code when used with the pipe macros.
- */
- #define PIPE_CONTROLPIPE 0
-
- /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value
- * in the device descriptor of the attached device.
- */
- #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64
-
- /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address
- * in the device.
- */
- #define PIPE_PIPENUM_MASK 0x07
-
- /** Total number of pipes (including the default control pipe at address 0) which may be used in
- * the device. Different USB AVR models support different amounts of pipes, this value reflects
- * the maximum number of pipes for the currently selected AVR model.
- */
- #define PIPE_TOTAL_PIPES 7
-
- /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR
- * model supports the largest bank size possible on the device; different pipe numbers support
- * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the
- * currently selected USB AVR model.
- */
- #define PIPE_MAX_SIZE 256
-
- /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
- * numerical address in the attached device.
- */
- #define PIPE_EPNUM_MASK 0x0F
-
- /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
- * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
- */
- #define PIPE_EPDIR_MASK 0x80
-
- /* Enums: */
- /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.
- *
- * \ingroup Group_PipeRW_AVR8
- */
- enum Pipe_WaitUntilReady_ErrorCodes_t
- {
- PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */
- PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */
- PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */
- PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet
- * within the software timeout period set by the
- * \ref USB_STREAM_TIMEOUT_MS macro.
- */
- };
-
- /* Inline Functions: */
- /** Indicates the number of bytes currently stored in the current pipes's selected bank.
- *
- * \note The return width of this function may differ, depending on the maximum pipe bank size
- * of the selected AVR model.
- *
- * \ingroup Group_PipeRW_AVR8
- *
- * \return Total number of bytes in the currently selected pipe's FIFO buffer.
- */
- static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t Pipe_BytesInPipe(void)
- {
- return UPBCX;
- }
-
- /** Returns the pipe address of the currently selected pipe. This is typically used to save the
- * currently selected pipe number so that it can be restored after another pipe has been manipulated.
- *
- * \return Index of the currently selected pipe.
- */
- static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_GetCurrentPipe(void)
- {
- return (UPNUM & PIPE_PIPENUM_MASK);
- }
-
- /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be
- * indicated will operate on the currently selected pipe.
- *
- * \param[in] PipeNumber Index of the pipe to select.
- */
- static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;
- static inline void Pipe_SelectPipe(const uint8_t PipeNumber)
- {
- UPNUM = PipeNumber;
- }
-
- /** Resets the desired pipe, including the pipe banks and flags.
- *
- * \param[in] PipeNumber Index of the pipe to reset.
- */
- static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ResetPipe(const uint8_t PipeNumber)
- {
- UPRST = (1 << PipeNumber);
- UPRST = 0;
- }
-
- /** Enables the currently selected pipe so that data can be sent and received through it to and from
- * an attached device.
- *
- * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe().
- */
- static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_EnablePipe(void)
- {
- UPCONX |= (1 << PEN);
- }
-
- /** Disables the currently selected pipe so that data cannot be sent and received through it to and
- * from an attached device.
- */
- static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_DisablePipe(void)
- {
- UPCONX &= ~(1 << PEN);
- }
-
- /** Determines if the currently selected pipe is enabled, but not necessarily configured.
- *
- * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise.
- */
- static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsEnabled(void)
- {
- return ((UPCONX & (1 << PEN)) ? true : false);
- }
-
- /** Gets the current pipe token, indicating the pipe's data direction and type.
- *
- * \return The current pipe token, as a \c PIPE_TOKEN_* mask.
- */
- static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_GetPipeToken(void)
- {
- return (UPCFG0X & (0x03 << PTOKEN0));
- }
-
- /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*
- * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during
- * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices
- * which have two endpoints of opposite direction sharing the same endpoint address within the device.
- *
- * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask.
- */
- static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;
- static inline void Pipe_SetPipeToken(const uint8_t Token)
- {
- UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);
- }
-
- /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */
- static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_SetInfiniteINRequests(void)
- {
- UPCONX |= (1 << INMODE);
- }
-
- /** Configures the currently selected pipe to only allow the specified number of IN requests to be
- * accepted by the pipe before it is automatically frozen.
- *
- * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing.
- */
- static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;
- static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)
- {
- UPCONX &= ~(1 << INMODE);
- UPINRQX = TotalINRequests;
- }
-
- /** Determines if the currently selected pipe is configured.
- *
- * \return Boolean \c true if the selected pipe is configured, \c false otherwise.
- */
- static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsConfigured(void)
- {
- return ((UPSTAX & (1 << CFGOK)) ? true : false);
- }
-
- /** Retrieves the endpoint number of the endpoint within the attached device that the currently selected
- * pipe is bound to.
- *
- * \return Endpoint number the currently selected pipe is bound to.
- */
- static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_BoundEndpointNumber(void)
- {
- return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK);
- }
-
- /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.
- *
- * \param[in] Milliseconds Number of milliseconds between each pipe poll.
- */
- static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;
- static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)
- {
- UPCFG2X = Milliseconds;
- }
-
- /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should
- * be serviced.
- *
- * \return Mask whose bits indicate which pipes have interrupted.
- */
- static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_GetPipeInterrupts(void)
- {
- return UPINT;
- }
-
- /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type
- * pipes).
- *
- * \param[in] PipeNumber Index of the pipe whose interrupt flag should be tested.
- *
- * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise.
- */
- static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber)
- {
- return ((UPINT & (1 << PipeNumber)) ? true : false);
- }
-
- /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */
- static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Unfreeze(void)
- {
- UPCONX &= ~(1 << PFREEZE);
- }
-
- /** Freezes the selected pipe, preventing it from communicating with an attached device. */
- static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Freeze(void)
- {
- UPCONX |= (1 << PFREEZE);
- }
-
- /** Determines if the currently selected pipe is frozen, and not able to accept data.
- *
- * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise.
- */
- static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsFrozen(void)
- {
- return ((UPCONX & (1 << PFREEZE)) ? true : false);
- }
-
- /** Clears the master pipe error flag. */
- static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearError(void)
- {
- UPINTX &= ~(1 << PERRI);
- }
-
- /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that
- * some sort of hardware error has occurred on the pipe.
- *
- * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.
- *
- * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise.
- */
- static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsError(void)
- {
- return ((UPINTX & (1 << PERRI)) ? true : false);
- }
-
- /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error
- * flag for the pipe.
- */
- static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearErrorFlags(void)
- {
- UPERRX = 0;
- }
-
- /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This
- * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.
- *
- * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe.
- */
- static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_GetErrorFlags(void)
- {
- return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |
- PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |
- PIPE_ERRORFLAG_DATATGL)) |
- (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW)));
- }
-
- /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for
- * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the
- * \ref Pipe_ClearIN() command.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Total number of busy banks in the selected pipe.
- */
- static inline uint8_t Pipe_GetBusyBanks(void)
- {
- return (UPSTAX & (0x03 << NBUSYBK0));
- }
-
- /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe
- * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT
- * direction). This function will return false if an error has occurred in the pipe, or if the pipe
- * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT
- * direction and the pipe bank is full.
- *
- * \note This function is not valid on CONTROL type pipes.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Boolean \c true if the currently selected pipe may be read from or written to, depending
- * on its direction.
- */
- static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsReadWriteAllowed(void)
- {
- return ((UPINTX & (1 << RWAL)) ? true : false);
- }
-
- /** Determines if a packet has been received on the currently selected IN pipe from the attached device.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise.
- */
- static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsINReceived(void)
- {
- return ((UPINTX & (1 << RXINI)) ? true : false);
- }
-
- /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise.
- */
- static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsOUTReady(void)
- {
- return ((UPINTX & (1 << TXOUTI)) ? true : false);
- }
-
- /** Determines if no SETUP request is currently being sent to the attached device on the selected
- * CONTROL type pipe.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise.
- */
- static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsSETUPSent(void)
- {
- return ((UPINTX & (1 << TXSTPI)) ? true : false);
- }
-
- /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- */
- static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearSETUP(void)
- {
- UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));
- }
-
- /** Acknowledges the reception of a setup IN request from the attached device on the currently selected
- * pipe, freeing the bank ready for the next packet.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- */
- static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearIN(void)
- {
- UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));
- }
-
- /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
- * the bank ready for the next packet.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- */
- static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearOUT(void)
- {
- UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));
- }
-
- /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on
- * the currently selected pipe. This occurs when the host sends a packet to the device, but the device
- * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been
- * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet
- * can be re-sent.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise.
- */
- static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsNAKReceived(void)
- {
- return ((UPINTX & (1 << NAKEDI)) ? true : false);
- }
-
- /** Clears the NAK condition on the currently selected pipe.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \see \ref Pipe_IsNAKReceived() for more details.
- */
- static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearNAKReceived(void)
- {
- UPINTX &= ~(1 << NAKEDI);
- }
-
- /** Determines if the currently selected pipe has had the STALL condition set by the attached device.
- *
- * \ingroup Group_PipePacketManagement_AVR8
- *
- * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise.
- */
- static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Pipe_IsStalled(void)
- {
- return ((UPINTX & (1 << RXSTALLI)) ? true : false);
- }
-
- /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the
- * STALL condition itself (this must be done via a ClearFeature control request to the device).
- *
- * \ingroup Group_PipePacketManagement_AVR8
- */
- static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearStall(void)
- {
- UPINTX &= ~(1 << RXSTALLI);
- }
-
- /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \return Next byte in the currently selected pipe's FIFO buffer.
- */
- static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_Read_Byte(void)
- {
- return UPDATX;
- }
-
- /** Writes one byte from the currently selected pipe's bank, for IN direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \param[in] Byte Next byte to write into the the currently selected pipe's FIFO buffer.
- */
- static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Write_Byte(const uint8_t Byte)
- {
- UPDATX = Byte;
- }
-
- /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- */
- static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Discard_Byte(void)
- {
- uint8_t Dummy;
-
- Dummy = UPDATX;
- }
-
- /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \return Next word in the currently selected pipe's FIFO buffer.
- */
- static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t Pipe_Read_Word_LE(void)
- {
- union
- {
- uint16_t Word;
- uint8_t Bytes[2];
- } Data;
-
- Data.Bytes[0] = UPDATX;
- Data.Bytes[1] = UPDATX;
-
- return Data.Word;
- }
-
- /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \return Next word in the currently selected pipe's FIFO buffer.
- */
- static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint16_t Pipe_Read_Word_BE(void)
- {
- union
- {
- uint16_t Word;
- uint8_t Bytes[2];
- } Data;
-
- Data.Bytes[1] = UPDATX;
- Data.Bytes[0] = UPDATX;
-
- return Data.Word;
- }
-
- /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.
- */
- static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Write_Word_LE(const uint16_t Word)
- {
- UPDATX = (Word & 0xFF);
- UPDATX = (Word >> 8);
- }
-
- /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.
- */
- static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Write_Word_BE(const uint16_t Word)
- {
- UPDATX = (Word >> 8);
- UPDATX = (Word & 0xFF);
- }
-
- /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- */
- static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Discard_Word(void)
- {
- uint8_t Dummy;
-
- Dummy = UPDATX;
- Dummy = UPDATX;
- }
-
- /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \return Next double word in the currently selected pipe's FIFO buffer.
- */
- static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint32_t Pipe_Read_DWord_LE(void)
- {
- union
- {
- uint32_t DWord;
- uint8_t Bytes[4];
- } Data;
-
- Data.Bytes[0] = UPDATX;
- Data.Bytes[1] = UPDATX;
- Data.Bytes[2] = UPDATX;
- Data.Bytes[3] = UPDATX;
-
- return Data.DWord;
- }
-
- /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \return Next double word in the currently selected pipe's FIFO buffer.
- */
- static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint32_t Pipe_Read_DWord_BE(void)
- {
- union
- {
- uint32_t DWord;
- uint8_t Bytes[4];
- } Data;
-
- Data.Bytes[3] = UPDATX;
- Data.Bytes[2] = UPDATX;
- Data.Bytes[1] = UPDATX;
- Data.Bytes[0] = UPDATX;
-
- return Data.DWord;
- }
-
- /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.
- */
- static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Write_DWord_LE(const uint32_t DWord)
- {
- UPDATX = (DWord & 0xFF);
- UPDATX = (DWord >> 8);
- UPDATX = (DWord >> 16);
- UPDATX = (DWord >> 24);
- }
-
- /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
- * direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- *
- * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.
- */
- static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Write_DWord_BE(const uint32_t DWord)
- {
- UPDATX = (DWord >> 24);
- UPDATX = (DWord >> 16);
- UPDATX = (DWord >> 8);
- UPDATX = (DWord & 0xFF);
- }
-
- /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
- *
- * \ingroup Group_PipePrimitiveRW_AVR8
- */
- static inline void Pipe_Discard_DWord(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_Discard_DWord(void)
- {
- uint8_t Dummy;
-
- Dummy = UPDATX;
- Dummy = UPDATX;
- Dummy = UPDATX;
- Dummy = UPDATX;
- }
-
- /* External Variables: */
- /** Global indicating the maximum packet size of the default control pipe located at address
- * 0 in the device. This value is set to the value indicated in the attached device's device
- * descriptor once the USB interface is initialized into host mode and a device is attached
- * to the USB bus.
- *
- * \note This variable should be treated as read-only in the user application, and never manually
- * changed in value.
- */
- extern uint8_t USB_ControlPipeSize;
-
- /* Function Prototypes: */
- /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the
- * attached device, bank size and banking mode.
- *
- * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()
- * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or
- * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite
- * numbers of IN requests without automatic freezing - this can be overridden by a call to
- * \ref Pipe_SetFiniteINRequests().
- *
- * \param[in] Number Pipe number to configure. This must be more than 0 and less than \ref PIPE_TOTAL_PIPES.
- *
- * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low
- * Speed USB devices - refer to the USB 2.0 specification.
- *
- * \param[in] Token Pipe data token, either \ref PIPE_TOKEN_SETUP, \ref PIPE_TOKEN_OUT or \ref PIPE_TOKEN_IN.
- * All pipes (except Control type) are unidirectional - data may only be read from or
- * written to the pipe bank based on its direction, not both.
- *
- * \param[in] EndpointNumber Endpoint index within the attached device that the pipe should interface to.
- *
- * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to
- * the USB device, or after they have been received from the USB device (depending on
- * the pipe's data direction). The bank size must indicate the maximum packet size that
- * the pipe can handle.
- *
- * \param[in] Banks Number of banks to use for the pipe being configured, a \c PIPE_BANK_* mask. More banks
- * uses more USB DPRAM, but offers better performance. Isochronous type pipes <b>must</b>
- * have at least two banks.
- *
- * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes <b>must</b> be configured in ascending order,
- * or bank corruption will occur.
- * \n\n
- *
- * \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's
- * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each pipe.
- * \n\n
- *
- * \note The default control pipe should not be manually configured by the user application, as it is
- * automatically configured by the library internally.
- * \n\n
- *
- * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which
- * failed to reconfigure correctly will be selected.
- *
- * \return Boolean \c true if the configuration succeeded, \c false otherwise.
- */
- bool Pipe_ConfigurePipe(const uint8_t Number,
- const uint8_t Type,
- const uint8_t Token,
- const uint8_t EndpointNumber,
- const uint16_t Size,
- const uint8_t Banks);
-
- /** Spin-loops until the currently selected non-control pipe is ready for the next packed of data to be read
- * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).
- *
- * \ingroup Group_PipeRW_AVR8
- *
- * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
- */
- uint8_t Pipe_WaitUntilReady(void);
-
- /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given
- * endpoint is found, it is automatically selected.
- *
- * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check.
- *
- * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found,
- * \c false otherwise.
- */
- bool Pipe_IsEndpointBound(const uint8_t EndpointAddress);
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #if !defined(ENDPOINT_CONTROLEP)
- #define ENDPOINT_CONTROLEP 0
- #endif
-
- /* Inline Functions: */
- static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
- static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)
- {
- uint8_t MaskVal = 0;
- uint16_t CheckBytes = 8;
-
- while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))
- {
- MaskVal++;
- CheckBytes <<= 1;
- }
-
- return (MaskVal << EPSIZE0);
- }
-
- /* Function Prototypes: */
- void Pipe_ClearPipes(void);
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#include "../USBMode.h"
+
+#if defined(USB_CAN_BE_HOST)
+
+#include "../Pipe.h"
+
+uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
+
+bool Pipe_ConfigurePipe(const uint8_t Number,
+ const uint8_t Type,
+ const uint8_t Token,
+ const uint8_t EndpointNumber,
+ const uint16_t Size,
+ const uint8_t Banks)
+{
+#if defined(ORDERED_EP_CONFIG)
+ Pipe_SelectPipe(Number);
+ Pipe_EnablePipe();
+
+ UPCFG1X = 0;
+
+ UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
+ UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
+
+ Pipe_SetInfiniteINRequests();
+
+ return Pipe_IsConfigured();
+#else
+ for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)
+ {
+ uint8_t UPCFG0XTemp;
+ uint8_t UPCFG1XTemp;
+ uint8_t UPCFG2XTemp;
+ uint8_t UPCONXTemp;
+ uint8_t UPINRQXTemp;
+ uint8_t UPIENXTemp;
+
+ Pipe_SelectPipe(PNum);
+
+ if (PNum == Number)
+ {
+ UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
+ UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
+ UPCFG2XTemp = 0;
+ UPCONXTemp = ((1 << PEN) | (1 << INMODE));
+ UPINRQXTemp = 0;
+ UPIENXTemp = 0;
+ }
+ else
+ {
+ UPCFG0XTemp = UPCFG0X;
+ UPCFG1XTemp = UPCFG1X;
+ UPCFG2XTemp = UPCFG2X;
+ UPCONXTemp = UPCONX;
+ UPINRQXTemp = UPINRQX;
+ UPIENXTemp = UPIENX;
+ }
+
+ if (!(UPCFG1XTemp & (1 << ALLOC)))
+ continue;
+
+ Pipe_DisablePipe();
+ UPCFG1X &= (1 << ALLOC);
+
+ Pipe_EnablePipe();
+ UPCFG0X = UPCFG0XTemp;
+ UPCFG1X = UPCFG1XTemp;
+ UPCFG2X = UPCFG2XTemp;
+ UPCONX = UPCONXTemp;
+ UPINRQX = UPINRQXTemp;
+ UPIENX = UPIENXTemp;
+
+ if (!(Pipe_IsConfigured()))
+ return false;
+ }
+
+ Pipe_SelectPipe(Number);
+ return true;
+#endif
+}
+
+void Pipe_ClearPipes(void)
+{
+ UPINT = 0;
+
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
+ {
+ Pipe_SelectPipe(PNum);
+ UPIENX = 0;
+ UPINTX = 0;
+ UPCFG1X = 0;
+ Pipe_DisablePipe();
+ }
+}
+
+bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)
+{
+ uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();
+
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
+ {
+ Pipe_SelectPipe(PNum);
+
+ if (!(Pipe_IsConfigured()))
+ continue;
+
+ uint8_t PipeToken = Pipe_GetPipeToken();
+ bool PipeTokenCorrect = true;
+
+ if (PipeToken != PIPE_TOKEN_SETUP)
+ PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));
+
+ if (PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))
+ return true;
+ }
+
+ Pipe_SelectPipe(PrevPipeNumber);
+ return false;
+}
+
+uint8_t Pipe_WaitUntilReady(void)
+{
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
+ #else
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;
+ #endif
+
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
+
+ for (;;)
+ {
+ if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)
+ {
+ if (Pipe_IsINReceived())
+ return PIPE_READYWAIT_NoError;
+ }
+ else
+ {
+ if (Pipe_IsOUTReady())
+ return PIPE_READYWAIT_NoError;
+ }
+
+ if (Pipe_IsStalled())
+ return PIPE_READYWAIT_PipeStalled;
+ else if (USB_HostState == HOST_STATE_Unattached)
+ return PIPE_READYWAIT_DeviceDisconnected;
+
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
+
+ if (CurrentFrameNumber != PreviousFrameNumber)
+ {
+ PreviousFrameNumber = CurrentFrameNumber;
+
+ if (!(TimeoutMSRem--))
+ return PIPE_READYWAIT_Timeout;
+ }
+ }
+}
+
+#endif
+
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB Pipe definitions for the AVR8 microcontrollers.
+ * \copydetails Group_PipeManagement_AVR8
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_PipeRW
+ * \defgroup Group_PipeRW_AVR8 Pipe Data Reading and Writing (AVR8)
+ * \brief Pipe data read/write definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.
+ */
+
+/** \ingroup Group_PipePrimitiveRW
+ * \defgroup Group_PipePrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8)
+ * \brief Pipe primative data read/write definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types
+ * from and to pipes.
+ */
+
+/** \ingroup Group_PipePacketManagement
+ * \defgroup Group_PipePacketManagement_AVR8 Pipe Packet Management (AVR8)
+ * \brief Pipe packet management definitions for the Atmel AVR8 architecture.
+ *
+ * Functions, macros, variables, enums and types related to packet management of pipes.
+ */
+
+/** \ingroup Group_PipeControlReq
+ * \defgroup Group_PipeControlReq_AVR8 Pipe Control Request Management (AVR8)
+ * \brief Pipe control request management definitions for the Atmel AVR8 architecture.
+ *
+ * Module for host mode request processing. This module allows for the transmission of standard, class and
+ * vendor control requests to the default control endpoint of an attached device while in host mode.
+ *
+ * \see Chapter 9 of the USB 2.0 specification.
+ */
+
+/** \ingroup Group_PipeManagement
+ * \defgroup Group_PipeManagement_AVR8 Pipe Management (AVR8)
+ * \brief Pipe management definitions for the Atmel AVR8 architecture.
+ *
+ * This module contains functions, macros and enums related to pipe management when in USB Host mode. This
+ * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions
+ * for various data types.
+ *
+ * @{
+ */
+
+#ifndef __PIPE_AVR8_H__
+#define __PIPE_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+ #include "../USBTask.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** \name Pipe Error Flag Masks */
+ //@{
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */
+ #define PIPE_ERRORFLAG_OVERFLOW (1 << 6)
+
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */
+ #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5)
+
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */
+ #define PIPE_ERRORFLAG_CRC16 (1 << 4)
+
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */
+ #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)
+
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */
+ #define PIPE_ERRORFLAG_PID (1 << 2)
+
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */
+ #define PIPE_ERRORFLAG_DATAPID (1 << 1)
+
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */
+ #define PIPE_ERRORFLAG_DATATGL (1 << 0)
+ //@}
+
+ /** \name Pipe Token Masks */
+ //@{
+ /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes),
+ * which will trigger a control request on the attached device when data is written to the pipe.
+ */
+ #define PIPE_TOKEN_SETUP (0 << PTOKEN0)
+
+ /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),
+ * indicating that the pipe data will flow from device to host.
+ */
+ #define PIPE_TOKEN_IN (1 << PTOKEN0)
+
+ /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes),
+ * indicating that the pipe data will flow from host to device.
+ */
+ #define PIPE_TOKEN_OUT (2 << PTOKEN0)
+ //@}
+
+ /** \name Pipe Bank Mode Masks */
+ //@{
+ /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe
+ * should have one single bank, which requires less USB FIFO memory but results in slower transfers as
+ * only one USB device (the AVR or the attached device) can access the pipe's bank at the one time.
+ */
+ #define PIPE_BANK_SINGLE (0 << EPBK0)
+
+ /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe
+ * should have two banks, which requires more USB FIFO memory but results in faster transfers as one
+ * USB device (the AVR or the attached device) can access one bank while the other accesses the second
+ * bank.
+ */
+ #define PIPE_BANK_DOUBLE (1 << EPBK0)
+ //@}
+
+ /** Pipe address for the default control pipe, which always resides in address 0. This is
+ * defined for convenience to give more readable code when used with the pipe macros.
+ */
+ #define PIPE_CONTROLPIPE 0
+
+ /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value
+ * in the device descriptor of the attached device.
+ */
+ #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64
+
+ /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address
+ * in the device.
+ */
+ #define PIPE_PIPENUM_MASK 0x07
+
+ /** Total number of pipes (including the default control pipe at address 0) which may be used in
+ * the device. Different USB AVR models support different amounts of pipes, this value reflects
+ * the maximum number of pipes for the currently selected AVR model.
+ */
+ #define PIPE_TOTAL_PIPES 7
+
+ /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR
+ * model supports the largest bank size possible on the device; different pipe numbers support
+ * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the
+ * currently selected USB AVR model.
+ */
+ #define PIPE_MAX_SIZE 256
+
+ /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
+ * numerical address in the attached device.
+ */
+ #define PIPE_EPNUM_MASK 0x0F
+
+ /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's
+ * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.
+ */
+ #define PIPE_EPDIR_MASK 0x80
+
+ /* Enums: */
+ /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.
+ *
+ * \ingroup Group_PipeRW_AVR8
+ */
+ enum Pipe_WaitUntilReady_ErrorCodes_t
+ {
+ PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */
+ PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */
+ PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */
+ PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet
+ * within the software timeout period set by the
+ * \ref USB_STREAM_TIMEOUT_MS macro.
+ */
+ };
+
+ /* Inline Functions: */
+ /** Indicates the number of bytes currently stored in the current pipes's selected bank.
+ *
+ * \note The return width of this function may differ, depending on the maximum pipe bank size
+ * of the selected AVR model.
+ *
+ * \ingroup Group_PipeRW_AVR8
+ *
+ * \return Total number of bytes in the currently selected pipe's FIFO buffer.
+ */
+ static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t Pipe_BytesInPipe(void)
+ {
+ return UPBCX;
+ }
+
+ /** Returns the pipe address of the currently selected pipe. This is typically used to save the
+ * currently selected pipe number so that it can be restored after another pipe has been manipulated.
+ *
+ * \return Index of the currently selected pipe.
+ */
+ static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_GetCurrentPipe(void)
+ {
+ return (UPNUM & PIPE_PIPENUM_MASK);
+ }
+
+ /** Selects the given pipe number. Any pipe operations which do not require the pipe number to be
+ * indicated will operate on the currently selected pipe.
+ *
+ * \param[in] PipeNumber Index of the pipe to select.
+ */
+ static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_SelectPipe(const uint8_t PipeNumber)
+ {
+ UPNUM = PipeNumber;
+ }
+
+ /** Resets the desired pipe, including the pipe banks and flags.
+ *
+ * \param[in] PipeNumber Index of the pipe to reset.
+ */
+ static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ResetPipe(const uint8_t PipeNumber)
+ {
+ UPRST = (1 << PipeNumber);
+ UPRST = 0;
+ }
+
+ /** Enables the currently selected pipe so that data can be sent and received through it to and from
+ * an attached device.
+ *
+ * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe().
+ */
+ static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_EnablePipe(void)
+ {
+ UPCONX |= (1 << PEN);
+ }
+
+ /** Disables the currently selected pipe so that data cannot be sent and received through it to and
+ * from an attached device.
+ */
+ static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_DisablePipe(void)
+ {
+ UPCONX &= ~(1 << PEN);
+ }
+
+ /** Determines if the currently selected pipe is enabled, but not necessarily configured.
+ *
+ * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise.
+ */
+ static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsEnabled(void)
+ {
+ return ((UPCONX & (1 << PEN)) ? true : false);
+ }
+
+ /** Gets the current pipe token, indicating the pipe's data direction and type.
+ *
+ * \return The current pipe token, as a \c PIPE_TOKEN_* mask.
+ */
+ static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_GetPipeToken(void)
+ {
+ return (UPCFG0X & (0x03 << PTOKEN0));
+ }
+
+ /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*
+ * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during
+ * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices
+ * which have two endpoints of opposite direction sharing the same endpoint address within the device.
+ *
+ * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask.
+ */
+ static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_SetPipeToken(const uint8_t Token)
+ {
+ UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);
+ }
+
+ /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */
+ static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_SetInfiniteINRequests(void)
+ {
+ UPCONX |= (1 << INMODE);
+ }
+
+ /** Configures the currently selected pipe to only allow the specified number of IN requests to be
+ * accepted by the pipe before it is automatically frozen.
+ *
+ * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing.
+ */
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)
+ {
+ UPCONX &= ~(1 << INMODE);
+ UPINRQX = TotalINRequests;
+ }
+
+ /** Determines if the currently selected pipe is configured.
+ *
+ * \return Boolean \c true if the selected pipe is configured, \c false otherwise.
+ */
+ static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsConfigured(void)
+ {
+ return ((UPSTAX & (1 << CFGOK)) ? true : false);
+ }
+
+ /** Retrieves the endpoint number of the endpoint within the attached device that the currently selected
+ * pipe is bound to.
+ *
+ * \return Endpoint number the currently selected pipe is bound to.
+ */
+ static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_BoundEndpointNumber(void)
+ {
+ return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK);
+ }
+
+ /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.
+ *
+ * \param[in] Milliseconds Number of milliseconds between each pipe poll.
+ */
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)
+ {
+ UPCFG2X = Milliseconds;
+ }
+
+ /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should
+ * be serviced.
+ *
+ * \return Mask whose bits indicate which pipes have interrupted.
+ */
+ static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_GetPipeInterrupts(void)
+ {
+ return UPINT;
+ }
+
+ /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type
+ * pipes).
+ *
+ * \param[in] PipeNumber Index of the pipe whose interrupt flag should be tested.
+ *
+ * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise.
+ */
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber)
+ {
+ return ((UPINT & (1 << PipeNumber)) ? true : false);
+ }
+
+ /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */
+ static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Unfreeze(void)
+ {
+ UPCONX &= ~(1 << PFREEZE);
+ }
+
+ /** Freezes the selected pipe, preventing it from communicating with an attached device. */
+ static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Freeze(void)
+ {
+ UPCONX |= (1 << PFREEZE);
+ }
+
+ /** Determines if the currently selected pipe is frozen, and not able to accept data.
+ *
+ * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise.
+ */
+ static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsFrozen(void)
+ {
+ return ((UPCONX & (1 << PFREEZE)) ? true : false);
+ }
+
+ /** Clears the master pipe error flag. */
+ static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearError(void)
+ {
+ UPINTX &= ~(1 << PERRI);
+ }
+
+ /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that
+ * some sort of hardware error has occurred on the pipe.
+ *
+ * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.
+ *
+ * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise.
+ */
+ static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsError(void)
+ {
+ return ((UPINTX & (1 << PERRI)) ? true : false);
+ }
+
+ /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error
+ * flag for the pipe.
+ */
+ static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearErrorFlags(void)
+ {
+ UPERRX = 0;
+ }
+
+ /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This
+ * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.
+ *
+ * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe.
+ */
+ static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_GetErrorFlags(void)
+ {
+ return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |
+ PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |
+ PIPE_ERRORFLAG_DATATGL)) |
+ (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW)));
+ }
+
+ /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for
+ * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the
+ * \ref Pipe_ClearIN() command.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Total number of busy banks in the selected pipe.
+ */
+ static inline uint8_t Pipe_GetBusyBanks(void)
+ {
+ return (UPSTAX & (0x03 << NBUSYBK0));
+ }
+
+ /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe
+ * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT
+ * direction). This function will return false if an error has occurred in the pipe, or if the pipe
+ * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT
+ * direction and the pipe bank is full.
+ *
+ * \note This function is not valid on CONTROL type pipes.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Boolean \c true if the currently selected pipe may be read from or written to, depending
+ * on its direction.
+ */
+ static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsReadWriteAllowed(void)
+ {
+ return ((UPINTX & (1 << RWAL)) ? true : false);
+ }
+
+ /** Determines if a packet has been received on the currently selected IN pipe from the attached device.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise.
+ */
+ static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsINReceived(void)
+ {
+ return ((UPINTX & (1 << RXINI)) ? true : false);
+ }
+
+ /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise.
+ */
+ static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsOUTReady(void)
+ {
+ return ((UPINTX & (1 << TXOUTI)) ? true : false);
+ }
+
+ /** Determines if no SETUP request is currently being sent to the attached device on the selected
+ * CONTROL type pipe.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise.
+ */
+ static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsSETUPSent(void)
+ {
+ return ((UPINTX & (1 << TXSTPI)) ? true : false);
+ }
+
+ /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ */
+ static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearSETUP(void)
+ {
+ UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));
+ }
+
+ /** Acknowledges the reception of a setup IN request from the attached device on the currently selected
+ * pipe, freeing the bank ready for the next packet.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ */
+ static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearIN(void)
+ {
+ UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));
+ }
+
+ /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
+ * the bank ready for the next packet.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ */
+ static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearOUT(void)
+ {
+ UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));
+ }
+
+ /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on
+ * the currently selected pipe. This occurs when the host sends a packet to the device, but the device
+ * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been
+ * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet
+ * can be re-sent.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise.
+ */
+ static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsNAKReceived(void)
+ {
+ return ((UPINTX & (1 << NAKEDI)) ? true : false);
+ }
+
+ /** Clears the NAK condition on the currently selected pipe.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \see \ref Pipe_IsNAKReceived() for more details.
+ */
+ static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearNAKReceived(void)
+ {
+ UPINTX &= ~(1 << NAKEDI);
+ }
+
+ /** Determines if the currently selected pipe has had the STALL condition set by the attached device.
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ *
+ * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise.
+ */
+ static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool Pipe_IsStalled(void)
+ {
+ return ((UPINTX & (1 << RXSTALLI)) ? true : false);
+ }
+
+ /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the
+ * STALL condition itself (this must be done via a ClearFeature control request to the device).
+ *
+ * \ingroup Group_PipePacketManagement_AVR8
+ */
+ static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_ClearStall(void)
+ {
+ UPINTX &= ~(1 << RXSTALLI);
+ }
+
+ /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \return Next byte in the currently selected pipe's FIFO buffer.
+ */
+ static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_Read_Byte(void)
+ {
+ return UPDATX;
+ }
+
+ /** Writes one byte from the currently selected pipe's bank, for IN direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \param[in] Byte Next byte to write into the the currently selected pipe's FIFO buffer.
+ */
+ static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Write_Byte(const uint8_t Byte)
+ {
+ UPDATX = Byte;
+ }
+
+ /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ */
+ static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Discard_Byte(void)
+ {
+ uint8_t Dummy;
+
+ Dummy = UPDATX;
+ }
+
+ /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \return Next word in the currently selected pipe's FIFO buffer.
+ */
+ static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t Pipe_Read_Word_LE(void)
+ {
+ union
+ {
+ uint16_t Word;
+ uint8_t Bytes[2];
+ } Data;
+
+ Data.Bytes[0] = UPDATX;
+ Data.Bytes[1] = UPDATX;
+
+ return Data.Word;
+ }
+
+ /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \return Next word in the currently selected pipe's FIFO buffer.
+ */
+ static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint16_t Pipe_Read_Word_BE(void)
+ {
+ union
+ {
+ uint16_t Word;
+ uint8_t Bytes[2];
+ } Data;
+
+ Data.Bytes[1] = UPDATX;
+ Data.Bytes[0] = UPDATX;
+
+ return Data.Word;
+ }
+
+ /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.
+ */
+ static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Write_Word_LE(const uint16_t Word)
+ {
+ UPDATX = (Word & 0xFF);
+ UPDATX = (Word >> 8);
+ }
+
+ /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.
+ */
+ static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Write_Word_BE(const uint16_t Word)
+ {
+ UPDATX = (Word >> 8);
+ UPDATX = (Word & 0xFF);
+ }
+
+ /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ */
+ static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Discard_Word(void)
+ {
+ uint8_t Dummy;
+
+ Dummy = UPDATX;
+ Dummy = UPDATX;
+ }
+
+ /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \return Next double word in the currently selected pipe's FIFO buffer.
+ */
+ static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint32_t Pipe_Read_DWord_LE(void)
+ {
+ union
+ {
+ uint32_t DWord;
+ uint8_t Bytes[4];
+ } Data;
+
+ Data.Bytes[0] = UPDATX;
+ Data.Bytes[1] = UPDATX;
+ Data.Bytes[2] = UPDATX;
+ Data.Bytes[3] = UPDATX;
+
+ return Data.DWord;
+ }
+
+ /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \return Next double word in the currently selected pipe's FIFO buffer.
+ */
+ static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint32_t Pipe_Read_DWord_BE(void)
+ {
+ union
+ {
+ uint32_t DWord;
+ uint8_t Bytes[4];
+ } Data;
+
+ Data.Bytes[3] = UPDATX;
+ Data.Bytes[2] = UPDATX;
+ Data.Bytes[1] = UPDATX;
+ Data.Bytes[0] = UPDATX;
+
+ return Data.DWord;
+ }
+
+ /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.
+ */
+ static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Write_DWord_LE(const uint32_t DWord)
+ {
+ UPDATX = (DWord & 0xFF);
+ UPDATX = (DWord >> 8);
+ UPDATX = (DWord >> 16);
+ UPDATX = (DWord >> 24);
+ }
+
+ /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
+ * direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ *
+ * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.
+ */
+ static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Write_DWord_BE(const uint32_t DWord)
+ {
+ UPDATX = (DWord >> 24);
+ UPDATX = (DWord >> 16);
+ UPDATX = (DWord >> 8);
+ UPDATX = (DWord & 0xFF);
+ }
+
+ /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
+ *
+ * \ingroup Group_PipePrimitiveRW_AVR8
+ */
+ static inline void Pipe_Discard_DWord(void) ATTR_ALWAYS_INLINE;
+ static inline void Pipe_Discard_DWord(void)
+ {
+ uint8_t Dummy;
+
+ Dummy = UPDATX;
+ Dummy = UPDATX;
+ Dummy = UPDATX;
+ Dummy = UPDATX;
+ }
+
+ /* External Variables: */
+ /** Global indicating the maximum packet size of the default control pipe located at address
+ * 0 in the device. This value is set to the value indicated in the attached device's device
+ * descriptor once the USB interface is initialized into host mode and a device is attached
+ * to the USB bus.
+ *
+ * \note This variable should be treated as read-only in the user application, and never manually
+ * changed in value.
+ */
+ extern uint8_t USB_ControlPipeSize;
+
+ /* Function Prototypes: */
+ /** Configures the specified pipe number with the given pipe type, token, target endpoint number in the
+ * attached device, bank size and banking mode.
+ *
+ * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()
+ * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or
+ * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite
+ * numbers of IN requests without automatic freezing - this can be overridden by a call to
+ * \ref Pipe_SetFiniteINRequests().
+ *
+ * \param[in] Number Pipe number to configure. This must be more than 0 and less than \ref PIPE_TOTAL_PIPES.
+ *
+ * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low
+ * Speed USB devices - refer to the USB 2.0 specification.
+ *
+ * \param[in] Token Pipe data token, either \ref PIPE_TOKEN_SETUP, \ref PIPE_TOKEN_OUT or \ref PIPE_TOKEN_IN.
+ * All pipes (except Control type) are unidirectional - data may only be read from or
+ * written to the pipe bank based on its direction, not both.
+ *
+ * \param[in] EndpointNumber Endpoint index within the attached device that the pipe should interface to.
+ *
+ * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to
+ * the USB device, or after they have been received from the USB device (depending on
+ * the pipe's data direction). The bank size must indicate the maximum packet size that
+ * the pipe can handle.
+ *
+ * \param[in] Banks Number of banks to use for the pipe being configured, a \c PIPE_BANK_* mask. More banks
+ * uses more USB DPRAM, but offers better performance. Isochronous type pipes <b>must</b>
+ * have at least two banks.
+ *
+ * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes <b>must</b> be configured in ascending order,
+ * or bank corruption will occur.
+ * \n\n
+ *
+ * \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's
+ * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each pipe.
+ * \n\n
+ *
+ * \note The default control pipe should not be manually configured by the user application, as it is
+ * automatically configured by the library internally.
+ * \n\n
+ *
+ * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which
+ * failed to reconfigure correctly will be selected.
+ *
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.
+ */
+ bool Pipe_ConfigurePipe(const uint8_t Number,
+ const uint8_t Type,
+ const uint8_t Token,
+ const uint8_t EndpointNumber,
+ const uint16_t Size,
+ const uint8_t Banks);
+
+ /** Spin-loops until the currently selected non-control pipe is ready for the next packed of data to be read
+ * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).
+ *
+ * \ingroup Group_PipeRW_AVR8
+ *
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.
+ */
+ uint8_t Pipe_WaitUntilReady(void);
+
+ /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given
+ * endpoint is found, it is automatically selected.
+ *
+ * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check.
+ *
+ * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found,
+ * \c false otherwise.
+ */
+ bool Pipe_IsEndpointBound(const uint8_t EndpointAddress);
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #if !defined(ENDPOINT_CONTROLEP)
+ #define ENDPOINT_CONTROLEP 0
+ #endif
+
+ /* Inline Functions: */
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)
+ {
+ uint8_t MaskVal = 0;
+ uint16_t CheckBytes = 8;
+
+ while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))
+ {
+ MaskVal++;
+ CheckBytes <<= 1;
+ }
+
+ return (MaskVal << EPSIZE0);
+ }
+
+ /* Function Prototypes: */
+ void Pipe_ClearPipes(void);
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#define __INCLUDE_FROM_USB_CONTROLLER_C
-#include "USBController.h"
-
-#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
-volatile uint8_t USB_CurrentMode = USB_MODE_None;
-#endif
-
-#if !defined(USE_STATIC_OPTIONS)
-volatile uint8_t USB_Options;
-#endif
-
-void USB_Init(
- #if defined(USB_CAN_BE_BOTH)
- const uint8_t Mode
- #endif
-
- #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))
- ,
- #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
- void
- #endif
-
- #if !defined(USE_STATIC_OPTIONS)
- const uint8_t Options
- #endif
- )
-{
- #if !defined(USE_STATIC_OPTIONS)
- USB_Options = Options;
- #endif
-
- if (!(USB_Options & USB_OPT_REG_DISABLED))
- USB_REG_On();
- else
- USB_REG_Off();
-
- #if defined(USB_CAN_BE_BOTH)
- if (Mode == USB_MODE_UID)
- {
- UHWCON |= (1 << UIDE);
- USB_INT_Enable(USB_INT_IDTI);
- USB_CurrentMode = USB_GetUSBModeFromUID();
- }
- else
- {
- USB_CurrentMode = Mode;
- }
- #endif
-
- USB_IsInitialized = true;
-
- USB_ResetInterface();
-}
-
-void USB_Disable(void)
-{
- USB_INT_DisableAllInterrupts();
- USB_INT_ClearAllInterrupts();
-
- USB_Detach();
- USB_Controller_Disable();
-
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- USB_PLL_Off();
-
- USB_REG_Off();
-
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- USB_OTGPAD_Off();
- #endif
-
- #if defined(USB_CAN_BE_BOTH)
- USB_CurrentMode = USB_MODE_None;
- #endif
-
- USB_IsInitialized = false;
-}
-
-void USB_ResetInterface(void)
-{
- #if defined(USB_CAN_BE_BOTH)
- bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0);
- #endif
-
- USB_INT_DisableAllInterrupts();
- USB_INT_ClearAllInterrupts();
-
- USB_Controller_Reset();
-
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- {
- #if defined(USB_SERIES_4_AVR)
- PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));
- #endif
-
- USB_PLL_On();
- while (!(USB_PLL_IsReady()));
- }
-
- #if defined(USB_CAN_BE_BOTH)
- if (UIDModeSelectEnabled)
- {
- UHWCON |= (1 << UIDE);
- USB_INT_Enable(USB_INT_IDTI);
- }
- #endif
-
- USB_CLK_Unfreeze();
-
- if (USB_CurrentMode == USB_MODE_Device)
- {
- #if defined(USB_CAN_BE_DEVICE)
- #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- UHWCON |= (1 << UIMOD);
- #endif
-
- USB_Init_Device();
- #endif
- }
- else if (USB_CurrentMode == USB_MODE_Host)
- {
- #if defined(USB_CAN_BE_HOST)
- UHWCON &= ~(1 << UIMOD);
-
- USB_Init_Host();
- #endif
- }
-
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- USB_OTGPAD_On();
- #endif
-}
-
-#if defined(USB_CAN_BE_DEVICE)
-static void USB_Init_Device(void)
-{
- USB_DeviceState = DEVICE_STATE_Unattached;
- USB_ConfigurationNumber = 0;
-
- #if !defined(NO_DEVICE_REMOTE_WAKEUP)
- USB_RemoteWakeupEnabled = false;
- #endif
-
- #if !defined(NO_DEVICE_SELF_POWER)
- USB_CurrentlySelfPowered = false;
- #endif
-
- #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
- USB_Descriptor_Device_t* DeviceDescriptorPtr;
-
- if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
- {
- #if defined(USE_RAM_DESCRIPTORS)
- USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
- #elif defined(USE_EEPROM_DESCRIPTORS)
- USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
- #else
- USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
- #endif
- }
- #endif
-
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
- if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
- USB_Device_SetLowSpeed();
- else
- USB_Device_SetFullSpeed();
-
- USB_INT_Enable(USB_INT_VBUS);
- #endif
-
- Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
- ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
- ENDPOINT_BANK_SINGLE);
-
- USB_INT_Clear(USB_INT_SUSPI);
- USB_INT_Enable(USB_INT_SUSPI);
- USB_INT_Enable(USB_INT_EORSTI);
-
- USB_Attach();
-}
-#endif
-
-#if defined(USB_CAN_BE_HOST)
-static void USB_Init_Host(void)
-{
- USB_HostState = HOST_STATE_Unattached;
- USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
-
- USB_Host_HostMode_On();
-
- USB_Host_VBUS_Auto_Off();
- USB_Host_VBUS_Manual_Enable();
- USB_Host_VBUS_Manual_On();
-
- USB_INT_Enable(USB_INT_SRPI);
- USB_INT_Enable(USB_INT_BCERRI);
-
- USB_Attach();
-}
-#endif
-
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB Controller definitions for the AVR8 microcontrollers.
- * \copydetails Group_USBManagement_AVR8
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_USBManagement
- * \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8)
- * \brief USB Controller definitions for the AVR8 microcontrollers.
- *
- * Functions, macros, variables, enums and types related to the setup and management of the USB interface.
- *
- * @{
- */
-
-#ifndef __USBCONTROLLER_AVR8_H__
-#define __USBCONTROLLER_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
- #include "../USBMode.h"
- #include "../Events.h"
- #include "../USBTask.h"
- #include "../USBInterrupt.h"
-
- #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
- #include "../Host.h"
- #include "../OTG.h"
- #include "../Pipe.h"
- #include "../HostStandardReq.h"
- #include "../PipeStream.h"
- #endif
-
- #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
- #include "../Device.h"
- #include "../Endpoint.h"
- #include "../DeviceStandardReq.h"
- #include "../EndpointStream.h"
- #endif
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks and Defines: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- #if !defined(F_CLOCK)
- #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled USB controller clock in your project makefile.
- #endif
-
- #if (F_CLOCK == 8000000)
- #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
- defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
- defined(__AVR_ATmega32U2__))
- #define USB_PLL_PSC 0
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- #define USB_PLL_PSC 0
- #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
- #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
- #endif
- #elif (F_CLOCK == 16000000)
- #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
- defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
- defined(__AVR_ATmega32U2__))
- #define USB_PLL_PSC (1 << PLLP0)
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
- #define USB_PLL_PSC (1 << PINDIV)
- #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
- #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
- #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
- #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))
- #endif
- #endif
-
- #if !defined(USB_PLL_PSC)
- #error No PLL prescale value available for chosen F_CLOCK value and AVR model.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** \name USB Controller Option Masks */
- //@{
- /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
- * regulator should be enabled to regulate the data pin voltages to within the USB standard.
- *
- * \note See USB AVR data sheet for more information on the internal pad regulator.
- */
- #define USB_OPT_REG_DISABLED (1 << 1)
-
- /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
- * regulator should be disabled and the AVR's VCC level used for the data pads.
- *
- * \note See USB AVR data sheet for more information on the internal pad regulator.
- */
- #define USB_OPT_REG_ENABLED (0 << 1)
-
- /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application
- * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock
- * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.
- */
- #define USB_OPT_MANUAL_PLL (1 << 2)
-
- /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should
- * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock
- * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.
- */
- #define USB_OPT_AUTO_PLL (0 << 2)
- //@}
-
- /** \name Endpoint/Pipe Type Masks */
- //@{
- /** Mask for a CONTROL type endpoint or pipe.
- *
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
- */
- #define EP_TYPE_CONTROL 0x00
-
- /** Mask for an ISOCHRONOUS type endpoint or pipe.
- *
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
- */
- #define EP_TYPE_ISOCHRONOUS 0x01
-
- /** Mask for a BULK type endpoint or pipe.
- *
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
- */
- #define EP_TYPE_BULK 0x02
-
- /** Mask for an INTERRUPT type endpoint or pipe.
- *
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
- */
- #define EP_TYPE_INTERRUPT 0x03
- //@}
-
- #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
- /** Constant for the maximum software timeout period of the USB data stream transfer functions
- * (both control and standard) when in either device or host mode. If the next packet of a stream
- * is not received or acknowledged within this time period, the stream function will fail.
- *
- * This value may be overridden in the user project makefile as the value of the
- * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.
- */
- #define USB_STREAM_TIMEOUT_MS 100
- #endif
-
- /* Inline Functions: */
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
- /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).
- *
- * \note This function is not available on some AVR models which do not support hardware VBUS monitoring.
- *
- * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.
- */
- static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_VBUS_GetStatus(void)
- {
- return ((USBSTA & (1 << VBUS)) ? true : false);
- }
- #endif
-
- /** Detaches the device from the USB bus. This has the effect of removing the device from any
- * attached host, ceasing USB communications. If no host is present, this prevents any host from
- * enumerating the device once attached until \ref USB_Attach() is called.
- */
- static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Detach(void)
- {
- UDCON |= (1 << DETACH);
- }
-
- /** Attaches the device to the USB bus. This announces the device's presence to any attached
- * USB host, starting the enumeration process. If no host is present, attaching the device
- * will allow for enumeration once a host is connected to the device.
- *
- * This is inexplicably also required for proper operation while in host mode, to enable the
- * attachment of a device to the host. This is despite the bit being located in the device-mode
- * register and despite the datasheet making no mention of its requirement in host mode.
- */
- static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Attach(void)
- {
- UDCON &= ~(1 << DETACH);
- }
-
- /* Function Prototypes: */
- /** Main function to initialize and start the USB interface. Once active, the USB interface will
- * allow for device connection to a host when in device mode, or for device enumeration while in
- * host mode.
- *
- * As the USB library relies on interrupts for the device and host mode enumeration processes,
- * the user must enable global interrupts before or shortly after this function is called. In
- * device mode, interrupts must be enabled within 500ms of this function being called to ensure
- * that the host does not time out whilst enumerating the device. In host mode, interrupts may be
- * enabled at the application's leisure however enumeration will not begin of an attached device
- * until after this has occurred.
- *
- * Calling this function when the USB interface is already initialized will cause a complete USB
- * interface reset and re-enumeration.
- *
- * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
- * from the \ref USB_Modes_t enum.
- *
- * \param[in] Options Mask indicating the options which should be used when initializing the USB
- * interface to control the USB interface's behaviour. This should be comprised of
- * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the
- * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device
- * mode speed.
- *
- * \note To reduce the FLASH requirements of the library if only device or host mode is required,
- * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY
- * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler
- * via the -D switch. If the mode is statically set, this parameter does not exist in the
- * function prototype.
- * \n\n
- *
- * \note To reduce the FLASH requirements of the library if only fixed settings are are required,
- * the options may be set statically in the same manner as the mode (see the Mode parameter of
- * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
- * defined to the appropriate options masks. When the options are statically set, this
- * parameter does not exist in the function prototype.
- * \n\n
- *
- * \note The mode parameter does not exist on devices where only one mode is possible, such as USB
- * AVR models which only implement the USB device mode in hardware.
- *
- * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
- */
- void USB_Init(
- #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
- const uint8_t Mode
- #endif
-
- #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)
- ,
- #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
- void
- #endif
-
- #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
- const uint8_t Options
- #endif
- );
-
- /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO
- * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface
- * is restarted with the \ref USB_Init() function.
- */
- void USB_Disable(void);
-
- /** Resets the interface, when already initialized. This will re-enumerate the device if already connected
- * to a host, or re-enumerate an already attached device when in host mode.
- */
- void USB_ResetInterface(void);
-
- /* Global Variables: */
- #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
- /** Indicates the mode that the USB interface is currently initialized to, a value from the
- * \ref USB_Modes_t enum.
- *
- * \note This variable should be treated as read-only in the user application, and never manually
- * changed in value.
- * \n\n
- *
- * \note When the controller is initialized into UID auto-detection mode, this variable will hold the
- * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller
- * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time
- * options, or a limitation of the USB controller in the chosen device model) this will evaluate to
- * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the
- * USB interface is not initialized.
- */
- extern volatile uint8_t USB_CurrentMode;
- #elif defined(USB_HOST_ONLY)
- #define USB_CurrentMode USB_MODE_Host
- #elif defined(USB_DEVICE_ONLY)
- #define USB_CurrentMode USB_MODE_Device
- #endif
-
- #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
- /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()
- * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.
- *
- * \note This variable should be treated as read-only in the user application, and never manually
- * changed in value.
- */
- extern volatile uint8_t USB_Options;
- #elif defined(USE_STATIC_OPTIONS)
- #define USB_Options USE_STATIC_OPTIONS
- #endif
-
- /* Enums: */
- /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
- * user application via \ref USB_CurrentMode.
- */
- enum USB_Modes_t
- {
- USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
- USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
- USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */
- USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the
- * USB connector.
- */
- };
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Function Prototypes: */
- #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
- #if defined(USB_CAN_BE_DEVICE)
- static void USB_Init_Device(void);
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- static void USB_Init_Host(void);
- #endif
- #endif
-
- /* Inline Functions: */
- static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_PLL_On(void)
- {
- PLLCSR = USB_PLL_PSC;
- PLLCSR |= (1 << PLLE);
- }
-
- static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_PLL_Off(void)
- {
- PLLCSR = 0;
- }
-
- static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_PLL_IsReady(void)
- {
- return ((PLLCSR & (1 << PLOCK)) ? true : false);
- }
-
- static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_REG_On(void)
- {
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- UHWCON |= (1 << UVREGE);
- #else
- REGCR &= ~(1 << REGDIS);
- #endif
- }
-
- static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_REG_Off(void)
- {
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- UHWCON &= ~(1 << UVREGE);
- #else
- REGCR |= (1 << REGDIS);
- #endif
- }
-
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTGPAD_On(void)
- {
- USBCON |= (1 << OTGPADE);
- }
-
- static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTGPAD_Off(void)
- {
- USBCON &= ~(1 << OTGPADE);
- }
- #endif
-
- static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
- static inline void USB_CLK_Freeze(void)
- {
- USBCON |= (1 << FRZCLK);
- }
-
- static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;
- static inline void USB_CLK_Unfreeze(void)
- {
- USBCON &= ~(1 << FRZCLK);
- }
-
- static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Controller_Enable(void)
- {
- USBCON |= (1 << USBE);
- }
-
- static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Controller_Disable(void)
- {
- USBCON &= ~(1 << USBE);
- }
-
- static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
- static inline void USB_Controller_Reset(void)
- {
- const uint8_t Temp = USBCON;
-
- USBCON = (Temp & ~(1 << USBE));
- USBCON = (Temp | (1 << USBE));
- }
-
- #if defined(USB_CAN_BE_BOTH)
- static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t USB_GetUSBModeFromUID(void)
- {
- if (USBSTA & (1 << ID))
- return USB_MODE_Device;
- else
- return USB_MODE_Host;
- }
- #endif
-
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
-/** @} */
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#define __INCLUDE_FROM_USB_CONTROLLER_C
+#include "../USBController.h"
+
+#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))
+volatile uint8_t USB_CurrentMode = USB_MODE_None;
+#endif
+
+#if !defined(USE_STATIC_OPTIONS)
+volatile uint8_t USB_Options;
+#endif
+
+void USB_Init(
+ #if defined(USB_CAN_BE_BOTH)
+ const uint8_t Mode
+ #endif
+
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))
+ ,
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
+ void
+ #endif
+
+ #if !defined(USE_STATIC_OPTIONS)
+ const uint8_t Options
+ #endif
+ )
+{
+ #if !defined(USE_STATIC_OPTIONS)
+ USB_Options = Options;
+ #endif
+
+ if (!(USB_Options & USB_OPT_REG_DISABLED))
+ USB_REG_On();
+ else
+ USB_REG_Off();
+
+ #if defined(USB_CAN_BE_BOTH)
+ if (Mode == USB_MODE_UID)
+ {
+ UHWCON |= (1 << UIDE);
+ USB_INT_Enable(USB_INT_IDTI);
+ USB_CurrentMode = USB_GetUSBModeFromUID();
+ }
+ else
+ {
+ USB_CurrentMode = Mode;
+ }
+ #endif
+
+ USB_IsInitialized = true;
+
+ USB_ResetInterface();
+}
+
+void USB_Disable(void)
+{
+ USB_INT_DisableAllInterrupts();
+ USB_INT_ClearAllInterrupts();
+
+ USB_Detach();
+ USB_Controller_Disable();
+
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))
+ USB_PLL_Off();
+
+ USB_REG_Off();
+
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USB_OTGPAD_Off();
+ #endif
+
+ #if defined(USB_CAN_BE_BOTH)
+ USB_CurrentMode = USB_MODE_None;
+ #endif
+
+ USB_IsInitialized = false;
+}
+
+void USB_ResetInterface(void)
+{
+ #if defined(USB_CAN_BE_BOTH)
+ bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0);
+ #endif
+
+ USB_INT_DisableAllInterrupts();
+ USB_INT_ClearAllInterrupts();
+
+ USB_Controller_Reset();
+
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))
+ {
+ #if defined(USB_SERIES_4_AVR)
+ PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));
+ #endif
+
+ USB_PLL_On();
+ while (!(USB_PLL_IsReady()));
+ }
+
+ #if defined(USB_CAN_BE_BOTH)
+ if (UIDModeSelectEnabled)
+ {
+ UHWCON |= (1 << UIDE);
+ USB_INT_Enable(USB_INT_IDTI);
+ }
+ #endif
+
+ USB_CLK_Unfreeze();
+
+ if (USB_CurrentMode == USB_MODE_Device)
+ {
+ #if defined(USB_CAN_BE_DEVICE)
+ #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ UHWCON |= (1 << UIMOD);
+ #endif
+
+ USB_Init_Device();
+ #endif
+ }
+ else if (USB_CurrentMode == USB_MODE_Host)
+ {
+ #if defined(USB_CAN_BE_HOST)
+ UHWCON &= ~(1 << UIMOD);
+
+ USB_Init_Host();
+ #endif
+ }
+
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ USB_OTGPAD_On();
+ #endif
+}
+
+#if defined(USB_CAN_BE_DEVICE)
+static void USB_Init_Device(void)
+{
+ USB_DeviceState = DEVICE_STATE_Unattached;
+ USB_ConfigurationNumber = 0;
+
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)
+ USB_RemoteWakeupEnabled = false;
+ #endif
+
+ #if !defined(NO_DEVICE_SELF_POWER)
+ USB_CurrentlySelfPowered = false;
+ #endif
+
+ #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)
+ USB_Descriptor_Device_t* DeviceDescriptorPtr;
+
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
+ {
+ #if defined(USE_RAM_DESCRIPTORS)
+ USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
+ #elif defined(USE_EEPROM_DESCRIPTORS)
+ USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
+ #else
+ USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
+ #endif
+ }
+ #endif
+
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
+ USB_Device_SetLowSpeed();
+ else
+ USB_Device_SetFullSpeed();
+
+ USB_INT_Enable(USB_INT_VBUS);
+ #endif
+
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
+ ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
+ ENDPOINT_BANK_SINGLE);
+
+ USB_INT_Clear(USB_INT_SUSPI);
+ USB_INT_Enable(USB_INT_SUSPI);
+ USB_INT_Enable(USB_INT_EORSTI);
+
+ USB_Attach();
+}
+#endif
+
+#if defined(USB_CAN_BE_HOST)
+static void USB_Init_Host(void)
+{
+ USB_HostState = HOST_STATE_Unattached;
+ USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
+
+ USB_Host_HostMode_On();
+
+ USB_Host_VBUS_Auto_Off();
+ USB_Host_VBUS_Manual_Enable();
+ USB_Host_VBUS_Manual_On();
+
+ USB_INT_Enable(USB_INT_SRPI);
+ USB_INT_Enable(USB_INT_BCERRI);
+
+ USB_Attach();
+}
+#endif
+
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB Controller definitions for the AVR8 microcontrollers.
+ * \copydetails Group_USBManagement_AVR8
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+/** \ingroup Group_USBManagement
+ * \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8)
+ * \brief USB Controller definitions for the AVR8 microcontrollers.
+ *
+ * Functions, macros, variables, enums and types related to the setup and management of the USB interface.
+ *
+ * @{
+ */
+
+#ifndef __USBCONTROLLER_AVR8_H__
+#define __USBCONTROLLER_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+ #include "../USBMode.h"
+ #include "../Events.h"
+ #include "../USBTask.h"
+ #include "../USBInterrupt.h"
+
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
+ #include "../Host.h"
+ #include "../OTG.h"
+ #include "../Pipe.h"
+ #include "../HostStandardReq.h"
+ #include "../PipeStream.h"
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
+ #include "../Device.h"
+ #include "../Endpoint.h"
+ #include "../DeviceStandardReq.h"
+ #include "../EndpointStream.h"
+ #endif
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks and Defines: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ #if !defined(F_CLOCK)
+ #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled USB controller clock in your project makefile.
+ #endif
+
+ #if (F_CLOCK == 8000000)
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
+ defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
+ defined(__AVR_ATmega32U2__))
+ #define USB_PLL_PSC 0
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+ #define USB_PLL_PSC 0
+ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
+ #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
+ #endif
+ #elif (F_CLOCK == 16000000)
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
+ defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
+ defined(__AVR_ATmega32U2__))
+ #define USB_PLL_PSC (1 << PLLP0)
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
+ #define USB_PLL_PSC (1 << PINDIV)
+ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
+ #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
+ #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
+ #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))
+ #endif
+ #endif
+
+ #if !defined(USB_PLL_PSC)
+ #error No PLL prescale value available for chosen F_CLOCK value and AVR model.
+ #endif
+
+ /* Public Interface - May be used in end-application: */
+ /* Macros: */
+ /** \name USB Controller Option Masks */
+ //@{
+ /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
+ * regulator should be enabled to regulate the data pin voltages to within the USB standard.
+ *
+ * \note See USB AVR data sheet for more information on the internal pad regulator.
+ */
+ #define USB_OPT_REG_DISABLED (1 << 1)
+
+ /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
+ * regulator should be disabled and the AVR's VCC level used for the data pads.
+ *
+ * \note See USB AVR data sheet for more information on the internal pad regulator.
+ */
+ #define USB_OPT_REG_ENABLED (0 << 1)
+
+ /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application
+ * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock
+ * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.
+ */
+ #define USB_OPT_MANUAL_PLL (1 << 2)
+
+ /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should
+ * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock
+ * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.
+ */
+ #define USB_OPT_AUTO_PLL (0 << 2)
+ //@}
+
+ /** \name Endpoint/Pipe Type Masks */
+ //@{
+ /** Mask for a CONTROL type endpoint or pipe.
+ *
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
+ */
+ #define EP_TYPE_CONTROL 0x00
+
+ /** Mask for an ISOCHRONOUS type endpoint or pipe.
+ *
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
+ */
+ #define EP_TYPE_ISOCHRONOUS 0x01
+
+ /** Mask for a BULK type endpoint or pipe.
+ *
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
+ */
+ #define EP_TYPE_BULK 0x02
+
+ /** Mask for an INTERRUPT type endpoint or pipe.
+ *
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.
+ */
+ #define EP_TYPE_INTERRUPT 0x03
+ //@}
+
+ #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
+ /** Constant for the maximum software timeout period of the USB data stream transfer functions
+ * (both control and standard) when in either device or host mode. If the next packet of a stream
+ * is not received or acknowledged within this time period, the stream function will fail.
+ *
+ * This value may be overridden in the user project makefile as the value of the
+ * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.
+ */
+ #define USB_STREAM_TIMEOUT_MS 100
+ #endif
+
+ /* Inline Functions: */
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
+ /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).
+ *
+ * \note This function is not available on some AVR models which do not support hardware VBUS monitoring.
+ *
+ * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.
+ */
+ static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_VBUS_GetStatus(void)
+ {
+ return ((USBSTA & (1 << VBUS)) ? true : false);
+ }
+ #endif
+
+ /** Detaches the device from the USB bus. This has the effect of removing the device from any
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from
+ * enumerating the device once attached until \ref USB_Attach() is called.
+ */
+ static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Detach(void)
+ {
+ UDCON |= (1 << DETACH);
+ }
+
+ /** Attaches the device to the USB bus. This announces the device's presence to any attached
+ * USB host, starting the enumeration process. If no host is present, attaching the device
+ * will allow for enumeration once a host is connected to the device.
+ *
+ * This is inexplicably also required for proper operation while in host mode, to enable the
+ * attachment of a device to the host. This is despite the bit being located in the device-mode
+ * register and despite the datasheet making no mention of its requirement in host mode.
+ */
+ static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Attach(void)
+ {
+ UDCON &= ~(1 << DETACH);
+ }
+
+ /* Function Prototypes: */
+ /** Main function to initialize and start the USB interface. Once active, the USB interface will
+ * allow for device connection to a host when in device mode, or for device enumeration while in
+ * host mode.
+ *
+ * As the USB library relies on interrupts for the device and host mode enumeration processes,
+ * the user must enable global interrupts before or shortly after this function is called. In
+ * device mode, interrupts must be enabled within 500ms of this function being called to ensure
+ * that the host does not time out whilst enumerating the device. In host mode, interrupts may be
+ * enabled at the application's leisure however enumeration will not begin of an attached device
+ * until after this has occurred.
+ *
+ * Calling this function when the USB interface is already initialized will cause a complete USB
+ * interface reset and re-enumeration.
+ *
+ * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value
+ * from the \ref USB_Modes_t enum.
+ *
+ * \param[in] Options Mask indicating the options which should be used when initializing the USB
+ * interface to control the USB interface's behaviour. This should be comprised of
+ * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the
+ * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device
+ * mode speed.
+ *
+ * \note To reduce the FLASH requirements of the library if only device or host mode is required,
+ * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY
+ * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler
+ * via the -D switch. If the mode is statically set, this parameter does not exist in the
+ * function prototype.
+ * \n\n
+ *
+ * \note To reduce the FLASH requirements of the library if only fixed settings are are required,
+ * the options may be set statically in the same manner as the mode (see the Mode parameter of
+ * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
+ * defined to the appropriate options masks. When the options are statically set, this
+ * parameter does not exist in the function prototype.
+ * \n\n
+ *
+ * \note The mode parameter does not exist on devices where only one mode is possible, such as USB
+ * AVR models which only implement the USB device mode in hardware.
+ *
+ * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
+ */
+ void USB_Init(
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
+ const uint8_t Mode
+ #endif
+
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)
+ ,
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))
+ void
+ #endif
+
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
+ const uint8_t Options
+ #endif
+ );
+
+ /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO
+ * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface
+ * is restarted with the \ref USB_Init() function.
+ */
+ void USB_Disable(void);
+
+ /** Resets the interface, when already initialized. This will re-enumerate the device if already connected
+ * to a host, or re-enumerate an already attached device when in host mode.
+ */
+ void USB_ResetInterface(void);
+
+ /* Global Variables: */
+ #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
+ /** Indicates the mode that the USB interface is currently initialized to, a value from the
+ * \ref USB_Modes_t enum.
+ *
+ * \note This variable should be treated as read-only in the user application, and never manually
+ * changed in value.
+ * \n\n
+ *
+ * \note When the controller is initialized into UID auto-detection mode, this variable will hold the
+ * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller
+ * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time
+ * options, or a limitation of the USB controller in the chosen device model) this will evaluate to
+ * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the
+ * USB interface is not initialized.
+ */
+ extern volatile uint8_t USB_CurrentMode;
+ #elif defined(USB_HOST_ONLY)
+ #define USB_CurrentMode USB_MODE_Host
+ #elif defined(USB_DEVICE_ONLY)
+ #define USB_CurrentMode USB_MODE_Device
+ #endif
+
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
+ /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()
+ * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.
+ *
+ * \note This variable should be treated as read-only in the user application, and never manually
+ * changed in value.
+ */
+ extern volatile uint8_t USB_Options;
+ #elif defined(USE_STATIC_OPTIONS)
+ #define USB_Options USE_STATIC_OPTIONS
+ #endif
+
+ /* Enums: */
+ /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the
+ * user application via \ref USB_CurrentMode.
+ */
+ enum USB_Modes_t
+ {
+ USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */
+ USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */
+ USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */
+ USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the
+ * USB connector.
+ */
+ };
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Function Prototypes: */
+ #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
+ #if defined(USB_CAN_BE_DEVICE)
+ static void USB_Init_Device(void);
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ static void USB_Init_Host(void);
+ #endif
+ #endif
+
+ /* Inline Functions: */
+ static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_PLL_On(void)
+ {
+ PLLCSR = USB_PLL_PSC;
+ PLLCSR |= (1 << PLLE);
+ }
+
+ static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_PLL_Off(void)
+ {
+ PLLCSR = 0;
+ }
+
+ static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline bool USB_PLL_IsReady(void)
+ {
+ return ((PLLCSR & (1 << PLOCK)) ? true : false);
+ }
+
+ static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_REG_On(void)
+ {
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ UHWCON |= (1 << UVREGE);
+ #else
+ REGCR &= ~(1 << REGDIS);
+ #endif
+ }
+
+ static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_REG_Off(void)
+ {
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ UHWCON &= ~(1 << UVREGE);
+ #else
+ REGCR |= (1 << REGDIS);
+ #endif
+ }
+
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTGPAD_On(void)
+ {
+ USBCON |= (1 << OTGPADE);
+ }
+
+ static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_OTGPAD_Off(void)
+ {
+ USBCON &= ~(1 << OTGPADE);
+ }
+ #endif
+
+ static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_CLK_Freeze(void)
+ {
+ USBCON |= (1 << FRZCLK);
+ }
+
+ static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_CLK_Unfreeze(void)
+ {
+ USBCON &= ~(1 << FRZCLK);
+ }
+
+ static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Controller_Enable(void)
+ {
+ USBCON |= (1 << USBE);
+ }
+
+ static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Controller_Disable(void)
+ {
+ USBCON &= ~(1 << USBE);
+ }
+
+ static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_Controller_Reset(void)
+ {
+ const uint8_t Temp = USBCON;
+
+ USBCON = (Temp & ~(1 << USBE));
+ USBCON = (Temp | (1 << USBE));
+ }
+
+ #if defined(USB_CAN_BE_BOTH)
+ static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
+ static inline uint8_t USB_GetUSBModeFromUID(void)
+ {
+ if (USBSTA & (1 << ID))
+ return USB_MODE_Device;
+ else
+ return USB_MODE_Host;
+ }
+ #endif
+
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
+/** @} */
+
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-#define __INCLUDE_FROM_USB_DRIVER
-#include "USBInterrupt.h"
-
-void USB_INT_DisableAllInterrupts(void)
-{
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- USBCON &= ~((1 << VBUSTE) | (1 << IDTE));
- #elif defined(USB_SERIES_4_AVR)
- USBCON &= ~(1 << VBUSTE);
- #endif
-
- #if defined(USB_CAN_BE_BOTH)
- OTGIEN = 0;
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- UHIEN = 0;
- #endif
-
- #if defined(USB_CAN_BE_DEVICE)
- UDIEN = 0;
- #endif
-}
-
-void USB_INT_ClearAllInterrupts(void)
-{
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- USBINT = 0;
- #endif
-
- #if defined(USB_CAN_BE_BOTH)
- OTGINT = 0;
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- UHINT = 0;
- #endif
-
- #if defined(USB_CAN_BE_DEVICE)
- UDINT = 0;
- #endif
-}
-
-ISR(USB_GEN_vect, ISR_BLOCK)
-{
- #if defined(USB_CAN_BE_DEVICE)
- #if !defined(NO_SOF_EVENTS)
- if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
- {
- USB_INT_Clear(USB_INT_SOFI);
-
- EVENT_USB_Device_StartOfFrame();
- }
- #endif
-
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
- if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))
- {
- USB_INT_Clear(USB_INT_VBUS);
-
- if (USB_VBUS_GetStatus())
- {
- USB_DeviceState = DEVICE_STATE_Powered;
- EVENT_USB_Device_Connect();
- }
- else
- {
- USB_DeviceState = DEVICE_STATE_Unattached;
- EVENT_USB_Device_Disconnect();
- }
- }
- #endif
-
- if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))
- {
- USB_INT_Clear(USB_INT_SUSPI);
-
- USB_INT_Disable(USB_INT_SUSPI);
- USB_INT_Enable(USB_INT_WAKEUPI);
-
- USB_CLK_Freeze();
-
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- USB_PLL_Off();
-
- #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
- USB_DeviceState = DEVICE_STATE_Unattached;
- EVENT_USB_Device_Disconnect();
- #else
- USB_DeviceState = DEVICE_STATE_Suspended;
- EVENT_USB_Device_Suspend();
- #endif
- }
-
- if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))
- {
- if (!(USB_Options & USB_OPT_MANUAL_PLL))
- {
- USB_PLL_On();
- while (!(USB_PLL_IsReady()));
- }
-
- USB_CLK_Unfreeze();
-
- USB_INT_Clear(USB_INT_WAKEUPI);
-
- USB_INT_Disable(USB_INT_WAKEUPI);
- USB_INT_Enable(USB_INT_SUSPI);
-
- if (USB_ConfigurationNumber)
- USB_DeviceState = DEVICE_STATE_Configured;
- else
- USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
-
- #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
- EVENT_USB_Device_Connect();
- #else
- EVENT_USB_Device_WakeUp();
- #endif
- }
-
- if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
- {
- USB_INT_Clear(USB_INT_EORSTI);
-
- USB_DeviceState = DEVICE_STATE_Default;
- USB_ConfigurationNumber = 0;
-
- USB_INT_Clear(USB_INT_SUSPI);
- USB_INT_Disable(USB_INT_SUSPI);
- USB_INT_Enable(USB_INT_WAKEUPI);
-
- Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
- ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
- ENDPOINT_BANK_SINGLE);
-
- #if defined(INTERRUPT_CONTROL_ENDPOINT)
- USB_INT_Enable(USB_INT_RXSTPI);
- #endif
-
- EVENT_USB_Device_Reset();
- }
- #endif
-
- #if defined(USB_CAN_BE_HOST)
- #if !defined(NO_SOF_EVENTS)
- if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))
- {
- USB_INT_Clear(USB_INT_HSOFI);
-
- EVENT_USB_Host_StartOfFrame();
- }
- #endif
-
- if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))
- {
- USB_INT_Clear(USB_INT_DDISCI);
- USB_INT_Clear(USB_INT_DCONNI);
- USB_INT_Disable(USB_INT_DDISCI);
-
- EVENT_USB_Host_DeviceUnattached();
-
- USB_ResetInterface();
- }
-
- if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))
- {
- USB_INT_Clear(USB_INT_VBERRI);
-
- USB_Host_VBUS_Manual_Off();
- USB_Host_VBUS_Auto_Off();
-
- EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);
- EVENT_USB_Host_DeviceUnattached();
-
- USB_HostState = HOST_STATE_Unattached;
- }
-
- if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI))
- {
- USB_INT_Clear(USB_INT_SRPI);
- USB_INT_Disable(USB_INT_SRPI);
-
- EVENT_USB_Host_DeviceAttached();
-
- USB_INT_Enable(USB_INT_DDISCI);
-
- USB_HostState = HOST_STATE_Powered;
- }
-
- if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))
- {
- USB_INT_Clear(USB_INT_BCERRI);
-
- EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
- EVENT_USB_Host_DeviceUnattached();
-
- USB_ResetInterface();
- }
- #endif
-
- #if defined(USB_CAN_BE_BOTH)
- if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))
- {
- USB_INT_Clear(USB_INT_IDTI);
-
- if (USB_DeviceState != DEVICE_STATE_Unattached)
- EVENT_USB_Device_Disconnect();
-
- if (USB_HostState != HOST_STATE_Unattached)
- EVENT_USB_Host_DeviceUnattached();
-
- USB_CurrentMode = USB_GetUSBModeFromUID();
- USB_ResetInterface();
-
- EVENT_USB_UIDChange();
- }
- #endif
-}
-
-#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)
-ISR(USB_COM_vect, ISR_BLOCK)
-{
- uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();
-
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
- USB_INT_Disable(USB_INT_RXSTPI);
-
- NONATOMIC_BLOCK(NONATOMIC_FORCEOFF)
- {
- USB_Device_ProcessControlRequest();
- }
-
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
- USB_INT_Enable(USB_INT_RXSTPI);
- Endpoint_SelectEndpoint(PrevSelectedEndpoint);
-}
-#endif
-
+++ /dev/null
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB Controller Interrupt definitions for the AVR8 microcontrollers.
- *
- * This file contains definitions required for the correct handling of low level USB service routine interrupts
- * from the USB controller.
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-#ifndef __USBINTERRUPT_AVR8_H__
-#define __USBINTERRUPT_AVR8_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
-
- /* Enable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Private Interface - For use in library only: */
- #if !defined(__DOXYGEN__)
- /* Macros: */
- #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE
- #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE
- #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE
- #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)
- #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)
-
- #define USB_INT_GET_EN_REG(EnableReg, EnableMask, FlagReg, FlagMask) EnableReg
- #define USB_INT_GET_EN_MASK(EnableReg, EnableMask, FlagReg, FlagMask) EnableMask
- #define USB_INT_GET_INT_REG(EnableReg, EnableMask, FlagReg, FlagMask) FlagReg
- #define USB_INT_GET_INT_MASK(EnableReg, EnableMask, FlagReg, FlagMask) FlagMask
-
- #define USB_INT_VBUS USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI)
- #define USB_INT_IDTI USBCON, (1 << IDTE) , USBINT, (1 << IDTI)
- #define USB_INT_WAKEUPI UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)
- #define USB_INT_SUSPI UDIEN , (1 << SUSPE) , UDINT , (1 << SUSPI)
- #define USB_INT_EORSTI UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI)
- #define USB_INT_DCONNI UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI)
- #define USB_INT_DDISCI UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI)
- #define USB_INT_BCERRI OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI)
- #define USB_INT_VBERRI OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI)
- #define USB_INT_SOFI UDIEN, (1 << SOFE) , UDINT , (1 << SOFI)
- #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI)
- #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI)
- #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI)
- #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)
-
- /* Includes: */
- #include "../USBMode.h"
- #include "../Events.h"
- #include "../USBController.h"
-
- /* Function Prototypes: */
- void USB_INT_ClearAllInterrupts(void);
- void USB_INT_DisableAllInterrupts(void);
- #endif
-
- /* Disable C linkage for C++ Compilers: */
- #if defined(__cplusplus)
- }
- #endif
-
-#endif
-
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+#define __INCLUDE_FROM_USB_DRIVER
+#include "../USBInterrupt.h"
+
+void USB_INT_DisableAllInterrupts(void)
+{
+ #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USBCON &= ~((1 << VBUSTE) | (1 << IDTE));
+ #elif defined(USB_SERIES_4_AVR)
+ USBCON &= ~(1 << VBUSTE);
+ #endif
+
+ #if defined(USB_CAN_BE_BOTH)
+ OTGIEN = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ UHIEN = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE)
+ UDIEN = 0;
+ #endif
+}
+
+void USB_INT_ClearAllInterrupts(void)
+{
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ USBINT = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_BOTH)
+ OTGINT = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ UHINT = 0;
+ #endif
+
+ #if defined(USB_CAN_BE_DEVICE)
+ UDINT = 0;
+ #endif
+}
+
+ISR(USB_GEN_vect, ISR_BLOCK)
+{
+ #if defined(USB_CAN_BE_DEVICE)
+ #if !defined(NO_SOF_EVENTS)
+ if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
+ {
+ USB_INT_Clear(USB_INT_SOFI);
+
+ EVENT_USB_Device_StartOfFrame();
+ }
+ #endif
+
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
+ if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))
+ {
+ USB_INT_Clear(USB_INT_VBUS);
+
+ if (USB_VBUS_GetStatus())
+ {
+ USB_DeviceState = DEVICE_STATE_Powered;
+ EVENT_USB_Device_Connect();
+ }
+ else
+ {
+ USB_DeviceState = DEVICE_STATE_Unattached;
+ EVENT_USB_Device_Disconnect();
+ }
+ }
+ #endif
+
+ if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))
+ {
+ USB_INT_Clear(USB_INT_SUSPI);
+
+ USB_INT_Disable(USB_INT_SUSPI);
+ USB_INT_Enable(USB_INT_WAKEUPI);
+
+ USB_CLK_Freeze();
+
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))
+ USB_PLL_Off();
+
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
+ USB_DeviceState = DEVICE_STATE_Unattached;
+ EVENT_USB_Device_Disconnect();
+ #else
+ USB_DeviceState = DEVICE_STATE_Suspended;
+ EVENT_USB_Device_Suspend();
+ #endif
+ }
+
+ if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))
+ {
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))
+ {
+ USB_PLL_On();
+ while (!(USB_PLL_IsReady()));
+ }
+
+ USB_CLK_Unfreeze();
+
+ USB_INT_Clear(USB_INT_WAKEUPI);
+
+ USB_INT_Disable(USB_INT_WAKEUPI);
+ USB_INT_Enable(USB_INT_SUSPI);
+
+ if (USB_ConfigurationNumber)
+ USB_DeviceState = DEVICE_STATE_Configured;
+ else
+ USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
+
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
+ EVENT_USB_Device_Connect();
+ #else
+ EVENT_USB_Device_WakeUp();
+ #endif
+ }
+
+ if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
+ {
+ USB_INT_Clear(USB_INT_EORSTI);
+
+ USB_DeviceState = DEVICE_STATE_Default;
+ USB_ConfigurationNumber = 0;
+
+ USB_INT_Clear(USB_INT_SUSPI);
+ USB_INT_Disable(USB_INT_SUSPI);
+ USB_INT_Enable(USB_INT_WAKEUPI);
+
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
+ ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
+ ENDPOINT_BANK_SINGLE);
+
+ #if defined(INTERRUPT_CONTROL_ENDPOINT)
+ USB_INT_Enable(USB_INT_RXSTPI);
+ #endif
+
+ EVENT_USB_Device_Reset();
+ }
+ #endif
+
+ #if defined(USB_CAN_BE_HOST)
+ #if !defined(NO_SOF_EVENTS)
+ if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))
+ {
+ USB_INT_Clear(USB_INT_HSOFI);
+
+ EVENT_USB_Host_StartOfFrame();
+ }
+ #endif
+
+ if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))
+ {
+ USB_INT_Clear(USB_INT_DDISCI);
+ USB_INT_Clear(USB_INT_DCONNI);
+ USB_INT_Disable(USB_INT_DDISCI);
+
+ EVENT_USB_Host_DeviceUnattached();
+
+ USB_ResetInterface();
+ }
+
+ if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))
+ {
+ USB_INT_Clear(USB_INT_VBERRI);
+
+ USB_Host_VBUS_Manual_Off();
+ USB_Host_VBUS_Auto_Off();
+
+ EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);
+ EVENT_USB_Host_DeviceUnattached();
+
+ USB_HostState = HOST_STATE_Unattached;
+ }
+
+ if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI))
+ {
+ USB_INT_Clear(USB_INT_SRPI);
+ USB_INT_Disable(USB_INT_SRPI);
+
+ EVENT_USB_Host_DeviceAttached();
+
+ USB_INT_Enable(USB_INT_DDISCI);
+
+ USB_HostState = HOST_STATE_Powered;
+ }
+
+ if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))
+ {
+ USB_INT_Clear(USB_INT_BCERRI);
+
+ EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);
+ EVENT_USB_Host_DeviceUnattached();
+
+ USB_ResetInterface();
+ }
+ #endif
+
+ #if defined(USB_CAN_BE_BOTH)
+ if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))
+ {
+ USB_INT_Clear(USB_INT_IDTI);
+
+ if (USB_DeviceState != DEVICE_STATE_Unattached)
+ EVENT_USB_Device_Disconnect();
+
+ if (USB_HostState != HOST_STATE_Unattached)
+ EVENT_USB_Host_DeviceUnattached();
+
+ USB_CurrentMode = USB_GetUSBModeFromUID();
+ USB_ResetInterface();
+
+ EVENT_USB_UIDChange();
+ }
+ #endif
+}
+
+#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)
+ISR(USB_COM_vect, ISR_BLOCK)
+{
+ uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();
+
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
+ USB_INT_Disable(USB_INT_RXSTPI);
+
+ NONATOMIC_BLOCK(NONATOMIC_FORCEOFF)
+ {
+ USB_Device_ProcessControlRequest();
+ }
+
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
+ USB_INT_Enable(USB_INT_RXSTPI);
+ Endpoint_SelectEndpoint(PrevSelectedEndpoint);
+}
+#endif
+
--- /dev/null
+/*
+ LUFA Library
+ Copyright (C) Dean Camera, 2011.
+
+ dean [at] fourwalledcubicle [dot] com
+ www.lufa-lib.org
+*/
+
+/*
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
+
+ Permission to use, copy, modify, distribute, and sell this
+ software and its documentation for any purpose is hereby granted
+ without fee, provided that the above copyright notice appear in
+ all copies and that both that the copyright notice and this
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+
+ The author disclaim all warranties with regard to this
+ software, including all implied warranties of merchantability
+ and fitness. In no event shall the author be liable for any
+ special, indirect or consequential damages or any damages
+ whatsoever resulting from loss of use, data or profits, whether
+ in an action of contract, negligence or other tortious action,
+ arising out of or in connection with the use or performance of
+ this software.
+*/
+
+/** \file
+ * \brief USB Controller Interrupt definitions for the AVR8 microcontrollers.
+ *
+ * This file contains definitions required for the correct handling of low level USB service routine interrupts
+ * from the USB controller.
+ *
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver
+ * dispatch header located in LUFA/Drivers/USB/USB.h.
+ */
+
+#ifndef __USBINTERRUPT_AVR8_H__
+#define __USBINTERRUPT_AVR8_H__
+
+ /* Includes: */
+ #include "../../../../Common/Common.h"
+
+ /* Enable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ extern "C" {
+ #endif
+
+ /* Preprocessor Checks: */
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
+ #endif
+
+ /* Private Interface - For use in library only: */
+ #if !defined(__DOXYGEN__)
+ /* Macros: */
+ #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE
+ #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE
+ #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE
+ #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)
+ #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)
+
+ #define USB_INT_GET_EN_REG(EnableReg, EnableMask, FlagReg, FlagMask) EnableReg
+ #define USB_INT_GET_EN_MASK(EnableReg, EnableMask, FlagReg, FlagMask) EnableMask
+ #define USB_INT_GET_INT_REG(EnableReg, EnableMask, FlagReg, FlagMask) FlagReg
+ #define USB_INT_GET_INT_MASK(EnableReg, EnableMask, FlagReg, FlagMask) FlagMask
+
+ #define USB_INT_VBUS USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI)
+ #define USB_INT_IDTI USBCON, (1 << IDTE) , USBINT, (1 << IDTI)
+ #define USB_INT_WAKEUPI UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)
+ #define USB_INT_SUSPI UDIEN , (1 << SUSPE) , UDINT , (1 << SUSPI)
+ #define USB_INT_EORSTI UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI)
+ #define USB_INT_DCONNI UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI)
+ #define USB_INT_DDISCI UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI)
+ #define USB_INT_BCERRI OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI)
+ #define USB_INT_VBERRI OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI)
+ #define USB_INT_SOFI UDIEN, (1 << SOFE) , UDINT , (1 << SOFI)
+ #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI)
+ #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI)
+ #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI)
+ #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)
+
+ /* Includes: */
+ #include "../USBMode.h"
+ #include "../Events.h"
+ #include "../USBController.h"
+
+ /* Function Prototypes: */
+ void USB_INT_ClearAllInterrupts(void);
+ void USB_INT_DisableAllInterrupts(void);
+ #endif
+
+ /* Disable C linkage for C++ Compilers: */
+ #if defined(__cplusplus)
+ }
+ #endif
+
+#endif
+
#include "Endpoint.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/Device.h"\r
+ #include "AVR8/Device_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/Device.h" \r
+ #include "UC3B/Device_UC3B.h"\r
#endif\r
\r
/* Preprocessor Checks: */\r
#include "../../../Common/Common.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/Endpoint.h"\r
+ #include "AVR8/Endpoint_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/Endpoint.h" \r
+ #include "UC3B/Endpoint_UC3B.h"\r
#endif\r
\r
/* Preprocessor Checks: */\r
#include "../../../Common/Common.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/Host.h"\r
+ #include "AVR8/Host_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/Host.h" \r
+ #include "UC3B/Host_UC3B.h"\r
#endif\r
\r
/* Preprocessor Checks: */\r
#include "../../../Common/Common.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/OTG.h"\r
+ #include "AVR8/OTG_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/OTG.h" \r
+ #include "UC3B/OTG_UC3B.h"\r
#endif\r
\r
/* Preprocessor Checks: */\r
#include "../../../Common/Common.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/Pipe.h"\r
+ #include "AVR8/Pipe_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/Pipe.h" \r
+ #include "UC3B/Pipe_UC3B.h"\r
#endif\r
\r
/* Preprocessor Checks: */\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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_USB_DRIVER\r
-#include "../USBMode.h"\r
-\r
-#if defined(USB_CAN_BE_DEVICE)\r
-\r
-#include "Device.h"\r
-\r
-void USB_Device_SendRemoteWakeup(void)\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
- AVR32_USBB.UDCON |= (1 << RMWKUP);\r
- while (!(AVR32_USBB.UDCON & (1 << RMWKUP)));\r
-}\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB Device definitions for the AVR32 UC3B microcontrollers.\r
- * \copydetails Group_Device_UC3B\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-/** \ingroup Group_Device\r
- * \defgroup Group_Device_UC3B Device Management (UC3B)\r
- * \brief USB Device definitions for the AVR32 UC3B microcontrollers.\r
- *\r
- * Architecture specific USB Device definitions for the Atmel 32-bit UC3B AVR microcontrollers.\r
- *\r
- * @{\r
- */\r
-\r
-#ifndef __USBDEVICE_UC3B_H__\r
-#define __USBDEVICE_UC3B_H__\r
-\r
- /* Includes: */\r
- #include "../../../../Common/Common.h"\r
- #include "../StdDescriptors.h"\r
- #include "../USBInterrupt.h"\r
- #include "../Endpoint.h"\r
- \r
- /* Preprocessor Checks: */\r
- #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
- #endif\r
-\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
- /* Public Interface - May be used in end-application: */\r
- /* Macros: */\r
- /** \name USB Device Mode Option Masks */\r
- //@{\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)\r
- /** Mask for the Options parameter of the \ref 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
- * \n\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 specification.\r
- */\r
- #define USB_DEVICE_OPT_LOWSPEED (1 << 0)\r
- #endif\r
-\r
- /** Mask for the Options parameter of the \ref 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
- \r
- #if (!defined(NO_INTERNAL_SERIAL) && \\r
- (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \\r
- defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \\r
- defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))\r
- /** String descriptor index for the device's unique serial number string descriptor within the device.\r
- * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
- * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain\r
- * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
- * will cause it to use the internal serial number.\r
- *\r
- * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial\r
- * number for the device.\r
- */\r
- #define USE_INTERNAL_SERIAL 0xDC\r
- #else\r
- #define USE_INTERNAL_SERIAL NO_DESCRIPTOR\r
- #endif \r
- \r
- /* Function Prototypes: */\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 \ref USB_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP compile\r
- * time option is used, this macro is unavailable.\r
- * \n\n\r
- *\r
- * \note The USB clock must be running for this function to operate. If the stack is initialized with\r
- * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running\r
- * before attempting to call this function.\r
- *\r
- * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.\r
- */\r
- void USB_Device_SendRemoteWakeup(void);\r
-\r
- /* Type Defines: */\r
- enum USB_Device_States_t\r
- {\r
- DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates\r
- * that the device is not currently connected to a host.\r
- */\r
- DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates\r
- * that the device is connected to a host, but enumeration has not\r
- * yet begun.\r
- */\r
- DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates\r
- * that the device's USB bus has been reset by the host and it is\r
- * now waiting for the host to begin the enumeration process.\r
- */\r
- DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates\r
- * that the device has been addressed by the USB Host, but is not\r
- * yet configured.\r
- */\r
- DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates\r
- * that the device has been enumerated by the host and is ready\r
- * for USB communications to begin.\r
- */\r
- DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates\r
- * that the USB bus has been suspended by the host, and the device\r
- * should power down to a minimal power level until the bus is\r
- * resumed.\r
- */\r
- };\r
-\r
- /* Inline Functions: */\r
- /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)\r
- * the frame number is incremented by one.\r
- */\r
- static inline uint16_t USB_Device_GetFrameNumber(void)\r
- {\r
- return AVR32_USBB.UDFNUM.fnum;\r
- }\r
-\r
- #if !defined(NO_SOF_EVENTS)\r
- /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
- * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
- * at the start of each USB frame when enumerated in device mode.\r
- *\r
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
- */\r
- static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_EnableSOFEvents(void)\r
- {\r
- USB_INT_Enable(USB_INT_SOFI);\r
- }\r
-\r
- /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
- * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
- *\r
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
- */\r
- static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_DisableSOFEvents(void)\r
- {\r
- USB_INT_Disable(USB_INT_SOFI);\r
- }\r
- #endif\r
-\r
- /* Private Interface - For use in library only: */\r
- #if !defined(__DOXYGEN__)\r
- /* Inline Functions: */\r
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
- static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_SetLowSpeed(void)\r
- {\r
- AVR32_USBB.UDCON.ls = true;\r
- }\r
-\r
- static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_SetFullSpeed(void)\r
- {\r
- AVR32_USBB.UDCON.ls = false;\r
- }\r
- #endif\r
-\r
- static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
- {\r
- AVR32_USBB.UDCON = (AVR32_USBB_UDCON & ~AVR32_USBB_UDADDR) | Address;\r
- AVR32_USBB.UDCON.adden = true;\r
- }\r
-\r
- static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE;\r
- static inline bool USB_Device_IsAddressSet(void)\r
- {\r
- return AVR32_USBB.UDCON.adden;\r
- }\r
- #endif\r
-\r
-#endif\r
-\r
-/** @} */\r
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Device.h"\r
+\r
+void USB_Device_SendRemoteWakeup(void)\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
+ AVR32_USBB.UDCON |= (1 << RMWKUP);\r
+ while (!(AVR32_USBB.UDCON & (1 << RMWKUP)));\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB Device definitions for the AVR32 UC3B microcontrollers.\r
+ * \copydetails Group_Device_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Device\r
+ * \defgroup Group_Device_UC3B Device Management (UC3B)\r
+ * \brief USB Device definitions for the AVR32 UC3B microcontrollers.\r
+ *\r
+ * Architecture specific USB Device definitions for the Atmel 32-bit UC3B AVR microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBDEVICE_UC3B_H__\r
+#define __USBDEVICE_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../USBInterrupt.h"\r
+ #include "../Endpoint.h"\r
+ \r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\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
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Device Mode Option Masks */\r
+ //@{\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)\r
+ /** Mask for the Options parameter of the \ref 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
+ * \n\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 specification.\r
+ */\r
+ #define USB_DEVICE_OPT_LOWSPEED (1 << 0)\r
+ #endif\r
+\r
+ /** Mask for the Options parameter of the \ref 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
+ \r
+ #if (!defined(NO_INTERNAL_SERIAL) && \\r
+ (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \\r
+ defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \\r
+ defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))\r
+ /** String descriptor index for the device's unique serial number string descriptor within the device.\r
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain\r
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
+ * will cause it to use the internal serial number.\r
+ *\r
+ * On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial\r
+ * number for the device.\r
+ */\r
+ #define USE_INTERNAL_SERIAL 0xDC\r
+ #else\r
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR\r
+ #endif \r
+ \r
+ /* Function Prototypes: */\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 \ref USB_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP compile\r
+ * time option is used, this macro is unavailable.\r
+ * \n\n\r
+ *\r
+ * \note The USB clock must be running for this function to operate. If the stack is initialized with\r
+ * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running\r
+ * before attempting to call this function.\r
+ *\r
+ * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.\r
+ */\r
+ void USB_Device_SendRemoteWakeup(void);\r
+\r
+ /* Type Defines: */\r
+ enum USB_Device_States_t\r
+ {\r
+ DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates\r
+ * that the device is not currently connected to a host.\r
+ */\r
+ DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates\r
+ * that the device is connected to a host, but enumeration has not\r
+ * yet begun.\r
+ */\r
+ DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates\r
+ * that the device's USB bus has been reset by the host and it is\r
+ * now waiting for the host to begin the enumeration process.\r
+ */\r
+ DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates\r
+ * that the device has been addressed by the USB Host, but is not\r
+ * yet configured.\r
+ */\r
+ DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates\r
+ * that the device has been enumerated by the host and is ready\r
+ * for USB communications to begin.\r
+ */\r
+ DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates\r
+ * that the USB bus has been suspended by the host, and the device\r
+ * should power down to a minimal power level until the bus is\r
+ * resumed.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)\r
+ * the frame number is incremented by one.\r
+ */\r
+ static inline uint16_t USB_Device_GetFrameNumber(void)\r
+ {\r
+ return AVR32_USBB.UDFNUM.fnum;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when enumerated in device mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_SOFI);\r
+ }\r
+\r
+ /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_SOFI);\r
+ }\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Inline Functions: */\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetLowSpeed(void)\r
+ {\r
+ AVR32_USBB.UDCON.ls = true;\r
+ }\r
+\r
+ static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetFullSpeed(void)\r
+ {\r
+ AVR32_USBB.UDCON.ls = false;\r
+ }\r
+ #endif\r
+\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ AVR32_USBB.UDCON = (AVR32_USBB_UDCON & ~AVR32_USBB_UDADDR) | Address;\r
+ AVR32_USBB.UDCON.adden = true;\r
+ }\r
+\r
+ static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Device_IsAddressSet(void)\r
+ {\r
+ return AVR32_USBB.UDCON.adden;\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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_USB_DRIVER\r
-#include "../USBMode.h"\r
-\r
-#if defined(USB_CAN_BE_DEVICE)\r
-\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
-uint8_t USB_SelectedEndpoint = ENDPOINT_CONTROLEP;\r
-\r
-bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
- const uint32_t UECFGXData)\r
-{\r
-#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)\r
- Endpoint_SelectEndpoint(Number);\r
- Endpoint_EnableEndpoint();\r
-\r
- *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0;\r
- *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = UECFGXData;\r
-\r
- return Endpoint_IsConfigured();\r
-#else \r
- for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
- {\r
- uint32_t UECFGXTemp;\r
- uint32_t UEIENXTemp;\r
-\r
- Endpoint_SelectEndpoint(EPNum);\r
- \r
- if (EPNum == Number)\r
- {\r
- UECFGXTemp = UECFGXData;\r
- UEIENXTemp = 0;\r
- }\r
- else\r
- {\r
- UECFGXTemp = *((uint32_t*)AVR32_USBB_UECFG0)[EPNum];\r
- UEIENXTemp = *((uint32_t*)AVR32_USBB_UEINT0)[EPNum];\r
- }\r
-\r
- if (!(UECFGXTemp & AVR32_USBB_ALLOC))\r
- continue;\r
-\r
- Endpoint_DisableEndpoint();\r
- *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] &= ~AVR32_USBB_ALLOC;\r
-\r
- Endpoint_EnableEndpoint();\r
- *((uint32_t*)AVR32_USBB_UECFG0)[EPNum] = UECFGXTemp;\r
- *((uint32_t*)AVR32_USBB_UEINT0)[EPNum] = UEINTXTemp;\r
- \r
- if (!(Endpoint_IsConfigured()))\r
- return false; \r
- }\r
- \r
- Endpoint_SelectEndpoint(Number);\r
- return true;\r
-#endif\r
-}\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
- UECFG1X = 0;\r
- Endpoint_DisableEndpoint();\r
- }\r
-}\r
-\r
-void Endpoint_ClearStatusStage(void)\r
-{\r
- if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)\r
- {\r
- while (!(Endpoint_IsOUTReceived()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
-\r
- Endpoint_ClearOUT();\r
- }\r
- else\r
- {\r
- while (!(Endpoint_IsINReady()))\r
- {\r
- if (USB_DeviceState == DEVICE_STATE_Unattached)\r
- return;\r
- }\r
-\r
- Endpoint_ClearIN();\r
- }\r
-}\r
-\r
-#if !defined(CONTROL_ONLY_DEVICE)\r
-uint8_t Endpoint_WaitUntilReady(void)\r
-{\r
- #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
- uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
- #else\r
- uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
- #endif\r
-\r
- uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();\r
-\r
- for (;;)\r
- {\r
- if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)\r
- {\r
- if (Endpoint_IsINReady())\r
- return ENDPOINT_READYWAIT_NoError;\r
- }\r
- else\r
- {\r
- if (Endpoint_IsOUTReceived())\r
- return ENDPOINT_READYWAIT_NoError;\r
- }\r
- \r
- uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
-\r
- if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
- return ENDPOINT_READYWAIT_DeviceDisconnected;\r
- else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
- return ENDPOINT_READYWAIT_BusSuspended;\r
- else if (Endpoint_IsStalled())\r
- return ENDPOINT_READYWAIT_EndpointStalled;\r
-\r
- uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();\r
-\r
- if (CurrentFrameNumber != PreviousFrameNumber)\r
- {\r
- PreviousFrameNumber = CurrentFrameNumber;\r
-\r
- if (!(TimeoutMSRem--))\r
- return ENDPOINT_READYWAIT_Timeout;\r
- }\r
- }\r
-}\r
-#endif\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB Endpoint definitions for the UC3B microcontrollers.\r
- * \copydetails Group_EndpointManagement_UC3B\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-/** \ingroup Group_EndpointRW\r
- * \defgroup Group_EndpointRW_UC3B Endpoint Data Reading and Writing (UC3B)\r
- * \brief Endpoint data read/write definitions for the Atmel AVR32 UC3B architecture.\r
- *\r
- * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.\r
- */\r
-\r
-/** \ingroup Group_EndpointPrimitiveRW\r
- * \defgroup Group_EndpointPrimitiveRW_UC3B Read/Write of Primitive Data Types (UC3B)\r
- * \brief Endpoint primative read/write definitions for the Atmel UC3B architecture.\r
- *\r
- * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
- * from and to endpoints.\r
- */\r
-\r
-/** \ingroup Group_EndpointPacketManagement\r
- * \defgroup Group_EndpointPacketManagement_UC3B Endpoint Packet Management (UC3B)\r
- * \brief Endpoint packet management definitions for the Atmel UC3B architecture.\r
- *\r
- * Functions, macros, variables, enums and types related to packet management of endpoints.\r
- */\r
-\r
-/** \ingroup Group_EndpointManagement\r
- * \defgroup Group_EndpointManagement_UC3B Endpoint Management (UC3B)\r
- * \brief Endpoint management definitions for the Atmel UC3B architecture.\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/receive functions for various data types.\r
- *\r
- * @{\r
- */\r
-\r
-#ifndef __ENDPOINT_UC3B_H__\r
-#define __ENDPOINT_UC3B_H__\r
-\r
- /* Includes: */\r
- #include "../../../../Common/Common.h"\r
- #include "../USBTask.h"\r
- #include "../USBInterrupt.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_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
- #endif\r
-\r
- /* Private Interface - For use in library only: */\r
- #if !defined(__DOXYGEN__)\r
- /* Macros: */\r
- #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex)\r
- #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails)\r
- #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize)\r
-\r
- #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex)\r
- #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)\r
- #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)\r
-\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- #define ENDPOINT_DETAILS_MAXEP 7\r
-\r
- #define ENDPOINT_DETAILS_EP0 64, 2\r
- #define ENDPOINT_DETAILS_EP1 256, 2\r
- #define ENDPOINT_DETAILS_EP2 64, 2\r
- #define ENDPOINT_DETAILS_EP3 64, 2\r
- #define ENDPOINT_DETAILS_EP4 64, 2\r
- #define ENDPOINT_DETAILS_EP5 64, 2\r
- #define ENDPOINT_DETAILS_EP6 64, 2\r
- #else\r
- #define ENDPOINT_DETAILS_MAXEP 5\r
-\r
- #define ENDPOINT_DETAILS_EP0 64, 2\r
- #define ENDPOINT_DETAILS_EP1 64, 1\r
- #define ENDPOINT_DETAILS_EP2 64, 1\r
- #define ENDPOINT_DETAILS_EP3 64, 2\r
- #define ENDPOINT_DETAILS_EP4 64, 2\r
- #endif\r
-\r
- /* Inline Functions: */\r
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
- ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
- {\r
- uint8_t MaskVal = 0;\r
- uint16_t CheckBytes = 8;\r
-\r
- while (CheckBytes < Bytes)\r
- {\r
- MaskVal++;\r
- CheckBytes <<= 1;\r
- }\r
-\r
- return (MaskVal << AVR32_USBB_EPSIZE_OFFSET);\r
- }\r
-\r
- /* Function Prototypes: */\r
- void Endpoint_ClearEndpoints(void);\r
- bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
- const uint32_t UECFGXData);\r
- \r
- /* External Variables: */\r
- extern uint8_t USB_SelectedEndpoint;\r
- #endif\r
-\r
- /* Public Interface - May be used in end-application: */\r
- /* Macros: */\r
- /** \name Endpoint Direction Masks */\r
- //@{\r
- /** Endpoint data direction mask for \ref 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 << AVR32_USBB_UECFG0_EPDIR_OFFSET)\r
-\r
- /** Endpoint data direction mask for \ref 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 << AVR32_USBB_UECFG0_EPDIR_OFFSET)\r
- //@}\r
- \r
- /** \name Endpoint Bank Mode Masks */\r
- //@{\r
- /** Mask for the bank mode selection for the \ref 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 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
-\r
- /** Mask for the bank mode selection for the \ref 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 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
-\r
- /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
- * that the endpoint should have three 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 remaining banks.\r
- */\r
- #define ENDPOINT_BANK_TRIPLE (2 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
- //@}\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
- #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
- /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size\r
- * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.\r
- */\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 0x07\r
-\r
- /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's\r
- * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.\r
- */\r
- #define ENDPOINT_EPDIR_MASK 0x80\r
-\r
- /** Retrives the maximum bank size in bytes of a given endpoint.\r
- *\r
- * \note This macro will only work correctly on endpoint indexes that are compile-time constants\r
- * defined by the preprocessor.\r
- *\r
- * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)\r
- */\r
- #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex)\r
-\r
- /** Retrieves the total number of banks supported by the given endpoint.\r
- *\r
- * \note This macro will only work correctly on endpoint indexes that are compile-time constants\r
- * defined by the preprocessor.\r
- *\r
- * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)\r
- */\r
- #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex)\r
-\r
- #if !defined(CONTROL_ONLY_DEVICE) || 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 ENDPOINT_DETAILS_MAXEP\r
- #else\r
- #define ENDPOINT_TOTAL_ENDPOINTS 1\r
- #endif\r
-\r
- /* Enums: */\r
- /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.\r
- *\r
- * \ingroup Group_EndpointRW_AVR8\r
- */\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_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
- * no USB endpoint traffic can occur until the bus\r
- * has resumed.\r
- */\r
- ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet\r
- * within the software timeout period set by the\r
- * \ref USB_STREAM_TIMEOUT_MS macro.\r
- */\r
- };\r
-\r
- /* Inline Functions: */\r
- /** Configures the specified endpoint number with the given endpoint type, direction, bank size\r
- * and banking mode. Once configured, the endpoint may be read from or written to, depending\r
- * on its direction.\r
- *\r
- * \param[in] Number Endpoint number to configure. This must be more than 0 and less than\r
- * \ref ENDPOINT_TOTAL_ENDPOINTS.\r
- *\r
- * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types\r
- * are available on Low Speed USB devices - refer to the USB 2.0 specification.\r
- *\r
- * \param[in] Direction Endpoint data direction, either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN.\r
- * All endpoints (except Control type) are unidirectional - data may only be read\r
- * from or written to the endpoint bank based on its direction, not both.\r
- *\r
- * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted\r
- * to the USB host, or after they have been received from the USB host (depending on\r
- * the endpoint's data direction). The bank size must indicate the maximum packet size\r
- * that the endpoint can handle.\r
- *\r
- * \param[in] Banks Number of banks to use for the endpoint being configured, an \c ENDPOINT_BANK_* mask.\r
- * More banks uses more USB DPRAM, but offers better performance. Isochronous type\r
- * endpoints <b>must</b> have at least two banks.\r
- *\r
- * \note When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints <b>must</b> be configured in\r
- * ascending order, or bank corruption will occur.\r
- * \n\n\r
- *\r
- * \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's\r
- * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.\r
- * \n\n\r
- *\r
- * \note The default control endpoint should not be manually configured by the user application, as\r
- * it is automatically configured by the library internally.\r
- * \n\n\r
- *\r
- * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint\r
- * which failed to reconfigure correctly will be selected.\r
- *\r
- * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
- */\r
- static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,\r
- const uint8_t Type,\r
- const uint8_t Direction,\r
- const uint16_t Size,\r
- const uint8_t Banks) ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,\r
- const uint8_t Type,\r
- const uint8_t Direction,\r
- const uint16_t Size,\r
- const uint8_t Banks)\r
- {\r
- return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << AVR32_USBB_EPTYPE_OFFSET) | AVR32_USBB_ALLOC |\r
- (Direction << AVR32_USBB_EPDIR_OFFSET) |\r
- (Banks << AVR32_USBB_EPBK_OFFSET) |\r
- Endpoint_BytesToEPSizeMask(Size)));\r
- }\r
-\r
- /** Indicates the number of bytes currently stored in the current endpoint's selected bank.\r
- *\r
- * \note The return width of this function may differ, depending on the maximum endpoint bank size\r
- * of the selected AVR model.\r
- *\r
- * \ingroup Group_EndpointRW_AVR8\r
- *\r
- * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.\r
- */\r
- static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint16_t Endpoint_BytesInEndpoint(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].byct;\r
- }\r
-\r
- /** Get 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
- * \return Index of the currently selected endpoint.\r
- */\r
- static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Endpoint_GetCurrentEndpoint(void)\r
- {\r
- return USB_SelectedEndpoint;\r
- }\r
-\r
- /** Selects the given endpoint number. If the address from the device descriptors is used, the\r
- * value should be masked with the \ref 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
- * \param[in] EndpointNumber Endpoint number to select.\r
- */\r
- static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber)\r
- {\r
- USB_SelectedEndpoint = EndpointNumber;\r
- }\r
-\r
- /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's\r
- * data In and Out pointers to the bank's contents.\r
- *\r
- * \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset.\r
- */\r
- static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)\r
- {\r
- AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_OFFSET << EndpointNumber);\r
- AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_OFFSET << EndpointNumber);\r
- }\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 via \ref Endpoint_ConfigureEndpoint().\r
- */\r
- static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_EnableEndpoint(void)\r
- {\r
- AVR32_USBB.uerst |= (AVR32_USBB_EPEN0 << USB_SelectedEndpoint);\r
- }\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
- static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_DisableEndpoint(void)\r
- {\r
- AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint);\r
- }\r
-\r
- /** Determines if the currently selected endpoint is enabled, but not necessarily configured.\r
- *\r
- * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.\r
- */\r
- static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsEnabled(void)\r
- {\r
- return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint)) ? true : false);\r
- }\r
-\r
- /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for\r
- * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the\r
- * \ref Endpoint_ClearOUT() command.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \return Total number of busy banks in the selected endpoint.\r
- */\r
- static inline uint8_t Endpoint_GetBusyBanks(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].nbusybk;\r
- }\r
-\r
- /** Aborts all pending IN transactions on the currently selected endpoint, once the bank\r
- * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function\r
- * will terminate all queued transactions, resetting the endpoint banks ready for a new\r
- * packet.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- */\r
- static inline void Endpoint_AbortPendingIN(void)\r
- {\r
- while (Endpoint_GetBusyBanks() != 0)\r
- {\r
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].killbk = true;\r
- while (((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0)[USB_SelectedEndpoint].killbk);\r
- }\r
- }\r
- \r
- /** Determines 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 IN\r
- * direction). This function will return false if an error has occurred in the endpoint, if the endpoint\r
- * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN\r
- * direction and the endpoint bank is full.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending\r
- * on its direction.\r
- */\r
- static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsReadWriteAllowed(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].rwall;\r
- }\r
-\r
- /** Determines if the currently selected endpoint is configured.\r
- *\r
- * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.\r
- */\r
- static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsConfigured(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].cfgok;\r
- }\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 <tt>(1 << <i>{Endpoint Number}</i>)</tt>.\r
- *\r
- * \return Mask whose bits indicate which endpoints have interrupted.\r
- */\r
- static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Endpoint_GetEndpointInterrupts(void)\r
- {\r
- return ((AVR32_USBB.udint & (AVR32_USBB_EP6INTES_MASK | AVR32_USBB_EP5INTES_MASK |\r
- AVR32_USBB_EP4INTES_MASK | AVR32_USBB_EP3INTES_MASK |\r
- AVR32_USBB_EP2INTES_MASK | AVR32_USBB_EP1INTES_MASK |\r
- AVR32_USBB_EP0INTES_MASK)) >> AVR32_USBB_EP0INT_OFFSET);\r
- }\r
-\r
- /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type\r
- * endpoints).\r
- *\r
- * \param[in] EndpointNumber Index of the endpoint whose interrupt flag should be tested.\r
- *\r
- * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise.\r
- */\r
- static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber)\r
- {\r
- return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false);\r
- }\r
-\r
- /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.\r
- */\r
- static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsINReady(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].txini;\r
- }\r
-\r
- /** Determines if the selected OUT endpoint has received new packet from the host.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.\r
- */\r
- static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsOUTReceived(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].rxouti;\r
- }\r
-\r
- /** Determines if the current CONTROL type endpoint has received a SETUP packet.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.\r
- */\r
- static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsSETUPReceived(void)\r
- {\r
- return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].rxstpi;\r
- }\r
-\r
- /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the\r
- * endpoint for the next packet.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \note This is not applicable for non CONTROL type endpoints.\r
- */\r
- static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_ClearSETUP(void)\r
- {\r
- ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxstpi = true;\r
- }\r
-\r
- /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the\r
- * next packet and switching to the alternative endpoint bank if double banked.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- */\r
- static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_ClearIN(void)\r
- {\r
- ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].txini = true;\r
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;\r
- }\r
-\r
- /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint\r
- * for the next packet and switching to the alternative endpoint bank if double banked.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- */\r
- static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_ClearOUT(void)\r
- {\r
- ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxouti = true;\r
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;\r
- }\r
-\r
- /** Stalls the current endpoint, indicating to the host that a logical problem occurred 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 sequence.\r
- *\r
- * The currently selected endpoint remains stalled until either the \ref 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
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- */\r
- static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_StallTransaction(void)\r
- {\r
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].stallrq = true;\r
- }\r
-\r
- /** Clears the STALL condition on the currently selected endpoint.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- */\r
- static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_ClearStall(void)\r
- {\r
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].stallrq = true;\r
- }\r
-\r
- /** Determines if the currently selected endpoint is stalled, false otherwise.\r
- *\r
- * \ingroup Group_EndpointPacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.\r
- */\r
- static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Endpoint_IsStalled(void)\r
- {\r
- return ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0)[USB_SelectedEndpoint].stallrq;\r
- }\r
-\r
- /** Resets the data toggle of the currently selected endpoint. */\r
- static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_ResetDataToggle(void)\r
- {\r
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].rstdt = true;\r
- }\r
-\r
- /** Determines the currently selected endpoint's direction.\r
- *\r
- * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.\r
- */\r
- static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Endpoint_GetEndpointDirection(void)\r
- {\r
- return (((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] & AVR32_USBB_UECFG0_EPDIR_MASK);\r
- }\r
-\r
- /** Sets the direction of the currently selected endpoint.\r
- *\r
- * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask.\r
- */\r
- static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask)\r
- {\r
- ((avr32_usbb_uecfg0_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint].epdir = (DirectionMask == ENDPOINT_DIR_IN);\r
- }\r
-\r
- /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \return Next byte in the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Endpoint_Read_Byte(void)\r
- {\r
- return *((uint8_t*)AVR32_USBB_EP_DATA);\r
- }\r
-\r
- /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \param[in] Byte Next byte to write into the the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
- {\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = Byte;\r
- }\r
-\r
- /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- */\r
- static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Discard_Byte(void)\r
- {\r
- uint8_t Dummy;\r
-\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- }\r
-\r
- /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
- * direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \return Next word in the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint16_t Endpoint_Read_Word_LE(void)\r
- {\r
- union\r
- {\r
- uint16_t Word;\r
- uint8_t Bytes[2];\r
- } Data;\r
-\r
- Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
-\r
- return Data.Word;\r
- }\r
-\r
- /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT\r
- * direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \return Next word in the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint16_t Endpoint_Read_Word_BE(void)\r
- {\r
- union\r
- {\r
- uint16_t Word;\r
- uint8_t Bytes[2];\r
- } Data;\r
-\r
- Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
-\r
- return Data.Word;\r
- }\r
-\r
- /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN\r
- * direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Write_Word_LE(const uint16_t Word)\r
- {\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (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
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Write_Word_BE(const uint16_t Word)\r
- {\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);\r
- }\r
-\r
- /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- */\r
- static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Discard_Word(void)\r
- {\r
- uint8_t Dummy;\r
-\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- }\r
-\r
- /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
- * direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \return Next double word in the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);\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
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \return Next double word in the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\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
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)\r
- {\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);\r
- }\r
-\r
- /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
- * direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- *\r
- * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.\r
- */\r
- static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)\r
- {\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);\r
- *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);\r
- }\r
-\r
- /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
- *\r
- * \ingroup Group_EndpointPrimitiveRW_AVR8\r
- */\r
- static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE;\r
- static inline void Endpoint_Discard_DWord(void)\r
- {\r
- uint8_t Dummy;\r
-\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
- Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\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 \c 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
- * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token\r
- * be used in the device 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
- /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,\r
- * with respect to the data direction. This is a convenience function which can be used to\r
- * simplify user control request handling.\r
- */\r
- void Endpoint_ClearStatusStage(void);\r
-\r
- /** Spin-loops 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
- * \ingroup Group_EndpointRW_AVR8\r
- *\r
- * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
- */\r
- uint8_t Endpoint_WaitUntilReady(void);\r
-\r
- /* Disable C linkage for C++ Compilers: */\r
- #if defined(__cplusplus)\r
- }\r
- #endif\r
-\r
-#endif\r
-\r
-/** @} */\r
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\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
+uint8_t USB_SelectedEndpoint = ENDPOINT_CONTROLEP;\r
+\r
+bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
+ const uint32_t UECFGXData)\r
+{\r
+#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)\r
+ Endpoint_SelectEndpoint(Number);\r
+ Endpoint_EnableEndpoint();\r
+\r
+ *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0;\r
+ *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = UECFGXData;\r
+\r
+ return Endpoint_IsConfigured();\r
+#else \r
+ for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ uint32_t UECFGXTemp;\r
+ uint32_t UEIENXTemp;\r
+\r
+ Endpoint_SelectEndpoint(EPNum);\r
+ \r
+ if (EPNum == Number)\r
+ {\r
+ UECFGXTemp = UECFGXData;\r
+ UEIENXTemp = 0;\r
+ }\r
+ else\r
+ {\r
+ UECFGXTemp = *((uint32_t*)AVR32_USBB_UECFG0)[EPNum];\r
+ UEIENXTemp = *((uint32_t*)AVR32_USBB_UEINT0)[EPNum];\r
+ }\r
+\r
+ if (!(UECFGXTemp & AVR32_USBB_ALLOC))\r
+ continue;\r
+\r
+ Endpoint_DisableEndpoint();\r
+ *((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] &= ~AVR32_USBB_ALLOC;\r
+\r
+ Endpoint_EnableEndpoint();\r
+ *((uint32_t*)AVR32_USBB_UECFG0)[EPNum] = UECFGXTemp;\r
+ *((uint32_t*)AVR32_USBB_UEINT0)[EPNum] = UEINTXTemp;\r
+ \r
+ if (!(Endpoint_IsConfigured()))\r
+ return false; \r
+ }\r
+ \r
+ Endpoint_SelectEndpoint(Number);\r
+ return true;\r
+#endif\r
+}\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
+ UECFG1X = 0;\r
+ Endpoint_DisableEndpoint();\r
+ }\r
+}\r
+\r
+void Endpoint_ClearStatusStage(void)\r
+{\r
+ if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)\r
+ {\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ else\r
+ {\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearIN();\r
+ }\r
+}\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)\r
+ {\r
+ if (Endpoint_IsINReady())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Endpoint_IsOUTReceived())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+ \r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_READYWAIT_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_READYWAIT_BusSuspended;\r
+ else if (Endpoint_IsStalled())\r
+ return ENDPOINT_READYWAIT_EndpointStalled;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return ENDPOINT_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB Endpoint definitions for the UC3B microcontrollers.\r
+ * \copydetails Group_EndpointManagement_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointRW\r
+ * \defgroup Group_EndpointRW_UC3B Endpoint Data Reading and Writing (UC3B)\r
+ * \brief Endpoint data read/write definitions for the Atmel AVR32 UC3B architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPrimitiveRW\r
+ * \defgroup Group_EndpointPrimitiveRW_UC3B Read/Write of Primitive Data Types (UC3B)\r
+ * \brief Endpoint primative read/write definitions for the Atmel UC3B architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPacketManagement\r
+ * \defgroup Group_EndpointPacketManagement_UC3B Endpoint Packet Management (UC3B)\r
+ * \brief Endpoint packet management definitions for the Atmel UC3B architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointManagement\r
+ * \defgroup Group_EndpointManagement_UC3B Endpoint Management (UC3B)\r
+ * \brief Endpoint management definitions for the Atmel UC3B architecture.\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/receive functions for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ENDPOINT_UC3B_H__\r
+#define __ENDPOINT_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.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_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex)\r
+ #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails)\r
+ #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize)\r
+\r
+ #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex)\r
+ #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)\r
+ #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ #define ENDPOINT_DETAILS_MAXEP 7\r
+\r
+ #define ENDPOINT_DETAILS_EP0 64, 2\r
+ #define ENDPOINT_DETAILS_EP1 256, 2\r
+ #define ENDPOINT_DETAILS_EP2 64, 2\r
+ #define ENDPOINT_DETAILS_EP3 64, 2\r
+ #define ENDPOINT_DETAILS_EP4 64, 2\r
+ #define ENDPOINT_DETAILS_EP5 64, 2\r
+ #define ENDPOINT_DETAILS_EP6 64, 2\r
+ #else\r
+ #define ENDPOINT_DETAILS_MAXEP 5\r
+\r
+ #define ENDPOINT_DETAILS_EP0 64, 2\r
+ #define ENDPOINT_DETAILS_EP1 64, 1\r
+ #define ENDPOINT_DETAILS_EP2 64, 1\r
+ #define ENDPOINT_DETAILS_EP3 64, 2\r
+ #define ENDPOINT_DETAILS_EP4 64, 2\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
+ ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while (CheckBytes < Bytes)\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << AVR32_USBB_EPSIZE_OFFSET);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ void Endpoint_ClearEndpoints(void);\r
+ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
+ const uint32_t UECFGXData);\r
+ \r
+ /* External Variables: */\r
+ extern uint8_t USB_SelectedEndpoint;\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name Endpoint Direction Masks */\r
+ //@{\r
+ /** Endpoint data direction mask for \ref 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 << AVR32_USBB_UECFG0_EPDIR_OFFSET)\r
+\r
+ /** Endpoint data direction mask for \ref 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 << AVR32_USBB_UECFG0_EPDIR_OFFSET)\r
+ //@}\r
+ \r
+ /** \name Endpoint Bank Mode Masks */\r
+ //@{\r
+ /** Mask for the bank mode selection for the \ref 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 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
+\r
+ /** Mask for the bank mode selection for the \ref 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 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
+\r
+ /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
+ * that the endpoint should have three 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 remaining banks.\r
+ */\r
+ #define ENDPOINT_BANK_TRIPLE (2 << AVR32_USBB_UECFG0_EPBK0_OFFSET)\r
+ //@}\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
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size\r
+ * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.\r
+ */\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 0x07\r
+\r
+ /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.\r
+ */\r
+ #define ENDPOINT_EPDIR_MASK 0x80\r
+\r
+ /** Retrives the maximum bank size in bytes of a given endpoint.\r
+ *\r
+ * \note This macro will only work correctly on endpoint indexes that are compile-time constants\r
+ * defined by the preprocessor.\r
+ *\r
+ * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)\r
+ */\r
+ #define ENDPOINT_MAX_SIZE(EPIndex) _ENDPOINT_GET_MAXSIZE(EPIndex)\r
+\r
+ /** Retrieves the total number of banks supported by the given endpoint.\r
+ *\r
+ * \note This macro will only work correctly on endpoint indexes that are compile-time constants\r
+ * defined by the preprocessor.\r
+ *\r
+ * \param[in] EPIndex Endpoint number, a value between 0 and (\ref ENDPOINT_TOTAL_ENDPOINTS - 1)\r
+ */\r
+ #define ENDPOINT_BANKS_SUPPORTED(EPIndex) _ENDPOINT_GET_BANKS(EPIndex)\r
+\r
+ #if !defined(CONTROL_ONLY_DEVICE) || 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 ENDPOINT_DETAILS_MAXEP\r
+ #else\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 1\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_EndpointRW_AVR8\r
+ */\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_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
+ * no USB endpoint traffic can occur until the bus\r
+ * has resumed.\r
+ */\r
+ ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Configures the specified endpoint number with the given endpoint type, direction, bank size\r
+ * and banking mode. Once configured, the endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ *\r
+ * \param[in] Number Endpoint number to configure. This must be more than 0 and less than\r
+ * \ref ENDPOINT_TOTAL_ENDPOINTS.\r
+ *\r
+ * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types\r
+ * are available on Low Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] Direction Endpoint data direction, either \ref ENDPOINT_DIR_OUT or \ref ENDPOINT_DIR_IN.\r
+ * All endpoints (except Control type) are unidirectional - data may only be read\r
+ * from or written to the endpoint bank based on its direction, not both.\r
+ *\r
+ * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted\r
+ * to the USB host, or after they have been received from the USB host (depending on\r
+ * the endpoint's data direction). The bank size must indicate the maximum packet size\r
+ * that the endpoint can handle.\r
+ *\r
+ * \param[in] Banks Number of banks to use for the endpoint being configured, an \c ENDPOINT_BANK_* mask.\r
+ * More banks uses more USB DPRAM, but offers better performance. Isochronous type\r
+ * endpoints <b>must</b> have at least two banks.\r
+ *\r
+ * \note When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints <b>must</b> be configured in\r
+ * ascending order, or bank corruption will occur.\r
+ * \n\n\r
+ *\r
+ * \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's\r
+ * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.\r
+ * \n\n\r
+ *\r
+ * \note The default control endpoint should not be manually configured by the user application, as\r
+ * it is automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint\r
+ * which failed to reconfigure correctly will be selected.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,\r
+ const uint8_t Type,\r
+ const uint8_t Direction,\r
+ const uint16_t Size,\r
+ const uint8_t Banks) ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Number,\r
+ const uint8_t Type,\r
+ const uint8_t Direction,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+ {\r
+ return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << AVR32_USBB_EPTYPE_OFFSET) | AVR32_USBB_ALLOC |\r
+ (Direction << AVR32_USBB_EPDIR_OFFSET) |\r
+ (Banks << AVR32_USBB_EPBK_OFFSET) |\r
+ Endpoint_BytesToEPSizeMask(Size)));\r
+ }\r
+\r
+ /** Indicates the number of bytes currently stored in the current endpoint's selected bank.\r
+ *\r
+ * \note The return width of this function may differ, depending on the maximum endpoint bank size\r
+ * of the selected AVR model.\r
+ *\r
+ * \ingroup Group_EndpointRW_AVR8\r
+ *\r
+ * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].byct;\r
+ }\r
+\r
+ /** Get 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
+ * \return Index of the currently selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void)\r
+ {\r
+ return USB_SelectedEndpoint;\r
+ }\r
+\r
+ /** Selects the given endpoint number. If the address from the device descriptors is used, the\r
+ * value should be masked with the \ref 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
+ * \param[in] EndpointNumber Endpoint number to select.\r
+ */\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber)\r
+ {\r
+ USB_SelectedEndpoint = EndpointNumber;\r
+ }\r
+\r
+ /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's\r
+ * data In and Out pointers to the bank's contents.\r
+ *\r
+ * \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset.\r
+ */\r
+ static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)\r
+ {\r
+ AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_OFFSET << EndpointNumber);\r
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_OFFSET << EndpointNumber);\r
+ }\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 via \ref Endpoint_ConfigureEndpoint().\r
+ */\r
+ static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_EnableEndpoint(void)\r
+ {\r
+ AVR32_USBB.uerst |= (AVR32_USBB_EPEN0 << USB_SelectedEndpoint);\r
+ }\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
+ static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_DisableEndpoint(void)\r
+ {\r
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint);\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsEnabled(void)\r
+ {\r
+ return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint)) ? true : false);\r
+ }\r
+\r
+ /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for\r
+ * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the\r
+ * \ref Endpoint_ClearOUT() command.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Total number of busy banks in the selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetBusyBanks(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].nbusybk;\r
+ }\r
+\r
+ /** Aborts all pending IN transactions on the currently selected endpoint, once the bank\r
+ * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function\r
+ * will terminate all queued transactions, resetting the endpoint banks ready for a new\r
+ * packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_AbortPendingIN(void)\r
+ {\r
+ while (Endpoint_GetBusyBanks() != 0)\r
+ {\r
+ ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].killbk = true;\r
+ while (((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0)[USB_SelectedEndpoint].killbk);\r
+ }\r
+ }\r
+ \r
+ /** Determines 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 IN\r
+ * direction). This function will return false if an error has occurred in the endpoint, if the endpoint\r
+ * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN\r
+ * direction and the endpoint bank is full.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsReadWriteAllowed(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].rwall;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsConfigured(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].cfgok;\r
+ }\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 <tt>(1 << <i>{Endpoint Number}</i>)</tt>.\r
+ *\r
+ * \return Mask whose bits indicate which endpoints have interrupted.\r
+ */\r
+ static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetEndpointInterrupts(void)\r
+ {\r
+ return ((AVR32_USBB.udint & (AVR32_USBB_EP6INTES_MASK | AVR32_USBB_EP5INTES_MASK |\r
+ AVR32_USBB_EP4INTES_MASK | AVR32_USBB_EP3INTES_MASK |\r
+ AVR32_USBB_EP2INTES_MASK | AVR32_USBB_EP1INTES_MASK |\r
+ AVR32_USBB_EP0INTES_MASK)) >> AVR32_USBB_EP0INT_OFFSET);\r
+ }\r
+\r
+ /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type\r
+ * endpoints).\r
+ *\r
+ * \param[in] EndpointNumber Index of the endpoint whose interrupt flag should be tested.\r
+ *\r
+ * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber)\r
+ {\r
+ return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsINReady(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].txini;\r
+ }\r
+\r
+ /** Determines if the selected OUT endpoint has received new packet from the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsOUTReceived(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].rxouti;\r
+ }\r
+\r
+ /** Determines if the current CONTROL type endpoint has received a SETUP packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsSETUPReceived(void)\r
+ {\r
+ return ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0)[USB_SelectedEndpoint].rxstpi;\r
+ }\r
+\r
+ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the\r
+ * endpoint for the next packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \note This is not applicable for non CONTROL type endpoints.\r
+ */\r
+ static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearSETUP(void)\r
+ {\r
+ ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxstpi = true;\r
+ }\r
+\r
+ /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the\r
+ * next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearIN(void)\r
+ {\r
+ ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].txini = true;\r
+ ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;\r
+ }\r
+\r
+ /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint\r
+ * for the next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearOUT(void)\r
+ {\r
+ ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxouti = true;\r
+ ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;\r
+ }\r
+\r
+ /** Stalls the current endpoint, indicating to the host that a logical problem occurred 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 sequence.\r
+ *\r
+ * The currently selected endpoint remains stalled until either the \ref 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
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_StallTransaction(void)\r
+ {\r
+ ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].stallrq = true;\r
+ }\r
+\r
+ /** Clears the STALL condition on the currently selected endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearStall(void)\r
+ {\r
+ ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].stallrq = true;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is stalled, false otherwise.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsStalled(void)\r
+ {\r
+ return ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0)[USB_SelectedEndpoint].stallrq;\r
+ }\r
+\r
+ /** Resets the data toggle of the currently selected endpoint. */\r
+ static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetDataToggle(void)\r
+ {\r
+ ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].rstdt = true;\r
+ }\r
+\r
+ /** Determines the currently selected endpoint's direction.\r
+ *\r
+ * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetEndpointDirection(void)\r
+ {\r
+ return (((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] & AVR32_USBB_UECFG0_EPDIR_MASK);\r
+ }\r
+\r
+ /** Sets the direction of the currently selected endpoint.\r
+ *\r
+ * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask)\r
+ {\r
+ ((avr32_usbb_uecfg0_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint].epdir = (DirectionMask == ENDPOINT_DIR_IN);\r
+ }\r
+\r
+ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next byte in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_Read_Byte(void)\r
+ {\r
+ return *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ }\r
+\r
+ /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Byte Next byte to write into the the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
+ {\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = Byte;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ */\r
+ static inline void Endpoint_Discard_Byte(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_Byte(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next word in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_Word_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Word;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+\r
+ return Data.Word;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next word in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_Word_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Word;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+\r
+ return Data.Word;\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_Word_LE(const uint16_t Word)\r
+ {\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (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
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Word Next word to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_Word_BE(const uint16_t Word)\r
+ {\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ */\r
+ static inline void Endpoint_Discard_Word(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_Word(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next double word in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);\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
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next double word in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);\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
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)\r
+ {\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] DWord Next double word to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)\r
+ {\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);\r
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ */\r
+ static inline void Endpoint_Discard_DWord(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_DWord(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\r
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);\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 \c 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
+ * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token\r
+ * be used in the device 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
+ /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,\r
+ * with respect to the data direction. This is a convenience function which can be used to\r
+ * simplify user control request handling.\r
+ */\r
+ void Endpoint_ClearStatusStage(void);\r
+\r
+ /** Spin-loops 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
+ * \ingroup Group_EndpointRW_AVR8\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_WaitUntilReady(void);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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_USB_DRIVER\r
-#include "../USBMode.h"\r
-\r
-#if defined(USB_CAN_BE_HOST)\r
-\r
-#define __INCLUDE_FROM_HOST_C\r
-#include "Host.h"\r
-\r
-void USB_Host_ProcessNextHostState(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
- if (!(--WaitMSRemaining))\r
- USB_HostState = PostWaitState;\r
- }\r
-\r
- break;\r
- case HOST_STATE_Powered:\r
- WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;\r
-\r
- USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;\r
- break;\r
- case HOST_STATE_Powered_WaitForDeviceSettle:\r
- if (WaitMSRemaining--)\r
- {\r
- _delay_ms(1);\r
- break;\r
- }\r
- else\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_Powered_WaitForConnect;\r
- }\r
-\r
- break;\r
- case HOST_STATE_Powered_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_Host_ResumeBus();\r
- Pipe_ClearPipes();\r
-\r
- HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);\r
- }\r
-\r
- break;\r
- case HOST_STATE_Powered_DoReset:\r
- USB_Host_ResetDevice();\r
-\r
- HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);\r
- break;\r
- case HOST_STATE_Powered_ConfigPipe:\r
- Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,\r
- PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,\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_ControlRequest = (USB_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 = 8,\r
- };\r
-\r
- uint8_t DataBuffer[8];\r
-\r
- if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)\r
- {\r
- ErrorCode = HOST_ENUMERROR_ControlError;\r
- break;\r
- }\r
-\r
- USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];\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_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,\r
- PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,\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
- USB_ControlRequest = (USB_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
- EVENT_USB_Host_DeviceEnumerationComplete();\r
- USB_HostState = HOST_STATE_Addressed;\r
- break;\r
- }\r
-\r
- if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))\r
- {\r
- EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);\r
-\r
- USB_Host_VBUS_Auto_Off();\r
-\r
- EVENT_USB_Host_DeviceUnattached();\r
-\r
- USB_ResetInterface();\r
- }\r
-}\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
- bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
-\r
- USB_INT_Disable(USB_INT_HSOFI);\r
- USB_INT_Clear(USB_INT_HSOFI);\r
-\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_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))\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
- if (HSOFIEnabled)\r
- USB_INT_Enable(USB_INT_HSOFI);\r
-\r
- return ErrorCode;\r
-}\r
-\r
-static 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_IsBusResetComplete()));\r
- USB_Host_ResumeBus();\r
-\r
- bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
-\r
- USB_INT_Disable(USB_INT_HSOFI);\r
- USB_INT_Clear(USB_INT_HSOFI);\r
-\r
- for (uint8_t MSRem = 10; MSRem != 0; MSRem--)\r
- {\r
- /* Workaround for powerless-pull-up devices. After a USB bus reset,\r
- all disconnection interrupts are suppressed 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_HSOFI);\r
- USB_INT_Clear(USB_INT_DDISCI);\r
- break;\r
- }\r
-\r
- _delay_ms(1);\r
- }\r
-\r
- if (HSOFIEnabled)\r
- USB_INT_Enable(USB_INT_HSOFI);\r
-\r
- if (BusSuspended)\r
- USB_Host_SuspendBus();\r
-\r
- USB_INT_Enable(USB_INT_DDISCI);\r
-}\r
-\r
-uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)\r
-{\r
- USB_ControlRequest = (USB_Request_Header_t)\r
- {\r
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
- .bRequest = REQ_SetConfiguration,\r
- .wValue = ConfigNumber,\r
- .wIndex = 0,\r
- .wLength = 0,\r
- };\r
-\r
- Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
-\r
- return USB_Host_SendControlRequest(NULL);\r
-}\r
-\r
-uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)\r
-{\r
- USB_ControlRequest = (USB_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 = sizeof(USB_Descriptor_Device_t),\r
- };\r
-\r
- Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
-\r
- return USB_Host_SendControlRequest(DeviceDescriptorPtr);\r
-}\r
-\r
-uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,\r
- void* const Buffer,\r
- const uint8_t BufferLength)\r
-{\r
- USB_ControlRequest = (USB_Request_Header_t)\r
- {\r
- .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
- .bRequest = REQ_GetDescriptor,\r
- .wValue = (DTYPE_String << 8) | Index,\r
- .wIndex = 0,\r
- .wLength = BufferLength,\r
- };\r
-\r
- Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
-\r
- return USB_Host_SendControlRequest(Buffer);\r
-}\r
-\r
-uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)\r
-{\r
- USB_ControlRequest = (USB_Request_Header_t)\r
- {\r
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
- .bRequest = REQ_ClearFeature,\r
- .wValue = FEATURE_SEL_EndpointHalt,\r
- .wIndex = EndpointNum,\r
- .wLength = 0,\r
- };\r
-\r
- Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
-\r
- return USB_Host_SendControlRequest(NULL);\r
-}\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB Host definitions for the AVR32 UC3B microcontrollers.\r
- * \copydetails Group_Host_UC3B\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-/** \ingroup Group_Host\r
- * \defgroup Group_Host_UC3B Host Management (UC3B)\r
- * \brief USB Host definitions for the AVR32 UC3B microcontrollers.\r
- *\r
- * Architecture specific USB Host definitions for the Atmel 32-bit AVR UC3B microcontrollers.\r
- *\r
- * @{\r
- */\r
-\r
-#ifndef __USBHOST_UC3B_H__\r
-#define __USBHOST_UC3B_H__\r
-\r
- /* Includes: */\r
- #include "../../../../Common/Common.h"\r
- #include "../StdDescriptors.h"\r
- #include "../Pipe.h"\r
- #include "../USBInterrupt.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_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\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
- * \ref 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
- * The default delay value may be overridden in the user project makefile by defining the\r
- * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the\r
- * compiler using the -D switch.\r
- */\r
- #define HOST_DEVICE_SETTLE_DELAY_MS 1000\r
- #endif\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 possible USB host state, refer to the USB 2.0 specification.\r
- * Several of the USB host states are broken up further into multiple smaller sub-states,\r
- * so that they can be internally implemented inside the library in an efficient manner.\r
- *\r
- * \see \ref USB_HostState, which stores the current host state machine state.\r
- */\r
- enum USB_Host_States_t\r
- {\r
- HOST_STATE_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be\r
- * used by the library to wait until the attached device is\r
- * removed by the user - useful for when an error occurs or\r
- * further communication with the device is not needed. This\r
- * allows for other code to run while the state machine is\r
- * effectively disabled.\r
- */\r
- HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates\r
- * that the stack is waiting for an interval to elapse before\r
- * continuing with the next step of the device enumeration\r
- * process.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates\r
- * that the host state machine is waiting for a device to be\r
- * attached so that it can start the enumeration process.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates\r
- * that a device has been attached, and the library's internals\r
- * are being configured to begin the enumeration process.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates\r
- * that the stack is waiting for the initial settling period to\r
- * elapse before beginning the enumeration process.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. This state indicates\r
- * that the stack is waiting for a connection event from the USB\r
- * controller to indicate a valid USB device has been attached to\r
- * the bus and is ready to be enumerated.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates\r
- * that a valid USB device has been attached, and that it is\r
- * will now be reset to ensure it is ready for enumeration.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates\r
- * that the attached device is currently powered and reset, and\r
- * that the control pipe is now being configured by the stack.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Default = 8, /**< Internally implemented by the library. This state indicates\r
- * that the stack is currently retrieving the control endpoint's\r
- * size from the device, so that the control pipe can be altered\r
- * to match.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. This state indicates that\r
- * the control pipe is being reconfigured to match the retrieved\r
- * control endpoint size from the device, and the device's USB bus\r
- * address is being set.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. This state indicates that\r
- * the device's address has now been set, and the stack is has now\r
- * completed the device enumeration process. This state causes the\r
- * stack to change the current USB device address to that set for\r
- * the connected device, before progressing to the user-implemented\r
- * \ref HOST_STATE_Addressed state for further communications.\r
- *\r
- * \note Do not manually change to this state in the user code.\r
- */\r
- HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should\r
- * set the device configuration before progressing to the\r
- * \ref HOST_STATE_Configured state. Other processing (such as the\r
- * retrieval and processing of the device descriptor) should also\r
- * be placed in this state.\r
- */\r
- HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the\r
- * actual work performed on the attached device and changed to the\r
- * \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.\r
- */\r
- HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained\r
- * while the bus is suspended, and changed to either the \ref HOST_STATE_Configured\r
- * (after resuming the bus with the USB_Host_ResumeBus() macro) or the\r
- * \ref HOST_STATE_WaitForDeviceRemoval states as needed.\r
- */\r
- };\r
-\r
- /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.\r
- *\r
- * \see \ref Group_Events 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 \ref EVENT_USB_Host_DeviceEnumerationFailed() event.\r
- *\r
- * \see \ref Group_Events 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 \ref EVENT_USB_Host_DeviceEnumerationFailed()\r
- * event.\r
- */\r
- HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed\r
- * to complete successfully, 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 successfully.\r
- */\r
- HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to\r
- * configure correctly.\r
- */\r
- };\r
-\r
- /* Inline Functions: */\r
- /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)\r
- * the frame number is incremented by one.\r
- */\r
- static inline uint16_t USB_Host_GetFrameNumber(void)\r
- {\r
- return UHFNUM;\r
- }\r
-\r
- #if !defined(NO_SOF_EVENTS)\r
- /** Enables the host mode Start Of Frame events. When enabled, this causes the\r
- * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
- * at the start of each USB frame when a device is enumerated while in host mode.\r
- *\r
- * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
- */\r
- static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_EnableSOFEvents(void)\r
- {\r
- USB_INT_Enable(USB_INT_HSOFI);\r
- }\r
-\r
- /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the\r
- * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.\r
- *\r
- * \note Not available when the NO_SOF_EVENTS compile time token is defined.\r
- */\r
- static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_DisableSOFEvents(void)\r
- {\r
- USB_INT_Disable(USB_INT_HSOFI);\r
- }\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
- static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_ResetBus(void)\r
- {\r
- UHCON |= (1 << RESET);\r
- }\r
-\r
- /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has\r
- * completed.\r
- *\r
- * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.\r
- */\r
- static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_Host_IsBusResetComplete(void)\r
- {\r
- return ((UHCON & (1 << RESET)) ? false : true);\r
- }\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
- static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_ResumeBus(void)\r
- {\r
- UHCON |= (1 << SOFEN);\r
- }\r
-\r
- /** Suspends the USB bus, preventing any communications from occurring 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
- static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_SuspendBus(void)\r
- {\r
- UHCON &= ~(1 << SOFEN);\r
- }\r
-\r
- /** Determines if the USB bus has been suspended via the use of the \ref 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
- * \return Boolean \c true if the bus is currently suspended, \c false otherwise.\r
- */\r
- static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_Host_IsBusSuspended(void)\r
- {\r
- return ((UHCON & (1 << SOFEN)) ? false : true);\r
- }\r
-\r
- /** Determines 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
- * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.\r
- */\r
- static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_Host_IsDeviceFullSpeed(void)\r
- {\r
- return ((USBSTA & (1 << SPEED)) ? true : false);\r
- }\r
-\r
- /** Determines 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
- * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.\r
- */\r
- static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_Host_IsRemoteWakeupSent(void)\r
- {\r
- return ((UHINT & (1 << RXRSMI)) ? true : false);\r
- }\r
-\r
- /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */\r
- static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_ClearRemoteWakeupSent(void)\r
- {\r
- UHINT &= ~(1 << RXRSMI);\r
- }\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
- static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_ResumeFromWakeupRequest(void)\r
- {\r
- UHCON |= (1 << RESUME);\r
- }\r
-\r
- /** Determines if a resume from Remote Wakeup request is currently being sent to an attached\r
- * device.\r
- *\r
- * \return Boolean \c true if no resume request is currently being sent, \c false otherwise.\r
- */\r
- static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)\r
- {\r
- return ((UHCON & (1 << RESUME)) ? false : true);\r
- }\r
-\r
- /* Function Prototypes: */\r
- /** Convenience function. This routine sends a SET CONFIGURATION standard request to the attached\r
- * device, with the given configuration index. This can be used to easily set the device\r
- * configuration without creating and sending the request manually.\r
- *\r
- * \note After this routine returns, the control pipe will be selected.\r
- *\r
- * \param[in] ConfigNumber Configuration index to send to the device.\r
- *\r
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
- */\r
- uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);\r
-\r
- /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached\r
- * device, requesting the device descriptor. This can be used to easily retrieve information\r
- * about the device such as its VID, PID and power requirements.\r
- *\r
- * \note After this routine returns, the control pipe will be selected.\r
- *\r
- * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where\r
- * the read data is to be stored.\r
- *\r
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
- */\r
- uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);\r
-\r
- /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached\r
- * device, requesting the string descriptor of the specified index. This can be used to easily\r
- * retrieve string descriptors from the device by index, after the index is obtained from the\r
- * Device or Configuration descriptors.\r
- *\r
- * \note After this routine returns, the control pipe will be selected.\r
- *\r
- * \param[in] Index Index of the string index to retrieve.\r
- * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is\r
- * to be stored.\r
- * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.\r
- *\r
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
- */\r
- uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,\r
- void* const Buffer,\r
- const uint8_t BufferLength);\r
-\r
- /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device.\r
- *\r
- * \note After this routine returns, the control pipe will be selected.\r
- *\r
- * \param[in] EndpointIndex Index of the endpoint to clear, including the endpoint's direction.\r
- *\r
- * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
- */\r
- uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex);\r
-\r
- /* Private Interface - For use in library only: */\r
- #if !defined(__DOXYGEN__)\r
- /* Macros: */\r
- static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_HostMode_On(void)\r
- {\r
- USBCON |= (1 << HOST);\r
- }\r
-\r
- static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_HostMode_Off(void)\r
- {\r
- USBCON &= ~(1 << HOST);\r
- }\r
-\r
- static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_VBUS_Auto_Enable(void)\r
- {\r
- OTGCON &= ~(1 << VBUSHWC);\r
- UHWCON |= (1 << UVCONE);\r
- }\r
-\r
- static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_VBUS_Manual_Enable(void)\r
- {\r
- OTGCON |= (1 << VBUSHWC);\r
- UHWCON &= ~(1 << UVCONE);\r
-\r
- DDRE |= (1 << 7);\r
- }\r
-\r
- static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_VBUS_Auto_On(void)\r
- {\r
- OTGCON |= (1 << VBUSREQ);\r
- }\r
-\r
- static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_VBUS_Manual_On(void)\r
- {\r
- PORTE |= (1 << 7);\r
- }\r
-\r
- static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_VBUS_Auto_Off(void)\r
- {\r
- OTGCON |= (1 << VBUSRQC);\r
- }\r
-\r
- static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_VBUS_Manual_Off(void)\r
- {\r
- PORTE &= ~(1 << 7);\r
- }\r
-\r
- static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Host_SetDeviceAddress(const uint8_t Address)\r
- {\r
- UHADDR = (Address & 0x7F);\r
- }\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
- void USB_Host_ProcessNextHostState(void);\r
- uint8_t USB_Host_WaitMS(uint8_t MS);\r
-\r
- #if defined(__INCLUDE_FROM_HOST_C)\r
- static void USB_Host_ResetDevice(void);\r
- #endif\r
- #endif\r
-\r
- /* Disable C linkage for C++ Compilers: */\r
- #if defined(__cplusplus)\r
- }\r
- #endif\r
-\r
-#endif\r
-\r
-/** @} */\r
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_HOST_C\r
+#include "../Host.h"\r
+\r
+void USB_Host_ProcessNextHostState(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
+ if (!(--WaitMSRemaining))\r
+ USB_HostState = PostWaitState;\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered:\r
+ WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;\r
+\r
+ USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;\r
+ break;\r
+ case HOST_STATE_Powered_WaitForDeviceSettle:\r
+ if (WaitMSRemaining--)\r
+ {\r
+ _delay_ms(1);\r
+ break;\r
+ }\r
+ else\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_Powered_WaitForConnect;\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered_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_Host_ResumeBus();\r
+ Pipe_ClearPipes();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered_DoReset:\r
+ USB_Host_ResetDevice();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);\r
+ break;\r
+ case HOST_STATE_Powered_ConfigPipe:\r
+ Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,\r
+ PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,\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_ControlRequest = (USB_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 = 8,\r
+ };\r
+\r
+ uint8_t DataBuffer[8];\r
+\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ USB_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];\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_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL,\r
+ PIPE_TOKEN_SETUP, ENDPOINT_CONTROLEP,\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
+ USB_ControlRequest = (USB_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
+ EVENT_USB_Host_DeviceEnumerationComplete();\r
+ USB_HostState = HOST_STATE_Addressed;\r
+ break;\r
+ }\r
+\r
+ if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))\r
+ {\r
+ EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);\r
+\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+}\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
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
+\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\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_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))\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
+ if (HSOFIEnabled)\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+static 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_IsBusResetComplete()));\r
+ USB_Host_ResumeBus();\r
+\r
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
+\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ for (uint8_t MSRem = 10; MSRem != 0; MSRem--)\r
+ {\r
+ /* Workaround for powerless-pull-up devices. After a USB bus reset,\r
+ all disconnection interrupts are suppressed 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_HSOFI);\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ break;\r
+ }\r
+\r
+ _delay_ms(1);\r
+ }\r
+\r
+ if (HSOFIEnabled)\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+}\r
+\r
+uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_SetConfiguration,\r
+ .wValue = ConfigNumber,\r
+ .wIndex = 0,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)\r
+{\r
+ USB_ControlRequest = (USB_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 = sizeof(USB_Descriptor_Device_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(DeviceDescriptorPtr);\r
+}\r
+\r
+uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,\r
+ void* const Buffer,\r
+ const uint8_t BufferLength)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetDescriptor,\r
+ .wValue = (DTYPE_String << 8) | Index,\r
+ .wIndex = 0,\r
+ .wLength = BufferLength,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Buffer);\r
+}\r
+\r
+uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointNum)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
+ .bRequest = REQ_ClearFeature,\r
+ .wValue = FEATURE_SEL_EndpointHalt,\r
+ .wIndex = EndpointNum,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB Host definitions for the AVR32 UC3B microcontrollers.\r
+ * \copydetails Group_Host_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Host\r
+ * \defgroup Group_Host_UC3B Host Management (UC3B)\r
+ * \brief USB Host definitions for the AVR32 UC3B microcontrollers.\r
+ *\r
+ * Architecture specific USB Host definitions for the Atmel 32-bit AVR UC3B microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBHOST_UC3B_H__\r
+#define __USBHOST_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../Pipe.h"\r
+ #include "../USBInterrupt.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_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\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
+ * \ref 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
+ * The default delay value may be overridden in the user project makefile by defining the\r
+ * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the\r
+ * compiler using the -D switch.\r
+ */\r
+ #define HOST_DEVICE_SETTLE_DELAY_MS 1000\r
+ #endif\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 possible USB host state, refer to the USB 2.0 specification.\r
+ * Several of the USB host states are broken up further into multiple smaller sub-states,\r
+ * so that they can be internally implemented inside the library in an efficient manner.\r
+ *\r
+ * \see \ref USB_HostState, which stores the current host state machine state.\r
+ */\r
+ enum USB_Host_States_t\r
+ {\r
+ HOST_STATE_WaitForDeviceRemoval = 0, /**< Internally implemented by the library. This state can be\r
+ * used by the library to wait until the attached device is\r
+ * removed by the user - useful for when an error occurs or\r
+ * further communication with the device is not needed. This\r
+ * allows for other code to run while the state machine is\r
+ * effectively disabled.\r
+ */\r
+ HOST_STATE_WaitForDevice = 1, /**< Internally implemented by the library. This state indicates\r
+ * that the stack is waiting for an interval to elapse before\r
+ * continuing with the next step of the device enumeration\r
+ * process.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Unattached = 2, /**< Internally implemented by the library. This state indicates\r
+ * that the host state machine is waiting for a device to be\r
+ * attached so that it can start the enumeration process.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Powered = 3, /**< Internally implemented by the library. This state indicates\r
+ * that a device has been attached, and the library's internals\r
+ * are being configured to begin the enumeration process.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Powered_WaitForDeviceSettle = 4, /**< Internally implemented by the library. This state indicates\r
+ * that the stack is waiting for the initial settling period to\r
+ * elapse before beginning the enumeration process.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Powered_WaitForConnect = 5, /**< Internally implemented by the library. This state indicates\r
+ * that the stack is waiting for a connection event from the USB\r
+ * controller to indicate a valid USB device has been attached to\r
+ * the bus and is ready to be enumerated.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Powered_DoReset = 6, /**< Internally implemented by the library. This state indicates\r
+ * that a valid USB device has been attached, and that it is\r
+ * will now be reset to ensure it is ready for enumeration.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Powered_ConfigPipe = 7, /**< Internally implemented by the library. This state indicates\r
+ * that the attached device is currently powered and reset, and\r
+ * that the control pipe is now being configured by the stack.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Default = 8, /**< Internally implemented by the library. This state indicates\r
+ * that the stack is currently retrieving the control endpoint's\r
+ * size from the device, so that the control pipe can be altered\r
+ * to match.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Default_PostReset = 9, /**< Internally implemented by the library. This state indicates that\r
+ * the control pipe is being reconfigured to match the retrieved\r
+ * control endpoint size from the device, and the device's USB bus\r
+ * address is being set.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Default_PostAddressSet = 10, /**< Internally implemented by the library. This state indicates that\r
+ * the device's address has now been set, and the stack is has now\r
+ * completed the device enumeration process. This state causes the\r
+ * stack to change the current USB device address to that set for\r
+ * the connected device, before progressing to the user-implemented\r
+ * \ref HOST_STATE_Addressed state for further communications.\r
+ *\r
+ * \note Do not manually change to this state in the user code.\r
+ */\r
+ HOST_STATE_Addressed = 11, /**< May be implemented by the user project. This state should\r
+ * set the device configuration before progressing to the\r
+ * \ref HOST_STATE_Configured state. Other processing (such as the\r
+ * retrieval and processing of the device descriptor) should also\r
+ * be placed in this state.\r
+ */\r
+ HOST_STATE_Configured = 12, /**< May be implemented by the user project. This state should implement the\r
+ * actual work performed on the attached device and changed to the\r
+ * \ref HOST_STATE_Suspended or \ref HOST_STATE_WaitForDeviceRemoval states as needed.\r
+ */\r
+ HOST_STATE_Suspended = 15, /**< May be implemented by the user project. This state should be maintained\r
+ * while the bus is suspended, and changed to either the \ref HOST_STATE_Configured\r
+ * (after resuming the bus with the USB_Host_ResumeBus() macro) or the\r
+ * \ref HOST_STATE_WaitForDeviceRemoval states as needed.\r
+ */\r
+ };\r
+\r
+ /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.\r
+ *\r
+ * \see \ref Group_Events 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 \ref EVENT_USB_Host_DeviceEnumerationFailed() event.\r
+ *\r
+ * \see \ref Group_Events 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 \ref EVENT_USB_Host_DeviceEnumerationFailed()\r
+ * event.\r
+ */\r
+ HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed\r
+ * to complete successfully, 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 successfully.\r
+ */\r
+ HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to\r
+ * configure correctly.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)\r
+ * the frame number is incremented by one.\r
+ */\r
+ static inline uint16_t USB_Host_GetFrameNumber(void)\r
+ {\r
+ return UHFNUM;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the host mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when a device is enumerated while in host mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+ }\r
+\r
+ /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.\r
+ *\r
+ * \note Not available when the NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ }\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
+ static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResetBus(void)\r
+ {\r
+ UHCON |= (1 << RESET);\r
+ }\r
+\r
+ /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has\r
+ * completed.\r
+ *\r
+ * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsBusResetComplete(void)\r
+ {\r
+ return ((UHCON & (1 << RESET)) ? false : true);\r
+ }\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
+ static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResumeBus(void)\r
+ {\r
+ UHCON |= (1 << SOFEN);\r
+ }\r
+\r
+ /** Suspends the USB bus, preventing any communications from occurring 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
+ static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_SuspendBus(void)\r
+ {\r
+ UHCON &= ~(1 << SOFEN);\r
+ }\r
+\r
+ /** Determines if the USB bus has been suspended via the use of the \ref 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
+ * \return Boolean \c true if the bus is currently suspended, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsBusSuspended(void)\r
+ {\r
+ return ((UHCON & (1 << SOFEN)) ? false : true);\r
+ }\r
+\r
+ /** Determines 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
+ * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void)\r
+ {\r
+ return ((USBSTA & (1 << SPEED)) ? true : false);\r
+ }\r
+\r
+ /** Determines 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
+ * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void)\r
+ {\r
+ return ((UHINT & (1 << RXRSMI)) ? true : false);\r
+ }\r
+\r
+ /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void)\r
+ {\r
+ UHINT &= ~(1 << RXRSMI);\r
+ }\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
+ static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResumeFromWakeupRequest(void)\r
+ {\r
+ UHCON |= (1 << RESUME);\r
+ }\r
+\r
+ /** Determines if a resume from Remote Wakeup request is currently being sent to an attached\r
+ * device.\r
+ *\r
+ * \return Boolean \c true if no resume request is currently being sent, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)\r
+ {\r
+ return ((UHCON & (1 << RESUME)) ? false : true);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ /** Convenience function. This routine sends a SET CONFIGURATION standard request to the attached\r
+ * device, with the given configuration index. This can be used to easily set the device\r
+ * configuration without creating and sending the request manually.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \param[in] ConfigNumber Configuration index to send to the device.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);\r
+\r
+ /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached\r
+ * device, requesting the device descriptor. This can be used to easily retrieve information\r
+ * about the device such as its VID, PID and power requirements.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where\r
+ * the read data is to be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr);\r
+\r
+ /** Convenience function. This routine sends a GET DESCRIPTOR standard request to the attached\r
+ * device, requesting the string descriptor of the specified index. This can be used to easily\r
+ * retrieve string descriptors from the device by index, after the index is obtained from the\r
+ * Device or Configuration descriptors.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \param[in] Index Index of the string index to retrieve.\r
+ * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is\r
+ * to be stored.\r
+ * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,\r
+ void* const Buffer,\r
+ const uint8_t BufferLength);\r
+\r
+ /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \param[in] EndpointIndex Index of the endpoint to clear, including the endpoint's direction.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_ClearPipeStall(const uint8_t EndpointIndex);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_HostMode_On(void)\r
+ {\r
+ USBCON |= (1 << HOST);\r
+ }\r
+\r
+ static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_HostMode_Off(void)\r
+ {\r
+ USBCON &= ~(1 << HOST);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_Enable(void)\r
+ {\r
+ OTGCON &= ~(1 << VBUSHWC);\r
+ UHWCON |= (1 << UVCONE);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_Enable(void)\r
+ {\r
+ OTGCON |= (1 << VBUSHWC);\r
+ UHWCON &= ~(1 << UVCONE);\r
+\r
+ DDRE |= (1 << 7);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_On(void)\r
+ {\r
+ OTGCON |= (1 << VBUSREQ);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_On(void)\r
+ {\r
+ PORTE |= (1 << 7);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_Off(void)\r
+ {\r
+ OTGCON |= (1 << VBUSRQC);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_Off(void)\r
+ {\r
+ PORTE &= ~(1 << 7);\r
+ }\r
+\r
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ UHADDR = (Address & 0x7F);\r
+ }\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
+ void USB_Host_ProcessNextHostState(void);\r
+ uint8_t USB_Host_WaitMS(uint8_t MS);\r
+\r
+ #if defined(__INCLUDE_FROM_HOST_C)\r
+ static void USB_Host_ResetDevice(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB OTG definitions for the UC3B microcontrollers.\r
- * \copydetails Group_OTG_UC3B\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-/** \ingroup Group_OTG\r
- * \defgroup Group_OTG_UC3B USB On The Go (OTG) Management (UC3B)\r
- * \brief USB OTG definitions for the UC3B microcontrollers.\r
- *\r
- * Architecture specific USB OTG definitions for the Atmel 32-bit AVR UC3B microcontrollers.\r
- *\r
- * @{\r
- */\r
-\r
-#ifndef __USBOTG_UC3B_H__\r
-#define __USBOTG_UC3B_H__\r
-\r
- /* Includes: */\r
- #include "../../../../Common/Common.h"\r
-\r
- /* Preprocessor Checks: */\r
- #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
- #endif\r
-\r
- /* Public Interface - May be used in end-application: */\r
- /* Macros: */\r
- /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.\r
- *\r
- * \see \ref USB_OTG_Device_InitiateSRP().\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 \ref USB_OTG_Device_InitiateSRP().\r
- */\r
- #define USB_OTG_STP_DATA 0\r
-\r
- /* Inline Functions: */\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
- static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTG_Device_RequestHNP(void)\r
- {\r
- OTGCON |= (1 << HNPREQ);\r
- }\r
-\r
- /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other\r
- * connected device.\r
- */\r
- static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTG_Device_CancelHNPRequest(void)\r
- {\r
- OTGCON &= ~(1 << HNPREQ);\r
- }\r
-\r
- /** Determines if the device is currently sending a HNP to an attached host.\r
- *\r
- * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise\r
- */\r
- static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE;\r
- static inline bool USB_OTG_Device_IsSendingHNP(void)\r
- {\r
- return ((OTGCON & (1 << HNPREQ)) ? true : false);\r
- }\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 pull-up resistor.\r
- *\r
- * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or\r
- * \ref USB_OTG_STP_DATA.\r
- */\r
- static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)\r
- {\r
- OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));\r
- }\r
-\r
- /** Accepts a HNP from a connected device, indicating that both devices should exchange\r
- * device/host roles.\r
- */\r
- static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTG_Host_AcceptHNP(void)\r
- {\r
- OTGCON |= (1 << HNPREQ);\r
- }\r
-\r
- /** Rejects a HNP from a connected device, indicating that both devices should remain in their\r
- * current device/host roles.\r
- */\r
- static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTG_Host_RejectHNP(void)\r
- {\r
- OTGCON &= ~(1 << HNPREQ);\r
- }\r
-\r
- /** Indicates if the connected device is not currently sending a HNP request.\r
- *\r
- * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.\r
- */\r
- static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_OTG_Host_IsHNPReceived(void)\r
- {\r
- return ((OTGCON & (1 << HNPREQ)) ? true : false);\r
- }\r
-\r
-#endif\r
-\r
-/** @} */\r
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB OTG definitions for the UC3B microcontrollers.\r
+ * \copydetails Group_OTG_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_OTG\r
+ * \defgroup Group_OTG_UC3B USB On The Go (OTG) Management (UC3B)\r
+ * \brief USB OTG definitions for the UC3B microcontrollers.\r
+ *\r
+ * Architecture specific USB OTG definitions for the Atmel 32-bit AVR UC3B microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBOTG_UC3B_H__\r
+#define __USBOTG_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.\r
+ *\r
+ * \see \ref USB_OTG_Device_InitiateSRP().\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 \ref USB_OTG_Device_InitiateSRP().\r
+ */\r
+ #define USB_OTG_STP_DATA 0\r
+\r
+ /* Inline Functions: */\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
+ static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Device_RequestHNP(void)\r
+ {\r
+ OTGCON |= (1 << HNPREQ);\r
+ }\r
+\r
+ /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other\r
+ * connected device.\r
+ */\r
+ static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Device_CancelHNPRequest(void)\r
+ {\r
+ OTGCON &= ~(1 << HNPREQ);\r
+ }\r
+\r
+ /** Determines if the device is currently sending a HNP to an attached host.\r
+ *\r
+ * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise\r
+ */\r
+ static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_OTG_Device_IsSendingHNP(void)\r
+ {\r
+ return ((OTGCON & (1 << HNPREQ)) ? true : false);\r
+ }\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 pull-up resistor.\r
+ *\r
+ * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or\r
+ * \ref USB_OTG_STP_DATA.\r
+ */\r
+ static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)\r
+ {\r
+ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));\r
+ }\r
+\r
+ /** Accepts a HNP from a connected device, indicating that both devices should exchange\r
+ * device/host roles.\r
+ */\r
+ static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Host_AcceptHNP(void)\r
+ {\r
+ OTGCON |= (1 << HNPREQ);\r
+ }\r
+\r
+ /** Rejects a HNP from a connected device, indicating that both devices should remain in their\r
+ * current device/host roles.\r
+ */\r
+ static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Host_RejectHNP(void)\r
+ {\r
+ OTGCON &= ~(1 << HNPREQ);\r
+ }\r
+\r
+ /** Indicates if the connected device is not currently sending a HNP request.\r
+ *\r
+ * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.\r
+ */\r
+ static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_OTG_Host_IsHNPReceived(void)\r
+ {\r
+ return ((OTGCON & (1 << HNPREQ)) ? true : false);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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_USB_DRIVER\r
-#include "../USBMode.h"\r
-\r
-#if defined(USB_CAN_BE_HOST)\r
-\r
-#include "Pipe.h"\r
-\r
-uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
-\r
-bool Pipe_ConfigurePipe(const uint8_t Number,\r
- const uint8_t Type,\r
- const uint8_t Token,\r
- const uint8_t EndpointNumber,\r
- const uint16_t Size,\r
- const uint8_t Banks)\r
-{\r
-#if defined(ORDERED_EP_CONFIG)\r
- Pipe_SelectPipe(Number);\r
- Pipe_EnablePipe();\r
-\r
- UPCFG1X = 0;\r
-\r
- UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));\r
- UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
-\r
- Pipe_SetInfiniteINRequests();\r
-\r
- return Pipe_IsConfigured();\r
-#else \r
- for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)\r
- {\r
- uint8_t UPCFG0XTemp;\r
- uint8_t UPCFG1XTemp;\r
- uint8_t UPCFG2XTemp;\r
- uint8_t UPCONXTemp;\r
- uint8_t UPINRQXTemp;\r
- uint8_t UPIENXTemp;\r
-\r
- Pipe_SelectPipe(PNum);\r
- \r
- if (PNum == Number)\r
- {\r
- UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));\r
- UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
- UPCFG2XTemp = 0;\r
- UPCONXTemp = ((1 << PEN) | (1 << INMODE));\r
- UPINRQXTemp = 0;\r
- UPIENXTemp = 0;\r
- }\r
- else\r
- {\r
- UPCFG0XTemp = UPCFG0X;\r
- UPCFG1XTemp = UPCFG1X;\r
- UPCFG2XTemp = UPCFG2X;\r
- UPCONXTemp = UPCONX;\r
- UPINRQXTemp = UPINRQX;\r
- UPIENXTemp = UPIENX;\r
- }\r
-\r
- if (!(UPCFG1XTemp & (1 << ALLOC)))\r
- continue;\r
- \r
- Pipe_DisablePipe();\r
- UPCFG1X &= (1 << ALLOC);\r
-\r
- Pipe_EnablePipe();\r
- UPCFG0X = UPCFG0XTemp;\r
- UPCFG1X = UPCFG1XTemp;\r
- UPCFG2X = UPCFG2XTemp;\r
- UPCONX = UPCONXTemp;\r
- UPINRQX = UPINRQXTemp;\r
- UPIENX = UPIENXTemp;\r
-\r
- if (!(Pipe_IsConfigured()))\r
- return false; \r
- }\r
- \r
- Pipe_SelectPipe(Number); \r
- return true;\r
-#endif\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_SelectPipe(PNum);\r
- UPIENX = 0;\r
- UPINTX = 0;\r
- UPCFG1X = 0;\r
- Pipe_DisablePipe();\r
- }\r
-}\r
-\r
-bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)\r
-{\r
- uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();\r
-\r
- for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
- {\r
- Pipe_SelectPipe(PNum);\r
-\r
- if (!(Pipe_IsConfigured()))\r
- continue;\r
-\r
- uint8_t PipeToken = Pipe_GetPipeToken();\r
- bool PipeTokenCorrect = true;\r
-\r
- if (PipeToken != PIPE_TOKEN_SETUP)\r
- PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));\r
-\r
- if (PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))\r
- return true;\r
- }\r
-\r
- Pipe_SelectPipe(PrevPipeNumber);\r
- return false;\r
-}\r
-\r
-uint8_t Pipe_WaitUntilReady(void)\r
-{\r
- #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
- uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
- #else\r
- uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
- #endif\r
-\r
- uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();\r
-\r
- for (;;)\r
- {\r
- if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)\r
- {\r
- if (Pipe_IsINReceived())\r
- return PIPE_READYWAIT_NoError;\r
- }\r
- else\r
- {\r
- if (Pipe_IsOUTReady())\r
- return PIPE_READYWAIT_NoError;\r
- }\r
-\r
- if (Pipe_IsStalled())\r
- return PIPE_READYWAIT_PipeStalled;\r
- else if (USB_HostState == HOST_STATE_Unattached)\r
- return PIPE_READYWAIT_DeviceDisconnected;\r
-\r
- uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();\r
-\r
- if (CurrentFrameNumber != PreviousFrameNumber)\r
- {\r
- PreviousFrameNumber = CurrentFrameNumber;\r
-\r
- if (!(TimeoutMSRem--))\r
- return PIPE_READYWAIT_Timeout;\r
- }\r
- }\r
-}\r
-\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB Pipe definitions for the UC3B microcontrollers.\r
- * \copydetails Group_PipeManagement_UC3B\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-/** \ingroup Group_PipeRW\r
- * \defgroup Group_PipeRW_UC3B Pipe Data Reading and Writing (UC3B)\r
- * \brief Pipe data read/write definitions for the Atmel AVR32 UC3B architecture.\r
- *\r
- * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.\r
- */\r
-\r
-/** \ingroup Group_PipePrimitiveRW\r
- * \defgroup Group_PipePrimitiveRW_UC3B Read/Write of Primitive Data Types (UC3B)\r
- * \brief Pipe primative data read/write definitions for the Atmel AVR32 UC3B architecture.\r
- *\r
- * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
- * from and to pipes.\r
- */\r
-\r
-/** \ingroup Group_PipePacketManagement\r
- * \defgroup Group_PipePacketManagement_UC3B Pipe Packet Management (UC3B)\r
- * \brief Pipe packet management definitions for the Atmel AVR32 UC3B architecture.\r
- *\r
- * Functions, macros, variables, enums and types related to packet management of pipes.\r
- */\r
-\r
-/** \ingroup Group_PipeControlReq\r
- * \defgroup Group_PipeControlReq_UC3B Pipe Control Request Management (UC3B)\r
- * \brief Pipe control request management definitions for the Atmel AVR32 UC3B architecture.\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
-/** \ingroup Group_PipeManagement\r
- * \defgroup Group_PipeManagement_UC3B Pipe Management (UC3B)\r
- * \brief Pipe management definitions for the Atmel AVR32 UC3B architecture.\r
- *\r
- * This module contains 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 send/receive functions\r
- * for various data types.\r
- *\r
- * @{\r
- */\r
-\r
-#ifndef __PIPE_UC3B_H__\r
-#define __PIPE_UC3B_H__\r
-\r
- /* Includes: */\r
- #include "../../../../Common/Common.h"\r
- #include "../USBTask.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_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
- #endif\r
-\r
- /* Public Interface - May be used in end-application: */\r
- /* Macros: */\r
- /** \name Pipe Error Flag Masks */\r
- //@{\r
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
- #define PIPE_ERRORFLAG_OVERFLOW (1 << 6)\r
-\r
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */\r
- #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5)\r
-\r
- /** Mask for \ref 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 \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)\r
-\r
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_PID (1 << 2)\r
-\r
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_DATAPID (1 << 1)\r
-\r
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_DATATGL (1 << 0)\r
- //@}\r
-\r
- /** \name Pipe Token Masks */\r
- //@{\r
- /** Token mask for \ref 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 (0 << PTOKEN0)\r
-\r
- /** Token mask for \ref 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 (1 << PTOKEN0)\r
-\r
- /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes),\r
- * indicating that the pipe data will flow from host to device.\r
- */\r
- #define PIPE_TOKEN_OUT (2 << PTOKEN0)\r
- //@}\r
- \r
- /** \name Pipe Bank Mode Masks */\r
- //@{\r
- /** Mask for the bank mode selection for the \ref 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 << EPBK0)\r
-\r
- /** Mask for the bank mode selection for the \ref 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
- \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 64\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 0x0F\r
-\r
- /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's\r
- * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.\r
- */\r
- #define PIPE_EPDIR_MASK 0x80\r
-\r
- /* Enums: */\r
- /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.\r
- *\r
- * \ingroup Group_PipeRW_AVR8\r
- */\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
- * \ref USB_STREAM_TIMEOUT_MS macro.\r
- */\r
- };\r
-\r
- /* Inline Functions: */\r
- /** Indicates the number of bytes currently stored in the current pipes's selected bank.\r
- *\r
- * \note The return width of this function may differ, depending on the maximum pipe bank size\r
- * of the selected AVR model.\r
- *\r
- * \ingroup Group_PipeRW_AVR8\r
- *\r
- * \return Total number of bytes in the currently selected pipe's FIFO buffer.\r
- */\r
- static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint16_t Pipe_BytesInPipe(void)\r
- {\r
- return UPBCX;\r
- }\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
- * \return Index of the currently selected pipe.\r
- */\r
- static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Pipe_GetCurrentPipe(void)\r
- {\r
- return (UPNUM & PIPE_PIPENUM_MASK);\r
- }\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
- * \param[in] PipeNumber Index of the pipe to select.\r
- */\r
- static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_SelectPipe(const uint8_t PipeNumber)\r
- {\r
- UPNUM = PipeNumber;\r
- }\r
-\r
- /** Resets the desired pipe, including the pipe banks and flags.\r
- *\r
- * \param[in] PipeNumber Index of the pipe to reset.\r
- */\r
- static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ResetPipe(const uint8_t PipeNumber)\r
- {\r
- UPRST = (1 << PipeNumber);\r
- UPRST = 0;\r
- }\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
- * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe().\r
- */\r
- static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_EnablePipe(void)\r
- {\r
- UPCONX |= (1 << PEN);\r
- }\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
- static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_DisablePipe(void)\r
- {\r
- UPCONX &= ~(1 << PEN);\r
- }\r
-\r
- /** Determines if the currently selected pipe is enabled, but not necessarily configured.\r
- *\r
- * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsEnabled(void)\r
- {\r
- return ((UPCONX & (1 << PEN)) ? true : false);\r
- }\r
-\r
- /** Gets the current pipe token, indicating the pipe's data direction and type.\r
- *\r
- * \return The current pipe token, as a \c PIPE_TOKEN_* mask.\r
- */\r
- static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Pipe_GetPipeToken(void)\r
- {\r
- return (UPCFG0X & (0x03 << PTOKEN0));\r
- }\r
-\r
- /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*\r
- * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during\r
- * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices\r
- * which have two endpoints of opposite direction sharing the same endpoint address within the device.\r
- *\r
- * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask.\r
- */\r
- static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_SetPipeToken(const uint8_t Token)\r
- {\r
- UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);\r
- }\r
-\r
- /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */\r
- static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_SetInfiniteINRequests(void)\r
- {\r
- UPCONX |= (1 << INMODE);\r
- }\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
- * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing.\r
- */\r
- static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)\r
- {\r
- UPCONX &= ~(1 << INMODE);\r
- UPINRQX = TotalINRequests;\r
- }\r
-\r
- /** Determines if the currently selected pipe is configured.\r
- *\r
- * \return Boolean \c true if the selected pipe is configured, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsConfigured(void)\r
- {\r
- return ((UPSTAX & (1 << CFGOK)) ? true : false);\r
- }\r
-\r
- /** Retrieves the endpoint number of the endpoint within the attached device that the currently selected\r
- * pipe is bound to.\r
- *\r
- * \return Endpoint number the currently selected pipe is bound to.\r
- */\r
- static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Pipe_BoundEndpointNumber(void)\r
- {\r
- return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK);\r
- }\r
-\r
- /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
- *\r
- * \param[in] Milliseconds Number of milliseconds between each pipe poll.\r
- */\r
- static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)\r
- {\r
- UPCFG2X = Milliseconds;\r
- }\r
-\r
- /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should\r
- * be serviced.\r
- *\r
- * \return Mask whose bits indicate which pipes have interrupted.\r
- */\r
- static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Pipe_GetPipeInterrupts(void)\r
- {\r
- return UPINT;\r
- }\r
-\r
- /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type\r
- * pipes).\r
- *\r
- * \param[in] PipeNumber Index of the pipe whose interrupt flag should be tested.\r
- *\r
- * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise.\r
- */\r
- static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber)\r
- {\r
- return ((UPINT & (1 << PipeNumber)) ? true : false);\r
- }\r
-\r
- /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */\r
- static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_Unfreeze(void)\r
- {\r
- UPCONX &= ~(1 << PFREEZE);\r
- }\r
-\r
- /** Freezes the selected pipe, preventing it from communicating with an attached device. */\r
- static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_Freeze(void)\r
- {\r
- UPCONX |= (1 << PFREEZE);\r
- }\r
-\r
- /** Determines if the currently selected pipe is frozen, and not able to accept data.\r
- *\r
- * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsFrozen(void)\r
- {\r
- return ((UPCONX & (1 << PFREEZE)) ? true : false);\r
- }\r
-\r
- /** Clears the master pipe error flag. */\r
- static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearError(void)\r
- {\r
- UPINTX &= ~(1 << PERRI);\r
- }\r
-\r
- /** Determines 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 \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.\r
- *\r
- * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsError(void)\r
- {\r
- return ((UPINTX & (1 << PERRI)) ? true : false);\r
- }\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
- */\r
- static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearErrorFlags(void)\r
- {\r
- UPERRX = 0;\r
- }\r
-\r
- /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This\r
- * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.\r
- *\r
- * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe.\r
- */\r
- static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Pipe_GetErrorFlags(void)\r
- {\r
- return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |\r
- PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |\r
- PIPE_ERRORFLAG_DATATGL)) |\r
- (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW)));\r
- }\r
- \r
- /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for\r
- * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the\r
- * \ref Pipe_ClearIN() command.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Total number of busy banks in the selected pipe.\r
- */\r
- static inline uint8_t Pipe_GetBusyBanks(void)\r
- {\r
- return (UPSTAX & (0x03 << NBUSYBK0));\r
- }\r
-\r
- /** Determines 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 occurred in the pipe, or if the pipe\r
- * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT\r
- * direction and the pipe bank is full.\r
- *\r
- * \note This function is not valid on CONTROL type pipes.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the currently selected pipe may be read from or written to, depending\r
- * on its direction.\r
- */\r
- static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsReadWriteAllowed(void)\r
- {\r
- return ((UPINTX & (1 << RWAL)) ? true : false);\r
- }\r
-\r
- /** Determines if a packet has been received on the currently selected IN pipe from the attached device.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsINReceived(void)\r
- {\r
- return ((UPINTX & (1 << RXINI)) ? true : false);\r
- }\r
-\r
- /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsOUTReady(void)\r
- {\r
- return ((UPINTX & (1 << TXOUTI)) ? true : false);\r
- }\r
-\r
- /** Determines if no SETUP request is currently being sent to the attached device on the selected\r
- * CONTROL type pipe.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsSETUPSent(void)\r
- {\r
- return ((UPINTX & (1 << TXSTPI)) ? true : false);\r
- }\r
-\r
- /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- */\r
- static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearSETUP(void)\r
- {\r
- UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));\r
- }\r
-\r
- /** Acknowledges the reception of a setup IN request from the attached device on the currently selected\r
- * pipe, freeing the bank ready for the next packet.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- */\r
- static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearIN(void)\r
- {\r
- UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));\r
- }\r
-\r
- /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing\r
- * the bank ready for the next packet.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- */\r
- static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearOUT(void)\r
- {\r
- UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));\r
- }\r
-\r
- /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
- * the currently selected pipe. This occurs 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 cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet\r
- * can be re-sent.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsNAKReceived(void)\r
- {\r
- return ((UPINTX & (1 << NAKEDI)) ? true : false);\r
- }\r
-\r
- /** Clears the NAK condition on the currently selected pipe.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \see \ref Pipe_IsNAKReceived() for more details.\r
- */\r
- static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearNAKReceived(void)\r
- {\r
- UPINTX &= ~(1 << NAKEDI);\r
- }\r
-\r
- /** Determines if the currently selected pipe has had the STALL condition set by the attached device.\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- *\r
- * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise.\r
- */\r
- static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool Pipe_IsStalled(void)\r
- {\r
- return ((UPINTX & (1 << RXSTALLI)) ? true : false);\r
- }\r
-\r
- /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the\r
- * STALL condition itself (this must be done via a ClearFeature control request to the device).\r
- *\r
- * \ingroup Group_PipePacketManagement_AVR8\r
- */\r
- static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_ClearStall(void)\r
- {\r
- UPINTX &= ~(1 << RXSTALLI);\r
- }\r
-\r
- /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \return Next byte in the currently selected pipe's FIFO buffer.\r
- */\r
- static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \param[in] Byte Next byte to write into the the currently selected pipe's FIFO buffer.\r
- */\r
- static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\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
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- */\r
- static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE;\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
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \return Next word in the currently selected pipe's FIFO buffer.\r
- */\r
- static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint16_t Pipe_Read_Word_LE(void)\r
- {\r
- union\r
- {\r
- uint16_t Word;\r
- uint8_t Bytes[2];\r
- } Data;\r
-\r
- Data.Bytes[0] = UPDATX;\r
- Data.Bytes[1] = UPDATX;\r
-\r
- return Data.Word;\r
- }\r
-\r
- /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT\r
- * direction pipes.\r
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \return Next word in the currently selected pipe's FIFO buffer.\r
- */\r
- static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint16_t Pipe_Read_Word_BE(void)\r
- {\r
- union\r
- {\r
- uint16_t Word;\r
- uint8_t Bytes[2];\r
- } Data;\r
-\r
- Data.Bytes[1] = UPDATX;\r
- Data.Bytes[0] = UPDATX;\r
-\r
- return Data.Word;\r
- }\r
-\r
- /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN\r
- * direction pipes.\r
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.\r
- */\r
- static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\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
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.\r
- */\r
- static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\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
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- */\r
- static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_Discard_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
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \return Next double word in the currently selected pipe's FIFO buffer.\r
- */\r
- static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \return Next double word in the currently selected pipe's FIFO buffer.\r
- */\r
- static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.\r
- */\r
- static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_Write_DWord_LE(const uint32_t DWord)\r
- {\r
- UPDATX = (DWord & 0xFF);\r
- UPDATX = (DWord >> 8);\r
- UPDATX = (DWord >> 16);\r
- UPDATX = (DWord >> 24);\r
- }\r
-\r
- /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
- * direction pipes.\r
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- *\r
- * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.\r
- */\r
- static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_Write_DWord_BE(const uint32_t DWord)\r
- {\r
- UPDATX = (DWord >> 24);\r
- UPDATX = (DWord >> 16);\r
- UPDATX = (DWord >> 8);\r
- UPDATX = (DWord & 0xFF);\r
- }\r
-\r
- /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.\r
- *\r
- * \ingroup Group_PipePrimitiveRW_AVR8\r
- */\r
- static inline void Pipe_Discard_DWord(void) ATTR_ALWAYS_INLINE;\r
- static inline void Pipe_Discard_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.\r
- *\r
- * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()\r
- * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or\r
- * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite\r
- * numbers of IN requests without automatic freezing - this can be overridden by a call to\r
- * \ref Pipe_SetFiniteINRequests().\r
- *\r
- * \param[in] Number Pipe number to configure. This must be more than 0 and less than \ref PIPE_TOTAL_PIPES.\r
- *\r
- * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low\r
- * Speed USB devices - refer to the USB 2.0 specification.\r
- *\r
- * \param[in] Token Pipe data token, either \ref PIPE_TOKEN_SETUP, \ref PIPE_TOKEN_OUT or \ref PIPE_TOKEN_IN.\r
- * All pipes (except Control type) are unidirectional - data may only be read from or\r
- * written to the pipe bank based on its direction, not both.\r
- *\r
- * \param[in] EndpointNumber Endpoint index within the attached device that the pipe should interface to.\r
- *\r
- * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to\r
- * the USB device, or after they have been received from the USB device (depending on\r
- * the pipe's data direction). The bank size must indicate the maximum packet size that\r
- * the pipe can handle.\r
- *\r
- * \param[in] Banks Number of banks to use for the pipe being configured, a \c PIPE_BANK_* mask. More banks\r
- * uses more USB DPRAM, but offers better performance. Isochronous type pipes <b>must</b>\r
- * have at least two banks.\r
- *\r
- * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes <b>must</b> be configured in ascending order,\r
- * or bank corruption will occur.\r
- * \n\n\r
- *\r
- * \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's\r
- * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each pipe.\r
- * \n\n\r
- *\r
- * \note The default control pipe should not be manually configured by the user application, as it is\r
- * automatically configured by the library internally.\r
- * \n\n\r
- *\r
- * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which\r
- * failed to reconfigure correctly will be selected.\r
- *\r
- * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
- */\r
- bool Pipe_ConfigurePipe(const uint8_t Number,\r
- const uint8_t Type,\r
- const uint8_t Token,\r
- const uint8_t EndpointNumber,\r
- const uint16_t Size,\r
- const uint8_t Banks);\r
-\r
- /** Spin-loops until the currently selected non-control pipe is ready for the next packed of data to be read\r
- * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).\r
- *\r
- * \ingroup Group_PipeRW_AVR8\r
- *\r
- * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
- */\r
- uint8_t Pipe_WaitUntilReady(void);\r
-\r
- /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given\r
- * endpoint is found, it is automatically selected.\r
- *\r
- * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check.\r
- *\r
- * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found,\r
- * \c false otherwise.\r
- */\r
- bool Pipe_IsEndpointBound(const uint8_t EndpointAddress);\r
-\r
- /* Private Interface - For use in library only: */\r
- #if !defined(__DOXYGEN__)\r
- /* Macros: */\r
- #if !defined(ENDPOINT_CONTROLEP)\r
- #define ENDPOINT_CONTROLEP 0\r
- #endif\r
-\r
- /* Inline Functions: */\r
- static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
- static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)\r
- {\r
- uint8_t MaskVal = 0;\r
- uint16_t CheckBytes = 8;\r
-\r
- while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))\r
- {\r
- MaskVal++;\r
- CheckBytes <<= 1;\r
- }\r
-\r
- return (MaskVal << EPSIZE0);\r
- }\r
-\r
- /* Function Prototypes: */\r
- void Pipe_ClearPipes(void);\r
- #endif\r
-\r
- /* Disable C linkage for C++ Compilers: */\r
- #if defined(__cplusplus)\r
- }\r
- #endif\r
-\r
-#endif\r
-\r
-/** @} */\r
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#include "../Pipe.h"\r
+\r
+uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+bool Pipe_ConfigurePipe(const uint8_t Number,\r
+ const uint8_t Type,\r
+ const uint8_t Token,\r
+ const uint8_t EndpointNumber,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+{\r
+#if defined(ORDERED_EP_CONFIG)\r
+ Pipe_SelectPipe(Number);\r
+ Pipe_EnablePipe();\r
+\r
+ UPCFG1X = 0;\r
+\r
+ UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));\r
+ UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
+\r
+ Pipe_SetInfiniteINRequests();\r
+\r
+ return Pipe_IsConfigured();\r
+#else \r
+ for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ uint8_t UPCFG0XTemp;\r
+ uint8_t UPCFG1XTemp;\r
+ uint8_t UPCFG2XTemp;\r
+ uint8_t UPCONXTemp;\r
+ uint8_t UPINRQXTemp;\r
+ uint8_t UPIENXTemp;\r
+\r
+ Pipe_SelectPipe(PNum);\r
+ \r
+ if (PNum == Number)\r
+ {\r
+ UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));\r
+ UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
+ UPCFG2XTemp = 0;\r
+ UPCONXTemp = ((1 << PEN) | (1 << INMODE));\r
+ UPINRQXTemp = 0;\r
+ UPIENXTemp = 0;\r
+ }\r
+ else\r
+ {\r
+ UPCFG0XTemp = UPCFG0X;\r
+ UPCFG1XTemp = UPCFG1X;\r
+ UPCFG2XTemp = UPCFG2X;\r
+ UPCONXTemp = UPCONX;\r
+ UPINRQXTemp = UPINRQX;\r
+ UPIENXTemp = UPIENX;\r
+ }\r
+\r
+ if (!(UPCFG1XTemp & (1 << ALLOC)))\r
+ continue;\r
+ \r
+ Pipe_DisablePipe();\r
+ UPCFG1X &= (1 << ALLOC);\r
+\r
+ Pipe_EnablePipe();\r
+ UPCFG0X = UPCFG0XTemp;\r
+ UPCFG1X = UPCFG1XTemp;\r
+ UPCFG2X = UPCFG2XTemp;\r
+ UPCONX = UPCONXTemp;\r
+ UPINRQX = UPINRQXTemp;\r
+ UPIENX = UPIENXTemp;\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ return false; \r
+ }\r
+ \r
+ Pipe_SelectPipe(Number); \r
+ return true;\r
+#endif\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_SelectPipe(PNum);\r
+ UPIENX = 0;\r
+ UPINTX = 0;\r
+ UPCFG1X = 0;\r
+ Pipe_DisablePipe();\r
+ }\r
+}\r
+\r
+bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)\r
+{\r
+ uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();\r
+\r
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ Pipe_SelectPipe(PNum);\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ continue;\r
+\r
+ uint8_t PipeToken = Pipe_GetPipeToken();\r
+ bool PipeTokenCorrect = true;\r
+\r
+ if (PipeToken != PIPE_TOKEN_SETUP)\r
+ PipeTokenCorrect = (PipeToken == ((EndpointAddress & PIPE_EPDIR_MASK) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT));\r
+\r
+ if (PipeTokenCorrect && (Pipe_BoundEndpointNumber() == (EndpointAddress & PIPE_EPNUM_MASK)))\r
+ return true;\r
+ }\r
+\r
+ Pipe_SelectPipe(PrevPipeNumber);\r
+ return false;\r
+}\r
+\r
+uint8_t Pipe_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)\r
+ {\r
+ if (Pipe_IsINReceived())\r
+ return PIPE_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Pipe_IsOUTReady())\r
+ return PIPE_READYWAIT_NoError;\r
+ }\r
+\r
+ if (Pipe_IsStalled())\r
+ return PIPE_READYWAIT_PipeStalled;\r
+ else if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return PIPE_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB Pipe definitions for the UC3B microcontrollers.\r
+ * \copydetails Group_PipeManagement_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeRW\r
+ * \defgroup Group_PipeRW_UC3B Pipe Data Reading and Writing (UC3B)\r
+ * \brief Pipe data read/write definitions for the Atmel AVR32 UC3B architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipePrimitiveRW\r
+ * \defgroup Group_PipePrimitiveRW_UC3B Read/Write of Primitive Data Types (UC3B)\r
+ * \brief Pipe primative data read/write definitions for the Atmel AVR32 UC3B architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipePacketManagement\r
+ * \defgroup Group_PipePacketManagement_UC3B Pipe Packet Management (UC3B)\r
+ * \brief Pipe packet management definitions for the Atmel AVR32 UC3B architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipeControlReq\r
+ * \defgroup Group_PipeControlReq_UC3B Pipe Control Request Management (UC3B)\r
+ * \brief Pipe control request management definitions for the Atmel AVR32 UC3B architecture.\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
+/** \ingroup Group_PipeManagement\r
+ * \defgroup Group_PipeManagement_UC3B Pipe Management (UC3B)\r
+ * \brief Pipe management definitions for the Atmel AVR32 UC3B architecture.\r
+ *\r
+ * This module contains 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 send/receive functions\r
+ * for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_UC3B_H__\r
+#define __PIPE_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.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_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name Pipe Error Flag Masks */\r
+ //@{\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_OVERFLOW (1 << 6)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5)\r
+\r
+ /** Mask for \ref 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 \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_PID (1 << 2)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATAPID (1 << 1)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATATGL (1 << 0)\r
+ //@}\r
+\r
+ /** \name Pipe Token Masks */\r
+ //@{\r
+ /** Token mask for \ref 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 (0 << PTOKEN0)\r
+\r
+ /** Token mask for \ref 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 (1 << PTOKEN0)\r
+\r
+ /** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from host to device.\r
+ */\r
+ #define PIPE_TOKEN_OUT (2 << PTOKEN0)\r
+ //@}\r
+ \r
+ /** \name Pipe Bank Mode Masks */\r
+ //@{\r
+ /** Mask for the bank mode selection for the \ref 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 << EPBK0)\r
+\r
+ /** Mask for the bank mode selection for the \ref 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
+ \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 64\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 0x0F\r
+\r
+ /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * direction for comparing with the \c ENDPOINT_DESCRIPTOR_DIR_* masks.\r
+ */\r
+ #define PIPE_EPDIR_MASK 0x80\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_PipeRW_AVR8\r
+ */\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
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Indicates the number of bytes currently stored in the current pipes's selected bank.\r
+ *\r
+ * \note The return width of this function may differ, depending on the maximum pipe bank size\r
+ * of the selected AVR model.\r
+ *\r
+ * \ingroup Group_PipeRW_AVR8\r
+ *\r
+ * \return Total number of bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_BytesInPipe(void)\r
+ {\r
+ return UPBCX;\r
+ }\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
+ * \return Index of the currently selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetCurrentPipe(void)\r
+ {\r
+ return (UPNUM & PIPE_PIPENUM_MASK);\r
+ }\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
+ * \param[in] PipeNumber Index of the pipe to select.\r
+ */\r
+ static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SelectPipe(const uint8_t PipeNumber)\r
+ {\r
+ UPNUM = PipeNumber;\r
+ }\r
+\r
+ /** Resets the desired pipe, including the pipe banks and flags.\r
+ *\r
+ * \param[in] PipeNumber Index of the pipe to reset.\r
+ */\r
+ static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ResetPipe(const uint8_t PipeNumber)\r
+ {\r
+ UPRST = (1 << PipeNumber);\r
+ UPRST = 0;\r
+ }\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
+ * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe().\r
+ */\r
+ static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_EnablePipe(void)\r
+ {\r
+ UPCONX |= (1 << PEN);\r
+ }\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
+ static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_DisablePipe(void)\r
+ {\r
+ UPCONX &= ~(1 << PEN);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsEnabled(void)\r
+ {\r
+ return ((UPCONX & (1 << PEN)) ? true : false);\r
+ }\r
+\r
+ /** Gets the current pipe token, indicating the pipe's data direction and type.\r
+ *\r
+ * \return The current pipe token, as a \c PIPE_TOKEN_* mask.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeToken(void)\r
+ {\r
+ return (UPCFG0X & (0x03 << PTOKEN0));\r
+ }\r
+\r
+ /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*\r
+ * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during\r
+ * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices\r
+ * which have two endpoints of opposite direction sharing the same endpoint address within the device.\r
+ *\r
+ * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask.\r
+ */\r
+ static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetPipeToken(const uint8_t Token)\r
+ {\r
+ UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);\r
+ }\r
+\r
+ /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */\r
+ static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetInfiniteINRequests(void)\r
+ {\r
+ UPCONX |= (1 << INMODE);\r
+ }\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
+ * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing.\r
+ */\r
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)\r
+ {\r
+ UPCONX &= ~(1 << INMODE);\r
+ UPINRQX = TotalINRequests;\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is configured.\r
+ *\r
+ * \return Boolean \c true if the selected pipe is configured, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsConfigured(void)\r
+ {\r
+ return ((UPSTAX & (1 << CFGOK)) ? true : false);\r
+ }\r
+\r
+ /** Retrieves the endpoint number of the endpoint within the attached device that the currently selected\r
+ * pipe is bound to.\r
+ *\r
+ * \return Endpoint number the currently selected pipe is bound to.\r
+ */\r
+ static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_BoundEndpointNumber(void)\r
+ {\r
+ return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK);\r
+ }\r
+\r
+ /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
+ *\r
+ * \param[in] Milliseconds Number of milliseconds between each pipe poll.\r
+ */\r
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)\r
+ {\r
+ UPCFG2X = Milliseconds;\r
+ }\r
+\r
+ /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should\r
+ * be serviced.\r
+ *\r
+ * \return Mask whose bits indicate which pipes have interrupted.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeInterrupts(void)\r
+ {\r
+ return UPINT;\r
+ }\r
+\r
+ /** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type\r
+ * pipes).\r
+ *\r
+ * \param[in] PipeNumber Index of the pipe whose interrupt flag should be tested.\r
+ *\r
+ * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber)\r
+ {\r
+ return ((UPINT & (1 << PipeNumber)) ? true : false);\r
+ }\r
+\r
+ /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */\r
+ static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Unfreeze(void)\r
+ {\r
+ UPCONX &= ~(1 << PFREEZE);\r
+ }\r
+\r
+ /** Freezes the selected pipe, preventing it from communicating with an attached device. */\r
+ static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Freeze(void)\r
+ {\r
+ UPCONX |= (1 << PFREEZE);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is frozen, and not able to accept data.\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsFrozen(void)\r
+ {\r
+ return ((UPCONX & (1 << PFREEZE)) ? true : false);\r
+ }\r
+\r
+ /** Clears the master pipe error flag. */\r
+ static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearError(void)\r
+ {\r
+ UPINTX &= ~(1 << PERRI);\r
+ }\r
+\r
+ /** Determines 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 \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.\r
+ *\r
+ * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsError(void)\r
+ {\r
+ return ((UPINTX & (1 << PERRI)) ? true : false);\r
+ }\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
+ */\r
+ static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearErrorFlags(void)\r
+ {\r
+ UPERRX = 0;\r
+ }\r
+\r
+ /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This\r
+ * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.\r
+ *\r
+ * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetErrorFlags(void)\r
+ {\r
+ return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |\r
+ PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |\r
+ PIPE_ERRORFLAG_DATATGL)) |\r
+ (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW)));\r
+ }\r
+ \r
+ /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for\r
+ * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the\r
+ * \ref Pipe_ClearIN() command.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Total number of busy banks in the selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetBusyBanks(void)\r
+ {\r
+ return (UPSTAX & (0x03 << NBUSYBK0));\r
+ }\r
+\r
+ /** Determines 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 occurred in the pipe, or if the pipe\r
+ * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT\r
+ * direction and the pipe bank is full.\r
+ *\r
+ * \note This function is not valid on CONTROL type pipes.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsReadWriteAllowed(void)\r
+ {\r
+ return ((UPINTX & (1 << RWAL)) ? true : false);\r
+ }\r
+\r
+ /** Determines if a packet has been received on the currently selected IN pipe from the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsINReceived(void)\r
+ {\r
+ return ((UPINTX & (1 << RXINI)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsOUTReady(void)\r
+ {\r
+ return ((UPINTX & (1 << TXOUTI)) ? true : false);\r
+ }\r
+\r
+ /** Determines if no SETUP request is currently being sent to the attached device on the selected\r
+ * CONTROL type pipe.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsSETUPSent(void)\r
+ {\r
+ return ((UPINTX & (1 << TXSTPI)) ? true : false);\r
+ }\r
+\r
+ /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearSETUP(void)\r
+ {\r
+ UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));\r
+ }\r
+\r
+ /** Acknowledges the reception of a setup IN request from the attached device on the currently selected\r
+ * pipe, freeing the bank ready for the next packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearIN(void)\r
+ {\r
+ UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));\r
+ }\r
+\r
+ /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing\r
+ * the bank ready for the next packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearOUT(void)\r
+ {\r
+ UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));\r
+ }\r
+\r
+ /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
+ * the currently selected pipe. This occurs 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 cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet\r
+ * can be re-sent.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsNAKReceived(void)\r
+ {\r
+ return ((UPINTX & (1 << NAKEDI)) ? true : false);\r
+ }\r
+\r
+ /** Clears the NAK condition on the currently selected pipe.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \see \ref Pipe_IsNAKReceived() for more details.\r
+ */\r
+ static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearNAKReceived(void)\r
+ {\r
+ UPINTX &= ~(1 << NAKEDI);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe has had the STALL condition set by the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsStalled(void)\r
+ {\r
+ return ((UPINTX & (1 << RXSTALLI)) ? true : false);\r
+ }\r
+\r
+ /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the\r
+ * STALL condition itself (this must be done via a ClearFeature control request to the device).\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearStall(void)\r
+ {\r
+ UPINTX &= ~(1 << RXSTALLI);\r
+ }\r
+\r
+ /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next byte in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Byte Next byte to write into the the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\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
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ */\r
+ static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE;\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
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next word in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_Read_Word_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Word;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[0] = UPDATX;\r
+ Data.Bytes[1] = UPDATX;\r
+\r
+ return Data.Word;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next word in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_Read_Word_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Word;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[1] = UPDATX;\r
+ Data.Bytes[0] = UPDATX;\r
+\r
+ return Data.Word;\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\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
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Word Next word to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\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
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ */\r
+ static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_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
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next double word in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next double word in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\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
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_DWord_LE(const uint32_t DWord)\r
+ {\r
+ UPDATX = (DWord & 0xFF);\r
+ UPDATX = (DWord >> 8);\r
+ UPDATX = (DWord >> 16);\r
+ UPDATX = (DWord >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_DWord_BE(const uint32_t DWord)\r
+ {\r
+ UPDATX = (DWord >> 24);\r
+ UPDATX = (DWord >> 16);\r
+ UPDATX = (DWord >> 8);\r
+ UPDATX = (DWord & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ */\r
+ static inline void Pipe_Discard_DWord(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_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.\r
+ *\r
+ * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()\r
+ * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or\r
+ * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite\r
+ * numbers of IN requests without automatic freezing - this can be overridden by a call to\r
+ * \ref Pipe_SetFiniteINRequests().\r
+ *\r
+ * \param[in] Number Pipe number to configure. This must be more than 0 and less than \ref PIPE_TOTAL_PIPES.\r
+ *\r
+ * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low\r
+ * Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] Token Pipe data token, either \ref PIPE_TOKEN_SETUP, \ref PIPE_TOKEN_OUT or \ref PIPE_TOKEN_IN.\r
+ * All pipes (except Control type) are unidirectional - data may only be read from or\r
+ * written to the pipe bank based on its direction, not both.\r
+ *\r
+ * \param[in] EndpointNumber Endpoint index within the attached device that the pipe should interface to.\r
+ *\r
+ * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to\r
+ * the USB device, or after they have been received from the USB device (depending on\r
+ * the pipe's data direction). The bank size must indicate the maximum packet size that\r
+ * the pipe can handle.\r
+ *\r
+ * \param[in] Banks Number of banks to use for the pipe being configured, a \c PIPE_BANK_* mask. More banks\r
+ * uses more USB DPRAM, but offers better performance. Isochronous type pipes <b>must</b>\r
+ * have at least two banks.\r
+ *\r
+ * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes <b>must</b> be configured in ascending order,\r
+ * or bank corruption will occur.\r
+ * \n\n\r
+ *\r
+ * \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's\r
+ * index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each pipe.\r
+ * \n\n\r
+ *\r
+ * \note The default control pipe should not be manually configured by the user application, as it is\r
+ * automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which\r
+ * failed to reconfigure correctly will be selected.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ bool Pipe_ConfigurePipe(const uint8_t Number,\r
+ const uint8_t Type,\r
+ const uint8_t Token,\r
+ const uint8_t EndpointNumber,\r
+ const uint16_t Size,\r
+ const uint8_t Banks);\r
+\r
+ /** Spin-loops until the currently selected non-control pipe is ready for the next packed of data to be read\r
+ * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).\r
+ *\r
+ * \ingroup Group_PipeRW_AVR8\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_WaitUntilReady(void);\r
+\r
+ /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given\r
+ * endpoint is found, it is automatically selected.\r
+ *\r
+ * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check.\r
+ *\r
+ * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found,\r
+ * \c false otherwise.\r
+ */\r
+ bool Pipe_IsEndpointBound(const uint8_t EndpointAddress);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #if !defined(ENDPOINT_CONTROLEP)\r
+ #define ENDPOINT_CONTROLEP 0\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << EPSIZE0);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ void Pipe_ClearPipes(void);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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_USB_DRIVER\r
-#define __INCLUDE_FROM_USB_CONTROLLER_C\r
-#include "USBController.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
- #if !defined(USE_STATIC_OPTIONS)\r
- USB_Options = Options;\r
- #endif\r
-\r
- if (!(USB_Options & USB_OPT_REG_DISABLED))\r
- USB_REG_On();\r
- else\r
- USB_REG_Off();\r
-\r
- #if defined(USB_CAN_BE_BOTH)\r
- if (Mode == USB_MODE_UID)\r
- {\r
- UHWCON |= (1 << UIDE);\r
- USB_INT_Enable(USB_INT_IDTI);\r
- USB_CurrentMode = USB_GetUSBModeFromUID();\r
- }\r
- else\r
- {\r
- USB_CurrentMode = Mode;\r
- }\r
- #endif\r
-\r
- USB_IsInitialized = true;\r
-\r
- USB_ResetInterface();\r
-}\r
-\r
-void USB_Disable(void)\r
-{\r
- USB_INT_DisableAllInterrupts();\r
- USB_INT_ClearAllInterrupts();\r
-\r
- USB_Detach();\r
- USB_Controller_Disable();\r
-\r
- if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
- USB_PLL_Off();\r
-\r
- USB_REG_Off();\r
-\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- USB_OTGPAD_Off();\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_BOTH)\r
- USB_CurrentMode = USB_MODE_None;\r
- #endif\r
-\r
- USB_IsInitialized = false;\r
-}\r
-\r
-void USB_ResetInterface(void)\r
-{\r
- #if defined(USB_CAN_BE_BOTH)\r
- bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0);\r
- #endif\r
-\r
- USB_INT_DisableAllInterrupts();\r
- USB_INT_ClearAllInterrupts();\r
-\r
- USB_Controller_Reset();\r
-\r
- if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
- {\r
- #if defined(USB_SERIES_4_AVR)\r
- PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));\r
- #endif\r
-\r
- USB_PLL_On();\r
- while (!(USB_PLL_IsReady()));\r
- }\r
-\r
- #if defined(USB_CAN_BE_BOTH)\r
- if (UIDModeSelectEnabled)\r
- {\r
- UHWCON |= (1 << UIDE);\r
- USB_INT_Enable(USB_INT_IDTI);\r
- }\r
- #endif\r
-\r
- USB_CLK_Unfreeze();\r
-\r
- if (USB_CurrentMode == USB_MODE_Device)\r
- {\r
- #if defined(USB_CAN_BE_DEVICE)\r
- #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
- UHWCON |= (1 << UIMOD);\r
- #endif\r
-\r
- USB_Init_Device();\r
- #endif\r
- }\r
- else if (USB_CurrentMode == USB_MODE_Host)\r
- {\r
- #if defined(USB_CAN_BE_HOST)\r
- UHWCON &= ~(1 << UIMOD);\r
-\r
- USB_Init_Host();\r
- #endif\r
- }\r
-\r
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
- USB_OTGPAD_On();\r
- #endif\r
-}\r
-\r
-#if defined(USB_CAN_BE_DEVICE)\r
-static void USB_Init_Device(void)\r
-{\r
- USB_DeviceState = DEVICE_STATE_Unattached;\r
- USB_ConfigurationNumber = 0;\r
-\r
- #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
- USB_RemoteWakeupEnabled = false;\r
- #endif\r
-\r
- #if !defined(NO_DEVICE_SELF_POWER)\r
- USB_CurrentlySelfPowered = false;\r
- #endif\r
-\r
- #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
- USB_Descriptor_Device_t* DeviceDescriptorPtr;\r
-\r
- if (CALLBACK_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
- #endif\r
-\r
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
- if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
- USB_Device_SetLowSpeed();\r
- else\r
- USB_Device_SetFullSpeed();\r
-\r
- USB_INT_Enable(USB_INT_VBUS);\r
- #endif\r
-\r
- Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
- ENDPOINT_DIR_OUT, USB_ControlEndpointSize,\r
- ENDPOINT_BANK_SINGLE);\r
-\r
- USB_INT_Clear(USB_INT_SUSPI);\r
- USB_INT_Enable(USB_INT_SUSPI);\r
- USB_INT_Enable(USB_INT_EORSTI);\r
-\r
- USB_Attach();\r
-}\r
-#endif\r
-\r
-#if defined(USB_CAN_BE_HOST)\r
-static void USB_Init_Host(void)\r
-{\r
- USB_HostState = HOST_STATE_Unattached;\r
- USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
-\r
- USB_Host_HostMode_On();\r
-\r
- USB_Host_VBUS_Auto_Off();\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
- USB_Attach();\r
-}\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB Controller definitions for the AVR32 UC3B microcontrollers.\r
- * \copydetails Group_USBManagement_UC3B\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-/** \ingroup Group_USBManagement\r
- * \defgroup Group_USBManagement_UC3B USB Interface Management (UC3B)\r
- * \brief USB Controller definitions for the AVR32 UC3B microcontrollers.\r
- *\r
- * Functions, macros, variables, enums and types related to the setup and management of the USB interface.\r
- *\r
- * @{\r
- */\r
-\r
-#ifndef __USBCONTROLLER_UC3B_H__\r
-#define __USBCONTROLLER_UC3B_H__\r
-\r
- /* Includes: */\r
- #include "../../../../Common/Common.h"\r
- #include "../USBMode.h"\r
- #include "../Events.h"\r
- #include "../USBTask.h"\r
- #include "../USBInterrupt.h"\r
-\r
- #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
- #include "../Host.h"\r
- #include "../OTG.h"\r
- #include "../Pipe.h"\r
- #include "../HostStandardReq.h"\r
- #include "../PipeStream.h"\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
- #include "../Device.h"\r
- #include "../Endpoint.h"\r
- #include "../DeviceStandardReq.h"\r
- #include "../EndpointStream.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 !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
- #endif\r
-\r
- #if !defined(F_CLOCK)\r
- #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled USB controller clock in your project makefile.\r
- #endif\r
-\r
- #if (F_CLOCK == 8000000)\r
- #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \\r
- defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \\r
- defined(__AVR_ATmega32U2__))\r
- #define USB_PLL_PSC 0\r
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
- #define USB_PLL_PSC 0\r
- #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))\r
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
- #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))\r
- #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
- #endif\r
- #elif (F_CLOCK == 16000000)\r
- #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \\r
- defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \\r
- defined(__AVR_ATmega32U2__))\r
- #define USB_PLL_PSC (1 << PLLP0)\r
- #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
- #define USB_PLL_PSC (1 << PINDIV)\r
- #elif (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
- #endif\r
- #endif\r
-\r
- #if !defined(USB_PLL_PSC)\r
- #error No PLL prescale value available for chosen F_CLOCK value and AVR model.\r
- #endif\r
-\r
- /* Public Interface - May be used in end-application: */\r
- /* Macros: */\r
- /** \name USB Controller Option Masks */\r
- //@{\r
- /** Regulator disable option mask for \ref 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 \ref 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 \ref 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 \ref 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
- \r
- /** \name Endpoint/Pipe Type Masks */\r
- //@{\r
- /** Mask for a CONTROL type endpoint or pipe.\r
- *\r
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
- */\r
- #define EP_TYPE_CONTROL 0x00\r
-\r
- /** Mask for an ISOCHRONOUS type endpoint or pipe.\r
- *\r
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
- */\r
- #define EP_TYPE_ISOCHRONOUS 0x01\r
-\r
- /** Mask for a BULK type endpoint or pipe.\r
- *\r
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
- */\r
- #define EP_TYPE_BULK 0x02\r
-\r
- /** Mask for an INTERRUPT type endpoint or pipe.\r
- *\r
- * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
- */\r
- #define EP_TYPE_INTERRUPT 0x03\r
- //@}\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 acknowledged 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
- * \ref 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
- /* Inline Functions: */\r
- /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
- * attached host, ceasing USB communications. If no host is present, this prevents any host from\r
- * enumerating the device once attached until \ref USB_Attach() is called.\r
- */\r
- static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Detach(void)\r
- {\r
- UDCON |= (1 << DETACH);\r
- }\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
- static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Attach(void)\r
- {\r
- UDCON &= ~(1 << DETACH);\r
- }\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 interrupts for the device and host mode enumeration processes,\r
- * the user must enable global interrupts before or shortly after this function is called. In\r
- * device mode, interrupts must be enabled within 500ms of this function being called to ensure\r
- * that the host does not time out whilst enumerating the device. In host mode, interrupts may be\r
- * enabled at the application's leisure however enumeration will not begin of an attached device\r
- * until after this has occurred.\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[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value\r
- * from the \ref USB_Modes_t enum.\r
- *\r
- * \param[in] 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 \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the\r
- * PLL, and a \c 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
- * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY\r
- * (for device mode) or \c USB_HOST_ONLY (for host mode), 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
- * \n\n\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 \c 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
- * \n\n\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 \ref Group_Device for the \c 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 \ref USB_Init() function.\r
- */\r
- void USB_Disable(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
- /* 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, a value from the\r
- * \ref USB_Modes_t enum.\r
- *\r
- * \note This variable should be treated as read-only in the user application, and never manually\r
- * changed in value.\r
- * \n\n\r
- *\r
- * \note When the controller is initialized into UID auto-detection mode, this variable will hold the\r
- * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller\r
- * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time\r
- * options, or a limitation of the USB controller in the chosen device model) this will evaluate to\r
- * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the\r
- * USB interface is not initialized.\r
- */\r
- extern volatile uint8_t USB_CurrentMode;\r
- #elif defined(USB_HOST_ONLY)\r
- #define USB_CurrentMode USB_MODE_Host\r
- #elif defined(USB_DEVICE_ONLY)\r
- #define USB_CurrentMode USB_MODE_Device\r
- #endif\r
-\r
- #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
- /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()\r
- * was called. This value will be one of the \c 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_Options;\r
- #elif defined(USE_STATIC_OPTIONS)\r
- #define USB_Options USE_STATIC_OPTIONS\r
- #endif\r
-\r
- /* Enums: */\r
- /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the\r
- * user application via \ref USB_CurrentMode.\r
- */\r
- enum USB_Modes_t\r
- {\r
- USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */\r
- USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */\r
- USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */\r
- USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the\r
- * USB connector.\r
- */\r
- };\r
-\r
- /* Private Interface - For use in library only: */\r
- #if !defined(__DOXYGEN__)\r
- /* Function Prototypes: */\r
- #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)\r
- #if defined(USB_CAN_BE_DEVICE)\r
- static void USB_Init_Device(void);\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_HOST)\r
- static void USB_Init_Host(void);\r
- #endif\r
- #endif\r
-\r
- /* Inline Functions: */\r
- static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_PLL_On(void)\r
- {\r
- PLLCSR = USB_PLL_PSC;\r
- PLLCSR |= (1 << PLLE);\r
- }\r
-\r
- static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_PLL_Off(void)\r
- {\r
- PLLCSR = 0;\r
- }\r
-\r
- static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline bool USB_PLL_IsReady(void)\r
- {\r
- return ((PLLCSR & (1 << PLOCK)) ? true : false);\r
- }\r
-\r
- static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_REG_On(void)\r
- {\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- UHWCON |= (1 << UVREGE);\r
- #else\r
- REGCR &= ~(1 << REGDIS);\r
- #endif\r
- }\r
-\r
- static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_REG_Off(void)\r
- {\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- UHWCON &= ~(1 << UVREGE);\r
- #else\r
- REGCR |= (1 << REGDIS);\r
- #endif\r
- }\r
-\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTGPAD_On(void)\r
- {\r
- USBCON |= (1 << OTGPADE);\r
- }\r
-\r
- static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_OTGPAD_Off(void)\r
- {\r
- USBCON &= ~(1 << OTGPADE);\r
- }\r
- #endif\r
-\r
- static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_CLK_Freeze(void)\r
- {\r
- USBCON |= (1 << FRZCLK);\r
- }\r
-\r
- static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_CLK_Unfreeze(void)\r
- {\r
- USBCON &= ~(1 << FRZCLK);\r
- }\r
-\r
- static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Controller_Enable(void)\r
- {\r
- USBCON |= (1 << USBE);\r
- }\r
-\r
- static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Controller_Disable(void)\r
- {\r
- USBCON &= ~(1 << USBE);\r
- }\r
-\r
- static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;\r
- static inline void USB_Controller_Reset(void)\r
- {\r
- const uint8_t Temp = USBCON;\r
-\r
- USBCON = (Temp & ~(1 << USBE));\r
- USBCON = (Temp | (1 << USBE));\r
- }\r
-\r
- #if defined(USB_CAN_BE_BOTH)\r
- static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
- static inline uint8_t USB_GetUSBModeFromUID(void)\r
- {\r
- if (USBSTA & (1 << ID))\r
- return USB_MODE_Device;\r
- else\r
- return USB_MODE_Host;\r
- }\r
- #endif\r
-\r
- #endif\r
-\r
- /* Disable C linkage for C++ Compilers: */\r
- #if defined(__cplusplus)\r
- }\r
- #endif\r
-\r
-#endif\r
-\r
-/** @} */\r
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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_USB_DRIVER\r
+#define __INCLUDE_FROM_USB_CONTROLLER_C\r
+#include "../USBController.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
+ #if !defined(USE_STATIC_OPTIONS)\r
+ USB_Options = Options;\r
+ #endif\r
+\r
+ if (!(USB_Options & USB_OPT_REG_DISABLED))\r
+ USB_REG_On();\r
+ else\r
+ USB_REG_Off();\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (Mode == USB_MODE_UID)\r
+ {\r
+ UHWCON |= (1 << UIDE);\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ }\r
+ else\r
+ {\r
+ USB_CurrentMode = Mode;\r
+ }\r
+ #endif\r
+\r
+ USB_IsInitialized = true;\r
+\r
+ USB_ResetInterface();\r
+}\r
+\r
+void USB_Disable(void)\r
+{\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Detach();\r
+ USB_Controller_Disable();\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ USB_PLL_Off();\r
+\r
+ USB_REG_Off();\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ USB_OTGPAD_Off();\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ USB_CurrentMode = USB_MODE_None;\r
+ #endif\r
+\r
+ USB_IsInitialized = false;\r
+}\r
+\r
+void USB_ResetInterface(void)\r
+{\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0);\r
+ #endif\r
+\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Controller_Reset();\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ #if defined(USB_SERIES_4_AVR)\r
+ PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));\r
+ #endif\r
+\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ }\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (UIDModeSelectEnabled)\r
+ {\r
+ UHWCON |= (1 << UIDE);\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ }\r
+ #endif\r
+\r
+ USB_CLK_Unfreeze();\r
+\r
+ if (USB_CurrentMode == USB_MODE_Device)\r
+ {\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ UHWCON |= (1 << UIMOD);\r
+ #endif\r
+\r
+ USB_Init_Device();\r
+ #endif\r
+ }\r
+ else if (USB_CurrentMode == USB_MODE_Host)\r
+ {\r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHWCON &= ~(1 << UIMOD);\r
+\r
+ USB_Init_Host();\r
+ #endif\r
+ }\r
+\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ USB_OTGPAD_On();\r
+ #endif\r
+}\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+static void USB_Init_Device(void)\r
+{\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ USB_ConfigurationNumber = 0;\r
+\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ USB_RemoteWakeupEnabled = false;\r
+ #endif\r
+\r
+ #if !defined(NO_DEVICE_SELF_POWER)\r
+ USB_CurrentlySelfPowered = false;\r
+ #endif\r
+\r
+ #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+ USB_Descriptor_Device_t* DeviceDescriptorPtr;\r
+\r
+ if (CALLBACK_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
+ #endif\r
+\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
+ USB_Device_SetLowSpeed();\r
+ else\r
+ USB_Device_SetFullSpeed();\r
+\r
+ USB_INT_Enable(USB_INT_VBUS);\r
+ #endif\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ ENDPOINT_DIR_OUT, USB_ControlEndpointSize,\r
+ ENDPOINT_BANK_SINGLE);\r
+\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_EORSTI);\r
+\r
+ USB_Attach();\r
+}\r
+#endif\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+static void USB_Init_Host(void)\r
+{\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+ USB_Host_HostMode_On();\r
+\r
+ USB_Host_VBUS_Auto_Off();\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
+ USB_Attach();\r
+}\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB Controller definitions for the AVR32 UC3B microcontrollers.\r
+ * \copydetails Group_USBManagement_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBManagement\r
+ * \defgroup Group_USBManagement_UC3B USB Interface Management (UC3B)\r
+ * \brief USB Controller definitions for the AVR32 UC3B microcontrollers.\r
+ *\r
+ * Functions, macros, variables, enums and types related to the setup and management of the USB interface.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBCONTROLLER_UC3B_H__\r
+#define __USBCONTROLLER_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #include "../Host.h"\r
+ #include "../OTG.h"\r
+ #include "../Pipe.h"\r
+ #include "../HostStandardReq.h"\r
+ #include "../PipeStream.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "../Device.h"\r
+ #include "../Endpoint.h"\r
+ #include "../DeviceStandardReq.h"\r
+ #include "../EndpointStream.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 !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if !defined(F_CLOCK)\r
+ #error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled USB controller clock in your project makefile.\r
+ #endif\r
+\r
+ #if (F_CLOCK == 8000000)\r
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \\r
+ defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \\r
+ defined(__AVR_ATmega32U2__))\r
+ #define USB_PLL_PSC 0\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_PLL_PSC 0\r
+ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))\r
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
+ #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))\r
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
+ #endif\r
+ #elif (F_CLOCK == 16000000)\r
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \\r
+ defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \\r
+ defined(__AVR_ATmega32U2__))\r
+ #define USB_PLL_PSC (1 << PLLP0)\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_PLL_PSC (1 << PINDIV)\r
+ #elif (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
+ #endif\r
+ #endif\r
+\r
+ #if !defined(USB_PLL_PSC)\r
+ #error No PLL prescale value available for chosen F_CLOCK value and AVR model.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Controller Option Masks */\r
+ //@{\r
+ /** Regulator disable option mask for \ref 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 \ref 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 \ref 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 \ref 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
+ \r
+ /** \name Endpoint/Pipe Type Masks */\r
+ //@{\r
+ /** Mask for a CONTROL type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_CONTROL 0x00\r
+\r
+ /** Mask for an ISOCHRONOUS type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_ISOCHRONOUS 0x01\r
+\r
+ /** Mask for a BULK type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_BULK 0x02\r
+\r
+ /** Mask for an INTERRUPT type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_INTERRUPT 0x03\r
+ //@}\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 acknowledged 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
+ * \ref 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
+ /* Inline Functions: */\r
+ /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from\r
+ * enumerating the device once attached until \ref USB_Attach() is called.\r
+ */\r
+ static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Detach(void)\r
+ {\r
+ UDCON |= (1 << DETACH);\r
+ }\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
+ static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Attach(void)\r
+ {\r
+ UDCON &= ~(1 << DETACH);\r
+ }\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 interrupts for the device and host mode enumeration processes,\r
+ * the user must enable global interrupts before or shortly after this function is called. In\r
+ * device mode, interrupts must be enabled within 500ms of this function being called to ensure\r
+ * that the host does not time out whilst enumerating the device. In host mode, interrupts may be\r
+ * enabled at the application's leisure however enumeration will not begin of an attached device\r
+ * until after this has occurred.\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[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value\r
+ * from the \ref USB_Modes_t enum.\r
+ *\r
+ * \param[in] 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 \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the\r
+ * PLL, and a \c 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
+ * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY\r
+ * (for device mode) or \c USB_HOST_ONLY (for host mode), 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
+ * \n\n\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 \c 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
+ * \n\n\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 \ref Group_Device for the \c 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 \ref USB_Init() function.\r
+ */\r
+ void USB_Disable(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
+ /* 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, a value from the\r
+ * \ref USB_Modes_t enum.\r
+ *\r
+ * \note This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ * \n\n\r
+ *\r
+ * \note When the controller is initialized into UID auto-detection mode, this variable will hold the\r
+ * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller\r
+ * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time\r
+ * options, or a limitation of the USB controller in the chosen device model) this will evaluate to\r
+ * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the\r
+ * USB interface is not initialized.\r
+ */\r
+ extern volatile uint8_t USB_CurrentMode;\r
+ #elif defined(USB_HOST_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Host\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Device\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()\r
+ * was called. This value will be one of the \c 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_Options;\r
+ #elif defined(USE_STATIC_OPTIONS)\r
+ #define USB_Options USE_STATIC_OPTIONS\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the\r
+ * user application via \ref USB_CurrentMode.\r
+ */\r
+ enum USB_Modes_t\r
+ {\r
+ USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */\r
+ USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */\r
+ USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */\r
+ USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the\r
+ * USB connector.\r
+ */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ static void USB_Init_Device(void);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ static void USB_Init_Host(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_PLL_On(void)\r
+ {\r
+ PLLCSR = USB_PLL_PSC;\r
+ PLLCSR |= (1 << PLLE);\r
+ }\r
+\r
+ static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_PLL_Off(void)\r
+ {\r
+ PLLCSR = 0;\r
+ }\r
+\r
+ static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_PLL_IsReady(void)\r
+ {\r
+ return ((PLLCSR & (1 << PLOCK)) ? true : false);\r
+ }\r
+\r
+ static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_REG_On(void)\r
+ {\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ UHWCON |= (1 << UVREGE);\r
+ #else\r
+ REGCR &= ~(1 << REGDIS);\r
+ #endif\r
+ }\r
+\r
+ static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_REG_Off(void)\r
+ {\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ UHWCON &= ~(1 << UVREGE);\r
+ #else\r
+ REGCR |= (1 << REGDIS);\r
+ #endif\r
+ }\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTGPAD_On(void)\r
+ {\r
+ USBCON |= (1 << OTGPADE);\r
+ }\r
+\r
+ static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTGPAD_Off(void)\r
+ {\r
+ USBCON &= ~(1 << OTGPADE);\r
+ }\r
+ #endif\r
+\r
+ static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_CLK_Freeze(void)\r
+ {\r
+ USBCON |= (1 << FRZCLK);\r
+ }\r
+\r
+ static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_CLK_Unfreeze(void)\r
+ {\r
+ USBCON &= ~(1 << FRZCLK);\r
+ }\r
+\r
+ static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Enable(void)\r
+ {\r
+ USBCON |= (1 << USBE);\r
+ }\r
+\r
+ static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Disable(void)\r
+ {\r
+ USBCON &= ~(1 << USBE);\r
+ }\r
+\r
+ static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Reset(void)\r
+ {\r
+ const uint8_t Temp = USBCON;\r
+\r
+ USBCON = (Temp & ~(1 << USBE));\r
+ USBCON = (Temp | (1 << USBE));\r
+ }\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t USB_GetUSBModeFromUID(void)\r
+ {\r
+ if (USBSTA & (1 << ID))\r
+ return USB_MODE_Device;\r
+ else\r
+ return USB_MODE_Host;\r
+ }\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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_USB_DRIVER\r
-#include "USBInterrupt.h"\r
-\r
-void USB_INT_DisableAllInterrupts(void)\r
-{\r
- #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- USBCON &= ~((1 << VBUSTE) | (1 << IDTE));\r
- #elif defined(USB_SERIES_4_AVR)\r
- USBCON &= ~(1 << VBUSTE);\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_BOTH)\r
- OTGIEN = 0;\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_HOST)\r
- UHIEN = 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_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- USBINT = 0;\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_BOTH)\r
- OTGINT = 0;\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_HOST)\r
- UHINT = 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(NO_SOF_EVENTS)\r
- if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))\r
- {\r
- USB_INT_Clear(USB_INT_SOFI);\r
-\r
- EVENT_USB_Device_StartOfFrame();\r
- }\r
- #endif\r
-\r
- #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
- if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))\r
- {\r
- USB_INT_Clear(USB_INT_VBUS);\r
-\r
- if (USB_VBUS_GetStatus())\r
- {\r
- USB_DeviceState = DEVICE_STATE_Powered;\r
- EVENT_USB_Device_Connect();\r
- }\r
- else\r
- {\r
- USB_DeviceState = DEVICE_STATE_Unattached;\r
- EVENT_USB_Device_Disconnect();\r
- }\r
- }\r
- #endif\r
-\r
- if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))\r
- {\r
- USB_INT_Clear(USB_INT_SUSPI);\r
-\r
- USB_INT_Disable(USB_INT_SUSPI);\r
- USB_INT_Enable(USB_INT_WAKEUPI);\r
-\r
- USB_CLK_Freeze();\r
-\r
- if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
- USB_PLL_Off();\r
-\r
- #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
- USB_DeviceState = DEVICE_STATE_Unattached;\r
- EVENT_USB_Device_Disconnect();\r
- #else\r
- USB_DeviceState = DEVICE_STATE_Suspended;\r
- EVENT_USB_Device_Suspend();\r
- #endif\r
- }\r
-\r
- if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))\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_WAKEUPI);\r
-\r
- USB_INT_Disable(USB_INT_WAKEUPI);\r
- USB_INT_Enable(USB_INT_SUSPI);\r
-\r
- if (USB_ConfigurationNumber)\r
- USB_DeviceState = DEVICE_STATE_Configured;\r
- else\r
- USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;\r
-\r
- #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
- EVENT_USB_Device_Connect();\r
- #else\r
- EVENT_USB_Device_WakeUp();\r
- #endif\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_DeviceState = DEVICE_STATE_Default;\r
- USB_ConfigurationNumber = 0;\r
-\r
- USB_INT_Clear(USB_INT_SUSPI);\r
- USB_INT_Disable(USB_INT_SUSPI);\r
- USB_INT_Enable(USB_INT_WAKEUPI);\r
-\r
- Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
- ENDPOINT_DIR_OUT, USB_ControlEndpointSize,\r
- ENDPOINT_BANK_SINGLE);\r
-\r
- #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
- USB_INT_Enable(USB_INT_RXSTPI);\r
- #endif\r
-\r
- EVENT_USB_Device_Reset();\r
- }\r
- #endif\r
-\r
- #if defined(USB_CAN_BE_HOST)\r
- #if !defined(NO_SOF_EVENTS)\r
- if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))\r
- {\r
- USB_INT_Clear(USB_INT_HSOFI);\r
-\r
- EVENT_USB_Host_StartOfFrame();\r
- }\r
- #endif\r
-\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
- EVENT_USB_Host_DeviceUnattached();\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
- EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);\r
- EVENT_USB_Host_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
- EVENT_USB_Host_DeviceAttached();\r
-\r
- USB_INT_Enable(USB_INT_DDISCI);\r
-\r
- USB_HostState = HOST_STATE_Powered;\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
- EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);\r
- EVENT_USB_Host_DeviceUnattached();\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_DeviceState != DEVICE_STATE_Unattached)\r
- EVENT_USB_Device_Disconnect();\r
-\r
- if (USB_HostState != HOST_STATE_Unattached)\r
- EVENT_USB_Host_DeviceUnattached();\r
-\r
- USB_CurrentMode = USB_GetUSBModeFromUID();\r
- USB_ResetInterface();\r
-\r
- EVENT_USB_UIDChange();\r
- }\r
- #endif\r
-}\r
-\r
-#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)\r
-ISR(USB_COM_vect, ISR_BLOCK)\r
-{\r
- uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
-\r
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
- USB_INT_Disable(USB_INT_RXSTPI);\r
-\r
- NONATOMIC_BLOCK(NONATOMIC_FORCEOFF)\r
- {\r
- USB_Device_ProcessControlRequest();\r
- }\r
-\r
- Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
- USB_INT_Enable(USB_INT_RXSTPI);\r
- Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
-}\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- LUFA Library\r
- Copyright (C) Dean Camera, 2011.\r
-\r
- dean [at] fourwalledcubicle [dot] com\r
- www.lufa-lib.org\r
-*/\r
-\r
-/*\r
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, distribute, and sell this\r
- software and its documentation for any purpose is hereby granted\r
- without fee, provided that the above copyright notice appear in\r
- all 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
- * \brief USB Controller Interrupt definitions for the AVR32 UC3B microcontrollers.\r
- *\r
- * This file contains definitions required for the correct handling of low level USB service routine interrupts\r
- * from the USB controller.\r
- *\r
- * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
- * dispatch header located in LUFA/Drivers/USB/USB.h.\r
- */\r
-\r
-#ifndef __USBINTERRUPT_UC3B_H__\r
-#define __USBINTERRUPT_UC3B_H__\r
-\r
- /* Includes: */\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_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
- #endif\r
-\r
- /* Private Interface - For use in library only: */\r
- #if !defined(__DOXYGEN__)\r
- /* Macros: */\r
- #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE\r
- #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE\r
- #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
- #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)\r
- #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)\r
-\r
- #define USB_INT_GET_EN_REG(EnableReg, EnableMask, FlagReg, FlagMask) EnableReg\r
- #define USB_INT_GET_EN_MASK(EnableReg, EnableMask, FlagReg, FlagMask) EnableMask\r
- #define USB_INT_GET_INT_REG(EnableReg, EnableMask, FlagReg, FlagMask) FlagReg\r
- #define USB_INT_GET_INT_MASK(EnableReg, EnableMask, FlagReg, FlagMask) FlagMask\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_WAKEUPI UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)\r
- #define USB_INT_SUSPI 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
- #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)\r
-\r
- /* Includes: */\r
- #include "../USBMode.h"\r
- #include "../Events.h"\r
- #include "../USBController.h"\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
-\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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_USB_DRIVER\r
+#include "../USBInterrupt.h"\r
+\r
+void USB_INT_DisableAllInterrupts(void)\r
+{\r
+ #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ USBCON &= ~((1 << VBUSTE) | (1 << IDTE));\r
+ #elif defined(USB_SERIES_4_AVR)\r
+ USBCON &= ~(1 << VBUSTE);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ OTGIEN = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHIEN = 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_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ USBINT = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ OTGINT = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHINT = 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(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SOFI);\r
+\r
+ EVENT_USB_Device_StartOfFrame();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBUS);\r
+\r
+ if (USB_VBUS_GetStatus())\r
+ {\r
+ USB_DeviceState = DEVICE_STATE_Powered;\r
+ EVENT_USB_Device_Connect();\r
+ }\r
+ else\r
+ {\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ EVENT_USB_Device_Disconnect();\r
+ }\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+\r
+ USB_INT_Disable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_WAKEUPI);\r
+\r
+ USB_CLK_Freeze();\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ USB_PLL_Off();\r
+\r
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ EVENT_USB_Device_Disconnect();\r
+ #else\r
+ USB_DeviceState = DEVICE_STATE_Suspended;\r
+ EVENT_USB_Device_Suspend();\r
+ #endif\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))\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_WAKEUPI);\r
+\r
+ USB_INT_Disable(USB_INT_WAKEUPI);\r
+ USB_INT_Enable(USB_INT_SUSPI);\r
+\r
+ if (USB_ConfigurationNumber)\r
+ USB_DeviceState = DEVICE_STATE_Configured;\r
+ else\r
+ USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;\r
+\r
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ EVENT_USB_Device_Connect();\r
+ #else\r
+ EVENT_USB_Device_WakeUp();\r
+ #endif\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_DeviceState = DEVICE_STATE_Default;\r
+ USB_ConfigurationNumber = 0;\r
+\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+ USB_INT_Disable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_WAKEUPI);\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ ENDPOINT_DIR_OUT, USB_ControlEndpointSize,\r
+ ENDPOINT_BANK_SINGLE);\r
+\r
+ #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_INT_Enable(USB_INT_RXSTPI);\r
+ #endif\r
+\r
+ EVENT_USB_Device_Reset();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #if !defined(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ EVENT_USB_Host_StartOfFrame();\r
+ }\r
+ #endif\r
+\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
+ EVENT_USB_Host_DeviceUnattached();\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
+ EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);\r
+ EVENT_USB_Host_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
+ EVENT_USB_Host_DeviceAttached();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+\r
+ USB_HostState = HOST_STATE_Powered;\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
+ EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);\r
+ EVENT_USB_Host_DeviceUnattached();\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_DeviceState != DEVICE_STATE_Unattached)\r
+ EVENT_USB_Device_Disconnect();\r
+\r
+ if (USB_HostState != HOST_STATE_Unattached)\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ USB_ResetInterface();\r
+\r
+ EVENT_USB_UIDChange();\r
+ }\r
+ #endif\r
+}\r
+\r
+#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)\r
+ISR(USB_COM_vect, ISR_BLOCK)\r
+{\r
+ uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ USB_INT_Disable(USB_INT_RXSTPI);\r
+\r
+ NONATOMIC_BLOCK(NONATOMIC_FORCEOFF)\r
+ {\r
+ USB_Device_ProcessControlRequest();\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ USB_INT_Enable(USB_INT_RXSTPI);\r
+ Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
+}\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all 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
+ * \brief USB Controller Interrupt definitions for the AVR32 UC3B microcontrollers.\r
+ *\r
+ * This file contains definitions required for the correct handling of low level USB service routine interrupts\r
+ * from the USB controller.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __USBINTERRUPT_UC3B_H__\r
+#define __USBINTERRUPT_UC3B_H__\r
+\r
+ /* Includes: */\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_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE\r
+ #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE\r
+ #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
+ #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)\r
+ #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)\r
+\r
+ #define USB_INT_GET_EN_REG(EnableReg, EnableMask, FlagReg, FlagMask) EnableReg\r
+ #define USB_INT_GET_EN_MASK(EnableReg, EnableMask, FlagReg, FlagMask) EnableMask\r
+ #define USB_INT_GET_INT_REG(EnableReg, EnableMask, FlagReg, FlagMask) FlagReg\r
+ #define USB_INT_GET_INT_MASK(EnableReg, EnableMask, FlagReg, FlagMask) FlagMask\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_WAKEUPI UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)\r
+ #define USB_INT_SUSPI 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
+ #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)\r
+\r
+ /* Includes: */\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBController.h"\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
+\r
#include "../../../Common/Common.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/USBController.h"\r
+ #include "AVR8/USBController_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/USBController.h" \r
+ #include "UC3B/USBController_UC3B.h" \r
#endif\r
\r
/* Preprocessor Checks and Defines: */\r
#include "../../../Common/Common.h"\r
\r
#if (ARCH == ARCH_AVR8)\r
- #include "AVR8/USBInterrupt.h"\r
+ #include "AVR8/USBInterrupt_AVR8.h"\r
#elif (ARCH == ARCH_UC3B)\r
- #include "UC3B/USBInterrupt.h" \r
+ #include "UC3B/USBInterrupt_UC3B.h"\r
#endif\r
\r
/* Preprocessor Checks: */\r
* - LUFA/Drivers/USB/Core/HostStandardReq.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
* - LUFA/Drivers/USB/Core/PipeStream.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
* - LUFA/Drivers/USB/Core/USBTask.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
- * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Device.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
- * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Endpoint.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
- * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Host.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
- * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Pipe.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
- * - LUFA/Drivers/USB/Core/<i>ARCH</i>/USBController.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
- * - LUFA/Drivers/USB/Core/<i>ARCH</i>/USBInterrupt.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Device_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Endpoint_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Host_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Pipe_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/USBController_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/USBInterrupt_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
* - LUFA/Drivers/USB/Class/Common/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>
*
* \section Sec_ModDescription Module Description
endif
# Define module source file lists
-LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptor.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/EndpointStream.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/PipeStream.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \
+LUFA_SRC_USB = $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptor.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/EndpointStream.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/PipeStream.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c
-LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/Audio.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDC.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HID.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorage.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDI.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDIS.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDC.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HID.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorage.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDI.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/Printer.c \
- $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDIS.c \
+LUFA_SRC_USBCLASS = $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/Audio.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDC.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HID.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorage.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDI.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDIS.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDC.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HID.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorage.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDI.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/Printer.c \
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDIS.c \
$(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImage.c
LUFA_SRC_TEMPERATURE = $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c
-LUFA_SRC_SERIAL = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial.c
-LUFA_SRC_TWI = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI.c
+LUFA_SRC_SERIAL = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c
+LUFA_SRC_TWI = $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c
LUFA_SRC_SCHEDULER = $(LUFA_ROOT_PATH)/Scheduler/Scheduler.c