AM263x MCU+ SDK  08.02.00
mcspi/v1/mcspi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
50 #ifndef MCSPI_H_
51 #define MCSPI_H_
52 
53 /* ========================================================================== */
54 /* Include Files */
55 /* ========================================================================== */
56 
57 #include <stdint.h>
58 #include <kernel/dpl/SystemP.h>
59 #include <kernel/dpl/SemaphoreP.h>
60 #include <kernel/dpl/HwiP.h>
61 #include <drivers/hw_include/csl_types.h>
62 #include <drivers/hw_include/cslr_mcspi.h>
63 #include <drivers/hw_include/cslr.h>
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /* ========================================================================== */
70 /* Macros & Typedefs */
71 /* ========================================================================== */
72 
74 typedef void *MCSPI_Handle;
75 
85 #define MCSPI_CHANNEL_0 (0U)
86 #define MCSPI_CHANNEL_1 (1U)
87 #define MCSPI_CHANNEL_2 (2U)
88 #define MCSPI_CHANNEL_3 (3U)
89 
99 #define MCSPI_OPER_MODE_POLLED (0U)
100 #define MCSPI_OPER_MODE_INTERRUPT (1U)
101 #define MCSPI_OPER_MODE_DMA (2U)
102 
105 #define MCSPI_MAX_NUM_CHANNELS (4U)
106 
115 #define MCSPI_TRANSFER_COMPLETED (0U)
116 #define MCSPI_TRANSFER_STARTED (1U)
117 #define MCSPI_TRANSFER_CANCELLED (2U)
118 #define MCSPI_TRANSFER_FAILED (3U)
119 #define MCSPI_TRANSFER_CSN_DEASSERT (4U)
120 #define MCSPI_TRANSFER_TIMEOUT (5U)
121 
142 #define MCSPI_TRANSFER_MODE_BLOCKING (0U)
143 
147 #define MCSPI_TRANSFER_MODE_CALLBACK (1U)
148 
166 #define MCSPI_MS_MODE_MASTER (CSL_MCSPI_MODULCTRL_MS_MASTER)
167 
168 #define MCSPI_MS_MODE_SLAVE (CSL_MCSPI_MODULCTRL_MS_SLAVE)
169 
185 #define MCSPI_FF_POL0_PHA0 (0U)
186 #define MCSPI_FF_POL0_PHA1 (1U)
187 #define MCSPI_FF_POL1_PHA0 (2U)
188 #define MCSPI_FF_POL1_PHA1 (3U)
189 
200 #define MCSPI_CS_POL_HIGH (CSL_MCSPI_CH0CONF_EPOL_ACTIVEHIGH)
201 
202 #define MCSPI_CS_POL_LOW (CSL_MCSPI_CH0CONF_EPOL_ACTIVELOW)
203 
211 #define MCSPI_TR_MODE_TX_RX (CSL_MCSPI_CH0CONF_TRM_TRANSRECEI)
212 #define MCSPI_TR_MODE_RX_ONLY (CSL_MCSPI_CH0CONF_TRM_RECEIVONLY)
213 #define MCSPI_TR_MODE_TX_ONLY (CSL_MCSPI_CH0CONF_TRM_TRANSONLY)
214 
223 #define MCSPI_IS_D0 (CSL_MCSPI_CH0CONF_IS_LINE0)
224 
225 #define MCSPI_IS_D1 (CSL_MCSPI_CH0CONF_IS_LINE1)
226 
235 #define MCSPI_DPE_ENABLE (CSL_MCSPI_CH0CONF_DPE0_ENABLED)
236 
237 #define MCSPI_DPE_DISABLE (CSL_MCSPI_CH0CONF_DPE0_DISABLED)
238 
246 #define MCSPI_SLV_CS_SELECT_0 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN0)
247 #define MCSPI_SLV_CS_SELECT_1 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN1)
248 #define MCSPI_SLV_CS_SELECT_2 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN2)
249 #define MCSPI_SLV_CS_SELECT_3 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN3)
250 
259 #define MCSPI_SB_POL_HIGH (CSL_MCSPI_CH0CONF_SBPOL_HIGHLEVEL)
260 
261 #define MCSPI_SB_POL_LOW (CSL_MCSPI_CH0CONF_SBPOL_LOWLEVEL)
262 
273 #define MCSPI_TCS0_0_CLK (CSL_MCSPI_CH0CONF_TCS0_ZEROCYCLEDLY)
274 
275 #define MCSPI_TCS0_1_CLK (CSL_MCSPI_CH0CONF_TCS0_ONECYCLEDLY)
276 
277 #define MCSPI_TCS0_2_CLK (CSL_MCSPI_CH0CONF_TCS0_TWOCYCLEDLY)
278 
279 #define MCSPI_TCS0_3_CLK (CSL_MCSPI_CH0CONF_TCS0_THREECYCLEDLY)
280 
292 #define MCSPI_CH_MODE_SINGLE (CSL_MCSPI_MODULCTRL_SINGLE_SINGLE)
293 
294 #define MCSPI_CH_MODE_MULTI (CSL_MCSPI_MODULCTRL_SINGLE_MULTI)
295 
307 #define MCSPI_PINMODE_3PIN (CSL_MCSPI_MODULCTRL_PIN34_3PINMODE)
308 #define MCSPI_PINMODE_4PIN (CSL_MCSPI_MODULCTRL_PIN34_4PINMODE)
309 
320 #define MCSPI_INITDLY_0 (CSL_MCSPI_MODULCTRL_INITDLY_NODELAY)
321 
322 #define MCSPI_INITDLY_4 (CSL_MCSPI_MODULCTRL_INITDLY_4CLKDLY)
323 
324 #define MCSPI_INITDLY_8 (CSL_MCSPI_MODULCTRL_INITDLY_8CLKDLY)
325 
326 #define MCSPI_INITDLY_16 (CSL_MCSPI_MODULCTRL_INITDLY_16CLKDLY)
327 
328 #define MCSPI_INITDLY_32 (CSL_MCSPI_MODULCTRL_INITDLY_32CLKDLY)
329 
331 /* ========================================================================== */
332 /* Structure Declarations */
333 /* ========================================================================== */
334 
343 typedef struct
344 {
345  uint32_t channel;
348  uint32_t csDisable;
354  uint32_t dataSize;
365  uint32_t count;
368  void *txBuf;
379  void *rxBuf;
386  void *args;
388  uint32_t status;
391 
399 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
400  MCSPI_Transaction *transaction);
401 
412 typedef struct
413 {
414  uint32_t transferMode;
416  uint32_t transferTimeout;
420  uint32_t msMode;
423 
435 typedef struct
436 {
437  uint32_t chNum;
439  uint32_t frameFormat;
441  uint32_t bitRate;
443  uint32_t csPolarity;
445  uint32_t trMode;
447  uint32_t inputSelect;
449  uint32_t dpe0;
451  uint32_t dpe1;
453  uint32_t slvCsSelect;
456  uint32_t startBitEnable;
462  uint32_t csIdleTime;
465  uint32_t defaultTxData;
469 
471 typedef struct
472 {
473  /*
474  * SOC configuration
475  */
476  uint32_t baseAddr;
478  uint32_t inputClkFreq;
481  /*
482  * Driver configuration
483  */
484  uint32_t intrNum;
486  uint32_t operMode;
488  uint8_t intrPriority;
491  /*
492  * MCSPI instance configuration - common across all channels
493  */
494  uint32_t chMode;
496  uint32_t pinMode;
498  uint32_t initDelay;
500 } MCSPI_Attrs;
501 
502 /* ========================================================================== */
503 /* Internal/Private Structure Declarations */
504 /* ========================================================================== */
505 
509 typedef struct
510 {
511  /*
512  * User parameters
513  */
517  /*
518  * State variables
519  */
520  uint32_t isOpen;
522  uint32_t csDisable;
524  uint32_t csEnable;
526  const uint8_t *curTxBufPtr;
528  uint8_t *curRxBufPtr;
530  uint32_t curTxWords;
534  uint32_t curRxWords;
537  /*
538  * MCSPI derived variables
539  */
540  uint8_t bufWidthShift;
548  uint32_t txFifoTrigLvl;
550  uint32_t rxFifoTrigLvl;
552  uint32_t effTxFifoDepth;
554  uint32_t effRxFifoDepth;
556  uint32_t intrMask;
559 
563 typedef struct
564 {
565  /*
566  * User parameters
567  */
572  uint32_t baseAddr;
577  /*
578  * State variables
579  */
580  uint32_t isOpen;
582  void *transferSem;
587  void *hwiHandle;
594 } MCSPI_Object;
595 
605 typedef struct
606 {
611 } MCSPI_Config;
612 
614 extern MCSPI_Config gMcspiConfig[];
616 extern uint32_t gMcspiConfigNum;
617 
618 /* ========================================================================== */
619 /* Function Declarations */
620 /* ========================================================================== */
621 
625 void MCSPI_init(void);
626 
630 void MCSPI_deinit(void);
631 
648 MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms);
649 
660 
672 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
673 
716 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
717 
738 
745 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
746 
753 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
754 
761 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans);
762 /* ========================================================================== */
763 /* Static Function Definitions */
764 /* ========================================================================== */
765 
766 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
767 {
768  if(openPrms != NULL)
769  {
772  openPrms->transferCallbackFxn = NULL;
773  openPrms->msMode = MCSPI_MS_MODE_MASTER;
774  }
775 }
776 
777 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
778 {
779  if(chConfig != NULL)
780  {
781  chConfig->chNum = MCSPI_CHANNEL_0;
782  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
783  chConfig->bitRate = 1000000U;
784  chConfig->csPolarity = MCSPI_CS_POL_LOW;
785  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
786  chConfig->inputSelect = MCSPI_IS_D1;
787  chConfig->dpe0 = MCSPI_DPE_ENABLE;
788  chConfig->dpe1 = MCSPI_DPE_DISABLE;
790  chConfig->startBitEnable = FALSE;
792  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
793  chConfig->defaultTxData = 0x00000000U;
794  }
795 }
796 
797 static inline void MCSPI_Transaction_init(MCSPI_Transaction *trans)
798 {
799  if(trans != NULL)
800  {
801  trans->channel = 0U;
802  trans->csDisable = TRUE;
803  trans->dataSize = 8U;
804  trans->count = 0U;
805  trans->txBuf = NULL;
806  trans->rxBuf = NULL;
807  trans->args = NULL;
809  }
810 }
811 
812 /* ========================================================================== */
813 /* Advanced Macros & Typedefs */
814 /* ========================================================================== */
816 #define MCSPI_FIFO_LENGTH (64U)
817 
820 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
821  << \
822  CSL_MCSPI_CH0CONF_FFER_SHIFT)
823 
827 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
828  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
829 
833 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
834  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
835 
839 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
840  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
841 
845 #define MCSPI_REG_OFFSET (0x14U)
846 
847 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
848  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
849  (uint32_t) (x)))
850 
851 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
852  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
853  (uint32_t) (x)))
854 
855 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
856  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
857  (uint32_t) (x)))
858 
859 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
860  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
861  (uint32_t) (x)))
862 
863 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
864  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
865  (uint32_t) (x)))
866 
867 #define MCSPI_CLKD_MASK (0x0FU)
868 
870 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
871  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
872  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
873  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
874  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
875  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
876  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
877  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
878  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
879  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
880  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
881  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
882  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
883  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
884  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
885 
886 /* ========================================================================== */
887 /* Advanced Function Declarations */
888 /* ========================================================================== */
898 
911  uint32_t chNum,
912  uint32_t numWordsRxTx);
913 
928 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
929 
953 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
954 
965 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
966 
976 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
977  uint32_t regVal);
978 
989 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
990 
1000 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1001  uint32_t regVal);
1002 
1019 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1020  uint32_t txData,
1021  uint32_t chNum);
1022 
1042 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
1043  uint32_t enableFlag);
1044 
1064 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1065  uint32_t enableFlag);
1066 
1082 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1083  uint32_t chNum);
1084 
1101 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1102  uint32_t dataWidth);
1103 
1104 /* ========================================================================== */
1105 /* Advanced Function Definitions */
1106 /* ========================================================================== */
1107 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1108 {
1109  uint32_t bufWidthShift = 0U;
1110 
1111  if(dataSize <= 8U)
1112  {
1113  bufWidthShift = 0U;
1114  }
1115  else if(dataSize <= 16U)
1116  {
1117  bufWidthShift = 1U;
1118  }
1119  else
1120  {
1121  bufWidthShift = 2U;
1122  }
1123 
1124  return bufWidthShift;
1125 }
1126 
1127 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1128 {
1129  /* Return the status from MCSPI_CHSTAT register. */
1130  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1131 }
1132 
1133 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1134 {
1135  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1136 }
1137 
1138 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1139  uint32_t regVal)
1140 {
1141  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1142 }
1143 
1144 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1145 {
1146  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1147 }
1148 
1149 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1150  uint32_t regVal)
1151 {
1152  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1153 }
1154 
1155 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1156  uint32_t txData,
1157  uint32_t chNum)
1158 {
1159  /* Load the MCSPI_TX register with the data to be transmitted */
1160  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1161 }
1162 
1163 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1164  uint32_t chNum,
1165  uint32_t enableFlag)
1166 {
1167  /* Set the FFEW field with user sent value. */
1168  CSL_REG32_FINS(
1169  baseAddr + MCSPI_CHCONF(chNum),
1170  MCSPI_CH0CONF_FFEW,
1171  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1172 }
1173 
1174 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1175  uint32_t chNum,
1176  uint32_t enableFlag)
1177 {
1178  /* Set the FFER field with the user sent value. */
1179  CSL_REG32_FINS(
1180  baseAddr + MCSPI_CHCONF(chNum),
1181  MCSPI_CH0CONF_FFER,
1182  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1183 }
1184 
1185 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1186 {
1187  /* Return the data present in the MCSPI_RX register. */
1188  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1189 }
1190 
1191 static inline void MCSPI_setDataWidth(uint32_t baseAddr, uint32_t chNum,
1192  uint32_t dataWidth)
1193 {
1194  uint32_t regVal;
1195 
1196  regVal = CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1197  CSL_FINS(regVal, MCSPI_CH0CONF_WL, (dataWidth - 1U));
1198  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1199 }
1200 
1201 /* ========================================================================== */
1202 /* Internal/Private Structure Declarations */
1203 /* ========================================================================== */
1204 
1205 #ifdef __cplusplus
1206 }
1207 #endif
1208 
1209 #endif /* #ifndef MCSPI_H_ */
1210 
MCSPI_IS_D1
#define MCSPI_IS_D1
Data line 1 (SPIDAT[1]) selected for reception.
Definition: mcspi/v1/mcspi.h:225
MCSPI_CHRX
#define MCSPI_CHRX(x)
Base address of McSPI_CHRX(x)
Definition: mcspi/v1/mcspi.h:863
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/v1/mcspi.h:472
MCSPI_OpenParams::transferTimeout
uint32_t transferTimeout
Definition: mcspi/v1/mcspi.h:416
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/v1/mcspi.h:1185
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v1/mcspi.h:510
MCSPI_Transaction::count
uint32_t count
Definition: mcspi/v1/mcspi.h:365
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/v1/mcspi.h:1155
MCSPI_readChCtrlReg
static uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
This API returns Channel control register value.
Definition: mcspi/v1/mcspi.h:1133
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/v1/mcspi.h:399
MCSPI_Attrs::operMode
uint32_t operMode
Definition: mcspi/v1/mcspi.h:486
MCSPI_Transaction::status
uint32_t status
Definition: mcspi/v1/mcspi.h:388
MCSPI_Transaction
Data structure used with MCSPI_transfer()
Definition: mcspi/v1/mcspi.h:344
MCSPI_Attrs::initDelay
uint32_t initDelay
Definition: mcspi/v1/mcspi.h:498
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v1/mcspi.h:552
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/v1/mcspi.h:1174
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/v1/mcspi.h:1127
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v1/mcspi.h:514
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v1/mcspi.h:556
MCSPI_readChConf
static uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
This API returns Channel Config register value.
Definition: mcspi/v1/mcspi.h:1144
MCSPI_CS_POL_LOW
#define MCSPI_CS_POL_LOW
SPIEN (CS) is held low during the ACTIVE state.
Definition: mcspi/v1/mcspi.h:202
MCSPI_reConfigFifo
int32_t MCSPI_reConfigFifo(MCSPI_Handle handle, uint32_t chNum, uint32_t numWordsRxTx)
Function to re-configure Effective FIFO Words.
MCSPI_getBufWidthShift
static uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
This API will return the buffer width in bytes based on dataSize.
Definition: mcspi/v1/mcspi.h:1107
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v1/mcspi.h:414
MCSPI_DPE_DISABLE
#define MCSPI_DPE_DISABLE
No transmission on Data Line.
Definition: mcspi/v1/mcspi.h:237
MCSPI_Object
MCSPI driver object.
Definition: mcspi/v1/mcspi.h:564
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/v1/mcspi.h:261
MCSPI_ChConfig::bitRate
uint32_t bitRate
Definition: mcspi/v1/mcspi.h:441
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v1/mcspi.h:568
MCSPI_MAX_NUM_CHANNELS
#define MCSPI_MAX_NUM_CHANNELS
Max number of channels/Chip Select (CS) supported.
Definition: mcspi/v1/mcspi.h:105
MCSPI_OpenParams
MCSPI Parameters.
Definition: mcspi/v1/mcspi.h:413
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/v1/mcspi.h:348
SemaphoreP.h
MCSPI_Handle
void * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: mcspi/v1/mcspi.h:74
MCSPI_ChConfig::trMode
uint32_t trMode
Definition: mcspi/v1/mcspi.h:445
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v1/mcspi.h:609
MCSPI_ChObject::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v1/mcspi.h:548
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v1/mcspi.h:478
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/v1/mcspi.h:166
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/v1/mcspi.h:142
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v1/mcspi.h:520
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v1/mcspi.h:589
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v1/mcspi.h:585
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v1/mcspi.h:476
MCSPI_ChObject::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v1/mcspi.h:550
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v1/mcspi.h:534
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v1/mcspi.h:851
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v1/mcspi.h:443
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/v1/mcspi.h:1191
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v1/mcspi.h:459
MCSPI_SLV_CS_SELECT_0
#define MCSPI_SLV_CS_SELECT_0
Definition: mcspi/v1/mcspi.h:246
MCSPI_writeChCtrlReg
static void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum, uint32_t regVal)
This API sets Channel control register value.
Definition: mcspi/v1/mcspi.h:1138
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v1/mcspi.h:494
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/v1/mcspi.h:484
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/v1/mcspi.h:420
MCSPI_ChObject::curTxBufPtr
const uint8_t * curTxBufPtr
Definition: mcspi/v1/mcspi.h:526
MCSPI_Transaction_init
static void MCSPI_Transaction_init(MCSPI_Transaction *trans)
Function to initialize the MCSPI_Transaction struct to its defaults.
Definition: mcspi/v1/mcspi.h:797
MCSPI_ChObject::csDisable
uint32_t csDisable
Definition: mcspi/v1/mcspi.h:522
MCSPI_Transaction::args
void * args
Definition: mcspi/v1/mcspi.h:386
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v1/mcspi.h:546
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v1/mcspi.h:496
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v1/mcspi.h:859
MCSPI_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v1/mcspi.h:456
MCSPI_TCS0_0_CLK
#define MCSPI_TCS0_0_CLK
0.5 clock cycles delay
Definition: mcspi/v1/mcspi.h:273
MCSPI_Transaction::txBuf
void * txBuf
Definition: mcspi/v1/mcspi.h:368
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v1/mcspi.h:379
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v1/mcspi.h:554
MCSPI_Transaction::dataSize
uint32_t dataSize
Definition: mcspi/v1/mcspi.h:354
MCSPI_ChConfig_init
static void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
Function to initialize the MCSPI_ChConfig struct to its defaults.
Definition: mcspi/v1/mcspi.h:777
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v1/mcspi.h:530
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v1/mcspi.h:453
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/v1/mcspi.h:488
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/v1/mcspi.h:1163
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v1/mcspi.h:540
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v1/mcspi.h:606
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v1/mcspi.h:582
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v1/mcspi.h:592
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v1/mcspi.h:847
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v1/mcspi.h:528
MCSPI_FF_POL0_PHA0
#define MCSPI_FF_POL0_PHA0
Definition: mcspi/v1/mcspi.h:185
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:91
MCSPI_Object::openPrms
MCSPI_OpenParams openPrms
Definition: mcspi/v1/mcspi.h:570
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v1/mcspi.h:465
MCSPI_OpenParams_init
static void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
Function to initialize the MCSPI_OpenParams struct to its defaults.
Definition: mcspi/v1/mcspi.h:766
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v1/mcspi.h:451
gMcspiConfigNum
uint32_t gMcspiConfigNum
Externally defined driver configuration array size.
MCSPI_ChObject::csEnable
uint32_t csEnable
Definition: mcspi/v1/mcspi.h:524
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
MCSPI_TRANSFER_COMPLETED
#define MCSPI_TRANSFER_COMPLETED
Definition: mcspi/v1/mcspi.h:115
MCSPI_Transaction::channel
uint32_t channel
Definition: mcspi/v1/mcspi.h:345
MCSPI_TR_MODE_TX_RX
#define MCSPI_TR_MODE_TX_RX
Definition: mcspi/v1/mcspi.h:211
MCSPI_ChConfig::inputSelect
uint32_t inputSelect
Definition: mcspi/v1/mcspi.h:447
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v1/mcspi.h:580
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v1/mcspi.h:449
MCSPI_writeChConfReg
static void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum, uint32_t regVal)
This API sets Channel Config register value.
Definition: mcspi/v1/mcspi.h:1149
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/v1/mcspi.h:436
gMcspiConfig
MCSPI_Config gMcspiConfig[]
Externally defined driver configuration array.
MCSPI_OpenParams::transferCallbackFxn
MCSPI_CallbackFxn transferCallbackFxn
Definition: mcspi/v1/mcspi.h:418
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v1/mcspi.h:572
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v1/mcspi.h:607
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v1/mcspi.h:855
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v1/mcspi.h:85
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v1/mcspi.h:439
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v1/mcspi.h:462
MCSPI_DPE_ENABLE
#define MCSPI_DPE_ENABLE
Data line selected for transmission.
Definition: mcspi/v1/mcspi.h:235
MCSPI_ChConfig::chNum
uint32_t chNum
Definition: mcspi/v1/mcspi.h:437
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v1/mcspi.h:587