Skip to main content

Module i2s

Module i2s 

Source
Expand description

I²S audio bus driver.

Safe wrappers around the oveRTOS I²S API for DMA-based audio streaming with double-buffered (ping-pong) operation.

Mirrors the crate::uart, crate::spi, and crate::i2c modules: free functions over an opaque handle. Lifecycle (ove_i2s_init / ove_i2s_create) and callback registration (ove_i2s_set_rx_callback / ove_i2s_set_tx_callback) are left to direct calls against [crate::ffi] so the safe surface stays small and the unsafe boundary matches the sibling drivers.

§Example

use ove::ffi;
// Heap-mode lifecycle stays at the FFI level — same as UART/SPI/I²C.
let mut handle: ffi::ove_i2s_t = core::ptr::null_mut();
let cfg = ffi::ove_i2s_cfg { /* ... */ };
ove::error::Error::from_code(unsafe { ffi::ove_i2s_create(&mut handle, &cfg) })?;

ove::i2s::start(handle)?;

// In your RX callback (registered via raw FFI), pull the just-filled half:
if let Some(p) = ove::i2s::rx_buf(handle) {
    let n = ove::i2s::half_buf_size(handle);
    let samples = unsafe { core::slice::from_raw_parts(p, n) };
    process(samples);
}

Requires CONFIG_OVE_I2S.

Enums§

Direction
I²S stream direction — mirrors ove_i2s_dir_t.

Functions§

half_buf_size
Size of one half-buffer in bytes. Pair with rx_buf / tx_buf to construct a slice via core::slice::from_raw_parts{,_mut}.
pause
Pause I²S DMA streaming. Can be resumed with resume.
resume
Resume I²S DMA streaming after pause.
rx_buf
Pointer to the most recently completed RX half-buffer, or None if the handle is invalid / no buffer has been filled yet.
start
Start I²S DMA streaming.
stop
Stop I²S DMA streaming.
tx_buf
Pointer to the TX half-buffer safe to write, or None if the handle is invalid.