Search by Tags

Windows CE Library - SPI Library (SPILib)


Article updated at 28 Oct 2017
Compare with Revision

Subscribe for this article updates

Attention: this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.


This library manages the SPI interfaces via polling

Current Version


Application Notes

SPILib supports up to 6 SPI ports on Colibri and Apalis modules.

The SPILib can be used in PIO-mode or DMA mode. PIO mode is more efficient for transfers < 32 SPI Words.

In SPI slave mode, data can easily get lost if packets are larger than FIFO size (32 frames on T20/T30). Use DMA mode instead.

Library API

Click here for the library API

Other Resources

Windows CE Libraries Overview

Colibri SPI

How to use SPI library

Revision History

Date Rev Change Notes
29/06/2015 V5.4 Fix default pin configuration for PXA300.
Implemented automatic default pin selection for all SPI channels on Colibri T20/T30 and Apalis T30.
Added code to detect and resolve conflicting AltFn settings on multiple pins (Tegra).
Added configuration options for Tegra (wait method, chip select number/behavior, packed mode).
Support all 6 SPI channels on T30. This is a requirement for CAN1 on Apalis T30.
Replace printf debug messages with regular debug output.
Improve stability of SPI communication on Tegra. Performance may be slightly degraded.
30/10/2014 V5.3 Fix issue on T20/T30 modules: Small SPI transfers using DMA caused the application to freeze.
Fix issue on T20/T30 modules: SPI transfers using DMA caused the application to freeze, if transfer size was not a multiple of 4.
27/05/2014 V5.2 Non-standard SPI pin configurations can now be defined as GPIO numbers instead of SODIMM pins. This is to support on-module SPI channels, e.g. for the Apalis on-module CAN controllers
Adjust default SPI pin configurations for Apalis
15/04/2014 V5.1 Add TegSpiSetWaitMethod() to choose between interrput-driven and busyLoop waiting
Use DMA-like SPI control method even in non-DMA mode to prevent possible data loss of received data.
Remove deprecated functions TegWriteSPIUnpacdked() and TegReadSPIUnpacked()
Fix issue that caused a data abort when calling SPIInit() the 2nd time
11/03/2014 V5.0 Fix bit rate calculation
Pre-allocate memory for DMA, instead of allocating it for each transfer
Performance improvements
Fix pin initialization
23/09/2013 V4.1 Change default SDK to Colibri600 / Added support for T30's SPI5 and SPI6
12/08/2013 V4.0.1 Improved performance of SPIReadWritePolling(), SPIReadPolling() and SPIWritePolling() on Tegra processors