Use SPI in real-time capable applications
Important
This is the Azure Sphere (Legacy) documentation. Azure Sphere (Legacy) is retiring on 27 September 2027, and users must migrate to Azure Sphere (Integrated) by this time. Use the Version selector located above the TOC to view the Azure Sphere (Integrated) documentation.
Azure Sphere supports Serial Peripheral Interface (SPI) in master mode. SPI is a serial interface used for communication between peripherals and integrated circuits. In contrast to I2C, SPI can be used with more complex higher speed peripherals.
This topic describes how to use SPI in real-time capable applications (RTApp). For information about using SPI in high-level applications, see Using SPI in high-level applications.
Note
The Azure Sphere OS does not reset peripherals on start-up. Your applications should ensure that peripherals are in a known-good state on start-up or after restart.
Chip select
Chip select manages the connection between a SPI master interface and a set of subordinate devices; and allows the master interface to send and receive data to each subordinate device independently. Azure Sphere supports the active-low and active-high settings for chip select, with active-low as the default setting. Only one application can use each SPI master interface at any time. The application must open the SPI master interface and identify each connected subordinate device before performing read and write operations on the interface.
MT3620 support for SPI on the real-time cores
When you configure the MT3620 dev board, you can use any ISU port as an SPI master interface. You can connect up to two subordinate devices to each ISU. When you use an ISU port as an SPI master interface, you can't use the same port as an I2C or UART interface.
The MT3620 supports SPI transactions that are up to 40 MHz.
The MT3620 doesn't support simultaneous bidirectional read and write (full-duplex) SPI operations within a single bus transaction.
The SPI specifications for the MT3620 are listed in MT3620 Support Status. The MT3620 development board user guide describes the pin layout and functions for wiring.
For register base addresses, interrupt numbers, clock rate, sampling frequency, and other details about the MT3620, see the MT3620 Datasheet and the MT3620 M4 User Manual; if questions remain, you can request details from Avnet by emailing Azure.Sphere@avnet.com.
Application manifest settings
To use the SPI APIs, you must add the SpiMaster
capability to the application manifest, and then specify each SPI master controller to the capability.
"Capabilities": {
"SpiMaster": [ "ISU0", "ISU1" ] }
Azure Sphere application manifest has more details about the application manifest.
The SPI sample applications
The CodethinkLabs repository on GitHub contains sample applications that demonstrate how to use MT3620 supported peripherals in Azure Sphere real-time capable applications. Specifically, the SPI_RTApp_MT3620_BareMetal and SPI_SDCard_RTApp_MT3620_BareMetal samples demonstrate how to incorporate an SPI peripheral in a real-time capable application.