nRF Connect SDK API 3.4.99
Loading...
Searching...
No Matches
audio_usb.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
16#ifndef _AUDIO_USB_H_
17#define _AUDIO_USB_H_
18
19#include <zephyr/kernel.h>
20#include <zephyr/usb/usbd.h>
21
22#if (CONFIG_AUDIO_SOURCE_USB && !CONFIG_AUDIO_SAMPLE_RATE_48000_HZ && \
23 MAX(CONFIG_AUDIO_INPUT_CHANNELS, CONFIG_AUDIO_OUTPUT_CHANNELS) != 2)
24/* Only 48kHz stereo is supported when using USB */
25#error USB only supports 48kHz stereo
26#endif /* (CONFIG_AUDIO_SOURCE_USB && !CONFIG_AUDIO_SAMPLE_RATE_48000_HZ) */
27
28#define USB_1MS_BLOCKS_NUM_MAX \
29 ((CONFIG_AUDIO_FRAME_DURATION_US / USEC_PER_MSEC) + \
30 (CONFIG_AUDIO_FRAME_DURATION_US % USEC_PER_MSEC ? 1 : 0))
31#define USB_BLOCK_1MS_MONO_SIZE \
32 (CONFIG_AUDIO_SAMPLE_RATE_HZ * CONFIG_AUDIO_BIT_DEPTH_OCTETS / MSEC_PER_SEC)
33#define USB_BLOCK_MULTI_CHAN_1MS_SIZE \
34 (USB_BLOCK_1MS_MONO_SIZE * MAX(CONFIG_AUDIO_INPUT_CHANNELS, CONFIG_AUDIO_OUTPUT_CHANNELS))
35
36struct usbd_context *audio_usbd_init_device(usbd_msg_cb_t msg_cb);
37
45
53
61
70int audio_usb_start(struct k_msgq *audio_q_out_ptr, struct k_msgq *audio_q_in_ptr);
71
81
88
100int audio_usb_init(bool host_in, bool host_out);
101
106#endif /* _AUDIO_USB_H_ */
bool audio_usb_headset_out_enabled(void)
Get the state of the USB devices headset out.
bool audio_usb_headset_in_enabled(void)
Get the state of the USB devices headset in.
int audio_usb_disable(void)
Stop and disable USB device.
int audio_usb_init(bool host_in, bool host_out)
Register and enable USB device.
bool audio_usb_headphones_out_enabled(void)
Get the state of the USB devices headphones out.
int audio_usb_start(struct k_msgq *audio_q_out_ptr, struct k_msgq *audio_q_in_ptr)
Set pointers to the queues to be used by the USB module and start sending/receiving data.
struct usbd_context * audio_usbd_init_device(usbd_msg_cb_t msg_cb)
int audio_usb_stop(void)
Stop sending/receiving data.