/*=======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
and must be same as configured on the SPI Server.
- Some settings are fixed and cannot be changed, these are the following ones:
- Clock / Frame Format: Clock Polarity 0/ Clock Phase 0
- Data Bits: 8
- Bit Order: MSB to LSB
- Settings configurable 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.
- 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 specify 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 selection 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.
- Event allows enabling or disabling of the whole 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_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
\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 used for command exchange with the SPI Client are fixed to:
- Mode: Slave with Slave Select Hardware monitored
- Clock / Frame Format: Clock Polarity 0/ Clock Phase 0
- Data Bits: 8
- Bit Order: MSB to LSB
\note The SPI Server is receiving commands operating in SPI Slave mode with usage of the Slave Select line
\note The SPI driver used by the SPI Server must support Hardware monitored Slave Select functionality
\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_hw_ctrl_out.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 file from the \\\Tools\\SPI_Server\\Include
directory to the project root
-# Copy the SPI_Server_Config.h file from the \\\Tools\\SPI_Server\\Config
directory to the project root and adapt this file as required by your device
-# 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
-# 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)
-# 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 correct driver instance is selected in the SPI_Server_Config.h file
- reduce bus speed used for communication with the SPI Server (in the DV_SPI_Config.h file)
2. SPI Server is not responding to commands it reports "Server Start failed!" message
if debug variant is used
- check heap settings
(it has to be larger than 2 * SPI_SERVER_BUF_SIZE specified in the SPI_Server_Config.h file)
- 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)
3. tests report data mismatch
- check that Slave Select line has a pull-up to Vcc line
- check that wires are separate and short as possible
- insure if possible that SCK and GND wires are a twisted pair
- insure that SPI driver in inactive mode does not drive Slave Select line
\section spi_server_MCBSTM32F400 SPI Server on the Keil MCBSTM32F400 board
µVision project and source files for the MCBSTM32F400 board are available in the \\\Tools\\SPI_Server\\Board\\MCBSTM32F400 directory.
On the Keil MCBSTM32F400 board 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.
\section spi_server_STM32F429I_DISC1 SPI Server on the STMicroelectronics STM32F429I-DISC1 (32F429IDISCOVERY) board
µVision project and source files for the STM32F429I-DISC1 board are available in the \\\Tools\\SPI_Server\\Board\\STM32F429I-DISC1 directory.
On the STMicroelectronics STM32F429I-DISC1 board the SPI1 interface is used, with the following pinout:
| SPI function | Pin |
| :------------------------------- | :----: |
| SPI Clock | PA5 |
| Master Output Slave Input (MOSI) | PA7 |
| Master Input Slave Output (MISO) | PB4 |
| Slave Select | PA15 |
\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 STMicroelectronics STM32F429I-DISC1 does not support National Semiconductor Microwire Frame Format.
*/