|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Serial Sound Interface Enhanced (SSIE / I2S audio) driver. More...
Go to the source code of this file.
Data Structures | |
| struct | ra8_ssie_cfg_t |
| Configuration descriptor for ra8_ssie_init. More... | |
| struct | ra8_ssie_status_t |
| Snapshot of FIFO levels + error flags returned by ra8_ssie_get_status. More... | |
| struct | ra8_ssie_dma_cfg_t |
| DMA pump descriptor for ra8_ssie_attach_dma. More... | |
Typedefs | |
| typedef void(* | ra8_ssie_event_fn_t) (void *ctx, uint8_t channel, uint8_t events, uint32_t ssisr) |
| SSIE event callback fired by ra8_ssie_dispatch. | |
Functions | |
| ra8_err_t | ra8_ssie_init (uint8_t channel, const ra8_ssie_cfg_t *cfg) |
| Initialise an SSIE channel for I2S / TDM / monaural transfer. | |
| ra8_err_t | ra8_ssie_deinit (uint8_t channel) |
| Tear down an SSIE channel and gate its clock. | |
| ra8_err_t | ra8_ssie_start (uint8_t channel, ra8_ssie_dir_t dir) |
| Enable transmission, reception, or full duplex. | |
| ra8_err_t | ra8_ssie_stop (uint8_t channel) |
| Disable transmission and reception. | |
| ra8_err_t | ra8_ssie_start_recovery (uint8_t channel) |
| Force the channel back into a known idle state. | |
| ra8_err_t | ra8_ssie_mute (uint8_t channel, bool enable) |
| Enable or disable mute on the next frame boundary. | |
| ra8_err_t | ra8_ssie_set_thresholds (uint8_t channel, uint8_t tx_threshold, uint8_t rx_threshold) |
| Update the FIFO trigger watermarks at runtime. | |
| ra8_err_t | ra8_ssie_set_fifo_threshold (uint8_t channel, uint8_t tx_threshold, uint8_t rx_threshold) |
| Programme SSITDMR / SSIRDMR FIFO thresholds in one call. | |
| ra8_err_t | ra8_ssie_attach_dma_pair (uint8_t channel, uint8_t tx_dma_channel, uint8_t rx_dma_channel) |
| Pair an SSIE channel's TX + RX FIFOs to DMAC channels. | |
| ra8_err_t | ra8_ssie_send_iso (uint8_t channel, const uint32_t *buffer, uint16_t samples) |
| Block-mode isochronous send. | |
| ra8_err_t | ra8_ssie_recv_iso (uint8_t channel, uint32_t *buffer, uint16_t max_samples, uint16_t *out_got) |
| Block-mode isochronous receive. | |
| ra8_err_t | ra8_ssie_write_sample (uint8_t channel, uint32_t sample) |
| Push one 32-bit sample into the transmit FIFO. | |
| ra8_err_t | ra8_ssie_read_sample (uint8_t channel, uint32_t *out) |
| Pop one 32-bit sample from the receive FIFO. | |
| ra8_err_t | ra8_ssie_write_buffer (uint8_t channel, const uint32_t *buffer, uint16_t samples, uint16_t *out_written) |
| Drain a host buffer into the TX FIFO until either runs out. | |
| ra8_err_t | ra8_ssie_read_buffer (uint8_t channel, uint32_t *buffer, uint16_t samples, uint16_t *out_read) |
| Empty the RX FIFO into a host buffer until either runs out. | |
| ra8_err_t | ra8_ssie_attach_dma (uint8_t channel, const ra8_ssie_dma_cfg_t *dma) |
| Attach DMAC channels to the SSIE TX and/or RX FIFOs. | |
| ra8_err_t | ra8_ssie_detach_dma (uint8_t channel) |
| Tear down DMAC channels attached to the SSIE FIFOs. | |
| ra8_err_t | ra8_ssie_get_status (uint8_t channel, ra8_ssie_status_t *out) |
| Snapshot SSISR + SSIFSR into a status struct. | |
| ra8_err_t | ra8_ssie_clear_status (uint8_t channel, uint32_t mask) |
| Clear sticky error flags in SSISR. | |
| ra8_err_t | ra8_ssie_attach_handler (ra8_ssie_event_fn_t fn, void *ctx) |
| Attach a shared event callback for both SSIE channels. | |
| void | ra8_ssie_dispatch (uint8_t channel) |
| ISR helper: fire the registered event handler. | |
| ra8_err_t | ra8_ssie_set_irq_enable (uint8_t channel, uint32_t mask, bool enable) |
| Update the IRQ enable mask without rewriting SSICR fully. | |
| ra8_err_t | ra8_ssie_enter_stop (uint8_t channel) |
| Gate the channel's MSTP bit (preserve register state). | |
| ra8_err_t | ra8_ssie_exit_stop (uint8_t channel) |
| Re-ungate the channel's MSTP bit. | |
Serial Sound Interface Enhanced (SSIE / I2S audio) driver.
Full-coverage RA8D2 SSIE driver. Each chip has two SSIE channels: SSIE0 is full-duplex (SSITXD0 + SSIRXD0) and SSIE1 is half-duplex (shared SSIDATA1 line). Both channels share the same register map and are addressed by channel = 0|1.
Coverage of HUM Ch 46 "Serial Sound Interface Enhanced (SSIE)" pages 3051-3121:
Every register access in the matching .c carries a HUM Ch 46 citation. FSP r_ssi.c was used as reference for the SSICR / SSIFCR / SSISCR shift macros and the start/stop sequences only – no code copied.
Definition in file ra8_ssie.h.
| typedef void(* ra8_ssie_event_fn_t) (void *ctx, uint8_t channel, uint8_t events, uint32_t ssisr) |
SSIE event callback fired by ra8_ssie_dispatch.
| [in] | ctx | Caller context registered via ra8_ssie_attach_handler. |
| [in] | channel | Channel that fired (0 or 1). |
| [in] | events | Decoded ra8_ssie_event_t bitmap. |
| [in] | ssisr | Snapshot of SSISR at IRQ entry. |
Definition at line 305 of file ra8_ssie.h.
| enum ra8_ssie_bclk_div_t : uint8_t |
Bit-clock divider (drives SSICR.CKDV[3:0]).
Controller-mode only. Divides AUDIO_MCK to produce SSIBCKn. See HUM Ch 46.2.1 CKDV table, p 3056. Encodings 0xD..0xF are "setting prohibited" and intentionally not exposed.
Definition at line 189 of file ra8_ssie.h.
| enum ra8_ssie_data_word_t : uint8_t |
Data word length (drives SSICR.DWL[2:0]).
"Number of significant bits per channel" (HUM Ch 46.2.1 DWL, p 3057). The encoding 111b is "setting prohibited" and not exposed.
Definition at line 151 of file ra8_ssie.h.
| enum ra8_ssie_dir_t : uint8_t |
Communication direction selector for ra8_ssie_start.
| Enumerator | |
|---|---|
| k_ra8_ssie_dir_rx | Reception only (REN). |
| k_ra8_ssie_dir_tx | Transmission only (TEN). |
| k_ra8_ssie_dir_tx_rx | Full duplex (TEN | REN). |
Definition at line 209 of file ra8_ssie.h.
| enum ra8_ssie_event_t : uint8_t |
Decoded SSIE callback event bit-flags.
Event bits delivered to the registered callback via ra8_ssie_dispatch. Multiple bits may be set on a single dispatch. Maps to SSISR / SSIFSR flags via internal_decode_event in ra8_ssie.c.
Definition at line 225 of file ra8_ssie.h.
| enum ra8_ssie_format_t : uint8_t |
Audio frame format (drives SSIOFR.OMOD[1:0] and SSICR.FRM).
The omod value goes straight to SSIOFR.OMOD[1:0] (HUM Ch 46.2.7 "OMOD" bits, p 3091). The driver maps the format_t enum to the exact OMOD encoding from the chapter table:
| Enum | OMOD | FRM | Words/frame |
|---|---|---|---|
| k_ra8_ssie_format_i2s | 00b | 00b | 2 (L,R) |
| k_ra8_ssie_format_left_just | 00b | 00b | 2, SDTA=0 |
| k_ra8_ssie_format_right_just | 00b | 00b | 2, PDTA=1 |
| k_ra8_ssie_format_monaural | 10b | 00b | 1 |
| k_ra8_ssie_format_tdm_4 | 01b | 01b | 4 |
| k_ra8_ssie_format_tdm_6 | 01b | 10b | 6 |
| k_ra8_ssie_format_tdm_8 | 01b | 11b | 8 |
| Enumerator | |
|---|---|
| k_ra8_ssie_format_i2s | I2S, 2 channels per frame. |
| k_ra8_ssie_format_left_just | Left-justified, 2 channels. |
| k_ra8_ssie_format_right_just | Right-justified, 2 channels. |
| k_ra8_ssie_format_monaural | Monaural single-channel. |
| k_ra8_ssie_format_tdm_4 | TDM 4-slot. |
| k_ra8_ssie_format_tdm_6 | TDM 6-slot. |
| k_ra8_ssie_format_tdm_8 | TDM 8-slot. |
| k_ra8_ssie_format_tdm | Backwards alias kept for unit tests that index OMOD directly. Same encoding as k_ra8_ssie_format_tdm_4 (OMOD=01b, FRM=01b). |
Definition at line 127 of file ra8_ssie.h.
| enum ra8_ssie_role_t : uint8_t |
Controller / peripheral selection (drives SSICR.MST).
See HUM Ch 46.2.1 "MST" bit, p 3057.
| Enumerator | |
|---|---|
| k_ra8_ssie_role_peripheral | Bit clock + LR clock are inputs. |
| k_ra8_ssie_role_controller | Bit clock + LR clock are outputs. |
Definition at line 103 of file ra8_ssie.h.
| enum ra8_ssie_system_word_t : uint8_t |
System word length (drives SSICR.SWL[2:0]).
"Number of bits per channel" including padding (HUM Ch 46.2.1 SWL, p 3057). Must be at least the data word length.
Definition at line 169 of file ra8_ssie.h.
|
nodiscard |
Attach DMAC channels to the SSIE TX and/or RX FIFOs.
Programmes a TX DMAC channel (source = caller buffer, dest = SSIFTDR, no dest increment) and an RX DMAC channel (source = SSIFRDR, dest = caller buffer, no source increment) per HUM Ch 46.4.1 "Operation in DMAC Transfer" p 3104. After this call the SSIE TIE/RIE bits are still required to advance the DMA (the FIFO watermark is the request signal).
Setting a channel ID >= 8 (the DMAC has only 8 channels) skips that direction.
| [in] | channel | Channel index (0 = SSIE0, 1 = SSIE1). |
| [in] | dma | Non-NULL DMA configuration. |
| k_ra8_ok | DMA channels programmed. |
| k_ra8_err_null_ptr | dma was NULL. |
| k_ra8_err_invalid_arg | Channel out of range or DMA samples = 0. |
Definition at line 224 of file ra8_ssie_stream.c.
References g_ssie_runtime, internal_attach_dma_dirs(), internal_validate_dma_cfg(), k_ra8_err_invalid_arg, k_ra8_ok, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, RA8_RETURN_ON_ERROR, and s_tag.
|
nodiscard |
Pair an SSIE channel's TX + RX FIFOs to DMAC channels.
Thin variant of ra8_ssie_attach_dma that takes only the DMAC channel ids (no buffers / counts). Useful for callers who programme the DMAC descriptors themselves and only need the SSIE side to record which DMAC channels to free during ra8_ssie_detach_dma. Pass >= 8 to skip a direction.
| [in] | channel | SSIE channel index 0..1. |
| [in] | tx_dma_channel | DMAC channel id pumping TX (or >= 8). |
| [in] | rx_dma_channel | DMAC channel id pumping RX (or >= 8). |
| k_ra8_ok | Channel binding recorded. |
| k_ra8_err_invalid_arg | Channel out of range OR both DMA ids >= 8. |
Definition at line 264 of file ra8_ssie_stream.c.
References ra8_ssie_runtime_t::dma_attached, g_ssie_runtime, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_channel_count, k_ra8_ssie_dma_ch_unused, k_ra8_ssie_dma_max_ch, ra8_ssie_runtime_t::rx_dma_channel, and ra8_ssie_runtime_t::tx_dma_channel.
|
nodiscard |
Attach a shared event callback for both SSIE channels.
| [in] | fn | Callback invoked from ra8_ssie_dispatch. |
| [in] | ctx | Opaque context forwarded to the callback. |
| k_ra8_ok | Always succeeds (handler may be nullptr to detach). |
Definition at line 915 of file ra8_ssie.c.
References k_ra8_ok, s_ssie_ctx, and s_ssie_fn.
|
nodiscard |
Clear sticky error flags in SSISR.
Performs a write-1-to-clear on the bits in mask that overlap SSISR.{ROIRQ, RUIRQ, TOIRQ, TUIRQ}. Other bits are ignored. See HUM Ch 46.2.2, p 3066-3071 for the per-flag clear protocol.
| [in] | channel | Channel index. |
| [in] | mask | Bitmask of flags to clear (use k_ra8_ssie_mask_err_all to clear them all). |
| k_ra8_ok | Mask written. |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 884 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_err_all, priv_ra8_ssie_internal_regs(), and r_ssie_regs_t::SSISR.
|
nodiscard |
Tear down an SSIE channel and gate its clock.
| [in] | channel | Channel index. |
Definition at line 638 of file ra8_ssie.c.
References g_ssie_runtime, k_ra8_err_invalid_arg, k_ra8_ssie_mask_aucke, k_ra8_ssie_mask_ren_ten, priv_ra8_ssie_internal_regs(), ra8_mstp_disable(), ra8_ssie_detach_dma(), s_ssie_mstp_table, r_ssie_regs_t::SSICR, and r_ssie_regs_t::SSIFCR.
Referenced by main().
|
nodiscard |
Tear down DMAC channels attached to the SSIE FIFOs.
| [in] | channel | Channel index. |
| k_ra8_ok | All attached DMA channels stopped. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 246 of file ra8_ssie_stream.c.
References ra8_ssie_runtime_t::dma_attached, g_ssie_runtime, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_channel_count, k_ra8_ssie_dma_ch_unused, k_ra8_ssie_dma_max_ch, ra8_dmac_stop(), ra8_ssie_runtime_t::rx_dma_channel, and ra8_ssie_runtime_t::tx_dma_channel.
Referenced by ra8_ssie_deinit().
| void ra8_ssie_dispatch | ( | uint8_t | channel | ) |
ISR helper: fire the registered event handler.
Snapshots SSISR for channel (HUM Ch 51 "Serial Sound Interface Enhanced (SSIE)", p 2731), then invokes the attached event handler. Out-of-range channel indices and unattached slots are silently dropped so spurious IRQs are harmless.
| [in] | channel | Channel that fired. |
Definition at line 923 of file ra8_ssie.c.
References internal_decode_event(), priv_ra8_ssie_internal_regs(), s_ssie_ctx, s_ssie_fn, r_ssie_regs_t::SSIFSR, and r_ssie_regs_t::SSISR.
|
nodiscard |
Gate the channel's MSTP bit (preserve register state).
| [in] | channel | Channel index. |
Definition at line 949 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ssie_channel_count, ra8_mstp_disable(), and s_ssie_mstp_table.
|
nodiscard |
Re-ungate the channel's MSTP bit.
| [in] | channel | Channel index. |
Definition at line 957 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ssie_channel_count, ra8_mstp_enable(), and s_ssie_mstp_table.
|
nodiscard |
Snapshot SSISR + SSIFSR into a status struct.
| [in] | channel | Channel index. |
| [out] | out | Non-NULL status struct. |
| k_ra8_ok | Snapshot taken. |
| k_ra8_err_null_ptr | out was nullptr. |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 860 of file ra8_ssie.c.
References ra8_ssie_status_t::error, ra8_ssie_status_t::events, ra8_ssie_status_t::idle, internal_decode_event(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_err_all, k_ra8_ssie_mask_iirq, k_ra8_ssie_mask_rdc, k_ra8_ssie_mask_rdf, k_ra8_ssie_mask_tdc, k_ra8_ssie_mask_tde, k_ra8_ssie_shift_rdc, k_ra8_ssie_shift_tdc, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, ra8_ssie_status_t::rx_count, ra8_ssie_status_t::rx_full, s_tag, r_ssie_regs_t::SSIFSR, ra8_ssie_status_t::ssifsr, r_ssie_regs_t::SSISR, ra8_ssie_status_t::ssisr, ra8_ssie_status_t::tx_count, and ra8_ssie_status_t::tx_empty.
|
nodiscard |
Initialise an SSIE channel for I2S / TDM / monaural transfer.
Algorithm (HUM Ch 46.6.1 "Initial Settings", p 3097):
| [in] | channel | Channel index (0 = SSIE0, 1 = SSIE1). |
| [in] | cfg | Non-NULL configuration descriptor. |
| k_ra8_ok | Channel initialized. |
| k_ra8_err_null_ptr | cfg was nullptr. |
| k_ra8_err_invalid_arg | channel out of range. |
| k_ra8_err_hw_timeout | SSIRST did not self-clear within k_ra8_ssie_reset_poll_max reads. |
Definition at line 610 of file ra8_ssie.c.
References g_ssie_runtime, internal_apply_init_regs(), internal_ssie_power_up(), internal_validate_init_cfg(), k_ra8_err_invalid_arg, k_ra8_ok, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, ra8_log_info_val, RA8_RETURN_ON_ERROR, and s_tag.
Referenced by internal_ssie_loop_run(), and ra8_board_audio_init().
|
nodiscard |
Enable or disable mute on the next frame boundary.
Toggles SSICR.MUEN per HUM Ch 46.2.1 (p 3056). Data is still written to the TX line but its bits are forced to zero.
| [in] | channel | Channel index. |
| [in] | enable | true to mute, false to un-mute. |
| k_ra8_ok | MUEN updated. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 740 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_muen, priv_ra8_ssie_internal_regs(), and r_ssie_regs_t::SSICR.
|
nodiscard |
Empty the RX FIFO into a host buffer until either runs out.
| [in] | channel | Channel index. |
| [out] | buffer | Destination samples. |
| [in] | samples | Destination-buffer length in samples. |
| [out] | out_read | Receives the number of samples consumed. |
| k_ra8_ok | At least zero samples consumed. |
| k_ra8_err_null_ptr | buffer or out_read was NULL. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 829 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_rdc, k_ra8_ssie_mask_tde_clear, k_ra8_ssie_shift_rdc, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, s_tag, r_ssie_regs_t::SSIFRDR, and r_ssie_regs_t::SSIFSR.
|
nodiscard |
Pop one 32-bit sample from the receive FIFO.
| [in] | channel | Channel index. |
| [out] | out | Receives the sample bits. |
| k_ra8_ok | Sample read. |
| k_ra8_err_null_ptr | out was nullptr. |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 782 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, s_tag, and r_ssie_regs_t::SSIFRDR.
|
nodiscard |
Block-mode isochronous receive.
Drains up to max_samples.
Loops until either the destination buffer is full or the SSIE RX FIFO drains. Returns the actual sample count via out_got.
| [in] | channel | Channel index 0..1. |
| [out] | buffer | Destination buffer. |
| [in] | max_samples | Capacity of buffer in 32-bit samples. |
| [out] | out_got | Receives the number of samples consumed. |
| k_ra8_ok | Up to max_samples words consumed. |
| k_ra8_err_null_ptr | buffer or out_got was NULL. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 313 of file ra8_ssie_stream.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_rdc, k_ra8_ssie_mask_tde_clear, k_ra8_ssie_shift_rdc, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, s_tag, r_ssie_regs_t::SSIFRDR, and r_ssie_regs_t::SSIFSR.
|
nodiscard |
Block-mode isochronous send.
Drains the buffer fully.
Loops until every requested sample has been pushed into SSIFTDR. Internally relies on the FIFO depth read-back to throttle, so the routine is bounded by samples * k_ra8_ssie_fifo_depth SSIFSR reads worst-case (HUM Ch 46.2.4 p 3083). The non-DMA path used by the iso pacing layer.
| [in] | channel | Channel index 0..1. |
| [in] | buffer | Source samples. |
| [in] | samples | Number of 32-bit samples to send. |
| k_ra8_ok | All samples queued. |
| k_ra8_err_null_ptr | buffer was NULL. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 285 of file ra8_ssie_stream.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_fifo_depth, k_ra8_ssie_mask_rdf_clear, k_ra8_ssie_mask_tdc, k_ra8_ssie_shift_tdc, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, s_tag, r_ssie_regs_t::SSIFSR, and r_ssie_regs_t::SSIFTDR.
|
nodiscard |
Programme SSITDMR / SSIRDMR FIFO thresholds in one call.
Convenience wrapper that drives ra8_ssie_set_thresholds with the exact pair of TX / RX FIFO watermarks the audio pipeline wants. The SSIE only carries SSISCR.TDES / SSISCR.RDFS (HUM Ch 46.2.8 p 3094) – the names SSITDMR / SSIRDMR are aliases the application layer uses for clarity.
| [in] | channel | Channel index (0 = SSIE0, 1 = SSIE1). |
| [in] | tx_threshold | TDES[4:0]: TX-empty IRQ when TDC <= value. |
| [in] | rx_threshold | RDFS[4:0]: RX-full IRQ when RDC > value. |
| k_ra8_ok | Thresholds programmed. |
| k_ra8_err_invalid_arg | Channel out of range or threshold > 0x1F. |
Definition at line 941 of file ra8_ssie.c.
References ra8_ssie_set_thresholds().
|
nodiscard |
Update the IRQ enable mask without rewriting SSICR fully.
Performs read-modify-write on SSICR.{IIEN, ROIEN, RUIEN, TOIEN, TUIEN}. Pass k_ra8_ssie_mask_irq_all in mask to enable every IRQ source.
| [in] | channel | Channel index. |
| [in] | mask | Mask of bits to set / clear. |
| [in] | enable | true to set bits, false to clear. |
| k_ra8_ok | SSICR updated. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 897 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_irq_all, priv_ra8_ssie_internal_regs(), and r_ssie_regs_t::SSICR.
|
nodiscard |
Update the FIFO trigger watermarks at runtime.
| [in] | channel | Channel index. |
| [in] | tx_threshold | TDES[4:0]: TX-empty IRQ when TDC <= value. |
| [in] | rx_threshold | RDFS[4:0]: RX-full IRQ when RDC > value. |
| k_ra8_ok | SSISCR updated. |
| k_ra8_err_invalid_arg | Channel out of range or threshold > 0x1F. |
Definition at line 757 of file ra8_ssie.c.
References internal_build_ssiscr(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_thresh_max, priv_ra8_ssie_internal_regs(), and r_ssie_regs_t::SSISCR.
Referenced by ra8_ssie_set_fifo_threshold().
|
nodiscard |
Enable transmission, reception, or full duplex.
Implements HUM Ch 46.6.2 "Transmission" (p 3098) and 46.6.3 "Reception" (p 3099). Resets both FIFOs (TFRST/RFRST), enables the matching interrupt mask in SSIFCR (TIE/RIE), enables the matching error masks in SSICR (TUIEN/ROIEN), then sets TEN/REN.
| [in] | channel | Channel index. |
| [in] | dir | k_ra8_ssie_dir_tx, ..._rx or ..._tx_rx. |
| k_ra8_ok | Direction enabled. |
| k_ra8_err_invalid_arg | Channel or direction out of range. |
| k_ra8_err_busy | SSIE is not idle and direction would change (must call ra8_ssie_stop first). |
Definition at line 656 of file ra8_ssie.c.
References internal_apply_dir_irq_bits(), internal_pulse_fifo_reset(), k_ra8_err_busy, k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_dir_rx, k_ra8_ssie_dir_tx, k_ra8_ssie_dir_tx_rx, k_ra8_ssie_mask_iirq, k_ra8_ssie_mask_ren_ten, priv_ra8_ssie_internal_regs(), RA8_RETURN_ON_ERROR, s_tag, r_ssie_regs_t::SSICR, r_ssie_regs_t::SSIFCR, and r_ssie_regs_t::SSISR.
Referenced by internal_ssie_loop_run().
|
nodiscard |
Force the channel back into a known idle state.
Issues a software reset (SSIFCR.SSIRST), waits for it to self-clear, then clears every error flag in SSISR. Used by the IRQ dispatcher when a TUIRQ/ROIRQ pair is observed.
| [in] | channel | Channel index. |
| k_ra8_ok | Channel reset and flags cleared. |
| k_ra8_err_invalid_arg | Channel out of range. |
| k_ra8_err_hw_timeout | SSIRST did not self-clear in bound. |
Definition at line 719 of file ra8_ssie.c.
References internal_wait_ssirst_clear(), k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_err_all, k_ra8_ssie_mask_ssirst, priv_ra8_ssie_internal_regs(), RA8_RETURN_ON_ERROR, s_tag, r_ssie_regs_t::SSIFCR, and r_ssie_regs_t::SSISR.
|
nodiscard |
Disable transmission and reception.
Implements HUM Ch 46.6.4 "Idle Operation" p 3100. Clears REN/TEN/error-IEN, leaves IIEN set so the caller is notified when SSIE finishes the in-flight frame.
| [in] | channel | Channel index. |
| k_ra8_ok | Stop requested; IIEN now armed. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 697 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_mask_err_ien, k_ra8_ssie_mask_iien, k_ra8_ssie_mask_ren_ten, k_ra8_ssie_mask_rie_tie, priv_ra8_ssie_internal_regs(), r_ssie_regs_t::SSICR, and r_ssie_regs_t::SSIFCR.
Referenced by main().
|
nodiscard |
Drain a host buffer into the TX FIFO until either runs out.
Loops while samples > 0 and SSIFSR.TDC < depth. Returns the number of samples actually written via out_written.
| [in] | channel | Channel index. |
| [in] | buffer | Source samples. |
| [in] | samples | Source-buffer length in samples. |
| [out] | out_written | Receives the number of samples written. |
| k_ra8_ok | At least zero samples written. |
| k_ra8_err_null_ptr | buffer or out_written was NULL. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 794 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, k_ra8_ssie_fifo_depth, k_ra8_ssie_mask_rdf_clear, k_ra8_ssie_mask_tdc, k_ra8_ssie_shift_tdc, priv_ra8_ssie_internal_regs(), RA8_CHECK_NULL_PTR, s_tag, r_ssie_regs_t::SSIFSR, and r_ssie_regs_t::SSIFTDR.
Referenced by ra8_board_audio_play_sample_block().
|
nodiscard |
Push one 32-bit sample into the transmit FIFO.
Performs a single 32-bit write to SSIFTDR (HUM Ch 46.2.5 p 3088). Samples wider than the configured DWL are truncated by the FIFO shift logic. Data alignment within the 32-bit word is governed by SSICR.PDTA / SSICR.SDTA.
| [in] | channel | Channel index (0 = SSIE0, 1 = SSIE1). |
| [in] | sample | Sample bits. |
| k_ra8_ok | Sample queued. |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 771 of file ra8_ssie.c.
References k_ra8_err_invalid_arg, k_ra8_ok, priv_ra8_ssie_internal_regs(), and r_ssie_regs_t::SSIFTDR.
Referenced by internal_ssie_loop_run().