PebbleOS v4.47.0-1075-g013613c8a
Loading...
Searching...
No Matches
STM32 SAI

DAI on a sub-block of an STM32 serial audio interface. More...

Data Structures

struct  pbl_audio_stm32_sai
 STM32 SAI sub-block. More...
 

Macros

#define PBL_AUDIO_STM32_SAI_DEFINE(sym, _name, _base, _common, _clk, _tx, _rx, _dir, _pinctrl, _ring, _ring_size)
 Define a SAI sub-block as a DAI.
 

Detailed Description

DAI on a sub-block of an STM32 serial audio interface.

For playback, the sub-block is the master of an I2S link: two 32-bit slots of 16-bit samples, a bit clock of 64 times the rate, and a master clock of 256 times the rate for the codec, divided from its kernel clock. A mono stream is sent on both slots.

For capture, sub-block A takes a pair of PDM microphones on its PDM interface, of a card of format pdm: the left one samples on the rising edge of the clock, the right one on the falling edge, and a mono stream takes the left one. The clock runs at 64 times the rate, 128 times at 8 kHz, and PDM to PCM decimates the stream to the rate in software, with a gain of 0 to 42 dB. The first 100 ms, while the microphones settle, are silence. The DMA controller fills a ring of raw samples, which must be in memory it reaches: the memory region of the sub-block, as the SRAM4 for the BDMA of SAI4, or else the heap.


Data Structure Documentation

◆ pbl_audio_stm32_sai

struct pbl_audio_stm32_sai

STM32 SAI sub-block.

Data Fields
uintptr_t base Registers of the sub-block.
struct pbl_clk clk Kernel clock.
uintptr_t common Common registers of the SAI.
struct pbl_audio_dai dai DAI.
const struct pbl_dma_chan * dma DMA channel.
const struct pbl_pinctrl * pinctrl Pins.
uintptr_t ring Memory for the raw capture ring, or 0 to take it from the heap.
size_t ring_size Size of ring, in bytes.
struct pbl_audio_stm32_sai_state * state Runtime state.

Macro Definition Documentation

◆ PBL_AUDIO_STM32_SAI_DEFINE

#define PBL_AUDIO_STM32_SAI_DEFINE (   sym,
  _name,
  _base,
  _common,
  _clk,
  _tx,
  _rx,
  _dir,
  _pinctrl,
  _ring,
  _ring_size 
)
Value:
static struct pbl_audio_stm32_sai_state sym##_sai_state; \
static const struct pbl_pinctrl sym##_sai_pins = PBL_PINCTRL(_pinctrl, nullptr, 0); \
PBL_DEVICE_INSTANCE(sym, struct pbl_audio_stm32_sai, struct pbl_audio_dai, dai) { \
.dai = PBL_AUDIO_DAI_INIT(sym, _name, nullptr, &pbl_audio_stm32_sai_ops, _dir), \
.base = (_base), .common = (_common), .clk = _clk, \
.dma = ((_dir) == PBL_AUDIO_PLAYBACK) ? (_tx) : (_rx), .pinctrl = &sym##_sai_pins, \
.ring = (_ring), .ring_size = (_ring_size), .state = &sym##_sai_state, \
}
STM32 SAI sub-block.
Definition stm32_sai.h:50
A digital audio interface of the SoC, streaming one direction.
Definition audio.h:355
#define PBL_AUDIO_DAI_INIT(sym, _name, _parent, _ops, _dir)
Initializer for a struct pbl_audio_dai.
Definition audio.h:409
#define PBL_AUDIO_DAI_STATE_DEFINE(sym)
Define the class state of a DAI.
Definition audio.h:396
@ PBL_AUDIO_PLAYBACK
From memory to the hardware.
Definition audio.h:90
Pin states of a peripheral, as used by a consumer.
Definition pinctrl.h:118
#define PBL_PINCTRL(_default, _sleep, _reg)
Initializer for a struct pbl_pinctrl.
Definition pinctrl.h:132

Define a SAI sub-block as a DAI.

Parameters
symSymbol of the DAI.
_nameDevice name.
_baseRegisters of the sub-block.
_commonCommon registers of the SAI.
_clkKernel clock, from PBL_CLK().
_txPlayback DMA channel, or NULL.
_rxCapture DMA channel, or NULL.
_dirDirection, one of pbl_audio_dir.
_pinctrlDefault state of the pins.
_ringMemory for the raw capture ring, or 0 to take it from the heap.
_ring_sizeSize of _ring, in bytes.