CC3200 Peripheral Driver Library User's Guide  1.2.0
spi.h
1 //*****************************************************************************
2 //
3 // spi.h
4 //
5 // Defines and Macros for the SPI.
6 //
7 // Copyright (C) 2014 Texas Instruments Incorporated - https://www.ti.com/
8 //
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions
12 // are met:
13 //
14 // Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the
20 // distribution.
21 //
22 // Neither the name of Texas Instruments Incorporated nor the names of
23 // its contributors may be used to endorse or promote products derived
24 // from this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 //*****************************************************************************
39 
40 #ifndef __SPI_H__
41 #define __SPI_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 // Values that can be passed to SPIConfigSetExpClk() as ulMode parameter
56 //*****************************************************************************
57 #define SPI_MODE_MASTER 0x00000000
58 #define SPI_MODE_SLAVE 0x00000004
59 
60 //*****************************************************************************
61 // Values that can be passed to SPIConfigSetExpClk() as ulSubMode parameter
62 //*****************************************************************************
63 #define SPI_SUB_MODE_0 0x00000000
64 #define SPI_SUB_MODE_1 0x00000001
65 #define SPI_SUB_MODE_2 0x00000002
66 #define SPI_SUB_MODE_3 0x00000003
67 
68 
69 //*****************************************************************************
70 // Values that can be passed to SPIConfigSetExpClk() as ulConfigFlags parameter
71 //*****************************************************************************
72 #define SPI_SW_CTRL_CS 0x01000000
73 #define SPI_HW_CTRL_CS 0x00000000
74 #define SPI_3PIN_MODE 0x02000000
75 #define SPI_4PIN_MODE 0x00000000
76 #define SPI_TURBO_ON 0x00080000
77 #define SPI_TURBO_OFF 0x00000000
78 #define SPI_CS_ACTIVEHIGH 0x00000000
79 #define SPI_CS_ACTIVELOW 0x00000040
80 #define SPI_WL_8 0x00000380
81 #define SPI_WL_16 0x00000780
82 #define SPI_WL_32 0x00000F80
83 
84 //*****************************************************************************
85 // Values that can be passed to SPIFIFOEnable() and SPIFIFODisable()
86 //*****************************************************************************
87 #define SPI_TX_FIFO 0x08000000
88 #define SPI_RX_FIFO 0x10000000
89 
90 //*****************************************************************************
91 // Values that can be passed to SPIDMAEnable() and SPIDMADisable()
92 //*****************************************************************************
93 #define SPI_RX_DMA 0x00008000
94 #define SPI_TX_DMA 0x00004000
95 
96 //*****************************************************************************
97 // Values that can be passed to SPIIntEnable(), SPIIntDiasble(),
98 // SPIIntClear() or returned from SPIStatus()
99 //*****************************************************************************
100 #define SPI_INT_DMATX 0x20000000
101 #define SPI_INT_DMARX 0x10000000
102 #define SPI_INT_EOW 0x00020000
103 #define SPI_INT_WKS 0x00010000
104 #define SPI_INT_RX_OVRFLOW 0x00000008
105 #define SPI_INT_RX_FULL 0x00000004
106 #define SPI_INT_TX_UDRFLOW 0x00000002
107 #define SPI_INT_TX_EMPTY 0x00000001
108 
109 //*****************************************************************************
110 // Values that can be passed to SPITransfer()
111 //*****************************************************************************
112 #define SPI_CS_ENABLE 0x00000001
113 #define SPI_CS_DISABLE 0x00000002
114 
115 //*****************************************************************************
116 //
117 // API Function prototypes
118 //
119 //*****************************************************************************
120 extern void SPIEnable(unsigned long ulBase);
121 extern void SPIDisable(unsigned long ulBase);
122 extern void SPIReset(unsigned long ulBase);
123 extern void SPIConfigSetExpClk(unsigned long ulBase,unsigned long ulSPIClk,
124  unsigned long ulBitRate, unsigned long ulMode,
125  unsigned long ulSubMode, unsigned long ulConfig);
126 extern long SPIDataGetNonBlocking(unsigned long ulBase,
127  unsigned long * pulData);
128 extern void SPIDataGet(unsigned long ulBase, unsigned long *pulData);
129 extern long SPIDataPutNonBlocking(unsigned long ulBase,
130  unsigned long ulData);
131 extern void SPIDataPut(unsigned long ulBase, unsigned long ulData);
132 extern void SPIFIFOEnable(unsigned long ulBase, unsigned long ulFlags);
133 extern void SPIFIFODisable(unsigned long ulBase, unsigned long ulFlags);
134 extern void SPIFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel,
135  unsigned long ulRxLevel);
136 extern void SPIFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel,
137  unsigned long *pulRxLevel);
138 extern void SPIWordCountSet(unsigned long ulBase, unsigned long ulWordCount);
139 extern void SPIIntRegister(unsigned long ulBase, void(*pfnHandler)(void));
140 extern void SPIIntUnregister(unsigned long ulBase);
141 extern void SPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
142 extern void SPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
143 extern unsigned long SPIIntStatus(unsigned long ulBase, tBoolean bMasked);
144 extern void SPIIntClear(unsigned long ulBase, unsigned long ulIntFlags);
145 extern void SPIDmaEnable(unsigned long ulBase, unsigned long ulFlags);
146 extern void SPIDmaDisable(unsigned long ulBase, unsigned long ulFlags);
147 extern void SPICSEnable(unsigned long ulBase);
148 extern void SPICSDisable(unsigned long ulBase);
149 extern long SPITransfer(unsigned long ulBase, unsigned char *ucDout,
150  unsigned char *ucDin, unsigned long ulSize,
151  unsigned long ulFlags);
152 
153 
154 //*****************************************************************************
155 //
156 // Mark the end of the C bindings section for C++ compilers.
157 //
158 //*****************************************************************************
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif // __SPI_H__
void SPIIntRegister(unsigned long ulBase, void(*pfnHandler)(void))
Definition: spi.c:1122
void SPICSDisable(unsigned long ulBase)
Definition: spi.c:1432
void SPIFIFODisable(unsigned long ulBase, unsigned long ulFlags)
Definition: spi.c:997
void SPIDataPut(unsigned long ulBase, unsigned long ulData)
Definition: spi.c:938
void SPIFIFOLevelSet(unsigned long ulBase, unsigned long ulTxLevel, unsigned long ulRxLevel)
Definition: spi.c:1019
void SPIDisable(unsigned long ulBase)
Definition: spi.c:583
unsigned long SPIIntStatus(unsigned long ulBase, tBoolean bMasked)
Definition: spi.c:1297
void SPIEnable(unsigned long ulBase)
Definition: spi.c:562
void SPIWordCountSet(unsigned long ulBase, unsigned long ulWordCount)
Definition: spi.c:1086
long SPIDataGetNonBlocking(unsigned long ulBase, unsigned long *pulData)
Definition: spi.c:836
void SPICSEnable(unsigned long ulBase)
Definition: spi.c:1411
long SPIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData)
Definition: spi.c:902
void SPIConfigSetExpClk(unsigned long ulBase, unsigned long ulSPIClk, unsigned long ulBitRate, unsigned long ulMode, unsigned long ulSubMode, unsigned long ulConfig)
Definition: spi.c:742
void SPIDmaEnable(unsigned long ulBase, unsigned long ulFlags)
Definition: spi.c:611
void SPIIntUnregister(unsigned long ulBase)
Definition: spi.c:1160
void SPIDataGet(unsigned long ulBase, unsigned long *pulData)
Definition: spi.c:873
void SPIFIFOLevelGet(unsigned long ulBase, unsigned long *pulTxLevel, unsigned long *pulRxLevel)
Definition: spi.c:1056
void SPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
Definition: spi.c:1252
void SPIFIFOEnable(unsigned long ulBase, unsigned long ulFlags)
Definition: spi.c:971
void SPIDmaDisable(unsigned long ulBase, unsigned long ulFlags)
Definition: spi.c:638
void SPIIntClear(unsigned long ulBase, unsigned long ulIntFlags)
Definition: spi.c:1370
long SPITransfer(unsigned long ulBase, unsigned char *ucDout, unsigned char *ucDin, unsigned long ulSize, unsigned long ulFlags)
Definition: spi.c:1470
void SPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
Definition: spi.c:1205
void SPIReset(unsigned long ulBase)
Definition: spi.c:658