SPIDRVEMDRV
Detailed Description
SPIDRV Serial Peripheral Interface Driver.
The
spidrv.c
and
spidrv.h
source files for the SPI driver library are in the emdrv/spidrv folder.
Introduction
The SPI driver supports the SPI capabilities of EFM32/EZR32/EFR32 USARTs. The driver is fully reentrant, supports several driver instances, and does not buffer or queue data. Both synchronous and asynchronous transfer functions are included for both master and slave SPI mode. Synchronous transfer functions are blocking and do not return before the transfer is complete. Asynchronous transfer functions report transfer completion with callback functions. Transfers are handled using DMA.
- Note
- Transfer completion callback functions are called from within the DMA interrupt handler with interrupts disabled.
Configuration Options
Some properties of the SPIDRV driver are compile-time configurable. These properties are stored in a file named spidrv_config.h. A template for this file, containing default values, is in the emdrv/config folder. Currently the configuration options are as follows:
- Inclusion of slave API transfer functions.
To configure SPIDRV, provide a custom configuration file. This is a sample spidrv_config.h file:
#ifndef __SILICON_LABS_SPIDRV_CONFIG_H__ #define __SILICON_LABS_SPIDRV_CONFIG_H__ // SPIDRV configuration option. Use this define to include the // slave part of the SPIDRV API. #define EMDRV_SPIDRV_INCLUDE_SLAVE #endif
The properties of each SPI driver instance are set at run-time using the SPIDRV_Init_t data structure input parameter to the SPIDRV_Init() function.
The API
This section contains brief descriptions of the API functions. For detailed information on input and output parameters and return values, click on the hyperlinked function names. Most functions return an error code,
ECODE_EMDRV_SPIDRV_OK
is returned on success, see
ecode.h
and
spidrv.h
for other error codes.
The application code must include
spidrv.h
.
SPIDRV_Init()
,
SPIDRV_DeInit()
These functions initialize or deinitializes the SPIDRV driver. Typically, SPIDRV_Init() is called once in the startup code.
SPIDRV_GetTransferStatus()
Query the status of a transfer. Reports number of items (frames) transmitted and remaining.
SPIDRV_AbortTransfer()
Stop an ongoing transfer.
SPIDRV_SetBitrate()
,
SPIDRV_GetBitrate()
Set or query the SPI bus bitrate.
SPIDRV_SetFramelength()
,
SPIDRV_GetFramelength()
Set or query SPI the bus frame length.
SPIDRV_MReceive()
,
SPIDRV_MReceiveB()
SPIDRV_MTransfer()
,
SPIDRV_MTransferB()
,
SPIDRV_MTransferSingleItemB()
SPIDRV_MTransmit()
,
SPIDRV_MTransmitB()
SPIDRV_SReceive()
,
SPIDRV_SReceiveB()
SPIDRV_STransfer()
,
SPIDRV_STransferB()
SPIDRV_STransmit()
,
SPIDRV_STransmitB()
SPI transfer functions for SPI masters have an uppercase M in their name, the slave counterparts have an S.
As previously mentioned, transfer functions are synchronous and asynchronous. The synchronous versions have an uppercase B (for Blocking) at the end of their function name.
Transmit functions discard received data, receive functions transmit a fixed data pattern set when the driver is initialized ( SPIDRV_Init_t::dummyTxValue ). Transfer functions both receive and transmit data.
All slave transfer functions have a millisecond timeout parameter. Use 0 for no (infinite) timeout.
Example
#include "spidrv.h" SPIDRV_HandleData_t handleData; SPIDRV_Handle_t handle = &handleData; void TransferComplete(SPIDRV_Handle_t handle, Ecode_t transferStatus, int itemsTransferred) { if (transferStatus == ECODE_EMDRV_SPIDRV_OK) { // Success ! } } int main(void) { uint8_t buffer[10]; SPIDRV_Init_t initData = SPIDRV_MASTER_USART2; // Initialize an SPI driver instance. SPIDRV_Init(handle, &initData); // Transmit data using a blocking transmit function. SPIDRV_MTransmitB(handle, buffer, 10); // Transmit data using a callback to catch transfer completion. SPIDRV_MTransmit(handle, buffer, 10, TransferComplete); }
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_MASTER_USART2 |
Configuration data for SPI master using USART2.
|
|
#define | SPIDRV_MASTER_USARTRF0 |
Configuration data for SPI master using USARTRF0.
|
|
#define | SPIDRV_MASTER_USARTRF1 |
Configuration data for SPI master using USARTRF1.
|
|
#define | SPIDRV_SLAVE_USART0 |
Configuration data for SPI slave using USART0.
|
|
#define | SPIDRV_SLAVE_USART1 |
Configuration data for SPI slave using USART1.
|
|
#define | SPIDRV_SLAVE_USART2 |
Configuration data for SPI slave using USART2.
|
|
#define | SPIDRV_SLAVE_USARTRF0 |
Configuration data for SPI slave using USARTRF0.
|
|
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.
|
|
Macro Definition Documentation
#define SPIDRV_MASTER_USART0 |
Configuration data for SPI master using USART0.
Definition at line
578
of file
spidrv.h
.
#define SPIDRV_MASTER_USART1 |
Configuration data for SPI master using USART1.
Definition at line
593
of file
spidrv.h
.
Referenced by KSZ8851SNL_SPI_Init() .
#define SPIDRV_MASTER_USART2 |
Configuration data for SPI master using USART2.
Definition at line
623
of file
spidrv.h
.
#define SPIDRV_MASTER_USARTRF0 |
Configuration data for SPI master using USARTRF0.
Definition at line
639
of file
spidrv.h
.
#define SPIDRV_MASTER_USARTRF1 |
Configuration data for SPI master using USARTRF1.
Definition at line
654
of file
spidrv.h
.
#define SPIDRV_SLAVE_USART0 |
Configuration data for SPI slave using USART0.
Definition at line
669
of file
spidrv.h
.
#define SPIDRV_SLAVE_USART1 |
Configuration data for SPI slave using USART1.
Definition at line
684
of file
spidrv.h
.
#define SPIDRV_SLAVE_USART2 |
Configuration data for SPI slave using USART2.
Definition at line
714
of file
spidrv.h
.
#define SPIDRV_SLAVE_USARTRF0 |
Configuration data for SPI slave using USARTRF0.
Definition at line
730
of file
spidrv.h
.
Typedef Documentation
typedef void(* SPIDRV_Callback_t) (struct SPIDRV_HandleData *handle, Ecode_t transferStatus, int itemsTransferred) |
SPIDRV transfer completion callback function.
Called when a transfer is complete. An application should check the transferStatus and itemsTransferred values.
- Parameters
-
[in] handle
The SPIDRV device handle used to start the transfer. [in] transferStatus
A number of bytes actually transferred. [in] itemsTransferred
A number of bytes transferred.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success, ECODE_EMDRV_SPIDRV_TIMEOUT on timeout. Timeouts are only relevant for slave mode transfers.
Definition at line
111
of file
spidrv.h
.
typedef struct SPIDRV_HandleData SPIDRV_HandleData_t |
An SPI driver instance handle data structure. The handle is allocated by the application using the SPIDRV. Several concurrent driver instances can exist in an application. The application is neither supposed to write or read the contents of the handle.
typedef struct SPIDRV_Init SPIDRV_Init_t |
An SPI driver instance initialization structure. Contains a number of SPIDRV configuration options. This structure is passed to SPIDRV_Init() when initializing a SPIDRV instance. Some common initialization data sets are predefined in SPIDRV_MASTER_USART0 and friends.
Enumeration Type Documentation
enum SPIDRV_BitOrder |
enum SPIDRV_ClockMode |
enum SPIDRV_CsControl |
enum SPIDRV_SlaveStart |
enum SPIDRV_Type |
Function Documentation
Ecode_t SPIDRV_AbortTransfer | ( | SPIDRV_Handle_t |
handle
|
) |
Abort an ongoing SPI transfer.
- Parameters
-
[in] handle
Pointer to an SPI driver handle.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success, ECODE_EMDRV_SPIDRV_IDLE if SPI is idle. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
443
of file
spidrv.c
.
References CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , DMADRV_StopTransfer() , DMADRV_TransferRemainingCount() , ECODE_EMDRV_SPIDRV_ABORTED , ECODE_EMDRV_SPIDRV_IDLE , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , RTCDRV_StopTimer() , and spidrvSlave .
Ecode_t SPIDRV_DeInit | ( | SPIDRV_Handle_t |
handle
|
) |
Deinitialize an SPI driver instance.
- Parameters
-
[in] handle
Pointer to an SPI driver handle.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
403
of file
spidrv.c
.
References CMU_ClockEnable() , DMADRV_DeInit() , DMADRV_FreeChannel() , DMADRV_StopTransfer() , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , RTCDRV_FreeTimer() , RTCDRV_StopTimer() , spidrvSlave , and USART_Reset() .
Ecode_t SPIDRV_GetBitrate | ( | SPIDRV_Handle_t |
handle,
|
uint32_t * |
bitRate
|
||
) |
Get current SPI bus bitrate.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] bitRate
Current SPI bus bitrate.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
494
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , ECODE_EMDRV_SPIDRV_PARAM_ERROR , and USART_BaudrateGet() .
Ecode_t SPIDRV_GetFramelength | ( | SPIDRV_Handle_t |
handle,
|
uint32_t * |
frameLength
|
||
) |
Get current SPI framelength.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] frameLength
Current SPI bus framelength.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
521
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , and ECODE_EMDRV_SPIDRV_PARAM_ERROR .
Ecode_t SPIDRV_GetTransferStatus | ( | SPIDRV_Handle_t |
handle,
|
int * |
itemsTransferred,
|
||
int * |
itemsRemaining
|
||
) |
Get the status of an SPI transfer.
Returns status of an ongoing transfer. If no transfer is in progress, the status of the last transfer is reported.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] itemsTransferred
Number of items (frames) transferred. [out] itemsRemaining
Number of items (frames) remaining.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
554
of file
spidrv.c
.
References CORE_ATOMIC_SECTION , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , and ECODE_EMDRV_SPIDRV_PARAM_ERROR .
Ecode_t SPIDRV_Init | ( | SPIDRV_Handle_t |
handle,
|
SPIDRV_Init_t * |
initData
|
||
) |
Initialize an SPI driver instance.
- Parameters
-
[out] handle
Pointer to an SPI driver handle; refer to SPIDRV_Handle_t . [in] initData
Pointer to an initialization data structure; refer to SPIDRV_Init_t .
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
117
of file
spidrv.c
.
References _USART_FRAME_DATABITS_FOUR , _USART_ROUTE_LOCATION_SHIFT , USART_InitSync_TypeDef::baudrate , SPIDRV_Init::bitOrder , SPIDRV_Init::bitRate , SPIDRV_Init::clockMode , USART_InitSync_TypeDef::clockMode , CMU_ClockEnable() , cmuClock_GPIO , cmuClock_HFPER , cmuClock_USART1 , CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , SPIDRV_Init::csControl , USART_TypeDef::CTRL , USART_InitSync_TypeDef::databits , DMADRV_AllocateChannel() , DMADRV_Init() , dmadrvPeripheralSignal_USART1_RXDATAV , dmadrvPeripheralSignal_USART1_TXBL , ECODE_EMDRV_DMADRV_OK , ECODE_EMDRV_RTCDRV_OK , ECODE_EMDRV_SPIDRV_DMA_ALLOC_ERROR , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , ECODE_EMDRV_SPIDRV_PARAM_ERROR , ECODE_EMDRV_SPIDRV_TIMER_ALLOC_ERROR , SPIDRV_Init::frameLength , GPIO , USART_InitSync_TypeDef::master , USART_InitSync_TypeDef::msbf , SPIDRV_Init::port , SPIDRV_Init::portLocation , USART_TypeDef::ROUTE , RTCDRV_AllocateTimer() , RTCDRV_Init() , spidrvBitOrderMsbFirst , spidrvClockMode0 , spidrvClockMode1 , spidrvClockMode2 , spidrvClockMode3 , spidrvCsControlAuto , spidrvMaster , spidrvSlave , SPIDRV_Init::type , USART1 , USART_CTRL_AUTOCS , USART_InitSync() , USART_INITSYNC_DEFAULT , USART_ROUTE_CLKPEN , USART_ROUTE_CSPEN , USART_ROUTE_RXPEN , USART_ROUTE_TXPEN , usartClockMode0 , usartClockMode1 , usartClockMode2 , and usartClockMode3 .
Referenced by ezradio_hal_SpiInit() , and KSZ8851SNL_SPI_Init() .
Ecode_t SPIDRV_MReceive | ( | SPIDRV_Handle_t |
handle,
|
void * |
buffer,
|
||
int |
count,
|
||
SPIDRV_Callback_t |
callback
|
||
) |
Start an SPI master receive transfer.
- Note
- The MOSI wire will transmit SPIDRV_Init_t::dummyTxValue .
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] buffer
Receive data buffer. [in] count
Number of bytes in transfer. [in] callback
Transfer completion callback.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
601
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , and spidrvSlave .
Ecode_t SPIDRV_MReceiveB | ( | SPIDRV_Handle_t |
handle,
|
void * |
buffer,
|
||
int |
count
|
||
) |
Start an SPI master blocking receive transfer.
- Note
-
The MOSI wire will transmit
SPIDRV_Init_t::dummyTxValue
.
This function is blocking and returns when the transfer is complete or when SPIDRV_AbortTransfer() is called.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] buffer
Receive data buffer. [in] count
Number of bytes in transfer.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
642
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , and spidrvSlave .
Referenced by ezradio_hal_SpiReadByte() , ezradio_hal_SpiReadData() , and KSZ8851SNL_SPI_Receive() .
Ecode_t SPIDRV_MTransfer | ( | SPIDRV_Handle_t |
handle,
|
const void * |
txBuffer,
|
||
void * |
rxBuffer,
|
||
int |
count,
|
||
SPIDRV_Callback_t |
callback
|
||
) |
Start an SPI master transfer.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] txBuffer
Transmit data buffer. [out] rxBuffer
Receive data buffer. [in] count
Number of bytes in transfer. [in] callback
Transfer completion callback.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
682
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , ECODE_EMDRV_SPIDRV_PARAM_ERROR , and spidrvSlave .
Ecode_t SPIDRV_MTransferB | ( | SPIDRV_Handle_t |
handle,
|
const void * |
txBuffer,
|
||
void * |
rxBuffer,
|
||
int |
count
|
||
) |
Start an SPI master blocking transfer.
- Note
- This function is blocking and returns when the transfer is complete or when SPIDRV_AbortTransfer() is called.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] txBuffer
Transmit data buffer. [out] rxBuffer
Receive data buffer. [in] count
Number of bytes in transfer.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
729
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , ECODE_EMDRV_SPIDRV_PARAM_ERROR , and spidrvSlave .
Referenced by ezradio_hal_SpiWriteReadData() , and KSZ8851SNL_SPI_ReadRegister() .
Ecode_t SPIDRV_MTransferSingleItemB | ( | SPIDRV_Handle_t |
handle,
|
uint32_t |
txValue,
|
||
void * |
rxValue
|
||
) |
Start an SPI master blocking single item (frame) transfer.
- Note
- This function is blocking and returns when the transfer is complete or when SPIDRV_AbortTransfer() is called.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] txValue
Value to transmit. [out] rxValue
Value received.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
775
of file
spidrv.c
.
References CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , ECODE_EMDRV_SPIDRV_BUSY , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_MODE_ERROR , rxBuffer , and spidrvSlave .
Ecode_t SPIDRV_MTransmit | ( | SPIDRV_Handle_t |
handle,
|
const void * |
buffer,
|
||
int |
count,
|
||
SPIDRV_Callback_t |
callback
|
||
) |
Start an SPI master transmit transfer.
- Note
- The data received on the MISO wire is discarded.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] buffer
Transmit data buffer. [in] count
Number of bytes in transfer. [in] callback
Transfer completion callback.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
829
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , and spidrvSlave .
Ecode_t SPIDRV_MTransmitB | ( | SPIDRV_Handle_t |
handle,
|
const void * |
buffer,
|
||
int |
count
|
||
) |
Start an SPI master blocking transmit transfer.
- Note
-
The data received on the MISO wire is discarded.
This function is blocking and returns when the transfer is complete.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] buffer
Transmit data buffer. [in] count
Number of bytes in transfer.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
869
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , and spidrvSlave .
Referenced by ezradio_hal_SpiWriteByte() , ezradio_hal_SpiWriteData() , and KSZ8851SNL_SPI_Transmit() .
Ecode_t SPIDRV_SetBitrate | ( | SPIDRV_Handle_t |
handle,
|
uint32_t |
bitRate
|
||
) |
Set SPI bus bitrate.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] bitRate
New SPI bus bitrate.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
903
of file
spidrv.c
.
References CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , ECODE_EMDRV_SPIDRV_BUSY , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , and USART_BaudrateSyncSet() .
Ecode_t SPIDRV_SetFramelength | ( | SPIDRV_Handle_t |
handle,
|
uint32_t |
frameLength
|
||
) |
Set SPI framelength.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] frameLength
New SPI bus framelength.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
936
of file
spidrv.c
.
References _USART_FRAME_DATABITS_FOUR , _USART_FRAME_DATABITS_MASK , _USART_FRAME_DATABITS_SHIFT , _USART_FRAME_DATABITS_SIXTEEN , CORE_DECLARE_IRQ_STATE , CORE_ENTER_ATOMIC , CORE_EXIT_ATOMIC , ECODE_EMDRV_SPIDRV_BUSY , ECODE_EMDRV_SPIDRV_ILLEGAL_HANDLE , ECODE_EMDRV_SPIDRV_OK , and ECODE_EMDRV_SPIDRV_PARAM_ERROR .
Ecode_t SPIDRV_SReceive | ( | SPIDRV_Handle_t |
handle,
|
void * |
buffer,
|
||
int |
count,
|
||
SPIDRV_Callback_t |
callback,
|
||
int |
timeoutMs
|
||
) |
Start an SPI slave receive transfer.
- Note
- The MISO wire will transmit SPIDRV_Init_t::dummyTxValue .
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] buffer
Receive data buffer. [in] count
Number of bytes in transfer. [in] callback
Transfer completion callback. [in] timeoutMs
Transfer timeout in milliseconds.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
988
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , RTCDRV_StartTimer() , rtcdrvTimerTypeOneshot , spidrvMaster , and spidrvSlaveStartDelayed .
Ecode_t SPIDRV_SReceiveB | ( | SPIDRV_Handle_t |
handle,
|
void * |
buffer,
|
||
int |
count,
|
||
int |
timeoutMs
|
||
) |
Start an SPI slave blocking receive transfer.
- Note
-
The MISO wire will transmit
SPIDRV_Init_t::dummyTxValue
.
This function is blocking and returns when the transfer is complete, on timeout, or when SPIDRV_AbortTransfer() is called.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [out] buffer
Receive data buffer. [in] count
Number of bytes in transfer. [in] timeoutMs
Transfer timeout in milliseconds.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success, ECODE_EMDRV_SPIDRV_TIMEOUT on timeout or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
1047
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , RTCDRV_StartTimer() , rtcdrvTimerTypeOneshot , spidrvMaster , and spidrvSlaveStartDelayed .
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.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] txBuffer
Transmit data buffer. [out] rxBuffer
Receive data buffer. [in] count
Number of bytes in transfer. [in] callback
Transfer completion callback. [in] timeoutMs
Transfer timeout in milliseconds.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
1104
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , ECODE_EMDRV_SPIDRV_PARAM_ERROR , RTCDRV_StartTimer() , rtcdrvTimerTypeOneshot , spidrvMaster , and spidrvSlaveStartDelayed .
Ecode_t SPIDRV_STransferB | ( | SPIDRV_Handle_t |
handle,
|
const void * |
txBuffer,
|
||
void * |
rxBuffer,
|
||
int |
count,
|
||
int |
timeoutMs
|
||
) |
Start an SPI slave blocking transfer.
- Note
-
This function is blocking and returns when the transfer is complete, on timeout, or when SPIDRV_AbortTransfer() is called.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] txBuffer
Transmit data buffer. [out] rxBuffer
Receive data buffer. [in] count
Number of bytes in transfer. [in] timeoutMs
Transfer timeout in milliseconds.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success, ECODE_EMDRV_SPIDRV_TIMEOUT on timeout or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
1169
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , ECODE_EMDRV_SPIDRV_PARAM_ERROR , RTCDRV_StartTimer() , rtcdrvTimerTypeOneshot , spidrvMaster , and spidrvSlaveStartDelayed .
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.
- Note
- The data received on the MOSI wire is discarded.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] buffer
Transmit data buffer. [in] count
Number of bytes in transfer. [in] callback
Transfer completion callback. [in] timeoutMs
Transfer timeout in milliseconds.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
1232
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , RTCDRV_StartTimer() , rtcdrvTimerTypeOneshot , spidrvMaster , and spidrvSlaveStartDelayed .
Ecode_t SPIDRV_STransmitB | ( | SPIDRV_Handle_t |
handle,
|
const void * |
buffer,
|
||
int |
count,
|
||
int |
timeoutMs
|
||
) |
Start an SPI slave blocking transmit transfer.
- Note
-
The data received on the MOSI wire is discarded.
This function is blocking and returns when the transfer is complete, on timeout, or when SPIDRV_AbortTransfer() is called.
- Parameters
-
[in] handle
Pointer to an SPI driver handle. [in] buffer
Transmit data buffer. [in] count
Number of bytes in transfer. [in] timeoutMs
Transfer timeout in milliseconds.
- Returns
- ECODE_EMDRV_SPIDRV_OK on success, ECODE_EMDRV_SPIDRV_TIMEOUT on timeout or ECODE_EMDRV_SPIDRV_ABORTED if SPIDRV_AbortTransfer() has been called. On failure, an appropriate SPIDRV Ecode_t is returned.
Definition at line
1291
of file
spidrv.c
.
References ECODE_EMDRV_SPIDRV_MODE_ERROR , ECODE_EMDRV_SPIDRV_OK , RTCDRV_StartTimer() , rtcdrvTimerTypeOneshot , spidrvMaster , and spidrvSlaveStartDelayed .