Loading...
Searching...
No Matches

usbdev driver functions More...

Detailed Description

usbdev driver functions

Helpers (such as usbdev_init) are provided and should be used instead. Directly calling these functions is not recommended.

Definition at line 273 of file usbdev.h.

#include <usbdev.h>

Data Fields

void(* init )(usbdev_t *usbdev)
 Initialize the USB peripheral device.
 
usbdev_ep_t *(* new_ep )(usbdev_t *dev, usb_ep_type_t type, usb_ep_dir_t dir, size_t size)
 Retrieve an USB endpoint of the specified type.
 
int(* get )(usbdev_t *usbdev, usbopt_t opt, void *value, size_t max_len)
 Get an option value from a given usb device.
 
int(* set )(usbdev_t *usbdev, usbopt_t opt, const void *value, size_t value_len)
 Set an option value for a given usb device.
 
void(* esr )(usbdev_t *dev)
 a driver's user-space event service handler
 
void(* ep0_stall )(usbdev_t *usbdev)
 Stall both OUT and IN packets on endpoint 0 until a setup packet is received.
 
void(* ep_init )(usbdev_ep_t *ep)
 Initialize the USB endpoint.
 
void(* ep_stall )(usbdev_ep_t *ep, bool enable)
 Enable or disable the stall condition on the USB endpoint.
 
int(* ep_get )(usbdev_ep_t *ep, usbopt_ep_t opt, void *value, size_t max_len)
 Get an option value from a given usb device endpoint.
 
int(* ep_set )(usbdev_ep_t *ep, usbopt_ep_t opt, const void *value, size_t value_len)
 Set an option value for a given usb device endpoint.
 
void(* ep_esr )(usbdev_ep_t *ep)
 an endpoint's user-space event handler
 
int(* xmit )(usbdev_ep_t *ep, uint8_t *buf, size_t len)
 Transmit a data buffer.
 

Field Documentation

◆ ep0_stall

void(* usbdev_driver::ep0_stall) (usbdev_t *usbdev)

Stall both OUT and IN packets on endpoint 0 until a setup packet is received.

Note
The stall condition should be cleared automatically either by hardware or by the usbdev implementation after receiving a setup packet.

Definition at line 345 of file usbdev.h.

◆ ep_esr

void(* usbdev_driver::ep_esr) (usbdev_ep_t *ep)

an endpoint's user-space event handler

Must be called in response to an USBDEV_EVENT_ESR event in userspace context.

Parameters
[in]epUSB endpoint descriptor to service

Definition at line 409 of file usbdev.h.

◆ ep_get

int(* usbdev_driver::ep_get) (usbdev_ep_t *ep, usbopt_ep_t opt, void *value, size_t max_len)

Get an option value from a given usb device endpoint.

Parameters
[in]epUSB endpoint descriptor
[in]optoption type
[out]valuepointer to store the option's value in
[in]max_lenmaximum number of byte that fit into value
Returns
number of bytes written to value
< 0 on error

Definition at line 384 of file usbdev.h.

◆ ep_init

void(* usbdev_driver::ep_init) (usbdev_ep_t *ep)

Initialize the USB endpoint.

This initializes the USB endpoint with the settings from the usbdev_ep.

Parameters
[in]epUSB endpoint descriptor

Definition at line 355 of file usbdev.h.

◆ ep_set

int(* usbdev_driver::ep_set) (usbdev_ep_t *ep, usbopt_ep_t opt, const void *value, size_t value_len)

Set an option value for a given usb device endpoint.

Parameters
[in]epUSB endpoint descriptor
[in]optoption type
[in]valuepointer to the value
[in]value_lenthe length of value
Returns
number of bytes used from value
< 0 on error

Definition at line 398 of file usbdev.h.

◆ ep_stall

void(* usbdev_driver::ep_stall) (usbdev_ep_t *ep, bool enable)

Enable or disable the stall condition on the USB endpoint.

After clearing the stall condition on the endpoint, the usb peripheral must reinitialize the data toggle to DATA0.

Note
For enabling stall on endpoint 0 usbdev_driver_t::ep0_stall must be used.
Precondition
(ep->num != 0)
Parameters
[in]epUSB endpoint descriptor
[in]enableTrue to set stall, false to disable stall

Definition at line 371 of file usbdev.h.

◆ esr

void(* usbdev_driver::esr) (usbdev_t *dev)

a driver's user-space event service handler

This function will be called from a USB stack's loop when being notified by usbdev_event_isr.

Parameters
[in]devUSB device descriptor

Definition at line 336 of file usbdev.h.

◆ get

int(* usbdev_driver::get) (usbdev_t *usbdev, usbopt_t opt, void *value, size_t max_len)

Get an option value from a given usb device.

Parameters
[in]devUSB device descriptor
[in]optoption type
[out]valuepointer to store the option's value in
[in]max_lenmaximal amount of byte that fit into value
Returns
number of bytes written to value
< 0 on error 0

Definition at line 311 of file usbdev.h.

◆ init

void(* usbdev_driver::init) (usbdev_t *usbdev)

Initialize the USB peripheral device.

This initializes the USB device but must not enable the USB pull up.

Parameters
[in]devUSB device descriptor

Definition at line 282 of file usbdev.h.

◆ new_ep

usbdev_ep_t *(* usbdev_driver::new_ep) (usbdev_t *dev, usb_ep_type_t type, usb_ep_dir_t dir, size_t size)

Retrieve an USB endpoint of the specified type.

requesting an endpoint of USB_EP_TYPE_CONTROL must always return endpoint 0 of the specified direction

Parameters
[in]devUSB device descriptor
[in]typeUSB endpoint type
[in]dirUSB endpoint direction
[in]sizeUSB endpoint buffer size
Returns
ptr to the new USB endpoint descriptor
NULL on error

Definition at line 298 of file usbdev.h.

◆ set

int(* usbdev_driver::set) (usbdev_t *usbdev, usbopt_t opt, const void *value, size_t value_len)

Set an option value for a given usb device.

Parameters
[in]devUSB device descriptor
[in]optoption type
[in]valuevalue to set
[in]value_lenthe length of value
Returns
number of bytes used from value
< 0 on error

Definition at line 325 of file usbdev.h.

◆ xmit

int(* usbdev_driver::xmit) (usbdev_ep_t *ep, uint8_t *buf, size_t len)

Transmit a data buffer.

Ownership of the buf is transferred to the usbdev device after calling this. Do not modify (or unallocate) the buffer between calling this and when it is released via the USBDEV_EVENT_TR_COMPLETE event.

This clears the stall setting in the endpoint if that is enabled.

Note
The buf passed here must have been declared as usbdev_ep_buf_t before so that DMA restrictions are applied to it
Parameters
[in]epUSB endpoint descriptor
[in,out]bufBuffer with the data to transfer
[in]len(Max) Length of the data to transfer

Definition at line 427 of file usbdev.h.


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