Module stm32_hal2::sai

source ·
Expand description

Serial audio interface (SAI) support, for digital audio input and output. Used for I2S, PCM/DSP, TDM, AC’97 etc. See L443 Reference Manual, section 41, or H743 RM, section 51.

Structs§

  • Represents the Serial Audio Interface (SAI) peripheral, used for digital audio input and output.
  • Configuration for the SAI peripheral. Mainly affects the ACR and BCR registers. Used for either channel. For details, see documentation of individual structs and fields. You may be forced into certain settings based on the device used.

Enums§

  • Select if signals generated by SAI change on SCK rising, or falling edge. Sets xCR1 register, CKSTR field.
  • Select the data size to use. xCR1 register, DS field.
  • FIFO threshold. Affects xCR2 reg, FTH field. Affects when SAI interrupts, and DMA transfers occur.
  • Set which bit is transmitted first: Least significant, or Most significant. You may have to choose the one used by your SAI device. Sets xCR1 register, LSBFIRST field.
  • Frame synchronization offset. Depending on the audio protocol targeted in the application, the Frame synchronization signal can be asserted when transmitting the last bit or the first bit of the audio frame (this is the case in I2S standard protocol and in MSB-justified protocol, respectively). Sets FRCR register, FSOFF field.
  • This bit is set and cleared by software. It is used to configure the level of the start of frame on the FS signal. It is meaningless and is not used in AC’97 or SPDIF audio block configuration. This bit must be configured when the audio block is disabled. Sets FRCR register, FSPOL field.
  • Set Where the signal is in the frame. Sets FRCR register, FSDEF field.
  • Select wheather the master clock is generated. xDR1 register, NOMCK field on H7. on other variants such as WB, affects the MCKEN and NODIV fields (?).
  • Select Stereo or Mono mode. Sets xCR1 register, MONO field.
  • Select the number of connected PDM mics. It is possible to select between 2,4,6 or 8 microphones. For example, if the application is using 3 microphones, the user has to select 4. Sets PDMCR register, MICNBR field.
  • Oversampling ratio for master clock. You may have to choose the one used by your SAI device. Sets xCR1 register, OSR field.
  • Select the audio protocol to use. xCR1 register, PRTCFG field.
  • The type of SAI interrupt to configure. Reference Section 41.5 of the L4 RM. Enabled in xIM register, yIE fields. See H743 RM, section 51.5: SAI interrupts.
  • Select Master or Slave mode. Sets xCR1 register, MODE field. The audio subblock can be a transmitter or receiver, in master or slave mode. The master mode means the SCK_x bit clock and the frame synchronization signal are generated from the SAI, whereas in slave mode, they come from another external or internal master. There is a particular case for which the FS signal direction is not directly linked to the master or slave mode definition. In AC’97 protocol, it will be an SAI output even if the SAI (link controller) is set-up to consume the SCK clock (and so to be in Slave mode).
  • Select the slot size to use. xSLOTR register, SLOTSZ field.
  • Synchronization inputs. Sets xGCR register, SYNCIn field. Must be set when SAI is diabled. Not block specific. Syncs this SAI peripheral with the one specified here, if sync_mode is configured as SyncExternal. The block synchronized with is controlled by that SAI’s sync_out setting.
  • Specify wheather sub-clocks A and B are synchronized. Sets xCR1 register, SYNCEN field.
  • Synchronization outputs. Sets xGCR register, SYNCOUT field. Must be set when SAI is diabled. Not block specific.