spidrv.h File Reference

SPIDRV API definition.

Version
5.4.0

License

(C) Copyright 2014 Silicon Labs, www.silabs.com

This file is licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.

Definition in file spidrv.h .

#include " em_device.h "
#include " em_cmu.h "
#include " ecode.h "
#include "spidrv_config.h"
#include " rtcdriver.h "
#include " dmadrv.h "

Data Structures

struct SPIDRV_HandleData
struct SPIDRV_Init

Macros

#define ECODE_EMDRV_SPIDRV_ABORTED ( ECODE_EMDRV_SPIDRV_BASE | 0x00000007)
An SPI transfer has been aborted.
#define ECODE_EMDRV_SPIDRV_BUSY ( ECODE_EMDRV_SPIDRV_BASE | 0x00000003)
The SPI port is busy.
#define ECODE_EMDRV_SPIDRV_DMA_ALLOC_ERROR ( ECODE_EMDRV_SPIDRV_BASE | 0x00000009)
Unable to allocate DMA channels.
#define ECODE_EMDRV_SPIDRV_IDLE ( ECODE_EMDRV_SPIDRV_BASE | 0x00000006)
No SPI transfer in progress.
#define ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE ( ECODE_EMDRV_SPIDRV_BASE | 0x00000001)
An illegal SPI handle.
#define ECODE_EMDRV_SPIDRV_MODE_ERROR ( ECODE_EMDRV_SPIDRV_BASE | 0x00000008)
SPI master used slave API or vica versa.
#define ECODE_EMDRV_SPIDRV_OK ( ECODE_OK )
A successful return value.
#define ECODE_EMDRV_SPIDRV_PARAM_ERROR ( ECODE_EMDRV_SPIDRV_BASE | 0x00000002)
An illegal input parameter.
#define ECODE_EMDRV_SPIDRV_TIMEOUT ( ECODE_EMDRV_SPIDRV_BASE | 0x00000005)
An SPI transfer timeout.
#define ECODE_EMDRV_SPIDRV_TIMER_ALLOC_ERROR ( ECODE_EMDRV_SPIDRV_BASE | 0x00000004)
Unable to allocate timeout timer.
#define SPIDRV_MASTER_USART0
Configuration data for SPI master using USART0.
#define SPIDRV_MASTER_USART1
Configuration data for SPI master using USART1.
#define SPIDRV_SLAVE_USART0
Configuration data for SPI slave using USART0.
#define SPIDRV_SLAVE_USART1
Configuration data for SPI slave using USART1.

Typedefs

typedef enum SPIDRV_BitOrder SPIDRV_BitOrder_t
SPI bus bit order.
typedef void(* SPIDRV_Callback_t ) (struct SPIDRV_HandleData *handle, Ecode_t transferStatus, int itemsTransferred)
SPIDRV transfer completion callback function.
typedef enum SPIDRV_ClockMode SPIDRV_ClockMode_t
SPI clock mode (clock polarity and phase).
typedef enum SPIDRV_CsControl SPIDRV_CsControl_t
SPI master chip select (CS) control scheme.
typedef SPIDRV_HandleData_t * SPIDRV_Handle_t
An SPI driver instance handle.
typedef struct SPIDRV_HandleData SPIDRV_HandleData_t
typedef struct SPIDRV_Init SPIDRV_Init_t
typedef enum SPIDRV_SlaveStart SPIDRV_SlaveStart_t
SPI slave transfer start scheme.
typedef enum SPIDRV_Type SPIDRV_Type_t
SPI driver instance type.

Enumerations

enum SPIDRV_BitOrder {
spidrvBitOrderLsbFirst = 0,
spidrvBitOrderMsbFirst = 1
}
SPI bus bit order.
enum SPIDRV_ClockMode {
spidrvClockMode0 = 0,
spidrvClockMode1 = 1,
spidrvClockMode2 = 2,
spidrvClockMode3 = 3
}
SPI clock mode (clock polarity and phase).
enum SPIDRV_CsControl {
spidrvCsControlAuto = 0,
spidrvCsControlApplication = 1
}
SPI master chip select (CS) control scheme.
enum SPIDRV_SlaveStart {
spidrvSlaveStartImmediate = 0,
spidrvSlaveStartDelayed = 1
}
SPI slave transfer start scheme.
enum SPIDRV_Type {
spidrvMaster = 0,
spidrvSlave = 1
}
SPI driver instance type.

Functions

Ecode_t SPIDRV_AbortTransfer ( SPIDRV_Handle_t handle)
Abort an ongoing SPI transfer.
Ecode_t SPIDRV_DeInit ( SPIDRV_Handle_t handle)
Deinitialize an SPI driver instance.
Ecode_t SPIDRV_GetBitrate ( SPIDRV_Handle_t handle, uint32_t *bitRate)
Get current SPI bus bitrate.
Ecode_t SPIDRV_GetFramelength ( SPIDRV_Handle_t handle, uint32_t *frameLength)
Get current SPI framelength.
Ecode_t SPIDRV_GetTransferStatus ( SPIDRV_Handle_t handle, int *itemsTransferred, int *itemsRemaining)
Get the status of an SPI transfer.
Ecode_t SPIDRV_Init ( SPIDRV_Handle_t handle, SPIDRV_Init_t *initData)
Initialize an SPI driver instance.
Ecode_t SPIDRV_MReceive ( SPIDRV_Handle_t handle, void *buffer, int count, SPIDRV_Callback_t callback)
Start an SPI master receive transfer.
Ecode_t SPIDRV_MReceiveB ( SPIDRV_Handle_t handle, void *buffer, int count)
Start an SPI master blocking receive transfer.
Ecode_t SPIDRV_MTransfer ( SPIDRV_Handle_t handle, const void *txBuffer, void * rxBuffer , int count, SPIDRV_Callback_t callback)
Start an SPI master transfer.
Ecode_t SPIDRV_MTransferB ( SPIDRV_Handle_t handle, const void *txBuffer, void * rxBuffer , int count)
Start an SPI master blocking transfer.
Ecode_t SPIDRV_MTransferSingleItemB ( SPIDRV_Handle_t handle, uint32_t txValue, void *rxValue)
Start an SPI master blocking single item (frame) transfer.
Ecode_t SPIDRV_MTransmit ( SPIDRV_Handle_t handle, const void *buffer, int count, SPIDRV_Callback_t callback)
Start an SPI master transmit transfer.
Ecode_t SPIDRV_MTransmitB ( SPIDRV_Handle_t handle, const void *buffer, int count)
Start an SPI master blocking transmit transfer.
Ecode_t SPIDRV_SetBitrate ( SPIDRV_Handle_t handle, uint32_t bitRate)
Set SPI bus bitrate.
Ecode_t SPIDRV_SetFramelength ( SPIDRV_Handle_t handle, uint32_t frameLength)
Set SPI framelength.
Ecode_t SPIDRV_SReceive ( SPIDRV_Handle_t handle, void *buffer, int count, SPIDRV_Callback_t callback, int timeoutMs)
Start an SPI slave receive transfer.
Ecode_t SPIDRV_SReceiveB ( SPIDRV_Handle_t handle, void *buffer, int count, int timeoutMs)
Start an SPI slave blocking receive transfer.
Ecode_t SPIDRV_STransfer ( SPIDRV_Handle_t handle, const void *txBuffer, void * rxBuffer , int count, SPIDRV_Callback_t callback, int timeoutMs)
Start an SPI slave transfer.
Ecode_t SPIDRV_STransferB ( SPIDRV_Handle_t handle, const void *txBuffer, void * rxBuffer , int count, int timeoutMs)
Start an SPI slave blocking transfer.
Ecode_t SPIDRV_STransmit ( SPIDRV_Handle_t handle, const void *buffer, int count, SPIDRV_Callback_t callback, int timeoutMs)
Start an SPI slave transmit transfer.
Ecode_t SPIDRV_STransmitB ( SPIDRV_Handle_t handle, const void *buffer, int count, int timeoutMs)
Start an SPI slave blocking transmit transfer.