blob: e4b379cb9cde47ff191e5bf03d4020bbc76e4cfb [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>SAI Interface</title>
<title>CMSIS-Driver: SAI Interface</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="cmsis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="printComponentTabs.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 46px;">
<td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">CMSIS-Driver
&#160;<span id="projectnumber">Version 2.7.1</span>
</div>
<div id="projectbrief">Peripheral Interface for Middleware and Application Code</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<div id="CMSISnav" class="tabs1">
<ul class="tablist">
<script type="text/javascript">
<!--
writeComponentTabs.call(this);
//-->
</script>
</ul>
</div>
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
<li><a href="modules.html"><span>Reference</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__sai__interface__gr.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#groups">Content</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">SAI Interface</div> </div>
</div><!--header-->
<div class="contents">
<p>Driver API for Serial Audio Interface (Driver_SAI.h)
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Content</h2></td></tr>
<tr class="memitem:group__sai__execution__status"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__execution__status.html">Status Error Codes</a></td></tr>
<tr class="memdesc:group__sai__execution__status"><td class="mdescLeft">&#160;</td><td class="mdescRight">Negative values indicate errors (SAI has specific codes in addition to common <a class="el" href="group__execution__status.html">Status Error Codes</a>). <br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__SAI__events"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__SAI__events.html">SAI Events</a></td></tr>
<tr class="memdesc:group__SAI__events"><td class="mdescLeft">&#160;</td><td class="mdescRight">The SAI driver generates call back events that are notified via the function <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a>. <br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__sai__control"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__control.html">SAI Control Codes</a></td></tr>
<tr class="memdesc:group__sai__control"><td class="mdescLeft">&#160;</td><td class="mdescRight">Many parameters of the SAI driver are configured using the <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> function. <br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:structARM__DRIVER__SAI"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a></td></tr>
<tr class="memdesc:structARM__DRIVER__SAI"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access structure of the SAI Driver. <a href="group__sai__interface__gr.html#structARM__DRIVER__SAI">More...</a><br/></td></tr>
<tr class="separator:structARM__DRIVER__SAI"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:structARM__SAI__CAPABILITIES"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a></td></tr>
<tr class="memdesc:structARM__SAI__CAPABILITIES"><td class="mdescLeft">&#160;</td><td class="mdescRight">SAI Driver Capabilities. <a href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">More...</a><br/></td></tr>
<tr class="separator:structARM__SAI__CAPABILITIES"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:structARM__SAI__STATUS"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a></td></tr>
<tr class="memdesc:structARM__SAI__STATUS"><td class="mdescLeft">&#160;</td><td class="mdescRight">SAI Status. <a href="group__sai__interface__gr.html#structARM__SAI__STATUS">More...</a><br/></td></tr>
<tr class="separator:structARM__SAI__STATUS"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gad8ca8e2459e540928f6315b3df6da0ee"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#gad8ca8e2459e540928f6315b3df6da0ee">ARM_SAI_SignalEvent_t</a> )(uint32_t event)</td></tr>
<tr class="memdesc:gad8ca8e2459e540928f6315b3df6da0ee"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> : Signal SAI Event. <a href="#gad8ca8e2459e540928f6315b3df6da0ee">More...</a><br/></td></tr>
<tr class="separator:gad8ca8e2459e540928f6315b3df6da0ee"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga786b1970a788a4dfc6156b42364e52f8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga786b1970a788a4dfc6156b42364e52f8">ARM_SAI_GetVersion</a> (void)</td></tr>
<tr class="memdesc:ga786b1970a788a4dfc6156b42364e52f8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get driver version. <a href="#ga786b1970a788a4dfc6156b42364e52f8">More...</a><br/></td></tr>
<tr class="separator:ga786b1970a788a4dfc6156b42364e52f8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac6c636757944eaf25aebf312a67665aa"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#gac6c636757944eaf25aebf312a67665aa">ARM_SAI_GetCapabilities</a> (void)</td></tr>
<tr class="memdesc:gac6c636757944eaf25aebf312a67665aa"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get driver capabilities. <a href="#gac6c636757944eaf25aebf312a67665aa">More...</a><br/></td></tr>
<tr class="separator:gac6c636757944eaf25aebf312a67665aa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga89622a02ca1e7affb1a01eefacb6f54c"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga89622a02ca1e7affb1a01eefacb6f54c">ARM_SAI_Initialize</a> (<a class="el" href="group__sai__interface__gr.html#gad8ca8e2459e540928f6315b3df6da0ee">ARM_SAI_SignalEvent_t</a> cb_event)</td></tr>
<tr class="memdesc:ga89622a02ca1e7affb1a01eefacb6f54c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize SAI Interface. <a href="#ga89622a02ca1e7affb1a01eefacb6f54c">More...</a><br/></td></tr>
<tr class="separator:ga89622a02ca1e7affb1a01eefacb6f54c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabdefafaba6f072cfd7ed6f8f132422b6"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#gabdefafaba6f072cfd7ed6f8f132422b6">ARM_SAI_Uninitialize</a> (void)</td></tr>
<tr class="memdesc:gabdefafaba6f072cfd7ed6f8f132422b6"><td class="mdescLeft">&#160;</td><td class="mdescRight">De-initialize SAI Interface. <a href="#gabdefafaba6f072cfd7ed6f8f132422b6">More...</a><br/></td></tr>
<tr class="separator:gabdefafaba6f072cfd7ed6f8f132422b6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacdec50a3dd5902de601caa7397c1dabc"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#gacdec50a3dd5902de601caa7397c1dabc">ARM_SAI_PowerControl</a> (<a class="el" href="group__common__drv__gr.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5">ARM_POWER_STATE</a> state)</td></tr>
<tr class="memdesc:gacdec50a3dd5902de601caa7397c1dabc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Control SAI Interface Power. <a href="#gacdec50a3dd5902de601caa7397c1dabc">More...</a><br/></td></tr>
<tr class="separator:gacdec50a3dd5902de601caa7397c1dabc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8bb6866c535adeb930bc4a847d476fcd"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a> (const void *data, uint32_t num)</td></tr>
<tr class="memdesc:ga8bb6866c535adeb930bc4a847d476fcd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start sending data to SAI transmitter. <a href="#ga8bb6866c535adeb930bc4a847d476fcd">More...</a><br/></td></tr>
<tr class="separator:ga8bb6866c535adeb930bc4a847d476fcd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2d55f506cef9d2849cbe418146086d98"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a> (void *data, uint32_t num)</td></tr>
<tr class="memdesc:ga2d55f506cef9d2849cbe418146086d98"><td class="mdescLeft">&#160;</td><td class="mdescRight">Start receiving data from SAI receiver. <a href="#ga2d55f506cef9d2849cbe418146086d98">More...</a><br/></td></tr>
<tr class="separator:ga2d55f506cef9d2849cbe418146086d98"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9805f9d32aee205f787e625a58e8898"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#gaa9805f9d32aee205f787e625a58e8898">ARM_SAI_GetTxCount</a> (void)</td></tr>
<tr class="memdesc:gaa9805f9d32aee205f787e625a58e8898"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get transmitted data count. <a href="#gaa9805f9d32aee205f787e625a58e8898">More...</a><br/></td></tr>
<tr class="separator:gaa9805f9d32aee205f787e625a58e8898"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2c571fcc8b9632c25a64043bc2b2baec"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga2c571fcc8b9632c25a64043bc2b2baec">ARM_SAI_GetRxCount</a> (void)</td></tr>
<tr class="memdesc:ga2c571fcc8b9632c25a64043bc2b2baec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get received data count. <a href="#ga2c571fcc8b9632c25a64043bc2b2baec">More...</a><br/></td></tr>
<tr class="separator:ga2c571fcc8b9632c25a64043bc2b2baec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga405a0769c33da6801055db0fb9b6c869"><td class="memItemLeft" align="right" valign="top">int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> (uint32_t control, uint32_t arg1, uint32_t arg2)</td></tr>
<tr class="memdesc:ga405a0769c33da6801055db0fb9b6c869"><td class="mdescLeft">&#160;</td><td class="mdescRight">Control SAI Interface. <a href="#ga405a0769c33da6801055db0fb9b6c869">More...</a><br/></td></tr>
<tr class="separator:ga405a0769c33da6801055db0fb9b6c869"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6a202b57697f0f7a9742e76b33d5eeec"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#ga6a202b57697f0f7a9742e76b33d5eeec">ARM_SAI_GetStatus</a> (void)</td></tr>
<tr class="memdesc:ga6a202b57697f0f7a9742e76b33d5eeec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get SAI status. <a href="#ga6a202b57697f0f7a9742e76b33d5eeec">More...</a><br/></td></tr>
<tr class="separator:ga6a202b57697f0f7a9742e76b33d5eeec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaedf3347cb25d6bf2faad1bbb35ad79f4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> (uint32_t event)</td></tr>
<tr class="memdesc:gaedf3347cb25d6bf2faad1bbb35ad79f4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Signal SAI Events. <a href="#gaedf3347cb25d6bf2faad1bbb35ad79f4">More...</a><br/></td></tr>
<tr class="separator:gaedf3347cb25d6bf2faad1bbb35ad79f4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>Driver API for Serial Audio Interface (Driver_SAI.h) </p>
<p>The <b>Serial Audio Interface</b> (SAI) implements a synchronous serial bus interface for connecting digital audio devices. It is by far the most common mechanism used to transfer two channels of audio data between devices within a system. <b>SAI</b> can transfer digital audio using various protocols:</p>
<ul>
<li><a class="el" href="group__sai__interface__gr.html#Driver_SAI_I2S">I2S</a></li>
<li><a class="el" href="group__sai__interface__gr.html#Driver_SAI_MSB">MSB Justified</a></li>
<li><a class="el" href="group__sai__interface__gr.html#Driver_SAI_LSB">LSB Justified</a></li>
<li><a class="el" href="group__sai__interface__gr.html#Driver_SAI_PCM">PCM</a></li>
<li><a class="el" href="group__sai__interface__gr.html#Driver_SAI_AC97">AC'97</a></li>
<li><a class="el" href="group__sai__interface__gr.html#Driver_SAI_User">User Defined Protocol</a></li>
</ul>
<p><b>Block Diagram</b></p>
<p>&#160;</p>
<div class="image">
<img src="SAI_Schematics.png" alt="SAI_Schematics.png"/>
<div class="caption">
Simplified SAI Schematic</div></div>
<p>&#160;</p>
<p><b>SAI API</b></p>
<p>The following header files define the Application Programming Interface (API) for the SAI interface:</p>
<ul>
<li><b>Driver_SAI.h</b> : Driver API for Serial Audio Interface</li>
</ul>
<p>The driver implementation is a typical part of the <a href="../../Pack/html/index.html" class="el" target="_blank">Device Family Pack (DFP)</a> that supports the peripherals of the microcontroller family.</p>
<p><b>Driver Functions</b></p>
<p>The driver functions are published in the access struct as explained in <a class="el" href="theoryOperation.html#DriverFunctions">Common Driver Functions</a></p>
<ul>
<li><a class="el" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a> : access struct for SAI driver functions</li>
</ul>
<h1><a class="anchor" id="Driver_SAI_I2S"></a>
I2S</h1>
<p><a href="https://en.wikipedia.org/wiki/I%C2%B2S" target="_blank">Integrated Interchip Sound</a> (<b>I2S</b>) is a serial bus interface that connects digital audio devices together. It was introduced by Philips (now <a href="http://www.nxp.com" target="_blank">NXP</a>) in the late 80's and last revised 1996. It uses pulse code modulation to exchange the audio data between the devices. The following timing diagram explains the operation:</p>
<div class="image">
<img src="driver_sai_i2s.png" alt="driver_sai_i2s.png"/>
</div>
<p>I2S separates the clock (<b>SCK</b>) from the serial data (<b>SD</b>), resulting in a lower jitter. A complete audio data frame consists of two slots, one for the left channel and one for the right. The slot size equals the data size. The word select (<b>WS</b>) line lets the device know whether the left channel (WS is low) or the right channel (WS is high) is currently being transmitted. WS has a 50% duty-cycle signal that has the same frequency as the sample frequency. It is an early signal, meaning that the WS line changes one clock cycle before the actual data (SD) is transmitted (left or right). The data on SD is always transmitted MSB first and can have a data size of 8 up to 32 bits.</p>
<p>In terms of the CMSIS-Driver for SAI, the I2S protocol can be described as follows:</p>
<ul>
<li>Data Size: 8..32 (MSB first)</li>
<li>Clock Polarity: Drive on falling edge, Capture on rising edge</li>
<li>Frame Length: 2 * Data Size = 2 * Slot Size</li>
<li>Frame Sync Width: Frame Length / 2</li>
<li>Frame Sync Polarity: Active Low</li>
<li>Frame Sync Early</li>
<li>Slot Count: 2 (L R)</li>
<li>Slot Size: Data Size</li>
<li>Slot Offset: 0</li>
</ul>
<h1><a class="anchor" id="Driver_SAI_MSB"></a>
MSB Justified</h1>
<p><b>MSB</b> <b>Justified</b> is much like <a class="el" href="group__sai__interface__gr.html#Driver_SAI_I2S">I2S</a>, with a few differences:</p>
<div class="image">
<img src="driver_sai_msb.png" alt="driver_sai_msb.png"/>
</div>
<p>Unlike I2S, in MSB Justified the word select (<b>WS</b>) signals the left channel when it is active high and the right channel, when it is active low. The signal changes when the first actual <b>SD</b> data is available. It might happen that a frame (left or right) is not fully filled with data. In this case, all data after the LSB is forced to zero.</p>
<p>In terms of the CMSIS-Driver for SAI, the MSB Justified protocol can be described as follows:</p>
<ul>
<li>Data Size: 8..32 (MSB first)</li>
<li>Clock Polarity: Drive on falling edge, Capture on rising edge</li>
<li>Frame Length: 2 * Slot Size</li>
<li>Frame Sync Width: Frame Length / 2</li>
<li>Frame Sync Polarity: Active High</li>
<li>Slot Count: 2 (L R)</li>
<li>Slot Size: Data Size or higher (16/32)</li>
<li>Slot Offset: 0 (Zero padding after Data: Slot Size - Data Size)</li>
</ul>
<h1><a class="anchor" id="Driver_SAI_LSB"></a>
LSB Justified</h1>
<p><b>LSB</b> <b>Justified</b> is much like <a class="el" href="group__sai__interface__gr.html#Driver_SAI_MSB">MSB Justified</a>, with the single difference that the padding 0's are sent before the first actual data (MSB on <b>SD</b>):</p>
<div class="image">
<img src="driver_sai_lsb.png" alt="driver_sai_lsb.png"/>
</div>
<p>In terms of the CMSIS-Driver for SAI, the LSB Justified protocol can be described as follows:</p>
<ul>
<li>Data Size: 8..32 (MSB first)</li>
<li>Clock Polarity: Drive on falling edge, Capture on rising edge</li>
<li>Frame Length: 2*Slot Size</li>
<li>Frame Sync Width: Frame Length / 2</li>
<li>Frame Sync Polarity: Active High</li>
<li>Slot Count: 2</li>
<li>Slot Size: Data Size or higher (16/32)</li>
<li>Slot Offset: Slot Size - Data Size (Zero padding before Data: Slot Size - Data Size)</li>
</ul>
<h1><a class="anchor" id="Driver_SAI_PCM"></a>
PCM</h1>
<p><a href="https://en.wikipedia.org/wiki/Pulse-code_modulation" target="_blank">Pulse Code Modulation</a> (<b>PCM</b>) differs to the previous protocols in a few ways:</p>
<div class="image">
<img src="driver_sai_pcm.png" alt="driver_sai_pcm.png"/>
</div>
<ul>
<li>Only one channel is transferred.</li>
<li>There are two types of synchronization modes available:<ul>
<li>In <b>short</b> <b>frame</b> sync mode, the falling edge of <b>Frame</b> <b>Sync</b> indicates the start of the serial data <b>SD</b>. <b>Frame</b> <b>Sync</b> is always one clock cycle long.</li>
<li>In <b>long</b> <b>frame</b> sync mode, the rising edge of <b>Frame</b> <b>Sync</b> indicates the start of the serial data <b>SD</b>. <b>Frame</b> <b>Sync</b> stays active high for 13 clock cycles.</li>
</ul>
</li>
</ul>
<p>In terms of the CMSIS-Driver for SAI, the PCM protocol can be described as follows:<br/>
<b>PCM</b> <b>Short</b> <b>Frame</b> </p>
<ul>
<li>Data Size: 8..32 (MSB first)</li>
<li>Clock Polarity: Drive on falling edge, Capture on rising edge</li>
<li>Frame Length: Slot Size</li>
<li>Frame Sync Width: 1</li>
<li>Frame Sync Polarity: Active High</li>
<li>Frame Sync Early</li>
<li>Slot Count: 1</li>
<li>Slot Size: Data Size or higher (16/32)</li>
<li>Slot Offset: 0</li>
</ul>
<p><b>PCM</b> <b>Long</b> <b>Frame</b> </p>
<ul>
<li>Data Size: 16..32 (MSB first)</li>
<li>Clock Polarity: Drive on falling edge, Capture on rising edge</li>
<li>Frame Length: Slot Size</li>
<li>Frame Sync Width: 13</li>
<li>Frame Sync Polarity: Active High</li>
<li>Slot Count: 1</li>
<li>Slot Size: Data Size or higher (32)</li>
<li>Slot Offset: 0</li>
</ul>
<h1><a class="anchor" id="Driver_SAI_AC97"></a>
AC'97</h1>
<p><a href="https://en.wikipedia.org/wiki/AC&apos;97" target="_blank">Audio Codec '97</a> was developed by <a href="http://www.intel.com" target="_blank">Intel</a>. It is composed of five wires: the clock (12.288 MHz), a sync signal, a reset signal, and two data wires: sdata_out (contains the AC97 output) and sdata_in (contains the CODEC output). For more information, consult the <a href="http://www-inst.eecs.berkeley.edu/~cs150/Documents/ac97_r23.pdf" target="_blank">standard documentation</a>.</p>
<h1><a class="anchor" id="Driver_SAI_User"></a>
User Defined Protocol</h1>
<p>Using the control structs of the CMSIS-Driver SAI, it is possible to create support for nearly all serial audio protocols that are available today.</p>
<div class="image">
<img src="driver_sai_user.png" alt="driver_sai_user.png"/>
</div>
<p>The following properties can be configured for a user protocol:</p>
<ul>
<li>Data Size in bits (8..32)</li>
<li>Data Bit Order: MSB first (default) or LSB first</li>
<li>Clock Polarity:<ul>
<li>Driver on falling edge, Capture on rising edge (default)</li>
<li>Driver on rising edge, Capture on falling edge</li>
</ul>
</li>
<li>Frame Length in bits</li>
<li>Frame Sync Width in bits (default=1)</li>
<li>Frame Sync Polarity: active high (default) or low</li>
<li>Frame Sync Early: Sync signal one bit before the first bit of frame</li>
<li>Slot Count: number of slots in frame (default=1)</li>
<li>Slot Size: equal to data size (default) or 16 or 32-bit</li>
<li>Slot Offset: offset of first data bit in slot (default=0)</li>
</ul>
<p>For more information, refer to <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> that explains the different configuration options in more detail. </p>
<hr/><h2 class="groupheader">Data Structure Documentation</h2>
<a name="structARM__DRIVER__SAI" id="structARM__DRIVER__SAI"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct ARM_DRIVER_SAI</td>
</tr>
</table>
</div><div class="memdoc">
<div class="textblock"><p>Access structure of the SAI Driver. </p>
<p>The functions of the SAI driver are accessed by function pointers exposed by this structure. Refer to <a class="el" href="theoryOperation.html#DriverFunctions">Common Driver Functions</a> for overview information.</p>
<p>Each instance of an SAI interface provides such an access structure. The instance is identified by a postfix number in the symbol name of the access structure, for example:</p>
<ul>
<li><b>Driver_SAI0</b> is the name of the access struct of the first instance (no. 0).</li>
<li><b>Driver_SAI1</b> is the name of the access struct of the second instance (no. 1).</li>
</ul>
<p>A middleware configuration setting allows connecting the middleware to a specific driver instance <b>Driver_SAI<em>n</em></b>. The default is <span class="XML-Token">0</span>, which connects a middleware to the first instance of a driver. </p>
</div><table class="memberdecls">
<tr><td colspan="2"><h3>Data Fields</h3></td></tr>
<tr class="memitem:a8834b281da48583845c044a81566c1b3"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a8834b281da48583845c044a81566c1b3">GetVersion</a> )(void)</td></tr>
<tr class="memdesc:a8834b281da48583845c044a81566c1b3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga786b1970a788a4dfc6156b42364e52f8">ARM_SAI_GetVersion</a> : Get driver version. <a href="#a8834b281da48583845c044a81566c1b3">More...</a><br/></td></tr>
<tr class="separator:a8834b281da48583845c044a81566c1b3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7e230744b9898cabf80ee6f2595569f6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a7e230744b9898cabf80ee6f2595569f6">GetCapabilities</a> )(void)</td></tr>
<tr class="memdesc:a7e230744b9898cabf80ee6f2595569f6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#gac6c636757944eaf25aebf312a67665aa">ARM_SAI_GetCapabilities</a> : Get driver capabilities. <a href="#a7e230744b9898cabf80ee6f2595569f6">More...</a><br/></td></tr>
<tr class="separator:a7e230744b9898cabf80ee6f2595569f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54a38e78d5fd7ca0d37174c81ec01731"><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a54a38e78d5fd7ca0d37174c81ec01731">Initialize</a> )(<a class="el" href="group__sai__interface__gr.html#gad8ca8e2459e540928f6315b3df6da0ee">ARM_SAI_SignalEvent_t</a> cb_event)</td></tr>
<tr class="memdesc:a54a38e78d5fd7ca0d37174c81ec01731"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga89622a02ca1e7affb1a01eefacb6f54c">ARM_SAI_Initialize</a> : Initialize SAI Interface. <a href="#a54a38e78d5fd7ca0d37174c81ec01731">More...</a><br/></td></tr>
<tr class="separator:a54a38e78d5fd7ca0d37174c81ec01731"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adcf20681a1402869ecb5c6447fada17b"><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#adcf20681a1402869ecb5c6447fada17b">Uninitialize</a> )(void)</td></tr>
<tr class="memdesc:adcf20681a1402869ecb5c6447fada17b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#gabdefafaba6f072cfd7ed6f8f132422b6">ARM_SAI_Uninitialize</a> : De-initialize SAI Interface. <a href="#adcf20681a1402869ecb5c6447fada17b">More...</a><br/></td></tr>
<tr class="separator:adcf20681a1402869ecb5c6447fada17b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aba8f1c8019af95ffe19c32403e3240ef"><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#aba8f1c8019af95ffe19c32403e3240ef">PowerControl</a> )(<a class="el" href="group__common__drv__gr.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5">ARM_POWER_STATE</a> state)</td></tr>
<tr class="memdesc:aba8f1c8019af95ffe19c32403e3240ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#gacdec50a3dd5902de601caa7397c1dabc">ARM_SAI_PowerControl</a> : Control SAI Interface Power. <a href="#aba8f1c8019af95ffe19c32403e3240ef">More...</a><br/></td></tr>
<tr class="separator:aba8f1c8019af95ffe19c32403e3240ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a44eedddf4428cf4b98883b6c27d31922"><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a44eedddf4428cf4b98883b6c27d31922">Send</a> )(const void *data, uint32_t num)</td></tr>
<tr class="memdesc:a44eedddf4428cf4b98883b6c27d31922"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a> : Start sending data to SAI Interface. <a href="#a44eedddf4428cf4b98883b6c27d31922">More...</a><br/></td></tr>
<tr class="separator:a44eedddf4428cf4b98883b6c27d31922"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adb9224a35fe16c92eb0dd103638e4cf3"><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#adb9224a35fe16c92eb0dd103638e4cf3">Receive</a> )(void *data, uint32_t num)</td></tr>
<tr class="memdesc:adb9224a35fe16c92eb0dd103638e4cf3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a> : Start receiving data from SAI Interface. <a href="#adb9224a35fe16c92eb0dd103638e4cf3">More...</a><br/></td></tr>
<tr class="separator:adb9224a35fe16c92eb0dd103638e4cf3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0b28b2c21016702f50c28655653099df"><td class="memItemLeft" align="right" valign="top">uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a0b28b2c21016702f50c28655653099df">GetTxCount</a> )(void)</td></tr>
<tr class="memdesc:a0b28b2c21016702f50c28655653099df"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#gaa9805f9d32aee205f787e625a58e8898">ARM_SAI_GetTxCount</a> : Get transmitted data count. <a href="#a0b28b2c21016702f50c28655653099df">More...</a><br/></td></tr>
<tr class="separator:a0b28b2c21016702f50c28655653099df"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a758c7822edf6ac18f82eb33c9dc09d71"><td class="memItemLeft" align="right" valign="top">uint32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a758c7822edf6ac18f82eb33c9dc09d71">GetRxCount</a> )(void)</td></tr>
<tr class="memdesc:a758c7822edf6ac18f82eb33c9dc09d71"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga2c571fcc8b9632c25a64043bc2b2baec">ARM_SAI_GetRxCount</a> : Get received data count. <a href="#a758c7822edf6ac18f82eb33c9dc09d71">More...</a><br/></td></tr>
<tr class="separator:a758c7822edf6ac18f82eb33c9dc09d71"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a80455fc2c7355b1850098710fd66a244"><td class="memItemLeft" align="right" valign="top">int32_t(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a80455fc2c7355b1850098710fd66a244">Control</a> )(uint32_t control, uint32_t arg1, uint32_t arg2)</td></tr>
<tr class="memdesc:a80455fc2c7355b1850098710fd66a244"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> : Control SAI Interface. <a href="#a80455fc2c7355b1850098710fd66a244">More...</a><br/></td></tr>
<tr class="separator:a80455fc2c7355b1850098710fd66a244"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a310d55d55bd7c6b0393d43bb994db708"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a>(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__sai__interface__gr.html#a310d55d55bd7c6b0393d43bb994db708">GetStatus</a> )(void)</td></tr>
<tr class="memdesc:a310d55d55bd7c6b0393d43bb994db708"><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to <a class="el" href="group__sai__interface__gr.html#ga6a202b57697f0f7a9742e76b33d5eeec">ARM_SAI_GetStatus</a> : Get SAI status. <a href="#a310d55d55bd7c6b0393d43bb994db708">More...</a><br/></td></tr>
<tr class="separator:a310d55d55bd7c6b0393d43bb994db708"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h4 class="groupheader">Field Documentation</h4>
<a class="anchor" id="a8834b281da48583845c044a81566c1b3"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a>(* GetVersion)(void)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga786b1970a788a4dfc6156b42364e52f8">ARM_SAI_GetVersion</a> : Get driver version. </p>
</div>
</div>
<a class="anchor" id="a7e230744b9898cabf80ee6f2595569f6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a>(* GetCapabilities)(void)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#gac6c636757944eaf25aebf312a67665aa">ARM_SAI_GetCapabilities</a> : Get driver capabilities. </p>
</div>
</div>
<a class="anchor" id="a54a38e78d5fd7ca0d37174c81ec01731"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* Initialize)(<a class="el" href="group__sai__interface__gr.html#gad8ca8e2459e540928f6315b3df6da0ee">ARM_SAI_SignalEvent_t</a> cb_event)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga89622a02ca1e7affb1a01eefacb6f54c">ARM_SAI_Initialize</a> : Initialize SAI Interface. </p>
</div>
</div>
<a class="anchor" id="adcf20681a1402869ecb5c6447fada17b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* Uninitialize)(void)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#gabdefafaba6f072cfd7ed6f8f132422b6">ARM_SAI_Uninitialize</a> : De-initialize SAI Interface. </p>
</div>
</div>
<a class="anchor" id="aba8f1c8019af95ffe19c32403e3240ef"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* PowerControl)(<a class="el" href="group__common__drv__gr.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5">ARM_POWER_STATE</a> state)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#gacdec50a3dd5902de601caa7397c1dabc">ARM_SAI_PowerControl</a> : Control SAI Interface Power. </p>
</div>
</div>
<a class="anchor" id="a44eedddf4428cf4b98883b6c27d31922"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* Send)(const void *data, uint32_t num)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a> : Start sending data to SAI Interface. </p>
</div>
</div>
<a class="anchor" id="adb9224a35fe16c92eb0dd103638e4cf3"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* Receive)(void *data, uint32_t num)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a> : Start receiving data from SAI Interface. </p>
</div>
</div>
<a class="anchor" id="a0b28b2c21016702f50c28655653099df"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t(* GetTxCount)(void)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#gaa9805f9d32aee205f787e625a58e8898">ARM_SAI_GetTxCount</a> : Get transmitted data count. </p>
</div>
</div>
<a class="anchor" id="a758c7822edf6ac18f82eb33c9dc09d71"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t(* GetRxCount)(void)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga2c571fcc8b9632c25a64043bc2b2baec">ARM_SAI_GetRxCount</a> : Get received data count. </p>
</div>
</div>
<a class="anchor" id="a80455fc2c7355b1850098710fd66a244"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t(* Control)(uint32_t control, uint32_t arg1, uint32_t arg2)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> : Control SAI Interface. </p>
</div>
</div>
<a class="anchor" id="a310d55d55bd7c6b0393d43bb994db708"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a>(* GetStatus)(void)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#ga6a202b57697f0f7a9742e76b33d5eeec">ARM_SAI_GetStatus</a> : Get SAI status. </p>
</div>
</div>
</div>
</div>
<a name="structARM__SAI__CAPABILITIES" id="structARM__SAI__CAPABILITIES"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct ARM_SAI_CAPABILITIES</td>
</tr>
</table>
</div><div class="memdoc">
<div class="textblock"><p>SAI Driver Capabilities. </p>
<p>An SAI driver can be implemented with different capabilities (for example protocol support). The data fields of this structure encode the capabilities implemented by this driver. If a certain hardware peripheral is not able to handle one of the protocols directly (not advertised using <a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES" title="SAI Driver Capabilities. ">ARM_SAI_CAPABILITIES</a>), then it might be possible to implement it using the <a class="el" href="group__sai__interface__gr.html#Driver_SAI_User">User Defined Protocol</a> (if supported).</p>
<p><b>Returned by:</b></p>
<ul>
<li><a class="el" href="group__sai__interface__gr.html#gac6c636757944eaf25aebf312a67665aa">ARM_SAI_GetCapabilities</a> </li>
</ul>
</div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a75ba2507ea29601a309393e794f4413d"></a>uint32_t</td>
<td class="fieldname">
asynchronous: 1</td>
<td class="fielddoc">
supports asynchronous Transmit/Receive </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a9fa4f850b8ce2be2c7ffa2e3ec70ae20"></a>uint32_t</td>
<td class="fieldname">
synchronous: 1</td>
<td class="fielddoc">
supports synchronous Transmit/Receive </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a808b1f9e0abc3fa67945899cfc9fccc1"></a>uint32_t</td>
<td class="fieldname">
protocol_user: 1</td>
<td class="fielddoc">
supports user defined Protocol </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a6fcb9d68c4999860ce162c0ef44c4c97"></a>uint32_t</td>
<td class="fieldname">
protocol_i2s: 1</td>
<td class="fielddoc">
supports I2S Protocol </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a5363ec1fc0042620cb8aeeee4f98691b"></a>uint32_t</td>
<td class="fieldname">
protocol_justified: 1</td>
<td class="fielddoc">
supports MSB/LSB justified Protocol </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a0b2c79bd96ecb47d801fc5389819314a"></a>uint32_t</td>
<td class="fieldname">
protocol_pcm: 1</td>
<td class="fielddoc">
supports PCM short/long frame Protocol </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a5255f8d78a18ace0a959f604f9c065dd"></a>uint32_t</td>
<td class="fieldname">
protocol_ac97: 1</td>
<td class="fielddoc">
supports AC'97 Protocol </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a8d92817d8662211abda2d747c52ff4a9"></a>uint32_t</td>
<td class="fieldname">
mono_mode: 1</td>
<td class="fielddoc">
supports Mono mode </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a77e4d8466d2bde30e6583b9ad8ba8c82"></a>uint32_t</td>
<td class="fieldname">
companding: 1</td>
<td class="fielddoc">
supports Companding </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a12554e2522a0c611e8a26c9e536554eb"></a>uint32_t</td>
<td class="fieldname">
mclk_pin: 1</td>
<td class="fielddoc">
supports MCLK (Master Clock) pin </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="acc06ba75f18af9862d171426abc3273e"></a>uint32_t</td>
<td class="fieldname">
event_frame_error: 1</td>
<td class="fielddoc">
supports Frame error event: <a class="el" href="group__SAI__events.html#ga6ffcf96fe404b48421a57fbd122b26bc">ARM_SAI_EVENT_FRAME_ERROR</a> </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aa43c4c21b173ada1b6b7568956f0d650"></a>uint32_t</td>
<td class="fieldname">
reserved: 21</td>
<td class="fielddoc">
Reserved (must be zero) </td></tr>
</table>
</div>
</div>
<a name="structARM__SAI__STATUS" id="structARM__SAI__STATUS"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct ARM_SAI_STATUS</td>
</tr>
</table>
</div><div class="memdoc">
<div class="textblock"><p>SAI Status. </p>
<p>Structure with information about the status of the SAI. The data fields encode busy flags and error flags.</p>
<p><b>Returned by:</b></p>
<ul>
<li><a class="el" href="group__sai__interface__gr.html#ga6a202b57697f0f7a9742e76b33d5eeec">ARM_SAI_GetStatus</a> </li>
</ul>
</div><table class="fieldtable">
<tr><th colspan="3">Data Fields</th></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a2c6d2b67fba3f3e084e96a6bc7fcac6b"></a>uint32_t</td>
<td class="fieldname">
tx_busy: 1</td>
<td class="fielddoc">
Transmitter busy flag. </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a9f5baee58ed41b382628a82a0b1cbcb4"></a>uint32_t</td>
<td class="fieldname">
rx_busy: 1</td>
<td class="fielddoc">
Receiver busy flag. </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a048f45e9d2257a21821f81d9edd17b72"></a>uint32_t</td>
<td class="fieldname">
tx_underflow: 1</td>
<td class="fielddoc">
Transmit data underflow detected (cleared on start of next send operation) </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="ac403aefd9bce8b0172e1996c0f3dd8aa"></a>uint32_t</td>
<td class="fieldname">
rx_overflow: 1</td>
<td class="fielddoc">
Receive data overflow detected (cleared on start of next receive operation) </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="a1b4f69a2caf19ef9fd75cf27ae3932f9"></a>uint32_t</td>
<td class="fieldname">
frame_error: 1</td>
<td class="fielddoc">
Sync Frame error detected (cleared on start of next send/receive operation) </td></tr>
<tr><td class="fieldtype">
<a class="anchor" id="aa43c4c21b173ada1b6b7568956f0d650"></a>uint32_t</td>
<td class="fieldname">
reserved: 27</td>
<td class="fielddoc">
</td></tr>
</table>
</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a class="anchor" id="gad8ca8e2459e540928f6315b3df6da0ee"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">ARM_SAI_SignalEvent_t</td>
</tr>
</table>
</div><div class="memdoc">
<p>Pointer to <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> : Signal SAI Event. </p>
<p>Provides the typedef for the callback function <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a>.</p>
<p><b>Parameter for:</b></p>
<ul>
<li><a class="el" href="group__sai__interface__gr.html#ga89622a02ca1e7affb1a01eefacb6f54c">ARM_SAI_Initialize</a> </li>
</ul>
</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga786b1970a788a4dfc6156b42364e52f8"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a> ARM_SAI_GetVersion </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get driver version. </p>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a></dd></dl>
<p>The function <b>ARM_SAI_GetVersion</b> returns version information of the driver implementation in <a class="el" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a></p>
<ul>
<li>API version is the version of the CMSIS-Driver specification used to implement this driver.</li>
<li>Driver version is source code version of the actual driver implementation.</li>
</ul>
<p><b>Example:</b> </p>
<div class="fragment"><div class="line"><span class="keyword">extern</span> <a class="code" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a> Driver_SAI0;</div>
<div class="line"><a class="code" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a> *drv_info;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> setup_sai (<span class="keywordtype">void</span>) {</div>
<div class="line"> <a class="code" href="group__common__drv__gr.html#structARM__DRIVER__VERSION">ARM_DRIVER_VERSION</a> version;</div>
<div class="line"> </div>
<div class="line"> drv_info = &amp;Driver_SAI0; </div>
<div class="line"> version = drv_info-&gt;<a class="code" href="group__sai__interface__gr.html#a8834b281da48583845c044a81566c1b3">GetVersion</a> ();</div>
<div class="line"> <span class="keywordflow">if</span> (version.<a class="code" href="group__common__drv__gr.html#ad180da20fbde1d3dafc074af87c19540">api</a> &lt; 0x10A) { <span class="comment">// requires at minimum API version 1.10 or higher</span></div>
<div class="line"> <span class="comment">// error handling</span></div>
<div class="line"> <span class="keywordflow">return</span>;</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="gac6c636757944eaf25aebf312a67665aa"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a> ARM_SAI_GetCapabilities </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get driver capabilities. </p>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a></dd></dl>
<p>The function <b>ARM_SAI_GetCapabilities</b> retrieves information about the capabilities in this driver implementation. The data fields of the struct <a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a> encode various capabilities, for example supported protocols, or if a hardware is capable to create signal events using the <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> callback function.</p>
<p><b>Example:</b> </p>
<div class="fragment"><div class="line"><span class="keyword">extern</span> <a class="code" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a> Driver_SAI0;</div>
<div class="line"><a class="code" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a> *drv_info;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> read_capabilities (<span class="keywordtype">void</span>) {</div>
<div class="line"> <a class="code" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a> drv_capabilities;</div>
<div class="line"> </div>
<div class="line"> drv_info = &amp;Driver_SAI0; </div>
<div class="line"> drv_capabilities = drv_info-&gt;<a class="code" href="group__sai__interface__gr.html#a7e230744b9898cabf80ee6f2595569f6">GetCapabilities</a> ();</div>
<div class="line"> <span class="comment">// interrogate capabilities</span></div>
<div class="line"> </div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ga89622a02ca1e7affb1a01eefacb6f54c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ARM_SAI_Initialize </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__sai__interface__gr.html#gad8ca8e2459e540928f6315b3df6da0ee">ARM_SAI_SignalEvent_t</a>&#160;</td>
<td class="paramname"><em>cb_event</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize SAI Interface. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">cb_event</td><td>Pointer to <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__execution__status.html">Status Error Codes</a></dd></dl>
<p>The function <b>ARM_SAI_Initialize</b> initializes the SAI interface. It is called when the middleware component starts operation.</p>
<p>The function performs the following operations:</p>
<ul>
<li>Initializes the required resources of the SAI interface.</li>
<li>Registers the <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> callback function.</li>
</ul>
<p>The parameter <em>cb_event</em> is a pointer to the <a class="el" href="group__sai__interface__gr.html#gaedf3347cb25d6bf2faad1bbb35ad79f4">ARM_SAI_SignalEvent</a> callback function; use a NULL pointer when no callback signals are required. </p>
</div>
</div>
<a class="anchor" id="gabdefafaba6f072cfd7ed6f8f132422b6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ARM_SAI_Uninitialize </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>De-initialize SAI Interface. </p>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__execution__status.html">Status Error Codes</a></dd></dl>
<p>The function <b>ARM_SAI_Uninitialize</b> de-initializes the resources of SAI interface.</p>
<p>It is called when the middleware component stops operation and releases the software resources used by the interface. </p>
</div>
</div>
<a class="anchor" id="gacdec50a3dd5902de601caa7397c1dabc"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ARM_SAI_PowerControl </td>
<td>(</td>
<td class="paramtype"><a class="el" href="group__common__drv__gr.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5">ARM_POWER_STATE</a>&#160;</td>
<td class="paramname"><em>state</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Control SAI Interface Power. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">state</td><td>Power state </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__execution__status.html">Status Error Codes</a></dd></dl>
<p>The function <b>ARM_SAI_PowerControl</b> allows you to control the power modes of the SAI interface.</p>
<p>The parameter <em>state</em> sets the operation and can have the following values:</p>
<ul>
<li><a class="el" href="Driver__Common_8h.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5abed52b77a9ce4775570e44a842b1295e">ARM_POWER_FULL</a> : set-up peripheral for data transfers, enable interrupts (NVIC) and optionally DMA. Can be called multiple times. If the peripheral is already in this mode the function performs no operation and returns with <a class="el" href="group__execution__status.html#ga85752c5de59e8adeb001e35ff5be6be7">ARM_DRIVER_OK</a>.</li>
<li><a class="el" href="Driver__Common_8h.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5a9ef9e57cbcc948d0e22314e73dc8c434">ARM_POWER_LOW</a> : may use power saving. Returns <a class="el" href="group__execution__status.html#ga2efa59e480d82697795439220e6884e4">ARM_DRIVER_ERROR_UNSUPPORTED</a> when not implemented.</li>
<li><a class="el" href="Driver__Common_8h.html#ga47d6d7c31f88f3b8ae4aaf9d8444afa5ab6f5becc85ebd51c3dd2524a95d2ca35">ARM_POWER_OFF</a> : terminates any pending data transfers, disables peripheral, disables related interrupts and DMA.</li>
</ul>
<p>Refer to <a class="el" href="theoryOperation.html#CallSequence">Function Call Sequence</a> for more information. </p>
</div>
</div>
<a class="anchor" id="ga8bb6866c535adeb930bc4a847d476fcd"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ARM_SAI_Send </td>
<td>(</td>
<td class="paramtype">const void *&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>num</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Start sending data to SAI transmitter. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">data</td><td>Pointer to buffer with data to send to SAI transmitter </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">num</td><td>Number of data items to send </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__execution__status.html">Status Error Codes</a></dd></dl>
<p>The function <b>ARM_SAI_Send</b> sends data to the SAI transmitter.</p>
<p>The function parameters specify the buffer with <em>data</em> and the number <em>num</em> of items to send. The item size is defined by the data type which depends on the configured number of data bits.</p>
<p>Data type is:</p>
<ul>
<li><em>uint8_t</em> when configured for <span class="XML-Token">8</span> data bits</li>
<li><em>uint16_t</em> when configured for <span class="XML-Token">9..16</span> data bits</li>
<li><em>uint32_t</em> when configured for <span class="XML-Token">17..32</span> data bits</li>
</ul>
<p>Transmitter is enabled by calling <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> with <a class="el" href="group__sai__controls.html#ga74d7850973c095bb8dbffa880b4af1bc">ARM_SAI_CONTROL_TX</a> as the control parameter and <span class="XML-Token">1</span> as an argument. This starts the transmit engine which, generates a clock and frame sync signal in master mode and transmits the data. In slave mode, clock and frame sync are generated by the external master. When mute is active, data is discarded and zero values are transmitted.</p>
<p>Calling the function <b>ARM_SAI_Send</b> only starts the send operation. The function is non-blocking and returns as soon as the driver has started the operation (the driver typically configures DMA or the interrupt system for continuous transfer). During the operation it is not allowed to call this function again. Also, the data buffer must stay allocated and the contents of unsent data must not be modified. When the send operation is completed (requested number of items have been sent), the event <a class="el" href="group__SAI__events.html#ga3dfa64375859f40d157c224187d2885e">ARM_SAI_EVENT_SEND_COMPLETE</a> is generated. Progress of the send operation can be monitored by reading the number of already sent items by calling the function <a class="el" href="group__sai__interface__gr.html#gaa9805f9d32aee205f787e625a58e8898">ARM_SAI_GetTxCount</a>.</p>
<p>The status of the transmitter can also be monitored by calling the function <a class="el" href="group__sai__interface__gr.html#ga6a202b57697f0f7a9742e76b33d5eeec">ARM_SAI_GetStatus</a> and checking the <em>tx_busy</em> flag, which indicates if a transmission is still in progress.</p>
<p>If the transmitter is enabled and data is to be sent but the send operation has not been started yet, then the event <a class="el" href="group__SAI__events.html#ga6a0be7aaf9d700e5259f741641bc37ca">ARM_SAI_EVENT_TX_UNDERFLOW</a> is generated.</p>
<p>If an invalid synchronization frame is detected in slave mode, then the event <a class="el" href="group__SAI__events.html#ga6ffcf96fe404b48421a57fbd122b26bc">ARM_SAI_EVENT_FRAME_ERROR</a> is generated (if supported and reported by <em>event_frame_error</em> in <a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a>).</p>
<p>The send operation can be aborted by calling the function <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> with the control parameter <a class="el" href="group__sai__controls.html#gab3ec8ef9e5e5a190bd2131ac8c99a240">ARM_SAI_ABORT_SEND</a>. </p>
</div>
</div>
<a class="anchor" id="ga2d55f506cef9d2849cbe418146086d98"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ARM_SAI_Receive </td>
<td>(</td>
<td class="paramtype">void *&#160;</td>
<td class="paramname"><em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>num</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Start receiving data from SAI receiver. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[out]</td><td class="paramname">data</td><td>Pointer to buffer for data to receive from SAI receiver </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">num</td><td>Number of data items to receive </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><a class="el" href="group__execution__status.html">Status Error Codes</a></dd></dl>
<p>The function <b>ARM_SAI_Receive</b> is used to receive data from the SAI receiver. The function parameters specify the buffer for <em>data</em> and the number <em>num</em> of items to receive. The item size is defined by the data type, which depends on the configured number of data bits.</p>
<p>Data type is:</p>
<ul>
<li><em>uint8_t</em> when configured for <span class="XML-Token">8</span> data bits</li>
<li><em>uint16_t</em> when configured for <span class="XML-Token">9..16</span> data bits</li>
<li><em>uint32_t</em> when configured for <span class="XML-Token">17..32</span> data bits</li>
</ul>
<p>The receiver is enabled by calling the function <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> with the control parameter <a class="el" href="group__sai__controls.html#gaa40390b6dd0df3b140fdc45bb7b1439d">ARM_SAI_CONTROL_RX</a> and the value <span class="XML-Token">1</span> for the parameter <em>arg1</em>. This starts the receive engine, which generates a clock and frame sync signal in master mode and receives data. In slave mode, clock and frame sync are generated by the external master.</p>
<p>Calling the function <b>ARM_SAI_Receive</b> only starts the receive operation. The function is non-blocking and returns as soon as the driver has started the operation (the driver typically configures DMA or the interrupt system for continuous transfer). During the operation, it is not allowed to call this function again. The data buffer must also stay allocated. When receive operation is completed (the requested number of items have been received), the <a class="el" href="group__SAI__events.html#ga5a9bde0b096aafe53279529a0adbef55">ARM_SAI_EVENT_RECEIVE_COMPLETE</a> event is generated. Progress of the receive operation can also be monitored by reading the number of items already received by calling the function <a class="el" href="group__sai__interface__gr.html#ga2c571fcc8b9632c25a64043bc2b2baec">ARM_SAI_GetRxCount</a>.</p>
<p>The status of the receiver can also be monitored by calling the function <a class="el" href="group__sai__interface__gr.html#ga6a202b57697f0f7a9742e76b33d5eeec">ARM_SAI_GetStatus</a> and checking the <em>rx_busy</em> flag, which indicates whether a reception is still in progress.</p>
<p>When the receiver is enabled and data is received but the receive operation has not been started yet, then the event <a class="el" href="group__SAI__events.html#gac83e9df0238803ef2c88f16605f73bf5">ARM_SAI_EVENT_RX_OVERFLOW</a> is generated.</p>
<p>If an invalid synchronization frame is detected in slave mode, then the event <a class="el" href="group__SAI__events.html#ga6ffcf96fe404b48421a57fbd122b26bc">ARM_SAI_EVENT_FRAME_ERROR</a> is generated (if supported and reported by <em>event_frame_error</em> in <a class="el" href="group__sai__interface__gr.html#structARM__SAI__CAPABILITIES">ARM_SAI_CAPABILITIES</a>).</p>
<p>The receive operation can be aborted by calling the function <a class="el" href="group__sai__interface__gr.html#ga405a0769c33da6801055db0fb9b6c869">ARM_SAI_Control</a> with the control parameter <a class="el" href="group__sai__controls.html#ga2b8d3d85c1e60f137f8c433f319244cb">ARM_SAI_ABORT_RECEIVE</a>. </p>
</div>
</div>
<a class="anchor" id="gaa9805f9d32aee205f787e625a58e8898"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t ARM_SAI_GetTxCount </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get transmitted data count. </p>
<dl class="section return"><dt>Returns</dt><dd>number of data items transmitted</dd></dl>
<p>The function <b>ARM_SAI_GetTxCount</b> returns the number of the currently transmitted data items during an <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a> operation. </p>
</div>
</div>
<a class="anchor" id="ga2c571fcc8b9632c25a64043bc2b2baec"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t ARM_SAI_GetRxCount </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get received data count. </p>
<dl class="section return"><dt>Returns</dt><dd>number of data items received</dd></dl>
<p>The function <b>ARM_SAI_GetRxCount</b> returns the number of the currently received data items during an <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a> operation. </p>
</div>
</div>
<a class="anchor" id="ga405a0769c33da6801055db0fb9b6c869"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int32_t ARM_SAI_Control </td>
<td>(</td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>control</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>arg1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>arg2</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Control SAI Interface. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">control</td><td>Operation </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">arg1</td><td>Argument 1 of operation (optional) </td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">arg2</td><td>Argument 2 of operation (optional) </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>common <a class="el" href="group__execution__status.html">Status Error Codes</a> and driver specific <a class="el" href="group__sai__execution__status.html">Status Error Codes</a></dd></dl>
<p>The function <b>ARM_SAI_Control</b> controls the SAI interface and executes various operations.</p>
<p>The parameter <em>control</em> specifies the operation. Values are listed in the table <a href="#sai_contrl_tab"><b>Parameter <em>control</em></b></a>.<br/>
The parameter <em>arg1</em> provides, depending on the operation, additional information or sets values. Refer to table <a href="#sai_arg1_tab"><b>Parameter <em>arg1</em></b></a>. <br/>
The parameter <em>arg2</em> provides, depending on the operation and/or <em>arg1</em>, additional information or sets values.</p>
<p>The driver provides a receiver/transmitter pair of signals. In asynchronous operation mode, they operate completely independent from each other. In synchronous operation mode, the synchronous channel uses the Clock (SCK) and Frame Sync (WS) signal from the asynchronous one (control category <a href="#sai_sync"><b>Synchronization</b></a>).</p>
<p>The clock polarity can be set for every protocol, regardless whether it is already predefined for I2S, MSB/LSB Jusitified (control category <a href="#sai_clk_polarity"><b>Clock Polarity</b></a>).</p>
<p>A master clock provides a faster clock from which the frame can be derived (usually 256 x faster than the normal frame clock). You can use a master clock only in master mode. A slave will always have only one clock (control category <a href="#master_clock"><b>Master Clock pin (MCLK)</b></a>).</p>
<p><a class="anchor" id="sai_contrl_tab"></a> The table lists the operation values for <em>control</em>. Values from different categories can be ORed. </p>
<table class="cmtable">
<tr>
<th>Parameter <em>control</em> </th><th>Bit </th><th>Category </th><th>Description </th></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#ga14ac7775060e731b26bc5b3acd2f317a">ARM_SAI_CONFIGURE_TX</a> </td><td rowspan="9" style="text-align:right">0..7 </td><td rowspan="9">Operation </td><td>Configure transmitter. <em>arg1</em> (see <a href="#sai_arg1_tab"><b>Parameter <em>arg1</em></b></a>) and <em>arg2</em> provide additional configuration. </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#ga14ac7775060e731b26bc5b3acd2f317a">ARM_SAI_CONFIGURE_TX</a> </td><td>Configure transmitter. <em>arg1</em> (see <a href="#sai_arg1_tab"><b>Parameter <em>arg1</em></b></a>) and <em>arg2</em> provide additional configuration. </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#gaba3e824e022fe2a5736de5dcbbd3d291">ARM_SAI_CONFIGURE_RX</a> </td><td>Configure transmitter. <em>arg1</em> and <em>arg2</em> provide additional configuration. </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#ga74d7850973c095bb8dbffa880b4af1bc">ARM_SAI_CONTROL_TX</a> </td><td>Enable or disable transmitter and control mute; <em>arg1.0</em> : <span class="XML-Token">0=disable (default); 1=enable;</span> <em>arg1.1</em> : <span class="XML-Token">mute</span> (see <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a>) </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#gaa40390b6dd0df3b140fdc45bb7b1439d">ARM_SAI_CONTROL_RX</a> </td><td>Enable or disable receiver; <em>arg1.0</em> : <span class="XML-Token">0=disable (default); 1=enable</span> (see <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a>) </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#ga8675b9776189caf4df7d558b3e18fcba">ARM_SAI_MASK_SLOTS_TX</a> </td><td>Mask transmitter slots; <em>arg1</em> = <span class="XML-Token">mask</span> (bit: 0=active, 1=inactive); all configured slots are active by default. </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#ga84302d372185665852c9ed941c6545e0">ARM_SAI_MASK_SLOTS_RX</a> </td><td>Mask receiver slots; <em>arg1</em> = <span class="XML-Token">mask</span> (bit: 0=active, 1=inactive); all configured slots are active by default. </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#gab3ec8ef9e5e5a190bd2131ac8c99a240">ARM_SAI_ABORT_SEND</a> </td><td>Abort send operation (see <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a>). </td></tr>
<tr>
<td><a class="el" href="group__sai__controls.html#ga2b8d3d85c1e60f137f8c433f319244cb">ARM_SAI_ABORT_RECEIVE</a> </td><td>Abort receive operation (see <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a>). </td></tr>
<tr>
<td><a class="el" href="group__sai__mode__control.html#ga5bedff714ea0f90139665b72d44daddc">ARM_SAI_MODE_MASTER</a> </td><td rowspan="2" style="text-align:right">8 </td><td rowspan="2">Mode </td><td>Master mode. <em>arg2</em> specifies the audio frequency in [Hz]. You can also set the <a href="#master_clock"><b>Master Clock pin</b></a>. </td></tr>
<tr>
<td><a class="el" href="group__sai__mode__control.html#ga5956c12a24a506754ecc7999f0660bb5">ARM_SAI_MODE_SLAVE</a> (default) </td><td>Slave mode. </td></tr>
<tr>
<td><a class="el" href="group__sai__sync__control.html#gad123537cb6ab9eefd6feab193ed74655">ARM_SAI_ASYNCHRONOUS</a> (default)<a class="anchor" id="sai_sync"></a></td><td rowspan="2" style="text-align:right">9 </td><td rowspan="2">Synchronization </td><td>Asynchronous operation using own clock and sync signal. </td></tr>
<tr>
<td><a class="el" href="group__sai__sync__control.html#gad2ad5406c30c353e80f54b40b3de5db8">ARM_SAI_SYNCHRONOUS</a> </td><td>Synchronous operation using clock and sync signal from other transmitter/receiver. </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#gacef87941052c21ebacd3dde6ce9d6925">ARM_SAI_PROTOCOL_USER</a> (default) </td><td rowspan="7" style="text-align:right">10..12 </td><td rowspan="7">Protocol </td><td>User defined </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#gaaaf423bbe59920b3c7813e22ce083ddc">ARM_SAI_PROTOCOL_I2S</a> </td><td>I2C </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#gad931f9e8aedff4e6040d726d707862f0">ARM_SAI_PROTOCOL_MSB_JUSTIFIED</a> </td><td>MSB (left) justified </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#gab88b6f9b61a20927ac8f8d39e46c6349">ARM_SAI_PROTOCOL_LSB_JUSTIFIED</a> </td><td>LSB (right) justified </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#ga3762437e0b1402b5d4fd293ae745f103">ARM_SAI_PROTOCOL_PCM_SHORT</a> </td><td>PCM with short frame </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#gad43530c5b6ae1e89db587b20d71440b4">ARM_SAI_PROTOCOL_PCM_LONG</a> </td><td>PCM with long frame </td></tr>
<tr>
<td><a class="el" href="group__sai__protocol__control.html#ga8b1669910f4db4bb3584543e7eb04d7a">ARM_SAI_PROTOCOL_AC97</a> </td><td>AC'97 </td></tr>
<tr>
<td><a class="el" href="group__sai__data__bits__control.html#ga1a7529e4b46d69dbd57ccef84552a3f4">ARM_SAI_DATA_SIZE(n)</a> </td><td style="text-align:right">13..17 </td><td>Data Size </td><td>Data size in bits; the range for <em>n</em> is <span class="XML-Token">8..32</span>. See also: <a href="#frame_slot_size"><b>Frame Slot Size</b></a>. </td></tr>
<tr>
<td><a class="el" href="group__sai__bit__order__control.html#gaf74bfe9c3005bf3b80d69f112ea9e62b">ARM_SAI_MSB_FIRST</a> </td><td rowspan="2" style="text-align:right">18 </td><td rowspan="2">Bit Order </td><td>Data is transferred with MSB first. </td></tr>
<tr>
<td><a class="el" href="group__sai__bit__order__control.html#ga19b51b75537b030b975efcf68f3db78b">ARM_SAI_LSB_FIRST</a> </td><td>Data is transferred with LSB first (User protocol only, ignored otherwise). </td></tr>
<tr>
<td><a class="el" href="group__sai__mono__control.html#ga0adcd27875d92add813b9664e9cb0b4b">ARM_SAI_MONO_MODE</a> </td><td style="text-align:right">19 </td><td>Mono Mode </td><td>Only for I2S, MSB/LSB justified. When using <a class="el" href="group__sai__interface__gr.html#Driver_SAI_I2S">I2S</a> in mono mode, only data for a single channel is sent to and received from the driver. Hardware will duplicate the data for the second channel on transmit and ignore the second channel on receive. </td></tr>
<tr>
<td><a class="el" href="group__sai__companding__control.html#ga185919d553cf9204e514136eb375ef08">ARM_SAI_COMPANDING_NONE</a> (default) </td><td rowspan="3" style="text-align:right">20..22 </td><td rowspan="3">Companding </td><td>No companding </td></tr>
<tr>
<td><a class="el" href="group__sai__companding__control.html#gacfd6c74148c0ae90aa6eaaf8e69da3a9">ARM_SAI_COMPANDING_A_LAW</a> </td><td>A-Law companding (8-bit data) </td></tr>
<tr>
<td><a class="el" href="group__sai__companding__control.html#ga7b571406bcce383140198e53312faee5">ARM_SAI_COMPANDING_U_LAW</a> </td><td>u-Law companding (8-bit data) </td></tr>
<tr>
<td><a class="el" href="group__sai__clock__pol__control.html#ga4311b6b6fd937d6ac37aa2d031a5d5ee">ARM_SAI_CLOCK_POLARITY_0</a>&#160;(default)<a class="anchor" id="sai_clk_polarity"></a>&gt; </td><td rowspan="2" style="text-align:right">23 </td><td rowspan="2">Clock Polarity </td><td>Drive on falling edge, capture on rising edge. </td></tr>
<tr>
<td><a class="el" href="group__sai__clock__pol__control.html#gae4c9b9abd3b7390810a5494363875a53">ARM_SAI_CLOCK_POLARITY_1</a><a class="anchor" id="master_clock"></a> </td><td>Drive on rising edge, capture on falling edge. </td></tr>
<tr>
<td><a class="el" href="group__sai__mclk__pin__control.html#ga7654bffb42e96d48df57c598323337d6">ARM_SAI_MCLK_PIN_INACTIVE</a>&#160;(default) </td><td rowspan="3" style="text-align:right">24..26 </td><td rowspan="3">Master Clock pin (MCLK) </td><td>MCLK not used. </td></tr>
<tr>
<td><a class="el" href="group__sai__mclk__pin__control.html#ga24d99edf05699eff32da02742fb04ced">ARM_SAI_MCLK_PIN_OUTPUT</a> </td><td>MCLK is output (Master mode only). </td></tr>
<tr>
<td><a class="el" href="group__sai__mclk__pin__control.html#ga2cd610be9ba9532b2926376deaacf5ad">ARM_SAI_MCLK_PIN_INPUT</a> </td><td>MCLK is input (Master mode only). </td></tr>
</table>
<p><a class="anchor" id="sai_arg1_tab"></a>The parameter <em>arg1</em> provides frame-specific values depending on the <em>control</em> operation. Values from different categories can be ORed. </p>
<table class="cmtable">
<tr>
<th>Parameter <em>arg1</em> </th><th style="text-align:right">Bit </th><th>Category </th><th>Description </th></tr>
<tr>
<td><a class="el" href="group__sai__frame__control.html#ga4c557aa02c83b8595be23a6c58d284e9">ARM_SAI_FRAME_LENGTH(n)</a> </td><td style="text-align:right">0..9 </td><td>Frame Length </td><td>Frame length in bits; the possible range for <em>n</em> is <span class="XML-Token">8..1024</span>; default depends on protocol and data. </td></tr>
<tr>
<td><a class="el" href="group__sai__frame__control.html#gae165fd96e6a5b06b362954fadeabcb7a">ARM_SAI_FRAME_SYNC_WIDTH(n)</a> </td><td style="text-align:right">10..17 </td><td>Frame Sync Width </td><td>Frame Sync width in bits; the possible range for <em>n</em> is <span class="XML-Token">1..256</span>; <span class="XML-Token">default=1</span>; User protocol only, ignored otherwise. </td></tr>
<tr>
<td><a class="el" href="group__sai__frame__control.html#ga7be0326e15d61d6c67febb22f5b14d58">ARM_SAI_FRAME_SYNC_POLARITY_HIGH</a> </td><td rowspan="2" style="text-align:right">18 </td><td rowspan="2" style="white-spaces:nowrap">Frame Sync Polarity </td><td>Frame Sync is active high (default). </td></tr>
<tr>
<td><a class="el" href="group__sai__frame__control.html#gaf3d6bdbc05379ac30905cecf1b2d917e">ARM_SAI_FRAME_SYNC_POLARITY_LOW</a> </td><td>Frame Sync is active low (User protocol only, ignored otherwise). </td></tr>
<tr>
<td><a class="el" href="group__sai__frame__control.html#gabec3992447436a2a8ed99108908ae208">ARM_SAI_FRAME_SYNC_EARLY</a> </td><td style="text-align:right">19 </td><td>Frame Sync Early </td><td>Frame Sync one bit before the first bit of the frame (User protocol only, ignored otherwise). </td></tr>
<tr>
<td><a class="el" href="group__sai__slot__control.html#ga8f2cf3a212ca7fe389e00b082efb5d0b">ARM_SAI_SLOT_COUNT(n)</a> </td><td style="text-align:right">20..24 </td><td>Frame Sync Count </td><td>Number of slots in frame; the possible range for <em>n</em> is <span class="XML-Token">1..32</span>; default=<span class="XML-Token">1</span>; User protocol only, ignored otherwise. </td></tr>
<tr>
<td><a class="el" href="group__sai__slot__control.html#gad77c6c0de2a4e7223a0c42e1594f0a2c">ARM_SAI_SLOT_SIZE_DEFAULT</a><a class="anchor" id="frame_slot_size"></a> </td><td rowspan="3" style="text-align:right">25..26 </td><td rowspan="3">Frame Slot Size </td><td>Slot size is equal to data size (default). </td></tr>
<tr>
<td><a class="el" href="group__sai__slot__control.html#ga2bb9cf53b07cac81fb0fe71de6c97c83">ARM_SAI_SLOT_SIZE_16</a> </td><td>Slot size is <span class="XML-Token">16 bits</span> (User protocol only, ignored otherwise). </td></tr>
<tr>
<td><a class="el" href="group__sai__slot__control.html#gaaa5c4cc18a0f5668bc9f117874cd83dd">ARM_SAI_SLOT_SIZE_32</a> </td><td>Slot size is <span class="XML-Token">32 bits</span> (User protocol only, ignored otherwise). </td></tr>
<tr>
<td><a class="el" href="group__sai__slot__control.html#ga48d4a142f3a1bb0fa4e88c9e427932a0">ARM_SAI_SLOT_OFFSET(n)</a> </td><td style="text-align:right">27..31 </td><td>Frame Slot Offset </td><td>Offset of first data bit in slot; The range for <em>n</em> is <span class="XML-Token">0..31</span>; default=<span class="XML-Token">0</span>; User protocol only, ignored otherwise. </td></tr>
</table>
<p><a class="anchor" id="mckl_prescaler"></a>Depending on the <em>control</em> operation, the parameter <em>arg2</em> specifies the Master Clock (MCLK) prescaler and calculates the audio frequency automatically.</p>
<table class="doxtable">
<tr>
<th align="left">Parameter <em>arg2</em> </th><th align="left">MCLK Prescaler </th></tr>
<tr>
<td align="left"><a class="el" href="group__sai__mclk__pres__control.html#ga2afa85cd335e75d8b9b06c9f47f3f4b0">ARM_SAI_MCLK_PRESCALER(n)</a> </td><td align="left">MCLK prescaler; Audio frequency = MCLK/n; the range for <em>n</em> is <span class="XML-Token">1..4096</span>; default=<span class="XML-Token">1</span>. </td></tr>
</table>
<p><b>Example</b> </p>
<div class="fragment"><div class="line"><span class="keyword">extern</span> <a class="code" href="group__sai__interface__gr.html#structARM__DRIVER__SAI">ARM_DRIVER_SAI</a> Driver_SAI0;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// configure Transmitter to Asynchronous Master: I2S Protocol, 16-bit data, 16kHz Audio frequency</span></div>
<div class="line">status = Driver_SAI0.<a class="code" href="group__sai__interface__gr.html#a80455fc2c7355b1850098710fd66a244">Control</a>(<a class="code" href="group__sai__controls.html#ga14ac7775060e731b26bc5b3acd2f317a">ARM_SAI_CONFIGURE_TX</a> | </div>
<div class="line"> <a class="code" href="group__sai__mode__control.html#ga5bedff714ea0f90139665b72d44daddc">ARM_SAI_MODE_MASTER</a> | </div>
<div class="line"> <a class="code" href="group__sai__sync__control.html#gad123537cb6ab9eefd6feab193ed74655">ARM_SAI_ASYNCHRONOUS</a> | </div>
<div class="line"> <a class="code" href="group__sai__protocol__control.html#gaaaf423bbe59920b3c7813e22ce083ddc">ARM_SAI_PROTOCOL_I2S</a> | </div>
<div class="line"> <a class="code" href="group__sai__data__bits__control.html#ga1a7529e4b46d69dbd57ccef84552a3f4">ARM_SAI_DATA_SIZE</a>(16), 0, 16000);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// configure Receiver to Asynchronous Master: I2S Protocol, 16-bit data, 16kHz Audio frequency</span></div>
<div class="line">status = Driver_SAI0.<a class="code" href="group__sai__interface__gr.html#a80455fc2c7355b1850098710fd66a244">Control</a>(<a class="code" href="group__sai__controls.html#gaba3e824e022fe2a5736de5dcbbd3d291">ARM_SAI_CONFIGURE_RX</a> | </div>
<div class="line"> <a class="code" href="group__sai__mode__control.html#ga5bedff714ea0f90139665b72d44daddc">ARM_SAI_MODE_MASTER</a> | </div>
<div class="line"> <a class="code" href="group__sai__sync__control.html#gad123537cb6ab9eefd6feab193ed74655">ARM_SAI_ASYNCHRONOUS</a> | </div>
<div class="line"> <a class="code" href="group__sai__protocol__control.html#gaaaf423bbe59920b3c7813e22ce083ddc">ARM_SAI_PROTOCOL_I2S</a> | </div>
<div class="line"> <a class="code" href="group__sai__data__bits__control.html#ga1a7529e4b46d69dbd57ccef84552a3f4">ARM_SAI_DATA_SIZE</a>(16), 0, 16000);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// enable Transmitter</span></div>
<div class="line">status = Driver_SAI0.<a class="code" href="group__sai__interface__gr.html#a80455fc2c7355b1850098710fd66a244">Control</a>(<a class="code" href="group__sai__controls.html#ga74d7850973c095bb8dbffa880b4af1bc">ARM_SAI_CONTROL_TX</a>, 1, 0);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// enable Receiver</span></div>
<div class="line">status = Driver_SAI0.<a class="code" href="group__sai__interface__gr.html#a80455fc2c7355b1850098710fd66a244">Control</a>(<a class="code" href="group__sai__controls.html#gaa40390b6dd0df3b140fdc45bb7b1439d">ARM_SAI_CONTROL_RX</a>, 1, 0);</div>
</div><!-- fragment -->
</div>
</div>
<a class="anchor" id="ga6a202b57697f0f7a9742e76b33d5eeec"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a> ARM_SAI_GetStatus </td>
<td>(</td>
<td class="paramtype">void&#160;</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Get SAI status. </p>
<dl class="section return"><dt>Returns</dt><dd>SAI status <a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a></dd></dl>
<p>The function <b>ARM_SAI_GetStatus</b> retrieves the current SAI interface status. </p>
</div>
</div>
<a class="anchor" id="gaedf3347cb25d6bf2faad1bbb35ad79f4"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ARM_SAI_SignalEvent </td>
<td>(</td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>event</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Signal SAI Events. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">event</td><td><a class="el" href="group__SAI__events.html">SAI Events</a> notification mask </td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>none</dd></dl>
<p>The function <b>ARM_SAI_SignalEvent</b> is a callback function registered by the function <a class="el" href="group__sai__interface__gr.html#ga89622a02ca1e7affb1a01eefacb6f54c">ARM_SAI_Initialize</a>.</p>
<p>The parameter <em>event</em> indicates one or more events that occurred during driver operation. Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call.</p>
<p>The following events can be generated:</p>
<table class="doxtable">
<tr>
<th>Parameter <em>event</em> </th><th align="center">Bit </th><th align="left">Description </th></tr>
<tr>
<td><a class="el" href="group__SAI__events.html#ga3dfa64375859f40d157c224187d2885e">ARM_SAI_EVENT_SEND_COMPLETE</a> </td><td align="center">0 </td><td align="left">Occurs after call to <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a> to indicate that all the data has been sent (or queued in transmit buffers). The driver is ready for the next call to <a class="el" href="group__sai__interface__gr.html#ga8bb6866c535adeb930bc4a847d476fcd">ARM_SAI_Send</a>. </td></tr>
<tr>
<td><a class="el" href="group__SAI__events.html#ga5a9bde0b096aafe53279529a0adbef55">ARM_SAI_EVENT_RECEIVE_COMPLETE</a> </td><td align="center">1 </td><td align="left">Occurs after call to <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a> to indicate that all the data has been received. The driver is ready for the next call to <a class="el" href="group__sai__interface__gr.html#ga2d55f506cef9d2849cbe418146086d98">ARM_SAI_Receive</a>. </td></tr>
<tr>
<td><a class="el" href="group__SAI__events.html#ga6a0be7aaf9d700e5259f741641bc37ca">ARM_SAI_EVENT_TX_UNDERFLOW</a> </td><td align="center">2 </td><td align="left">Occurs when data is to be sent but send operation has not been started. Data field <em>tx_underflow</em> = <span class="XML-Token">1</span> of <a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a>. </td></tr>
<tr>
<td><a class="el" href="group__SAI__events.html#gac83e9df0238803ef2c88f16605f73bf5">ARM_SAI_EVENT_RX_OVERFLOW</a> </td><td align="center">3 </td><td align="left">Occurs when data is received but receive operation has not been started. Data field <em>rx_underflow</em> = <span class="XML-Token">1</span> of <a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a>. </td></tr>
<tr>
<td><a class="el" href="group__SAI__events.html#ga6ffcf96fe404b48421a57fbd122b26bc">ARM_SAI_EVENT_FRAME_ERROR</a> </td><td align="center">4 </td><td align="left">Occurs in slave mode when invalid synchronization frame is detected. Data field <em>event_frame_error</em> = <span class="XML-Token">1</span> of <a class="el" href="group__sai__interface__gr.html#structARM__SAI__STATUS">ARM_SAI_STATUS</a>. </td></tr>
</table>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated on Wed Jul 10 2019 15:20:31 for CMSIS-Driver Version 2.7.1 by Arm Ltd. All rights reserved.
<!--
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
-->
</li>
</ul>
</div>
</body>
</html>