AM62x MCU+ SDK  10.00.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_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  uint16_t eventId;
508  uint32_t operMode;
510  uint8_t intrPriority;
513  /*
514  * MCSPI instance configuration - common across all channels
515  */
516  uint32_t chMode;
518  uint32_t pinMode;
520  uint32_t initDelay;
522 } MCSPI_Attrs;
523 
524 /* ========================================================================== */
525 /* Internal/Private Structure Declarations */
526 /* ========================================================================== */
527 
531 typedef struct
532 {
533  /*
534  * User parameters
535  */
539  /*
540  * State variables
541  */
542  uint32_t isOpen;
544  uint32_t csDisable;
546  uint32_t csEnable;
548  const uint8_t *curTxBufPtr;
550  uint8_t *curRxBufPtr;
552  uint32_t curTxWords;
556  uint32_t curRxWords;
559  /*
560  * MCSPI derived variables
561  */
562  uint8_t bufWidthShift;
570  uint32_t effTxFifoDepth;
572  uint32_t effRxFifoDepth;
574  uint32_t intrMask;
578  uint32_t chConfRegVal;
580  uint32_t chCtrlRegVal;
582  uint32_t systRegVal;
584 
588 typedef struct
589 {
590  /*
591  * User parameters
592  */
597  uint32_t baseAddr;
601  uint32_t errorFlag;
604  /*
605  * State variables
606  */
607  uint32_t isOpen;
609  void *transferSem;
614  void *hwiHandle;
623 } MCSPI_Object;
624 
634 typedef struct
635 {
640 } MCSPI_Config;
641 
643 extern MCSPI_Config gMcspiConfig[];
645 extern uint32_t gMcspiConfigNum;
646 
647 /* ========================================================================== */
648 /* Function Declarations */
649 /* ========================================================================== */
650 
654 void MCSPI_init(void);
655 
659 void MCSPI_deinit(void);
660 
677 MCSPI_Handle MCSPI_open(uint32_t mcspiConfigIndex, const MCSPI_OpenParams *openPrms);
678 
689 
701 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
702 
716  const MCSPI_ChConfig *chCfg,
717  const MCSPI_DmaChConfig *dmaChCfg);
760 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
761 
782 
789 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
790 
797 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
798 
805 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
806 /* ========================================================================== */
807 /* Static Function Definitions */
808 /* ========================================================================== */
809 
810 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
811 {
812  if(openPrms != NULL)
813  {
816  openPrms->transferCallbackFxn = NULL;
817  openPrms->msMode = MCSPI_MS_MODE_MASTER;
818  }
819 }
820 
821 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
822 {
823  if(chConfig != NULL)
824  {
825  chConfig->chNum = MCSPI_CHANNEL_0;
826  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
827  chConfig->bitRate = 1000000U;
828  chConfig->csPolarity = MCSPI_CS_POL_LOW;
829  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
830  chConfig->inputSelect = MCSPI_IS_D1;
831  chConfig->dpe0 = MCSPI_DPE_ENABLE;
832  chConfig->dpe1 = MCSPI_DPE_DISABLE;
834  chConfig->startBitEnable = FALSE;
836  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
837  chConfig->defaultTxData = 0x00000000U;
838  chConfig->txFifoTrigLvl = 16;
839  chConfig->rxFifoTrigLvl = 16;
840  }
841 }
842 
843 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
844 {
845  if(trans != NULL)
846  {
847  trans->channel = 0U;
848  trans->csDisable = TRUE;
849  trans->dataSize = 8U;
850  trans->count = 0U;
851  trans->txBuf = NULL;
852  trans->rxBuf = NULL;
853  trans->args = NULL;
855  }
856 }
857 
858 /* ========================================================================== */
859 /* Advanced Macros & Typedefs */
860 /* ========================================================================== */
862 #define MCSPI_FIFO_LENGTH (64U)
863 
866 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
867  << \
868  CSL_MCSPI_CH0CONF_FFER_SHIFT)
869 
873 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
874  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
875 
879 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
880  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
881 
885 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
886  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
887 
891 #define MCSPI_REG_OFFSET (0x14U)
892 
893 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
894  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
895  (uint32_t) (x)))
896 
897 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
898  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
899  (uint32_t) (x)))
900 
901 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
902  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
903  (uint32_t) (x)))
904 
905 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
906  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
907  (uint32_t) (x)))
908 
909 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
910  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
911  (uint32_t) (x)))
912 
913 #define MCSPI_CLKD_MASK (0x0FU)
914 
916 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
917  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
918  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
919  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
920  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
921  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
922  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
923  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
924  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
925  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
926  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
927  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
928  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
929  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
930  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
931 
932 /* ========================================================================== */
933 /* Advanced Function Declarations */
934 /* ========================================================================== */
944 
957  uint32_t chNum,
958  uint32_t numWordsRxTx);
959 
974 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
975 
999 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
1000 
1011 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
1012 
1022 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1023  uint32_t regVal);
1024 
1035 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1036 
1046 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1047  uint32_t regVal);
1048 
1065 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1066  uint32_t txData,
1067  uint32_t chNum);
1068 
1088 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1089  uint32_t enableFlag);
1090 
1110 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1111  uint32_t enableFlag);
1112 
1128 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1129  uint32_t chNum);
1130 
1147 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1148  uint32_t dataWidth);
1149 
1150 /* ========================================================================== */
1151 /* Advanced Function Definitions */
1152 /* ========================================================================== */
1153 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1154 {
1155  uint32_t bufWidthShift = 0U;
1156 
1157  if(dataSize <= 8U)
1158  {
1159  bufWidthShift = 0U;
1160  }
1161  else if(dataSize <= 16U)
1162  {
1163  bufWidthShift = 1U;
1164  }
1165  else
1166  {
1167  bufWidthShift = 2U;
1168  }
1169 
1170  return bufWidthShift;
1171 }
1172 
1173 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1174 {
1175  /* Return the status from MCSPI_CHSTAT register. */
1176  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1177 }
1178 
1179 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1180 {
1181  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1182 }
1183 
1184 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1185  uint32_t regVal)
1186 {
1187  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1188 }
1189 
1190 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1191 {
1192  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1193 }
1194 
1195 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1196  uint32_t regVal)
1197 {
1198  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1199 }
1200 
1201 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1202  uint32_t txData,
1203  uint32_t chNum)
1204 {
1205  /* Load the MCSPI_TX register with the data to be transmitted */
1206  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1207 }
1208 
1209 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1210  uint32_t chNum,
1211  uint32_t enableFlag)
1212 {
1213  /* Set the FFEW field with user sent value. */
1214  CSL_REG32_FINS(
1215  baseAddr + MCSPI_CHCONF(chNum),
1216  MCSPI_CH0CONF_FFEW,
1217  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1218 }
1219 
1220 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1221  uint32_t chNum,
1222  uint32_t enableFlag)
1223 {
1224  /* Set the FFER field with the user sent value. */
1225  CSL_REG32_FINS(
1226  baseAddr + MCSPI_CHCONF(chNum),
1227  MCSPI_CH0CONF_FFER,
1228  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1229 }
1230 
1231 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1232 {
1233  /* Return the data present in the MCSPI_RX register. */
1234  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1235 }
1236 
1237 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1238  uint32_t dataWidth)
1239 {
1240  uint32_t regVal;
1241 
1242  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1243  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1244  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1245 }
1246 
1247 /* ========================================================================== */
1248 /* Internal/Private Structure Declarations */
1249 /* ========================================================================== */
1250 
1251 #ifdef __cplusplus
1252 }
1253 #endif
1254 
1255 #endif /* #ifndef MCSPI_H_ */
1256 
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:909
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:1231
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:532
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:1201
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:1179
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:508
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:520
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:570
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:1220
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:1173
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:536
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:574
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:1190
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:578
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:1153
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:425
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:589
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:601
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:593
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:580
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:638
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
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:542
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:616
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:612
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:495
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:556
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:897
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:1237
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:1184
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:516
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:548
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:843
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:544
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:397
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:568
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:518
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:905
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:582
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:572
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:821
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:552
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:510
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:1209
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:621
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:562
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:635
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:609
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:619
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:893
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:550
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:595
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:810
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:546
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
MCSPI_Attrs::eventId
uint16_t eventId
Definition: mcspi/v0/mcspi.h:505
MCSPI_ChObject::dmaChCfg
MCSPI_DmaChConfig dmaChCfg
Definition: mcspi/v0/mcspi.h:576
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:607
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:1195
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:597
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:636
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:901
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:614