MSPM0G1X0X_G3X0X TI-Driver Library  1.20.01.06
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 SPI Driver Interface
36  *
37  * @defgroup SPI Serial Peripheral Interface (SPI)
38  *
39  * The SPI header file should be included in an application as follows:
40  * @code
41  * #include <ti/drivers/SPI.h>
42  * @endcode
43  *
44  * @anchor ti_drivers_SPI_Overview
45  * # Overview
46  * The Serial Peripheral Interface (SPI) driver is a generic, full-duplex
47  * driver that transmits and receives data on a SPI bus. SPI is sometimes
48  * called SSI (Synchronous Serial Interface).
49  * The SPI protocol defines the format of a data transfer over the SPI bus,
50  * but it leaves flow control, data formatting, and handshaking mechanisms
51  * to higher-level software layers.
52  *
53  * The SPI driver operates on some key definitions and assumptions:
54  * - The driver operates transparently from the chip select. Some SPI
55  * controllers feature a hardware chip select to assert SPI peripheral
56  * peripherals. See the specific device implementations on chip
57  * select requirements.
58  *
59  * - The SPI protocol does not account for a built-in handshaking mechanism
60  * and neither does this SPI driver. Therefore, when operating in
61  * #SPI_PERIPHERAL mode, the application must provide such a mechanism to
62  * ensure that the SPI peripheral is ready for the SPI controller. The SPI
63  * peripheral must call #SPI_transfer() *before* the SPI controller starts
64  * transmitting.
65  * Some example application mechanisms could include:
66  * - Timed delays on the SPI controller to guarantee the SPI peripheral is
67  * ready for a SPI transaction.
68  * - A form of GPIO flow control from the peripheral to the SPI controller to
69  * notify the controller when ready.
70  *
71  * <hr>
72  * @anchor ti_drivers_SPI_Usage
73  * # Usage
74  *
75  * To use the SPI driver to send data over the SPI bus, the application
76  * calls the following APIs:
77  * - SPI_init(): Initialize the SPI driver.
78  * - SPI_Params_init(): Initialize a #SPI_Params structure with default
79  * values. Then change the parameters from non-default values as
80  * needed.
81  * - SPI_open(): Open an instance of the SPI driver, passing the
82  * initialized parameters, or NULL, and an index to the configuration to
83  * open (detailed later).
84  * - SPI_transfer(): Transmit/receive data. This function takes a
85  * #SPI_Transaction argument that describes the transfer that is requested.
86  * - SPI_close(): De-initialize the SPI instance.
87  *
88  * @anchor ti_drivers_SPI_Synopsis
89  * ## Synopsis
90  * The following code example opens a SPI instance as a SPI controller,
91  * and issues a transaction.
92  *
93  * @code
94  * SPI_Handle spi;
95  * SPI_Params spiParams;
96  * SPI_Transaction spiTransaction;
97  * uint8_t transmitBuffer[MSGSIZE];
98  * uint8_t receiveBuffer[MSGSIZE];
99  * bool transferOK;
100  *
101  * SPI_init(); // Initialize the SPI driver
102  *
103  * SPI_Params_init(&spiParams); // Initialize SPI parameters
104  * spiParams.dataSize = 8; // 8-bit data size
105  *
106  * spi = SPI_open(CONFIG_SPI0, &spiParams);
107  * if (spi == NULL) {
108  * while (1); // SPI_open() failed
109  * }
110  *
111  * // Fill in transmitBuffer
112  * spiTransaction.count = MSGSIZE;
113  * spiTransaction.txBuf = (void *)transmitBuffer;
114  * spiTransaction.rxBuf = (void *)receiveBuffer;
115  *
116  * transferOK = SPI_transfer(spi, &spiTransaction);
117  * if (!transferOK) {
118  * // Error in SPI or transfer already in progress.
119  * while (1);
120  * }
121  * @endcode
122  *
123  * More details on usage are provided in the following subsections.
124  *
125  * @anchor ti_drivers_SPI_Examples
126  * ## Examples #
127  * * @ref ti_drivers_SPI_Synopsis "Usage Synopsis"
128  * * @ref ti_drivers_SPI_Example_openblocking "Open in blocking mode"
129  * * @ref ti_drivers_SPI_Example_opencallback "Open in callback mode"
130  * * @ref ti_drivers_SPI_Example_6bitframes "Sending 6 bit frames"
131  * * @ref ti_drivers_SPI_Example_12bitframes "Sending 12 bit frames"
132  * * @ref ti_drivers_SPI_Example_callbackarg "Callback function using arg"
133  *
134  * ## Initializing the SPI Driver
135  *
136  * SPI_init() must be called before any other SPI APIs. This function
137  * iterates through the elements of the @p SPI_config[] array, calling
138  * the element's device implementation SPI initialization function.
139  *
140  * ## Opening the SPI Driver
141  * After initializing the SPI driver by calling SPI_init(), the application
142  * can open a SPI instance by calling SPI_open(). This function
143  * takes an index into the @p SPI_config[] array, and a SPI parameters data
144  * structure. The SPI instance is specified by the index of the SPI in
145  * @p SPI_config[]. Calling SPI_open() a second time with the same index
146  * previously passed to SPI_open() will result in an error. You can,
147  * though, re-use the index if the instance is closed via SPI_close().
148  *
149  * If no #SPI_Params structure is passed to SPI_open(), default values are
150  * used. If the open call is successful, it returns a non-NULL value.
151  *
152  * @anchor ti_drivers_SPI_Example_openblocking
153  * Example opening a SPI driver instance in blocking mode:
154  * @code
155  * SPI_Handle spi;
156  * SPI_Params spiParams;
157  *
158  * SPI_Params_init(&spiParams);
159  * spiParams.transferMode = SPI_MODE_BLOCKING;
160  * spi = SPI_open(CONFIG_SPI0, &spiParams);
161  *
162  * if (spi == NULL) {
163  * // Error opening SPI
164  * while(1);
165  * }
166  * @endcode
167  *
168  * @anchor ti_drivers_SPI_Example_opencallback
169  * Example opening a SPI driver instance in callback mode:
170  * @code
171  * SPI_Handle spi;
172  * SPI_Params spiParams;
173  *
174  * SPI_Params_init(&spiParams);
175  * spiParams.transferMode = SPI_MODE_CALLBACK;
176  * spiParams.transferCallbackFxn = UserCallbackFxn;
177  *
178  * spi = SPI_open(CONFIG_SPI0, &spiParams);
179  * if (spi == NULL) {
180  * // Error opening SPI
181  * while (1);
182  * }
183  * @endcode
184  *
185  * ## SPI Parameters
186  *
187  * The #SPI_Params structure is passed to the SPI_open() call. If NULL
188  * is passed for the parameters, SPI_open() uses default parameters.
189  * A #SPI_Params structure is initialized with default values by passing
190  * it to SPI_Params_init().
191  * Some of the SPI parameters are described below. To see brief descriptions
192  * of all the parameters, see #SPI_Params.
193  *
194  * ### SPI Mode
195  * The SPI driver operates in both SPI controller and SPI peripheral modes.
196  * Logically, the implementation is identical, however the difference
197  * between these two modes is driven by hardware. The default mode is
198  * #SPI_CONTROLLER, but can be set to peripheral mode by setting
199  * #SPI_Params.mode to #SPI_PERIPHERAL in the parameters passed to SPI_open().
200  * See @ref ti_drivers_SPI_ControllerPeripheralModes "Controller/Peripheral Modes"
201  * for further details.
202  *
203  * ### SPI Transfer Mode
204  * The SPI driver supports two transfer modes of operation: blocking and
205  * callback. The transfer mode is determined by the transferMode parameter
206  * in the #SPI_Params data structure. The SPI driver
207  * defaults to blocking mode, if the application does not set it.
208  * Once a SPI driver is opened, the only way to change the operation mode
209  * is to close and re-open the SPI instance with the new transfer mode.
210  *
211  * In blocking mode, a task's code execution is blocked until a SPI
212  * transaction has completed or a timeout has occurred. This ensures
213  * that only one SPI transfer operates at a given time. Other tasks requesting
214  * SPI transfers while a transfer is currently taking place will receive
215  * a FALSE return value. If a timeout occurs the transfer is canceled, the
216  * task is unblocked & will receive a FALSE return value. The transaction
217  * count field will have the amount of frames which were transferred
218  * successfully before the timeout. In blocking mode, transfers cannot be
219  * performed in software or hardware ISR context.
220  *
221  * In callback mode, a SPI transaction functions asynchronously, which
222  * means that it does not block code execution. After a SPI transaction
223  * has been completed, the SPI driver calls a user-provided hook function.
224  * Callback mode is supported in the execution context of tasks and
225  * hardware interrupt routines.
226  *
227  * ### SPI Frame Formats and Data Size
228  * The SPI driver can configure the device's SPI peripheral to transfer
229  * data in several SPI format options: SPI (with various polarity and phase
230  * settings), TI, and Micro-wire. The frame format is set with
231  * #SPI_Params.frameFormat. Some SPI implementations may not support all frame
232  * formats & the SPI driver will fail to opened. Refer to the device specific
233  * implementation documentation for details on which frame formats are
234  * supported.
235  *
236  * The smallest single unit of data transmitted onto the SPI bus is called
237  * a SPI frame and is of size #SPI_Params.dataSize. A series of SPI frames
238  * transmitted/received on a SPI bus is referred to as a SPI transaction.
239  *
240  * ## SPI Transactions
241  *
242  * A SPI transaction consists of a series of SPI frames
243  * transmitted/received on a SPI bus. A SPI transaction is performed
244  * using SPI_transfer(). SPI_transfer() accepts a pointer to a
245  * #SPI_Transaction structure that dictates the quantity of data to be
246  * sent and received.
247  * The #SPI_Transaction.txBuf and #SPI_Transaction.rxBuf are both pointers
248  * to data buffers. If txBuf is NULL, the driver sends SPI frames with all
249  * data set to the default value specified in the hardware attributes. If
250  * rxBuf is NULL, the driver discards all SPI frames received. SPI_transfer()
251  * of a SPI transaction is performed atomically.
252  *
253  * @warning The use of NULL as a sentinel txBuf or rxBuf value to determine
254  * whether the SPI transaction includes a tx or rx component implies
255  * that it is not possible to perform a transmit or receive transfer
256  * directly from/to a buffer with a base address of 0x00000000. To support
257  * this rare use-case, the application will have to manually copy the
258  * contents of location 0x00000000 to/from a temporary buffer before/after
259  * the tx/rx SPI transaction.
260  *
261  * When the SPI is opened, the dataSize value determines the element types
262  * of txBuf and rxBuf. If the dataSize is from 4 to 8 bits, the driver
263  * assumes the data buffers are of type uint8_t (unsigned char). If the
264  * dataSize is from 8 to 16 bits, the driver assumes the data buffers are
265  * of type uint16_t (unsigned short). If the dataSize is greater than
266  * 16 bits, the driver assumes the data buffers are uint32_t (unsigned long).
267  * Some SPI driver implementations may not support all data sizes; refer
268  * to device specific SPI implementation documentation for details on
269  * what data sizes are supported.
270  *
271  * The optional #SPI_Transaction.arg variable can only be used when the
272  * SPI driver has been opened in callback mode. This variable is used to
273  * pass a user-defined value into the user-defined callback function.
274  *
275  * SPI_transfer() always performs full-duplex SPI transactions. This means
276  * the SPI simultaneously receives data as it transmits data. The application
277  * is responsible for formatting the data to be transmitted as well as
278  * determining whether the data received is meaningful.
279  * Specifics about SPI frame formatting and data sizes are provided in
280  * device-specific data sheets and technical reference manuals.
281  *
282  * The following code snippets perform SPI transactions.
283  *
284  * @anchor ti_drivers_SPI_Example_6bitframes
285  * Example transferring 6-bit SPI frames. The transmit and receive
286  * buffers are of type uint8_t.
287  * @code
288  * SPI_Transaction spiTransaction;
289  * uint8_t transmitBuffer[BUFSIZE];
290  * uint8_t receiveBuffer[BUFSIZE];
291  * bool transferOK;
292  *
293  * SPI_Params_init(&spiParams);
294  * spiParams.dataSize = 6;
295  * spi = SPI_open(CONFIG_SPI0, &spiParams);
296  * ...
297  * spiTransaction.count = someIntegerValue;
298  * spiTransaction.txBuf = transmitBuffer;
299  * spiTransaction.rxBuf = receiveBuffer;
300  *
301  * transferOK = SPI_transfer(spi, &spiTransaction);
302  * if (!transferOK) {
303  * // Error in SPI or transfer already in progress.
304  * }
305  * @endcode
306  *
307  * @anchor ti_drivers_SPI_Example_12bitframes
308  * Example transferring 12-bit SPI frames. The transmit and receive
309  * buffers are of type uint16_t.
310  * @code
311  * SPI_Transaction spiTransaction;
312  * uint16_t transmitBuffer[BUFSIZE];
313  * uint16_t receiveBuffer[BUFSIZE];
314  * bool transferOK;
315  *
316  * SPI_Params_init(&spiParams);
317  * spiParams.dataSize = 12;
318  * spi = SPI_open(CONFIG_SPI0, &spiParams);
319  * ...
320  * spiTransaction.count = someIntegerValue;
321  * spiTransaction.txBuf = transmitBuffer;
322  * spiTransaction.rxBuf = receiveBuffer;
323  *
324  * transferOK = SPI_transfer(spi, &spiTransaction);
325  * if (!transferOK) {
326  * // Error in SPI or transfer already in progress.
327  * }
328  * @endcode
329  *
330  * The following example shows an example of a callback function that
331  * utilizes the arg parameter.
332  * @anchor ti_drivers_SPI_Example_callbackarg
333  * @code
334  * // SPI is opened with callback function as seen in other examples
335  * // Our goal is to post a semaphore when transfer with sufficient size
336  * // completes.
337  * ...
338  * // Pass pointer to an initialized semaphore to callback via arg
339  * spiTransaction.count = someIntegerValue;
340  * spiTransaction.txBuf = transmitBuffer;
341  * spiTransaction.rxBuf = receiveBuffer;
342  * spiTransaction.arg = &mySemaphore;
343  *
344  * ...
345  *
346  * // Our callback function is defined here
347  * void spiCallbackFxn(SPI_Handle spi, SPI_Transaction *tran)
348  * {
349  * sem_t *semPtr = (sem_t *)(tran->arg);
350  *
351  * // Post the semaphore if our transaction was more than LIMIT
352  * if (tran->status == SPI_STATUS_SUCCESS &&
353  * tran->count > LIMIT) {
354  * sem_post(semPtr);
355  * }
356  * }
357  * @endcode
358  *
359  * ## Canceling a transaction
360  * SPI_transferCancel() is used to cancel a SPI transaction when the driver is
361  * used in #SPI_MODE_CALLBACK mode.
362  *
363  * Calling this API while no transfer is in progress has no effect. If a
364  * transfer is in progress, it is canceled and the callback functions is
365  * called.
366  * The #SPI_Status status field in the #SPI_Transaction structure
367  * can be examined within the callback to determine if the transaction
368  * succeeded.
369  *
370  * Example:
371  * @code
372  * SPI_transferCancel(spi);
373  * @endcode
374  *
375  * @anchor ti_drivers_SPI_ControllerPeripheralModes
376  * ## Controller/Peripheral Modes
377  * This SPI driver functions in both SPI controller and SPI peripheral modes.
378  * Logically, the implementation is identical, however the difference between
379  * these two modes is driven by hardware. As a SPI controller, the peripheral is
380  * in control of the clock signal and therefore will commence communications
381  * to the SPI peripheral immediately. As a SPI peripheral, the SPI driver
382  * prepares the peripheral to transmit and receive data in a way such that the
383  * peripheral is ready to transfer data when the SPI controller initiates a
384  * transaction.
385  *
386  * ## Asserting on Chip Select
387  * The SPI protocol requires that the SPI controller asserts a SPI peripheral's
388  * chip select pin prior to starting a SPI transaction. While this protocol is
389  * generally followed, various types of SPI peripherals have different
390  * timing requirements as to when and for how long the chip select pin must
391  * remain asserted for a SPI transaction.
392  *
393  * Commonly, the SPI controller uses a hardware chip select to assert and
394  * de-assert the SPI peripheral for every data frame. In other cases, a SPI
395  * peripheral imposes the requirement of asserting the chip select over several SPI
396  * data frames. This is generally accomplished by using a regular,
397  * general-purpose output pin. Due to the complexity of such SPI peripheral
398  * implementations, this SPI driver has been designed to operate
399  * transparently to the SPI chip select. When the hardware chip
400  * select is used, the peripheral automatically selects/enables the
401  * peripheral. When using a software chip select, the application needs to
402  * handle the proper chip select and pin configuration. Chip select support
403  * will vary per SPI peripheral, refer to the device specific implementation
404  * documentation for details on chip select support.
405  *
406  * - _Hardware chip select_ No additional action by the application is
407  * required.
408  * - _Software chip select_ The application needs to handle the chip select
409  * assertion and de-assertion for the proper SPI peripheral.
410  *
411  * <hr>
412  * @anchor ti_drivers_SPI_Configuration
413  * # Configuration
414  *
415  * In order to use the SPI APIs, the application is required to provide
416  * device-specific SPI configuration in the ti_drivers_config.c file.
417  * The SPI driver interface defines a configuration data structure:
418  *
419  * @code
420  * typedef struct {
421  * SPI_FxnTable const *fxnTablePtr;
422  * void *object;
423  * void const *hwAttrs;
424  * } SPI_Config;
425  * @endcode
426  *
427  * The application must declare an array of #SPI_Config elements, named
428  * @p SPI_config[]. Each element of @p SPI_config[] must be populated with
429  * pointers to a device specific SPI driver implementation's function
430  * table, driver object, and hardware attributes. The hardware attributes
431  * define properties such as the SPI peripheral's base address, and
432  * the PICO and POCI pins. Each element in @p SPI_config[] corresponds to
433  * a SPI instance, and none of the elements should have NULL pointers.
434  * There is no correlation between the index and the
435  * peripheral designation (such as SPI0 or SPI1). For example, it is
436  * possible to use SPI_config[0] for SPI1.
437  *
438  * Because the SPI configuration is very device dependent, you will need to
439  * check the doxygen for the device specific SPI implementation. There you
440  * will find a description of the SPI hardware attributes. Please also
441  * refer to the ti_drivers_config.c file of any of your examples to see the
442  * SPI configuration.
443  *
444  *******************************************************************************
445  */
449 /* clang-format off */
450 #ifndef ti_drivers_SPI__include
451 #define ti_drivers_SPI__include
452 
453 #include <stdbool.h>
454 #include <stddef.h>
455 #include <stdint.h>
456 
457 #ifdef __cplusplus
458 extern "C" {
459 #endif
460 
478 #define SPI_CMD_RESERVED (32)
479 
492 #define SPI_STATUS_RESERVED (-32)
493 
507 #define SPI_STATUS_SUCCESS (0)
508 
515 #define SPI_STATUS_ERROR (-1)
516 
524 #define SPI_STATUS_UNDEFINEDCMD (-2)
525 
535 /* Add SPI_CMD_<commands> here */
536 
544 #define SPI_WAIT_FOREVER (~(0U))
545 
549 typedef struct SPI_Config_ *SPI_Handle;
550 
554 typedef enum
555 {
574 } SPI_Status;
575 
584 typedef struct
585 {
586  /* User input (write-only) fields */
588  size_t count;
590  void *txBuf;
592  void *rxBuf;
594  void *arg;
595  /* User output (read-only) fields */
597  SPI_Status status;
601  void *nextPtr;
603 
611 typedef void (*SPI_CallbackFxn)(SPI_Handle handle, SPI_Transaction *transaction);
616 typedef enum
617 {
622 } SPI_Mode;
623 
628 typedef enum
629 {
636 } SPI_Parity;
641 typedef enum
642 {
647 } SPI_BitOrder;
652 typedef enum
653 {
665 
670 typedef enum
671 {
691  SPI_TI = 8
693 
704 typedef enum
705 {
718 
727 typedef struct
728 {
730  SPI_TransferMode transferMode;
732  uint32_t transferTimeout;
738  uint32_t bitRate;
740  uint32_t dataSize;
748  void *custom;
749 } SPI_Params;
750 
755 typedef void (*SPI_CloseFxn)(SPI_Handle handle);
756 
761 typedef int_fast16_t (*SPI_ControlFxn)(SPI_Handle handle, uint_fast16_t cmd, void *arg);
762 
767 typedef void (*SPI_InitFxn)(SPI_Handle handle);
768 
773 typedef SPI_Handle (*SPI_OpenFxn)(SPI_Handle handle, SPI_Params *params);
774 
779 typedef bool (*SPI_TransferFxn)(SPI_Handle handle, SPI_Transaction *transaction);
780 
785 typedef void (*SPI_TransferCancelFxn)(SPI_Handle handle);
786 
792 typedef struct
793 {
796 
799 
802 
805 
808 
811 } SPI_FxnTable;
812 
824 typedef struct SPI_Config_
825 {
828 
830  void *object;
831 
833  void const *hwAttrs;
834 } SPI_Config;
835 
845 extern void SPI_close(SPI_Handle handle);
846 
884 extern int_fast16_t SPI_control(SPI_Handle handle, uint_fast16_t cmd, void *controlArg);
885 
894 extern void SPI_init(void);
895 
913 extern SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params);
914 
932 extern void SPI_Params_init(SPI_Params *params);
933 
978 extern bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction);
979 
999 extern void SPI_transferCancel(SPI_Handle handle);
1000 
1001 #ifdef __cplusplus
1002 }
1003 #endif
1004 
1005 #endif /* ti_drivers_SPI__include */
1006 /* clang-format on */
Definition: SPI.h:557
Definition: SPI.h:716
Definition: SPI.h:635
bool(* SPI_TransferFxn)(SPI_Handle handle, SPI_Transaction *transaction)
A function pointer to a driver specific implementation of SPI_transfer().
Definition: SPI.h:779
Definition: SPI.h:685
Definition: SPI.h:683
uint32_t bitRate
SPI bit rate in Hz.
Definition: SPI.h:738
size_t count
Definition: SPI.h:588
void const * hwAttrs
Definition: SPI.h:833
SPI_FrameFormat frameFormat
Definition: SPI.h:742
Definition: SPI.h:675
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:611
void(* SPI_InitFxn)(SPI_Handle handle)
A function pointer to a driver specific implementation of SPI_init().
Definition: SPI.h:767
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:761
uint32_t transferTimeout
Definition: SPI.h:732
SPI_TransferMode transferMode
Definition: SPI.h:730
SPI_FxnTable const * fxnTablePtr
Definition: SPI.h:827
SPI_CloseFxn closeFxn
Definition: SPI.h:795
SPI_TransferCancelFxn transferCancelFxn
Definition: SPI.h:810
Definition: SPI.h:644
SPI Parameters.
Definition: SPI.h:727
Definition: SPI.h:655
SPI_TransferMode
SPI transfer mode determines the whether the SPI controller operates synchronously or asynchronously...
Definition: SPI.h:704
void * arg
Definition: SPI.h:594
Definition: SPI.h:573
void * nextPtr
Definition: SPI.h:601
void SPI_Params_init(SPI_Params *params)
Function to initialize the SPI_Params struct to its defaults.
SPI_ControlFxn controlFxn
Definition: SPI.h:798
Definition: SPI.h:657
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:679
Definition: SPI.h:687
Definition: SPI.h:619
void(* SPI_TransferCancelFxn)(SPI_Handle handle)
A function pointer to a driver specific implementation of SPI_transferCancel().
Definition: SPI.h:785
SPI_Parity parity
Definition: SPI.h:744
void * txBuf
Definition: SPI.h:590
The definition of a SPI function table that contains the required set of functions to control a speci...
Definition: SPI.h:792
SPI_BitOrder bitOrder
Definition: SPI.h:746
Definition: SPI.h:563
SPI_FrameFormat
Definitions for various SPI data frame formats.
Definition: SPI.h:670
void(* SPI_CloseFxn)(SPI_Handle handle)
A function pointer to a driver specific implementation of SPI_close().
Definition: SPI.h:755
uint32_t dataSize
Definition: SPI.h:740
SPI_Mode
Definitions for various SPI modes of operation.
Definition: SPI.h:616
Definition: SPI.h:661
SPI_Parity
Definitions for parity.
Definition: SPI.h:628
SPI_Chip_Select
Definitions for chip select.
Definition: SPI.h:652
Definition: SPI.h:710
Definition: SPI.h:633
void SPI_init(void)
This function initializes the SPI module.
A SPI_Transaction data structure is used with SPI_transfer(). It indicates how many SPI_FrameFormat f...
Definition: SPI.h:584
SPI_OpenFxn openFxn
Definition: SPI.h:804
Definition: SPI.h:659
SPI Global configuration.
Definition: SPI.h:824
Definition: SPI.h:646
Definition: SPI.h:571
Definition: SPI.h:561
void * rxBuf
Definition: SPI.h:592
Definition: SPI.h:567
Definition: SPI.h:559
struct SPI_Config_ SPI_Config
SPI Global configuration.
void SPI_close(SPI_Handle handle)
Function to close a SPI peripheral specified by the SPI handle.
SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params)
This function opens a given SPI peripheral.
SPI_Status
Status codes that are set by the SPI driver.
Definition: SPI.h:554
Definition: SPI.h:663
Definition: SPI.h:677
Definition: SPI.h:673
SPI_TransferFxn transferFxn
Definition: SPI.h:807
Definition: SPI.h:681
void * custom
Definition: SPI.h:748
SPI_BitOrder
Definitions for bit order.
Definition: SPI.h:641
SPI_Handle(* SPI_OpenFxn)(SPI_Handle handle, SPI_Params *params)
A function pointer to a driver specific implementation of SPI_open().
Definition: SPI.h:773
Definition: SPI.h:621
SPI_CallbackFxn transferCallbackFxn
Definition: SPI.h:734
bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction)
Function to perform SPI transactions.
SPI_Status status
Definition: SPI.h:597
struct SPI_Config_ * SPI_Handle
A handle that is returned from a SPI_open() call.
Definition: SPI.h:549
void SPI_transferCancel(SPI_Handle handle)
Function to cancel SPI transactions.
Definition: SPI.h:631
Definition: SPI.h:691
SPI_Mode mode
Definition: SPI.h:736
SPI_InitFxn initFxn
Definition: SPI.h:801
void * object
Definition: SPI.h:830
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale