330 lines
16 KiB
HTML
330 lines
16 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.9.1"/>
|
|
<title>discoverpixy: Hardware CRC Calculation functions</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="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() { init_search(); });
|
|
</script>
|
|
<link href="doxygen.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 style="padding-left: 0.5em;">
|
|
<div id="projectname">discoverpixy
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.9.1 -->
|
|
<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 Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li><a href="files.html"><span>Files</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 -->
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</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="#func-members">Functions</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">Hardware CRC Calculation functions<div class="ingroups"><a class="el" href="group___s_t_m32_f4xx___std_periph___driver.html">STM32F4xx_StdPeriph_Driver</a> » <a class="el" href="group___s_p_i.html">SPI</a> » <a class="el" href="group___s_p_i___private___functions.html">SPI_Private_Functions</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Hardware CRC Calculation functions.
|
|
<a href="#details">More...</a></p>
|
|
<div class="dynheader">
|
|
Collaboration diagram for Hardware CRC Calculation functions:</div>
|
|
<div class="dyncontent">
|
|
<center><table><tr><td><img src="group___s_p_i___group3.png" border="0" alt="" usemap="#group______s__p__i______group3"/>
|
|
<map name="group______s__p__i______group3" id="group______s__p__i______group3">
|
|
<area shape="rect" id="node2" href="group___s_p_i___private___functions.html" title="SPI_Private_Functions" alt="" coords="5,13,159,39"/></map>
|
|
</td></tr></table></center>
|
|
</div>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
|
|
Functions</h2></td></tr>
|
|
<tr class="memitem:ga64f7276d119e6cb58afc100f8832adb0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group___s_p_i___group3.html#ga64f7276d119e6cb58afc100f8832adb0">SPI_CalculateCRC</a> (<a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> *SPIx, FunctionalState NewState)</td></tr>
|
|
<tr class="memdesc:ga64f7276d119e6cb58afc100f8832adb0"><td class="mdescLeft"> </td><td class="mdescRight">Enables or disables the CRC value calculation of the transferred bytes. <a href="#ga64f7276d119e6cb58afc100f8832adb0">More...</a><br /></td></tr>
|
|
<tr class="separator:ga64f7276d119e6cb58afc100f8832adb0"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:gace8b1058e09bab150b0dbe5978810273"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="group___s_p_i___group3.html#gace8b1058e09bab150b0dbe5978810273">SPI_TransmitCRC</a> (<a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> *SPIx)</td></tr>
|
|
<tr class="memdesc:gace8b1058e09bab150b0dbe5978810273"><td class="mdescLeft"> </td><td class="mdescRight">Transmit the SPIx CRC value. <a href="#gace8b1058e09bab150b0dbe5978810273">More...</a><br /></td></tr>
|
|
<tr class="separator:gace8b1058e09bab150b0dbe5978810273"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga4c81c193516e82cf0a2fdc149ef20cc6"><td class="memItemLeft" align="right" valign="top">uint16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group___s_p_i___group3.html#ga4c81c193516e82cf0a2fdc149ef20cc6">SPI_GetCRC</a> (<a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> *SPIx, uint8_t SPI_CRC)</td></tr>
|
|
<tr class="memdesc:ga4c81c193516e82cf0a2fdc149ef20cc6"><td class="mdescLeft"> </td><td class="mdescRight">Returns the transmit or the receive CRC register value for the specified SPI. <a href="#ga4c81c193516e82cf0a2fdc149ef20cc6">More...</a><br /></td></tr>
|
|
<tr class="separator:ga4c81c193516e82cf0a2fdc149ef20cc6"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ga80fb9374cfce670f29128bb78568353f"><td class="memItemLeft" align="right" valign="top">uint16_t </td><td class="memItemRight" valign="bottom"><a class="el" href="group___s_p_i___group3.html#ga80fb9374cfce670f29128bb78568353f">SPI_GetCRCPolynomial</a> (<a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> *SPIx)</td></tr>
|
|
<tr class="memdesc:ga80fb9374cfce670f29128bb78568353f"><td class="mdescLeft"> </td><td class="mdescRight">Returns the CRC Polynomial register value for the specified SPI. <a href="#ga80fb9374cfce670f29128bb78568353f">More...</a><br /></td></tr>
|
|
<tr class="separator:ga80fb9374cfce670f29128bb78568353f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<p>Hardware CRC Calculation functions. </p>
|
|
<pre class="fragment"> ===============================================================================
|
|
##### Hardware CRC Calculation functions #####
|
|
===============================================================================
|
|
|
|
[..] This section provides a set of functions allowing to manage the SPI CRC hardware
|
|
calculation
|
|
|
|
[..] SPI communication using CRC is possible through the following procedure:
|
|
(#) Program the Data direction, Polarity, Phase, First Data, Baud Rate Prescaler,
|
|
Slave Management, Peripheral Mode and CRC Polynomial values using the SPI_Init()
|
|
function.
|
|
(#) Enable the CRC calculation using the SPI_CalculateCRC() function.
|
|
(#) Enable the SPI using the SPI_Cmd() function
|
|
(#) Before writing the last data to the TX buffer, set the CRCNext bit using the
|
|
SPI_TransmitCRC() function to indicate that after transmission of the last
|
|
data, the CRC should be transmitted.
|
|
(#) After transmitting the last data, the SPI transmits the CRC. The SPI_CR1_CRCNEXT
|
|
bit is reset. The CRC is also received and compared against the SPI_RXCRCR
|
|
value.
|
|
If the value does not match, the SPI_FLAG_CRCERR flag is set and an interrupt
|
|
can be generated when the SPI_I2S_IT_ERR interrupt is enabled.
|
|
|
|
[..]
|
|
(@) It is advised not to read the calculated CRC values during the communication.
|
|
|
|
(@) When the SPI is in slave mode, be careful to enable CRC calculation only
|
|
when the clock is stable, that is, when the clock is in the steady state.
|
|
If not, a wrong CRC calculation may be done. In fact, the CRC is sensitive
|
|
to the SCK slave input clock as soon as CRCEN is set, and this, whatever
|
|
the value of the SPE bit.
|
|
|
|
(@) With high bitrate frequencies, be careful when transmitting the CRC.
|
|
As the number of used CPU cycles has to be as low as possible in the CRC
|
|
transfer phase, it is forbidden to call software functions in the CRC
|
|
transmission sequence to avoid errors in the last data and CRC reception.
|
|
In fact, CRCNEXT bit has to be written before the end of the transmission/reception
|
|
of the last data.
|
|
|
|
(@) For high bit rate frequencies, it is advised to use the DMA mode to avoid the
|
|
degradation of the SPI speed performance due to CPU accesses impacting the
|
|
SPI bandwidth.
|
|
|
|
(@) When the STM32F4xx is configured as slave and the NSS hardware mode is
|
|
used, the NSS pin needs to be kept low between the data phase and the CRC
|
|
phase.
|
|
|
|
(@) When the SPI is configured in slave mode with the CRC feature enabled, CRC
|
|
calculation takes place even if a high level is applied on the NSS pin.
|
|
This may happen for example in case of a multi-slave environment where the
|
|
communication master addresses slaves alternately.
|
|
|
|
(@) Between a slave de-selection (high level on NSS) and a new slave selection
|
|
(low level on NSS), the CRC value should be cleared on both master and slave
|
|
sides in order to resynchronize the master and slave for their respective
|
|
CRC calculation.
|
|
|
|
(@) To clear the CRC, follow the procedure below:
|
|
(#@) Disable SPI using the SPI_Cmd() function
|
|
(#@) Disable the CRC calculation using the SPI_CalculateCRC() function.
|
|
(#@) Enable the CRC calculation using the SPI_CalculateCRC() function.
|
|
(#@) Enable SPI using the SPI_Cmd() function.</pre> <h2 class="groupheader">Function Documentation</h2>
|
|
<a class="anchor" id="ga64f7276d119e6cb58afc100f8832adb0"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void SPI_CalculateCRC </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> * </td>
|
|
<td class="paramname"><em>SPIx</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">FunctionalState </td>
|
|
<td class="paramname"><em>NewState</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Enables or disables the CRC value calculation of the transferred bytes. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">SPIx</td><td>where x can be 1, 2, 3, 4, 5 or 6 to select the SPI peripheral. </td></tr>
|
|
<tr><td class="paramname">NewState</td><td>new state of the SPIx CRC value calculation. This parameter can be: ENABLE or DISABLE. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="retval"><dt>Return values</dt><dd>
|
|
<table class="retval">
|
|
<tr><td class="paramname">None</td><td></td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ga4c81c193516e82cf0a2fdc149ef20cc6"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">uint16_t SPI_GetCRC </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> * </td>
|
|
<td class="paramname"><em>SPIx</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">uint8_t </td>
|
|
<td class="paramname"><em>SPI_CRC</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the transmit or the receive CRC register value for the specified SPI. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">SPIx</td><td>where x can be 1, 2, 3, 4, 5 or 6 to select the SPI peripheral. </td></tr>
|
|
<tr><td class="paramname">SPI_CRC</td><td>specifies the CRC register to be read. This parameter can be one of the following values: <ul>
|
|
<li>SPI_CRC_Tx: Selects Tx CRC register </li>
|
|
<li>SPI_CRC_Rx: Selects Rx CRC register </li>
|
|
</ul>
|
|
</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="retval"><dt>Return values</dt><dd>
|
|
<table class="retval">
|
|
<tr><td class="paramname">The</td><td>selected CRC register value.. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="ga80fb9374cfce670f29128bb78568353f"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">uint16_t SPI_GetCRCPolynomial </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> * </td>
|
|
<td class="paramname"><em>SPIx</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns the CRC Polynomial register value for the specified SPI. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">SPIx</td><td>where x can be 1, 2, 3, 4, 5 or 6 to select the SPI peripheral. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="retval"><dt>Return values</dt><dd>
|
|
<table class="retval">
|
|
<tr><td class="paramname">The</td><td>CRC Polynomial register value. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
<a class="anchor" id="gace8b1058e09bab150b0dbe5978810273"></a>
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void SPI_TransmitCRC </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="struct_s_p_i___type_def.html">SPI_TypeDef</a> * </td>
|
|
<td class="paramname"><em>SPIx</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Transmit the SPIx CRC value. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">SPIx</td><td>where x can be 1, 2, 3, 4, 5 or 6 to select the SPI peripheral. </td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="retval"><dt>Return values</dt><dd>
|
|
<table class="retval">
|
|
<tr><td class="paramname">None</td><td></td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
</div>
|
|
</div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Sun May 10 2015 15:15:20 for discoverpixy by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.9.1
|
|
</small></address>
|
|
</body>
|
|
</html>
|