Skip to content

Commit

Permalink
Adds a SAI driver to the tree
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SpinFast authored and mciantyre committed Jun 26, 2024
1 parent d759d38 commit 7aca2b9
Show file tree
Hide file tree
Showing 2 changed files with 603 additions and 1 deletion.
Loading

0 comments on commit 7aca2b9

Please sign in to comment.