/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\defgroup spi_config Configuration
\ingroup dv_spi
The SPI driver validation settings are available in the DV_SPI_Config.h configuration file.
\image html dv_spi_config_h.png "DV_SPI_Config.h configuration file in Configuration Wizard view mode"
Some settings depend on the test environment and need to be changed for proper operation of the SPI driver validation.
\section spi_config_detail Configuration settings
Driver_SPI# selects the driver instance that will be tested.
For example if we want to test Driver_SPI2 then this setting would be set to 2.
Configuration section contains configuration of: Test Mode, SPI Server and Tests settings:
- Test Mode can be set to Loopback or SPI Server.
Loopback mode should be used for initial validation.
Loopback mode requires that MOSI and MISO pins are connected together thus driver validation can test basic
functionality in the Master mode.
For full compliance of the SPI driver with the CMSIS-Driver SPI specification the SPI Server Test Mode has to be used.
- SPI Server settings are relevant if Test Mode: SPI Server is selected.
These settings specify communication settings at which Driver Validation communicates with the SPI Server.
These settings must be same as configured on the SPI Server.
Settings available for the SPI Server are:
- Slave Select setting specifies the way that Slave Select line will be handled by the driver under test.
SPI Server requires that commands are exchanged with Slave Select line used, so driver being tested must support
Slave Select line handling.
Software Controlled selection means that driver will use software controlled driving of the Slave Select line by
calling driver Control function with ARM_SPI_CONTROL_SS control code to activate Slave Select Line
before the transfer and deactivate it after the transfer.
Hardware Controlled selection means that driver will use hardware controlled driving of the Slave Select line.
- Clock / Frame Format setting specifies the clock or frame format used for command exchange with the SPI Server.
Both the SPI Server and the driver being tested must use the same clock / frame format setting.
- Data Bits setting specifies the number of data bits per item used for command exchange with the SPI Server.
Both the SPI Server and the driver being tested must use the same data bits setting.
- Bit Order setting specifies the bit order used for command exchange with the SPI Server.
Both the SPI Server and the driver being tested must use the same bit order setting.
- Bus Speed setting specifies the nominal bus speed used to exchange commands with the SPI Server.
This setting should be set to a speed guaranteeing reliable command exchange with the SPI Server.
- Tests settings specifies tests configuration:
- Default settings specifies the default settings used in the data exchange tests.
Usually, one feature is tested by executing the data exchange while all other parameters are used as default.
For details on which parameters are used as default in each test function please refer to \ref spi_tests_data_xchg
functions documentation.
- Bus Speed settings specifies minimum and maximum bus speeds at which data transfer will be executed.
These settings are used by the \ref SPI_Bus_Speed_Min and \ref SPI_Bus_Speed_Max test functions.
- Number of Items settings specifies a few different number of items to be tested.
These settings are used by the \ref SPI_Number_Of_Items test function which tests that odd and unusual number of items
are transferred correctly according to the CMSIS-Driver specification.
Tests section contains selections of tests to be executed:
- Driver Management allows enabling or disabling of the whole driver management group of test functions.
Each test function in this group can be enabled or disabled individually, for details on tests performed
by each test function please refer to \ref spi_tests_drv_mgmt documentation.
- Data Exchange allows enabling or disabling of the whole data exchange group of test functions.
Each test function in this group can be enabled or disabled individually, for details on tests performed
by each test function please refer to \ref spi_tests_data_xchg documentation.
- Error Event allows enabling or disabling of the whole error event group of test functions.
Each test function in this group can be enabled or disabled individually, for details on tests performed
by each test function please refer to \ref spi_tests_err_evt documentation.
*/
/*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
/**
\defgroup spi_server SPI Server
\ingroup dv_spi
The SPI Server is an application providing a set of features used by the CMSIS-Driver Validation suite to test the
physical operation of the SPI driver.
It is located in the \\\Tools\\SPI_Server directory.
The SPI Server offers the following features:
- read of the version information
- read of the capabilities information
- set and read of the data buffers content
- read of the last transfer count
- transfer in Slave or Master mode
- generation of mode fault by activation of the Slave Select line during Slave transfer
\section spi_server_oper Operation
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.
Most commands do not have any additional related data phase, but some do have additional input or output
data exchange phase following the command.
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.
\section spi_server_config Configuration
Communication interface settings used during command exchange are set in the SPI_Server_Config.h configuration file.
\image html spi_server_config_h.png "SPI_Server_Config.h configuration file in Configuration Wizard view mode"
\subsection spi_server_config_detail Configuration settings
Driver_SPI# selects the driver instance used by the SPI Server.
Communication settings specify the communication parameters for command exchange with the SPI Client:
- Clock / Frame Format setting specifies the clock or frame format used for command exchange.
- Data Bits setting specifies the number of data bits per item used for command exchange.
- Bit Order setting specifies the bit order used for command exchange.
\note The SPI Server is receiving commands operating in SPI Slave mode with usage of the Slave Select line
\section spi_server_commands Commands
Commands are encoded in human readable format (ASCII strings) so they can be viewed by the SPI bus analyzer
and analyzed more easily.
Supported commands:
- GET VER: used to retrieve version of the SPI Server application
- GET CAP: used to retrieve capabilities of the SPI Server
(the Server auto-detects capabilities upon reception of this command)
- SET BUF: used to initialize receive or transmit buffer content of the SPI Server
- GET BUF: used to retrieve receive or transmit buffer content of the SPI Server
- SET COM: used to specify transfer configuration for the next transfer
- XFER: used to trigger a transfer
- GET CNT: used to retrieve number of transferred items in the last transfer
\note For details about commands please refer to Abstract.txt file in the
\\\Tools\\SPI_Server\\Board\\MCBSTM32F400 directory.
Picture below shows a capture of SPI Driver Validation validating functionality of the Master transfer with Slave Select
line not used \image html spi_bus_master_ss_unused.png
\section spi_server_porting Porting SPI Server to other targets
To create SPI Server application for a different target device, follow the steps below:
-# Create a new project in µVision for your target device
-# In the RTE window enable and configure the following software components:
- CMSIS: CORE
- CMSIS: RTOS2 (API): Keil RTX5 any variant
- CMSIS Driver: SPI (API)
- CMSIS Driver: VIO (API) select Virtual implementation if implementation for your target system is not available
- Generic device specific components (startup, clock system, I/O, ...) as required
(please consult device's documentation for more information)
- Resolve any unresolved dependencies between components
-# Copy the SPI_Server.c file from the \\\Tools\\SPI_Server\\Source directory
to the project root and add it to µVision project
-# Copy the SPI_Server.h and SPI_Server_HW.h files from the \\\Tools\\SPI_Server\\Include
directory to the project root
-# Copy the files specified below from the directory \\\Tools\\SPI_Server\\Config
to the project root and add them to µVision project:
- SPI_Server_Config.h: also adapt this file as required by your device
- SPI_Server_HW.c: also adapt this file for your device's specific handling of the SPI Slave Select line
-# Add root of the project to include path (Options for Target -> C/C++ -> Include Paths: .\\)
-# Add the main.c file from a template
(Right-click Source Group 1... and select Add New Item to Group, select User Code Template and choose the
CMSIS-RTOS2 'main' function file from CMSIS: RTOS2:Keil RTX5)
and update with code snippet below (replace app_main function):
\code
#include "SPI_Server.h"
/*----------------------------------------------------------------------------
* Application main thread
*---------------------------------------------------------------------------*/
__NO_RETURN static void app_main (void *argument) {
(void)argument;
SPI_Server_Start();
for (;;) {}
}
\endcode
-# Build and download the ported SPI Server application to the target device
\section spi_server_troubleshooting Troubleshooting
Problems and solutions:
1. SPI Server is not responding to commands
- reset the SPI Server
- check that communication settings between SPI Server and SPI Driver Validation
are the same,
if they are not, correct them, rebuild the application and
download to the hardware
\section spi_server_MCBSTM32F400 SPI Server on the Keil MCBSTM32F400
SPI Server is currently available for the Keil MCBSTM32F400 evaluation board.
uVision project and source files are available in the \\\Tools\\SPI_Server\\Board\\MCBSTM32F400 directory.
On the Keil MCBSTM32F400 the SPI2 interface is used, with the following pinout:
| SPI function | Pin |
| :------------------------------- | :----: |
| SPI Clock | PB10 |
| Master Output Slave Input (MOSI) | PB15 |
| Master Input Slave Output (MISO) | PB14 |
| Slave Select | PI0 |
\note IMPORTANT: Ground must be connected between SPI Server and Device (Driver) Under Test
so that SPI signals have same ground potential.
For more information please consult Abstract.txt file in the project root.
\note SPI Server on the Keil MCBSTM32F400 does not support National Semiconductor Microwire Frame Format.
*/