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_DOMAIN_CNT (SPI_MAX_DOMAIN_CNT)
71 
75 #define MCSPI_MAX_NUM_CHANNELS (CSL_MCSPI_CHAN_CNT)
76 
80 typedef struct MCSPI_Config_s *MCSPI_Handle;
81 
86 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
87  SPI_Transaction *transaction);
88 
97 typedef struct MCSPI_Params_s {
99  uint32_t transferTimeout;
105  uint32_t bitRate;
106  uint32_t dataSize;
108  void *custom;
111 } MCSPI_Params;
112 
117 typedef void (*MCSPI_CloseFxn) (MCSPI_Handle handle);
118 
123 typedef int32_t (*MCSPI_ControlFxn) (MCSPI_Handle handle,
124  uint32_t cmd,
125  const void *arg);
126 
131 typedef void (*MCSPI_InitFxn) (MCSPI_Handle handle);
132 
138  const MCSPI_Params *params);
139 
144 typedef bool (*MCSPI_TransferFxn) (MCSPI_Handle handle,
145  SPI_Transaction *transaction);
146 
151 typedef void (*MCSPI_TransferCancelFxn) (MCSPI_Handle handle);
152 
158 typedef struct MCSPI_FxnTable_s {
161 
164 
167 
170 
173 
176 
178 
190 typedef struct MCSPI_Config_s {
193 
196 
198  uint32_t chnNum;
199 
200 } MCSPI_Config;
201 
203 
213 extern void MCSPI_close(MCSPI_Handle handle);
214 
234 extern int32_t MCSPI_control(MCSPI_Handle handle, uint32_t cmd, void *arg);
235 
244 extern void MCSPI_init(void);
245 
269 extern MCSPI_Handle MCSPI_open(uint32_t domain, uint32_t idx, uint32_t channel, MCSPI_Params *params);
270 
286 extern void MCSPI_Params_init(MCSPI_Params *params);
287 
318 extern bool MCSPI_transfer(MCSPI_Handle handle, SPI_Transaction *spiTrans);
319 
338 extern void MCSPI_transferCancel(MCSPI_Handle handle);
339 
340 #ifdef __cplusplus
341 }
342 #endif
343 
344 #endif /* _MCSPI_H */
345 
346 /* @} */
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:123
void MCSPI_Params_init(MCSPI_Params *params)
Function to initialize the MCSPI_Params struct to its defaults.
MCSPI_Config MCSPI_config_list[MCSPI_MAX_DOMAIN_CNT][MCSPI_MAX_NUM_INSTANCES][MCSPI_MAX_NUM_CHANNELS]
Definition: MCSPI.h:202
The definition of a MCSPI function table that contains the required set of functions to control a spe...
Definition: MCSPI.h:158
SPI_Mode
Definitions for various SPI modes of operation.
Definition: SPI.h:185
SPI_FrameFormat
Definitions for various SPI data frame formats.
Definition: SPI.h:194
MCSPI_InitFxn mcspiInitFxn
Definition: MCSPI.h:166
MCSPI Global configuration.
Definition: MCSPI.h:190
MCSPI_OpenFxn openFxn
Definition: MCSPI.h:169
uint32_t transferTimeout
Definition: MCSPI.h:99
struct SPI_Config_s * SPI_Handle
A handle that is returned from a SPI_open() call.
Definition: SPI.h:135
MCSPI_CallbackFxn transferCallbackFxn
Definition: MCSPI.h:102
uint32_t dataSize
Definition: MCSPI.h:106
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:137
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:105
SPI_Mode mode
Definition: MCSPI.h:103
SPI_Handle handle
Definition: MCSPI.h:195
MCSPI_TransferFxn transferFxn
Definition: MCSPI.h:172
SPI driver interface.
MCSPI_Handle MCSPI_open(uint32_t domain, uint32_t idx, uint32_t channel, MCSPI_Params *params)
This function opens a given channel of a given MCSPI peripheral.
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:75
void * custom
Definition: MCSPI.h:108
void(* MCSPI_InitFxn)(MCSPI_Handle handle)
A function pointer to a driver specific implementation of MCSPI_init().
Definition: MCSPI.h:131
MCSPI_CloseFxn closeFxn
Definition: MCSPI.h:160
MCSPI Parameters.
Definition: MCSPI.h:97
SPI_TransferMode
SPI transfer mode determines the whether the SPI controller operates synchronously or asynchronously....
Definition: SPI.h:213
#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.
gptp_ipc_command_t cmd
Definition: gptpipc.h:140
void MCSPI_init(void)
This function initializes the MCSPI module.
MCSPI_ControlFxn controlFxn
Definition: MCSPI.h:163
domgrp_t domain
Definition: tisci_pm_core.h:130
void(* MCSPI_CloseFxn)(MCSPI_Handle handle)
A function pointer to a driver specific implementation of MCSPI_close().
Definition: MCSPI.h:117
SPI_TransferMode transferMode
Definition: MCSPI.h:98
#define MCSPI_MAX_DOMAIN_CNT
Max number of MCSPI peripheral domains.
Definition: MCSPI.h:70
MCSPI_FxnTable const * fxnTablePtr
Definition: MCSPI.h:192
void(* MCSPI_TransferCancelFxn)(MCSPI_Handle handle)
A function pointer to a driver specific implementation of MCSPI_transferCancel().
Definition: MCSPI.h:151
bool(* MCSPI_TransferFxn)(MCSPI_Handle handle, SPI_Transaction *transaction)
A function pointer to a driver specific implementation of MCSPI_transfer().
Definition: MCSPI.h:144
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:86
SPI_FrameFormat frameFormat
Definition: MCSPI.h:107
MCSPI_TransferCancelFxn transferCancelFxn
Definition: MCSPI.h:175
uint32_t chnNum
Definition: MCSPI.h:198
A SPI_Transaction data structure is used with SPI_transfer(). It indicates how many SPI_FrameFormat f...
Definition: SPI.h:157
struct MCSPI_Config_s * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: MCSPI.h:80
void MCSPI_close(MCSPI_Handle handle)
Function to close a channel of a SPI peripheral specified by the MCSPI handle.