| Kinetis SDK API Reference Manual 1.0.0-beta Freescale Semiconductor, Inc.

- Introduction
- Related Pages
- API Usage

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Enumerations
fsl_spi_hal.h File Reference
SPI HAL driver
`#include "fsl_spi_features.h"`
`#include "fsl_device_registers.h"`
`#include <stdint.h>`
`#include <stdbool.h>`
`#include <assert.h>`

## Data Structures
struct | spi_config_t
| SPI hardware configuration settings. More...

## Enumerations
enum | spi_status_t { kStatus_SPI_Success = 0, kStatus_SPI_SlaveTxUnderrun, kStatus_SPI_SlaveRxOverrun, kStatus_SPI_Timeout, kStatus_SPI_Busy, kStatus_SPI_NoTransferInProgress }
| Error codes for the SPI driver. More...
enum | spi_master_slave_mode_t { kSpiMaster = 1, kSpiSlave = 0 }
| SPI master or slave configuration. More...
enum | spi_clock_polarity_t { kSpiClockPolarity_ActiveHigh = 0, kSpiClockPolarity_ActiveLow = 1 }
| SPI clock polarity configuration. More...
enum | spi_clock_phase_t { kSpiClockPhase_FirstEdge = 0, kSpiClockPhase_SecondEdge = 1 }
| SPI clock phase configuration. More...
enum | spi_shift_direction_t { kSpiMsbFirst = 0, kSpiLsbFirst = 1 }
| SPI data shifter direction options. More...
enum | spi_ss_output_mode_t { kSpiSlaveSelect_AsGpio = 0, kSpiSlaveSelect_FaultInput = 2, kSpiSlaveSelect_AutomaticOutput = 3 }
| SPI slave select output mode options. More...
enum | spi_pin_mode_t { kSpiPinMode_Normal = 0, kSpiPinMode_Input = 1, kSpiPinMode_Output = 3 }
| SPI pin mode options. More...

## Functions
Configuration
void | spi_hal_init (uint32_t instance, const spi_config_t *config)
| Configures the SPI peripheral.
void | spi_hal_reset (uint32_t instance)
| Restores the SPI to reset the configuration.
static void | spi_hal_enable (uint32_t instance)
| Enables the SPI peripheral.
static void | spi_hal_disable (uint32_t instance)
| Disables the SPI peripheral.
void | spi_hal_set_baud (uint32_t instance, uint32_t kbitsPerSec)
| Sets the SPI baud rate in kilobits per second.
static void | spi_hal_set_baud_divisors (uint32_t instance, uint32_t prescaleDivisor, uint32_t rateDivisor)
| Configures the baud rate divisors manually.
static void | spi_hal_set_master_slave (uint32_t instance, spi_master_slave_mode_t mode)
| Configures the SPI for master or slave.
void | spi_hal_set_slave_select_output_mode (uint32_t instance, spi_ss_output_mode_t mode)
| Sets how the slave select output operates.
void | spi_hal_set_data_format (uint32_t instance, spi_clock_polarity_t polarity, spi_clock_phase_t phase, spi_shift_direction_t direction)
| Sets the polarity, phase, and shift direction.
void | spi_hal_set_pin_mode (uint32_t instance, spi_pin_mode_t mode)
| Sets the SPI pin mode.
DMA
void | spi_hal_configure_dma (uint32_t instance, bool enableTransmit, bool enableReceive)
| Configures the transmit and receive DMA requests.
Low power
static void | spi_hal_configure_stop_in_wait_mode (uint32_t instance, bool enable)
| Enables or disables the SPI clock to stop when the CPU enters wait mode.
Interrupts
static void | spi_hal_enable_receive_and_fault_interrupt (uint32_t instance)
| Enables the receive buffer full and mode fault interrupt.
static void | spi_hal_disable_receive_and_fault_interrupt (uint32_t instance)
| Disables the receive buffer full and mode fault interrupt.
static void | spi_hal_enable_transmit_interrupt (uint32_t instance)
| Enables the transmit buffer empty interrupt.
static void | spi_hal_disable_transmit_interrupt (uint32_t instance)
| Disables the transmit buffer empty interrupt.
static void | spi_hal_enable_match_interrupt (uint32_t instance)
| Enables the match interrupt.
static void | spi_hal_disable_match_interrupt (uint32_t instance)
| Disables the match interrupt.
Status
static bool | spi_hal_is_read_buffer_full (uint32_t instance)
| Checks whether the read buffer is full. More...
static bool | spi_hal_is_transmit_buffer_empty (uint32_t instance)
| Checks whether the transmit buffer is empty. More...
static bool | spi_hal_is_mode_fault (uint32_t instance)
| Checks whether a mode fault occurred.
void | spi_hal_clear_mode_fault (uint32_t instance)
| Clears the mode fault flag.
static bool | spi_hal_is_match (uint32_t instance)
| Checks whether the data received matches the previously-set match value.
void | spi_hal_clear_match (uint32_t instance)
| Clears the match flag.
Data transfer
static uint8_t | spi_hal_read_data (uint32_t instance)
| Reads a byte from the data buffer.
static void | spi_hal_write_data (uint32_t instance, uint8_t data)
| Writes a byte into the data buffer.
Match byte
static void | spi_hal_set_match_value (uint32_t instance, uint8_t matchByte)
| Sets the value which triggers the match interrupt.