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:
Configures two SPI instances - one as Controller (master) and one as Target (slave)
Demonstrates how to transmit data using polling mode from the Controller
Demonstrates how to receive data using interrupt mode on the Target
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
Build and Load the example to your device
The example initializes the SPI Controller and Target instances
It prepares a test pattern (sequential values 0-255) in the Controller transmit buffer
The Target is set up to receive data using interrupt mode
The Controller transmits the data using polling mode
The application verifies that the received data matches the transmitted data
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.