Skip to content

Class daisy::USBHostHandle

ClassList > daisy > USBHostHandle

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

  • #include <usb_host.h>

Classes

Type Name
struct Config
Configuration structure for interfacing with USB host Driver.

Public Types

Type Name
typedef void(* ClassActiveCallback
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(* ConnectCallback
User defineable callback for USB Connection.
typedef void(* DisconnectCallback
User defineable callback for USB Disconnection.
typedef void(* ErrorCallback
User defineable callback for USB Unrecoverable Error.
enum 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.

Public Functions

Type Name
Result Deinit ()
bool GetPresent ()
const char * GetProductName ()
bool GetReady ()
Result Init (USBHostHandle::Config & config)
bool IsActiveClass (USBH_ClassTypeDef * usbClass)
bool IsDeviceConnected ()
Returns if the ST Middleware detects a connected device.
bool IsPortEnabled ()
Returns if the HAL detects that the port is enabled.
Result Process ()
Result ReEnumerate ()
Result RegisterClass (USBH_ClassTypeDef * pClass)
USBHostHandle ()
USBHostHandle (const USBHostHandle & other) = default
USBHostHandle & operator= (const USBHostHandle & other) = default

Detailed Description

Author:

Gabriel Ball

Date:

September 16, 2021

Public Types Documentation

typedef ClassActiveCallback

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(* daisy::USBHostHandle::ClassActiveCallback) (void *userdata);

Parameters:

  • userdata a 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.


typedef ConnectCallback

User defineable callback for USB Connection.

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


typedef DisconnectCallback

User defineable callback for USB Disconnection.

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


typedef ErrorCallback

User defineable callback for USB Unrecoverable Error.

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

Todo

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


enum 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.

enum daisy::USBHostHandle::Result {
    OK,
    BUSY,
    FAIL,
    NOT_SUPPORTED,
    UNRECOVERED_ERROR,
    ERROR_SPEED_UNKNOWN
};

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


Public Functions Documentation

function Deinit

Result daisy::USBHostHandle::Deinit () 

Deinitializes USB host-related peripherals


function GetPresent

bool daisy::USBHostHandle::GetPresent () 

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


function GetProductName

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

Returns name of the connected devices if there is one


function GetReady

bool daisy::USBHostHandle::GetReady () 

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


function Init

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

Initializes the USB drivers and starts timeout.

Parameters:

  • config Configuration struct for initialization

function IsActiveClass

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

Returns true if the specified class is active


function IsDeviceConnected

Returns if the ST Middleware detects a connected device.

bool daisy::USBHostHandle::IsDeviceConnected () 


function IsPortEnabled

Returns if the HAL detects that the port is enabled.

bool daisy::USBHostHandle::IsPortEnabled () 


function Process

Result daisy::USBHostHandle::Process () 

Manages usb host functionality


function ReEnumerate

Result daisy::USBHostHandle::ReEnumerate () 

Forces USB host to re-enumerate device


function RegisterClass

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

Register a USB class


function USBHostHandle [½]

inline daisy::USBHostHandle::USBHostHandle () 

function USBHostHandle [2/2]

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

function operator=

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


The documentation for this class was generated from the following file external-docs/libDaisy/src/hid/usb_host.h