SPI.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!*****************************************************************************
33  * @file SPI.h
34  *
35  * @brief Serial Peripheral Interface (SPI) Driver Interface
36  *
37  * @anchor ti_drivers_SPI_Overview
38  * # Overview
39  * The Serial Peripheral Interface (SPI) driver is a generic, full-duplex
40  * driver that transmits and receives data on a SPI bus. SPI is sometimes
41  * called SSI (Synchronous Serial Interface).
42  * The SPI protocol defines the format of a data transfer over the SPI bus,
43  * but it leaves flow control, data formatting, and handshaking mechanisms
44  * to higher-level software layers.
45  *
46  * The SPI driver operates on some key definitions and assumptions:
47  * - The driver operates transparently from the chip select. Some SPI
48  * controllers feature a hardware chip select to assert SPI peripheral
49  * peripherals. See the specific device implementations on chip
50  * select requirements.
51  *
52  * - The SPI protocol does not account for a built-in handshaking mechanism
53  * and neither does this SPI driver. Therefore, when operating in
54  * #SPI_PERIPHERAL mode, the application must provide such a mechanism to
55  * ensure that the SPI peripheral is ready for the SPI controller. The SPI
56  * peripheral must call #SPI_transfer() *before* the SPI controller starts
57  * transmitting.
58  * Some example application mechanisms could include:
59  * - Timed delays on the SPI controller to guarantee the SPI peripheral is
60  * ready for a SPI transaction.
61  * - A form of GPIO flow control from the peripheral to the SPI controller to
62  * notify the controller when ready.
63  *
64  * <hr>
65  * @anchor ti_drivers_SPI_Usage
66  * # Usage
67  *
68  * To use the SPI driver to send data over the SPI bus, the application
69  * calls the following APIs:
70  * - SPI_init(): Initialize the SPI driver.
71  * - SPI_Params_init(): Initialize a #SPI_Params structure with default
72  * values. Then change the parameters from non-default values as
73  * needed.
74  * - SPI_open(): Open an instance of the SPI driver, passing the
75  * initialized parameters, or NULL, and an index to the configuration to
76  * open (detailed later).
77  * - SPI_transfer(): Transmit/receive data. This function takes a
78  * #SPI_Transaction argument that describes the transfer that is requested.
79  * - SPI_close(): De-initialize the SPI instance.
80  *
81  * @anchor ti_drivers_SPI_Synopsis
82  * ## Synopsis
83  * The following code example opens a SPI instance as a SPI controller,
84  * and issues a transaction.
85  *
86  * @code
87  * SPI_Handle spi;
88  * SPI_Params spiParams;
89  * SPI_Transaction spiTransaction;
90  * uint8_t transmitBuffer[MSGSIZE];
91  * uint8_t receiveBuffer[MSGSIZE];
92  * bool transferOK;
93  *
94  * SPI_init(); // Initialize the SPI driver
95  *
96  * SPI_Params_init(&spiParams); // Initialize SPI parameters
97  * spiParams.dataSize = 8; // 8-bit data size
98  *
99  * spi = SPI_open(CONFIG_SPI0, &spiParams);
100  * if (spi == NULL) {
101  * while (1); // SPI_open() failed
102  * }
103  *
104  * // Fill in transmitBuffer
105  * spiTransaction.count = MSGSIZE;
106  * spiTransaction.txBuf = (void *)transmitBuffer;
107  * spiTransaction.rxBuf = (void *)receiveBuffer;
108  *
109  * transferOK = SPI_transfer(spi, &spiTransaction);
110  * if (!transferOK) {
111  * // Error in SPI or transfer already in progress.
112  * while (1);
113  * }
114  * @endcode
115  *
116  * More details on usage are provided in the following subsections.
117  *
118  * @anchor ti_drivers_SPI_Examples
119  * ## Examples #
120  * * @ref ti_drivers_SPI_Synopsis "Usage Synopsis"
121  * * @ref ti_drivers_SPI_Example_openblocking "Open in blocking mode"
122  * * @ref ti_drivers_SPI_Example_opencallback "Open in callback mode"
123  * * @ref ti_drivers_SPI_Example_6bitframes "Sending 6 bit frames"
124  * * @ref ti_drivers_SPI_Example_12bitframes "Sending 12 bit frames"
125  * * @ref ti_drivers_SPI_Example_callbackarg "Callback function using arg"
126  *
127  * ## Initializing the SPI Driver
128  *
129  * SPI_init() must be called before any other SPI APIs. This function
130  * iterates through the elements of the @p SPI_config[] array, calling
131  * the element's device implementation SPI initialization function.
132  *
133  * ## Opening the SPI Driver
134  * After initializing the SPI driver by calling SPI_init(), the application
135  * can open a SPI instance by calling SPI_open(). This function
136  * takes an index into the @p SPI_config[] array, and a SPI parameters data
137  * structure. The SPI instance is specified by the index of the SPI in
138  * @p SPI_config[]. Calling SPI_open() a second time with the same index
139  * previously passed to SPI_open() will result in an error. You can,
140  * though, re-use the index if the instance is closed via SPI_close().
141  *
142  * If no #SPI_Params structure is passed to SPI_open(), default values are
143  * used. If the open call is successful, it returns a non-NULL value.
144  *
145  * @anchor ti_drivers_SPI_Example_openblocking
146  * Example opening a SPI driver instance in blocking mode:
147  * @code
148  * SPI_Handle spi;
149  * SPI_Params spiParams;
150  *
151  * SPI_Params_init(&spiParams);
152  * spiParams.transferMode = SPI_MODE_BLOCKING;
153  * spi = SPI_open(CONFIG_SPI0, &spiParams);
154  *
155  * if (spi == NULL) {
156  * // Error opening SPI
157  * while(1);
158  * }
159  * @endcode
160  *
161  * @anchor ti_drivers_SPI_Example_opencallback
162  * Example opening a SPI driver instance in callback mode:
163  * @code
164  * SPI_Handle spi;
165  * SPI_Params spiParams;
166  *
167  * SPI_Params_init(&spiParams);
168  * spiParams.transferMode = SPI_MODE_CALLBACK;
169  * spiParams.transferCallbackFxn = UserCallbackFxn;
170  *
171  * spi = SPI_open(CONFIG_SPI0, &spiParams);
172  * if (spi == NULL) {
173  * // Error opening SPI
174  * while (1);
175  * }
176  * @endcode
177  *
178  * ## SPI Parameters
179  *
180  * The #SPI_Params structure is passed to the SPI_open() call. If NULL
181  * is passed for the parameters, SPI_open() uses default parameters.
182  * A #SPI_Params structure is initialized with default values by passing
183  * it to SPI_Params_init().
184  * Some of the SPI parameters are described below. To see brief descriptions
185  * of all the parameters, see #SPI_Params.
186  *
187  * ### SPI Mode
188  * The SPI driver operates in both SPI controller and SPI peripheral modes.
189  * Logically, the implementation is identical, however the difference
190  * between these two modes is driven by hardware. The default mode is
191  * #SPI_CONTROLLER, but can be set to peripheral mode by setting
192  * #SPI_Params.mode to #SPI_PERIPHERAL in the parameters passed to SPI_open().
193  * See @ref ti_drivers_SPI_ControllerPeripheralModes "Controller/Peripheral Modes"
194  * for further details.
195  *
196  * ### SPI Transfer Mode
197  * The SPI driver supports two transfer modes of operation: blocking and
198  * callback. The transfer mode is determined by the transferMode parameter
199  * in the #SPI_Params data structure. The SPI driver
200  * defaults to blocking mode, if the application does not set it.
201  * Once a SPI driver is opened, the only way to change the operation mode
202  * is to close and re-open the SPI instance with the new transfer mode.
203  *
204  * In blocking mode, a task's code execution is blocked until a SPI
205  * transaction has completed or a timeout has occurred. This ensures
206  * that only one SPI transfer operates at a given time. Other tasks requesting
207  * SPI transfers while a transfer is currently taking place will receive
208  * a FALSE return value. If a timeout occurs the transfer is canceled, the
209  * task is unblocked & will receive a FALSE return value. The transaction
210  * count field will have the amount of frames which were transferred
211  * successfully before the timeout. In blocking mode, transfers cannot be
212  * performed in software or hardware ISR context.
213  *
214  * In callback mode, a SPI transaction functions asynchronously, which
215  * means that it does not block code execution. After a SPI transaction
216  * has been completed, the SPI driver calls a user-provided hook function.
217  * Callback mode is supported in the execution context of tasks and
218  * hardware interrupt routines.
219  *
220  * ### SPI Frame Formats and Data Size
221  * The SPI driver can configure the device's SPI peripheral to transfer
222  * data in several SPI format options: SPI (with various polarity and phase
223  * settings), TI, and Micro-wire. The frame format is set with
224  * #SPI_Params.frameFormat. Some SPI implementations may not support all frame
225  * formats & the SPI driver will fail to opened. Refer to the device specific
226  * implementation documentation for details on which frame formats are
227  * supported.
228  *
229  * The smallest single unit of data transmitted onto the SPI bus is called
230  * a SPI frame and is of size #SPI_Params.dataSize. A series of SPI frames
231  * transmitted/received on a SPI bus is referred to as a SPI transaction.
232  *
233  * ## SPI Transactions
234  *
235  * A SPI transaction consists of a series of SPI frames
236  * transmitted/received on a SPI bus. A SPI transaction is performed
237  * using SPI_transfer(). SPI_transfer() accepts a pointer to a
238  * #SPI_Transaction structure that dictates the quantity of data to be
239  * sent and received.
240  * The #SPI_Transaction.txBuf and #SPI_Transaction.rxBuf are both pointers
241  * to data buffers. If txBuf is NULL, the driver sends SPI frames with all
242  * data set to the default value specified in the hardware attributes. If
243  * rxBuf is NULL, the driver discards all SPI frames received. SPI_transfer()
244  * of a SPI transaction is performed atomically.
245  *
246  * @warning The use of NULL as a sentinel txBuf or rxBuf value to determine
247  * whether the SPI transaction includes a tx or rx component implies
248  * that it is not possible to perform a transmit or receive transfer
249  * directly from/to a buffer with a base address of 0x00000000. To support
250  * this rare use-case, the application will have to manually copy the
251  * contents of location 0x00000000 to/from a temporary buffer before/after
252  * the tx/rx SPI transaction.
253  *
254  * When the SPI is opened, the dataSize value determines the element types
255  * of txBuf and rxBuf. If the dataSize is from 4 to 8 bits, the driver
256  * assumes the data buffers are of type uint8_t (unsigned char). If the
257  * dataSize is from 8 to 16 bits, the driver assumes the data buffers are
258  * of type uint16_t (unsigned short). If the dataSize is greater than
259  * 16 bits, the driver assumes the data buffers are uint32_t (unsigned long).
260  * Some SPI driver implementations may not support all data sizes; refer
261  * to device specific SPI implementation documentation for details on
262  * what data sizes are supported.
263  *
264  * The optional #SPI_Transaction.arg variable can only be used when the
265  * SPI driver has been opened in callback mode. This variable is used to
266  * pass a user-defined value into the user-defined callback function.
267  *
268  * SPI_transfer() always performs full-duplex SPI transactions. This means
269  * the SPI simultaneously receives data as it transmits data. The application
270  * is responsible for formatting the data to be transmitted as well as
271  * determining whether the data received is meaningful.
272  * Specifics about SPI frame formatting and data sizes are provided in
273  * device-specific data sheets and technical reference manuals.
274  *
275  * The following code snippets perform SPI transactions.
276  *
277  * @anchor ti_drivers_SPI_Example_6bitframes
278  * Example transferring 6-bit SPI frames. The transmit and receive
279  * buffers are of type uint8_t.
280  * @code
281  * SPI_Transaction spiTransaction;
282  * uint8_t transmitBuffer[BUFSIZE];
283  * uint8_t receiveBuffer[BUFSIZE];
284  * bool transferOK;
285  *
286  * SPI_Params_init(&spiParams);
287  * spiParams.dataSize = 6;
288  * spi = SPI_open(CONFIG_SPI0, &spiParams);
289  * ...
290  * spiTransaction.count = someIntegerValue;
291  * spiTransaction.txBuf = transmitBuffer;
292  * spiTransaction.rxBuf = receiveBuffer;
293  *
294  * transferOK = SPI_transfer(spi, &spiTransaction);
295  * if (!transferOK) {
296  * // Error in SPI or transfer already in progress.
297  * }
298  * @endcode
299  *
300  * @anchor ti_drivers_SPI_Example_12bitframes
301  * Example transferring 12-bit SPI frames. The transmit and receive
302  * buffers are of type uint16_t.
303  * @code
304  * SPI_Transaction spiTransaction;
305  * uint16_t transmitBuffer[BUFSIZE];
306  * uint16_t receiveBuffer[BUFSIZE];
307  * bool transferOK;
308  *
309  * SPI_Params_init(&spiParams);
310  * spiParams.dataSize = 12;
311  * spi = SPI_open(CONFIG_SPI0, &spiParams);
312  * ...
313  * spiTransaction.count = someIntegerValue;
314  * spiTransaction.txBuf = transmitBuffer;
315  * spiTransaction.rxBuf = receiveBuffer;
316  *
317  * transferOK = SPI_transfer(spi, &spiTransaction);
318  * if (!transferOK) {
319  * // Error in SPI or transfer already in progress.
320  * }
321  * @endcode
322  *
323  * The following example shows an example of a callback function that
324  * utilizes the arg parameter.
325  * @anchor ti_drivers_SPI_Example_callbackarg
326  * @code
327  * // SPI is opened with callback function as seen in other examples
328  * // Our goal is to post a semaphore when transfer with sufficient size
329  * // completes.
330  * ...
331  * // Pass pointer to an initialized semaphore to callback via arg
332  * spiTransaction.count = someIntegerValue;
333  * spiTransaction.txBuf = transmitBuffer;
334  * spiTransaction.rxBuf = receiveBuffer;
335  * spiTransaction.arg = &mySemaphore;
336  *
337  * ...
338  *
339  * // Our callback function is defined here
340  * void spiCallbackFxn(SPI_Handle spi, SPI_Transaction *tran)
341  * {
342  * sem_t *semPtr = (sem_t *)(tran->arg);
343  *
344  * // Post the semaphore if our transaction was more than LIMIT
345  * if (tran->status == SPI_STATUS_SUCCESS &&
346  * tran->count > LIMIT) {
347  * sem_post(semPtr);
348  * }
349  * }
350  * @endcode
351  *
352  * ## Canceling a transaction
353  * SPI_transferCancel() is used to cancel a SPI transaction when the driver is
354  * used in #SPI_MODE_CALLBACK mode.
355  *
356  * Calling this API while no transfer is in progress has no effect. If a
357  * transfer is in progress, it is canceled and the callback functions is
358  * called.
359  * The #SPI_Status status field in the #SPI_Transaction structure
360  * can be examined within the callback to determine if the transaction
361  * succeeded.
362  *
363  * Example:
364  * @code
365  * SPI_transferCancel(spi);
366  * @endcode
367  *
368  * @anchor ti_drivers_SPI_ControllerPeripheralModes
369  * ## Controller/Peripheral Modes
370  * This SPI driver functions in both SPI controller and SPI peripheral modes.
371  * Logically, the implementation is identical, however the difference between
372  * these two modes is driven by hardware. As a SPI controller, the peripheral is
373  * in control of the clock signal and therefore will commence communications
374  * to the SPI peripheral immediately. As a SPI peripheral, the SPI driver
375  * prepares the peripheral to transmit and receive data in a way such that the
376  * peripheral is ready to transfer data when the SPI controller initiates a
377  * transaction.
378  *
379  * ## Asserting on Chip Select
380  * The SPI protocol requires that the SPI controller asserts a SPI peripheral's
381  * chip select pin prior to starting a SPI transaction. While this protocol is
382  * generally followed, various types of SPI peripherals have different
383  * timing requirements as to when and for how long the chip select pin must
384  * remain asserted for a SPI transaction.
385  *
386  * Commonly, the SPI controller uses a hardware chip select to assert and
387  * de-assert the SPI peripheral for every data frame. In other cases, a SPI
388  * peripheral imposes the requirement of asserting the chip select over several SPI
389  * data frames. This is generally accomplished by using a regular,
390  * general-purpose output pin. Due to the complexity of such SPI peripheral
391  * implementations, this SPI driver has been designed to operate
392  * transparently to the SPI chip select. When the hardware chip
393  * select is used, the peripheral automatically selects/enables the
394  * peripheral. When using a software chip select, the application needs to
395  * handle the proper chip select and pin configuration. Chip select support
396  * will vary per SPI peripheral, refer to the device specific implementation
397  * documentation for details on chip select support.
398  *
399  * - _Hardware chip select_ No additional action by the application is
400  * required.
401  * - _Software chip select_ The application needs to handle the chip select
402  * assertion and de-assertion for the proper SPI peripheral.
403  *
404  * <hr>
405  * @anchor ti_drivers_SPI_Configuration
406  * # Configuration
407  *
408  * In order to use the SPI APIs, the application is required to provide
409  * device-specific SPI configuration in the ti_drivers_config.c file.
410  * The SPI driver interface defines a configuration data structure:
411  *
412  * @code
413  * typedef struct {
414  * SPI_FxnTable const *fxnTablePtr;
415  * void *object;
416  * void const *hwAttrs;
417  * } SPI_Config;
418  * @endcode
419  *
420  * The application must declare an array of #SPI_Config elements, named
421  * @p SPI_config[]. Each element of @p SPI_config[] must be populated with
422  * pointers to a device specific SPI driver implementation's function
423  * table, driver object, and hardware attributes. The hardware attributes
424  * define properties such as the SPI peripheral's base address, and
425  * the PICO and POCI pins. Each element in @p SPI_config[] corresponds to
426  * a SPI instance, and none of the elements should have NULL pointers.
427  * There is no correlation between the index and the
428  * peripheral designation (such as SPI0 or SPI1). For example, it is
429  * possible to use SPI_config[0] for SPI1.
430  *
431  * Because the SPI configuration is very device dependent, you will need to
432  * check the doxygen for the device specific SPI implementation. There you
433  * will find a description of the SPI hardware attributes. Please also
434  * refer to the ti_drivers_config.c file of any of your examples to see the
435  * SPI configuration.
436  *
437  *******************************************************************************
438  */
439 
440 #ifndef ti_drivers_SPI__include
441 #define ti_drivers_SPI__include
442 
443 #include <stdbool.h>
444 #include <stddef.h>
445 #include <stdint.h>
446 
447 /* Enable backwards-compatibility for legacy terminology if specified. */
448 #ifdef ENABLE_LEGACY_TERMINOLOGY
450 #endif
451 
452 #ifdef __cplusplus
453 extern "C" {
454 #endif
455 
473 #define SPI_CMD_RESERVED (32)
474 
487 #define SPI_STATUS_RESERVED (-32)
488 
502 #define SPI_STATUS_SUCCESS (0)
503 
510 #define SPI_STATUS_ERROR (-1)
511 
519 #define SPI_STATUS_UNDEFINEDCMD (-2)
520 
530 /* Add SPI_CMD_<commands> here */
531 
539 #define SPI_WAIT_FOREVER (~(0U))
540 
544 typedef struct SPI_Config_ *SPI_Handle;
545 
549 typedef enum
550 {
560 } SPI_Status;
561 
570 typedef struct
571 {
572  /* User input (write-only) fields */
573  size_t count;
574  void *txBuf;
575  void *rxBuf;
576  void *arg;
578  /* User output (read-only) fields */
579  SPI_Status status;
581  void *nextPtr;
584 
592 typedef void (*SPI_CallbackFxn)(SPI_Handle handle, SPI_Transaction *transaction);
597 typedef enum
598 {
601 } SPI_Mode;
602 
607 typedef enum
608 {
613  SPI_TI = 4,
615  SPI_MW = 5
618 
629 typedef enum
630 {
643 
652 typedef struct
653 {
654  SPI_TransferMode transferMode;
655  uint32_t transferTimeout;
670  uint32_t bitRate;
671  uint32_t dataSize;
673  void *custom;
675 } SPI_Params;
676 
681 typedef void (*SPI_CloseFxn)(SPI_Handle handle);
682 
687 typedef int_fast16_t (*SPI_ControlFxn)(SPI_Handle handle, uint_fast16_t cmd, void *arg);
688 
693 typedef void (*SPI_InitFxn)(SPI_Handle handle);
694 
699 typedef SPI_Handle (*SPI_OpenFxn)(SPI_Handle handle, SPI_Params *params);
700 
705 typedef bool (*SPI_TransferFxn)(SPI_Handle handle, SPI_Transaction *transaction);
706 
711 typedef void (*SPI_TransferCancelFxn)(SPI_Handle handle);
712 
718 typedef struct
719 {
722 
725 
728 
731 
734 
737 } SPI_FxnTable;
738 
750 typedef struct SPI_Config_
751 {
754 
756  void *object;
757 
759  void const *hwAttrs;
760 } SPI_Config;
761 
771 extern void SPI_close(SPI_Handle handle);
772 
810 extern int_fast16_t SPI_control(SPI_Handle handle, uint_fast16_t cmd, void *controlArg);
811 
820 extern void SPI_init(void);
821 
839 extern SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params);
840 
856 extern void SPI_Params_init(SPI_Params *params);
857 
902 extern bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction);
903 
923 extern void SPI_transferCancel(SPI_Handle handle);
924 
925 #ifdef __cplusplus
926 }
927 #endif
928 
929 #endif /* ti_drivers_SPI__include */
ADC_Params params
Definition: Driver_Init.h:11
Definition: SPI.h:613
void SPI_init(void)
This function initializes the SPI module.
uint32_t bitRate
SPI bit rate in Hz.
Definition: SPI.h:670
size_t count
Definition: SPI.h:573
void const * hwAttrs
Definition: SPI.h:759
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.
Definition: SPI.h:592
SPI_FrameFormat frameFormat
Definition: SPI.h:672
void SPI_transferCancel(SPI_Handle handle)
Function to cancel SPI transactions.
uint32_t transferTimeout
Definition: SPI.h:655
Definition: SPI.h:557
SPI_TransferMode
SPI transfer mode determines the whether the SPI controller operates synchronously or asynchronously...
Definition: SPI.h:629
SPI_TransferMode transferMode
Definition: SPI.h:654
SPI_FxnTable const * fxnTablePtr
Definition: SPI.h:753
void SPI_Params_init(SPI_Params *params)
Function to initialize the SPI_Params struct to its defaults.
SPI_CloseFxn closeFxn
Definition: SPI.h:721
SPI_TransferCancelFxn transferCancelFxn
Definition: SPI.h:736
SPI Parameters.
Definition: SPI.h:652
SPI_Status
Status codes that are set by the SPI driver.
Definition: SPI.h:549
bool(* SPI_TransferFxn)(SPI_Handle handle, SPI_Transaction *transaction)
A function pointer to a driver specific implementation of SPI_transfer().
Definition: SPI.h:705
void * arg
Definition: SPI.h:576
void * nextPtr
Definition: SPI.h:581
SPI_ControlFxn controlFxn
Definition: SPI.h:724
Definition: SPI.h:635
void(* SPI_TransferCancelFxn)(SPI_Handle handle)
A function pointer to a driver specific implementation of SPI_transferCancel().
Definition: SPI.h:711
void * txBuf
Definition: SPI.h:574
The definition of a SPI function table that contains the required set of functions to control a speci...
Definition: SPI.h:718
Definition: SPI.h:600
Definition: SPI.h:555
void(* SPI_CloseFxn)(SPI_Handle handle)
A function pointer to a driver specific implementation of SPI_close().
Definition: SPI.h:681
uint32_t dataSize
Definition: SPI.h:671
int_fast16_t SPI_control(SPI_Handle handle, uint_fast16_t cmd, void *controlArg)
Function performs implementation specific features on a given SPI_Handle.
Definition: SPI.h:612
A SPI_Transaction data structure is used with SPI_transfer(). It indicates how many SPI_FrameFormat f...
Definition: SPI.h:570
SPI_OpenFxn openFxn
Definition: SPI.h:730
bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction)
Function to perform SPI transactions.
struct SPI_Config_ SPI_Config
SPI Global configuration.
SPI_Mode
Definitions for various SPI modes of operation.
Definition: SPI.h:597
Definition: SPI.h:641
SPI Global configuration.
Definition: SPI.h:750
Definition: SPI.h:610
Definition: SPI.h:615
void * rxBuf
Definition: SPI.h:575
void SPI_close(SPI_Handle handle)
Function to close a SPI peripheral specified by the SPI handle.
struct SPI_Config_ * SPI_Handle
A handle that is returned from a SPI_open() call.
Definition: SPI.h:544
Definition: SPI.h:611
SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params)
This function opens a given SPI peripheral.
Definition: SPI.h:554
Definition: SPI.h:599
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().
Definition: SPI.h:687
void(* SPI_InitFxn)(SPI_Handle handle)
A function pointer to a driver specific implementation of SPI_init().
Definition: SPI.h:693
SPI_TransferFxn transferFxn
Definition: SPI.h:733
void * custom
Definition: SPI.h:673
Definition: SPI.h:552
SPI_Handle(* SPI_OpenFxn)(SPI_Handle handle, SPI_Params *params)
A function pointer to a driver specific implementation of SPI_open().
Definition: SPI.h:699
SPI_CallbackFxn transferCallbackFxn
Definition: SPI.h:657
Definition: SPI.h:551
SPI_Status status
Definition: SPI.h:579
Definition: SPI.h:559
Definition: SPI.h:553
SPI_FrameFormat
Definitions for various SPI data frame formats.
Definition: SPI.h:607
SPI_Mode mode
Definition: SPI.h:658
Definition: SPI.h:609
Provide a translation layer for legacy terminology.
SPI_InitFxn initFxn
Definition: SPI.h:727
void * object
Definition: SPI.h:756
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale