usbdev driver functions More...
usbdev driver functions
Helpers (such as usbdev_init) are provided and should be used instead. Directly calling these functions is not recommended.
#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. | |
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.
[in] | ep | USB endpoint descriptor to service |
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.
[in] | ep | USB endpoint descriptor |
[in] | opt | option type |
[out] | value | pointer to store the option's value in |
[in] | max_len | maximum number of byte that fit into value |
value
< 0
on error void(* usbdev_driver::ep_init) (usbdev_ep_t *ep) |
int(* usbdev_driver::ep_set) (usbdev_ep_t *ep, usbopt_ep_t opt, const void *value, size_t value_len) |
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.
[in] | ep | USB endpoint descriptor |
[in] | enable | True to set stall, false to disable stall |
void(* usbdev_driver::esr) (usbdev_t *dev) |
Get an option value from a given usb device.
[in] | dev | USB device descriptor |
[in] | opt | option type |
[out] | value | pointer to store the option's value in |
[in] | max_len | maximal amount of byte that fit into value |
value
< 0
on error 0 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
[in] | dev | USB device descriptor |
[in] | type | USB endpoint type |
[in] | dir | USB endpoint direction |
[in] | size | USB endpoint buffer size |
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.
buf
passed here must have been declared as usbdev_ep_buf_t before so that DMA restrictions are applied to it[in] | ep | USB endpoint descriptor |
[in,out] | buf | Buffer with the data to transfer |
[in] | len | (Max) Length of the data to transfer |