ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fsl_spi_master_driver.c File Reference

fsl_spi_master_driver.c implements spi master driver layer. More...

#include "fsl_spi_master_driver.h"
#include "isf_fsl_spi_master_PEx.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "mqxlite.h"
#include "lwmem.h"
#include "isf_util.h"
Include dependency graph for fsl_spi_master_driver.c:

Go to the source code of this file.

Functions

void spi_master_init (uint32_t instance)
 Initialize a SPI instance for master mode operation. More...
 
void spi_master_configure_bus (uint32_t instance, const spi_user_config_t *device)
 Configure the SPI port to access a device on the bus. More...
 
spi_status_t spi_master_transfer (uint32_t instance, const spi_user_config_t *device, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount, uint32_t timeout)
 Perform a blocking SPI master mode transfer. More...
 
spi_status_t spi_master_transfer_async (uint32_t instance, const spi_user_config_t *device, const uint8_t *sendBuffer, uint8_t *receiveBuffer, uint16_t transferByteCount)
 Perform an non-blocking SPI master mode transfer. More...
 

Variables

uint8 gSys_NumSpiBuses
 
spi_master_instance_PEx spi_master_instance_tbl []
 Lookup table for the LLD instance. More...
 
spi_master_state_t spi_master_state []
 

Detailed Description

fsl_spi_master_driver.c implements spi master driver layer.

File: fsl_spi_master_driver.c

Copyright (c) 2014, Freescale Semiconductor, Inc.

Definition in file fsl_spi_master_driver.c.

Function Documentation

void spi_master_configure_bus ( uint32_t  instance,
const spi_user_config_t device 
)

Configure the SPI port to access a device on the bus.

Parameters
instanceThe instance number of the SPI peripheral.
devicePointer to the device information struct. This struct contains the settings for how the SPI bus will be configured.

Definition at line 60 of file fsl_spi_master_driver.c.

Referenced by spi_master_adapter_configure().

Here is the caller graph for this function:

void spi_master_init ( uint32_t  instance)

Initialize a SPI instance for master mode operation.

Parameters
instanceThe instance number of the SPI peripheral.

Definition at line 43 of file fsl_spi_master_driver.c.

References spi_master_instance_PEx::fnSPILLDInit, gSys_NumSpiBuses, and SPI_Master_State::pDeviceHandle.

Referenced by spi_master_adapter_init().

Here is the caller graph for this function:

spi_status_t spi_master_transfer ( uint32_t  instance,
const spi_user_config_t device,
const uint8_t *  sendBuffer,
uint8_t *  receiveBuffer,
uint16_t  transferByteCount,
uint32_t  timeout 
)

Perform a blocking SPI master mode transfer.

This function simultaneously sends and receives data on the SPI bus, as SPI is naturally a full-duplex bus.

Parameters
instanceThe instance number of the SPI peripheral.
devicePointer to the device information struct. This struct contains the settings for how the SPI bus will be configured for this transfer. You may pass NULL for this parameter, in which case the current bus configuration is used unmodified.
sendBufferBuffer of data to send. You may pass NULL for this parameter, in which case bytes with a value of 0 (zero) will be sent.
receiveBufferBuffer where received bytes are stored. If you pass NULL for this parameter, the received bytes are ignored.
transferByteCountThe number of bytes to send and receive.
timeoutA timeout for the transfer in microseconds. If the transfer takes longer than this amount of time, the transfer will be aborted and a kStatus_SPI_Timeout error will be returned.
Return values
#kStatus_SuccessThe transfer was succesful.
kStatus_SPI_BusyCannot perform another transfer because one is already in progress.
kStatus_SPI_TimeoutThe transfer timed out and was aborted.

Definition at line 70 of file fsl_spi_master_driver.c.

References FALSE, gSys_NumSpiBuses, kStatus_SPI_Error, kStatus_SPI_Success, and SPI_PEX_READ_EVENT_SUCCESS.

spi_status_t spi_master_transfer_async ( uint32_t  instance,
const spi_user_config_t device,
const uint8_t *  sendBuffer,
uint8_t *  receiveBuffer,
uint16_t  transferByteCount 
)

Perform an non-blocking SPI master mode transfer.

Parameters
instanceThe instance number of the SPI peripheral.
devicePointer to the device information struct. This struct contains the settings for how the SPI bus will be configured for this transfer. You may pass NULL for this parameter, in which case the current bus configuration is used unmodified.
sendBufferBuffer of data to send. You may pass NULL for this parameter, in which case bytes with a value of 0 (zero) will be sent.
receiveBufferBuffer where received bytes are stored. If you pass NULL for this parameter, the received bytes are ignored.
transferByteCountThe number of bytes to send and receive.
Return values
#kStatus_SuccessThe transfer was succesful.
kStatus_SPI_BusyCannot perform another transfer because one is already in progress.
kStatus_SPI_TimeoutThe transfer timed out and was aborted.

Definition at line 105 of file fsl_spi_master_driver.c.

References kStatus_SPI_Success.

Variable Documentation

uint8 gSys_NumSpiBuses

Definition at line 96 of file isf_sysconf_comms.c.

Referenced by spi_master_init(), and spi_master_transfer().

spi_master_instance_PEx spi_master_instance_tbl[]

Lookup table for the LLD instance.

Definition at line 26 of file isf_fsl_spi_master_PEx.c.

spi_master_state_t spi_master_state[]

Definition at line 26 of file fsl_spi_master_driver.c.