xWRL6432 MMWAVE-L-SDK  05.04.00.01
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>
65 
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 /* ========================================================================== */
72 /* Macros & Typedefs */
73 /* ========================================================================== */
74 
76 typedef void *MCSPI_Handle;
77 
87 #define MCSPI_CHANNEL_0 (0U)
88 #define MCSPI_CHANNEL_1 (1U)
89 #define MCSPI_CHANNEL_2 (2U)
90 #define MCSPI_CHANNEL_3 (3U)
91 
101 #define MCSPI_OPER_MODE_POLLED (0U)
102 #define MCSPI_OPER_MODE_INTERRUPT (1U)
103 #define MCSPI_OPER_MODE_DMA (2U)
104 
107 #define MCSPI_MAX_NUM_CHANNELS (4U)
108 
117 #define MCSPI_TRANSFER_COMPLETED (0U)
118 #define MCSPI_TRANSFER_STARTED (1U)
119 #define MCSPI_TRANSFER_CANCELLED (2U)
120 #define MCSPI_TRANSFER_FAILED (3U)
121 #define MCSPI_TRANSFER_CSN_DEASSERT (4U)
122 #define MCSPI_TRANSFER_TIMEOUT (5U)
123 
144 #define MCSPI_TRANSFER_MODE_BLOCKING (0U)
145 
149 #define MCSPI_TRANSFER_MODE_CALLBACK (1U)
150 
168 #define MCSPI_MS_MODE_CONTROLLER (CSL_APP_SPI_MODULCTRL_MS_MASTER)
169 
170 #define MCSPI_MS_MODE_PERIPHERAL (CSL_APP_SPI_MODULCTRL_MS_SLAVE)
171 
187 #define MCSPI_FF_POL0_PHA0 (0U)
188 #define MCSPI_FF_POL0_PHA1 (1U)
189 #define MCSPI_FF_POL1_PHA0 (2U)
190 #define MCSPI_FF_POL1_PHA1 (3U)
191 
202 #define MCSPI_CS_POL_HIGH (CSL_APP_SPI_CH0CONF_EPOL_ACTIVEHIGH)
203 
204 #define MCSPI_CS_POL_LOW (CSL_APP_SPI_CH0CONF_EPOL_ACTIVELOW)
205 
213 #define MCSPI_TR_MODE_TX_RX (CSL_APP_SPI_CH0CONF_TRM_TRANSRECEI)
214 #define MCSPI_TR_MODE_RX_ONLY (CSL_APP_SPI_CH0CONF_TRM_RECEIVONLY)
215 #define MCSPI_TR_MODE_TX_ONLY (CSL_APP_SPI_CH0CONF_TRM_TRANSONLY)
216 
224 #define MCSPI_LOOPBACK_DISABLE (0U)
225 #define MCSPI_LOOPBACK_ENABLE (1U)
226 
236 #define MCSPI_IS_D0 (CSL_APP_SPI_CH0CONF_IS_LINE0)
237 
238 #define MCSPI_IS_D1 (CSL_APP_SPI_CH0CONF_IS_LINE1)
239 
248 #define MCSPI_DPE_ENABLE (CSL_APP_SPI_CH0CONF_DPE0_ENABLED)
249 
250 #define MCSPI_DPE_DISABLE (CSL_APP_SPI_CH0CONF_DPE0_DISABLED)
251 
259 #define MCSPI_SLV_CS_SELECT_0 (CSL_APP_SPI_CH0CONF_SPIENSLV_SPIEN0)
260 #define MCSPI_SLV_CS_SELECT_1 (CSL_APP_SPI_CH0CONF_SPIENSLV_SPIEN1)
261 #define MCSPI_SLV_CS_SELECT_2 (CSL_APP_SPI_CH0CONF_SPIENSLV_SPIEN2)
262 #define MCSPI_SLV_CS_SELECT_3 (CSL_APP_SPI_CH0CONF_SPIENSLV_SPIEN3)
263 
272 #define MCSPI_SB_POL_HIGH (CSL_APP_SPI_CH0CONF_SBPOL_HIGHLEVEL)
273 
274 #define MCSPI_SB_POL_LOW (CSL_APP_SPI_CH0CONF_SBPOL_LOWLEVEL)
275 
286 #define MCSPI_TCS0_0_CLK (CSL_APP_SPI_CH0CONF_TCS0_ZEROCYCLEDLY)
287 
288 #define MCSPI_TCS0_1_CLK (CSL_APP_SPI_CH0CONF_TCS0_ONECYCLEDLY)
289 
290 #define MCSPI_TCS0_2_CLK (CSL_APP_SPI_CH0CONF_TCS0_TWOCYCLEDLY)
291 
292 #define MCSPI_TCS0_3_CLK (CSL_APP_SPI_CH0CONF_TCS0_THREECYCLEDLY)
293 
305 #define MCSPI_CH_MODE_SINGLE (CSL_APP_SPI_MODULCTRL_SINGLE_SINGLE)
306 
307 #define MCSPI_CH_MODE_MULTI (CSL_APP_SPI_MODULCTRL_SINGLE_MULTI)
308 
320 #define MCSPI_PINMODE_3PIN (CSL_APP_SPI_MODULCTRL_PIN34_3PINMODE)
321 #define MCSPI_PINMODE_4PIN (CSL_APP_SPI_MODULCTRL_PIN34_4PINMODE)
322 
333 #define MCSPI_INITDLY_0 (CSL_APP_SPI_MODULCTRL_INITDLY_NODELAY)
334 
335 #define MCSPI_INITDLY_4 (CSL_APP_SPI_MODULCTRL_INITDLY_4CLKDLY)
336 
337 #define MCSPI_INITDLY_8 (CSL_APP_SPI_MODULCTRL_INITDLY_8CLKDLY)
338 
339 #define MCSPI_INITDLY_16 (CSL_APP_SPI_MODULCTRL_INITDLY_16CLKDLY)
340 
341 #define MCSPI_INITDLY_32 (CSL_APP_SPI_MODULCTRL_INITDLY_32CLKDLY)
342 
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 loopback;
435  uint32_t msMode;
437  int32_t mcspiDmaIndex;
442 
454 typedef struct
455 {
456  uint32_t chNum;
458  uint32_t frameFormat;
460  uint32_t bitRate;
462  uint32_t csPolarity;
464  uint32_t trMode;
466  uint32_t inputSelect;
468  uint32_t dpe0;
470  uint32_t dpe1;
472  uint32_t slvCsSelect;
475  uint32_t startBitEnable;
481  uint32_t csIdleTime;
484  uint32_t defaultTxData;
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 txFifoTrigLvl;
569  uint32_t rxFifoTrigLvl;
571  uint32_t effTxFifoDepth;
573  uint32_t effRxFifoDepth;
575  uint32_t intrMask;
579 
583 typedef struct
584 {
585  /*
586  * User parameters
587  */
592  uint32_t baseAddr;
597  /*
598  * State variables
599  */
600  uint32_t isOpen;
602  void *transferSem;
607  void *hwiHandle;
616 } MCSPI_Object;
617 
627 typedef struct
628 {
633 } MCSPI_Config;
634 
636 extern MCSPI_Config gMcspiConfig[];
638 extern uint32_t gMcspiConfigNum;
639 
640 /* ========================================================================== */
641 /* Function Declarations */
642 /* ========================================================================== */
643 
647 void MCSPI_init(void);
648 
652 void MCSPI_deinit(void);
653 
670 MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms);
671 
682 
694 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
695 
709  const MCSPI_ChConfig *chCfg,
710  const MCSPI_DmaChConfig *dmaChCfg);
753 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
754 
775 
782 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
783 
790 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
791 
798 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
799 /* ========================================================================== */
800 /* Static Function Definitions */
801 /* ========================================================================== */
802 
803 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
804 {
805  if(openPrms != NULL)
806  {
809  openPrms->transferCallbackFxn = NULL;
810  openPrms->loopback = MCSPI_LOOPBACK_DISABLE;
811  openPrms->msMode = MCSPI_MS_MODE_CONTROLLER;
812  }
813 }
814 
815 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
816 {
817  if(chConfig != NULL)
818  {
819  chConfig->chNum = MCSPI_CHANNEL_0;
820  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
821  chConfig->bitRate = 1000000U;
822  chConfig->csPolarity = MCSPI_CS_POL_LOW;
823  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
824  chConfig->inputSelect = MCSPI_IS_D1;
825  chConfig->dpe0 = MCSPI_DPE_ENABLE;
826  chConfig->dpe1 = MCSPI_DPE_DISABLE;
828  chConfig->startBitEnable = FALSE;
830  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
831  chConfig->defaultTxData = 0x00000000U;
832  }
833 }
834 
835 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
836 {
837  if(trans != NULL)
838  {
839  trans->channel = 0U;
840  trans->csDisable = TRUE;
841  trans->dataSize = 8U;
842  trans->count = 0U;
843  trans->txBuf = NULL;
844  trans->rxBuf = NULL;
845  trans->args = NULL;
847  }
848 }
849 /* ========================================================================== */
850 /* Advanced Macros & Typedefs */
851 /* ========================================================================== */
853 #define MCSPI_FIFO_LENGTH (64U)
854 
857 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_APP_SPI_CH0CONF_FFER_FFENABLED \
858  << \
859  CSL_APP_SPI_CH0CONF_FFER_SHIFT)
860 
864 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_APP_SPI_CH0CONF_FFER_FFDISABLED \
865  << CSL_APP_SPI_CH0CONF_FFER_SHIFT)
866 
870 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_APP_SPI_CH0CONF_FFEW_FFENABLED \
871  << CSL_APP_SPI_CH0CONF_FFEW_SHIFT)
872 
876 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_APP_SPI_CH0CONF_FFEW_FFDISABLED \
877  << CSL_APP_SPI_CH0CONF_FFEW_SHIFT)
878 
882 #define MCSPI_REG_OFFSET (0x14U)
883 
884 #define APP_SPI_CHCONF(x) ((uint32_t) CSL_APP_SPI_CH0CONF + \
885  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
886  (uint32_t) (x)))
887 
888 #define APP_SPI_CHSTAT(x) ((uint32_t) CSL_APP_SPI_CH0STAT + \
889  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
890  (uint32_t) (x)))
891 
892 #define APP_SPI_CHCTRL(x) ((uint32_t) CSL_APP_SPI_CH0CTRL + \
893  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
894  (uint32_t) (x)))
895 
896 #define APP_SPI_CHTX(x) ((uint32_t) CSL_APP_SPI_TX0 + \
897  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
898  (uint32_t) (x)))
899 
900 #define APP_SPI_CHRX(x) ((uint32_t) CSL_APP_SPI_RX0 + \
901  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
902  (uint32_t) (x)))
903 
904 #define MCSPI_CLKD_MASK (0x0FU)
905 
907 #define APP_SPI_IRQSTATUS_CLEAR_ALL (CSL_APP_SPI_IRQSTATUS_EOW_MASK | \
908  CSL_APP_SPI_IRQSTATUS_WKS_MASK | \
909  CSL_APP_SPI_IRQSTATUS_RX3_FULL_MASK | \
910  CSL_APP_SPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
911  CSL_APP_SPI_IRQSTATUS_TX3_EMPTY_MASK | \
912  CSL_APP_SPI_IRQSTATUS_RX2_FULL_MASK | \
913  CSL_APP_SPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
914  CSL_APP_SPI_IRQSTATUS_TX2_EMPTY_MASK | \
915  CSL_APP_SPI_IRQSTATUS_RX1_FULL_MASK | \
916  CSL_APP_SPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
917  CSL_APP_SPI_IRQSTATUS_TX1_EMPTY_MASK | \
918  CSL_APP_SPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
919  CSL_APP_SPI_IRQSTATUS_RX0_FULL_MASK | \
920  CSL_APP_SPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
921  CSL_APP_SPI_IRQSTATUS_TX0_EMPTY_MASK)
922 
923 /* ========================================================================== */
924 /* Advanced Function Declarations */
925 /* ========================================================================== */
935 
948  uint32_t chNum,
949  uint32_t numWordsRxTx);
950 
965 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
966 
990 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
991 
1002 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
1003 
1013 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1014  uint32_t regVal);
1015 
1026 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
1027 
1037 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1038  uint32_t regVal);
1039 
1056 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1057  uint32_t txData,
1058  uint32_t chNum);
1059 
1079 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1080  uint32_t enableFlag);
1081 
1101 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1102  uint32_t enableFlag);
1103 
1119 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1120  uint32_t chNum);
1121 
1138 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1139  uint32_t dataWidth);
1140 /* ========================================================================== */
1141 /* Advanced Function Definitions */
1142 /* ========================================================================== */
1143 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1144 {
1145  uint32_t bufWidthShift = 0U;
1146 
1147  if(dataSize <= 8U)
1148  {
1149  bufWidthShift = 0U;
1150  }
1151  else if(dataSize <= 16U)
1152  {
1153  bufWidthShift = 1U;
1154  }
1155  else
1156  {
1157  bufWidthShift = 2U;
1158  }
1159 
1160  return bufWidthShift;
1161 }
1162 
1163 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1164 {
1165  /* Return the status from MCSPI_CHSTAT register. */
1166  return (CSL_REG32_RD(baseAddr + APP_SPI_CHSTAT(chNum)));
1167 }
1168 
1169 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1170 {
1171  return CSL_REG32_RD(baseAddr + APP_SPI_CHCTRL(chNum));
1172 }
1173 
1174 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1175  uint32_t regVal)
1176 {
1177  CSL_REG32_WR(baseAddr + APP_SPI_CHCTRL(chNum), regVal);
1178 }
1179 
1180 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1181 {
1182  return CSL_REG32_RD(baseAddr + APP_SPI_CHCONF(chNum));
1183 }
1184 
1185 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1186  uint32_t regVal)
1187 {
1188  CSL_REG32_WR(baseAddr + APP_SPI_CHCONF(chNum), regVal);
1189 }
1190 
1191 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1192  uint32_t txData,
1193  uint32_t chNum)
1194 {
1195  /* Load the MCSPI_TX register with the data to be transmitted */
1196  CSL_REG32_WR(baseAddr + APP_SPI_CHTX(chNum), txData);
1197 }
1198 
1199 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1200  uint32_t chNum,
1201  uint32_t enableFlag)
1202 {
1203  /* Set the FFEW field with user sent value. */
1204  CSL_REG32_FINS(
1205  baseAddr + APP_SPI_CHCONF(chNum),
1206  APP_SPI_CH0CONF_FFEW,
1207  enableFlag >> CSL_APP_SPI_CH0CONF_FFEW_SHIFT);
1208 }
1209 
1210 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1211  uint32_t chNum,
1212  uint32_t enableFlag)
1213 {
1214  /* Set the FFER field with the user sent value. */
1215  CSL_REG32_FINS(
1216  baseAddr + APP_SPI_CHCONF(chNum),
1217  APP_SPI_CH0CONF_FFER,
1218  enableFlag >> CSL_APP_SPI_CH0CONF_FFER_SHIFT);
1219 }
1220 
1221 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1222 {
1223  /* Return the data present in the MCSPI_RX register. */
1224  return (CSL_REG32_RD(baseAddr + APP_SPI_CHRX(chNum)));
1225 }
1226 
1227 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1228  uint32_t dataWidth)
1229 {
1230  uint32_t regVal;
1231 
1232  regVal = CSL_REG32_RD(baseAddr + APP_SPI_CHCONF(chNum));
1233  CSL_FINS(regVal, APP_SPI_CH0CONF_WL, (dataWidth - 1U));
1234  CSL_REG32_WR(baseAddr + APP_SPI_CHCONF(chNum), regVal);
1235 }
1236 
1237 /* ========================================================================== */
1238 /* Internal/Private Structure Declarations */
1239 /* ========================================================================== */
1240 
1241 #ifdef __cplusplus
1242 }
1243 #endif
1244 
1245 #endif /* #ifndef MCSPI_H_ */
1246 
MCSPI_DmaChConfig
Definition: mcspi_dma_edma.h:51
MCSPI_IS_D1
#define MCSPI_IS_D1
Data line 1 (SPIDAT[1]) selected for reception.
Definition: mcspi/v0/mcspi.h:238
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
APP_SPI_CHCONF
#define APP_SPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:884
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:1221
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:529
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:1191
APP_SPI_CHRX
#define APP_SPI_CHRX(x)
Base address of McSPI_CHRX(x)
Definition: mcspi/v0/mcspi.h:900
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:1169
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:505
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:517
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:571
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:1210
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:1163
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:533
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:575
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:1180
MCSPI_CS_POL_LOW
#define MCSPI_CS_POL_LOW
SPIEN (CS) is held low during the ACTIVE state.
Definition: mcspi/v0/mcspi.h:204
MCSPI_reConfigFifo
int32_t MCSPI_reConfigFifo(MCSPI_Handle handle, uint32_t chNum, uint32_t numWordsRxTx)
Function to re-configure Effective FIFO Words.
mcspi_dma_edma.h
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:1143
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:427
MCSPI_MS_MODE_CONTROLLER
#define MCSPI_MS_MODE_CONTROLLER
The module generates the clock and CS.
Definition: mcspi/v0/mcspi.h:168
MCSPI_DPE_DISABLE
#define MCSPI_DPE_DISABLE
No transmission on Data Line.
Definition: mcspi/v0/mcspi.h:250
MCSPI_Object
MCSPI driver object.
Definition: mcspi/v0/mcspi.h:584
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:274
APP_SPI_CHTX
#define APP_SPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:896
MCSPI_ChConfig::bitRate
uint32_t bitRate
Definition: mcspi/v0/mcspi.h:460
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v0/mcspi.h:588
MCSPI_MAX_NUM_CHANNELS
#define MCSPI_MAX_NUM_CHANNELS
Max number of channels/Chip Select (CS) supported.
Definition: mcspi/v0/mcspi.h:107
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:103
MCSPI_Transaction::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:361
SemaphoreP.h
MCSPI_LOOPBACK_DISABLE
#define MCSPI_LOOPBACK_DISABLE
Definition: mcspi/v0/mcspi.h:224
MCSPI_Handle
void * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: mcspi/v0/mcspi.h:76
MCSPI_ChConfig::trMode
uint32_t trMode
Definition: mcspi/v0/mcspi.h:464
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v0/mcspi.h:631
MCSPI_ChObject::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:567
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_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:144
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:539
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:609
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:605
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:495
MCSPI_ChObject::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:569
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:553
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v0/mcspi.h:462
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:1227
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v0/mcspi.h:478
APP_SPI_CHCTRL
#define APP_SPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:892
MCSPI_SLV_CS_SELECT_0
#define MCSPI_SLV_CS_SELECT_0
Definition: mcspi/v0/mcspi.h:259
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:1174
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:513
MCSPI_OpenParams::loopback
uint32_t loopback
Definition: mcspi/v0/mcspi.h:433
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:435
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:835
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v0/mcspi.h:541
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:399
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_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v0/mcspi.h:475
MCSPI_TCS0_0_CLK
#define MCSPI_TCS0_0_CLK
0.5 clock cycles delay
Definition: mcspi/v0/mcspi.h:286
MCSPI_Transaction::txBuf
void * txBuf
Definition: mcspi/v0/mcspi.h:381
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v0/mcspi.h:392
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:573
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:815
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:549
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v0/mcspi.h:472
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:1199
MCSPI_Object::mcspiDmaHandle
void * mcspiDmaHandle
Definition: mcspi/v0/mcspi.h:614
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:559
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:628
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:602
APP_SPI_CHSTAT
#define APP_SPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:888
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:612
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:547
MCSPI_FF_POL0_PHA0
#define MCSPI_FF_POL0_PHA0
Definition: mcspi/v0/mcspi.h:187
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:590
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v0/mcspi.h:484
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:803
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v0/mcspi.h:470
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:577
MCSPI_OpenParams::mcspiDmaIndex
int32_t mcspiDmaIndex
Definition: mcspi/v0/mcspi.h:437
MCSPI_TRANSFER_COMPLETED
#define MCSPI_TRANSFER_COMPLETED
Definition: mcspi/v0/mcspi.h:117
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:213
MCSPI_ChConfig::inputSelect
uint32_t inputSelect
Definition: mcspi/v0/mcspi.h:466
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:600
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v0/mcspi.h:468
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:1185
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:455
gMcspiConfig
MCSPI_Config gMcspiConfig[]
Externally defined driver configuration array.
MCSPI_OpenParams::transferCallbackFxn
MCSPI_CallbackFxn transferCallbackFxn
Definition: mcspi/v0/mcspi.h:431
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:592
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:629
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v0/mcspi.h:87
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v0/mcspi.h:458
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v0/mcspi.h:481
MCSPI_DPE_ENABLE
#define MCSPI_DPE_ENABLE
Data line selected for transmission.
Definition: mcspi/v0/mcspi.h:248
MCSPI_ChConfig::chNum
uint32_t chNum
Definition: mcspi/v0/mcspi.h:456
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v0/mcspi.h:607