ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_haud.h
Go to the documentation of this file.
1
48
49#pragma once
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#include <stdint.h>
56
57#include "ra8_err.h"
58#include "ra8_usb.h"
59
60/* =============================================================================
61 * Constants
62 * =============================================================================
63 */
64
79
94
108
125
137
149
167
187
199
208typedef enum : int32_t {
209 k_ra8_haud_volume_silence = (int32_t)0x8000,
210 k_ra8_haud_volume_min_db = (int32_t)-32768,
211 k_ra8_haud_volume_max_db = (int32_t)32767,
213
223
235
248
276
290typedef void (*ra8_usb_haud_attach_fn_t)(void* ctx, const ra8_usb_haud_device_t* device);
291
292/* =============================================================================
293 * Lifecycle
294 * =============================================================================
295 */
296
324[[nodiscard]] ra8_err_t ra8_usb_haud_init(ra8_usb_speed_t speed);
325
342[[nodiscard]] ra8_err_t ra8_usb_haud_close(void);
343
344/* =============================================================================
345 * Attach callback
346 * =============================================================================
347 */
348
373[[nodiscard]] ra8_err_t ra8_usb_haud_attach_callback(ra8_usb_haud_attach_fn_t on_attach, void* ctx);
374
375/* =============================================================================
376 * Class control transfers
377 * =============================================================================
378 */
379
415[[nodiscard]] ra8_err_t
416ra8_usb_haud_set_format(uint8_t channel_count, uint8_t bits_per_sample, uint32_t sample_rate_hz);
417
448[[nodiscard]] ra8_err_t ra8_usb_haud_set_volume(uint8_t channel, int16_t volume);
449
479[[nodiscard]] ra8_err_t ra8_usb_haud_set_mute(uint8_t channel, bool mute);
480
481/* =============================================================================
482 * Isochronous data transfer
483 * =============================================================================
484 */
485
515[[nodiscard]] ra8_err_t ra8_usb_haud_send_samples(const uint8_t* buf, uint16_t len_bytes);
516
545[[nodiscard]] ra8_err_t
546ra8_usb_haud_recv_samples(uint8_t* buf, uint16_t max_len_bytes, uint16_t* got_len_bytes);
547
548/* =============================================================================
549 * Test / introspection helpers
550 * =============================================================================
551 */
552
575[[nodiscard]] ra8_err_t ra8_usb_haud_step(void);
576
577#ifdef __cplusplus
578}
579#endif
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Native USB controller driver public API (device + host modes).
ra8_usb_speed_t
Selects which controller instance the call targets.
ra8_err_t ra8_usb_haud_step(void)
Drive the enumeration step machine forward by one step.
void(* ra8_usb_haud_attach_fn_t)(void *ctx, const ra8_usb_haud_device_t *device)
Attach-callback signature.
ra8_err_t ra8_usb_haud_set_mute(uint8_t channel, bool mute)
Issue SET_CUR on the Feature Unit Mute control (USB Audio 1.0 sec 5.2.2.4.3.1 "Mute Control").
ra8_err_t ra8_usb_haud_close(void)
Tear down the host-Audio driver and release the controller.
ra8_usb_haud_as_subtype_t
Class-specific AS interface descriptor subtypes (USB Audio 1.0 sec A.6 "Audio Class-Specific AS Inter...
@ k_ra8_haud_as_general
AS_GENERAL.
@ k_ra8_haud_as_format_specific
FORMAT_SPECIFIC.
@ k_ra8_haud_as_format_type
FORMAT_TYPE.
ra8_usb_haud_ac_subtype_t
Class-specific AC interface descriptor subtypes (USB Audio 1.0 sec A.5 "Audio Class-Specific AC Inter...
@ k_ra8_haud_ac_input_terminal
INPUT_TERMINAL.
@ k_ra8_haud_ac_output_terminal
OUTPUT_TERMINAL.
@ k_ra8_haud_ac_header
HEADER.
@ k_ra8_haud_ac_selector_unit
SELECTOR_UNIT.
@ k_ra8_haud_ac_extension_unit
EXTENSION_UNIT.
@ k_ra8_haud_ac_processing_unit
PROCESSING_UNIT.
@ k_ra8_haud_ac_feature_unit
FEATURE_UNIT.
@ k_ra8_haud_ac_mixer_unit
MIXER_UNIT.
ra8_err_t ra8_usb_haud_recv_samples(uint8_t *buf, uint16_t max_len_bytes, uint16_t *got_len_bytes)
Drain isochronous-IN samples from a microphone.
ra8_err_t ra8_usb_haud_send_samples(const uint8_t *buf, uint16_t len_bytes)
Push isochronous-OUT samples to a speaker / headphones.
ra8_usb_haud_format_limit_t
Range checks for ra8_usb_haud_set_format.
@ k_ra8_haud_max_sample_rate_hz
192 kHz max.
@ k_ra8_haud_min_channels
Mono.
@ k_ra8_haud_max_channels
7.1 surround ceiling.
@ k_ra8_haud_min_sample_rate_hz
8 kHz min.
@ k_ra8_haud_min_bits
8-bit ceiling.
@ k_ra8_haud_max_bits
32-bit ceiling.
ra8_usb_haud_ep_control_t
Endpoint Control Selectors (USB Audio 1.0 sec A.10.5).
@ k_ra8_haud_ep_control_sampling_freq
SAMPLING_FREQ_CONTROL.
@ k_ra8_haud_ep_control_undefined
EP_CONTROL_UNDEFINED.
@ k_ra8_haud_ep_control_pitch
PITCH_CONTROL.
ra8_usb_haud_default_t
Default audio format applied by the descriptor-walk stub when the attached device follows the canonic...
@ k_ra8_haud_default_sample_rate_hz
48 kHz default.
@ k_ra8_haud_default_channels
Stereo.
@ k_ra8_haud_default_bits
16-bit PCM.
ra8_usb_haud_format_type_t
Audio-Streaming format-type codes (USB Audio Data Formats 1.0 sec 2 "Format Type Codes").
@ k_ra8_haud_format_type_iii
FORMAT_TYPE_III.
@ k_ra8_haud_format_type_i
FORMAT_TYPE_I (PCM).
@ k_ra8_haud_format_type_undefined
FORMAT_TYPE_UNDEFINED.
@ k_ra8_haud_format_type_ii
FORMAT_TYPE_II.
ra8_err_t ra8_usb_haud_init(ra8_usb_speed_t speed)
Bring up the host-Audio driver on a chosen USB controller.
ra8_err_t ra8_usb_haud_attach_callback(ra8_usb_haud_attach_fn_t on_attach, void *ctx)
Register (or detach) the attach callback.
ra8_usb_haud_packet_t
Packet sizing for the attached device's isochronous endpoints.
@ k_ra8_haud_iso_max_packet_fs
FS isochronous ceiling.
@ k_ra8_haud_iso_max_packet_hs
HS isochronous ceiling.
@ k_ra8_haud_iso_max_packet_default
Common 48 kHz / 16-bit / stereo.
ra8_err_t ra8_usb_haud_set_volume(uint8_t channel, int16_t volume)
Issue SET_CUR on the Feature Unit Volume control (USB Audio 1.0 sec 5.2.2.4.3 "Volume Control").
ra8_usb_haud_class_t
Class / subclass triplet that identifies the Audio function within an attached USB device's descripto...
@ k_ra8_haud_subclass_undefined
SUBCLASS_UNDEFINED.
@ k_ra8_haud_subclass_audiocontrol
AUDIOCONTROL.
@ k_ra8_haud_subclass_audiostreaming
AUDIOSTREAMING.
@ k_ra8_haud_subclass_midistreaming
MIDISTREAMING.
@ k_ra8_haud_class_audio
AUDIO interface class.
ra8_usb_haud_request_t
Audio class-specific request codes the host issues to the attached device (USB Audio 1....
@ k_ra8_haud_req_set_min
SET_MIN.
@ k_ra8_haud_req_get_cur
GET_CUR.
@ k_ra8_haud_req_set_max
SET_MAX.
@ k_ra8_haud_req_get_min
GET_MIN.
@ k_ra8_haud_req_get_res
GET_RES.
@ k_ra8_haud_req_undefined
REQUEST_CODE_UNDEFINED.
@ k_ra8_haud_req_set_cur
SET_CUR.
@ k_ra8_haud_req_get_max
GET_MAX.
@ k_ra8_haud_req_set_res
SET_RES.
ra8_usb_haud_volume_t
Volume-control wire encoding helpers.
@ k_ra8_haud_volume_silence
Silence sentinel.
@ k_ra8_haud_volume_min_db
-128.0 dB ceiling.
@ k_ra8_haud_volume_max_db
+127.998 dB ceiling.
ra8_usb_haud_pipe_t
PIPE numbers used by the host-Audio driver for the attached peripheral's isochronous endpoints.
@ k_ra8_haud_pipe_iso_in
PIPE1 -> attached EP iso IN.
@ k_ra8_haud_pipe_iso_out
PIPE2 -> attached EP iso OUT.
ra8_usb_haud_fu_control_t
Feature Unit control selectors (USB Audio 1.0 sec A.10.2 "Feature Unit Control Selectors").
@ k_ra8_haud_fu_control_mid
MID_CONTROL.
@ k_ra8_haud_fu_control_auto_gain
AUTOMATIC_GAIN_CONTROL.
@ k_ra8_haud_fu_control_volume
VOLUME_CONTROL.
@ k_ra8_haud_fu_control_graphic_eq
GRAPHIC_EQ_CONTROL.
@ k_ra8_haud_fu_control_undefined
FU_CONTROL_UNDEFINED.
@ k_ra8_haud_fu_control_loudness
LOUDNESS_CONTROL.
@ k_ra8_haud_fu_control_bass_boost
BASS_BOOST_CONTROL.
@ k_ra8_haud_fu_control_delay
DELAY_CONTROL.
@ k_ra8_haud_fu_control_treble
TREBLE_CONTROL.
@ k_ra8_haud_fu_control_bass
BASS_CONTROL.
@ k_ra8_haud_fu_control_mute
MUTE_CONTROL.
ra8_usb_haud_cs_desc_t
Class-specific descriptor type values (USB Audio 1.0 sec A.4 "Audio Class-Specific Descriptor Types")...
@ k_ra8_haud_cs_desc_endpoint
CS_ENDPOINT.
@ k_ra8_haud_cs_desc_undefined
CS_UNDEFINED.
@ k_ra8_haud_cs_desc_string
CS_STRING.
@ k_ra8_haud_cs_desc_interface
CS_INTERFACE.
@ k_ra8_haud_cs_desc_device
CS_DEVICE.
@ k_ra8_haud_cs_desc_config
CS_CONFIGURATION.
ra8_err_t ra8_usb_haud_set_format(uint8_t channel_count, uint8_t bits_per_sample, uint32_t sample_rate_hz)
Issue SET_CUR on the format-type-I descriptor (USB Audio 1.0 sec 5.2.3 "Class-Specific AS Interface C...
Snapshot of the attached audio device, passed to the attach callback.
uint32_t sample_rate_min_hz
Minimum tSamFreq from FORMAT_TYPE_I.
uint8_t feature_unit_id
Feature Unit bUnitID (for FU controls).
uint16_t iso_in_max_packet
iso-IN wMaxPacketSize.
uint8_t channel_count
bNrChannels from FORMAT_TYPE_I desc.
uint8_t ac_interface
AudioControl bInterfaceNumber.
uint16_t vendor_id
idVendor from device descriptor.
uint8_t as_interface
AudioStreaming bInterfaceNumber.
uint8_t device_address
Assigned USB address (1..127).
uint16_t iso_out_max_packet
iso-OUT wMaxPacketSize.
uint8_t iso_out_ep
iso-OUT EP num (0 if absent).
uint32_t sample_rate_max_hz
Maximum tSamFreq from FORMAT_TYPE_I.
uint8_t iso_in_ep
iso-IN EP num (0 if absent).
uint16_t product_id
idProduct from device descriptor.
uint8_t bits_per_sample
bBitResolution from FORMAT_TYPE_I.