PDK API Guide for J721E
MCSPI.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 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 
53 #ifndef MCSPI_H
54 #define MCSPI_H
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
60 #include <ti/drv/spi/SPI.h>
61 
65 #define MCSPI_MAX_NUM_INSTANCES (SPI_MAX_CONFIG_CNT)
66 
70 #define MCSPI_MAX_NUM_CHANNELS (4U)
71 
75 typedef struct MCSPI_Config_s *MCSPI_Handle;
76 
81 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
82  SPI_Transaction *transaction);
83 
92 typedef struct MCSPI_Params_s {
94  uint32_t transferTimeout;
100  uint32_t bitRate;
101  uint32_t dataSize;
103  void *custom;
106 } MCSPI_Params;
107 
112 typedef void (*MCSPI_CloseFxn) (MCSPI_Handle handle);
113 
118 typedef int32_t (*MCSPI_ControlFxn) (MCSPI_Handle handle,
119  uint32_t cmd,
120  const void *arg);
121 
126 typedef void (*MCSPI_InitFxn) (MCSPI_Handle handle);
127 
133  const MCSPI_Params *params);
134 
139 typedef bool (*MCSPI_TransferFxn) (MCSPI_Handle handle,
140  SPI_Transaction *transaction);
141 
146 typedef void (*MCSPI_TransferCancelFxn) (MCSPI_Handle handle);
147 
153 typedef struct MCSPI_FxnTable_s {
156 
159 
162 
165 
168 
171 
173 
185 typedef struct MCSPI_Config_s {
188 
191 
193  uint32_t chnNum;
194 
195 } MCSPI_Config;
196 
198 
208 extern void MCSPI_close(MCSPI_Handle handle);
209 
229 extern int32_t MCSPI_control(MCSPI_Handle handle, uint32_t cmd, void *arg);
230 
239 extern void MCSPI_init(void);
240 
261 extern MCSPI_Handle MCSPI_open(uint32_t idx, uint32_t channel, MCSPI_Params *params);
262 
278 extern void MCSPI_Params_init(MCSPI_Params *params);
279 
310 extern bool MCSPI_transfer(MCSPI_Handle handle, SPI_Transaction *spiTrans);
311 
330 extern void MCSPI_transferCancel(MCSPI_Handle handle);
331 
332 #ifdef __cplusplus
333 }
334 #endif
335 
336 #endif /* _MCSPI_H */
337 
338 /* @} */
int32_t(* MCSPI_ControlFxn)(MCSPI_Handle handle, uint32_t cmd, const void *arg)
A function pointer to a driver specific implementation of MCSPI_control().
Definition: MCSPI.h:118
void MCSPI_Params_init(MCSPI_Params *params)
Function to initialize the MCSPI_Params struct to its defaults.
The definition of a MCSPI function table that contains the required set of functions to control a spe...
Definition: MCSPI.h:153
SPI_Mode
Definitions for various SPI modes of operation.
Definition: SPI.h:180
SPI_FrameFormat
Definitions for various SPI data frame formats.
Definition: SPI.h:189
MCSPI_InitFxn mcspiInitFxn
Definition: MCSPI.h:161
MCSPI Global configuration.
Definition: MCSPI.h:185
MCSPI_OpenFxn openFxn
Definition: MCSPI.h:164
uint32_t transferTimeout
Definition: MCSPI.h:94
struct SPI_Config_s * SPI_Handle
A handle that is returned from a SPI_open() call.
Definition: SPI.h:132
MCSPI_CallbackFxn transferCallbackFxn
Definition: MCSPI.h:97
uint32_t dataSize
Definition: MCSPI.h:101
MCSPI_Handle(* MCSPI_OpenFxn)(MCSPI_Handle handle, const MCSPI_Params *params)
A function pointer to a driver specific implementation of MCSPI_open().
Definition: MCSPI.h:132
bool MCSPI_transfer(MCSPI_Handle handle, SPI_Transaction *spiTrans)
Function to perform SPI transactions on a channel of a SPI peripheral specified by the MCSPI handle.
uint32_t bitRate
Definition: MCSPI.h:100
SPI_Mode mode
Definition: MCSPI.h:98
SPI_Handle handle
Definition: MCSPI.h:190
MCSPI_TransferFxn transferFxn
Definition: MCSPI.h:167
SPI driver interface.
int32_t MCSPI_control(MCSPI_Handle handle, uint32_t cmd, void *arg)
Function performs implementation specific features on a channel of a SPI peripheral specified by the ...
#define MCSPI_MAX_NUM_CHANNELS
Max number of channels of a MCSPI peripheral instance.
Definition: MCSPI.h:70
void * custom
Definition: MCSPI.h:103
MCSPI_Handle MCSPI_open(uint32_t idx, uint32_t channel, MCSPI_Params *params)
This function opens a given channel of a given MCSPI peripheral.
void(* MCSPI_InitFxn)(MCSPI_Handle handle)
A function pointer to a driver specific implementation of MCSPI_init().
Definition: MCSPI.h:126
MCSPI_CloseFxn closeFxn
Definition: MCSPI.h:155
MCSPI Parameters.
Definition: MCSPI.h:92
SPI_TransferMode
SPI transfer mode determines the whether the SPI controller operates synchronously or asynchronously....
Definition: SPI.h:208
#define MCSPI_MAX_NUM_INSTANCES
Max number of MCSPI peripheral instances.
Definition: MCSPI.h:65
void MCSPI_transferCancel(MCSPI_Handle handle)
Function to cancel SPI transactions on channel of a SPI peripheral specified by the MCSPI handle.
void MCSPI_init(void)
This function initializes the MCSPI module.
MCSPI_ControlFxn controlFxn
Definition: MCSPI.h:158
void(* MCSPI_CloseFxn)(MCSPI_Handle handle)
A function pointer to a driver specific implementation of MCSPI_close().
Definition: MCSPI.h:112
SPI_TransferMode transferMode
Definition: MCSPI.h:93
MCSPI_FxnTable const * fxnTablePtr
Definition: MCSPI.h:187
void(* MCSPI_TransferCancelFxn)(MCSPI_Handle handle)
A function pointer to a driver specific implementation of MCSPI_transferCancel().
Definition: MCSPI.h:146
bool(* MCSPI_TransferFxn)(MCSPI_Handle handle, SPI_Transaction *transaction)
A function pointer to a driver specific implementation of MCSPI_transfer().
Definition: MCSPI.h:139
void(* MCSPI_CallbackFxn)(MCSPI_Handle handle, SPI_Transaction *transaction)
The definition of a callback function used by the MCSPI driver when used in SPI_MODE_CALLBACK.
Definition: MCSPI.h:81
SPI_FrameFormat frameFormat
Definition: MCSPI.h:102
MCSPI_Config MCSPI_config_list[MCSPI_MAX_NUM_INSTANCES][MCSPI_MAX_NUM_CHANNELS]
Definition: MCSPI.h:197
MCSPI_TransferCancelFxn transferCancelFxn
Definition: MCSPI.h:170
uint32_t chnNum
Definition: MCSPI.h:193
A SPI_Transaction data structure is used with SPI_transfer(). It indicates how many SPI_FrameFormat f...
Definition: SPI.h:154
struct MCSPI_Config_s * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: MCSPI.h:75
void MCSPI_close(MCSPI_Handle handle)
Function to close a channel of a SPI peripheral specified by the MCSPI handle.