Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
|
USB Audio Device Class public header. More...
#include <zephyr/usb/usb_ch9.h>
#include <zephyr/device.h>
#include <zephyr/net_buf.h>
#include <zephyr/sys/util.h>
Go to the source code of this file.
Data Structures | |
struct | usb_audio_fu_evt |
Feature Unit event structure. More... | |
struct | usb_audio_ops |
Audio callbacks used to interact with audio devices by user App. More... | |
Typedefs | |
typedef void(* | usb_audio_data_request_cb_t) (const struct device *dev) |
Callback type used to inform the app that data were requested from the device and may be send to the Host. | |
typedef void(* | usb_audio_data_completion_cb_t) (const struct device *dev, struct net_buf *buffer, size_t size) |
Callback type used to inform the app that data were successfully send/received. | |
typedef void(* | usb_audio_feature_updated_cb_t) (const struct device *dev, const struct usb_audio_fu_evt *evt) |
Callback type used to inform the app that Host has changed one of the features configured for the device. | |
Functions | |
size_t | usb_audio_get_in_frame_size (const struct device *dev) |
Get the frame size that is accepted by the Host. | |
void | usb_audio_register (const struct device *dev, const struct usb_audio_ops *ops) |
Register the USB Audio device and make it usable. | |
int | usb_audio_send (const struct device *dev, struct net_buf *buffer, size_t len) |
Send data using USB Audio device. | |
USB Audio Device Class public header.
Header follows below documentation:
Additional documentation considered a part of USB Audio v1.0:
typedef void(* usb_audio_data_completion_cb_t) (const struct device *dev, struct net_buf *buffer, size_t size) |
Callback type used to inform the app that data were successfully send/received.
dev | The device for which the callback was called. |
buffer | Pointer to the net_buf data chunk that was successfully send/received. If the application uses data_written_cb and/or data_received_cb callbacks it is responsible for freeing the buffer by itself. |
size | Amount of data that were successfully send/received. |
typedef void(* usb_audio_data_request_cb_t) (const struct device *dev) |
Callback type used to inform the app that data were requested from the device and may be send to the Host.
For sending the data usb_audio_send() API function should be used.
dev | The device for which data were requested by the Host. |
typedef void(* usb_audio_feature_updated_cb_t) (const struct device *dev, const struct usb_audio_fu_evt *evt) |
Callback type used to inform the app that Host has changed one of the features configured for the device.
Applicable for all devices.
dev | USB Audio device |
evt | Pointer to an event to be parsed by the App. Pointer struct is temporary and is valid only during the execution of this callback. |
Audio Class-Specific AC Interface Descriptor Subtypes.
Refer to Table A-5 from audio10.pdf
Audio Class-Specific Request Codes Refer to Table A-9 from audio10.pdf.
enum usb_audio_direction |
enum usb_audio_fucs |
Feature Unit Control Selectors Refer to Table A-11 from audio10.pdf.
USB Terminal Types Refer to Table 2-1 - Table 2-4 from termt10.pdf.
Get the frame size that is accepted by the Host.
This function returns the frame size for Input Devices that is expected by the Host. Returned value rely on Input Device configuration:
dev | The Input device that is asked for frame size. |
void usb_audio_register | ( | const struct device * | dev, |
const struct usb_audio_ops * | ops ) |
Register the USB Audio device and make it usable.
This must be called in order to make the device work and respond to all relevant requests.
dev | USB Audio device |
ops | USB audio callback structure. Callback are used to inform the user about what is happening |
Send data using USB Audio device.
dev | USB Audio device which will send the data over its ISO IN endpoint |
buffer | Pointer to the buffer that should be send. User is responsible for managing the buffer for Input devices. In case of sending error user must decide if the buffer should be dropped or retransmitted. After the buffer was sent successfully it is passed to the data_written_cb callback if the application uses one or automatically freed otherwise. User must provide proper net_buf chunk especially when it comes to its size. This information can be obtained using usb_audio_get_in_frame_size() API function. |
len | Length of the data to be send |