]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - msp430-bsl/msp430-bsl.git/blob - source/driverlib/MSP430F5xx_6xx/usci_b_spi.h
MSP-BSL v3.0
[msp430-bsl/msp430-bsl.git] / source / driverlib / MSP430F5xx_6xx / usci_b_spi.h
1 /* --COPYRIGHT--,BSD\r
2  * Copyright (c) 2014, Texas Instruments Incorporated\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * *  Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  * *  Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  * --/COPYRIGHT--*/\r
32 //*****************************************************************************\r
33 //\r
34 // usci_b_spi.h - Driver for the USCI_B_SPI Module.\r
35 //\r
36 //*****************************************************************************\r
37 \r
38 #ifndef __MSP430WARE_USCI_B_SPI_H__\r
39 #define __MSP430WARE_USCI_B_SPI_H__\r
40 \r
41 #include "inc/hw_memmap.h"\r
42 \r
43 #ifdef __MSP430_HAS_USCI_Bx__\r
44 \r
45 //*****************************************************************************\r
46 //\r
47 // If building with a C++ compiler, make all of the definitions in this header\r
48 // have a C binding.\r
49 //\r
50 //*****************************************************************************\r
51 #ifdef __cplusplus\r
52 extern "C"\r
53 {\r
54 #endif\r
55 \r
56 //******************************************************************************\r
57 //\r
58 // The following is a struct that is passed to USCI_B_SPI_initMaster()\r
59 //\r
60 //******************************************************************************\r
61 typedef struct USCI_B_SPI_initMasterParam {\r
62         uint8_t selectClockSource;\r
63         uint32_t clockSourceFrequency;\r
64         uint32_t desiredSpiClock;\r
65         uint8_t msbFirst;\r
66         uint8_t clockPhase;\r
67         uint8_t clockPolarity;\r
68 } USCI_B_SPI_initMasterParam;\r
69 \r
70 //******************************************************************************\r
71 //\r
72 // The following is a struct that is passed to USCI_B_SPI_changeMasterParam()\r
73 //\r
74 //******************************************************************************\r
75 typedef struct USCI_B_SPI_ChangeMasterClockParam {\r
76         uint32_t clockSourceFrequency;\r
77         uint32_t desiredSpiClock;\r
78 } USCI_B_SPI_changeMasterClockParam;\r
79 \r
80 //*****************************************************************************\r
81 //\r
82 // The following are values that can be passed to the clockPhase parameter for\r
83 // functions: USCI_B_SPI_masterInit(), USCI_B_SPI_slaveInit(), and\r
84 // USCI_B_SPI_changeClockPhasePolarity().\r
85 //\r
86 //*****************************************************************************\r
87 #define USCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT             0x00\r
88 #define USCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT           UCCKPH\r
89 \r
90 //*****************************************************************************\r
91 //\r
92 // The following are values that can be passed to the msbFirst parameter for\r
93 // functions: USCI_B_SPI_masterInit(), and USCI_B_SPI_slaveInit().\r
94 //\r
95 //*****************************************************************************\r
96 #define USCI_B_SPI_MSB_FIRST                                              UCMSB\r
97 #define USCI_B_SPI_LSB_FIRST                                               0x00\r
98 \r
99 //*****************************************************************************\r
100 //\r
101 // The following are values that can be passed to the clockPolarity parameter\r
102 // for functions: USCI_B_SPI_masterInit(), USCI_B_SPI_slaveInit(), and\r
103 // USCI_B_SPI_changeClockPhasePolarity().\r
104 //\r
105 //*****************************************************************************\r
106 #define USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH                         UCCKPL\r
107 #define USCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW                            0x00\r
108 \r
109 //*****************************************************************************\r
110 //\r
111 // The following are values that can be passed to the selectClockSource\r
112 // parameter for functions: USCI_B_SPI_masterInit().\r
113 //\r
114 //*****************************************************************************\r
115 #define USCI_B_SPI_CLOCKSOURCE_ACLK                                UCSSEL__ACLK\r
116 #define USCI_B_SPI_CLOCKSOURCE_SMCLK                              UCSSEL__SMCLK\r
117 \r
118 //*****************************************************************************\r
119 //\r
120 // The following are values that can be passed to the mask parameter for\r
121 // functions: USCI_B_SPI_enableInterrupt(), USCI_B_SPI_disableInterrupt(),\r
122 // USCI_B_SPI_getInterruptStatus(), and USCI_B_SPI_clearInterruptFlag() as well\r
123 // as returned by the USCI_B_SPI_getInterruptStatus() function.\r
124 //\r
125 //*****************************************************************************\r
126 #define USCI_B_SPI_TRANSMIT_INTERRUPT                                    UCTXIE\r
127 #define USCI_B_SPI_RECEIVE_INTERRUPT                                     UCRXIE\r
128 \r
129 //*****************************************************************************\r
130 //\r
131 // The following are values that can be passed toThe following are values that\r
132 // can be returned by the USCI_B_SPI_isBusy() function.\r
133 //\r
134 //*****************************************************************************\r
135 #define USCI_B_SPI_BUSY                                                  UCBUSY\r
136 #define USCI_B_SPI_NOT_BUSY                                                0x00\r
137 \r
138 //*****************************************************************************\r
139 //\r
140 // Prototypes for the APIs.\r
141 //\r
142 //*****************************************************************************\r
143 extern bool USCI_B_SPI_initMaster(uint16_t baseAddress,\r
144                                   USCI_B_SPI_initMasterParam *param);\r
145 \r
146 extern void USCI_B_SPI_changeMasterClock(uint16_t baseAddress,\r
147                                          USCI_B_SPI_changeMasterClockParam *param);\r
148 \r
149 extern bool USCI_B_SPI_slaveInit(uint16_t baseAddress,\r
150                                  uint8_t msbFirst,\r
151                                  uint8_t clockPhase,\r
152                                  uint8_t clockPolarity);\r
153 \r
154 extern void USCI_B_SPI_changeClockPhasePolarity(uint16_t baseAddress,\r
155                                                 uint8_t clockPhase,\r
156                                                 uint8_t clockPolarity);\r
157 \r
158 extern void USCI_B_SPI_transmitData(uint16_t baseAddress,\r
159                                     uint8_t transmitData);\r
160 \r
161 extern uint8_t USCI_B_SPI_receiveData(uint16_t baseAddress);\r
162 \r
163 extern void USCI_B_SPI_enableInterrupt(uint16_t baseAddress,\r
164                                        uint8_t mask);\r
165 \r
166 extern void USCI_B_SPI_disableInterrupt(uint16_t baseAddress,\r
167                                         uint8_t mask);\r
168 \r
169 extern uint8_t USCI_B_SPI_getInterruptStatus(uint16_t baseAddress,\r
170                                              uint8_t mask);\r
171 \r
172 extern void USCI_B_SPI_clearInterruptFlag(uint16_t baseAddress,\r
173                                           uint8_t mask);\r
174 \r
175 extern void USCI_B_SPI_enable(uint16_t baseAddress);\r
176 \r
177 extern void USCI_B_SPI_disable(uint16_t baseAddress);\r
178 \r
179 extern uint32_t USCI_B_SPI_getReceiveBufferAddressForDMA(uint16_t baseAddress);\r
180 \r
181 extern uint32_t USCI_B_SPI_getTransmitBufferAddressForDMA(uint16_t baseAddress);\r
182 \r
183 extern uint8_t USCI_B_SPI_isBusy(uint16_t baseAddress);\r
184 \r
185 //*****************************************************************************\r
186 //\r
187 // The following are deprecated APIs.\r
188 //\r
189 //*****************************************************************************\r
190 extern bool USCI_B_SPI_masterInit(uint16_t baseAddress,\r
191                                   uint8_t selectClockSource,\r
192                                   uint32_t clockSourceFrequency,\r
193                                   uint32_t desiredSpiClock,\r
194                                   uint8_t msbFirst,\r
195                                   uint8_t clockPhase,\r
196                                   uint8_t clockPolarity);\r
197 \r
198 extern void USCI_B_SPI_masterChangeClock(uint16_t baseAddress,\r
199                                          uint32_t clockSourceFrequency,\r
200                                          uint32_t desiredSpiClock);\r
201 \r
202 //*****************************************************************************\r
203 //\r
204 // Mark the end of the C bindings section for C++ compilers.\r
205 //\r
206 //*****************************************************************************\r
207 #ifdef __cplusplus\r
208 }\r
209 #endif\r
210 \r
211 #endif\r
212 #endif // __MSP430WARE_USCI_B_SPI_H__\r