ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_usb_haud.c
Go to the documentation of this file.
1
35
36#include "ra8_usb_haud.h"
37
38#include <stdint.h>
39
40#include "ra8_attributes.h"
41#include "ra8_check.h"
42#include "ra8_err.h"
43#include "ra8_log.h"
44#include "ra8_usb.h"
45
46static const char* s_tag = "USBHAUD";
47
48/* =============================================================================
49 * Internal constants
50 * =============================================================================
51 */
52
72
77typedef enum : uint8_t {
78 /* Chapter-9 standard requests (USB 2.0 spec section 9.4). */
86 /* USB Audio 1.0 sec 5.2 "Class-Specific Requests" envelopes. */
91 /* Descriptor types in wValue's high byte (chapter 9). */
95
110
119
133
134/* =============================================================================
135 * Internal state
136 * =============================================================================
137 */
138
152
154
155/* =============================================================================
156 * Internal helpers
157 * =============================================================================
158 */
159
180
202{
203 ra8_err_t err = k_ra8_ok;
204 if (s_state.device.iso_out_ep != 0U) {
207 s_state.device.iso_out_ep,
210 s_state.device.iso_out_max_packet);
211 RA8_RETURN_ON_ERROR(err, s_tag, "haud: iso-out cfg");
212 }
213 if (s_state.device.iso_in_ep != 0U) {
216 s_state.device.iso_in_ep,
219 s_state.device.iso_in_max_packet);
220 }
221 return err;
222}
223
240static ra8_err_t internal_setup_get_descriptor(uint8_t desc_type, uint16_t length)
241{
242 const ra8_usb_setup_t setup = {
243 .bm_request_type = k_ra8_haud_bm_std_dev_in,
245 .w_value = (uint16_t)((uint16_t)desc_type << k_ra8_haud_shift_byte1),
246 .w_index = 0U,
247 .w_length = length,
248 };
249 return ra8_usb_host_setup_request(s_state.speed, &setup);
250}
251
268{
269 const ra8_usb_setup_t setup = {
270 .bm_request_type = k_ra8_haud_bm_std_dev_out,
271 .b_request = k_ra8_haud_breq_set_address,
272 .w_value = (uint16_t)address,
273 .w_index = 0U,
274 .w_length = 0U,
275 };
276 return ra8_usb_host_setup_request(s_state.speed, &setup);
277}
278
294static ra8_err_t internal_setup_set_config(uint8_t config_value)
295{
296 const ra8_usb_setup_t setup = {
297 .bm_request_type = k_ra8_haud_bm_std_dev_out,
298 .b_request = k_ra8_haud_breq_set_config,
299 .w_value = (uint16_t)config_value,
300 .w_index = 0U,
301 .w_length = 0U,
302 };
303 return ra8_usb_host_setup_request(s_state.speed, &setup);
304}
305
324{
325 const ra8_usb_setup_t setup = {
326 .bm_request_type = k_ra8_haud_bm_std_iface_out,
328 .w_value = k_ra8_haud_default_alt,
329 .w_index = (uint16_t)s_state.device.as_interface,
330 .w_length = 0U,
331 };
332 return ra8_usb_host_setup_request(s_state.speed, &setup);
333}
334
376{
377 s_state.device.device_address = (uint8_t)k_ra8_haud_assigned_address;
378 s_state.device.ac_interface = k_ra8_haud_default_ac_interface;
379 s_state.device.as_interface = k_ra8_haud_default_as_interface;
380 s_state.device.feature_unit_id = k_ra8_haud_default_feature_unit_id;
381 s_state.device.iso_out_ep = k_ra8_haud_default_iso_out_ep;
382 s_state.device.iso_in_ep = k_ra8_haud_default_iso_in_ep;
383 s_state.device.channel_count = (uint8_t)k_ra8_haud_default_channels;
384 s_state.device.bits_per_sample = (uint8_t)k_ra8_haud_default_bits;
385 s_state.device.iso_out_max_packet = internal_iso_max_packet(s_state.speed);
386 s_state.device.iso_in_max_packet = 0U;
387 s_state.device.sample_rate_min_hz = k_ra8_haud_default_sample_rate_hz;
388 s_state.device.sample_rate_max_hz = k_ra8_haud_default_sample_rate_hz;
389 /* VID / PID stay at zero until the production GET_DEVICE_DESCRIPTOR
390 * data stage lands; both fields are informational. */
391}
392
408{
410 return ra8_usb_host_bus_reset(s_state.speed, true);
411}
412
428{
429 const ra8_err_t rel = ra8_usb_host_bus_reset(s_state.speed, false);
430 RA8_RETURN_ON_ERROR(rel, /* GCOVR_EXCL_BR_LINE -- stored speed valid; reset rejects only speed */
431 s_tag,
432 "haud: release bus reset");
435}
436
453{
454 const ra8_err_t addr_err =
456 RA8_RETURN_ON_ERROR(addr_err, /* GCOVR_EXCL_BR_LINE -- valid speed + static in-range address */
457 s_tag,
458 "haud: set USBADDR");
461}
462
482
498{
499 /* Walk the class-specific descriptors out of the staged GET_CFG_DESC
500 * data buffer. Stub overwrites s_state.device defaults. */
504}
505
525
541{
543 return k_ra8_ok;
544}
545
561{
562 const ra8_err_t pipes_err = internal_configure_pipes();
563 RA8_RETURN_ON_ERROR(pipes_err, s_tag, "haud: configure pipes");
564 s_state.attached = true;
566 if (s_state.attach_cb != nullptr) {
567 s_state.attach_cb(s_state.attach_ctx, &s_state.device);
568 }
569 return k_ra8_ok;
570}
571
587{
588 switch (s_state.step) {
590 return internal_do_idle();
592 return internal_do_bus_reset();
600 return internal_do_set_config();
604 return internal_do_walk_desc();
605 default:
606 /* Already done; idempotent. */
607 return k_ra8_ok;
608 }
609}
610
626{
627 if (!s_state.initialized) {
629 }
630 if (!s_state.attached) {
632 }
633 return k_ra8_ok;
634}
635
653static bool internal_format_ok(uint8_t channel_count, uint8_t bits_per_sample, uint32_t sample_rate)
654{
655 if ((channel_count < (uint8_t)k_ra8_haud_min_channels) ||
656 (channel_count > (uint8_t)k_ra8_haud_max_channels)) {
657 return false;
658 }
659 if ((bits_per_sample < (uint8_t)k_ra8_haud_min_bits) ||
660 (bits_per_sample > (uint8_t)k_ra8_haud_max_bits)) {
661 return false;
662 }
663 if ((sample_rate < k_ra8_haud_min_sample_rate_hz) ||
664 (sample_rate > k_ra8_haud_max_sample_rate_hz)) {
665 return false;
666 }
667 return true;
668}
669
670/* =============================================================================
671 * Lifecycle
672 * =============================================================================
673 */
674
676{
677 if ((speed != k_ra8_usb_speed_fs) && (speed != k_ra8_usb_speed_hs)) {
679 }
680 const ra8_err_t usb_err = ra8_usb_host_init(speed);
681 if (usb_err != k_ra8_ok) {
682 ra8_log_error_val(s_tag, "ra8_usb_host_init failed", (uint32_t)usb_err);
684 }
685
686 s_state.speed = speed;
688 s_state.attached = false;
689 s_state.attach_cb = nullptr;
690 s_state.attach_ctx = nullptr;
691 s_state.device = (ra8_usb_haud_device_t){};
692 s_state.initialized = true;
693
694 ra8_log_info_val(s_tag, "host-Audio ready", (uint32_t)speed);
695 return k_ra8_ok;
696}
697
699{
700 if (!s_state.initialized) {
702 }
703 /* Bus power down: drop UACT before tearing the controller. */
704 (void)ra8_usb_host_set_uact(s_state.speed, false);
705 const ra8_err_t err = ra8_usb_host_deinit(s_state.speed);
706 s_state.initialized = false;
707 s_state.attached = false;
708 s_state.attach_cb = nullptr;
709 s_state.attach_ctx = nullptr;
711 return err;
712}
713
714/* =============================================================================
715 * Attach callback
716 * =============================================================================
717 */
718
720{
721 if (!s_state.initialized) {
723 }
724 s_state.attach_cb = on_attach;
725 s_state.attach_ctx = ctx;
726 return k_ra8_ok;
727}
728
729/* =============================================================================
730 * Class control transfers
731 * =============================================================================
732 */
733
734/* USB Audio 1.0 sec 5.2.3.2.3.1 "Sampling Frequency Control":
735 * bmRequestType = 0x22 (H2D | Class | Endpoint)
736 * bRequest = 0x01 (SET_CUR)
737 * wValue.high = 0x01 (SAMPLING_FREQ_CONTROL)
738 * wValue.low = 0x00
739 * wIndex = endpoint address
740 * wLength = 3 (24-bit LE sample rate)
741 */
743ra8_usb_haud_set_format(uint8_t channel_count, uint8_t bits_per_sample, uint32_t sample_rate_hz)
744{
746 if (pre != k_ra8_ok) {
747 return pre;
748 }
749 if (!internal_format_ok(channel_count, bits_per_sample, sample_rate_hz)) {
751 }
752 /* Update the cached snapshot so the recipient's
753 * `ra8_usb_haud_device_t` reflects the new format. */
754 s_state.device.channel_count = channel_count;
755 s_state.device.bits_per_sample = bits_per_sample;
756 s_state.device.sample_rate_min_hz = sample_rate_hz;
757 s_state.device.sample_rate_max_hz = sample_rate_hz;
758
759 const uint8_t target_ep =
760 (s_state.device.iso_out_ep != 0U) ? s_state.device.iso_out_ep : s_state.device.iso_in_ep;
761 const ra8_usb_setup_t setup = {
762 .bm_request_type = k_ra8_haud_bm_class_ep_out,
763 .b_request = k_ra8_haud_req_set_cur,
764 .w_value = (uint16_t)((uint16_t)k_ra8_haud_ep_control_sampling_freq << k_ra8_haud_shift_byte1),
765 .w_index = (uint16_t)target_ep,
767 };
768 return ra8_usb_host_setup_request(s_state.speed, &setup);
769}
770
771/* USB Audio 1.0 sec 5.2.2.4.3.2 "Volume Control":
772 * bmRequestType = 0x21 (H2D | Class | Interface)
773 * bRequest = 0x01 (SET_CUR)
774 * wValue.high = 0x02 (VOLUME_CONTROL)
775 * wValue.low = channel
776 * wIndex.high = bUnitID (Feature Unit)
777 * wIndex.low = bInterfaceNumber (AC interface)
778 * wLength = 2 (signed 16-bit dB in 1/256 step)
779 */
780ra8_err_t ra8_usb_haud_set_volume(uint8_t channel, int16_t volume)
781{
783 if (pre != k_ra8_ok) {
784 return pre;
785 }
786 const uint16_t w_value =
787 (uint16_t)(((uint16_t)k_ra8_haud_fu_control_volume << k_ra8_haud_shift_byte1) |
788 (uint16_t)channel);
789 const uint16_t w_index =
790 (uint16_t)(((uint16_t)s_state.device.feature_unit_id << k_ra8_haud_shift_byte1) |
791 (uint16_t)s_state.device.ac_interface);
792 const ra8_usb_setup_t setup = {
793 .bm_request_type = k_ra8_haud_bm_class_iface_out,
794 .b_request = k_ra8_haud_req_set_cur,
795 .w_value = w_value,
796 .w_index = w_index,
797 .w_length = k_ra8_haud_volume_payload,
798 };
799 /* Production path queues the 2-byte signed dB payload on the DCP
800 * data stage. The starter just ensures the SETUP envelope hits the
801 * wire. */
802 (void)volume;
803 return ra8_usb_host_setup_request(s_state.speed, &setup);
804}
805
806/* USB Audio 1.0 sec 5.2.2.4.3.1 "Mute Control":
807 * bmRequestType = 0x21 (H2D | Class | Interface)
808 * bRequest = 0x01 (SET_CUR)
809 * wValue.high = 0x01 (MUTE_CONTROL)
810 * wValue.low = channel
811 * wIndex.high = bUnitID (Feature Unit)
812 * wIndex.low = bInterfaceNumber (AC interface)
813 * wLength = 1 (boolean)
814 */
815ra8_err_t ra8_usb_haud_set_mute(uint8_t channel, bool mute)
816{
818 if (pre != k_ra8_ok) {
819 return pre;
820 }
821 const uint16_t w_value =
822 (uint16_t)(((uint16_t)k_ra8_haud_fu_control_mute << k_ra8_haud_shift_byte1) |
823 (uint16_t)channel);
824 const uint16_t w_index =
825 (uint16_t)(((uint16_t)s_state.device.feature_unit_id << k_ra8_haud_shift_byte1) |
826 (uint16_t)s_state.device.ac_interface);
827 const ra8_usb_setup_t setup = {
828 .bm_request_type = k_ra8_haud_bm_class_iface_out,
829 .b_request = k_ra8_haud_req_set_cur,
830 .w_value = w_value,
831 .w_index = w_index,
832 .w_length = k_ra8_haud_mute_payload,
833 };
834 (void)mute;
835 return ra8_usb_host_setup_request(s_state.speed, &setup);
836}
837
838/* =============================================================================
839 * Isochronous data transfer
840 * =============================================================================
841 */
842
843ra8_err_t ra8_usb_haud_send_samples(const uint8_t* buf, uint16_t len_bytes)
844{
845 if ((buf == nullptr) && (len_bytes != 0U)) {
846 return k_ra8_err_null_ptr;
847 }
848 if (buf == nullptr) {
849 return k_ra8_err_null_ptr;
850 }
852 if (pre != k_ra8_ok) {
853 return pre;
854 }
855 if (len_bytes == 0U) {
857 }
858 if (s_state.device.iso_out_ep == 0U) {
860 }
861 return ra8_usb_queue_in(s_state.speed, k_ra8_haud_pipe_iso_out, buf, len_bytes);
862}
863
864ra8_err_t ra8_usb_haud_recv_samples(uint8_t* buf, uint16_t max_len_bytes, uint16_t* got_len_bytes)
865{
866 RA8_CHECK_NULL_PTR(buf, s_tag, "recv_samples: buf");
867 RA8_CHECK_NULL_PTR(got_len_bytes, s_tag, "recv_samples: got_len_bytes");
869 if (pre != k_ra8_ok) {
870 return pre;
871 }
872 if (max_len_bytes == 0U) {
874 }
875 if (s_state.device.iso_in_ep == 0U) {
877 }
878 uint16_t inout_len = max_len_bytes;
879 const ra8_err_t err =
880 ra8_usb_queue_out(s_state.speed, k_ra8_haud_pipe_iso_in, buf, &inout_len, true);
881 if (err == k_ra8_ok) {
882 *got_len_bytes = inout_len;
883 } else {
884 *got_len_bytes = 0U;
885 }
886 return err;
887}
888
889/* =============================================================================
890 * Test / introspection helpers
891 * =============================================================================
892 */
893
895{
896 if (!s_state.initialized) {
898 }
899 return internal_step_advance();
900}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Definition ra8_check.h:184
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_init_failed
Hardware peripheral failed to initialise.
Definition ra8_err.h:290
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
Definition ra8_err.h:161
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
Definition ra8_err.h:478
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info_val(tag, message, value)
RA8 log info val.
Definition ra8_log.h:366
#define ra8_log_error_val(tag, message, value)
RA8 log error val.
Definition ra8_log.h:337
static uint32_t s_state
Native USB controller driver public API (device + host modes).
ra8_err_t ra8_usb_queue_out(ra8_usb_speed_t speed, uint8_t pipe_num, uint8_t *out_buf, uint16_t *inout_len, bool rearm)
Drain an OUT transfer (host -> device) from pipe_num.
@ k_ra8_usb_ep_type_iso
Isochronous transfer.
ra8_err_t ra8_usb_set_address(ra8_usb_speed_t speed, uint8_t address)
Program the device USB address into USBADDR.
ra8_err_t ra8_usb_configure_endpoint(ra8_usb_speed_t speed, uint8_t pipe_num, uint8_t ep_addr, ra8_usb_ep_dir_t dir, ra8_usb_ep_type_t type, uint16_t max_packet)
Configure a non-control PIPE for IN or OUT bulk / interrupt / iso transfers.
@ k_ra8_usb_ep_dir_in
Device -> host.
@ k_ra8_usb_ep_dir_out
Host -> device.
ra8_usb_speed_t
Selects which controller instance the call targets.
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
@ k_ra8_usb_speed_fs
Full-Speed controller (USBFS @ 0x40250000).
ra8_err_t ra8_usb_queue_in(ra8_usb_speed_t speed, uint8_t pipe_num, const uint8_t *data, uint16_t len)
Queue an IN transfer (device -> host) on pipe_num.
ra8_err_t ra8_usb_haud_step(void)
Drive the enumeration step machine forward by one step.
static ra8_err_t internal_do_set_address(void)
Step handler – store assigned address + SETUP for GET_DEVICE_DESCRIPTOR.
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").
static ra8_err_t internal_setup_set_config(uint8_t config_value)
Stage a SET_CONFIGURATION SETUP request.
static ra8_err_t internal_do_idle(void)
Step handler – bus-reset assert.
ra8_err_t ra8_usb_haud_close(void)
Tear down the host-Audio driver and release the controller.
static ra8_err_t internal_step_advance(void)
Drive the enumeration step machine forward by one step.
static ra8_err_t internal_do_set_config(void)
Step handler – SETUP for SET_INTERFACE (alt 1).
ra8_usb_haud_default_unit_t
Default Feature Unit ID applied by the descriptor-walk stub when the attached device follows the cano...
@ k_ra8_haud_default_as_interface
AS bInterfaceNumber.
@ k_ra8_haud_default_ac_interface
AC bInterfaceNumber.
@ k_ra8_haud_default_iso_in_ep
No mic in default stub.
@ k_ra8_haud_default_iso_out_ep
Common iso-OUT EP num.
@ k_ra8_haud_default_feature_unit_id
Common bUnitID for FU.
static ra8_err_t internal_setup_set_interface(void)
Stage a SET_INTERFACE SETUP request to the AS interface.
static ra8_err_t internal_setup_get_descriptor(uint8_t desc_type, uint16_t length)
Stage a chapter-9 GET_DESCRIPTOR SETUP request.
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.
static ra8_err_t internal_do_bus_reset(void)
Step handler – bus-reset release + SETUP for SET_ADDRESS.
static ra8_err_t internal_do_get_dev_desc(void)
Step handler – SETUP for GET_CONFIGURATION_DESCRIPTOR.
static uint16_t internal_iso_max_packet(ra8_usb_speed_t speed)
Pick the iso-max-packet ceiling matching the negotiated speed.
static void internal_walk_config_descriptor(void)
Populate s_state.device with stub descriptor data.
ra8_usb_haud_step_t
Enumeration step machine states.
@ k_ra8_haud_step_bus_reset
Drive USBRST then release.
@ k_ra8_haud_step_done
Attach callback fires.
@ k_ra8_haud_step_walk_desc
Walk AC + AS interfaces.
@ k_ra8_haud_step_set_address
SET_ADDRESS to assigned 1.
@ k_ra8_haud_step_get_cfg_desc
GET_CONFIGURATION_DESCRIPTOR.
@ k_ra8_haud_step_idle
Pre-attach.
@ k_ra8_haud_step_set_interface
SET_INTERFACE (alt 1).
@ k_ra8_haud_step_get_dev_desc
GET_DEVICE_DESCRIPTOR (18).
@ k_ra8_haud_step_set_config
SET_CONFIGURATION (1).
static ra8_err_t internal_do_set_interface(void)
Step handler – pure software state move into walk_desc.
ra8_usb_haud_setup_field_t
Standard chapter-9 + Audio class request encodings.
@ k_ra8_haud_desc_device
DEVICE descriptor.
@ k_ra8_haud_bm_std_dev_in
Std | Device | In.
@ k_ra8_haud_bm_class_ep_in
Class | Endpoint | In.
@ k_ra8_haud_bm_std_iface_out
Std | Interface | Out.
@ k_ra8_haud_breq_set_interface
SET_INTERFACE.
@ k_ra8_haud_breq_set_config
SET_CONFIGURATION.
@ k_ra8_haud_breq_get_descriptor
GET_DESCRIPTOR.
@ k_ra8_haud_bm_class_iface_out
Class | Interface | Out.
@ k_ra8_haud_bm_class_iface_in
Class | Interface | In.
@ k_ra8_haud_breq_set_address
SET_ADDRESS.
@ k_ra8_haud_bm_std_dev_out
Std | Device | Out.
@ k_ra8_haud_desc_configuration
CONFIGURATION descriptor.
@ k_ra8_haud_bm_class_ep_out
Class | Endpoint | Out.
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_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").
static bool internal_format_ok(uint8_t channel_count, uint8_t bits_per_sample, uint32_t sample_rate)
Validate audio format against the supported ranges.
static ra8_err_t internal_do_walk_desc(void)
Step handler – configure pipes and finalise.
static ra8_err_t internal_class_preflight(void)
Common pre-flight for every class control transfer.
ra8_usb_haud_size_t
Standard descriptor sizes and wire payloads.
@ k_ra8_haud_dev_desc_len
USB DEVICE descriptor.
@ k_ra8_haud_sample_rate_payload
24-bit LE rate payload.
@ k_ra8_haud_assigned_address
First assigned device addr.
@ k_ra8_haud_mute_payload
1-byte boolean payload.
@ k_ra8_haud_default_alt
Streaming alt setting.
@ k_ra8_haud_cfg_desc_len
CONFIGURATION descriptor hdr.
@ k_ra8_haud_volume_payload
16-bit signed dB payload.
@ k_ra8_haud_default_config
bConfigurationValue = 1.
static ra8_err_t internal_setup_set_address(uint8_t address)
Stage a SET_ADDRESS SETUP request.
ra8_usb_haud_byte_shift_t
Per-byte left-shift constants for wValue / wIndex layout.
@ k_ra8_haud_shift_byte1
RA8 haud shift byte1.
@ k_ra8_haud_shift_byte0
RA8 haud shift byte0.
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...
static ra8_err_t internal_do_get_cfg_desc(void)
Step handler – SETUP for SET_CONFIGURATION.
static ra8_err_t internal_configure_pipes(void)
Configure the host-Audio iso pipes against the attached device's endpoints.
Native USB host-side Audio class layer (USB Audio 1.0).
void(* ra8_usb_haud_attach_fn_t)(void *ctx, const ra8_usb_haud_device_t *device)
Attach-callback signature.
@ 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.
@ k_ra8_haud_ep_control_sampling_freq
SAMPLING_FREQ_CONTROL.
@ k_ra8_haud_default_sample_rate_hz
48 kHz default.
@ k_ra8_haud_default_channels
Stereo.
@ k_ra8_haud_default_bits
16-bit PCM.
@ k_ra8_haud_iso_max_packet_fs
FS isochronous ceiling.
@ k_ra8_haud_iso_max_packet_hs
HS isochronous ceiling.
@ k_ra8_haud_req_set_cur
SET_CUR.
@ k_ra8_haud_pipe_iso_in
PIPE1 -> attached EP iso IN.
@ k_ra8_haud_pipe_iso_out
PIPE2 -> attached EP iso OUT.
@ k_ra8_haud_fu_control_volume
VOLUME_CONTROL.
@ k_ra8_haud_fu_control_mute
MUTE_CONTROL.
ra8_err_t ra8_usb_host_bus_reset(ra8_usb_speed_t speed, bool assert_reset)
Drive (or release) the bus reset line.
ra8_err_t ra8_usb_host_init(ra8_usb_speed_t speed)
Bring up a USB controller in HOST mode.
ra8_err_t ra8_usb_host_deinit(ra8_usb_speed_t speed)
Tear down a host-mode controller and drop its MSTP reference.
ra8_err_t ra8_usb_host_setup_request(ra8_usb_speed_t speed, const ra8_usb_setup_t *setup)
Issue a SETUP packet through the DCP (host -> peripheral).
ra8_err_t ra8_usb_host_set_uact(ra8_usb_speed_t speed, bool enable)
Enable / disable SOF (Start-of-Frame) generation on the bus.
Snapshot of the attached audio device, passed to the attach callback.
Singleton shadow state for the host-Audio driver.
ra8_usb_haud_step_t step
Current enumeration step.
ra8_usb_haud_attach_fn_t attach_cb
Attach callback, or NULL.
ra8_usb_speed_t speed
Underlying controller.
bool initialized
True after ra8_usb_haud_init.
ra8_usb_haud_device_t device
Snapshot of attached device.
bool attached
True after enumeration done.
void * attach_ctx
Attach callback ctx.
Decoded 8-byte USB SETUP packet.