]> begriffs open source - cmsis-driver-validation/blob - docs/html/group__spi__server.html
rework release history
[cmsis-driver-validation] / docs / html / group__spi__server.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <title>SPI Server</title>
7 <title>CMSIS-Driver Validation: SPI Server</title>
8 <link href="tabs.css" rel="stylesheet" type="text/css"/>
9 <link href="drv.css" rel="stylesheet" type="text/css" />
10 <script type="text/javascript" src="jquery.js"></script>
11 <script type="text/javascript" src="dynsections.js"></script>
12 <script type="text/javascript" src="printComponentTabs.js"></script>
13 <link href="navtree.css" rel="stylesheet" type="text/css"/>
14 <script type="text/javascript" src="resize.js"></script>
15 <script type="text/javascript" src="navtree.js"></script>
16 <script type="text/javascript">
17   $(document).ready(initResizable);
18   $(window).load(resizeHeight);
19 </script>
20 <link href="search/search.css" rel="stylesheet" type="text/css"/>
21 <script type="text/javascript" src="search/search.js"></script>
22 <script type="text/javascript">
23   $(document).ready(function() { searchBox.OnSelectItem(0); });
24 </script>
25 <link href="stylsheetf" rel="stylesheet" type="text/css" />
26 </head>
27 <body>
28 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
29 <div id="titlearea">
30 <table cellspacing="0" cellpadding="0">
31  <tbody>
32  <tr style="height: 46px;">
33   <td id="projectlogo"><img alt="Logo" src="keilarm.png"/></td>
34   <td style="padding-left: 0.5em;">
35    <div id="projectname">CMSIS-Driver Validation
36    &#160;<span id="projectnumber">Version 3.0.0</span>
37    </div>
38    <div id="projectbrief">Driver Validation</div>
39   </td>
40  </tr>
41  </tbody>
42 </table>
43 </div>
44 <!-- end header part -->
45 <div id="DRVnav" class="tabs1">
46     <ul class="tablist">
47       <script type="text/javascript">
48                 <!--
49                 writeComponentTabs.call(this);
50                 //-->
51       </script>
52           </ul>
53 </div>
54 <!-- Generated by Doxygen 1.8.6 -->
55 <script type="text/javascript">
56 var searchBox = new SearchBox("searchBox", "search",false,'Search');
57 </script>
58   <div id="navrow1" class="tabs">
59     <ul class="tablist">
60       <li><a href="index.html"><span>Main&#160;Page</span></a></li>
61       <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
62       <li><a href="modules.html"><span>Reference</span></a></li>
63       <li>
64         <div id="MSearchBox" class="MSearchBoxInactive">
65         <span class="left">
66           <img id="MSearchSelect" src="search/mag_sel.png"
67                onmouseover="return searchBox.OnSearchSelectShow()"
68                onmouseout="return searchBox.OnSearchSelectHide()"
69                alt=""/>
70           <input type="text" id="MSearchField" value="Search" accesskey="S"
71                onfocus="searchBox.OnSearchFieldFocus(true)" 
72                onblur="searchBox.OnSearchFieldFocus(false)" 
73                onkeyup="searchBox.OnSearchFieldChange(event)"/>
74           </span><span class="right">
75             <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
76           </span>
77         </div>
78       </li>
79     </ul>
80   </div>
81 </div><!-- top -->
82 <div id="side-nav" class="ui-resizable side-nav-resizable">
83   <div id="nav-tree">
84     <div id="nav-tree-contents">
85       <div id="nav-sync" class="sync"></div>
86     </div>
87   </div>
88   <div id="splitbar" style="-moz-user-select:none;" 
89        class="ui-resizable-handle">
90   </div>
91 </div>
92 <script type="text/javascript">
93 $(document).ready(function(){initNavTree('group__spi__server.html','');});
94 </script>
95 <div id="doc-content">
96 <!-- window showing the filter options -->
97 <div id="MSearchSelectWindow"
98      onmouseover="return searchBox.OnSearchSelectShow()"
99      onmouseout="return searchBox.OnSearchSelectHide()"
100      onkeydown="return searchBox.OnSearchSelectKey(event)">
101 <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>Files</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>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>
102
103 <!-- iframe showing the search results (closed by default) -->
104 <div id="MSearchResultsWindow">
105 <iframe src="javascript:void(0)" frameborder="0" 
106         name="MSearchResults" id="MSearchResults">
107 </iframe>
108 </div>
109
110 <div class="header">
111   <div class="headertitle">
112 <div class="title">SPI Server<div class="ingroups"><a class="el" href="group__dv__spi.html">SPI Validation</a></div></div>  </div>
113 </div><!--header-->
114 <div class="contents">
115 <p>The <b>SPI Server</b> is an application providing a set of features used by the CMSIS-Driver Validation suite to test the physical operation of the SPI driver.<br/>
116  It is located in the <code>&lt;pack root directory&gt;</code><b>\Tools\SPI_Server</b> directory.</p>
117 <p>The SPI Server offers the following features:</p>
118 <ul>
119 <li>read of the <b>version</b> information</li>
120 <li>read of the <b>capabilities</b> information</li>
121 <li>set and read of the <b>data buffers content</b></li>
122 <li>read of the last <b>transfer count</b></li>
123 <li><b>transfer</b> in Slave or Master mode</li>
124 </ul>
125 <h1><a class="anchor" id="spi_server_oper"></a>
126 Operation</h1>
127 <p>The SPI Server is continuously waiting on a command from the SPI Client (Driver Validation), after the command is received it is executed, and the process repeats.<br/>
128  Most commands do not have any additional related data phase, but some do have additional input or output data exchange phase following the command.</p>
129 <p>The SPI Server behaves as an SPI Slave except when command for Master transfer was requested, in which case it executes the requested Master transfer and reverts to Slave mode.</p>
130 <h1><a class="anchor" id="spi_server_config"></a>
131 Configuration</h1>
132 <p>Communication interface settings used during command exchange are set in the <b>SPI_Server_Config.h</b> configuration file. </p>
133 <div class="image">
134 <img src="spi_server_config_h.png" alt="spi_server_config_h.png"/>
135 <div class="caption">
136 SPI_Server_Config.h configuration file in Configuration Wizard view mode</div></div>
137  <h2><a class="anchor" id="spi_server_config_detail"></a>
138 Configuration settings</h2>
139 <p><b>Driver_SPI#</b> selects the driver instance used by the SPI Server.<br/>
140  Communication settings used for command exchange with the SPI Client are fixed to:</p>
141 <ul>
142 <li><b>Mode: Slave with Slave Select Hardware monitored</b></li>
143 <li><b>Clock / Frame Format: Clock Polarity 0/ Clock Phase 0</b></li>
144 <li><b>Data Bits: 8</b></li>
145 <li><b>Bit Order: MSB to LSB</b></li>
146 </ul>
147 <dl class="section note"><dt>Note</dt><dd>The SPI Server is receiving commands operating in SPI Slave mode with usage of the Slave Select line </dd>
148 <dd>
149 The SPI driver used by the SPI Server must support Hardware monitored Slave Select functionality</dd></dl>
150 <h1><a class="anchor" id="spi_server_commands"></a>
151 Commands</h1>
152 <p>Commands are encoded in human readable format (ASCII strings) so they can be viewed by the SPI bus analyzer and analyzed more easily.</p>
153 <p>Supported commands:</p>
154 <ul>
155 <li><b>GET VER</b>: used to retrieve version of the SPI Server application</li>
156 <li><b>GET CAP</b>: used to retrieve capabilities of the SPI Server (the Server auto-detects capabilities upon reception of this command)</li>
157 <li><b>SET BUF</b>: used to initialize receive or transmit buffer content of the SPI Server</li>
158 <li><b>GET BUF</b>: used to retrieve receive or transmit buffer content of the SPI Server</li>
159 <li><b>SET COM</b>: used to specify transfer configuration for the next transfer</li>
160 <li><b>XFER</b>: used to trigger a transfer</li>
161 <li><b>GET CNT</b>: used to retrieve number of transferred items in the last transfer</li>
162 </ul>
163 <dl class="section note"><dt>Note</dt><dd>For details about commands please refer to <b>Abstract.txt</b> file in the <code>&lt;pack root directory&gt;</code>\Tools\SPI_Server\Board\MCBSTM32F400 directory.</dd></dl>
164 <p>Picture below shows a capture of SPI Driver Validation validating functionality of the Master transfer with Slave Select line not used </p>
165 <div class="image">
166 <img src="spi_bus_master_ss_hw_ctrl_out.png" alt="spi_bus_master_ss_hw_ctrl_out.png"/>
167 </div>
168 <h1><a class="anchor" id="spi_server_porting"></a>
169 Porting SPI Server to other targets</h1>
170 <p>To create SPI Server application for a different target device, follow the steps below:</p>
171 <ol type="1">
172 <li>Create a new project in µVision for your target device</li>
173 <li>In the RTE window enable and configure the following software components:<ul>
174 <li><b>CMSIS: CORE</b></li>
175 <li><b>CMSIS: RTOS2 (API): Keil RTX5</b> any variant</li>
176 <li><b>CMSIS Driver: SPI (API)</b></li>
177 <li><b>CMSIS Driver: VIO (API)</b> select <b>Virtual</b> implementation if implementation for your target system is not available</li>
178 <li>Generic device specific components (startup, clock system, I/O, ...) as required (please consult device's documentation for more information)</li>
179 <li>Resolve any unresolved dependencies between components</li>
180 </ul>
181 </li>
182 <li>Copy the <b>SPI_Server.c</b> file from the <code>&lt;pack root directory&gt;</code><b>\Tools\SPI_Server\Source</b> directory to the project root and add it to µVision project</li>
183 <li>Copy the <b>SPI_Server.h</b> file from the <code>&lt;pack root directory&gt;</code><b>\Tools\SPI_Server\Include</b> directory to the project root</li>
184 <li>Copy the <b>SPI_Server_Config.h</b> file from the <code>&lt;pack root directory&gt;</code><b>\Tools\SPI_Server\Config</b> directory to the project root and adapt this file as required by your device</li>
185 <li>Add root of the project to include path (<b>Options for Target</b> -&gt; <b>C/C++</b> -&gt; <b>Include Paths: .\</b>)</li>
186 <li>Add the <b>main.c</b> file from a template (Right-click <b>Source Group 1...</b> and select <b>Add New Item to Group</b>, select <b>User Code Template</b> and choose the <b>CMSIS-RTOS2 'main' function</b> file from <b>CMSIS: RTOS2:Keil RTX5</b>) and update with code snippet below (replace <code>app_main</code> function): <div class="fragment"><div class="line"><span class="preprocessor">#include &quot;SPI_Server.h&quot;</span></div>
187 <div class="line"> </div>
188 <div class="line"><span class="comment">/*----------------------------------------------------------------------------</span></div>
189 <div class="line"><span class="comment"> * Application main thread</span></div>
190 <div class="line"><span class="comment"> *---------------------------------------------------------------------------*/</span></div>
191 <div class="line">__NO_RETURN <span class="keyword">static</span> <span class="keywordtype">void</span> app_main (<span class="keywordtype">void</span> *argument) {</div>
192 <div class="line">  (void)argument;</div>
193 <div class="line">  SPI_Server_Start();</div>
194 <div class="line">  <span class="keywordflow">for</span> (;;) {}</div>
195 <div class="line">}</div>
196 </div><!-- fragment --></li>
197 <li>Ensure that system has at least 10kB of heap available for the transfer buffers (this is usually set in the startup file of the device)</li>
198 <li>Build and download the ported SPI Server application to the target device</li>
199 </ol>
200 <h1><a class="anchor" id="spi_server_troubleshooting"></a>
201 Troubleshooting</h1>
202 <p>Problems and solutions:</p>
203 <ol type="1">
204 <li>SPI Server is not responding to commands<ul>
205 <li>reset the SPI Server</li>
206 <li>check that correct driver instance is selected in the SPI_Server_Config.h file</li>
207 <li>reduce bus speed used for communication with the SPI Server (in the DV_SPI_Config.h file)</li>
208 </ul>
209 </li>
210 <li>SPI Server is not responding to commands it reports "Server Start failed!" message if debug variant is used<ul>
211 <li>check heap settings (it has to be larger than 2 * SPI_SERVER_BUF_SIZE specified in the SPI_Server_Config.h file)</li>
212 <li>check that RTOS allows allocation of at least 512 bytes for the SPI Server main thread (Global Dynamic Memory size [bytes] setting in RTX_Config.h file if RTX5 is used)</li>
213 </ul>
214 </li>
215 <li>tests report data mismatch<ul>
216 <li>check that Slave Select line has a pull-up to Vcc line</li>
217 <li>check that wires are separate and short as possible</li>
218 <li>insure if possible that SCK and GND wires are a twisted pair</li>
219 <li>insure that SPI driver in inactive mode does not drive Slave Select line</li>
220 </ul>
221 </li>
222 </ol>
223 <h1><a class="anchor" id="spi_server_MCBSTM32F400"></a>
224 SPI Server on the Keil MCBSTM32F400 board</h1>
225 <p>µVision project and source files for the MCBSTM32F400 board are available in the <code>&lt;pack root directory&gt;</code><b>\Tools\SPI_Server\Board\MCBSTM32F400</b> directory.</p>
226 <p>On the Keil MCBSTM32F400 board the <b>SPI2</b> interface is used, with the following pinout:</p>
227 <table class="doxtable">
228 <tr>
229 <th align="left">SPI function </th><th align="center">Pin  </th></tr>
230 <tr>
231 <td align="left">SPI Clock </td><td align="center">PB10 </td></tr>
232 <tr>
233 <td align="left">Master Output Slave Input (MOSI) </td><td align="center">PB15 </td></tr>
234 <tr>
235 <td align="left">Master Input Slave Output (MISO) </td><td align="center">PB14 </td></tr>
236 <tr>
237 <td align="left">Slave Select </td><td align="center">PI0 </td></tr>
238 </table>
239 <dl class="section note"><dt>Note</dt><dd>IMPORTANT: Ground must be connected between SPI Server and Device (Driver) Under Test so that SPI signals have same ground potential.</dd></dl>
240 <p>For more information please consult <b>Abstract.txt</b> file in the project root.</p>
241 <dl class="section note"><dt>Note</dt><dd>SPI Server on the Keil MCBSTM32F400 does not support National Semiconductor Microwire Frame Format.</dd></dl>
242 <h1><a class="anchor" id="spi_server_STM32F429I_DISC1"></a>
243 SPI Server on the STMicroelectronics STM32F429I-DISC1 (32F429IDISCOVERY) board</h1>
244 <p>µVision project and source files for the STM32F429I-DISC1 board are available in the <code>&lt;pack root directory&gt;</code><b>\Tools\SPI_Server\Board\STM32F429I-DISC1</b> directory.</p>
245 <p>On the STMicroelectronics STM32F429I-DISC1 board the <b>SPI1</b> interface is used, with the following pinout:</p>
246 <table class="doxtable">
247 <tr>
248 <th align="left">SPI function </th><th align="center">Pin  </th></tr>
249 <tr>
250 <td align="left">SPI Clock </td><td align="center">PA5 </td></tr>
251 <tr>
252 <td align="left">Master Output Slave Input (MOSI) </td><td align="center">PA7 </td></tr>
253 <tr>
254 <td align="left">Master Input Slave Output (MISO) </td><td align="center">PB4 </td></tr>
255 <tr>
256 <td align="left">Slave Select </td><td align="center">PA15 </td></tr>
257 </table>
258 <dl class="section note"><dt>Note</dt><dd>IMPORTANT: Ground must be connected between SPI Server and Device (Driver) Under Test so that SPI signals have same ground potential.</dd></dl>
259 <p>For more information please consult <b>Abstract.txt</b> file in the project root.</p>
260 <dl class="section note"><dt>Note</dt><dd>SPI Server on the STMicroelectronics STM32F429I-DISC1 does not support National Semiconductor Microwire Frame Format. </dd></dl>
261 </div><!-- contents -->
262 </div><!-- doc-content -->
263 <!-- start footer part -->
264 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
265   <ul>
266     <li class="footer">Generated on Fri Jul 15 2022 08:42:08 for CMSIS-Driver Validation by ARM Ltd. All rights reserved.
267         <!--
268     <a href="http://www.doxygen.org/index.html">
269     <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 
270         -->
271         </li>
272   </ul>
273 </div>
274 </body>
275 </html>