Adaptation of the official mbed USBHost repository to work with the LPC4088 Display Module

Dependents:   DMSupport DMSupport DMSupport DMSupport

Fork of DM_USBHost by EmbeddedArtists AB

Embed: (wiki syntax)

« Back to documentation index

USBHost Class Reference

USBHost class This class is a singleton. More...

#include <USBHost.h>

Inherits USBHALHost.

Data Structures

class  Lock
 Instantiate to protect USB thread from accessing shared objects (USBConnectedDevices and Interfaces) More...

Public Member Functions

USB_TYPE controlRead (USBDeviceConnected *dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t *buf, uint32_t len)
 Control read: setup stage, data stage and status stage.
USB_TYPE controlWrite (USBDeviceConnected *dev, uint8_t requestType, uint8_t request, uint32_t value, uint32_t index, uint8_t *buf, uint32_t len)
 Control write: setup stage, data stage and status stage.
USB_TYPE bulkRead (USBDeviceConnected *dev, USBEndpoint *ep, uint8_t *buf, uint32_t len, bool blocking=true)
 Bulk read.
USB_TYPE bulkWrite (USBDeviceConnected *dev, USBEndpoint *ep, uint8_t *buf, uint32_t len, bool blocking=true)
 Bulk write.
USB_TYPE interruptRead (USBDeviceConnected *dev, USBEndpoint *ep, uint8_t *buf, uint32_t len, bool blocking=true)
 Interrupt read.
USB_TYPE interruptWrite (USBDeviceConnected *dev, USBEndpoint *ep, uint8_t *buf, uint32_t len, bool blocking=true)
 Interrupt write.
USB_TYPE enumerate (USBDeviceConnected *dev, IUSBEnumerator *pEnumerator)
 Enumerate a device.
USB_TYPE resetDevice (USBDeviceConnected *dev)
 reset a specific device
USBDeviceConnectedgetDevice (uint8_t index)
 Get a device.
template<typename T >
void registerDriver (USBDeviceConnected *dev, uint8_t intf, T *tptr, void(T::*mptr)(void))
 register a driver into the host associated with a callback function called when the device is disconnected
void registerDriver (USBDeviceConnected *dev, uint8_t intf, void(*fn)(void))
 register a driver into the host associated with a callback function called when the device is disconnected

Static Public Member Functions

static USBHostgetHostInst ()
 Static method to create or retrieve the single USBHost instance.

Protected Member Functions

virtual void transferCompleted (volatile uint32_t addr)
 Virtual method called when a transfer has been completed.
virtual void deviceConnected (int hub, int port, bool lowSpeed, USBHostHub *hub_parent=NULL)
 Virtual method called when a device has been connected.
virtual void deviceDisconnected (int hub, int port, USBHostHub *hub_parent, volatile uint32_t addr)
 Virtuel method called when a device has been disconnected.
void init ()
 Initialize host controller.
void resetRootHub ()
 reset the root hub
uint32_t controlHeadED ()
 return the value contained in the control HEAD ED register
uint32_t bulkHeadED ()
 return the value contained in the bulk HEAD ED register
uint32_t interruptHeadED ()
 return the value of the head interrupt ED contained in the HCCA
void updateControlHeadED (uint32_t addr)
 Update the head ED for control transfers.
void updateBulkHeadED (uint32_t addr)
 Update the head ED for bulk transfers.
void updateInterruptHeadED (uint32_t addr)
 Update the head ED for interrupt transfers.
void enableList (ENDPOINT_TYPE type)
 Enable List for the specified endpoint type.
bool disableList (ENDPOINT_TYPE type)
 Disable List for the specified endpoint type.
volatile uint8_t * getED ()
 Find a memory section for a new ED.
volatile uint8_t * getTD ()
 Find a memory section for a new TD.
void freeED (volatile uint8_t *ed)
 Release a previous memory section reserved for an ED.
void freeTD (volatile uint8_t *td)
 Release a previous memory section reserved for an TD.

Friends

class USBHostHub

Detailed Description

USBHost class This class is a singleton.

All drivers have a reference on the static USBHost instance

Definition at line 32 of file USBHost.h.


Member Function Documentation

uint32_t bulkHeadED (  ) [protected, inherited]

return the value contained in the bulk HEAD ED register

Returns:
address of the bulk head ED

Definition at line 218 of file USBHALHost.cpp.

USB_TYPE bulkRead ( USBDeviceConnected dev,
USBEndpoint ep,
uint8_t *  buf,
uint32_t  len,
bool  blocking = true 
)

Bulk read.

Parameters:
devthe bulk transfer will be done for this device
epUSBEndpoint which will be used to read a packet
bufpointer on a buffer where will be store the data received
lenlength of the transfer
blockingif true, the read is blocking (wait for completion)
Returns:
status of the bulk read

Definition at line 999 of file USBHost.cpp.

USB_TYPE bulkWrite ( USBDeviceConnected dev,
USBEndpoint ep,
uint8_t *  buf,
uint32_t  len,
bool  blocking = true 
)

Bulk write.

Parameters:
devthe bulk transfer will be done for this device
epUSBEndpoint which will be used to write a packet
bufpointer on a buffer which will be written
lenlength of the transfer
blockingif true, the write is blocking (wait for completion)
Returns:
status of the bulk write

Definition at line 994 of file USBHost.cpp.

uint32_t controlHeadED (  ) [protected, inherited]

return the value contained in the control HEAD ED register

Returns:
address of the control Head ED

Definition at line 214 of file USBHALHost.cpp.

USB_TYPE controlRead ( USBDeviceConnected dev,
uint8_t  requestType,
uint8_t  request,
uint32_t  value,
uint32_t  index,
uint8_t *  buf,
uint32_t  len 
)

Control read: setup stage, data stage and status stage.

Parameters:
devthe control read will be done for this device
requestTyperequest type
requestrequest
valuevalue
indexindex
bufpointer on a buffer where will be store the data received
lenlength of the transfer
Returns:
status of the control read

Definition at line 1081 of file USBHost.cpp.

USB_TYPE controlWrite ( USBDeviceConnected dev,
uint8_t  requestType,
uint8_t  request,
uint32_t  value,
uint32_t  index,
uint8_t *  buf,
uint32_t  len 
)

Control write: setup stage, data stage and status stage.

Parameters:
devthe control write will be done for this device
requestTyperequest type
requestrequest
valuevalue
indexindex
bufpointer on a buffer which will be written
lenlength of the transfer
Returns:
status of the control write

Definition at line 1085 of file USBHost.cpp.

void deviceConnected ( int  hub,
int  port,
bool  lowSpeed,
USBHostHub hub_parent = NULL 
) [protected, virtual]

Virtual method called when a device has been connected.

Parameters:
hubhub number of the device
portport number of the device
lowSpeed1 if low speed, 0 otherwise
hub_parentreference on the parent hub

Implements USBHALHost.

Definition at line 373 of file USBHost.cpp.

void deviceDisconnected ( int  hub,
int  port,
USBHostHub hub_parent,
volatile uint32_t  addr 
) [protected, virtual]

Virtuel method called when a device has been disconnected.

Parameters:
hubhub number of the device
portport number of the device
addrlist of the TDs which have been completed to dequeue freed TDs

Implements USBHALHost.

Definition at line 395 of file USBHost.cpp.

bool disableList ( ENDPOINT_TYPE  type ) [protected, inherited]

Disable List for the specified endpoint type.

Parameters:
typedisable the list of ENDPOINT_TYPE type

Definition at line 259 of file USBHALHost.cpp.

void enableList ( ENDPOINT_TYPE  type ) [protected, inherited]

Enable List for the specified endpoint type.

Parameters:
typeenable the list of ENDPOINT_TYPE type

Definition at line 240 of file USBHALHost.cpp.

USB_TYPE enumerate ( USBDeviceConnected dev,
IUSBEnumerator *  pEnumerator 
)

Enumerate a device.

Parameters:
devdevice which will be enumerated
Returns:
status of the enumeration

Definition at line 841 of file USBHost.cpp.

void freeED ( volatile uint8_t *  ed ) [protected, inherited]

Release a previous memory section reserved for an ED.

Parameters:
edaddress of the ED

Definition at line 316 of file USBHALHost.cpp.

void freeTD ( volatile uint8_t *  td ) [protected, inherited]

Release a previous memory section reserved for an TD.

Parameters:
tdaddress of the TD

Definition at line 322 of file USBHALHost.cpp.

USBDeviceConnected * getDevice ( uint8_t  index )

Get a device.

Parameters:
indexindex of the device which will be returned
Returns:
pointer on the "index" device

Definition at line 525 of file USBHost.cpp.

volatile uint8_t * getED (  ) [protected, inherited]

Find a memory section for a new ED.

Returns:
the address of the new ED

Definition at line 292 of file USBHALHost.cpp.

USBHost * getHostInst (  ) [static]

Static method to create or retrieve the single USBHost instance.

Definition at line 358 of file USBHost.cpp.

volatile uint8_t * getTD (  ) [protected, inherited]

Find a memory section for a new TD.

Returns:
the address of the new TD

Definition at line 303 of file USBHALHost.cpp.

void init (  ) [protected, inherited]

Initialize host controller.

Enable USB interrupts. This part is not in the constructor because, this function calls a virtual method if a device is already connected

Definition at line 121 of file USBHALHost.cpp.

uint32_t interruptHeadED (  ) [protected, inherited]

return the value of the head interrupt ED contained in the HCCA

Returns:
address of the head interrupt ED contained in the HCCA

Definition at line 222 of file USBHALHost.cpp.

USB_TYPE interruptRead ( USBDeviceConnected dev,
USBEndpoint ep,
uint8_t *  buf,
uint32_t  len,
bool  blocking = true 
)

Interrupt read.

Parameters:
devthe bulk transfer will be done for this device
epUSBEndpoint which will be used to write a packet
bufpointer on a buffer which will be written
lenlength of the transfer
blockingif true, the read is blocking (wait for completion)
Returns:
status of the interrupt read

Definition at line 1009 of file USBHost.cpp.

USB_TYPE interruptWrite ( USBDeviceConnected dev,
USBEndpoint ep,
uint8_t *  buf,
uint32_t  len,
bool  blocking = true 
)

Interrupt write.

Parameters:
devthe bulk transfer will be done for this device
epUSBEndpoint which will be used to write a packet
bufpointer on a buffer which will be written
lenlength of the transfer
blockingif true, the write is blocking (wait for completion)
Returns:
status of the interrupt write

Definition at line 1004 of file USBHost.cpp.

void registerDriver ( USBDeviceConnected dev,
uint8_t  intf,
T *  tptr,
void(T::*)(void)  mptr 
)

register a driver into the host associated with a callback function called when the device is disconnected

Parameters:
devdevice
intfinterface number
tptrpointer to the object to call the member function on
mptrpointer to the member function to be called

Definition at line 165 of file USBHost.h.

void registerDriver ( USBDeviceConnected dev,
uint8_t  intf,
void(*)(void)  fn 
)

register a driver into the host associated with a callback function called when the device is disconnected

Parameters:
devdevice
intfinterface number
fncallback called when the specified device has been disconnected

Definition at line 181 of file USBHost.h.

USB_TYPE resetDevice ( USBDeviceConnected dev )

reset a specific device

Parameters:
devdevice which will be resetted

Definition at line 556 of file USBHost.cpp.

void resetRootHub (  ) [protected, inherited]

reset the root hub

Definition at line 329 of file USBHALHost.cpp.

void transferCompleted ( volatile uint32_t  addr ) [protected, virtual]

Virtual method called when a transfer has been completed.

Parameters:
addrlist of the TDs which have been completed

Implements USBHALHost.

Definition at line 311 of file USBHost.cpp.

void updateBulkHeadED ( uint32_t  addr ) [protected, inherited]

Update the head ED for bulk transfers.

Definition at line 226 of file USBHALHost.cpp.

void updateControlHeadED ( uint32_t  addr ) [protected, inherited]

Update the head ED for control transfers.

Definition at line 231 of file USBHALHost.cpp.

void updateInterruptHeadED ( uint32_t  addr ) [protected, inherited]

Update the head ED for interrupt transfers.

Definition at line 235 of file USBHALHost.cpp.