MSPM0G1X0X_G3X0X TI-Driver Library  1.20.01.06
Data Structures | Macros | Typedefs | Enumerations | Functions
SPI.h File Reference

Detailed Description

SPI Driver Interface.


#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for SPI.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SPI_Transaction
 A SPI_Transaction data structure is used with SPI_transfer(). It indicates how many SPI_FrameFormat frames are sent and received from the buffers pointed to txBuf and rxBuf. The arg variable is an user-definable argument which gets passed to the SPI_CallbackFxn when the SPI driver is in SPI_MODE_CALLBACK. More...
 
struct  SPI_Params
 SPI Parameters. More...
 
struct  SPI_FxnTable
 The definition of a SPI function table that contains the required set of functions to control a specific SPI driver implementation. More...
 
struct  SPI_Config_
 SPI Global configuration. More...
 

Macros

#define SPI_CMD_RESERVED   (32)
 
#define SPI_STATUS_RESERVED   (-32)
 
#define SPI_STATUS_SUCCESS   (0)
 Successful status code returned by SPI_control(). More...
 
#define SPI_STATUS_ERROR   (-1)
 Generic error status code returned by SPI_control(). More...
 
#define SPI_STATUS_UNDEFINEDCMD   (-2)
 An error status code returned by SPI_control() for undefined command codes. More...
 
#define SPI_WAIT_FOREVER   (~(0U))
 Wait forever define used to specify timeouts.
 

Typedefs

typedef struct SPI_Config_SPI_Handle
 A handle that is returned from a SPI_open() call.
 
typedef void(* SPI_CallbackFxn) (SPI_Handle handle, SPI_Transaction *transaction)
 The definition of a callback function used by the SPI driver when used in SPI_MODE_CALLBACK. More...
 
typedef void(* SPI_CloseFxn) (SPI_Handle handle)
 A function pointer to a driver specific implementation of SPI_close().
 
typedef int_fast16_t(* SPI_ControlFxn) (SPI_Handle handle, uint_fast16_t cmd, void *arg)
 A function pointer to a driver specific implementation of SPI_control().
 
typedef void(* SPI_InitFxn) (SPI_Handle handle)
 A function pointer to a driver specific implementation of SPI_init().
 
typedef SPI_Handle(* SPI_OpenFxn) (SPI_Handle handle, SPI_Params *params)
 A function pointer to a driver specific implementation of SPI_open().
 
typedef bool(* SPI_TransferFxn) (SPI_Handle handle, SPI_Transaction *transaction)
 A function pointer to a driver specific implementation of SPI_transfer().
 
typedef void(* SPI_TransferCancelFxn) (SPI_Handle handle)
 A function pointer to a driver specific implementation of SPI_transferCancel().
 
typedef struct SPI_Config_ SPI_Config
 SPI Global configuration. More...
 

Enumerations

enum  SPI_Status {
  SPI_TRANSFER_COMPLETED = 0,
  SPI_TRANSFER_STARTED,
  SPI_TRANSFER_CANCELED,
  SPI_TRANSFER_FAILED,
  SPI_TRANSFER_CSN_DEASSERT,
  SPI_TRANSFER_PEND_CSN_ASSERT,
  SPI_TRANSFER_QUEUED
}
 Status codes that are set by the SPI driver. More...
 
enum  SPI_Mode {
  SPI_CONTROLLER = 0,
  SPI_PERIPHERAL = 1
}
 Definitions for various SPI modes of operation. More...
 
enum  SPI_Parity {
  SPI_PARITY_EVEN = 0,
  SPI_PARITY_ODD = 1,
  SPI_PARITY_NONE = 2
}
 Definitions for parity. More...
 
enum  SPI_BitOrder {
  SPI_BIT_ORDER_MSB_FIRST = 0,
  SPI_BIT_ORDER_LSB_FIRST = 1
}
 Definitions for bit order. More...
 
enum  SPI_Chip_Select {
  SPI_CHIP_SELECT_0 = 0,
  SPI_CHIP_SELECT_1 = 1,
  SPI_CHIP_SELECT_2 = 2,
  SPI_CHIP_SELECT_3 = 3,
  SPI_CHIP_SELECT_NONE = 4
}
 Definitions for chip select. More...
 
enum  SPI_FrameFormat {
  SPI_MOTO3_POL0_PHA0 = 0,
  SPI_MOTO3_POL0_PHA1 = 1,
  SPI_MOTO3_POL1_PHA0 = 2,
  SPI_MOTO3_POL1_PHA1 = 3,
  SPI_MOTO4_POL0_PHA0 = 4,
  SPI_MOTO4_POL0_PHA1 = 5,
  SPI_MOTO4_POL1_PHA0 = 6,
  SPI_MOTO4_POL1_PHA1 = 7,
  SPI_TI = 8
}
 Definitions for various SPI data frame formats. More...
 
enum  SPI_TransferMode {
  SPI_MODE_BLOCKING,
  SPI_MODE_CALLBACK
}
 SPI transfer mode determines the whether the SPI controller operates synchronously or asynchronously. In SPI_MODE_BLOCKING mode SPI_transfer() blocks code execution until the SPI transaction has completed. In SPI_MODE_CALLBACK SPI_transfer() does not block code execution and instead calls a SPI_CallbackFxn callback function when the transaction has completed (successfully or not). More...
 

Functions

void SPI_close (SPI_Handle handle)
 Function to close a SPI peripheral specified by the SPI handle. More...
 
int_fast16_t SPI_control (SPI_Handle handle, uint_fast16_t cmd, void *controlArg)
 Function performs implementation specific features on a given SPI_Handle. More...
 
void SPI_init (void)
 This function initializes the SPI module. More...
 
SPI_Handle SPI_open (uint_least8_t index, SPI_Params *params)
 This function opens a given SPI peripheral. More...
 
void SPI_Params_init (SPI_Params *params)
 Function to initialize the SPI_Params struct to its defaults. More...
 
bool SPI_transfer (SPI_Handle handle, SPI_Transaction *transaction)
 Function to perform SPI transactions. More...
 
void SPI_transferCancel (SPI_Handle handle)
 Function to cancel SPI transactions. More...
 
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale