AM62D FreeRTOS SDK  11.02.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 
81 #define MCSPI_MAX_TIMEOUT_VALUE (1000000000U)
82 
84 typedef void *MCSPI_Handle;
85 
95 #define MCSPI_CHANNEL_0 (0U)
96 #define MCSPI_CHANNEL_1 (1U)
97 #define MCSPI_CHANNEL_2 (2U)
98 #define MCSPI_CHANNEL_3 (3U)
99 
109 #define MCSPI_OPER_MODE_POLLED (0U)
110 #define MCSPI_OPER_MODE_INTERRUPT (1U)
111 #define MCSPI_OPER_MODE_DMA (2U)
112 
115 #define MCSPI_MAX_NUM_CHANNELS (4U)
116 
125 #define MCSPI_TRANSFER_COMPLETED (0U)
126 #define MCSPI_TRANSFER_STARTED (1U)
127 #define MCSPI_TRANSFER_CANCELLED (2U)
128 #define MCSPI_TRANSFER_FAILED (3U)
129 #define MCSPI_TRANSFER_CSN_DEASSERT (4U)
130 #define MCSPI_TRANSFER_TIMEOUT (5U)
131 
152 #define MCSPI_TRANSFER_MODE_BLOCKING (0U)
153 
157 #define MCSPI_TRANSFER_MODE_CALLBACK (1U)
158 
176 #define MCSPI_MS_MODE_MASTER (CSL_MCSPI_MODULCTRL_MS_MASTER)
177 
178 #define MCSPI_MS_MODE_SLAVE (CSL_MCSPI_MODULCTRL_MS_SLAVE)
179 
195 #define MCSPI_FF_POL0_PHA0 (0U)
196 #define MCSPI_FF_POL0_PHA1 (1U)
197 #define MCSPI_FF_POL1_PHA0 (2U)
198 #define MCSPI_FF_POL1_PHA1 (3U)
199 
210 #define MCSPI_CS_POL_HIGH (CSL_MCSPI_CH0CONF_EPOL_ACTIVEHIGH)
211 
212 #define MCSPI_CS_POL_LOW (CSL_MCSPI_CH0CONF_EPOL_ACTIVELOW)
213 
221 #define MCSPI_TR_MODE_TX_RX (CSL_MCSPI_CH0CONF_TRM_TRANSRECEI)
222 #define MCSPI_TR_MODE_RX_ONLY (CSL_MCSPI_CH0CONF_TRM_RECEIVONLY)
223 #define MCSPI_TR_MODE_TX_ONLY (CSL_MCSPI_CH0CONF_TRM_TRANSONLY)
224 
233 #define MCSPI_IS_D0 (CSL_MCSPI_CH0CONF_IS_LINE0)
234 
235 #define MCSPI_IS_D1 (CSL_MCSPI_CH0CONF_IS_LINE1)
236 
245 #define MCSPI_DPE_ENABLE (CSL_MCSPI_CH0CONF_DPE0_ENABLED)
246 
247 #define MCSPI_DPE_DISABLE (CSL_MCSPI_CH0CONF_DPE0_DISABLED)
248 
256 #define MCSPI_SLV_CS_SELECT_0 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN0)
257 #define MCSPI_SLV_CS_SELECT_1 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN1)
258 #define MCSPI_SLV_CS_SELECT_2 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN2)
259 #define MCSPI_SLV_CS_SELECT_3 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN3)
260 
269 #define MCSPI_SB_POL_HIGH (CSL_MCSPI_CH0CONF_SBPOL_HIGHLEVEL)
270 
271 #define MCSPI_SB_POL_LOW (CSL_MCSPI_CH0CONF_SBPOL_LOWLEVEL)
272 
283 #define MCSPI_TCS0_0_CLK (CSL_MCSPI_CH0CONF_TCS0_ZEROCYCLEDLY)
284 
285 #define MCSPI_TCS0_1_CLK (CSL_MCSPI_CH0CONF_TCS0_ONECYCLEDLY)
286 
287 #define MCSPI_TCS0_2_CLK (CSL_MCSPI_CH0CONF_TCS0_TWOCYCLEDLY)
288 
289 #define MCSPI_TCS0_3_CLK (CSL_MCSPI_CH0CONF_TCS0_THREECYCLEDLY)
290 
302 #define MCSPI_CH_MODE_SINGLE (CSL_MCSPI_MODULCTRL_SINGLE_SINGLE)
303 
304 #define MCSPI_CH_MODE_MULTI (CSL_MCSPI_MODULCTRL_SINGLE_MULTI)
305 
317 #define MCSPI_PINMODE_3PIN (CSL_MCSPI_MODULCTRL_PIN34_3PINMODE)
318 #define MCSPI_PINMODE_4PIN (CSL_MCSPI_MODULCTRL_PIN34_4PINMODE)
319 
330 #define MCSPI_INITDLY_0 (CSL_MCSPI_MODULCTRL_INITDLY_NODELAY)
331 
332 #define MCSPI_INITDLY_4 (CSL_MCSPI_MODULCTRL_INITDLY_4CLKDLY)
333 
334 #define MCSPI_INITDLY_8 (CSL_MCSPI_MODULCTRL_INITDLY_8CLKDLY)
335 
336 #define MCSPI_INITDLY_16 (CSL_MCSPI_MODULCTRL_INITDLY_16CLKDLY)
337 
338 #define MCSPI_INITDLY_32 (CSL_MCSPI_MODULCTRL_INITDLY_32CLKDLY)
339 
341 #define MCSPI_ERROR_TX_UNDERFLOW (0x00000001U)
342 #define MCSPI_ERROR_RX_OVERFLOW (0x00000002U)
343 
344 /* ========================================================================== */
345 /* Structure Declarations */
346 /* ========================================================================== */
347 
356 typedef struct
357 {
358  uint32_t channel;
361  uint32_t csDisable;
367  uint32_t dataSize;
378  uint32_t count;
381  void *txBuf;
392  void *rxBuf;
399  void *args;
401  uint32_t status;
404 
412 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
413  MCSPI_Transaction *transaction);
414 
425 typedef struct
426 {
427  uint32_t transferMode;
429  uint32_t transferTimeout;
433  uint32_t msMode;
435  int32_t mcspiDmaIndex;
440 
452 typedef struct
453 {
454  uint32_t chNum;
456  uint32_t frameFormat;
458  uint32_t bitRate;
460  uint32_t csPolarity;
462  uint32_t trMode;
464  uint32_t inputSelect;
466  uint32_t dpe0;
468  uint32_t dpe1;
470  uint32_t slvCsSelect;
473  uint32_t startBitEnable;
479  uint32_t csIdleTime;
482  uint32_t defaultTxData;
485  uint32_t txFifoTrigLvl;
487  uint32_t rxFifoTrigLvl;
490 
492 typedef struct
493 {
494  /*
495  * SOC configuration
496  */
497  uint32_t baseAddr;
499  uint32_t inputClkFreq;
502  /*
503  * Driver configuration
504  */
505  uint32_t intrNum;
507  uint16_t eventId;
510  uint32_t operMode;
512  uint8_t intrPriority;
515  /*
516  * MCSPI instance configuration - common across all channels
517  */
518  uint32_t chMode;
520  uint32_t pinMode;
522  uint32_t initDelay;
524 } MCSPI_Attrs;
525 
526 /* ========================================================================== */
527 /* Internal/Private Structure Declarations */
528 /* ========================================================================== */
529 
533 typedef struct
534 {
535  /*
536  * User parameters
537  */
541  /*
542  * State variables
543  */
544  uint32_t isOpen;
546  uint32_t csDisable;
548  uint32_t csEnable;
550  const uint8_t *curTxBufPtr;
552  uint8_t *curRxBufPtr;
554  uint32_t curTxWords;
558  uint32_t curRxWords;
561  /*
562  * MCSPI derived variables
563  */
564  uint8_t bufWidthShift;
572  uint32_t effTxFifoDepth;
574  uint32_t effRxFifoDepth;
576  uint32_t intrMask;
580  uint32_t chConfRegVal;
582  uint32_t chCtrlRegVal;
584  uint32_t systRegVal;
586 
590 typedef struct
591 {
592  /*
593  * User parameters
594  */
599  uint32_t baseAddr;
603  uint32_t errorFlag;
606  /*
607  * State variables
608  */
609  uint32_t isOpen;
611  void *transferSem;
616  void *hwiHandle;
625 } MCSPI_Object;
626 
636 typedef struct
637 {
642 } MCSPI_Config;
643 
645 extern MCSPI_Config gMcspiConfig[];
647 extern uint32_t gMcspiConfigNum;
648 
649 /* ========================================================================== */
650 /* Function Declarations */
651 /* ========================================================================== */
652 
656 void MCSPI_init(void);
657 
661 void MCSPI_deinit(void);
662 
679 MCSPI_Handle MCSPI_open(uint32_t mcspiConfigIndex, const MCSPI_OpenParams *openPrms);
680 
691 
703 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
704 
718  const MCSPI_ChConfig *chCfg,
719  const MCSPI_DmaChConfig *dmaChCfg);
762 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
763 
784 
791 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
792 
799 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
800 
807 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
808 /* ========================================================================== */
809 /* Static Function Definitions */
810 /* ========================================================================== */
811 
812 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
813 {
814  if(openPrms != NULL)
815  {
818  openPrms->transferCallbackFxn = NULL;
819  openPrms->msMode = MCSPI_MS_MODE_MASTER;
820  }
821 }
822 
823 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
824 {
825  if(chConfig != NULL)
826  {
827  chConfig->chNum = MCSPI_CHANNEL_0;
828  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
829  chConfig->bitRate = 1000000U;
830  chConfig->csPolarity = MCSPI_CS_POL_LOW;
831  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
832  chConfig->inputSelect = MCSPI_IS_D1;
833  chConfig->dpe0 = MCSPI_DPE_ENABLE;
834  chConfig->dpe1 = MCSPI_DPE_DISABLE;
836  chConfig->startBitEnable = FALSE;
838  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
839  chConfig->defaultTxData = 0x00000000U;
840  chConfig->txFifoTrigLvl = 16;
841  chConfig->rxFifoTrigLvl = 16;
842  }
843 }
844 
845 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
846 {
847  if(trans != NULL)
848  {
849  trans->channel = 0U;
850  trans->csDisable = TRUE;
851  trans->dataSize = 8U;
852  trans->count = 0U;
853  trans->txBuf = NULL;
854  trans->rxBuf = NULL;
855  trans->args = NULL;
857  }
858 }
859 
860 /* ========================================================================== */
861 /* Advanced Macros & Typedefs */
862 /* ========================================================================== */
864 #define MCSPI_FIFO_LENGTH (64U)
865 
868 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
869  << \
870  CSL_MCSPI_CH0CONF_FFER_SHIFT)
871 
875 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
876  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
877 
881 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
882  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
883 
887 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
888  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
889 
893 #define MCSPI_REG_OFFSET (0x14U)
894 
895 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
896  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
897  (uint32_t) (x)))
898 
899 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
900  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
901  (uint32_t) (x)))
902 
903 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
904  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
905  (uint32_t) (x)))
906 
907 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
908  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
909  (uint32_t) (x)))
910 
911 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
912  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
913  (uint32_t) (x)))
914 
915 #define MCSPI_CLKD_MASK (0x0FU)
916 
918 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
919  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
920  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
921  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
922  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
923  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
924  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
925  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
926  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
927  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
928  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
929  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
930  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
931  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
932  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
933 
934 /* ========================================================================== */
935 /* Advanced Function Declarations */
936 /* ========================================================================== */
946 
959  uint32_t chNum,
960  uint32_t numWordsRxTx);
961 
976 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
977 
1001 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
1002 
1013 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
1014 
1024 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1025  uint32_t regVal);
1026 
1037 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1038 
1048 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1049  uint32_t regVal);
1050 
1067 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1068  uint32_t txData,
1069  uint32_t chNum);
1070 
1090 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1091  uint32_t enableFlag);
1092 
1112 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1113  uint32_t enableFlag);
1114 
1130 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1131  uint32_t chNum);
1132 
1149 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1150  uint32_t dataWidth);
1151 
1152 /* ========================================================================== */
1153 /* Advanced Function Definitions */
1154 /* ========================================================================== */
1155 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1156 {
1157  uint32_t bufWidthShift = 0U;
1158 
1159  if(dataSize <= 8U)
1160  {
1161  bufWidthShift = 0U;
1162  }
1163  else if(dataSize <= 16U)
1164  {
1165  bufWidthShift = 1U;
1166  }
1167  else
1168  {
1169  bufWidthShift = 2U;
1170  }
1171 
1172  return bufWidthShift;
1173 }
1174 
1175 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1176 {
1177  /* Return the status from MCSPI_CHSTAT register. */
1178  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1179 }
1180 
1181 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1182 {
1183  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1184 }
1185 
1186 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1187  uint32_t regVal)
1188 {
1189  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1190 }
1191 
1192 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1193 {
1194  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1195 }
1196 
1197 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1198  uint32_t regVal)
1199 {
1200  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1201 }
1202 
1203 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1204  uint32_t txData,
1205  uint32_t chNum)
1206 {
1207  /* Load the MCSPI_TX register with the data to be transmitted */
1208  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1209 }
1210 
1211 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1212  uint32_t chNum,
1213  uint32_t enableFlag)
1214 {
1215  /* Set the FFEW field with user sent value. */
1216  CSL_REG32_FINS(
1217  baseAddr + MCSPI_CHCONF(chNum),
1218  MCSPI_CH0CONF_FFEW,
1219  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1220 }
1221 
1222 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1223  uint32_t chNum,
1224  uint32_t enableFlag)
1225 {
1226  /* Set the FFER field with the user sent value. */
1227  CSL_REG32_FINS(
1228  baseAddr + MCSPI_CHCONF(chNum),
1229  MCSPI_CH0CONF_FFER,
1230  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1231 }
1232 
1233 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1234 {
1235  /* Return the data present in the MCSPI_RX register. */
1236  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1237 }
1238 
1239 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1240  uint32_t dataWidth)
1241 {
1242  uint32_t regVal;
1243 
1244  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1245  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1246  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1247 }
1248 
1249 /* ========================================================================== */
1250 /* Internal/Private Structure Declarations */
1251 /* ========================================================================== */
1252 
1253 #ifdef __cplusplus
1254 }
1255 #endif
1256 
1257 #endif /* #ifndef MCSPI_H_ */
1258 
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:235
MCSPI_CHRX
#define MCSPI_CHRX(x)
Base address of McSPI_CHRX(x)
Definition: mcspi/v0/mcspi.h:911
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:493
MCSPI_OpenParams::transferTimeout
uint32_t transferTimeout
Definition: mcspi/v0/mcspi.h:429
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:1233
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:534
MCSPI_Transaction::count
uint32_t count
Definition: mcspi/v0/mcspi.h:378
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:1203
MCSPI_ChConfig::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:485
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:1181
MCSPI_ChConfig::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:487
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:412
MCSPI_Attrs::operMode
uint32_t operMode
Definition: mcspi/v0/mcspi.h:510
MCSPI_Transaction::status
uint32_t status
Definition: mcspi/v0/mcspi.h:401
MCSPI_Transaction
Data structure used with MCSPI_transfer()
Definition: mcspi/v0/mcspi.h:357
MCSPI_Attrs::initDelay
uint32_t initDelay
Definition: mcspi/v0/mcspi.h:522
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:572
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:1222
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:1175
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:538
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:576
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:1192
MCSPI_CS_POL_LOW
#define MCSPI_CS_POL_LOW
SPIEN (CS) is held low during the ACTIVE state.
Definition: mcspi/v0/mcspi.h:212
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:580
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:1155
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:427
MCSPI_DPE_DISABLE
#define MCSPI_DPE_DISABLE
No transmission on Data Line.
Definition: mcspi/v0/mcspi.h:247
MCSPI_Object
MCSPI driver object.
Definition: mcspi/v0/mcspi.h:591
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:271
MCSPI_Object::errorFlag
uint32_t errorFlag
Definition: mcspi/v0/mcspi.h:603
MCSPI_ChConfig::bitRate
uint32_t bitRate
Definition: mcspi/v0/mcspi.h:458
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v0/mcspi.h:595
MCSPI_MAX_NUM_CHANNELS
#define MCSPI_MAX_NUM_CHANNELS
Max number of channels/Chip Select (CS) supported.
Definition: mcspi/v0/mcspi.h:115
MCSPI_OpenParams
MCSPI Parameters.
Definition: mcspi/v0/mcspi.h:426
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:361
MCSPI_ChObject::chCtrlRegVal
uint32_t chCtrlRegVal
Definition: mcspi/v0/mcspi.h:582
SemaphoreP.h
MCSPI_Handle
void * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: mcspi/v0/mcspi.h:84
MCSPI_ChConfig::trMode
uint32_t trMode
Definition: mcspi/v0/mcspi.h:462
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v0/mcspi.h:640
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v0/mcspi.h:499
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:176
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:152
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:544
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:618
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:614
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:497
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:558
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:899
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v0/mcspi.h:460
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:1239
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v0/mcspi.h:476
MCSPI_SLV_CS_SELECT_0
#define MCSPI_SLV_CS_SELECT_0
Definition: mcspi/v0/mcspi.h:256
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:1186
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:518
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:505
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:433
MCSPI_ChObject::curTxBufPtr
const uint8_t * curTxBufPtr
Definition: mcspi/v0/mcspi.h:550
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:845
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:546
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:399
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:570
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:520
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:907
MCSPI_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v0/mcspi.h:473
mcspi_dma_udma.h
MCSPI_TCS0_0_CLK
#define MCSPI_TCS0_0_CLK
0.5 clock cycles delay
Definition: mcspi/v0/mcspi.h:283
MCSPI_Transaction::txBuf
void * txBuf
Definition: mcspi/v0/mcspi.h:381
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v0/mcspi.h:392
MCSPI_ChObject::systRegVal
uint32_t systRegVal
Definition: mcspi/v0/mcspi.h:584
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:574
MCSPI_Transaction::dataSize
uint32_t dataSize
Definition: mcspi/v0/mcspi.h:367
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:823
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:554
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v0/mcspi.h:470
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:512
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:1211
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:623
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:564
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:637
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:611
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:621
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:895
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:552
MCSPI_FF_POL0_PHA0
#define MCSPI_FF_POL0_PHA0
Definition: mcspi/v0/mcspi.h:195
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:597
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v0/mcspi.h:482
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:812
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v0/mcspi.h:468
gMcspiConfigNum
uint32_t gMcspiConfigNum
Externally defined driver configuration array size.
MCSPI_ChObject::csEnable
uint32_t csEnable
Definition: mcspi/v0/mcspi.h:548
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:507
MCSPI_ChObject::dmaChCfg
MCSPI_DmaChConfig dmaChCfg
Definition: mcspi/v0/mcspi.h:578
MCSPI_OpenParams::mcspiDmaIndex
int32_t mcspiDmaIndex
Definition: mcspi/v0/mcspi.h:435
MCSPI_TRANSFER_COMPLETED
#define MCSPI_TRANSFER_COMPLETED
Definition: mcspi/v0/mcspi.h:125
MCSPI_Transaction::channel
uint32_t channel
Definition: mcspi/v0/mcspi.h:358
MCSPI_TR_MODE_TX_RX
#define MCSPI_TR_MODE_TX_RX
Definition: mcspi/v0/mcspi.h:221
MCSPI_ChConfig::inputSelect
uint32_t inputSelect
Definition: mcspi/v0/mcspi.h:464
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:609
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v0/mcspi.h:466
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:1197
MCSPI_ChConfig
MCSPI configuration parameters for the channel.
Definition: mcspi/v0/mcspi.h:453
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:431
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:599
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:638
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:903
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v0/mcspi.h:95
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v0/mcspi.h:456
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v0/mcspi.h:479
MCSPI_DPE_ENABLE
#define MCSPI_DPE_ENABLE
Data line selected for transmission.
Definition: mcspi/v0/mcspi.h:245
MCSPI_ChConfig::chNum
uint32_t chNum
Definition: mcspi/v0/mcspi.h:454
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v0/mcspi.h:616