Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAI: audio pll, sai peripheral driver, and small rtic synthesizing sample #143

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Commits on Jun 26, 2024

  1. Update imxrt-iomuxc to 0.2.4

    SpinFast authored and mciantyre committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    5bfb251 View commit details
    Browse the repository at this point in the history
  2. Update imxrt-ral to 0.6

    SpinFast authored and mciantyre committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    386945c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0a93a4c View commit details
    Browse the repository at this point in the history
  4. Add pll4 clock module and sai clock modules

    Provides a pll4 reset function with all the options to set the
    div_select, num, denom values with asserts ensuring bounds are kept
    based on the data sheet. It would be nice to assert these at compile
    time if possible and could be a future improvement to ensure the pll
    options are valid.
    
    The sai clock gating, selection, and divisor settings are also added
    enabling the full clocking of a sai peripheral from the audio pll to the
    peripheral input clock.
    
    The board clocks for sai1 are setup to generate an appropriate clock for
    a 48KHz 16bit stereo i2s stream by default that a wolfson wm8960 codec
    can pick up for playback.
    SpinFast authored and mciantyre committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    d759d38 View commit details
    Browse the repository at this point in the history
  5. Adds a SAI driver to the tree

    SAI can be modeled like a UART in some regards where there are a Tx/Rx
    pair. Unlike a UART though SAI in iMXRT can have multiple data channels
    connected to the same peripheral. While each channel has its own fifo
    and pin they are still part of the same peripheral instance. Meaning the
    clock, status, FIFO watermark, and more are all the shared.
    
    This adds some complications. Use of the Tx and Rx together is also
    optional, its quite possible only Tx or Rx in use.
    
    So modeling this API requires some interesting use of generics, but in
    effect the Sai struct is a builder that enables building a Sai Tx/Rx
    optional pair given pins and builder like options.
    
    The goal in the end is to have static const generated register fields
    from perhaps a const fn friendly builder type (SaiConfig).
    
    From there a Tx/Rx pair provide functionality for writing
    frames of audio samples per channel, managing interrupt masks, checking
    status, and enabling/disabling the transmitter or receiver.
    
    In some instances the Tx/Rx pair are *synchronized* meaning between the
    pair one will drive the frame sync clock of the other.
    
    This leads to a small potential race at the moment if a Tx and Rx are
    setup as synchronized and the tx/rx is enabled/disabled independent of
    the other that I can see. I don't have a great way of solving this
    particular setup in a safe way at the moment.
    SpinFast authored and mciantyre committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    7aca2b9 View commit details
    Browse the repository at this point in the history
  6. SAI example with wolfson wm8960 codec

    Provides a sample application for playing back audio without DMA
    directly writing to the FIFO of the SAI peripheral, which should result
    in an I2S signaling to the WM8960 codec on the EVK boards. The codec
    should then output a nice square wave on one channel and a sine wave on
    the other.
    
    The example in this case uses a PIT timer to print the status and a SAI1
    interrupt noting a FIFO request to synthesize samples when needed.
    SpinFast authored and mciantyre committed Jun 26, 2024
    Configuration menu
    Copy the full SHA
    3fd5e9d View commit details
    Browse the repository at this point in the history

Commits on Jun 28, 2024

  1. Configuration menu
    Copy the full SHA
    8c555e8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0e4ce04 View commit details
    Browse the repository at this point in the history