HAL SPI loopback

This example demonstrates the usage of the SPI HAL APIs for communication in a loopback configuration. The application performs the following operations:

  1. Configures two SPI instances - one as Controller (master) and one as Target (slave)

  2. Demonstrates how to transmit data using polling mode from the Controller

  3. Demonstrates how to receive data using interrupt mode on the Target

  4. Verifies the received data matches the transmitted data

The example transmits a test pattern (sequential values 0-255) and verifies proper reception by comparing the data received by the Target with the data sent by the Controller.

Example Usage

  1. Build and Load the example to your device

  2. The example initializes the SPI Controller and Target instances

  3. It prepares a test pattern (sequential values 0-255) in the Controller transmit buffer

  4. The Target is set up to receive data using interrupt mode

  5. The Controller transmits the data using polling mode

  6. The application verifies that the received data matches the transmitted data

  7. If successful, “All Test Passes!” will be displayed on the console

Key features demonstrated:

  • SPI HAL initialization and configuration for both Controller and Target modes

  • Polling-based transmission from Controller

  • Interrupt-based reception on Target

  • Proper callback handling for interrupt operations

  • Error detection and status checking

External Connections

This example uses the SPGSS inter-module internal loopback between unicomms, so no external wiring is required by default.

If the unicomm instance used for the Controller or Target is changed, update the loopback macros in app_cfg.h to match. Alternatively, external loopback can be used instead by externally connecting the Controller and Target SPI pins.