]> begriffs open source - cmsis-driver-validation/blob - Doxygen/src/DV_SPI.txt
Updated Readme with ref to use Doxygen 1.9.2
[cmsis-driver-validation] / Doxygen / src / DV_SPI.txt
1 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2 /**
3 \defgroup spi_config Configuration
4 \ingroup  dv_spi
5
6 The SPI driver validation settings are available in the <b>DV_SPI_Config.h</b> configuration file.
7
8 \image html dv_spi_config_h.png "DV_SPI_Config.h configuration file in Configuration Wizard view mode"
9
10 Some settings depend on the test environment and need to be changed for proper operation of the SPI driver validation.<br>
11
12 \section spi_config_detail Configuration settings
13
14 <b>Driver_SPI#</b> selects the driver instance that will be tested.<br>
15 For example if we want to test <c>Driver_SPI2</c> then this setting would be set to <c>2</c>.
16
17 <b>Configuration</b> section contains configuration of: Test Mode, SPI Server and Tests settings:
18 - <b>Test Mode</b> can be set to <b>Loopback</b> or <b>SPI Server</b>.<br>
19   Loopback mode should be used for initial validation.<br>
20   Loopback mode requires that MOSI and MISO pins are connected together thus driver validation can test basic 
21   functionality in the Master mode.<br>
22   <b>For full compliance of the SPI driver with the CMSIS-Driver SPI specification the SPI Server Test Mode has to be used.</b>
23 - <b>SPI Server</b> settings are relevant if <b>Test Mode: SPI Server</b> is selected.<br>
24   These settings specify communication settings at which Driver Validation communicates with the SPI Server<br>
25   and <b>must be same as configured on the SPI Server.</b>   
26   - Some settings are fixed and cannot be changed, these are the following ones:
27     - <b>Clock / Frame Format: Clock Polarity 0/ Clock Phase 0</b>
28     - <b>Data Bits: 8</b>
29     - <b>Bit Order: MSB to LSB</b>   
30   - Settings configurable for the SPI Server are:
31     - <b>Slave Select</b> setting specifies the way that Slave Select line will be handled by the driver under test.<br>
32       SPI Server requires that commands are exchanged with Slave Select line used, so driver being tested must support 
33       Slave Select line handling.<br>
34       <b>Software Controlled</b> selection means that driver will use software controlled driving of the Slave Select line by 
35       calling driver <c>Control</c> function with <c>ARM_SPI_CONTROL_SS</c> control code to activate Slave Select Line 
36       before the transfer and deactivate it after the transfer.<br>
37       <b>Hardware Controlled</b> selection means that driver will use hardware controlled driving of the Slave Select line.
38     - <b>Bus Speed</b> setting specifies the nominal bus speed used to exchange commands with the SPI Server.<br>
39       This setting should be set to a speed guaranteeing reliable command exchange with the SPI Server.
40 - <b>Tests</b> settings specify tests configuration:
41   - <b>Default settings</b> specifies the default settings used in the data exchange tests.<br>
42     Usually, one feature is tested by executing the data exchange while all other parameters are used as default.<br>
43     For details on which parameters are used as default in each test function please refer to \ref spi_tests_data_xchg
44     functions documentation.
45   - <b>Bus Speed</b> settings specifies minimum and maximum bus speeds at which data transfer will be executed.<br>
46     These settings are used by the \ref SPI_Bus_Speed_Min and \ref SPI_Bus_Speed_Max test functions.
47   - <b>Number of Items</b> settings specifies a few different number of items to be tested.<br>
48     These settings are used by the \ref SPI_Number_Of_Items test function which tests that odd and unusual number of items 
49     are transferred correctly according to the CMSIS-Driver specification.
50
51 <b>Tests</b> section contains selection of tests to be executed:
52 - <b>Driver Management</b> allows enabling or disabling of the whole driver management group of test functions.<br>
53   Each test function in this group can be enabled or disabled individually, for details on tests performed 
54   by each test function please refer to \ref spi_tests_drv_mgmt documentation.
55 - <b>Data Exchange</b> allows enabling or disabling of the whole data exchange group of test functions.<br>
56   Each test function in this group can be enabled or disabled individually, for details on tests performed 
57   by each test function please refer to \ref spi_tests_data_xchg documentation.
58 - <b>Event</b> allows enabling or disabling of the whole event group of test functions.<br>
59   Each test function in this group can be enabled or disabled individually, for details on tests performed 
60   by each test function please refer to \ref spi_tests_evt documentation.
61 */
62
63
64 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
65 /**
66 \defgroup spi_server SPI Server
67 \ingroup  dv_spi
68
69 The <b>SPI Server</b> is an application providing a set of features used by the CMSIS-Driver Validation suite to test the
70 physical operation of the SPI driver.<br>
71 It is located in the <c>\<pack root directory\></c><b>\\Tools\\SPI_Server</b> directory.
72
73 The SPI Server offers the following features:
74 - read of the <b>version</b> information
75 - read of the <b>capabilities</b> information
76 - set and read of the <b>data buffers content</b>
77 - read of the last <b>transfer count</b>
78 - <b>transfer</b> in Slave or Master mode
79
80 \section spi_server_oper Operation
81
82 The SPI Server is continuously waiting on a command from the SPI Client (Driver Validation), 
83 after the command is received it is executed, and the process repeats.<br>
84 Most commands do not have any additional related data phase, but some do have additional input or output 
85 data exchange phase following the command.
86
87 The SPI Server behaves as an SPI Slave except when command for Master transfer was requested, in which case it 
88 executes the requested Master transfer and reverts to Slave mode.
89
90 \section spi_server_config Configuration
91
92 Communication interface settings used during command exchange are set in the <b>SPI_Server_Config.h</b> configuration file. 
93 \image html spi_server_config_h.png "SPI_Server_Config.h configuration file in Configuration Wizard view mode"
94
95 \subsection spi_server_config_detail Configuration settings
96
97 <b>Driver_SPI#</b> selects the driver instance used by the SPI Server.<br>
98 Communication settings used for command exchange with the SPI Client are fixed to:
99   - <b>Mode: Slave with Slave Select Hardware monitored</b>
100   - <b>Clock / Frame Format: Clock Polarity 0/ Clock Phase 0</b>
101   - <b>Data Bits: 8</b>
102   - <b>Bit Order: MSB to LSB</b>   
103
104 \note The SPI Server is receiving commands operating in SPI Slave mode with usage of the Slave Select line
105 \note The SPI driver used by the SPI Server must support Hardware monitored Slave Select functionality
106
107 \section spi_server_commands Commands
108
109 Commands are encoded in human readable format (ASCII strings) so they can be viewed by the SPI bus analyzer 
110 and analyzed more easily.
111
112 Supported commands:
113  - <b>GET VER</b>: used to retrieve version of the SPI Server application
114  - <b>GET CAP</b>: used to retrieve capabilities of the SPI Server 
115                    (the Server auto-detects capabilities upon reception of this command)
116  - <b>SET BUF</b>: used to initialize receive or transmit buffer content of the SPI Server
117  - <b>GET BUF</b>: used to retrieve receive or transmit buffer content of the SPI Server
118  - <b>SET COM</b>: used to specify transfer configuration for the next transfer
119  - <b>XFER</b>:    used to trigger a transfer
120  - <b>GET CNT</b>: used to retrieve number of transferred items in the last transfer
121
122 \note For details about commands please refer to <b>Abstract.txt</b> file in the 
123 <c>\<pack root directory\></c>\\Tools\\SPI_Server\\Board\\MCBSTM32F400 directory.
124
125 Picture below shows a capture of SPI Driver Validation validating functionality of the Master transfer with Slave Select 
126 line not used \image html spi_bus_master_ss_hw_ctrl_out.png
127
128 \section spi_server_porting Porting SPI Server to other targets
129
130 To create SPI Server application for a different target device, follow the steps below:
131 -# Create a new project in µVision for your target device
132 -# In the RTE window enable and configure the following software components:
133  - <b>CMSIS: CORE</b>
134  - <b>CMSIS: RTOS2 (API): Keil RTX5</b> any variant
135  - <b>CMSIS Driver: SPI (API)</b>
136  - <b>CMSIS Driver: VIO (API)</b> select <b>Virtual</b> implementation if implementation for your target system is not available
137  - Generic device specific components (startup, clock system, I/O, ...) as required 
138    (please consult device's documentation for more information)
139  - Resolve any unresolved dependencies between components
140 -# Copy the <b>SPI_Server.c</b> file from the <c>\<pack root directory\></c><b>\\Tools\\SPI_Server\\Source</b> directory 
141    to the project root and add it to µVision project
142 -# Copy the <b>SPI_Server.h</b> file from the <c>\<pack root directory\></c><b>\\Tools\\SPI_Server\\Include</b> 
143    directory to the project root
144 -# Copy the <b>SPI_Server_Config.h</b> file from the <c>\<pack root directory\></c><b>\\Tools\\SPI_Server\\Config</b> 
145    directory to the project root and adapt this file as required by your device
146 -# Add root of the project to include path (<b>Options for Target</b> -> <b>C/C++</b> -> <b>Include Paths: .\\</b>)
147 -# Add the <b>main.c</b> file from a template 
148    (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
149    <b>CMSIS-RTOS2 'main' function</b> file from <b>CMSIS: RTOS2:Keil RTX5</b>)
150    and update with code snippet below (replace <c>app_main</c> function):
151 \code
152 #include "SPI_Server.h"
153  
154 /*----------------------------------------------------------------------------
155  * Application main thread
156  *---------------------------------------------------------------------------*/
157 __NO_RETURN static void app_main (void *argument) {
158   (void)argument;
159   SPI_Server_Start();
160   for (;;) {}
161 }
162 \endcode
163 -# Ensure that system has at least 10kB of heap available for the transfer buffers
164    (this is usually set in the startup file of the device) 
165 -# Build and download the ported SPI Server application to the target device
166
167 \section spi_server_troubleshooting Troubleshooting
168
169 Problems and solutions:
170  1. SPI Server is not responding to commands
171     - reset the SPI Server
172     - check that correct driver instance is selected in the SPI_Server_Config.h file
173     - reduce bus speed used for communication with the SPI Server (in the DV_SPI_Config.h file)
174  2. SPI Server is not responding to commands it reports "Server Start failed!" message 
175     if debug variant is used
176     - check heap settings
177       (it has to be larger than 2 * SPI_SERVER_BUF_SIZE specified in the SPI_Server_Config.h file)
178     - check that RTOS allows allocation of at least 512 bytes for the SPI Server main thread
179       (Global Dynamic Memory size [bytes] setting in RTX_Config.h file if RTX5 is used)
180  3. tests report data mismatch
181     - check that Slave Select line has a pull-up to Vcc line
182     - check that wires are separate and short as possible
183     - insure if possible that SCK and GND wires are a twisted pair
184     - insure that SPI driver in inactive mode does not drive Slave Select line
185
186 \section spi_server_MCBSTM32F400 SPI Server on the Keil MCBSTM32F400 board
187
188 µVision project and source files for the MCBSTM32F400 board are available in the <c>\<pack root directory\></c><b>\\Tools\\SPI_Server\\Board\\MCBSTM32F400</b> directory.
189
190 On the Keil MCBSTM32F400 board the <b>SPI2</b> interface is used, with the following pinout:
191
192 | SPI function                     | Pin    |
193 | :------------------------------- | :----: |
194 | SPI Clock                        | PB10   |
195 | Master Output Slave Input (MOSI) | PB15   |
196 | Master Input Slave Output (MISO) | PB14   |
197 | Slave Select                     | PI0    |
198
199 \note IMPORTANT: Ground must be connected between SPI Server and Device (Driver) Under Test 
200 so that SPI signals have same ground potential.
201
202 For more information please consult <b>Abstract.txt</b> file in the project root.
203
204 \note SPI Server on the Keil MCBSTM32F400 does not support National Semiconductor Microwire Frame Format.
205
206
207 \section spi_server_STM32F429I_DISC1 SPI Server on the STMicroelectronics STM32F429I-DISC1 (32F429IDISCOVERY) board
208
209 µVision project and source files for the STM32F429I-DISC1 board are available in the <c>\<pack root directory\></c><b>\\Tools\\SPI_Server\\Board\\STM32F429I-DISC1</b> directory.
210
211 On the STMicroelectronics STM32F429I-DISC1 board the <b>SPI1</b> interface is used, with the following pinout:
212
213 | SPI function                     | Pin    |
214 | :------------------------------- | :----: |
215 | SPI Clock                        | PA5    |
216 | Master Output Slave Input (MOSI) | PA7    |
217 | Master Input Slave Output (MISO) | PB4    |
218 | Slave Select                     | PA15   |
219
220 \note IMPORTANT: Ground must be connected between SPI Server and Device (Driver) Under Test 
221 so that SPI signals have same ground potential.
222
223 For more information please consult <b>Abstract.txt</b> file in the project root.
224
225 \note SPI Server on the STMicroelectronics STM32F429I-DISC1 does not support National Semiconductor Microwire Frame Format.
226
227 */