AM64x MCU+ SDK  08.02.00
mcspi/v0/mcspi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * 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
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
50 #ifndef MCSPI_H_
51 #define MCSPI_H_
52 
53 /* ========================================================================== */
54 /* Include Files */
55 /* ========================================================================== */
56 
57 #include <stdint.h>
58 #include <kernel/dpl/SystemP.h>
59 #include <kernel/dpl/SemaphoreP.h>
60 #include <kernel/dpl/HwiP.h>
61 #include <drivers/hw_include/csl_types.h>
62 #include <drivers/hw_include/cslr_mcspi.h>
63 #include <drivers/hw_include/cslr.h>
64 
65 #if defined (DRV_VERSION_MCSPI_V0)
67 #endif
68 
69 #if defined (DRV_VERSION_MCSPI_V1)
70 /* Include EDMA */
71 #endif
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 /* ========================================================================== */
78 /* Macros & Typedefs */
79 /* ========================================================================== */
80 
82 typedef void *MCSPI_Handle;
83 
93 #define MCSPI_CHANNEL_0 (0U)
94 #define MCSPI_CHANNEL_1 (1U)
95 #define MCSPI_CHANNEL_2 (2U)
96 #define MCSPI_CHANNEL_3 (3U)
97 
107 #define MCSPI_OPER_MODE_POLLED (0U)
108 #define MCSPI_OPER_MODE_INTERRUPT (1U)
109 #define MCSPI_OPER_MODE_DMA (2U)
110 
113 #define MCSPI_MAX_NUM_CHANNELS (4U)
114 
123 #define MCSPI_TRANSFER_COMPLETED (0U)
124 #define MCSPI_TRANSFER_STARTED (1U)
125 #define MCSPI_TRANSFER_CANCELLED (2U)
126 #define MCSPI_TRANSFER_FAILED (3U)
127 #define MCSPI_TRANSFER_CSN_DEASSERT (4U)
128 #define MCSPI_TRANSFER_TIMEOUT (5U)
129 
150 #define MCSPI_TRANSFER_MODE_BLOCKING (0U)
151 
155 #define MCSPI_TRANSFER_MODE_CALLBACK (1U)
156 
174 #define MCSPI_MS_MODE_MASTER (CSL_MCSPI_MODULCTRL_MS_MASTER)
175 
176 #define MCSPI_MS_MODE_SLAVE (CSL_MCSPI_MODULCTRL_MS_SLAVE)
177 
193 #define MCSPI_FF_POL0_PHA0 (0U)
194 #define MCSPI_FF_POL0_PHA1 (1U)
195 #define MCSPI_FF_POL1_PHA0 (2U)
196 #define MCSPI_FF_POL1_PHA1 (3U)
197 
208 #define MCSPI_CS_POL_HIGH (CSL_MCSPI_CH0CONF_EPOL_ACTIVEHIGH)
209 
210 #define MCSPI_CS_POL_LOW (CSL_MCSPI_CH0CONF_EPOL_ACTIVELOW)
211 
219 #define MCSPI_TR_MODE_TX_RX (CSL_MCSPI_CH0CONF_TRM_TRANSRECEI)
220 #define MCSPI_TR_MODE_RX_ONLY (CSL_MCSPI_CH0CONF_TRM_RECEIVONLY)
221 #define MCSPI_TR_MODE_TX_ONLY (CSL_MCSPI_CH0CONF_TRM_TRANSONLY)
222 
231 #define MCSPI_IS_D0 (CSL_MCSPI_CH0CONF_IS_LINE0)
232 
233 #define MCSPI_IS_D1 (CSL_MCSPI_CH0CONF_IS_LINE1)
234 
243 #define MCSPI_DPE_ENABLE (CSL_MCSPI_CH0CONF_DPE0_ENABLED)
244 
245 #define MCSPI_DPE_DISABLE (CSL_MCSPI_CH0CONF_DPE0_DISABLED)
246 
254 #define MCSPI_SLV_CS_SELECT_0 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN0)
255 #define MCSPI_SLV_CS_SELECT_1 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN1)
256 #define MCSPI_SLV_CS_SELECT_2 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN2)
257 #define MCSPI_SLV_CS_SELECT_3 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN3)
258 
267 #define MCSPI_SB_POL_HIGH (CSL_MCSPI_CH0CONF_SBPOL_HIGHLEVEL)
268 
269 #define MCSPI_SB_POL_LOW (CSL_MCSPI_CH0CONF_SBPOL_LOWLEVEL)
270 
281 #define MCSPI_TCS0_0_CLK (CSL_MCSPI_CH0CONF_TCS0_ZEROCYCLEDLY)
282 
283 #define MCSPI_TCS0_1_CLK (CSL_MCSPI_CH0CONF_TCS0_ONECYCLEDLY)
284 
285 #define MCSPI_TCS0_2_CLK (CSL_MCSPI_CH0CONF_TCS0_TWOCYCLEDLY)
286 
287 #define MCSPI_TCS0_3_CLK (CSL_MCSPI_CH0CONF_TCS0_THREECYCLEDLY)
288 
300 #define MCSPI_CH_MODE_SINGLE (CSL_MCSPI_MODULCTRL_SINGLE_SINGLE)
301 
302 #define MCSPI_CH_MODE_MULTI (CSL_MCSPI_MODULCTRL_SINGLE_MULTI)
303 
315 #define MCSPI_PINMODE_3PIN (CSL_MCSPI_MODULCTRL_PIN34_3PINMODE)
316 #define MCSPI_PINMODE_4PIN (CSL_MCSPI_MODULCTRL_PIN34_4PINMODE)
317 
328 #define MCSPI_INITDLY_0 (CSL_MCSPI_MODULCTRL_INITDLY_NODELAY)
329 
330 #define MCSPI_INITDLY_4 (CSL_MCSPI_MODULCTRL_INITDLY_4CLKDLY)
331 
332 #define MCSPI_INITDLY_8 (CSL_MCSPI_MODULCTRL_INITDLY_8CLKDLY)
333 
334 #define MCSPI_INITDLY_16 (CSL_MCSPI_MODULCTRL_INITDLY_16CLKDLY)
335 
336 #define MCSPI_INITDLY_32 (CSL_MCSPI_MODULCTRL_INITDLY_32CLKDLY)
337 
339 /* ========================================================================== */
340 /* Structure Declarations */
341 /* ========================================================================== */
342 
351 typedef struct
352 {
353  uint32_t channel;
356  uint32_t csDisable;
358  uint32_t dataSize;
369  uint32_t count;
372  void *txBuf;
383  void *rxBuf;
390  void *args;
392  uint32_t status;
395 
403 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
404  MCSPI_Transaction *transaction);
405 
416 typedef struct
417 {
418  uint32_t transferMode;
420  uint32_t transferTimeout;
424  uint32_t msMode;
426  int32_t mcspiDmaIndex;
431 
443 typedef struct
444 {
445  uint32_t chNum;
447  uint32_t frameFormat;
449  uint32_t bitRate;
451  uint32_t csPolarity;
453  uint32_t trMode;
455  uint32_t inputSelect;
457  uint32_t dpe0;
459  uint32_t dpe1;
461  uint32_t slvCsSelect;
464  uint32_t startBitEnable;
470  uint32_t csIdleTime;
473  uint32_t defaultTxData;
477 
479 typedef struct
480 {
481  /*
482  * SOC configuration
483  */
484  uint32_t baseAddr;
486  uint32_t inputClkFreq;
489  /*
490  * Driver configuration
491  */
492  uint32_t intrNum;
494  uint32_t operMode;
496  uint8_t intrPriority;
499  /*
500  * MCSPI instance configuration - common across all channels
501  */
502  uint32_t chMode;
504  uint32_t pinMode;
506  uint32_t initDelay;
508 } MCSPI_Attrs;
509 
510 /* ========================================================================== */
511 /* Internal/Private Structure Declarations */
512 /* ========================================================================== */
513 
517 typedef struct
518 {
519  /*
520  * User parameters
521  */
525  /*
526  * State variables
527  */
528  uint32_t isOpen;
530  uint32_t csDisable;
532  uint32_t csEnable;
534  const uint8_t *curTxBufPtr;
536  uint8_t *curRxBufPtr;
538  uint32_t curTxWords;
542  uint32_t curRxWords;
545  /*
546  * MCSPI derived variables
547  */
548  uint8_t bufWidthShift;
556  uint32_t txFifoTrigLvl;
558  uint32_t rxFifoTrigLvl;
560  uint32_t effTxFifoDepth;
562  uint32_t effRxFifoDepth;
564  uint32_t intrMask;
568 
572 typedef struct
573 {
574  /*
575  * User parameters
576  */
581  uint32_t baseAddr;
586  /*
587  * State variables
588  */
589  uint32_t isOpen;
591  void *transferSem;
596  void *hwiHandle;
605 } MCSPI_Object;
606 
616 typedef struct
617 {
622 } MCSPI_Config;
623 
625 extern MCSPI_Config gMcspiConfig[];
627 extern uint32_t gMcspiConfigNum;
628 
629 /* ========================================================================== */
630 /* Function Declarations */
631 /* ========================================================================== */
632 
636 void MCSPI_init(void);
637 
641 void MCSPI_deinit(void);
642 
659 MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms);
660 
671 
683 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
684 
698  const MCSPI_ChConfig *chCfg,
699  const MCSPI_DmaChConfig *dmaChCfg);
742 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
743 
764 
771 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
772 
779 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
780 
787 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
788 /* ========================================================================== */
789 /* Static Function Definitions */
790 /* ========================================================================== */
791 
792 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
793 {
794  if(openPrms != NULL)
795  {
798  openPrms->transferCallbackFxn = NULL;
799  openPrms->msMode = MCSPI_MS_MODE_MASTER;
800  }
801 }
802 
803 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
804 {
805  if(chConfig != NULL)
806  {
807  chConfig->chNum = MCSPI_CHANNEL_0;
808  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
809  chConfig->bitRate = 1000000U;
810  chConfig->csPolarity = MCSPI_CS_POL_LOW;
811  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
812  chConfig->inputSelect = MCSPI_IS_D1;
813  chConfig->dpe0 = MCSPI_DPE_ENABLE;
814  chConfig->dpe1 = MCSPI_DPE_DISABLE;
816  chConfig->startBitEnable = FALSE;
818  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
819  chConfig->defaultTxData = 0x00000000U;
820  }
821 }
822 
823 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
824 {
825  if(trans != NULL)
826  {
827  trans->channel = 0U;
828  trans->csDisable = TRUE;
829  trans->dataSize = 8U;
830  trans->count = 0U;
831  trans->txBuf = NULL;
832  trans->rxBuf = NULL;
833  trans->args = NULL;
835  }
836 }
837 
838 /* ========================================================================== */
839 /* Advanced Macros & Typedefs */
840 /* ========================================================================== */
842 #define MCSPI_FIFO_LENGTH (64U)
843 
846 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
847  << \
848  CSL_MCSPI_CH0CONF_FFER_SHIFT)
849 
853 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
854  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
855 
859 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
860  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
861 
865 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
866  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
867 
871 #define MCSPI_REG_OFFSET (0x14U)
872 
873 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
874  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
875  (uint32_t) (x)))
876 
877 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
878  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
879  (uint32_t) (x)))
880 
881 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
882  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
883  (uint32_t) (x)))
884 
885 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
886  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
887  (uint32_t) (x)))
888 
889 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
890  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
891  (uint32_t) (x)))
892 
893 #define MCSPI_CLKD_MASK (0x0FU)
894 
896 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
897  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
898  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
899  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
900  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
901  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
902  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
903  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
904  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
905  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
906  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
907  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
908  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
909  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
910  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
911 
912 /* ========================================================================== */
913 /* Advanced Function Declarations */
914 /* ========================================================================== */
924 
937  uint32_t chNum,
938  uint32_t numWordsRxTx);
939 
954 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
955 
979 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
980 
991 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
992 
1002 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1003  uint32_t regVal);
1004 
1015 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1016 
1026 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1027  uint32_t regVal);
1028 
1045 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1046  uint32_t txData,
1047  uint32_t chNum);
1048 
1068 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1069  uint32_t enableFlag);
1070 
1090 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1091  uint32_t enableFlag);
1092 
1108 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1109  uint32_t chNum);
1110 
1127 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1128  uint32_t dataWidth);
1129 
1130 /* ========================================================================== */
1131 /* Advanced Function Definitions */
1132 /* ========================================================================== */
1133 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1134 {
1135  uint32_t bufWidthShift = 0U;
1136 
1137  if(dataSize <= 8U)
1138  {
1139  bufWidthShift = 0U;
1140  }
1141  else if(dataSize <= 16U)
1142  {
1143  bufWidthShift = 1U;
1144  }
1145  else
1146  {
1147  bufWidthShift = 2U;
1148  }
1149 
1150  return bufWidthShift;
1151 }
1152 
1153 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1154 {
1155  /* Return the status from MCSPI_CHSTAT register. */
1156  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1157 }
1158 
1159 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1160 {
1161  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1162 }
1163 
1164 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1165  uint32_t regVal)
1166 {
1167  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1168 }
1169 
1170 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1171 {
1172  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1173 }
1174 
1175 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1176  uint32_t regVal)
1177 {
1178  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1179 }
1180 
1181 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1182  uint32_t txData,
1183  uint32_t chNum)
1184 {
1185  /* Load the MCSPI_TX register with the data to be transmitted */
1186  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1187 }
1188 
1189 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1190  uint32_t chNum,
1191  uint32_t enableFlag)
1192 {
1193  /* Set the FFEW field with user sent value. */
1194  CSL_REG32_FINS(
1195  baseAddr + MCSPI_CHCONF(chNum),
1196  MCSPI_CH0CONF_FFEW,
1197  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1198 }
1199 
1200 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1201  uint32_t chNum,
1202  uint32_t enableFlag)
1203 {
1204  /* Set the FFER field with the user sent value. */
1205  CSL_REG32_FINS(
1206  baseAddr + MCSPI_CHCONF(chNum),
1207  MCSPI_CH0CONF_FFER,
1208  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1209 }
1210 
1211 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1212 {
1213  /* Return the data present in the MCSPI_RX register. */
1214  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1215 }
1216 
1217 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1218  uint32_t dataWidth)
1219 {
1220  uint32_t regVal;
1221 
1222  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1223  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1224  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1225 }
1226 
1227 /* ========================================================================== */
1228 /* Internal/Private Structure Declarations */
1229 /* ========================================================================== */
1230 
1231 #ifdef __cplusplus
1232 }
1233 #endif
1234 
1235 #endif /* #ifndef MCSPI_H_ */
1236 
MCSPI_DmaChConfig
Definition: mcspi_dma_udma.h:50
MCSPI_IS_D1
#define MCSPI_IS_D1
Data line 1 (SPIDAT[1]) selected for reception.
Definition: mcspi/v0/mcspi.h:233
MCSPI_CHRX
#define MCSPI_CHRX(x)
Base address of McSPI_CHRX(x)
Definition: mcspi/v0/mcspi.h:889
MCSPI_dmaChConfig
int32_t MCSPI_dmaChConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg, const MCSPI_DmaChConfig *dmaChCfg)
Function to configure a DMA of a channel.
MCSPI_close
void MCSPI_close(MCSPI_Handle handle)
Function to close a MCSPI peripheral specified by the MCSPI handle.
MCSPI_Attrs
MCSPI instance attributes - used during init time.
Definition: mcspi/v0/mcspi.h:480
MCSPI_OpenParams::transferTimeout
uint32_t transferTimeout
Definition: mcspi/v0/mcspi.h:420
MCSPI_readRxDataReg
static uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
This API will return the data present in the MCSPI_RX register.
Definition: mcspi/v0/mcspi.h:1211
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:518
MCSPI_Transaction::count
uint32_t count
Definition: mcspi/v0/mcspi.h:369
MCSPI_writeTxDataReg
static void MCSPI_writeTxDataReg(uint32_t baseAddr, uint32_t txData, uint32_t chNum)
This API will put the data on to the McSPI Channel transmit register.
Definition: mcspi/v0/mcspi.h:1181
MCSPI_readChCtrlReg
static uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
This API returns Channel control register value.
Definition: mcspi/v0/mcspi.h:1159
MCSPI_CallbackFxn
void(* MCSPI_CallbackFxn)(MCSPI_Handle handle, MCSPI_Transaction *transaction)
The definition of a callback function used by the SPI driver when used in MCSPI_TRANSFER_MODE_CALLBAC...
Definition: mcspi/v0/mcspi.h:403
MCSPI_Attrs::operMode
uint32_t operMode
Definition: mcspi/v0/mcspi.h:494
MCSPI_Transaction::status
uint32_t status
Definition: mcspi/v0/mcspi.h:392
MCSPI_Transaction
Data structure used with MCSPI_transfer()
Definition: mcspi/v0/mcspi.h:352
MCSPI_Attrs::initDelay
uint32_t initDelay
Definition: mcspi/v0/mcspi.h:506
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:560
MCSPI_enableRxFIFO
static void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum, uint32_t enableFlag)
This API will enable/disable the Rx FIFOs of McSPI peripheral.
Definition: mcspi/v0/mcspi.h:1200
MCSPI_readChStatusReg
static uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
This API will return the status of the McSPI channel currently in use.
Definition: mcspi/v0/mcspi.h:1153
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:522
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:564
MCSPI_readChConf
static uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
This API returns Channel Config register value.
Definition: mcspi/v0/mcspi.h:1170
MCSPI_CS_POL_LOW
#define MCSPI_CS_POL_LOW
SPIEN (CS) is held low during the ACTIVE state.
Definition: mcspi/v0/mcspi.h:210
index
uint16_t index
Definition: tisci_rm_proxy.h:3
MCSPI_reConfigFifo
int32_t MCSPI_reConfigFifo(MCSPI_Handle handle, uint32_t chNum, uint32_t numWordsRxTx)
Function to re-configure Effective FIFO Words.
MCSPI_getBufWidthShift
static uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
This API will return the buffer width in bytes based on dataSize.
Definition: mcspi/v0/mcspi.h:1133
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:418
MCSPI_DPE_DISABLE
#define MCSPI_DPE_DISABLE
No transmission on Data Line.
Definition: mcspi/v0/mcspi.h:245
MCSPI_Object
MCSPI driver object.
Definition: mcspi/v0/mcspi.h:573
MCSPI_getBaseAddr
uint32_t MCSPI_getBaseAddr(MCSPI_Handle handle)
Function to get base address of MCSPI instance of a particular handle.
MCSPI_SB_POL_LOW
#define MCSPI_SB_POL_LOW
Start-bit polarity is held to 0 during MCSPI transfer.
Definition: mcspi/v0/mcspi.h:269
MCSPI_ChConfig::bitRate
uint32_t bitRate
Definition: mcspi/v0/mcspi.h:449
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v0/mcspi.h:577
MCSPI_MAX_NUM_CHANNELS
#define MCSPI_MAX_NUM_CHANNELS
Max number of channels/Chip Select (CS) supported.
Definition: mcspi/v0/mcspi.h:113
MCSPI_OpenParams
MCSPI Parameters.
Definition: mcspi/v0/mcspi.h:417
SystemP_WAIT_FOREVER
#define SystemP_WAIT_FOREVER
Value to use when needing a timeout of infinity or wait forver until resource is available.
Definition: SystemP.h:83
MCSPI_Transaction::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:356
SemaphoreP.h
MCSPI_Handle
void * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: mcspi/v0/mcspi.h:82
MCSPI_ChConfig::trMode
uint32_t trMode
Definition: mcspi/v0/mcspi.h:453
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v0/mcspi.h:620
MCSPI_ChObject::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:556
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v0/mcspi.h:486
MCSPI_init
void MCSPI_init(void)
This function initializes the MCSPI module.
MCSPI_MS_MODE_MASTER
#define MCSPI_MS_MODE_MASTER
The module generates the clock and CS.
Definition: mcspi/v0/mcspi.h:174
MCSPI_TRANSFER_MODE_BLOCKING
#define MCSPI_TRANSFER_MODE_BLOCKING
MCSPI_transfer() blocks execution. This mode can only be used when called within a Task context
Definition: mcspi/v0/mcspi.h:150
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:528
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:598
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:594
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:484
MCSPI_ChObject::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:558
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:542
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:877
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v0/mcspi.h:451
MCSPI_setDataWidth
static void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum, uint32_t dataWidth)
This API will set the data width in the channel config register.
Definition: mcspi/v0/mcspi.h:1217
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v0/mcspi.h:467
MCSPI_SLV_CS_SELECT_0
#define MCSPI_SLV_CS_SELECT_0
Definition: mcspi/v0/mcspi.h:254
MCSPI_writeChCtrlReg
static void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum, uint32_t regVal)
This API sets Channel control register value.
Definition: mcspi/v0/mcspi.h:1164
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:502
MCSPI_transfer
int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction)
Function to perform MCSPI transactions.
MCSPI_Attrs::intrNum
uint32_t intrNum
Definition: mcspi/v0/mcspi.h:492
HwiP.h
MCSPI_transferCancel
int32_t MCSPI_transferCancel(MCSPI_Handle handle)
Function to cancel MCSPI transactions on channel of a SPI peripheral specified by the MCSPI handle.
MCSPI_OpenParams::msMode
uint32_t msMode
Definition: mcspi/v0/mcspi.h:424
MCSPI_ChObject::curTxBufPtr
const uint8_t * curTxBufPtr
Definition: mcspi/v0/mcspi.h:534
MCSPI_Transaction_init
static void MCSPI_Transaction_init(MCSPI_Transaction *trans)
Function to initialize the MCSPI_Transaction struct to its defaults.
Definition: mcspi/v0/mcspi.h:823
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:530
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:390
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:554
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:504
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:885
MCSPI_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v0/mcspi.h:464
mcspi_dma_udma.h
MCSPI_TCS0_0_CLK
#define MCSPI_TCS0_0_CLK
0.5 clock cycles delay
Definition: mcspi/v0/mcspi.h:281
MCSPI_Transaction::txBuf
void * txBuf
Definition: mcspi/v0/mcspi.h:372
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v0/mcspi.h:383
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:562
MCSPI_Transaction::dataSize
uint32_t dataSize
Definition: mcspi/v0/mcspi.h:358
MCSPI_ChConfig_init
static void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
Function to initialize the MCSPI_ChConfig struct to its defaults.
Definition: mcspi/v0/mcspi.h:803
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:538
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v0/mcspi.h:461
MCSPI_chConfig
int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg)
Function to configure a MCSPI channel.
MCSPI_Attrs::intrPriority
uint8_t intrPriority
Definition: mcspi/v0/mcspi.h:496
MCSPI_enableTxFIFO
static void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum, uint32_t enableFlag)
This API will enable/disable the Tx FIFOs of McSPI peripheral.
Definition: mcspi/v0/mcspi.h:1189
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:603
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:548
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:617
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:591
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:601
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:873
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:536
MCSPI_FF_POL0_PHA0
#define MCSPI_FF_POL0_PHA0
Definition: mcspi/v0/mcspi.h:193
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:91
MCSPI_Object::openPrms
MCSPI_OpenParams openPrms
Definition: mcspi/v0/mcspi.h:579
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v0/mcspi.h:473
MCSPI_OpenParams_init
static void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
Function to initialize the MCSPI_OpenParams struct to its defaults.
Definition: mcspi/v0/mcspi.h:792
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v0/mcspi.h:459
gMcspiConfigNum
uint32_t gMcspiConfigNum
Externally defined driver configuration array size.
MCSPI_ChObject::csEnable
uint32_t csEnable
Definition: mcspi/v0/mcspi.h:532
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
MCSPI_ChObject::dmaChCfg
MCSPI_DmaChConfig dmaChCfg
Definition: mcspi/v0/mcspi.h:566
MCSPI_OpenParams::mcspiDmaIndex
int32_t mcspiDmaIndex
Definition: mcspi/v0/mcspi.h:426
MCSPI_TRANSFER_COMPLETED
#define MCSPI_TRANSFER_COMPLETED
Definition: mcspi/v0/mcspi.h:123
MCSPI_Transaction::channel
uint32_t channel
Definition: mcspi/v0/mcspi.h:353
MCSPI_TR_MODE_TX_RX
#define MCSPI_TR_MODE_TX_RX
Definition: mcspi/v0/mcspi.h:219
MCSPI_ChConfig::inputSelect
uint32_t inputSelect
Definition: mcspi/v0/mcspi.h:455
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:589
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v0/mcspi.h:457
MCSPI_writeChConfReg
static void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum, uint32_t regVal)
This API sets Channel Config register value.
Definition: mcspi/v0/mcspi.h:1175
MCSPI_open
MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms)
This function opens a given MCSPI peripheral.
MCSPI_ChConfig
MCSPI configuration parameters for the channel.
Definition: mcspi/v0/mcspi.h:444
gMcspiConfig
MCSPI_Config gMcspiConfig[]
Externally defined driver configuration array.
MCSPI_OpenParams::transferCallbackFxn
MCSPI_CallbackFxn transferCallbackFxn
Definition: mcspi/v0/mcspi.h:422
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:581
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:618
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:881
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v0/mcspi.h:93
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v0/mcspi.h:447
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v0/mcspi.h:470
MCSPI_DPE_ENABLE
#define MCSPI_DPE_ENABLE
Data line selected for transmission.
Definition: mcspi/v0/mcspi.h:243
MCSPI_ChConfig::chNum
uint32_t chNum
Definition: mcspi/v0/mcspi.h:445
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v0/mcspi.h:596