AM243x MCU+ SDK  08.01.00
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>
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 
92 #define MCSPI_MAX_NUM_CHANNELS (4U)
93 
102 #define MCSPI_TRANSFER_COMPLETED (0U)
103 #define MCSPI_TRANSFER_STARTED (1U)
104 #define MCSPI_TRANSFER_CANCELLED (2U)
105 #define MCSPI_TRANSFER_FAILED (3U)
106 #define MCSPI_TRANSFER_CSN_DEASSERT (4U)
107 #define MCSPI_TRANSFER_TIMEOUT (5U)
108 
129 #define MCSPI_TRANSFER_MODE_BLOCKING (0U)
130 
134 #define MCSPI_TRANSFER_MODE_CALLBACK (1U)
135 
153 #define MCSPI_MS_MODE_MASTER (CSL_MCSPI_MODULCTRL_MS_MASTER)
154 
155 #define MCSPI_MS_MODE_SLAVE (CSL_MCSPI_MODULCTRL_MS_SLAVE)
156 
172 #define MCSPI_FF_POL0_PHA0 (0U)
173 #define MCSPI_FF_POL0_PHA1 (1U)
174 #define MCSPI_FF_POL1_PHA0 (2U)
175 #define MCSPI_FF_POL1_PHA1 (3U)
176 
187 #define MCSPI_CS_POL_HIGH (CSL_MCSPI_CH0CONF_EPOL_ACTIVEHIGH)
188 
189 #define MCSPI_CS_POL_LOW (CSL_MCSPI_CH0CONF_EPOL_ACTIVELOW)
190 
198 #define MCSPI_TR_MODE_TX_RX (CSL_MCSPI_CH0CONF_TRM_TRANSRECEI)
199 #define MCSPI_TR_MODE_RX_ONLY (CSL_MCSPI_CH0CONF_TRM_RECEIVONLY)
200 #define MCSPI_TR_MODE_TX_ONLY (CSL_MCSPI_CH0CONF_TRM_TRANSONLY)
201 
210 #define MCSPI_IS_D0 (CSL_MCSPI_CH0CONF_IS_LINE0)
211 
212 #define MCSPI_IS_D1 (CSL_MCSPI_CH0CONF_IS_LINE1)
213 
222 #define MCSPI_DPE_ENABLE (CSL_MCSPI_CH0CONF_DPE0_ENABLED)
223 
224 #define MCSPI_DPE_DISABLE (CSL_MCSPI_CH0CONF_DPE0_DISABLED)
225 
233 #define MCSPI_SLV_CS_SELECT_0 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN0)
234 #define MCSPI_SLV_CS_SELECT_1 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN1)
235 #define MCSPI_SLV_CS_SELECT_2 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN2)
236 #define MCSPI_SLV_CS_SELECT_3 (CSL_MCSPI_CH0CONF_SPIENSLV_SPIEN3)
237 
246 #define MCSPI_SB_POL_HIGH (CSL_MCSPI_CH0CONF_SBPOL_HIGHLEVEL)
247 
248 #define MCSPI_SB_POL_LOW (CSL_MCSPI_CH0CONF_SBPOL_LOWLEVEL)
249 
260 #define MCSPI_TCS0_0_CLK (CSL_MCSPI_CH0CONF_TCS0_ZEROCYCLEDLY)
261 
262 #define MCSPI_TCS0_1_CLK (CSL_MCSPI_CH0CONF_TCS0_ONECYCLEDLY)
263 
264 #define MCSPI_TCS0_2_CLK (CSL_MCSPI_CH0CONF_TCS0_TWOCYCLEDLY)
265 
266 #define MCSPI_TCS0_3_CLK (CSL_MCSPI_CH0CONF_TCS0_THREECYCLEDLY)
267 
279 #define MCSPI_CH_MODE_SINGLE (CSL_MCSPI_MODULCTRL_SINGLE_SINGLE)
280 
281 #define MCSPI_CH_MODE_MULTI (CSL_MCSPI_MODULCTRL_SINGLE_MULTI)
282 
294 #define MCSPI_PINMODE_3PIN (CSL_MCSPI_MODULCTRL_PIN34_3PINMODE)
295 #define MCSPI_PINMODE_4PIN (CSL_MCSPI_MODULCTRL_PIN34_4PINMODE)
296 
307 #define MCSPI_INITDLY_0 (CSL_MCSPI_MODULCTRL_INITDLY_NODELAY)
308 
309 #define MCSPI_INITDLY_4 (CSL_MCSPI_MODULCTRL_INITDLY_4CLKDLY)
310 
311 #define MCSPI_INITDLY_8 (CSL_MCSPI_MODULCTRL_INITDLY_8CLKDLY)
312 
313 #define MCSPI_INITDLY_16 (CSL_MCSPI_MODULCTRL_INITDLY_16CLKDLY)
314 
315 #define MCSPI_INITDLY_32 (CSL_MCSPI_MODULCTRL_INITDLY_32CLKDLY)
316 
318 /* ========================================================================== */
319 /* Structure Declarations */
320 /* ========================================================================== */
321 
330 typedef struct
331 {
332  uint32_t channel;
335  uint32_t count;
338  void *txBuf;
349  void *rxBuf;
356  void *args;
358  uint32_t status;
361 
369 typedef void (*MCSPI_CallbackFxn) (MCSPI_Handle handle,
370  MCSPI_Transaction *transaction);
371 
382 typedef struct
383 {
384  uint32_t transferMode;
386  uint32_t transferTimeout;
390  uint32_t msMode;
393 
405 typedef struct
406 {
407  uint32_t chNum;
409  uint32_t frameFormat;
411  uint32_t bitRate;
413  uint32_t csPolarity;
415  uint32_t dataSize;
426  uint32_t trMode;
428  uint32_t inputSelect;
430  uint32_t dpe0;
432  uint32_t dpe1;
434  uint32_t slvCsSelect;
437  uint32_t startBitEnable;
443  uint32_t csIdleTime;
446  uint32_t defaultTxData;
450 
452 typedef struct
453 {
454  /*
455  * SOC configuration
456  */
457  uint32_t baseAddr;
459  uint32_t inputClkFreq;
462  /*
463  * Driver configuration
464  */
465  uint32_t intrNum;
467  uint32_t intrEnable;
469  uint8_t intrPriority;
472  /*
473  * MCSPI instance configuration - common across all channels
474  */
475  uint32_t chMode;
477  uint32_t pinMode;
479  uint32_t initDelay;
481 } MCSPI_Attrs;
482 
483 /* ========================================================================== */
484 /* Internal/Private Structure Declarations */
485 /* ========================================================================== */
486 
490 typedef struct
491 {
492  /*
493  * User parameters
494  */
498  /*
499  * State variables
500  */
501  uint32_t isOpen;
503  const uint8_t *curTxBufPtr;
505  uint8_t *curRxBufPtr;
507  uint32_t curTxWords;
511  uint32_t curRxWords;
514  /*
515  * MCSPI derived variables
516  */
517  uint8_t bufWidthShift;
525  uint32_t txFifoTrigLvl;
527  uint32_t rxFifoTrigLvl;
529  uint32_t effTxFifoDepth;
531  uint32_t effRxFifoDepth;
533  uint32_t intrMask;
536 
540 typedef struct
541 {
542  /*
543  * User parameters
544  */
549  uint32_t baseAddr;
554  /*
555  * State variables
556  */
557  uint32_t isOpen;
559  void *transferSem;
564  void *hwiHandle;
571 } MCSPI_Object;
572 
582 typedef struct
583 {
588 } MCSPI_Config;
589 
591 extern MCSPI_Config gMcspiConfig[];
593 extern uint32_t gMcspiConfigNum;
594 
595 /* ========================================================================== */
596 /* Function Declarations */
597 /* ========================================================================== */
598 
602 void MCSPI_init(void);
603 
607 void MCSPI_deinit(void);
608 
625 MCSPI_Handle MCSPI_open(uint32_t index, const MCSPI_OpenParams *openPrms);
626 
637 
649 int32_t MCSPI_chConfig(MCSPI_Handle handle, const MCSPI_ChConfig *chCfg);
650 
693 int32_t MCSPI_transfer(MCSPI_Handle handle, MCSPI_Transaction *transaction);
694 
715 
722 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms);
723 
730 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig);
731 
732 /* ========================================================================== */
733 /* Static Function Definitions */
734 /* ========================================================================== */
735 
736 static inline void MCSPI_OpenParams_init(MCSPI_OpenParams *openPrms)
737 {
738  if(openPrms != NULL)
739  {
742  openPrms->transferCallbackFxn = NULL;
743  openPrms->msMode = MCSPI_MS_MODE_MASTER;
744  }
745 }
746 
747 static inline void MCSPI_ChConfig_init(MCSPI_ChConfig *chConfig)
748 {
749  if(chConfig != NULL)
750  {
751  chConfig->chNum = MCSPI_CHANNEL_0;
752  chConfig->frameFormat = MCSPI_FF_POL0_PHA0;
753  chConfig->bitRate = 1000000U;
754  chConfig->csPolarity = MCSPI_CS_POL_LOW;
755  chConfig->dataSize = 8U;
756  chConfig->trMode = MCSPI_TR_MODE_TX_RX;
757  chConfig->inputSelect = MCSPI_IS_D1;
758  chConfig->dpe0 = MCSPI_DPE_ENABLE;
759  chConfig->dpe1 = MCSPI_DPE_DISABLE;
761  chConfig->startBitEnable = FALSE;
763  chConfig->csIdleTime = MCSPI_TCS0_0_CLK;
764  chConfig->defaultTxData = 0x00000000U;
765  }
766 }
767 
768 /* ========================================================================== */
769 /* Advanced Macros & Typedefs */
770 /* ========================================================================== */
772 #define MCSPI_FIFO_LENGTH (64U)
773 
776 #define MCSPI_RX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFENABLED \
777  << \
778  CSL_MCSPI_CH0CONF_FFER_SHIFT)
779 
783 #define MCSPI_RX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFER_FFDISABLED \
784  << CSL_MCSPI_CH0CONF_FFER_SHIFT)
785 
789 #define MCSPI_TX_FIFO_ENABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFENABLED \
790  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
791 
795 #define MCSPI_TX_FIFO_DISABLE ((uint32_t) CSL_MCSPI_CH0CONF_FFEW_FFDISABLED \
796  << CSL_MCSPI_CH0CONF_FFEW_SHIFT)
797 
801 #define MCSPI_REG_OFFSET (0x14U)
802 
803 #define MCSPI_CHCONF(x) ((uint32_t) CSL_MCSPI_CH0CONF + \
804  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
805  (uint32_t) (x)))
806 
807 #define MCSPI_CHSTAT(x) ((uint32_t) CSL_MCSPI_CH0STAT + \
808  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
809  (uint32_t) (x)))
810 
811 #define MCSPI_CHCTRL(x) ((uint32_t) CSL_MCSPI_CH0CTRL + \
812  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
813  (uint32_t) (x)))
814 
815 #define MCSPI_CHTX(x) ((uint32_t) CSL_MCSPI_TX0 + \
816  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
817  (uint32_t) (x)))
818 
819 #define MCSPI_CHRX(x) ((uint32_t) CSL_MCSPI_RX0 + \
820  (uint32_t) ((uint32_t) MCSPI_REG_OFFSET * \
821  (uint32_t) (x)))
822 
823 #define MCSPI_CLKD_MASK (0x0FU)
824 
826 #define MCSPI_IRQSTATUS_CLEAR_ALL (CSL_MCSPI_IRQSTATUS_EOW_MASK | \
827  CSL_MCSPI_IRQSTATUS_WKS_MASK | \
828  CSL_MCSPI_IRQSTATUS_RX3_FULL_MASK | \
829  CSL_MCSPI_IRQSTATUS_TX3_UNDERFLOW_MASK | \
830  CSL_MCSPI_IRQSTATUS_TX3_EMPTY_MASK | \
831  CSL_MCSPI_IRQSTATUS_RX2_FULL_MASK | \
832  CSL_MCSPI_IRQSTATUS_TX2_UNDERFLOW_MASK | \
833  CSL_MCSPI_IRQSTATUS_TX2_EMPTY_MASK | \
834  CSL_MCSPI_IRQSTATUS_RX1_FULL_MASK | \
835  CSL_MCSPI_IRQSTATUS_TX1_UNDERFLOW_MASK | \
836  CSL_MCSPI_IRQSTATUS_TX1_EMPTY_MASK | \
837  CSL_MCSPI_IRQSTATUS_RX0_OVERFLOW_MASK | \
838  CSL_MCSPI_IRQSTATUS_RX0_FULL_MASK | \
839  CSL_MCSPI_IRQSTATUS_TX0_UNDERFLOW_MASK | \
840  CSL_MCSPI_IRQSTATUS_TX0_EMPTY_MASK)
841 
842 /* ========================================================================== */
843 /* Advanced Function Declarations */
844 /* ========================================================================== */
854 
867  uint32_t chNum,
868  uint32_t numWordsRxTx);
869 
884 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize);
885 
909 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum);
910 
921 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum);
922 
932 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
933  uint32_t regVal);
934 
945 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum);
946 
956 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
957  uint32_t regVal);
958 
975 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
976  uint32_t txData,
977  uint32_t chNum);
978 
998 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr, uint32_t chNum,
999  uint32_t enableFlag);
1000 
1020 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr, uint32_t chNum,
1021  uint32_t enableFlag);
1022 
1038 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr,
1039  uint32_t chNum);
1040 
1041 /* ========================================================================== */
1042 /* Advanced Function Definitions */
1043 /* ========================================================================== */
1044 static inline uint32_t MCSPI_getBufWidthShift(uint32_t dataSize)
1045 {
1046  uint32_t bufWidthShift = 0U;
1047 
1048  if(dataSize <= 8U)
1049  {
1050  bufWidthShift = 0U;
1051  }
1052  else if(dataSize <= 16U)
1053  {
1054  bufWidthShift = 1U;
1055  }
1056  else
1057  {
1058  bufWidthShift = 2U;
1059  }
1060 
1061  return bufWidthShift;
1062 }
1063 
1064 static inline uint32_t MCSPI_readChStatusReg(uint32_t baseAddr, uint32_t chNum)
1065 {
1066  /* Return the status from MCSPI_CHSTAT register. */
1067  return (CSL_REG32_RD(baseAddr + MCSPI_CHSTAT(chNum)));
1068 }
1069 
1070 static inline uint32_t MCSPI_readChCtrlReg(uint32_t baseAddr, uint32_t chNum)
1071 {
1072  return CSL_REG32_RD(baseAddr + MCSPI_CHCTRL(chNum));
1073 }
1074 
1075 static inline void MCSPI_writeChCtrlReg(uint32_t baseAddr, uint32_t chNum,
1076  uint32_t regVal)
1077 {
1078  CSL_REG32_WR(baseAddr + MCSPI_CHCTRL(chNum), regVal);
1079 }
1080 
1081 static inline uint32_t MCSPI_readChConf(uint32_t baseAddr, uint32_t chNum)
1082 {
1083  return CSL_REG32_RD(baseAddr + MCSPI_CHCONF(chNum));
1084 }
1085 
1086 static inline void MCSPI_writeChConfReg(uint32_t baseAddr, uint32_t chNum,
1087  uint32_t regVal)
1088 {
1089  CSL_REG32_WR(baseAddr + MCSPI_CHCONF(chNum), regVal);
1090 }
1091 
1092 static inline void MCSPI_writeTxDataReg(uint32_t baseAddr,
1093  uint32_t txData,
1094  uint32_t chNum)
1095 {
1096  /* Load the MCSPI_TX register with the data to be transmitted */
1097  CSL_REG32_WR(baseAddr + MCSPI_CHTX(chNum), txData);
1098 }
1099 
1100 static inline void MCSPI_enableTxFIFO(uint32_t baseAddr,
1101  uint32_t chNum,
1102  uint32_t enableFlag)
1103 {
1104  /* Set the FFEW field with user sent value. */
1105  CSL_REG32_FINS(
1106  baseAddr + MCSPI_CHCONF(chNum),
1107  MCSPI_CH0CONF_FFEW,
1108  enableFlag >> CSL_MCSPI_CH0CONF_FFEW_SHIFT);
1109 }
1110 
1111 static inline void MCSPI_enableRxFIFO(uint32_t baseAddr,
1112  uint32_t chNum,
1113  uint32_t enableFlag)
1114 {
1115  /* Set the FFER field with the user sent value. */
1116  CSL_REG32_FINS(
1117  baseAddr + MCSPI_CHCONF(chNum),
1118  MCSPI_CH0CONF_FFER,
1119  enableFlag >> CSL_MCSPI_CH0CONF_FFER_SHIFT);
1120 }
1121 
1122 static inline uint32_t MCSPI_readRxDataReg(uint32_t baseAddr, uint32_t chNum)
1123 {
1124  /* Return the data present in the MCSPI_RX register. */
1125  return (CSL_REG32_RD(baseAddr + MCSPI_CHRX(chNum)));
1126 }
1127 
1128 /* ========================================================================== */
1129 /* Internal/Private Structure Declarations */
1130 /* ========================================================================== */
1131 
1132 #ifdef __cplusplus
1133 }
1134 #endif
1135 
1136 #endif /* #ifndef MCSPI_H_ */
1137 
MCSPI_IS_D1
#define MCSPI_IS_D1
Data line 1 (SPIDAT[1]) selected for reception.
Definition: mcspi/v0/mcspi.h:212
MCSPI_CHRX
#define MCSPI_CHRX(x)
Base address of McSPI_CHRX(x)
Definition: mcspi/v0/mcspi.h:819
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:453
MCSPI_OpenParams::transferTimeout
uint32_t transferTimeout
Definition: mcspi/v0/mcspi.h:386
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:1122
MCSPI_ChObject
MCSPI channel object.
Definition: mcspi/v0/mcspi.h:491
MCSPI_Transaction::count
uint32_t count
Definition: mcspi/v0/mcspi.h:335
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:1092
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:1070
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:369
MCSPI_Transaction::status
uint32_t status
Definition: mcspi/v0/mcspi.h:358
MCSPI_Transaction
Data structure used with MCSPI_transfer()
Definition: mcspi/v0/mcspi.h:331
MCSPI_Attrs::initDelay
uint32_t initDelay
Definition: mcspi/v0/mcspi.h:479
MCSPI_ChObject::effTxFifoDepth
uint32_t effTxFifoDepth
Definition: mcspi/v0/mcspi.h:529
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:1111
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:1064
MCSPI_ChObject::chCfg
MCSPI_ChConfig chCfg
Definition: mcspi/v0/mcspi.h:495
MCSPI_ChObject::intrMask
uint32_t intrMask
Definition: mcspi/v0/mcspi.h:533
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:1081
MCSPI_CS_POL_LOW
#define MCSPI_CS_POL_LOW
SPIEN (CS) is held low during the ACTIVE state.
Definition: mcspi/v0/mcspi.h:189
index
uint16_t index
Definition: tisci_rm_proxy.h:3
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/v0/mcspi.h:1044
SystemP.h
MCSPI_OpenParams::transferMode
uint32_t transferMode
Definition: mcspi/v0/mcspi.h:384
MCSPI_DPE_DISABLE
#define MCSPI_DPE_DISABLE
No transmission on Data Line.
Definition: mcspi/v0/mcspi.h:224
MCSPI_Object
MCSPI driver object.
Definition: mcspi/v0/mcspi.h:541
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:248
MCSPI_ChConfig::bitRate
uint32_t bitRate
Definition: mcspi/v0/mcspi.h:411
MCSPI_deinit
void MCSPI_deinit(void)
This function de-initializes the MCSPI module.
MCSPI_Object::handle
MCSPI_Handle handle
Definition: mcspi/v0/mcspi.h:545
MCSPI_MAX_NUM_CHANNELS
#define MCSPI_MAX_NUM_CHANNELS
Max number of channels/Chip Select (CS) supported.
Definition: mcspi/v0/mcspi.h:92
MCSPI_OpenParams
MCSPI Parameters.
Definition: mcspi/v0/mcspi.h:383
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
SemaphoreP.h
MCSPI_Handle
void * MCSPI_Handle
A handle that is returned from a MCSPI_open() call.
Definition: mcspi/v0/mcspi.h:74
MCSPI_ChConfig::trMode
uint32_t trMode
Definition: mcspi/v0/mcspi.h:426
MCSPI_Config::object
MCSPI_Object * object
Definition: mcspi/v0/mcspi.h:586
MCSPI_ChObject::txFifoTrigLvl
uint32_t txFifoTrigLvl
Definition: mcspi/v0/mcspi.h:525
MCSPI_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mcspi/v0/mcspi.h:459
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:153
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:129
MCSPI_ChObject::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:501
MCSPI_Object::hwiObj
HwiP_Object hwiObj
Definition: mcspi/v0/mcspi.h:566
MCSPI_ChConfig::dataSize
uint32_t dataSize
Definition: mcspi/v0/mcspi.h:415
MCSPI_Object::transferSemObj
SemaphoreP_Object transferSemObj
Definition: mcspi/v0/mcspi.h:562
MCSPI_Attrs::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:457
MCSPI_ChObject::rxFifoTrigLvl
uint32_t rxFifoTrigLvl
Definition: mcspi/v0/mcspi.h:527
MCSPI_ChObject::curRxWords
uint32_t curRxWords
Definition: mcspi/v0/mcspi.h:511
MCSPI_CHSTAT
#define MCSPI_CHSTAT(x)
Base address of McSPI_CHSTAT(x)
Definition: mcspi/v0/mcspi.h:807
MCSPI_ChConfig::csPolarity
uint32_t csPolarity
Definition: mcspi/v0/mcspi.h:413
MCSPI_ChConfig::startBitPolarity
uint32_t startBitPolarity
Definition: mcspi/v0/mcspi.h:440
MCSPI_SLV_CS_SELECT_0
#define MCSPI_SLV_CS_SELECT_0
Definition: mcspi/v0/mcspi.h:233
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:1075
MCSPI_Attrs::chMode
uint32_t chMode
Definition: mcspi/v0/mcspi.h:475
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:465
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:390
MCSPI_ChObject::curTxBufPtr
const uint8_t * curTxBufPtr
Definition: mcspi/v0/mcspi.h:503
MCSPI_Transaction::args
void * args
Definition: mcspi/v0/mcspi.h:356
MCSPI_ChObject::dataWidthBitMask
uint32_t dataWidthBitMask
Definition: mcspi/v0/mcspi.h:523
MCSPI_Attrs::pinMode
uint32_t pinMode
Definition: mcspi/v0/mcspi.h:477
MCSPI_CHTX
#define MCSPI_CHTX(x)
Base address of McSPI_CHTX(x)
Definition: mcspi/v0/mcspi.h:815
MCSPI_ChConfig::startBitEnable
uint32_t startBitEnable
Definition: mcspi/v0/mcspi.h:437
MCSPI_TCS0_0_CLK
#define MCSPI_TCS0_0_CLK
0.5 clock cycles delay
Definition: mcspi/v0/mcspi.h:260
MCSPI_Transaction::txBuf
void * txBuf
Definition: mcspi/v0/mcspi.h:338
MCSPI_Transaction::rxBuf
void * rxBuf
Definition: mcspi/v0/mcspi.h:349
MCSPI_ChObject::effRxFifoDepth
uint32_t effRxFifoDepth
Definition: mcspi/v0/mcspi.h:531
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:747
MCSPI_ChObject::curTxWords
uint32_t curTxWords
Definition: mcspi/v0/mcspi.h:507
MCSPI_ChConfig::slvCsSelect
uint32_t slvCsSelect
Definition: mcspi/v0/mcspi.h:434
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:469
MCSPI_Attrs::intrEnable
uint32_t intrEnable
Definition: mcspi/v0/mcspi.h:467
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:1100
MCSPI_ChObject::bufWidthShift
uint8_t bufWidthShift
Definition: mcspi/v0/mcspi.h:517
MCSPI_Config
MCSPI global configuration array.
Definition: mcspi/v0/mcspi.h:583
MCSPI_Object::transferSem
void * transferSem
Definition: mcspi/v0/mcspi.h:559
MCSPI_Object::currTransaction
MCSPI_Transaction * currTransaction
Definition: mcspi/v0/mcspi.h:569
MCSPI_CHCONF
#define MCSPI_CHCONF(x)
Base address of McSPI_CHCONF(x)
Definition: mcspi/v0/mcspi.h:803
MCSPI_ChObject::curRxBufPtr
uint8_t * curRxBufPtr
Definition: mcspi/v0/mcspi.h:505
MCSPI_FF_POL0_PHA0
#define MCSPI_FF_POL0_PHA0
Definition: mcspi/v0/mcspi.h:172
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:547
MCSPI_ChConfig::defaultTxData
uint32_t defaultTxData
Definition: mcspi/v0/mcspi.h:446
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:736
MCSPI_ChConfig::dpe1
uint32_t dpe1
Definition: mcspi/v0/mcspi.h:432
gMcspiConfigNum
uint32_t gMcspiConfigNum
Externally defined driver configuration array size.
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
MCSPI_Transaction::channel
uint32_t channel
Definition: mcspi/v0/mcspi.h:332
MCSPI_TR_MODE_TX_RX
#define MCSPI_TR_MODE_TX_RX
Definition: mcspi/v0/mcspi.h:198
MCSPI_ChConfig::inputSelect
uint32_t inputSelect
Definition: mcspi/v0/mcspi.h:428
MCSPI_Object::isOpen
uint32_t isOpen
Definition: mcspi/v0/mcspi.h:557
MCSPI_ChConfig::dpe0
uint32_t dpe0
Definition: mcspi/v0/mcspi.h:430
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:1086
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:406
gMcspiConfig
MCSPI_Config gMcspiConfig[]
Externally defined driver configuration array.
MCSPI_OpenParams::transferCallbackFxn
MCSPI_CallbackFxn transferCallbackFxn
Definition: mcspi/v0/mcspi.h:388
MCSPI_Object::baseAddr
uint32_t baseAddr
Definition: mcspi/v0/mcspi.h:549
MCSPI_Config::attrs
const MCSPI_Attrs * attrs
Definition: mcspi/v0/mcspi.h:584
MCSPI_CHCTRL
#define MCSPI_CHCTRL(x)
Base address of McSPI_CHCTRL(x)
Definition: mcspi/v0/mcspi.h:811
MCSPI_CHANNEL_0
#define MCSPI_CHANNEL_0
Definition: mcspi/v0/mcspi.h:85
MCSPI_ChConfig::frameFormat
uint32_t frameFormat
Definition: mcspi/v0/mcspi.h:409
MCSPI_ChConfig::csIdleTime
uint32_t csIdleTime
Definition: mcspi/v0/mcspi.h:443
MCSPI_DPE_ENABLE
#define MCSPI_DPE_ENABLE
Data line selected for transmission.
Definition: mcspi/v0/mcspi.h:222
MCSPI_ChConfig::chNum
uint32_t chNum
Definition: mcspi/v0/mcspi.h:407
MCSPI_Object::hwiHandle
void * hwiHandle
Definition: mcspi/v0/mcspi.h:564