AM64x MCU+ SDK  08.06.00
mcspi/v0/mcspi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-22 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 (DMA_VERSION_MCSPI_UDMA)
67 #endif
68 
69 #if defined (DMA_VERSION_MCSPI_EDMA)
70 #include <drivers/mcspi/v0/dma/edma/mcspi_dma_edma.h>
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_CONTROLLER (CSL_MCSPI_MODULCTRL_MS_MASTER)
175 
176 #define MCSPI_MS_MODE_PERIPHERAL (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;
362  uint32_t dataSize;
373  uint32_t count;
376  void *txBuf;
387  void *rxBuf;
394  void *args;
396  uint32_t status;
399 
407 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
408  MCSPI_Transaction *transaction);
409 
420 typedef struct
421 {
422  uint32_t transferMode;
424  uint32_t transferTimeout;
428  uint32_t msMode;
430  int32_t mcspiDmaIndex;
435 
447 typedef struct
448 {
449  uint32_t chNum;
451  uint32_t frameFormat;
453  uint32_t bitRate;
455  uint32_t csPolarity;
457  uint32_t trMode;
459  uint32_t inputSelect;
461  uint32_t dpe0;
463  uint32_t dpe1;
465  uint32_t slvCsSelect;
468  uint32_t startBitEnable;
474  uint32_t csIdleTime;
477  uint32_t defaultTxData;
480  uint32_t txFifoTrigLvl;
482  uint32_t rxFifoTrigLvl;
485 
487 typedef struct
488 {
489  /*
490  * SOC configuration
491  */
492  uint32_t baseAddr;
494  uint32_t inputClkFreq;
497  /*
498  * Driver configuration
499  */
500  uint32_t intrNum;
502  uint32_t operMode;
504  uint8_t intrPriority;
507  /*
508  * MCSPI instance configuration - common across all channels
509  */
510  uint32_t chMode;
512  uint32_t pinMode;
514  uint32_t initDelay;
516 } MCSPI_Attrs;
517 
518 /* ========================================================================== */
519 /* Internal/Private Structure Declarations */
520 /* ========================================================================== */
521 
525 typedef struct
526 {
527  /*
528  * User parameters
529  */
533  /*
534  * State variables
535  */
536  uint32_t isOpen;
538  uint32_t csDisable;
540  uint32_t csEnable;
542  const uint8_t *curTxBufPtr;
544  uint8_t *curRxBufPtr;
546  uint32_t curTxWords;
550  uint32_t curRxWords;
553  /*
554  * MCSPI derived variables
555  */
556  uint8_t bufWidthShift;
564  uint32_t effTxFifoDepth;
566  uint32_t effRxFifoDepth;
568  uint32_t intrMask;
572  uint32_t chConfRegVal;
574  uint32_t chCtrlRegVal;
576  uint32_t systRegVal;
578 
582 typedef struct
583 {
584  /*
585  * User parameters
586  */
591  uint32_t baseAddr;
596  /*
597  * State variables
598  */
599  uint32_t isOpen;
601  void *transferSem;
606  void *hwiHandle;
615 } MCSPI_Object;
616 
626 typedef struct
627 {
632 } MCSPI_Config;
633 
635 extern MCSPI_Config gMcspiConfig[];
637 extern uint32_t gMcspiConfigNum;
638 
639 /* ========================================================================== */
640 /* Function Declarations */
641 /* ========================================================================== */
642 
646 void MCSPI_init(void);
647 
651 void MCSPI_deinit(void);
652 
669 MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms);
670 
681 
693 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
694 
708  const MCSPI_ChConfig *chCfg,
709  const MCSPI_DmaChConfig *dmaChCfg);
752 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
753 
774 
781 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
782 
789 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
790 
797 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
798 /* ========================================================================== */
799 /* Static Function Definitions */
800 /* ========================================================================== */
801 
802 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
803 {
804  if(openPrms != NULL)
805  {
808  openPrms->transferCallbackFxn = NULL;
809  openPrms->msMode = MCSPI_MS_MODE_CONTROLLER;
810  }
811 }
812 
813 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
814 {
815  if(chConfig != NULL)
816  {
817  chConfig->chNum = MCSPI_CHANNEL_0;
818  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
819  chConfig->bitRate = 1000000U;
820  chConfig->csPolarity = MCSPI_CS_POL_LOW;
821  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
822  chConfig->inputSelect = MCSPI_IS_D1;
823  chConfig->dpe0 = MCSPI_DPE_ENABLE;
824  chConfig->dpe1 = MCSPI_DPE_DISABLE;
826  chConfig->startBitEnable = FALSE;
828  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
829  chConfig->defaultTxData = 0x00000000U;
830  chConfig->txFifoTrigLvl = 16;
831  chConfig->rxFifoTrigLvl = 16;
832  }
833 }
834 
835 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
836 {
837  if(trans != NULL)
838  {
839  trans->channel = 0U;
840  trans->csDisable = TRUE;
841  trans->dataSize = 8U;
842  trans->count = 0U;
843  trans->txBuf = NULL;
844  trans->rxBuf = NULL;
845  trans->args = NULL;
847  }
848 }
849 
850 /* ========================================================================== */
851 /* Advanced Macros & Typedefs */
852 /* ========================================================================== */
854 #define MCSPI_FIFO_LENGTH (64U)
855 
858 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
859  << \
860  CSL_MCSPI_CH0CONF_FFER_SHIFT)
861 
865 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
866  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
867 
871 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
872  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
873 
877 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
878  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
879 
883 #define MCSPI_REG_OFFSET (0x14U)
884 
885 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
886  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
887  (uint32_t) (x)))
888 
889 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
890  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
891  (uint32_t) (x)))
892 
893 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
894  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
895  (uint32_t) (x)))
896 
897 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
898  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
899  (uint32_t) (x)))
900 
901 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
902  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
903  (uint32_t) (x)))
904 
905 #define MCSPI_CLKD_MASK (0x0FU)
906 
908 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
909  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
910  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
911  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
912  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
913  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
914  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
915  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
916  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
917  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
918  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
919  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
920  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
921  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
922  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
923 
924 /* ========================================================================== */
925 /* Advanced Function Declarations */
926 /* ========================================================================== */
936 
949  uint32_t chNum,
950  uint32_t numWordsRxTx);
951 
966 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
967 
991 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
992 
1003 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
1004 
1014 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1015  uint32_t regVal);
1016 
1027 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1028 
1038 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1039  uint32_t regVal);
1040 
1057 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1058  uint32_t txData,
1059  uint32_t chNum);
1060 
1080 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1081  uint32_t enableFlag);
1082 
1102 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1103  uint32_t enableFlag);
1104 
1120 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1121  uint32_t chNum);
1122 
1139 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1140  uint32_t dataWidth);
1141 
1142 /* ========================================================================== */
1143 /* Advanced Function Definitions */
1144 /* ========================================================================== */
1145 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1146 {
1147  uint32_t bufWidthShift = 0U;
1148 
1149  if(dataSize <= 8U)
1150  {
1151  bufWidthShift = 0U;
1152  }
1153  else if(dataSize <= 16U)
1154  {
1155  bufWidthShift = 1U;
1156  }
1157  else
1158  {
1159  bufWidthShift = 2U;
1160  }
1161 
1162  return bufWidthShift;
1163 }
1164 
1165 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1166 {
1167  /* Return the status from MCSPI_CHSTAT register. */
1168  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1169 }
1170 
1171 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1172 {
1173  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1174 }
1175 
1176 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1177  uint32_t regVal)
1178 {
1179  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1180 }
1181 
1182 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1183 {
1184  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1185 }
1186 
1187 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1188  uint32_t regVal)
1189 {
1190  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1191 }
1192 
1193 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1194  uint32_t txData,
1195  uint32_t chNum)
1196 {
1197  /* Load the MCSPI_TX register with the data to be transmitted */
1198  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1199 }
1200 
1201 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1202  uint32_t chNum,
1203  uint32_t enableFlag)
1204 {
1205  /* Set the FFEW field with user sent value. */
1206  CSL_REG32_FINS(
1207  baseAddr + MCSPI_CHCONF(chNum),
1208  MCSPI_CH0CONF_FFEW,
1209  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1210 }
1211 
1212 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1213  uint32_t chNum,
1214  uint32_t enableFlag)
1215 {
1216  /* Set the FFER field with the user sent value. */
1217  CSL_REG32_FINS(
1218  baseAddr + MCSPI_CHCONF(chNum),
1219  MCSPI_CH0CONF_FFER,
1220  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1221 }
1222 
1223 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1224 {
1225  /* Return the data present in the MCSPI_RX register. */
1226  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1227 }
1228 
1229 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1230  uint32_t dataWidth)
1231 {
1232  uint32_t regVal;
1233 
1234  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1235  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1236  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1237 }
1238 
1239 /* ========================================================================== */
1240 /* Internal/Private Structure Declarations */
1241 /* ========================================================================== */
1242 
1243 #ifdef __cplusplus
1244 }
1245 #endif
1246 
1247 #endif /* #ifndef MCSPI_H_ */
1248 
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:901
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:488
MCSPI_OpenParams::transferTimeout
uint32_t transferTimeout
Definition: mcspi/v0/mcspi.h:424
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:1223
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:526
MCSPI_Transaction::count
uint32_t count
Definition: mcspi/v0/mcspi.h:373
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:1193
MCSPI_ChConfig::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:480
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:1171
MCSPI_ChConfig::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:482
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:407
MCSPI_Attrs::operMode
uint32_t operMode
Definition: mcspi/v0/mcspi.h:502
MCSPI_Transaction::status
uint32_t status
Definition: mcspi/v0/mcspi.h:396
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:514
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:564
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:1212
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:1165
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:530
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:568
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:1182
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_ChObject::chConfRegVal
uint32_t chConfRegVal
Definition: mcspi/v0/mcspi.h:572
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:1145
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:422
MCSPI_MS_MODE_CONTROLLER
#define MCSPI_MS_MODE_CONTROLLER
The module generates the clock and CS.
Definition: mcspi/v0/mcspi.h:174
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:583
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:453
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v0/mcspi.h:587
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:421
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
MCSPI_ChObject::chCtrlRegVal
uint32_t chCtrlRegVal
Definition: mcspi/v0/mcspi.h:574
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:457
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v0/mcspi.h:630
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v0/mcspi.h:494
MCSPI_init
void MCSPI_init(void)
This function initializes the MCSPI module.
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:536
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:608
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:604
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:492
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:550
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:889
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v0/mcspi.h:455
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:1229
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v0/mcspi.h:471
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:1176
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:510
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:500
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:428
MCSPI_ChObject::curTxBufPtr
const uint8_t * curTxBufPtr
Definition: mcspi/v0/mcspi.h:542
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:835
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:538
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:394
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:562
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:512
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:897
MCSPI_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v0/mcspi.h:468
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:376
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v0/mcspi.h:387
MCSPI_ChObject::systRegVal
uint32_t systRegVal
Definition: mcspi/v0/mcspi.h:576
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:566
MCSPI_Transaction::dataSize
uint32_t dataSize
Definition: mcspi/v0/mcspi.h:362
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:813
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:546
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v0/mcspi.h:465
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:504
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:1201
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:613
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:556
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:627
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:601
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:611
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:885
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:544
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:589
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v0/mcspi.h:477
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:802
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v0/mcspi.h:463
gMcspiConfigNum
uint32_t gMcspiConfigNum
Externally defined driver configuration array size.
MCSPI_ChObject::csEnable
uint32_t csEnable
Definition: mcspi/v0/mcspi.h:540
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:570
MCSPI_OpenParams::mcspiDmaIndex
int32_t mcspiDmaIndex
Definition: mcspi/v0/mcspi.h:430
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:459
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:599
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v0/mcspi.h:461
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:1187
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:448
gMcspiConfig
MCSPI_Config gMcspiConfig[]
Externally defined driver configuration array.
MCSPI_OpenParams::transferCallbackFxn
MCSPI_CallbackFxn transferCallbackFxn
Definition: mcspi/v0/mcspi.h:426
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:591
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:628
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:893
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v0/mcspi.h:93
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v0/mcspi.h:451
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v0/mcspi.h:474
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:449
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v0/mcspi.h:606