<alp/i2s.h> — I²S / SAI
Raw I²S / SAI bus access. For higher-level audio capture and playback, use <alp/audio.h>.
Header
#include <alp/i2s.h>
Quick example
alp_i2s_t *i2s = alp_i2s_open(&(alp_i2s_config_t){
.bus_id = ALP_E1M_I2S0,
.sample_rate_hz = 44100,
.word_bits = 16,
.channels = 2,
.format = ALP_I2S_FMT_I2S,
.direction = ALP_I2S_DIR_TX,
.block_frames = 256,
});
alp_i2s_start(i2s);
alp_i2s_write(i2s, pcm_buffer, pcm_bytes, /* timeout_ms */ 100);
alp_i2s_stop(i2s);
alp_i2s_close(i2s);
Default-initialiser macro
alp_i2s_config_t cfg = ALP_I2S_CONFIG_DEFAULT(ALP_E1M_I2S0);
cfg.direction = ALP_I2S_DIR_TX;
ALP_I2S_CONFIG_DEFAULT(id) (v0.10) sets bus_id from id plus: sample_rate_hz = 48000, word_bits = 16, channels = 2 (stereo), format = ALP_I2S_FMT_I2S, direction = ALP_I2S_DIR_RX, block_frames = 256.
See the shared macro contract for the C++ compound-literal caveat that applies to every ALP_*_CONFIG_DEFAULT.
See also
<alp/audio.h>— high-level audio- Examples: i2s-tone
Questions about this page? Discuss in Community Forum