AM62Px MCU+ SDK  09.02.01
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>
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_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 #define MCSPI_ERROR_TX_UNDERFLOW (0x00000001U)
340 #define MCSPI_ERROR_RX_OVERFLOW (0x00000002U)
341 
342 /* ========================================================================== */
343 /* Structure Declarations */
344 /* ========================================================================== */
345 
354 typedef struct
355 {
356  uint32_t channel;
359  uint32_t csDisable;
365  uint32_t dataSize;
376  uint32_t count;
379  void *txBuf;
390  void *rxBuf;
397  void *args;
399  uint32_t status;
402 
410 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
411  MCSPI_Transaction *transaction);
412 
423 typedef struct
424 {
425  uint32_t transferMode;
427  uint32_t transferTimeout;
431  uint32_t msMode;
433  int32_t mcspiDmaIndex;
438 
450 typedef struct
451 {
452  uint32_t chNum;
454  uint32_t frameFormat;
456  uint32_t bitRate;
458  uint32_t csPolarity;
460  uint32_t trMode;
462  uint32_t inputSelect;
464  uint32_t dpe0;
466  uint32_t dpe1;
468  uint32_t slvCsSelect;
471  uint32_t startBitEnable;
477  uint32_t csIdleTime;
480  uint32_t defaultTxData;
483  uint32_t txFifoTrigLvl;
485  uint32_t rxFifoTrigLvl;
488 
490 typedef struct
491 {
492  /*
493  * SOC configuration
494  */
495  uint32_t baseAddr;
497  uint32_t inputClkFreq;
500  /*
501  * Driver configuration
502  */
503  uint32_t intrNum;
505  uint32_t operMode;
507  uint8_t intrPriority;
510  /*
511  * MCSPI instance configuration - common across all channels
512  */
513  uint32_t chMode;
515  uint32_t pinMode;
517  uint32_t initDelay;
519 } MCSPI_Attrs;
520 
521 /* ========================================================================== */
522 /* Internal/Private Structure Declarations */
523 /* ========================================================================== */
524 
528 typedef struct
529 {
530  /*
531  * User parameters
532  */
536  /*
537  * State variables
538  */
539  uint32_t isOpen;
541  uint32_t csDisable;
543  uint32_t csEnable;
545  const uint8_t *curTxBufPtr;
547  uint8_t *curRxBufPtr;
549  uint32_t curTxWords;
553  uint32_t curRxWords;
556  /*
557  * MCSPI derived variables
558  */
559  uint8_t bufWidthShift;
567  uint32_t effTxFifoDepth;
569  uint32_t effRxFifoDepth;
571  uint32_t intrMask;
575  uint32_t chConfRegVal;
577  uint32_t chCtrlRegVal;
579  uint32_t systRegVal;
581 
585 typedef struct
586 {
587  /*
588  * User parameters
589  */
594  uint32_t baseAddr;
598  uint32_t errorFlag;
601  /*
602  * State variables
603  */
604  uint32_t isOpen;
606  void *transferSem;
611  void *hwiHandle;
620 } MCSPI_Object;
621 
631 typedef struct
632 {
637 } MCSPI_Config;
638 
640 extern MCSPI_Config gMcspiConfig[];
642 extern uint32_t gMcspiConfigNum;
643 
644 /* ========================================================================== */
645 /* Function Declarations */
646 /* ========================================================================== */
647 
651 void MCSPI_init(void);
652 
656 void MCSPI_deinit(void);
657 
674 MCSPI_Handle MCSPI_open(uint32_t mcspiConfigIndex, const MCSPI_OpenParams *openPrms);
675 
686 
698 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
699 
713  const MCSPI_ChConfig *chCfg,
714  const MCSPI_DmaChConfig *dmaChCfg);
757 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
758 
779 
786 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
787 
794 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
795 
802 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
803 /* ========================================================================== */
804 /* Static Function Definitions */
805 /* ========================================================================== */
806 
807 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
808 {
809  if(openPrms != NULL)
810  {
813  openPrms->transferCallbackFxn = NULL;
814  openPrms->msMode = MCSPI_MS_MODE_MASTER;
815  }
816 }
817 
818 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
819 {
820  if(chConfig != NULL)
821  {
822  chConfig->chNum = MCSPI_CHANNEL_0;
823  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
824  chConfig->bitRate = 1000000U;
825  chConfig->csPolarity = MCSPI_CS_POL_LOW;
826  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
827  chConfig->inputSelect = MCSPI_IS_D1;
828  chConfig->dpe0 = MCSPI_DPE_ENABLE;
829  chConfig->dpe1 = MCSPI_DPE_DISABLE;
831  chConfig->startBitEnable = FALSE;
833  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
834  chConfig->defaultTxData = 0x00000000U;
835  chConfig->txFifoTrigLvl = 16;
836  chConfig->rxFifoTrigLvl = 16;
837  }
838 }
839 
840 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
841 {
842  if(trans != NULL)
843  {
844  trans->channel = 0U;
845  trans->csDisable = TRUE;
846  trans->dataSize = 8U;
847  trans->count = 0U;
848  trans->txBuf = NULL;
849  trans->rxBuf = NULL;
850  trans->args = NULL;
852  }
853 }
854 
855 /* ========================================================================== */
856 /* Advanced Macros & Typedefs */
857 /* ========================================================================== */
859 #define MCSPI_FIFO_LENGTH (64U)
860 
863 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
864  << \
865  CSL_MCSPI_CH0CONF_FFER_SHIFT)
866 
870 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
871  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
872 
876 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
877  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
878 
882 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
883  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
884 
888 #define MCSPI_REG_OFFSET (0x14U)
889 
890 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
891  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
892  (uint32_t) (x)))
893 
894 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
895  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
896  (uint32_t) (x)))
897 
898 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
899  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
900  (uint32_t) (x)))
901 
902 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
903  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
904  (uint32_t) (x)))
905 
906 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
907  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
908  (uint32_t) (x)))
909 
910 #define MCSPI_CLKD_MASK (0x0FU)
911 
913 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
914  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
915  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
916  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
917  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
918  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
919  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
920  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
921  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
922  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
923  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
924  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
925  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
926  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
927  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
928 
929 /* ========================================================================== */
930 /* Advanced Function Declarations */
931 /* ========================================================================== */
941 
954  uint32_t chNum,
955  uint32_t numWordsRxTx);
956 
971 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
972 
996 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
997 
1008 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
1009 
1019 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1020  uint32_t regVal);
1021 
1032 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1033 
1043 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1044  uint32_t regVal);
1045 
1062 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1063  uint32_t txData,
1064  uint32_t chNum);
1065 
1085 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1086  uint32_t enableFlag);
1087 
1107 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1108  uint32_t enableFlag);
1109 
1125 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1126  uint32_t chNum);
1127 
1144 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1145  uint32_t dataWidth);
1146 
1147 /* ========================================================================== */
1148 /* Advanced Function Definitions */
1149 /* ========================================================================== */
1150 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1151 {
1152  uint32_t bufWidthShift = 0U;
1153 
1154  if(dataSize <= 8U)
1155  {
1156  bufWidthShift = 0U;
1157  }
1158  else if(dataSize <= 16U)
1159  {
1160  bufWidthShift = 1U;
1161  }
1162  else
1163  {
1164  bufWidthShift = 2U;
1165  }
1166 
1167  return bufWidthShift;
1168 }
1169 
1170 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1171 {
1172  /* Return the status from MCSPI_CHSTAT register. */
1173  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1174 }
1175 
1176 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1177 {
1178  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1179 }
1180 
1181 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1182  uint32_t regVal)
1183 {
1184  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1185 }
1186 
1187 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1188 {
1189  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1190 }
1191 
1192 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1193  uint32_t regVal)
1194 {
1195  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1196 }
1197 
1198 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1199  uint32_t txData,
1200  uint32_t chNum)
1201 {
1202  /* Load the MCSPI_TX register with the data to be transmitted */
1203  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1204 }
1205 
1206 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1207  uint32_t chNum,
1208  uint32_t enableFlag)
1209 {
1210  /* Set the FFEW field with user sent value. */
1211  CSL_REG32_FINS(
1212  baseAddr + MCSPI_CHCONF(chNum),
1213  MCSPI_CH0CONF_FFEW,
1214  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1215 }
1216 
1217 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1218  uint32_t chNum,
1219  uint32_t enableFlag)
1220 {
1221  /* Set the FFER field with the user sent value. */
1222  CSL_REG32_FINS(
1223  baseAddr + MCSPI_CHCONF(chNum),
1224  MCSPI_CH0CONF_FFER,
1225  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1226 }
1227 
1228 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1229 {
1230  /* Return the data present in the MCSPI_RX register. */
1231  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1232 }
1233 
1234 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1235  uint32_t dataWidth)
1236 {
1237  uint32_t regVal;
1238 
1239  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1240  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1241  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1242 }
1243 
1244 /* ========================================================================== */
1245 /* Internal/Private Structure Declarations */
1246 /* ========================================================================== */
1247 
1248 #ifdef __cplusplus
1249 }
1250 #endif
1251 
1252 #endif /* #ifndef MCSPI_H_ */
1253 
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:906
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:491
MCSPI_OpenParams::transferTimeout
uint32_t transferTimeout
Definition: mcspi/v0/mcspi.h:427
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:1228
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:529
MCSPI_Transaction::count
uint32_t count
Definition: mcspi/v0/mcspi.h:376
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:1198
MCSPI_ChConfig::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:483
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:1176
MCSPI_ChConfig::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:485
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:410
MCSPI_Attrs::operMode
uint32_t operMode
Definition: mcspi/v0/mcspi.h:505
MCSPI_Transaction::status
uint32_t status
Definition: mcspi/v0/mcspi.h:399
MCSPI_Transaction
Data structure used with MCSPI_transfer()
Definition: mcspi/v0/mcspi.h:355
MCSPI_Attrs::initDelay
uint32_t initDelay
Definition: mcspi/v0/mcspi.h:517
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:567
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:1217
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:1170
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:533
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:571
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:1187
MCSPI_CS_POL_LOW
#define MCSPI_CS_POL_LOW
SPIEN (CS) is held low during the ACTIVE state.
Definition: mcspi/v0/mcspi.h:210
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:575
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:1150
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:425
NULL
#define NULL
Define NULL if not defined.
Definition: csl_types.h:100
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:586
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_Object::errorFlag
uint32_t errorFlag
Definition: mcspi/v0/mcspi.h:598
MCSPI_ChConfig::bitRate
uint32_t bitRate
Definition: mcspi/v0/mcspi.h:456
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v0/mcspi.h:590
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:424
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:359
MCSPI_ChObject::chCtrlRegVal
uint32_t chCtrlRegVal
Definition: mcspi/v0/mcspi.h:577
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:460
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v0/mcspi.h:635
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v0/mcspi.h:497
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
csl_types.h
This file contains the Register Desciptions for CSL types.
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:539
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:613
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:609
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:495
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:553
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:894
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v0/mcspi.h:458
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:1234
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v0/mcspi.h:474
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:1181
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:513
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:503
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:431
MCSPI_ChObject::curTxBufPtr
const uint8_t * curTxBufPtr
Definition: mcspi/v0/mcspi.h:545
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:840
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:541
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:397
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:565
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:515
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:902
MCSPI_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v0/mcspi.h:471
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:379
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v0/mcspi.h:390
MCSPI_ChObject::systRegVal
uint32_t systRegVal
Definition: mcspi/v0/mcspi.h:579
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:569
MCSPI_Transaction::dataSize
uint32_t dataSize
Definition: mcspi/v0/mcspi.h:365
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:818
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:549
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v0/mcspi.h:468
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:507
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:1206
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:618
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:559
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:632
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:606
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:616
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:890
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:547
TRUE
#define TRUE
Definition: csl_types.h:61
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:93
MCSPI_Object::openPrms
MCSPI_OpenParams openPrms
Definition: mcspi/v0/mcspi.h:592
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v0/mcspi.h:480
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:807
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v0/mcspi.h:466
gMcspiConfigNum
uint32_t gMcspiConfigNum
Externally defined driver configuration array size.
MCSPI_ChObject::csEnable
uint32_t csEnable
Definition: mcspi/v0/mcspi.h:543
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:573
MCSPI_OpenParams::mcspiDmaIndex
int32_t mcspiDmaIndex
Definition: mcspi/v0/mcspi.h:433
MCSPI_TRANSFER_COMPLETED
#define MCSPI_TRANSFER_COMPLETED
Definition: mcspi/v0/mcspi.h:123
MCSPI_Transaction::channel
uint32_t channel
Definition: mcspi/v0/mcspi.h:356
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:462
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:604
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v0/mcspi.h:464
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:1192
MCSPI_ChConfig
MCSPI configuration parameters for the channel.
Definition: mcspi/v0/mcspi.h:451
gMcspiConfig
MCSPI_Config gMcspiConfig[]
Externally defined driver configuration array.
MCSPI_open
MCSPI_Handle MCSPI_open(uint32_t mcspiConfigIndex, const MCSPI_OpenParams *openPrms)
This function opens a given MCSPI peripheral.
MCSPI_OpenParams::transferCallbackFxn
MCSPI_CallbackFxn transferCallbackFxn
Definition: mcspi/v0/mcspi.h:429
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:594
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:633
FALSE
#define FALSE
Definition: csl_types.h:62
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:898
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v0/mcspi.h:93
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v0/mcspi.h:454
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v0/mcspi.h:477
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:452
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v0/mcspi.h:611