CMSIS-Driver Validation  
Driver Validation
 All Files Functions Variables Macros Groups Pages
SPI Server

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 <pack root directory>\Tools\SPI_Server directory.

The SPI Server offers the following features:

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.

Configuration

Communication interface settings used during command exchange are set in the SPI_Server_Config.h configuration file.

spi_server_config_h.png
SPI_Server_Config.h configuration file in Configuration Wizard view mode

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:

Note
The SPI Server is receiving commands operating in SPI Slave mode with usage of the Slave Select line
The SPI driver used by the SPI Server must support Hardware monitored Slave Select functionality

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:

Note
For details about commands please refer to Abstract.txt file in the <pack root directory>\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

spi_bus_master_ss_hw_ctrl_out.png

Porting SPI Server to other targets

To create SPI Server application for a different target device, follow the steps below:

  1. Create a new project in µVision for your target device
  2. 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
  3. Copy the SPI_Server.c file from the <pack root directory>\Tools\SPI_Server\Source directory to the project root and add it to µVision project
  4. Copy the SPI_Server.h file from the <pack root directory>\Tools\SPI_Server\Include directory to the project root
  5. Copy the SPI_Server_Config.h file from the <pack root directory>\Tools\SPI_Server\Config directory to the project root and adapt this file as required by your device
  6. Add root of the project to include path (Options for Target -> C/C++ -> Include Paths: .\)
  7. 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):
    #include "SPI_Server.h"
    /*----------------------------------------------------------------------------
    * Application main thread
    *---------------------------------------------------------------------------*/
    __NO_RETURN static void app_main (void *argument) {
    (void)argument;
    SPI_Server_Start();
    for (;;) {}
    }
  8. 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)
  9. Build and download the ported SPI Server application to the target device

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

SPI Server on the Keil MCBSTM32F400 board

µVision project and source files for the MCBSTM32F400 board are available in the <pack root directory>\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.

SPI Server on the STMicroelectronics STM32F429I-DISC1 (32F429IDISCOVERY) board

µVision project and source files for the STM32F429I-DISC1 board are available in the <pack root directory>\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.