1 //*****************************************************************************
2 //
3 // ssi.h - Prototypes for the Synchronous Serial Interface Driver.
4 //
5 // Copyright (c) 2005-2012 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 //   Redistribution and use in source and binary forms, with or without
9 //   modification, are permitted provided that the following conditions
10 //   are met:
11 //
12 //   Redistributions of source code must retain the above copyright
13 //   notice, this list of conditions and the following disclaimer.
14 //
15 //   Redistributions in binary form must reproduce the above copyright
16 //   notice, this list of conditions and the following disclaimer in the
17 //   documentation and/or other materials provided with the
18 //   distribution.
19 //
20 //   Neither the name of Texas Instruments Incorporated nor the names of
21 //   its contributors may be used to endorse or promote products derived
22 //   from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __SSI_H__
41 #define __SSI_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 //
56 // Values that can be passed to SSIIntEnable, SSIIntDisable, and SSIIntClear
57 // as the ulIntFlags parameter, and returned by SSIIntStatus.
58 //
59 //*****************************************************************************
60 #define SSI_TXFF                0x00000008  // TX FIFO half full or less
61 #define SSI_RXFF                0x00000004  // RX FIFO half full or more
62 #define SSI_RXTO                0x00000002  // RX timeout
63 #define SSI_RXOR                0x00000001  // RX overrun
64 
65 //*****************************************************************************
66 //
67 // Values that can be passed to SSIConfigSetExpClk.
68 //
69 //*****************************************************************************
70 #define SSI_FRF_MOTO_MODE_0     0x00000000  // Moto fmt, polarity 0, phase 0
71 #define SSI_FRF_MOTO_MODE_1     0x00000002  // Moto fmt, polarity 0, phase 1
72 #define SSI_FRF_MOTO_MODE_2     0x00000001  // Moto fmt, polarity 1, phase 0
73 #define SSI_FRF_MOTO_MODE_3     0x00000003  // Moto fmt, polarity 1, phase 1
74 #define SSI_FRF_TI              0x00000010  // TI frame format
75 #define SSI_FRF_NMW             0x00000020  // National MicroWire frame format
76 
77 #define SSI_MODE_MASTER         0x00000000  // SSI master
78 #define SSI_MODE_SLAVE          0x00000001  // SSI slave
79 #define SSI_MODE_SLAVE_OD       0x00000002  // SSI slave with output disabled
80 
81 //*****************************************************************************
82 //
83 // Values that can be passed to SSIDMAEnable() and SSIDMADisable().
84 //
85 //*****************************************************************************
86 #define SSI_DMA_TX              0x00000002  // Enable DMA for transmit
87 #define SSI_DMA_RX              0x00000001  // Enable DMA for receive
88 
89 //*****************************************************************************
90 //
91 // Values that can be passed to SSIClockSourceSet() or returned from
92 // SSIClockSourceGet().
93 //
94 //*****************************************************************************
95 #define SSI_CLOCK_SYSTEM        0x00000000
96 #define SSI_CLOCK_PIOSC         0x00000005
97 
98 //*****************************************************************************
99 //
100 // Prototypes for the APIs.
101 //
102 //*****************************************************************************
103 extern void SSIConfigSetExpClk(unsigned long ulBase, unsigned long ulSSIClk,
104                                unsigned long ulProtocol, unsigned long ulMode,
105                                unsigned long ulBitRate,
106                                unsigned long ulDataWidth);
107 extern void SSIDataGet(unsigned long ulBase, unsigned long *pulData);
108 extern long SSIDataGetNonBlocking(unsigned long ulBase,
109                                   unsigned long *pulData);
110 extern void SSIDataPut(unsigned long ulBase, unsigned long ulData);
111 extern long SSIDataPutNonBlocking(unsigned long ulBase, unsigned long ulData);
112 extern void SSIDisable(unsigned long ulBase);
113 extern void SSIEnable(unsigned long ulBase);
114 extern void SSIIntClear(unsigned long ulBase, unsigned long ulIntFlags);
115 extern void SSIIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
116 extern void SSIIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
117 extern void SSIIntRegister(unsigned long ulBase, void(*pfnHandler)(void));
118 extern unsigned long SSIIntStatus(unsigned long ulBase, tBoolean bMasked);
119 extern void SSIIntUnregister(unsigned long ulBase);
120 extern void SSIDMAEnable(unsigned long ulBase, unsigned long ulDMAFlags);
121 extern void SSIDMADisable(unsigned long ulBase, unsigned long ulDMAFlags);
122 extern tBoolean SSIBusy(unsigned long ulBase);
123 extern void SSIClockSourceSet(unsigned long ulBase, unsigned long ulSource);
124 extern unsigned long SSIClockSourceGet(unsigned long ulBase);
125 
126 //*****************************************************************************
127 //
128 // Several SSI APIs have been renamed, with the original function name being
129 // deprecated.  These defines provide backward compatibility.
130 //
131 //*****************************************************************************
132 #ifndef DEPRECATED
133 #include "driverlib/sysctl.h"
134 #define SSIConfig(a, b, c, d, e)                            \
135         SSIConfigSetExpClk(a, SysCtlClockGet(), b, c, d, e)
136 #define SSIDataNonBlockingGet(a, b) \
137         SSIDataGetNonBlocking(a, b)
138 #define SSIDataNonBlockingPut(a, b) \
139         SSIDataPutNonBlocking(a, b)
140 #endif
141 
142 //*****************************************************************************
143 //
144 // Mark the end of the C bindings section for C++ compilers.
145 //
146 //*****************************************************************************
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif // __SSI_H__
152