Lightweight USB stack  1.0

Data Structures

struct  usbd_driver
 Represents a hardware USB driver call table. More...
 

Typedefs

typedef uint32_t(* usbd_hw_getinfo) (void)
 Get USB device status and capabilities. More...
 
typedef void(* usbd_hw_enable) (bool enable)
 Enables or disables USB hardware. More...
 
typedef uint8_t(* usbd_hw_connect) (bool connect)
 
typedef void(* usbd_hw_setaddr) (uint8_t address)
 Sets USB hardware address. More...
 
typedef bool(* usbd_hw_ep_config) (uint8_t ep, uint8_t eptype, uint16_t epsize)
 Configures endpoint. More...
 
typedef void(* usbd_hw_ep_deconfig) (uint8_t ep)
 De-configures, cleans and disables endpoint. More...
 
typedef int32_t(* usbd_hw_ep_read) (uint8_t ep, void *buf, uint16_t blen)
 Reads data from OUT or control endpoint. More...
 
typedef int32_t(* usbd_hw_ep_write) (uint8_t ep, void *buf, uint16_t blen)
 Writes data to IN or control endpoint. More...
 
typedef void(* usbd_hw_ep_setstall) (uint8_t ep, bool stall)
 
typedef bool(* usbd_hw_ep_isstalled) (uint8_t ep)
 Checks endpoint for stalled state. More...
 
typedef void(* usbd_hw_poll) (usbd_device *dev, usbd_evt_callback callback)
 Polls USB hardware for the events. More...
 
typedef uint16_t(* usbd_hw_get_frameno) (void)
 Gets frame number from usb hardware.
 
typedef uint16_t(* usbd_hw_get_serialno) (void *buffer)
 Makes a string descriptor contains unique serial number from hardware ID's. More...
 

USB device events

#define usbd_evt_reset   0
 Reset.
 
#define usbd_evt_sof   1
 Start of frame.
 
#define usbd_evt_susp   2
 Suspend.
 
#define usbd_evt_wkup   3
 Wakeup.
 
#define usbd_evt_eptx   4
 Data packet transmitted.
 
#define usbd_evt_eprx   5
 Data packet received.
 
#define usbd_evt_epsetup   6
 Setup packet received.
 
#define usbd_evt_error   7
 Data error.
 
#define usbd_evt_count   8
 

USB lanes connection states

#define usbd_lane_unk   0
 Unknown or proprietary charger.
 
#define usbd_lane_dsc   1
 Lanes disconnected.
 
#define usbd_lane_sdp   2
 Lanes connected to standard downstream port.
 
#define usbd_lane_cdp   3
 Lanes connected to charging downstream port.
 
#define usbd_lane_dcp   4
 Lanes connected to dedicated charging port.
 

USB HW capabilities and status

#define USBD_HW_ADDRFST   (1 << 0)
 Set address before STATUS_OUT.
 
#define USBD_HW_BC   (1 << 1)
 Battery charging detection supported.
 
#define USND_HW_HS   (1 << 2)
 High speed supported.
 
#define USBD_HW_ENABLED   (1 << 3)
 USB device enabled.
 
#define USBD_HW_ENUMSPEED   (2 << 4)
 USB device enumeration speed mask.
 
#define USBD_HW_SPEED_NC   (0 << 4)
 Not connected.
 
#define USBD_HW_SPEED_LS   (1 << 4)
 Low speed.
 
#define USBD_HW_SPEED_FS   (2 << 4)
 Full speed.
 
#define USBD_HW_SPEED_HS   (3 << 4)
 High speed.
 

Detailed Description

Typedef Documentation

◆ usbd_hw_getinfo

typedef uint32_t(* usbd_hw_getinfo) (void)

Get USB device status and capabilities.

Returns
Hardware status and capabilities USBD_HW_CAPS

Definition at line 227 of file usbd_core.h.

◆ usbd_hw_enable

typedef void(* usbd_hw_enable) (bool enable)

Enables or disables USB hardware.

Parameters
enableEnables USB when TRUE disables otherwise.

Definition at line 232 of file usbd_core.h.

◆ usbd_hw_connect

typedef uint8_t(* usbd_hw_connect) (bool connect)

Connects or disconnects USB hardware to/from usb host

Parameters
connectConnects USB to host if TRUE, disconnects otherwise
Returns
lanes connection status.

Definition at line 238 of file usbd_core.h.

◆ usbd_hw_setaddr

typedef void(* usbd_hw_setaddr) (uint8_t address)

Sets USB hardware address.

Parameters
addressUSB address

Definition at line 243 of file usbd_core.h.

◆ usbd_hw_ep_config

typedef bool(* usbd_hw_ep_config) (uint8_t ep, uint8_t eptype, uint16_t epsize)

Configures endpoint.

Parameters
ependpoint address. Use USB_EPDIR_ macros to set endpoint direction
eptypeendpoint type. Use USB_EPTYPE_* macros.
epsizeendpoint size in bytes
Returns
TRUE if success

Definition at line 251 of file usbd_core.h.

◆ usbd_hw_ep_deconfig

typedef void(* usbd_hw_ep_deconfig) (uint8_t ep)

De-configures, cleans and disables endpoint.

Parameters
ependpoint index
Note
if you have two one-direction single-buffered endpoints with same index (i.e. 0x02 and 0x82) both will be deconfigured.

Definition at line 258 of file usbd_core.h.

◆ usbd_hw_ep_read

typedef int32_t(* usbd_hw_ep_read) (uint8_t ep, void *buf, uint16_t blen)

Reads data from OUT or control endpoint.

Parameters
ependpoint index, should belong to OUT or CONTROL endpoint.
bufpointer to read buffer
blensize of the read buffer in bytes
Returns
size of the actually received data, -1 on error.
Note
if data does not fit buffer it will be truncated

Definition at line 267 of file usbd_core.h.

◆ usbd_hw_ep_write

typedef int32_t(* usbd_hw_ep_write) (uint8_t ep, void *buf, uint16_t blen)

Writes data to IN or control endpoint.

Parameters
ependpoint index, hould belong to IN or CONTROL endpoint
bufpointer to data buffer
blensize of data will be written
Returns
number of written bytes

Definition at line 275 of file usbd_core.h.

◆ usbd_hw_ep_setstall

typedef void(* usbd_hw_ep_setstall) (uint8_t ep, bool stall)

Stalls and unstalls endpoint

Parameters
ependpoint address
stallendpoint will be stalled if TRUE and unstalled otherwise.
Note
Has no effect on inactive endpoints.

Definition at line 282 of file usbd_core.h.

◆ usbd_hw_ep_isstalled

typedef bool(* usbd_hw_ep_isstalled) (uint8_t ep)

Checks endpoint for stalled state.

Parameters
ependpoint address
Returns
TRUE if endpoint is stalled

Definition at line 288 of file usbd_core.h.

◆ usbd_hw_poll

typedef void(* usbd_hw_poll) (usbd_device *dev, usbd_evt_callback callback)

Polls USB hardware for the events.

Parameters
[in]devpointer to usb device structure
callbackcallback to event processing subroutine

Definition at line 294 of file usbd_core.h.

◆ usbd_hw_get_serialno

typedef uint16_t(* usbd_hw_get_serialno) (void *buffer)

Makes a string descriptor contains unique serial number from hardware ID's.

Parameters
[in]bufferpointer to buffer for the descriptor
Returns
of the descriptor in bytes

Definition at line 304 of file usbd_core.h.