Synopsis
CTL_STATUS_t platform_configure_spi_bus(int index,
                                        int extended_frames);
Description

platform_configure_spi_bus powers-up and initializes the SPI peripheral and configures the appropriate pins for SPI configuration on SPI bus index. The MISO, MOSI, and SCK pins are configured for shared use of those functions as returned by plaform_spi_bus_pins.

platform_configure_spi_bus guarantees to successfully configure devices for 8-bit frame sizes, or multiples thereof. If you know that all devices connected to an SPI bus require frames that are multiples of a byte, you can use platform_configure_spi_bus to configure the bus. In this case, it's likely that the Platform Library will use a hardware SPI controller to drive the bus.

If some device on the bus requires non-byte-multiple frames (for example, some SPI LCDs require 9-bit frames), then platform_configure_spi_bus will not, in general, guarantee to support those devices. If you require non-byte-multiple frame sizes, set extended_frames to a non-zero value and this will force use of a software SPI controller when the hardware controller only supports 8-bit frame sizes.

Platform notes

KL05Z, KL25Z, STM32F1, and STM32F4 SPI controllers support only 8-bit frames in hardware.

For the Arduino Uno, or compatibles using the ATmega328P such as the Arduino Pro and the Olimexino-328, the SS pin is automatically configured for shared digital output along with the hardware functions for MISO, MOSI, and SCK.

The ATmega328P will switch to SPI slave mode if SS is driven low with SS configured as an input, so the Platform Library silently configures SS as a shared output to avoid inadvertently switching to SPI slave mode.

Return Value

platform_configure_spi_bus returns a standard status code.

See Also

platform_configure_spi_bus_ex