EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2
spidrv.h File Reference

Detailed Description

SPIDRV API definition.

Version
5.1.2

License

(C) Copyright 2014 Silicon Labs, http://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"

Go to the source code of this file.

Data Structures

struct  SPIDRV_HandleData
 
struct  SPIDRV_Init
 

Macros

#define ECODE_EMDRV_SPIDRV_ABORTED   ( ECODE_EMDRV_SPIDRV_BASE | 0x00000007 )
 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 allocated 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 )
 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 )
 Success return value.
 
#define ECODE_EMDRV_SPIDRV_PARAM_ERROR   ( ECODE_EMDRV_SPIDRV_BASE | 0x00000002 )
 Illegal input parameter.
 
#define ECODE_EMDRV_SPIDRV_TIMEOUT   ( ECODE_EMDRV_SPIDRV_BASE | 0x00000005 )
 SPI transfer timeout.
 
#define ECODE_EMDRV_SPIDRV_TIMER_ALLOC_ERROR   ( ECODE_EMDRV_SPIDRV_BASE | 0x00000004 )
 Unable to allocated timeout timer.
 
#define SPIDRV_MASTER_USART0
 Configuration data for SPI master using USART0. More...
 
#define SPIDRV_MASTER_USART1
 Configuration data for SPI master using USART1. More...
 
#define SPIDRV_SLAVE_USART0
 Configuration data for SPI slave using USART0. More...
 
#define SPIDRV_SLAVE_USART1
 Configuration data for SPI slave using USART1. More...
 

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. More...
 
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_tSPIDRV_Handle_t
 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. More...
 
enum  SPIDRV_ClockMode {
  spidrvClockMode0 = 0,
  spidrvClockMode1 = 1,
  spidrvClockMode2 = 2,
  spidrvClockMode3 = 3
}
 SPI clock mode (clock polarity and phase). More...
 
enum  SPIDRV_CsControl {
  spidrvCsControlAuto = 0,
  spidrvCsControlApplication = 1
}
 SPI master chip select (CS) control scheme. More...
 
enum  SPIDRV_SlaveStart {
  spidrvSlaveStartImmediate = 0,
  spidrvSlaveStartDelayed = 1
}
 SPI slave transfer start scheme. More...
 
enum  SPIDRV_Type {
  spidrvMaster = 0,
  spidrvSlave = 1
}
 SPI driver instance type. More...
 

Functions

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