The Pedigree Project
0.1
|
Classes | |
struct | ConfigDescriptor |
struct | DeviceDescriptor |
struct | DeviceQualifier |
struct | Endpoint |
struct | Interface |
struct | Setup |
struct | UnknownDescriptor |
Public Types | |
enum | UsbState { Connected = 0, Addressed, HasDescriptors, Configured, HasInterface, HasDriver } |
Possible states for an USB device. | |
Public Member Functions | |
UsbDevice (UsbHub *pHub, uint8_t nPort, UsbSpeed speed) | |
Default constructor. | |
UsbDevice (UsbDevice *pDev) | |
Copy constructor. | |
virtual | ~UsbDevice () |
Destructor. | |
void | initialise (uint8_t nAddress) |
Initialises the device at the given address. More... | |
virtual void | initialiseDriver () |
Implemented by the driver class, initialises driver-specific stuff. | |
virtual void | getUsbDeviceName (String &str) |
uint8_t | getAddress () |
Returns the current address of the device. | |
uint8_t | getPort () |
Returns the number of the port on which the device is connected. | |
UsbSpeed | getSpeed () |
Returns the speed at which the device operates. | |
UsbState | getUsbState () |
Returns the current state of the device. | |
DeviceDescriptor * | getDescriptor () |
Returns the device descriptor of the device. | |
ConfigDescriptor * | getConfiguration () |
Returns the configuration in use. | |
Interface * | getInterface () |
Returns the interface in use. | |
void | useConfiguration (uint8_t nConfig) |
Switches to the given configuration. | |
void | useInterface (uint8_t nInterface) |
Switches to the given interface. | |
UsbDeviceContainer * | getContainer () const |
Gets our Device container, for replacing parents on hubs etc. | |
virtual bool | hasSubtree () const |
Do we expose our own Device tree? | |
virtual Device * | getDevice () |
Public Attributes | |
struct UsbDevice::Setup | PACKED |
struct UsbDevice::DeviceQualifier | PACKED |
Protected Member Functions | |
ssize_t | doSync (Endpoint *pEndpoint, UsbPid pid, uintptr_t pBuffer, size_t nBytes, size_t timeout) |
ssize_t | syncIn (Endpoint *pEndpoint, uintptr_t pBuffer, size_t nBytes, size_t timeout=5000) |
ssize_t | syncOut (Endpoint *pEndpoint, uintptr_t pBuffer, size_t nBytes, size_t timeout=5000) |
void | addInterruptInHandler (Endpoint *pEndpoint, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), uintptr_t pParam=0) |
bool | controlRequest (uint8_t nRequestType, uint8_t nRequest, uint16_t nValue, uint16_t nIndex, uint16_t nLength=0, uintptr_t pBuffer=0) |
Performs an USB control request. | |
uint16_t | getStatus () |
Gets device's current status. | |
bool | clearEndpointHalt (Endpoint *pEndpoint) |
Clears a halt on the given endpoint. | |
void * | getDescriptor (uint8_t nDescriptorType, uint8_t nDescriptorIndex, uint16_t nBytes, uint8_t requestType=0) |
Gets a descriptor from the device. More... | |
uint8_t | getDescriptorLength (uint8_t nDescriptorType, uint8_t nDescriptorIndex, uint8_t requestType=0) |
Gets a descriptor's length from the device. More... | |
String | getString (uint8_t nString) |
Gets a string. More... | |
Protected Attributes | |
uint8_t | m_nAddress |
The current address of the device. | |
uint8_t | m_nPort |
The number of the port on which the device is connected. | |
UsbSpeed | m_Speed |
The speed at which the device operates. | |
UsbState | m_UsbState |
The current state of the device. | |
DeviceDescriptor * | m_pDescriptor |
Device descriptor for this device. | |
ConfigDescriptor * | m_pConfiguration |
Configuration in use. | |
Interface * | m_pInterface |
Interface in use. | |
UsbHub * | m_pHub |
Parent USB hub. | |
UsbDeviceContainer * | m_pContainer |
Our current container. | |
Private Member Functions | |
UsbDevice (const UsbDevice &d) | |
const UsbDevice & | operator= (const UsbDevice &d) |
Friends | |
class | UsbDeviceContainer |
Definition at line 37 of file UsbDevice.h.
|
protected |
Gets a descriptor from the device.
Definition at line 556 of file UsbDevice.cc.
References controlRequest(), and m_pInterface.
|
protected |
Gets a descriptor's length from the device.
Definition at line 580 of file UsbDevice.cc.
References controlRequest(), and m_pInterface.
Referenced by getString(), and initialise().
|
inlinevirtual |
Get a usable Device for this particular UsbDevice, if it has a subtree.
Reimplemented in UsbMassStorageDevice.
Definition at line 255 of file UsbDevice.h.
Referenced by getString().
|
protected |
Gets a string.
Definition at line 600 of file UsbDevice.cc.
References getDescriptor(), getDescriptorLength(), getDevice(), hasSubtree(), m_pContainer, and Device::setParent().
Referenced by initialise().
void UsbDevice::initialise | ( | uint8_t | nAddress | ) |
Initialises the device at the given address.
Definition at line 155 of file UsbDevice.cc.
References UsbHub::addInterruptInHandler(), UsbHub::addTransferToTransaction(), assert, controlRequest(), UsbHub::createTransaction(), DEBUG_LOG, Dec, UsbHub::doSync(), ERROR, getDescriptor(), getDescriptorLength(), getString(), Hex, m_nAddress, m_nPort, m_pDescriptor, m_pHub, m_Speed, m_UsbState, useConfiguration(), and WARNING.
Referenced by UsbHub::deviceConnected().