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;
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;
481 
483 typedef struct
484 {
485  /*
486  * SOC configuration
487  */
488  uint32_t baseAddr;
490  uint32_t inputClkFreq;
493  /*
494  * Driver configuration
495  */
496  uint32_t intrNum;
498  uint32_t operMode;
500  uint8_t intrPriority;
503  /*
504  * MCSPI instance configuration - common across all channels
505  */
506  uint32_t chMode;
508  uint32_t pinMode;
510  uint32_t initDelay;
512 } MCSPI_Attrs;
513 
514 /* ========================================================================== */
515 /* Internal/Private Structure Declarations */
516 /* ========================================================================== */
517 
521 typedef struct
522 {
523  /*
524  * User parameters
525  */
529  /*
530  * State variables
531  */
532  uint32_t isOpen;
534  uint32_t csDisable;
536  uint32_t csEnable;
538  const uint8_t *curTxBufPtr;
540  uint8_t *curRxBufPtr;
542  uint32_t curTxWords;
546  uint32_t curRxWords;
549  /*
550  * MCSPI derived variables
551  */
552  uint8_t bufWidthShift;
560  uint32_t txFifoTrigLvl;
562  uint32_t rxFifoTrigLvl;
564  uint32_t effTxFifoDepth;
566  uint32_t effRxFifoDepth;
568  uint32_t intrMask;
572 
576 typedef struct
577 {
578  /*
579  * User parameters
580  */
585  uint32_t baseAddr;
590  /*
591  * State variables
592  */
593  uint32_t isOpen;
595  void *transferSem;
600  void *hwiHandle;
609 } MCSPI_Object;
610 
620 typedef struct
621 {
626 } MCSPI_Config;
627 
629 extern MCSPI_Config gMcspiConfig[];
631 extern uint32_t gMcspiConfigNum;
632 
633 /* ========================================================================== */
634 /* Function Declarations */
635 /* ========================================================================== */
636 
640 void MCSPI_init(void);
641 
645 void MCSPI_deinit(void);
646 
663 MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms);
664 
675 
687 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
688 
702  const MCSPI_ChConfig *chCfg,
703  const MCSPI_DmaChConfig *dmaChCfg);
746 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
747 
768 
775 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
776 
783 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
784 
791 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
792 /* ========================================================================== */
793 /* Static Function Definitions */
794 /* ========================================================================== */
795 
796 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
797 {
798  if(openPrms != NULL)
799  {
802  openPrms->transferCallbackFxn = NULL;
803  openPrms->msMode = MCSPI_MS_MODE_MASTER;
804  }
805 }
806 
807 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
808 {
809  if(chConfig != NULL)
810  {
811  chConfig->chNum = MCSPI_CHANNEL_0;
812  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
813  chConfig->bitRate = 1000000U;
814  chConfig->csPolarity = MCSPI_CS_POL_LOW;
815  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
816  chConfig->inputSelect = MCSPI_IS_D1;
817  chConfig->dpe0 = MCSPI_DPE_ENABLE;
818  chConfig->dpe1 = MCSPI_DPE_DISABLE;
820  chConfig->startBitEnable = FALSE;
822  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
823  chConfig->defaultTxData = 0x00000000U;
824  }
825 }
826 
827 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
828 {
829  if(trans != NULL)
830  {
831  trans->channel = 0U;
832  trans->csDisable = TRUE;
833  trans->dataSize = 8U;
834  trans->count = 0U;
835  trans->txBuf = NULL;
836  trans->rxBuf = NULL;
837  trans->args = NULL;
839  }
840 }
841 
842 /* ========================================================================== */
843 /* Advanced Macros & Typedefs */
844 /* ========================================================================== */
846 #define MCSPI_FIFO_LENGTH (64U)
847 
850 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
851  << \
852  CSL_MCSPI_CH0CONF_FFER_SHIFT)
853 
857 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
858  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
859 
863 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
864  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
865 
869 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
870  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
871 
875 #define MCSPI_REG_OFFSET (0x14U)
876 
877 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
878  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
879  (uint32_t) (x)))
880 
881 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
882  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
883  (uint32_t) (x)))
884 
885 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
886  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
887  (uint32_t) (x)))
888 
889 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
890  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
891  (uint32_t) (x)))
892 
893 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
894  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
895  (uint32_t) (x)))
896 
897 #define MCSPI_CLKD_MASK (0x0FU)
898 
900 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
901  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
902  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
903  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
904  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
905  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
906  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
907  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
908  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
909  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
910  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
911  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
912  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
913  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
914  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
915 
916 /* ========================================================================== */
917 /* Advanced Function Declarations */
918 /* ========================================================================== */
928 
941  uint32_t chNum,
942  uint32_t numWordsRxTx);
943 
958 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
959 
983 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
984 
995 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
996 
1006 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1007  uint32_t regVal);
1008 
1019 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1020 
1030 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1031  uint32_t regVal);
1032 
1049 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1050  uint32_t txData,
1051  uint32_t chNum);
1052 
1072 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1073  uint32_t enableFlag);
1074 
1094 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1095  uint32_t enableFlag);
1096 
1112 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1113  uint32_t chNum);
1114 
1131 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1132  uint32_t dataWidth);
1133 
1134 /* ========================================================================== */
1135 /* Advanced Function Definitions */
1136 /* ========================================================================== */
1137 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1138 {
1139  uint32_t bufWidthShift = 0U;
1140 
1141  if(dataSize <= 8U)
1142  {
1143  bufWidthShift = 0U;
1144  }
1145  else if(dataSize <= 16U)
1146  {
1147  bufWidthShift = 1U;
1148  }
1149  else
1150  {
1151  bufWidthShift = 2U;
1152  }
1153 
1154  return bufWidthShift;
1155 }
1156 
1157 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1158 {
1159  /* Return the status from MCSPI_CHSTAT register. */
1160  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1161 }
1162 
1163 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1164 {
1165  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1166 }
1167 
1168 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1169  uint32_t regVal)
1170 {
1171  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1172 }
1173 
1174 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1175 {
1176  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1177 }
1178 
1179 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1180  uint32_t regVal)
1181 {
1182  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1183 }
1184 
1185 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1186  uint32_t txData,
1187  uint32_t chNum)
1188 {
1189  /* Load the MCSPI_TX register with the data to be transmitted */
1190  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1191 }
1192 
1193 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1194  uint32_t chNum,
1195  uint32_t enableFlag)
1196 {
1197  /* Set the FFEW field with user sent value. */
1198  CSL_REG32_FINS(
1199  baseAddr + MCSPI_CHCONF(chNum),
1200  MCSPI_CH0CONF_FFEW,
1201  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1202 }
1203 
1204 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1205  uint32_t chNum,
1206  uint32_t enableFlag)
1207 {
1208  /* Set the FFER field with the user sent value. */
1209  CSL_REG32_FINS(
1210  baseAddr + MCSPI_CHCONF(chNum),
1211  MCSPI_CH0CONF_FFER,
1212  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1213 }
1214 
1215 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1216 {
1217  /* Return the data present in the MCSPI_RX register. */
1218  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1219 }
1220 
1221 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1222  uint32_t dataWidth)
1223 {
1224  uint32_t regVal;
1225 
1226  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1227  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1228  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1229 }
1230 
1231 /* ========================================================================== */
1232 /* Internal/Private Structure Declarations */
1233 /* ========================================================================== */
1234 
1235 #ifdef __cplusplus
1236 }
1237 #endif
1238 
1239 #endif /* #ifndef MCSPI_H_ */
1240 
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:893
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:484
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:1215
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:522
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:1185
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:1163
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:498
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:510
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:1204
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:1157
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:526
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:1174
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:1137
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:422
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:577
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:581
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
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:624
MCSPI_ChObject::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:560
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v0/mcspi.h:490
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:532
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:602
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:598
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:488
MCSPI_ChObject::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:562
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:546
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:881
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:1221
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:1168
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:506
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:496
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:538
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:827
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:534
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:394
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:558
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:508
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:889
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::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:807
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:542
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:500
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:1193
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:607
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:552
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:621
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:595
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:605
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:877
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:540
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:583
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:796
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:536
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:593
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:1179
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:585
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:622
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:885
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:600