libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::USBHostHandle Class Reference

Presents a USB Mass Storage Device host interface. More...

Detailed Description

Presents a USB Mass Storage Device host interface.

Author
Gabriel Ball
Date
September 16, 2021

#include <usb_host.h>

Classes

struct  Config
 Configuration structure for interfacing with USB host Driver. More...
 

Public Types

enum class  Result {
  OK , BUSY , FAIL , NOT_SUPPORTED ,
  UNRECOVERED_ERROR , ERROR_SPEED_UNKNOWN
}
 return codes from the USB Processing can be used to check the state of USB while running outside of what may be happening with the limited user callbacks. More...
 
typedef void(* ConnectCallback) (void *data)
 User defineable callback for USB Connection.
 
typedef void(* DisconnectCallback) (void *data)
 User defineable callback for USB Disconnection.
 
typedef void(* ClassActiveCallback) (void *userdata)
 User defineable callback upon completion of class initialization For example, when a USB drive is connected and the usb device class initialization has finished, this callback will fire.
 
typedef void(* ErrorCallback) (void *data)
 User defineable callback for USB Unrecoverable Error.
 

Public Member Functions

Result RegisterClass (USBH_ClassTypeDef *pClass)
 
Result Init (USBHostHandle::Config &config)
 
Result Deinit ()
 
bool IsActiveClass (USBH_ClassTypeDef *usbClass)
 
Result Process ()
 
Result ReEnumerate ()
 
bool GetReady ()
 
bool GetPresent ()
 
const charGetProductName ()
 
 USBHostHandle ()
 
 USBHostHandle (const USBHostHandle &other)=default
 
USBHostHandleoperator= (const USBHostHandle &other)=default
 

Member Typedef Documentation

◆ ClassActiveCallback

typedef void(* daisy::USBHostHandle::ClassActiveCallback) (void *userdata)

User defineable callback upon completion of class initialization For example, when a USB drive is connected and the usb device class initialization has finished, this callback will fire.

Parameters
userdataa pointer to some arbitrary data for use by the user. this is supplied in the Config struct. Can be used to avoid globals.
Todo:
At some point this may be replaced for individual callbacks for each supported USB Host class.

◆ ConnectCallback

typedef void(* daisy::USBHostHandle::ConnectCallback) (void *data)

User defineable callback for USB Connection.

◆ DisconnectCallback

typedef void(* daisy::USBHostHandle::DisconnectCallback) (void *data)

User defineable callback for USB Disconnection.

◆ ErrorCallback

typedef void(* daisy::USBHostHandle::ErrorCallback) (void *data)

User defineable callback for USB Unrecoverable Error.

Todo:
add some sort of feedback about the type of error, etc. if possible

Member Enumeration Documentation

◆ Result

return codes from the USB Processing can be used to check the state of USB while running outside of what may be happening with the limited user callbacks.

At this time, these correlate directly to the ST Middleware USBH_StatusTypeDef codes

Enumerator
OK 
BUSY 
FAIL 
NOT_SUPPORTED 
UNRECOVERED_ERROR 
ERROR_SPEED_UNKNOWN 

Constructor & Destructor Documentation

◆ USBHostHandle() [1/2]

daisy::USBHostHandle::USBHostHandle ( )
inline

◆ USBHostHandle() [2/2]

daisy::USBHostHandle::USBHostHandle ( const USBHostHandle other)
default

Member Function Documentation

◆ Deinit()

Result daisy::USBHostHandle::Deinit ( )

Deinitializes USB host-related peripherals

◆ GetPresent()

bool daisy::USBHostHandle::GetPresent ( )

Run after the first Process call to detect if a device is present

◆ GetProductName()

const char * daisy::USBHostHandle::GetProductName ( )

Returns name of the connected devices if there is one

◆ GetReady()

bool daisy::USBHostHandle::GetReady ( )

Returns true if a Mass Storage Device is connected and ready for communicaton

◆ Init()

Result daisy::USBHostHandle::Init ( USBHostHandle::Config config)

Initializes the USB drivers and starts timeout.

Parameters
configConfiguration struct for initialization

◆ IsActiveClass()

bool daisy::USBHostHandle::IsActiveClass ( USBH_ClassTypeDef usbClass)

Returns true if the specified class is active

◆ operator=()

USBHostHandle & daisy::USBHostHandle::operator= ( const USBHostHandle other)
default

◆ Process()

Result daisy::USBHostHandle::Process ( )

Manages usb host functionality

◆ ReEnumerate()

Result daisy::USBHostHandle::ReEnumerate ( )

Forces USB host to re-enumerate device

◆ RegisterClass()

Result daisy::USBHostHandle::RegisterClass ( USBH_ClassTypeDef pClass)

Register a USB class


The documentation for this class was generated from the following file: