MCUXpresso_LPC55S69/docs/MCUXpresso SDK API Referenc.../a00248.html

469 lines
51 KiB
HTML

<!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"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>MCUXpresso SDK API Reference Manual: I2S: I2S Driver</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.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>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
</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: 56px;">
<td id="projectlogo"><img alt="Logo" src="fs_logo.gif"/></td>
<td style="padding-left: 0.5em;">
<div id="projectname">MCUXpresso SDK API Reference Manual
&#160;<span id="projectnumber">Rev 2.15.000</span>
</div>
<div id="projectbrief">NXP Semiconductors</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<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>Related&#160;Pages</span></a></li>
<li><a href="modules.html"><span>API&#160;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('a00248.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>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><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">Modules</a> </div>
<div class="headertitle">
<div class="title">I2S: I2S Driver</div> </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<p>The MCUXpresso SDK provides the peripheral driver for the I2S function of FLEXCOMM module of MCUXpresso SDK devices.<br/>
<br/>
The I2S module is used to transmit or receive digital audio data. Only transmit or receive is enabled at one time in one module. <br/>
Driver currently supports one (primary) channel pair per one I2S enabled FLEXCOMM module only. <br/>
</p>
<h1><a class="anchor" id="I2SInit"></a>
I2S Driver Initialization and Configuration</h1>
<p><a class="el" href="a00031.html#ga5d68b2f69b625a753d498dab6758c5b9" title="Initializes the FLEXCOMM peripheral for I2S transmit functionality. ">I2S_TxInit()</a> and <a class="el" href="a00031.html#gaa71e9b55c275d5469c1e3f723dc55213" title="Initializes the FLEXCOMM peripheral for I2S receive functionality. ">I2S_RxInit()</a> functions ungate the clock for the FLEXCOMM module, assign I2S function to FLEXCOMM module and configure audio data format and other I2S operational settings. <a class="el" href="a00031.html#ga5d68b2f69b625a753d498dab6758c5b9" title="Initializes the FLEXCOMM peripheral for I2S transmit functionality. ">I2S_TxInit()</a> is used when I2S should transmit data, <a class="el" href="a00031.html#gaa71e9b55c275d5469c1e3f723dc55213" title="Initializes the FLEXCOMM peripheral for I2S receive functionality. ">I2S_RxInit()</a> when it should receive data.</p>
<p><a class="el" href="a00031.html#ga905cb886175d4a1f9ac2fbf8d2722cf6" title="Sets the I2S Tx configuration structure to default values. ">I2S_TxGetDefaultConfig()</a> and <a class="el" href="a00031.html#ga8356de62fea66f67a9803ee89a78805a" title="Sets the I2S Rx configuration structure to default values. ">I2S_RxGetDefaultConfig()</a> functions can be used to set the module configuration structure with default values for transmit and receive function, respectively.</p>
<p><a class="el" href="a00031.html#ga68e9243ae7345a144668c7e04f1f52ac" title="De-initializes the I2S peripheral. ">I2S_Deinit()</a> function resets the FLEXCOMM module.</p>
<p><a class="el" href="a00031.html#ga0e630bdd0adb5a39b52e374ede7bc07f" title="Initializes handle for transfer of audio data. ">I2S_TxTransferCreateHandle()</a> function creates transactional handle for transmit in interrupt mode.</p>
<p><a class="el" href="a00031.html#gabd8c54c9689fd89024c83bb883693c16" title="Initializes handle for reception of audio data. ">I2S_RxTransferCreateHandle()</a> function creates transactional handle for receive in interrupt mode.</p>
<p><a class="el" href="a00032.html#gab367abb21d0180a8327c3408efa06bd8" title="Initializes handle for transfer of audio data. ">I2S_TxTransferCreateHandleDMA()</a> function creates transactional handle for transmit in DMA mode.</p>
<p><a class="el" href="a00032.html#gabf7c9bdafbd7e7aac4b265dace33f9e6" title="Initializes handle for reception of audio data. ">I2S_RxTransferCreateHandleDMA()</a> function creates transactional handle for receive in DMA mode.</p>
<h1><a class="anchor" id="I2STransfer"></a>
I2S Transmit Data</h1>
<p><a class="el" href="a00031.html#ga8e341c9ce48e5be03e120ea332758048" title="Begins or queue sending of the given data. ">I2S_TxTransferNonBlocking()</a> function is used to add data buffer to transmit in interrupt mode. It also begins transmission if not transmitting yet.</p>
<p><a class="el" href="a00031.html#ga454cba72bec3ebeecf865570ce6ed900" title="Begins or queue reception of data into given buffer. ">I2S_RxTransferNonBlocking()</a> function is used to add data buffer to receive data into in interrupt mode. It also begins reception if not receiving yet.</p>
<p><a class="el" href="a00032.html#ga7f0ee69bcc210dc1519a99e2d9403e67" title="Begins or queue sending of the given data. ">I2S_TxTransferSendDMA()</a> function is used to add data buffer to transmit in DMA mode. It also begins transmission if not transmitting yet.</p>
<p><a class="el" href="a00032.html#gae8c0cacf997b6d4642c6c4e26dccf5aa" title="Begins or queue reception of data into given buffer. ">I2S_RxTransferReceiveDMA()</a> function is used to add data buffer to receive data into in DMA mode. It also begins reception if not receiving yet.</p>
<p>The transfer of data will be stopped automatically when all data buffers queued using the above functions will be processed and no new data buffer is enqueued meanwhile. If the above functions are not called frequently enough, I2S stop followed by restart may keep occurring resulting in drops audio stream.</p>
<h1><a class="anchor" id="I2SInterrupt"></a>
I2S Interrupt related functions</h1>
<p><a class="el" href="a00031.html#ga435263725c056eccaa82eb1947e162aa" title="Enables I2S FIFO interrupts. ">I2S_EnableInterrupts()</a> function is used to enable interrupts in FIFO interrupt register. Regular use cases do not require this function to be called from application code.</p>
<p><a class="el" href="a00031.html#gaa6f8ed52f3cd5c63b3a3716a70c77223" title="Disables I2S FIFO interrupts. ">I2S_DisableInterrupts()</a> function is used to disable interrupts in FIFO interrupt register. Regular use cases do not require this function to be called from application code.</p>
<p><a class="el" href="a00031.html#ga2d96a8f63e454de7225a98541b6461b9" title="Returns the set of currently enabled I2S FIFO interrupts. ">I2S_GetEnabledInterrupts()</a> function returns interrupts enabled in FIFO interrupt register. Regular use cases do not require this function to be called from application code.</p>
<p><a class="el" href="a00031.html#ga2423f95dc2c00bce6a9de6d868d1fde2" title="Invoked from interrupt handler when transmit FIFO level decreases. ">I2S_TxHandleIRQ()</a> and <a class="el" href="a00031.html#gaeff61f8cbd780c881c593ad059f98338" title="Invoked from interrupt handler when receive FIFO level decreases. ">I2S_RxHandleIRQ()</a> functions are called from ISR which is invoked when actual FIFO level decreases to configured watermark value.</p>
<p><a class="el" href="a00032.html#gac9f82a576dc3a2d10df9cade5ce57a42" title="Invoked from DMA interrupt handler. ">I2S_DMACallback()</a> function is called from ISR which is invoked when DMA transfer (actual descriptor) finishes.</p>
<h1><a class="anchor" id="I2SOther"></a>
I2S Other functions</h1>
<p><a class="el" href="a00031.html#gac109aadc23d6f31e6f8420fa3f4018fd" title="Enables I2S operation. ">I2S_Enable()</a> function enables I2S function in FLEXCOMM module. Regular use cases do not require this function to be called from application code.</p>
<p><a class="el" href="a00031.html#ga4b393781ae83a07d4d3e99972429cfa1" title="Disables I2S operation. ">I2S_Disable()</a> function disables I2S function in FLEXCOMM module. Regular use cases do not require this function to be called from application code.</p>
<p><a class="el" href="a00031.html#gae3d210a830859e93103931b4baf83586" title="Returns number of buffer underruns or overruns. ">I2S_TransferGetErrorCount()</a> function returns the number of FIFO underruns or overruns in interrupt mode.</p>
<p><a class="el" href="a00031.html#ga14ef749f4300fe7b1fd38277f0ef167f" title="Returns number of bytes transferred so far. ">I2S_TransferGetCount()</a> function returns the number of bytes transferred in interrupt mode.</p>
<p><a class="el" href="a00031.html#ga25659519f70757bf2db3831f7e807bd8" title="Aborts sending of data. ">I2S_TxTransferAbort()</a> function aborts trasmit operation in interrupt mode.</p>
<p><a class="el" href="a00031.html#ga32eb018b43745a695ef26cec1ff73a73" title="Aborts receiving of data. ">I2S_RxTransferAbort()</a> function aborts receive operation in interrupt mode.</p>
<p><a class="el" href="a00032.html#ga59beaf115701e7b97ffd517a83e6b611" title="Aborts transfer of data. ">I2S_TransferAbortDMA()</a> function aborts transmit or receive operation in DMA mode.</p>
<h1>I2S Functional limitations</h1>
<p>I2S can not to accurately determine when the data is sent to the end. Since program commands cannot quickly disable I2S, there will always be more clock exposure. If someone want to get accurate data, can use <a class="el" href="a00032.html#ga59beaf115701e7b97ffd517a83e6b611" title="Aborts transfer of data. ">I2S_TransferAbortDMA()</a> api in TxCallback() to terminate sending data prematurely and ensure the accuracy of the data with delay function.</p>
<h1><a class="anchor" id="I2SFormat"></a>
I2S Data formats</h1>
<h2><a class="anchor" id="I2SFormatDMA"></a>
DMA mode</h2>
<p>Length of buffer for transmit or receive has to be multiply of 4 bytes. Buffer address has to be aligned to 4-bytes. Data are put into or taken from FIFO unaltered in DMA mode so buffer has to be prepared according to following information. If oneChannel is enabled, then the buffer should contain valid data only, that is to say, audio data should be put continuously in the buffer Take 8 bit data as example: </p>
<p><code>LSB</code> </p>
<p><code>L07</code> </p>
<p><code>L06</code> </p>
<p><code>L05</code> </p>
<p><code>L04</code> </p>
<p><code>L03</code> </p>
<p><code>L02</code> </p>
<p><code>L01</code> </p>
<p><code>L00</code> </p>
<p><code>L07</code> </p>
<p><code>L06</code> </p>
<p><code>L05</code> </p>
<p><code>L04</code> </p>
<p><code>L03</code> </p>
<p><code>L02</code> </p>
<p><code>L01</code> </p>
<p><code>L00</code> </p>
<p><code>L07</code> </p>
<p><code>L06</code> </p>
<p><code>L05</code> </p>
<p><code>L04</code> </p>
<p><code>L03</code> </p>
<p><code>L02</code> </p>
<p><code>L01</code> </p>
<p><code>L00</code> </p>
<p><code>L07</code> </p>
<p><code>L06</code> </p>
<p><code>L05</code> </p>
<p><code>L04</code> </p>
<p><code>L03</code> </p>
<p><code>L02</code> </p>
<p><code>L01</code> </p>
<p><code>L00</code> </p>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 4 and 16, every word in buffer should contain data for left and right channels.</p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>Rnn - right channel bit nn <br/>
Lnn - left channel bit nn <br/>
Note that for example if <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> = 7, bits on positions R07-R15 and L07-L15 are ignored (buffer "wastes space"). <br/>
</p>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 17 and 24 and <a class="el" href="a00031.html#a81806913aaa20f7a6204d215c9510fdf" title="Packing format for 48-bit data (false - 24 bit values, true - alternating 32-bit and 16-bit values) ...">i2s_config_t.pack48</a> = false:</p>
<p>Even words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>Odd words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><code>R23</code> </td><td><code>R22</code> </td><td><code>R21</code> </td><td><code>R20</code> </td><td><code>R19</code> </td><td><code>R18</code> </td><td><code>R17</code> </td><td><code>R16</code> </td><td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 17 and 24 and <a class="el" href="a00031.html#a81806913aaa20f7a6204d215c9510fdf" title="Packing format for 48-bit data (false - 24 bit values, true - alternating 32-bit and 16-bit values) ...">i2s_config_t.pack48</a> = true:</p>
<p>Even words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>Odd words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td><code>R23</code> </td><td><code>R22</code> </td><td><code>R21</code> </td><td><code>R20</code> </td><td><code>R19</code> </td><td><code>R18</code> </td><td><code>R17</code> </td><td><code>R16</code> </td><td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 25 and 32:</p>
<p>Even words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>L31</code> </td><td><code>L30</code> </td><td><code>L29</code> </td><td><code>L28</code> </td><td><code>L27</code> </td><td><code>L26</code> </td><td><code>L25</code> </td><td><code>L24</code> </td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>Odd words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R31</code> </td><td><code>R30</code> </td><td><code>R29</code> </td><td><code>R28</code> </td><td><code>R27</code> </td><td><code>R26</code> </td><td><code>R25</code> </td><td><code>R24</code> </td><td><code>R23</code> </td><td><code>R22</code> </td><td><code>R21</code> </td><td><code>R20</code> </td><td><code>R19</code> </td><td><code>R18</code> </td><td><code>R17</code> </td><td><code>R16</code> </td><td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td></tr>
</table>
<h2><a class="anchor" id="I2SFormatInterrupt"></a>
Interrupt mode</h2>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is 4:</p>
<p>Buffer does not need to be aligned (buffer is read / written by single bytes, each byte contain left and right channel): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 5 and 8:</p>
<p>Length of buffer for transmit or receive has to be multiply of 2 bytes. Buffer address has to be aligned to 2-bytes. </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 9 and 16:</p>
<p>Length of buffer for transmit or receive has to be multiply of 4 bytes. Buffer address has to be aligned to 4-bytes. </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 17 and 24 and <a class="el" href="a00031.html#a81806913aaa20f7a6204d215c9510fdf" title="Packing format for 48-bit data (false - 24 bit values, true - alternating 32-bit and 16-bit values) ...">i2s_config_t.pack48</a> = false(mono channel audio data is supported):</p>
<p>Length of buffer for transmit or receive has to be multiply of 6 bytes. </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R23</code> </td><td><code>R22</code> </td><td><code>R21</code> </td><td><code>R20</code> </td><td><code>R19</code> </td><td><code>R18</code> </td><td><code>R17</code> </td><td><code>R16</code> </td><td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 17 and 24 and <a class="el" href="a00031.html#a81806913aaa20f7a6204d215c9510fdf" title="Packing format for 48-bit data (false - 24 bit values, true - alternating 32-bit and 16-bit values) ...">i2s_config_t.pack48</a> = true:</p>
<p>Length of buffer for transmit or receive has to be multiply of 6 bytes. Buffer address has to be aligned to 4-bytes. </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R23</code> </td><td><code>R22</code> </td><td><code>R21</code> </td><td><code>R20</code> </td><td><code>R19</code> </td><td><code>R18</code> </td><td><code>R17</code> </td><td><code>R16</code> </td><td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 25 and 32 and <a class="el" href="a00031.html#a08c393f7fb7985c1469fc27eece2f444" title="true mono, false stereo ">i2s_config_t.oneChannel</a> = false:</p>
<p>Buffer for transmit or receive has to be multiply of 8 bytes. Buffer address has to be aligned to 4-bytes.</p>
<p>Even words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>L31</code> </td><td><code>L30</code> </td><td><code>L29</code> </td><td><code>L28</code> </td><td><code>L27</code> </td><td><code>L26</code> </td><td><code>L25</code> </td><td><code>L24</code> </td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<p>Odd words (counting from zero): </p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>R31</code> </td><td><code>R30</code> </td><td><code>R29</code> </td><td><code>R28</code> </td><td><code>R27</code> </td><td><code>R26</code> </td><td><code>R25</code> </td><td><code>R24</code> </td><td><code>R23</code> </td><td><code>R22</code> </td><td><code>R21</code> </td><td><code>R20</code> </td><td><code>R19</code> </td><td><code>R18</code> </td><td><code>R17</code> </td><td><code>R16</code> </td><td><code>R15</code> </td><td><code>R14</code> </td><td><code>R13</code> </td><td><code>R12</code> </td><td><code>R11</code> </td><td><code>R10</code> </td><td><code>R09</code> </td><td><code>R08</code> </td><td><code>R07</code> </td><td><code>R06</code> </td><td><code>R05</code> </td><td><code>R04</code> </td><td><code>R03</code> </td><td><code>R02</code> </td><td><code>R01</code> </td><td><code>R00</code> </td></tr>
</table>
<p>If <a class="el" href="a00031.html#a7804296c524c18b636be8af8e627cc8a" title="Data length (4 - 32) ">i2s_config_t.dataLength</a> (channel bit width) is between 25 and 32 and <a class="el" href="a00031.html#a08c393f7fb7985c1469fc27eece2f444" title="true mono, false stereo ">i2s_config_t.oneChannel</a> = true:</p>
<p>Buffer for transmit or receive has to be multiply of 4 bytes. Buffer address has to be aligned to 4-bytes.</p>
<table class="doxtable">
<tr>
<th><code>MSB</code> </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th><code>LSB</code> </th></tr>
<tr>
<td><code>L31</code> </td><td><code>L30</code> </td><td><code>L29</code> </td><td><code>L28</code> </td><td><code>L27</code> </td><td><code>L26</code> </td><td><code>L25</code> </td><td><code>L24</code> </td><td><code>L23</code> </td><td><code>L22</code> </td><td><code>L21</code> </td><td><code>L20</code> </td><td><code>L19</code> </td><td><code>L18</code> </td><td><code>L17</code> </td><td><code>L16</code> </td><td><code>L15</code> </td><td><code>L14</code> </td><td><code>L13</code> </td><td><code>L12</code> </td><td><code>L11</code> </td><td><code>L10</code> </td><td><code>L09</code> </td><td><code>L08</code> </td><td><code>L07</code> </td><td><code>L06</code> </td><td><code>L05</code> </td><td><code>L04</code> </td><td><code>L03</code> </td><td><code>L02</code> </td><td><code>L01</code> </td><td><code>L00</code> </td></tr>
</table>
<h1><a class="anchor" id="I2SEx"></a>
I2S Driver Examples</h1>
<h2><a class="anchor" id="I2SInterruptEx"></a>
Interrupt mode examples</h2>
<p>Transmit example </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> StartTransfer(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="a00031.html#a00350">i2s_config_t</a> config;</div>
<div class="line"> <a class="code" href="a00031.html#a00353">i2s_transfer_t</a> transfer;</div>
<div class="line"> <a class="code" href="a00031.html#a00352">i2s_handle_t</a> handle;</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00031.html#ga905cb886175d4a1f9ac2fbf8d2722cf6">I2S_TxGetDefaultConfig</a>(&amp;config);</div>
<div class="line"> config.<a class="code" href="a00031.html#a1c5e1132f4c7132d5b9406c686ccf0cb">masterSlave</a> = <a class="code" href="a00031.html#gga58fcc3bdc4a785b22d7a8f397e91911ba13ab2820eda5d509bb3ceff6fb28758b">kI2S_MasterSlaveNormalMaster</a>;</div>
<div class="line"> config.<a class="code" href="a00031.html#ae54489ab2f0a78b1271d04f69c64494d">divider</a> = 32; <span class="comment">/* clock frequency/audio sample frequency/channels/channel bit depth */</span></div>
<div class="line"> <a class="code" href="a00031.html#ga5d68b2f69b625a753d498dab6758c5b9">I2S_TxInit</a>(I2S0, &amp;config);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00031.html#ga0e630bdd0adb5a39b52e374ede7bc07f">I2S_TxTransferCreateHandle</a>(I2S0, &amp;handle, TxCallback, NULL);</div>
<div class="line"></div>
<div class="line"> transfer.<a class="code" href="a00031.html#a7e1639769facb3330f554448901824c7">data</a> = buffer;</div>
<div class="line"> transfer.<a class="code" href="a00031.html#a20eea1329988a3a572c92b630cd3c589">dataSize</a> = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> <a class="code" href="a00031.html#ga8e341c9ce48e5be03e120ea332758048">I2S_TxTransferNonBlocking</a>(I2S0, &amp;handle, transfer);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Enqueue next buffer right away so there is no drop in audio data stream when the first buffer finishes */</span></div>
<div class="line"> <a class="code" href="a00031.html#ga8e341c9ce48e5be03e120ea332758048">I2S_TxTransferNonBlocking</a>(I2S0, &amp;handle, someTransfer);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> TxCallback(I2S_Type *base, <a class="code" href="a00031.html#a00352">i2s_handle_t</a> *handle, <a class="code" href="a00242.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> completionStatus, <span class="keywordtype">void</span> *userData)</div>
<div class="line">{</div>
<div class="line"> i2s_tranfer_t transfer;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (completionStatus == <a class="code" href="a00031.html#ggabc6126af1d45847bc59afa0aa3216b04a634ef87c7515bb4037dfaaea2d75b6e1">kStatus_I2S_BufferComplete</a>)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">/* Enqueue next buffer */</span></div>
<div class="line"> transfer.data = buffer;</div>
<div class="line"> transfer.dataSize = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> <a class="code" href="a00031.html#ga8e341c9ce48e5be03e120ea332758048">I2S_TxTransferNonBlocking</a>(base, handle, transfer);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><p>Receive example </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> StartTransfer(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="a00031.html#a00350">i2s_config_t</a> config;</div>
<div class="line"> <a class="code" href="a00031.html#a00353">i2s_transfer_t</a> transfer;</div>
<div class="line"> <a class="code" href="a00031.html#a00352">i2s_handle_t</a> handle;</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00031.html#ga8356de62fea66f67a9803ee89a78805a">I2S_RxGetDefaultConfig</a>(&amp;config);</div>
<div class="line"> config.<a class="code" href="a00031.html#a1c5e1132f4c7132d5b9406c686ccf0cb">masterSlave</a> = <a class="code" href="a00031.html#gga58fcc3bdc4a785b22d7a8f397e91911ba13ab2820eda5d509bb3ceff6fb28758b">kI2S_MasterSlaveNormalMaster</a>;</div>
<div class="line"> config.<a class="code" href="a00031.html#ae54489ab2f0a78b1271d04f69c64494d">divider</a> = 32; <span class="comment">/* clock frequency/audio sample frequency/channels/channel bit depth */</span></div>
<div class="line"> <a class="code" href="a00031.html#gaa71e9b55c275d5469c1e3f723dc55213">I2S_RxInit</a>(I2S0, &amp;config);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00031.html#gabd8c54c9689fd89024c83bb883693c16">I2S_RxTransferCreateHandle</a>(I2S0, &amp;handle, RxCallback, NULL);</div>
<div class="line"></div>
<div class="line"> transfer.<a class="code" href="a00031.html#a7e1639769facb3330f554448901824c7">data</a> = buffer;</div>
<div class="line"> transfer.<a class="code" href="a00031.html#a20eea1329988a3a572c92b630cd3c589">dataSize</a> = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> <a class="code" href="a00031.html#ga454cba72bec3ebeecf865570ce6ed900">I2S_RxTransferNonBlocking</a>(I2S0, &amp;handle, transfer);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Enqueue next buffer right away so there is no drop in audio data stream when the first buffer finishes */</span></div>
<div class="line"> <a class="code" href="a00031.html#ga454cba72bec3ebeecf865570ce6ed900">I2S_RxTransferNonBlocking</a>(I2S0, &amp;handle, someTransfer);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> RxCallback(I2S_Type *base, <a class="code" href="a00031.html#a00352">i2s_handle_t</a> *handle, <a class="code" href="a00242.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> completionStatus, <span class="keywordtype">void</span> *userData)</div>
<div class="line">{</div>
<div class="line"> i2s_tranfer_t transfer;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (completionStatus == <a class="code" href="a00031.html#ggabc6126af1d45847bc59afa0aa3216b04a634ef87c7515bb4037dfaaea2d75b6e1">kStatus_I2S_BufferComplete</a>)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">/* Enqueue next buffer */</span></div>
<div class="line"> transfer.data = buffer;</div>
<div class="line"> transfer.dataSize = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> <a class="code" href="a00031.html#ga454cba72bec3ebeecf865570ce6ed900">I2S_RxTransferNonBlocking</a>(base, handle, transfer);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><h2><a class="anchor" id="I2SDMAEx"></a>
DMA mode examples</h2>
<p>Transmit example </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> StartTransfer(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="a00031.html#a00350">i2s_config_t</a> config;</div>
<div class="line"> <a class="code" href="a00031.html#a00353">i2s_transfer_t</a> transfer;</div>
<div class="line"> <a class="code" href="a00032.html#a00351">i2s_dma_handle_t</a> handle;</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00031.html#ga905cb886175d4a1f9ac2fbf8d2722cf6">I2S_TxGetDefaultConfig</a>(&amp;config);</div>
<div class="line"> config.<a class="code" href="a00031.html#a1c5e1132f4c7132d5b9406c686ccf0cb">masterSlave</a> = <a class="code" href="a00031.html#gga58fcc3bdc4a785b22d7a8f397e91911ba13ab2820eda5d509bb3ceff6fb28758b">kI2S_MasterSlaveNormalMaster</a>;</div>
<div class="line"> config.<a class="code" href="a00031.html#ae54489ab2f0a78b1271d04f69c64494d">divider</a> = 32; <span class="comment">/* clock frequency/audio sample frequency/channels/channel bit depth */</span></div>
<div class="line"> <a class="code" href="a00031.html#ga5d68b2f69b625a753d498dab6758c5b9">I2S_TxInit</a>(I2S0, &amp;config);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00032.html#gab367abb21d0180a8327c3408efa06bd8">I2S_TxTransferCreateHandleDMA</a>(I2S0, &amp;handle, TxCallback, NULL);</div>
<div class="line"></div>
<div class="line"> transfer.<a class="code" href="a00031.html#a7e1639769facb3330f554448901824c7">data</a> = buffer;</div>
<div class="line"> transfer.<a class="code" href="a00031.html#a20eea1329988a3a572c92b630cd3c589">dataSize</a> = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> I2S_TxTransferNonBlockingDMA(I2S0, &amp;handle, transfer);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Enqueue next buffer right away so there is no drop in audio data stream when the first buffer finishes */</span></div>
<div class="line"> I2S_TxTransferNonBlockingDMA(I2S0, &amp;handle, someTransfer);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> TxCallback(I2S_Type *base, <a class="code" href="a00032.html#a00351">i2s_dma_handle_t</a> *handle, <a class="code" href="a00242.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> completionStatus, <span class="keywordtype">void</span> *userData)</div>
<div class="line">{</div>
<div class="line"> i2s_tranfer_t transfer;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (completionStatus == <a class="code" href="a00031.html#ggabc6126af1d45847bc59afa0aa3216b04a634ef87c7515bb4037dfaaea2d75b6e1">kStatus_I2S_BufferComplete</a>)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">/* Enqueue next buffer */</span></div>
<div class="line"> transfer.data = buffer;</div>
<div class="line"> transfer.dataSize = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> I2S_TxTransferNonBlockingDMA(base, handle, transfer);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><p>Receive example </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> StartTransfer(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="a00031.html#a00350">i2s_config_t</a> config;</div>
<div class="line"> <a class="code" href="a00031.html#a00353">i2s_transfer_t</a> transfer;</div>
<div class="line"> <a class="code" href="a00032.html#a00351">i2s_dma_handle_t</a> handle;</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00031.html#ga8356de62fea66f67a9803ee89a78805a">I2S_RxGetDefaultConfig</a>(&amp;config);</div>
<div class="line"> config.<a class="code" href="a00031.html#a1c5e1132f4c7132d5b9406c686ccf0cb">masterSlave</a> = <a class="code" href="a00031.html#gga58fcc3bdc4a785b22d7a8f397e91911ba13ab2820eda5d509bb3ceff6fb28758b">kI2S_MasterSlaveNormalMaster</a>;</div>
<div class="line"> config.<a class="code" href="a00031.html#ae54489ab2f0a78b1271d04f69c64494d">divider</a> = 32; <span class="comment">/* clock frequency/audio sample frequency/channels/channel bit depth */</span></div>
<div class="line"> <a class="code" href="a00031.html#gaa71e9b55c275d5469c1e3f723dc55213">I2S_RxInit</a>(I2S0, &amp;config);</div>
<div class="line"></div>
<div class="line"> <a class="code" href="a00032.html#gabf7c9bdafbd7e7aac4b265dace33f9e6">I2S_RxTransferCreateHandleDMA</a>(I2S0, &amp;handle, RxCallback, NULL);</div>
<div class="line"></div>
<div class="line"> transfer.<a class="code" href="a00031.html#a7e1639769facb3330f554448901824c7">data</a> = buffer;</div>
<div class="line"> transfer.<a class="code" href="a00031.html#a20eea1329988a3a572c92b630cd3c589">dataSize</a> = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> I2S_RxTransferNonBlockingDMA(I2S0, &amp;handle, transfer);</div>
<div class="line"></div>
<div class="line"> <span class="comment">/* Enqueue next buffer right away so there is no drop in audio data stream when the first buffer finishes */</span></div>
<div class="line"> I2S_RxTransferNonBlockingDMA(I2S0, &amp;handle, someTransfer);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> RxCallback(I2S_Type *base, <a class="code" href="a00032.html#a00351">i2s_dma_handle_t</a> *handle, <a class="code" href="a00242.html#gaaabdaf7ee58ca7269bd4bf24efcde092">status_t</a> completionStatus, <span class="keywordtype">void</span> *userData)</div>
<div class="line">{</div>
<div class="line"> i2s_tranfer_t transfer;</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (completionStatus == <a class="code" href="a00031.html#ggabc6126af1d45847bc59afa0aa3216b04a634ef87c7515bb4037dfaaea2d75b6e1">kStatus_I2S_BufferComplete</a>)</div>
<div class="line"> {</div>
<div class="line"> <span class="comment">/* Enqueue next buffer */</span></div>
<div class="line"> transfer.data = buffer;</div>
<div class="line"> transfer.dataSize = <span class="keyword">sizeof</span>(buffer);</div>
<div class="line"> I2S_RxTransferNonBlockingDMA(base, handle, transfer);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Modules</h2></td></tr>
<tr class="memitem:a00032"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00032.html">I2S DMA Driver</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a00031"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00031.html">I2S Driver</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.5-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul class="foot">
<li class="footer">&copy; 2016 NXP Semiconductors. All rights reserved.
</li>
</ul>
</div>
</body>
</html>