libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Defined Constants and Types for the USB Drivers More...
Macros | |
#define | otgfs_usb_driver stm32f107_usb_driver |
#define | otghs_usb_driver stm32f207_usb_driver |
Typedefs | |
typedef struct _usbd_driver | usbd_driver |
typedef struct _usbd_device | usbd_device |
typedef void(* | usbd_control_complete_callback) (usbd_device *usbd_dev, struct usb_setup_data *req) |
typedef enum usbd_request_return_codes(* | usbd_control_callback) (usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete) |
typedef void(* | usbd_set_config_callback) (usbd_device *usbd_dev, uint16_t wValue) |
typedef void(* | usbd_set_altsetting_callback) (usbd_device *usbd_dev, uint16_t wIndex, uint16_t wValue) |
typedef void(* | usbd_endpoint_callback) (usbd_device *usbd_dev, uint8_t ep) |
Enumerations | |
enum | usbd_request_return_codes { USBD_REQ_NOTSUPP = 0 , USBD_REQ_HANDLED = 1 , USBD_REQ_NEXT_CALLBACK = 2 } |
Functions | |
usbd_device * | usbd_init (const usbd_driver *driver, const struct usb_device_descriptor *dev, const struct usb_config_descriptor *conf, const char *const *strings, int num_strings, uint8_t *control_buffer, uint16_t control_buffer_size) |
Main initialization entry point. More... | |
void | usbd_register_reset_callback (usbd_device *usbd_dev, void(*callback)(void)) |
Registers a reset callback. More... | |
void | usbd_register_suspend_callback (usbd_device *usbd_dev, void(*callback)(void)) |
Registers a suspend callback. More... | |
void | usbd_register_resume_callback (usbd_device *usbd_dev, void(*callback)(void)) |
Registers a resume callback. More... | |
void | usbd_register_sof_callback (usbd_device *usbd_dev, void(*callback)(void)) |
Registers a SOF callback. More... | |
int | usbd_register_control_callback (usbd_device *usbd_dev, uint8_t type, uint8_t type_mask, usbd_control_callback callback) |
Registers a control callback. More... | |
int | usbd_register_set_config_callback (usbd_device *usbd_dev, usbd_set_config_callback callback) |
Registers a "Set Config" callback. More... | |
void | usbd_register_set_altsetting_callback (usbd_device *usbd_dev, usbd_set_altsetting_callback callback) |
Registers a "Set Interface" (alternate setting) callback. More... | |
void | usbd_register_extra_string (usbd_device *usbd_dev, int index, const char *string) |
Registers a non-contiguous string descriptor. More... | |
void | usbd_poll (usbd_device *usbd_dev) |
void | usbd_disconnect (usbd_device *usbd_dev, bool disconnected) |
Disconnect, if supported by the driver. More... | |
void | usbd_ep_setup (usbd_device *usbd_dev, uint8_t addr, uint8_t type, uint16_t max_size, usbd_endpoint_callback callback) |
Setup an endpoint. More... | |
uint16_t | usbd_ep_write_packet (usbd_device *usbd_dev, uint8_t addr, const void *buf, uint16_t len) |
Write a packet. More... | |
uint16_t | usbd_ep_read_packet (usbd_device *usbd_dev, uint8_t addr, void *buf, uint16_t len) |
Read a packet. More... | |
void | usbd_ep_stall_set (usbd_device *usbd_dev, uint8_t addr, uint8_t stall) |
Set/clear STALL condition on an endpoint. More... | |
uint8_t | usbd_ep_stall_get (usbd_device *usbd_dev, uint8_t addr) |
Get STALL status of an endpoint. More... | |
void | usbd_ep_nak_set (usbd_device *usbd_dev, uint8_t addr, uint8_t nak) |
Set an Out endpoint to NAK. More... | |
Variables | |
const usbd_driver | st_usbfs_v1_usb_driver |
const usbd_driver | stm32f107_usb_driver |
const usbd_driver | stm32f207_usb_driver |
const usbd_driver | st_usbfs_v2_usb_driver |
const usbd_driver | efm32lg_usb_driver |
const usbd_driver | efm32hg_usb_driver |
const usbd_driver | lm4f_usb_driver |
Defined Constants and Types for the USB Drivers
LGPL License Terms libopencm3 License
#define otgfs_usb_driver stm32f107_usb_driver |
#define otghs_usb_driver stm32f207_usb_driver |
typedef enum usbd_request_return_codes(* usbd_control_callback) (usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, usbd_control_complete_callback *complete) |
typedef void(* usbd_control_complete_callback) (usbd_device *usbd_dev, struct usb_setup_data *req) |
typedef struct _usbd_device usbd_device |
typedef struct _usbd_driver usbd_driver |
typedef void(* usbd_endpoint_callback) (usbd_device *usbd_dev, uint8_t ep) |
typedef void(* usbd_set_altsetting_callback) (usbd_device *usbd_dev, uint16_t wIndex, uint16_t wValue) |
typedef void(* usbd_set_config_callback) (usbd_device *usbd_dev, uint16_t wValue) |
void usbd_disconnect | ( | usbd_device * | usbd_dev, |
bool | disconnected | ||
) |
Disconnect, if supported by the driver.
This function is implemented as weak function and can be replaced by an application specific version to handle chips that don't have built-in handling for this (e.g. STM32F1.)
usbd_dev | the usb device handle returned from usbd_init |
disconnected | true to request a disconnect |
Definition at line 131 of file usb.c.
References usbd_dev.
void usbd_ep_nak_set | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
uint8_t | nak | ||
) |
Set an Out endpoint to NAK.
usbd_dev | the usb device handle returned from usbd_init |
addr | EP address |
nak | if nonzero, set NAK |
Definition at line 168 of file usb.c.
References usbd_dev.
Referenced by _usbd_control_in(), _usbd_control_setup(), and usb_control_setup_write().
uint16_t usbd_ep_read_packet | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
void * | buf, | ||
uint16_t | len | ||
) |
Read a packet.
usbd_dev | the usb device handle returned from usbd_init |
addr | EP address |
buf | user buffer that will receive data |
len | # of bytes |
Definition at line 152 of file usb.c.
References usbd_dev.
Referenced by _usbd_control_out(), msc_data_rx_cb(), and usb_control_recv_chunk().
void usbd_ep_setup | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
uint8_t | type, | ||
uint16_t | max_size, | ||
usbd_endpoint_callback | callback | ||
) |
Setup an endpoint.
usbd_dev | the usb device handle returned from usbd_init |
addr | Full EP address including direction (e.g. 0x01 or 0x81) |
type | Value for bmAttributes (USB_ENDPOINT_ATTR_*) |
max_size | Endpoint max size |
callback | your desired callback function |
Definition at line 140 of file usb.c.
References usbd_dev.
Referenced by _usbd_reset(), and msc_set_config().
uint8_t usbd_ep_stall_get | ( | usbd_device * | usbd_dev, |
uint8_t | addr | ||
) |
Get STALL status of an endpoint.
usbd_dev | the usb device handle returned from usbd_init |
addr | Full EP address (with direction bit) |
Definition at line 163 of file usb.c.
References usbd_dev.
Referenced by usb_standard_endpoint_get_status().
void usbd_ep_stall_set | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
uint8_t | stall | ||
) |
Set/clear STALL condition on an endpoint.
usbd_dev | the usb device handle returned from usbd_init |
addr | Full EP address (with direction bit) |
stall | if 0, clear STALL, else set stall. |
Definition at line 158 of file usb.c.
References usbd_dev.
Referenced by stall_transaction(), usb_standard_endpoint_stall(), and usb_standard_endpoint_unstall().
uint16_t usbd_ep_write_packet | ( | usbd_device * | usbd_dev, |
uint8_t | addr, | ||
const void * | buf, | ||
uint16_t | len | ||
) |
Write a packet.
usbd_dev | the usb device handle returned from usbd_init |
addr | EP address (direction is ignored) |
buf | pointer to user data to write |
len | # of bytes |
Definition at line 146 of file usb.c.
References usbd_dev.
Referenced by _usbd_control_out(), msc_data_rx_cb(), msc_data_tx_cb(), usb_control_send_chunk(), and usb_control_setup_read().
usbd_device * usbd_init | ( | const usbd_driver * | driver, |
const struct usb_device_descriptor * | dev, | ||
const struct usb_config_descriptor * | conf, | ||
const char *const * | strings, | ||
int | num_strings, | ||
uint8_t * | control_buffer, | ||
uint16_t | control_buffer_size | ||
) |
Main initialization entry point.
Initialize the USB firmware library to implement the USB device described by the descriptors provided.
It is required that the 48MHz USB clock is already available.
driver | TODO |
dev | Pointer to USB device descriptor. This must not be changed while the device is in use. |
conf | Pointer to array of USB configuration descriptors. These must not be changed while the device is in use. The length of this array is determined by the bNumConfigurations field in the device descriptor. |
strings | Pointer to an array of strings for USB string descriptors. Referenced in iSomething fields, e.g. iManufacturer. Since a zero index means "no string", an iSomething value of 1 refers strings[0]. |
num_strings | Number of items in strings array. |
control_buffer | Pointer to array that would hold the data received during control requests with DATA stage |
control_buffer_size | Size of control_buffer |
To place strings entirely into Flash/read-only memory, use
(note the double const.) The first const refers to the strings while the second const refers to the array.
Definition at line 42 of file usb.c.
References _usbd_control_in(), _usbd_control_out(), _usbd_control_setup(), and usbd_dev.
void usbd_poll | ( | usbd_device * | usbd_dev | ) |
int usbd_register_control_callback | ( | usbd_device * | usbd_dev, |
uint8_t | type, | ||
uint8_t | type_mask, | ||
usbd_control_callback | callback | ||
) |
Registers a control callback.
Since the list of user control callbacks is cleared every time device configuration is set (inside usb_standard_set_configuration()), control callback registration must happen inside (or after) the config callback. The specified callback will be called if (type == (bmRequestType & type_mask)).
usbd_dev | the usb device handle returned from usbd_init |
type | Handled request type |
type_mask | Mask to apply before matching request type |
callback | your desired callback function |
Definition at line 73 of file usb_control.c.
References usbd_dev.
Referenced by msc_set_config().
void usbd_register_extra_string | ( | usbd_device * | usbd_dev, |
int | index, | ||
const char * | string | ||
) |
void usbd_register_reset_callback | ( | usbd_device * | usbd_dev, |
void(*)(void) | callback | ||
) |
void usbd_register_resume_callback | ( | usbd_device * | usbd_dev, |
void(*)(void) | callback | ||
) |
void usbd_register_set_altsetting_callback | ( | usbd_device * | usbd_dev, |
usbd_set_altsetting_callback | callback | ||
) |
Registers a "Set Interface" (alternate setting) callback.
usbd_dev | the usb device handle returned from usbd_init |
callback | your desired callback function |
Definition at line 62 of file usb_standard.c.
References usbd_dev.
int usbd_register_set_config_callback | ( | usbd_device * | usbd_dev, |
usbd_set_config_callback | callback | ||
) |
Registers a "Set Config" callback.
usbd_dev | the usb device handle returned from usbd_init |
callback | your desired callback function |
Definition at line 42 of file usb_standard.c.
References usbd_dev.
Referenced by usb_msc_init().
void usbd_register_sof_callback | ( | usbd_device * | usbd_dev, |
void(*)(void) | callback | ||
) |
void usbd_register_suspend_callback | ( | usbd_device * | usbd_dev, |
void(*)(void) | callback | ||
) |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
Definition at line 36 of file usb_f107.c.
Referenced by stm32f107_usbd_init().
|
extern |
Definition at line 36 of file usb_f207.c.
Referenced by stm32f207_usbd_init().