]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/driverlib/i2c.h
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / driverlib / i2c.h
1 /*
2  * -------------------------------------------
3  *    MSP432 DriverLib - v3_10_00_09 
4  * -------------------------------------------
5  *
6  * --COPYRIGHT--,BSD,BSD
7  * Copyright (c) 2014, Texas Instruments Incorporated
8  * All rights reserved.
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 distribution.
20  *
21  * *  Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  * --/COPYRIGHT--*/
37 #ifndef I2C_H_
38 #define I2C_H_
39
40 //*****************************************************************************
41 //
42 //! \addtogroup i2c_api
43 //! @{
44 //
45 //*****************************************************************************
46
47 //*****************************************************************************
48 //
49 // If building with a C++ compiler, make all of the definitions in this header
50 // have a C binding.
51 //
52 //*****************************************************************************
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57
58 #include <stdint.h>
59 #include <stdbool.h>
60 #include <msp.h>
61 #include "eusci.h"
62
63 #define EUSCI_B_I2C_NO_AUTO_STOP                           EUSCI_B_CTLW1_ASTP_0
64 #define EUSCI_B_I2C_SET_BYTECOUNT_THRESHOLD_FLAG           EUSCI_B_CTLW1_ASTP_1
65 #define EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD  \
66                                                                EUSCI_B_CTLW1_ASTP_2
67
68 #define EUSCI_B_I2C_SET_DATA_RATE_1MBPS                                 1000000
69 #define EUSCI_B_I2C_SET_DATA_RATE_400KBPS                                400000
70 #define EUSCI_B_I2C_SET_DATA_RATE_100KBPS                                100000
71
72 #define EUSCI_B_I2C_CLOCKSOURCE_ACLK                   EUSCI_B_CTLW0_SSEL__ACLK
73 #define EUSCI_B_I2C_CLOCKSOURCE_SMCLK                 EUSCI_B_CTLW0_SSEL__SMCLK
74
75 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET0                                    0x00
76 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET1                                    0x02
77 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET2                                    0x04
78 #define EUSCI_B_I2C_OWN_ADDRESS_OFFSET3                                    0x06
79
80 #define EUSCI_B_I2C_OWN_ADDRESS_DISABLE                                    0x00
81 #define EUSCI_B_I2C_OWN_ADDRESS_ENABLE                      EUSCI_B_I2COA0_OAEN
82
83 #define EUSCI_B_I2C_TRANSMIT_MODE                              EUSCI_B_CTLW0_TR
84 #define EUSCI_B_I2C_RECEIVE_MODE                                           0x00
85
86 #define EUSCI_B_I2C_NAK_INTERRUPT                             EUSCI_B_IE_NACKIE
87 #define EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT                   EUSCI_B_IE_ALIE
88 #define EUSCI_B_I2C_STOP_INTERRUPT                             EUSCI_B_IE_STPIE
89 #define EUSCI_B_I2C_START_INTERRUPT                            EUSCI_B_IE_STTIE
90 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT0                        EUSCI_B_IE_TXIE0
91 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT1                        EUSCI_B_IE_TXIE1
92 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT2                        EUSCI_B_IE_TXIE2
93 #define EUSCI_B_I2C_TRANSMIT_INTERRUPT3                        EUSCI_B_IE_TXIE3
94 #define EUSCI_B_I2C_RECEIVE_INTERRUPT0                         EUSCI_B_IE_RXIE0
95 #define EUSCI_B_I2C_RECEIVE_INTERRUPT1                         EUSCI_B_IE_RXIE1
96 #define EUSCI_B_I2C_RECEIVE_INTERRUPT2                         EUSCI_B_IE_RXIE2
97 #define EUSCI_B_I2C_RECEIVE_INTERRUPT3                         EUSCI_B_IE_RXIE3
98 #define EUSCI_B_I2C_BIT9_POSITION_INTERRUPT                   EUSCI_B_IE_BIT9IE
99 #define EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT               EUSCI_B_IE_CLTOIE
100 #define EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT                    EUSCI_B_IE_BCNTIE
101
102 #define EUSCI_B_I2C_BUS_BUSY                                EUSCI_B_STATW_BBUSY
103 #define EUSCI_B_I2C_BUS_NOT_BUSY                                           0x00
104
105 #define EUSCI_B_I2C_STOP_SEND_COMPLETE                                     0x00
106 #define EUSCI_B_I2C_SENDING_STOP                            EUSCI_B_CTLW0_TXSTP
107
108 #define EUSCI_B_I2C_START_SEND_COMPLETE                                    0x00
109 #define EUSCI_B_I2C_SENDING_START                           EUSCI_B_CTLW0_TXSTT
110
111 //*****************************************************************************
112 //
113 //!     ypedef eUSCI_I2C_MasterConfig
114 //! \brief Type definition for \link _eUSCI_I2C_MasterConfig \endlink structure
115 //!
116 //! \struct _eUSCI_I2C_MasterConfig
117 //! \brief Configuration structure for master mode in the \b I2C module. See
118 //!          \link I2C_initMaster \endlink for parameter documentation.
119 //
120 //*****************************************************************************
121 typedef struct
122 {
123     uint_fast8_t selectClockSource;
124     uint32_t i2cClk;
125     uint32_t dataRate;
126     uint_fast8_t byteCounterThreshold;
127     uint_fast8_t autoSTOPGeneration;
128 } eUSCI_I2C_MasterConfig;
129
130
131 //*****************************************************************************
132 //
133 //! Initializes the I2C Master block.
134 //!
135 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
136 //! parameters vary from part to part, but can include:
137 //!         - \b EUSCI_B0_BASE
138 //!         - \b EUSCI_B1_BASE
139 //!         - \b EUSCI_B2_BASE
140 //!         - \b EUSCI_B3_BASE
141 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
142 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
143 //!  I2C mode.
144 //! \param config Configuration structure for I2C master mode
145 //!
146 //! <hr>
147 //! <b>Configuration options for \link eUSCI_I2C_MasterConfig \endlink structure.</b>
148 //! <hr>
149 //!
150 //! \param selectClockSource is the clock source.
151 //!         Valid values are
152 //!         - \b EUSCI_B_I2C_CLOCKSOURCE_ACLK
153 //!         - \b EUSCI_B_I2C_CLOCKSOURCE_SMCLK
154 //! \param i2cClk is the rate of the clock supplied to the I2C module
155 //!                   (the frequency in Hz of the clock source specified in
156 //!                     selectClockSource).
157 //! \param dataRate set up for selecting data transfer rate.
158 //!         Valid values are
159 //!         - \b EUSCI_B_I2C_SET_DATA_RATE_1MBPS
160 //!         - \b EUSCI_B_I2C_SET_DATA_RATE_400KBPS
161 //!         - \b EUSCI_B_I2C_SET_DATA_RATE_100KBPS
162 //! \param byteCounterThreshold sets threshold for automatic STOP or UCSTPIFG
163 //! \param autoSTOPGeneration sets up the STOP condition generation.
164 //!         Valid values are
165 //!         - \b EUSCI_B_I2C_NO_AUTO_STOP
166 //!         - \b EUSCI_B_I2C_SET_BYTECOUNT_THRESHOLD_FLAG
167 //!         - \b EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD
168 //!
169 //! This function initializes operation of the I2C Master block.  Upon
170 //! successful initialization of the I2C block, this function will have set the
171 //! bus speed for the master; however I2C module is still disabled till
172 //! I2C_enableModule is invoked
173 //!
174 //! Modified bits are \b UCMST,UCMODE_3,\b UCSYNC of \b UCBxCTL0 register
175 //!                   \b UCSSELx, \b UCSWRST, of \b UCBxCTL1 register
176 //!                   \b UCBxBR0 and \b UCBxBR1 registers
177 //! \return None.
178 //
179 //*****************************************************************************
180 extern void I2C_initMaster(uint32_t moduleInstance,
181         const eUSCI_I2C_MasterConfig *config);
182
183 //*****************************************************************************
184 //
185 //! Initializes the I2C Slave block.
186 //!
187 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
188 //! parameters vary from part to part, but can include:
189 //!         - \b EUSCI_B0_BASE
190 //!         - \b EUSCI_B1_BASE
191 //!         - \b EUSCI_B2_BASE
192 //!         - \b EUSCI_B3_BASE
193 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
194 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
195 //!  I2C mode.
196 //!
197 //! \param slaveAddress 7-bit or 10-bit slave address 
198 //! \param slaveAddressOffset Own address Offset referred to- 'x' value of
199 //!     UCBxI2COAx. Valid values are:
200 //!                  - \b EUSCI_B_I2C_OWN_ADDRESS_OFFSET0,
201 //!                  - \b EUSCI_B_I2C_OWN_ADDRESS_OFFSET1,
202 //!                  - \b EUSCI_B_I2C_OWN_ADDRESS_OFFSET2,
203 //!                  - \b EUSCI_B_I2C_OWN_ADDRESS_OFFSET3
204 //! \param slaveOwnAddressEnable selects if the specified address is enabled
205 //!     or disabled. Valid values are:
206 //!                     - \b EUSCI_B_I2C_OWN_ADDRESS_DISABLE,
207 //!                     - \b EUSCI_B_I2C_OWN_ADDRESS_ENABLE
208 //!
209 //! This function initializes operation of the I2C as a Slave mode.  Upon
210 //! successful initialization of the I2C blocks, this function will have set
211 //! the slave address but the I2C module is still disabled till
212 //! I2C_enableModule is invoked.
213 //!
214 //! The parameter slaveAddress is the value that will be compared against the
215 //! slave address sent by an I2C master.
216 //!
217 //! Modified bits are \b UCMODE_3, \b UCSYNC of \b UCBxCTL0 register
218 //!                   \b UCSWRST of \b UCBxCTL1 register
219 //!                   \b UCBxI2COA register
220 //!
221 //! \return None.
222 //
223 //*****************************************************************************
224 extern void I2C_initSlave(uint32_t moduleInstance, uint_fast16_t slaveAddress,
225         uint_fast8_t slaveAddressOffset, uint32_t slaveOwnAddressEnable);
226
227 //*****************************************************************************
228 //
229 //! Enables the I2C block.
230 //!
231 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
232 //! parameters vary from part to part, but can include:
233 //!         - \b EUSCI_B0_BASE
234 //!         - \b EUSCI_B1_BASE
235 //!         - \b EUSCI_B2_BASE
236 //!         - \b EUSCI_B3_BASE
237 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
238 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
239 //!  I2C mode.
240 //!
241 //! This will enable operation of the I2C block.
242 //! Modified bits are \b UCSWRST of \b UCBxCTL1 register.
243 //!
244 //! \return None.
245 //
246 //*****************************************************************************
247 extern void I2C_enableModule(uint32_t moduleInstance);
248
249 //*****************************************************************************
250 //
251 //! Disables the I2C block.
252 //!
253 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
254 //! parameters vary from part to part, but can include:
255 //!         - \b EUSCI_B0_BASE
256 //!         - \b EUSCI_B1_BASE
257 //!         - \b EUSCI_B2_BASE
258 //!         - \b EUSCI_B3_BASE
259 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
260 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
261 //!  I2C mode.
262 //!
263 //! This will disable operation of the I2C block.
264 //! Modified bits are \b UCSWRST of \b UCBxCTL1 register.
265 //!
266 //! \return None.
267 //
268 //*****************************************************************************
269 extern void I2C_disableModule(uint32_t moduleInstance);
270
271 //*****************************************************************************
272 //
273 //! Sets the address that the I2C Master will place on the bus.
274 //!
275 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
276 //! parameters vary from part to part, but can include:
277 //!         - \b EUSCI_B0_BASE
278 //!         - \b EUSCI_B1_BASE
279 //!         - \b EUSCI_B2_BASE
280 //!         - \b EUSCI_B3_BASE
281 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
282 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
283 //!  I2C mode.
284 //!
285 //! \param slaveAddress 7-bit or 10-bit slave address
286 //!
287 //! This function will set the address that the I2C Master will place on the
288 //! bus when initiating a transaction.
289 //! Modified register is  \b UCBxI2CSA register
290 //!
291 //! \return None.
292 //
293 //*****************************************************************************
294 extern void I2C_setSlaveAddress(uint32_t moduleInstance,
295         uint_fast16_t slaveAddress);
296
297 //*****************************************************************************
298 //
299 //! Sets the mode of the I2C device
300 //!
301 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
302 //! parameters vary from part to part, but can include:
303 //!         - \b EUSCI_B0_BASE
304 //!         - \b EUSCI_B1_BASE
305 //!         - \b EUSCI_B2_BASE
306 //!         - \b EUSCI_B3_BASE
307 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
308 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
309 //!  I2C mode.
310 //!
311 //! \param mode indicates whether module is in transmit/receive mode
312 //!     - \b EUSCI_B_I2C_TRANSMIT_MODE
313 //!     - \b EUSCI_B_I2C_RECEIVE_MODE [Default value]
314 //!
315 //! Modified bits are \b UCTR of \b UCBxCTL1 register
316 //!
317 //! \return None.
318 //
319 //*****************************************************************************
320 extern void I2C_setMode(uint32_t moduleInstance, uint_fast8_t mode);
321
322 //*****************************************************************************
323 //
324 //! \brief Gets the mode of the I2C device
325 //!
326 //! Current I2C transmit/receive mode.
327 //!
328 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
329 //! parameters vary from part to part, but can include:
330 //!         - \b EUSCI_B0_BASE
331 //!         - \b EUSCI_B1_BASE
332 //!         - \b EUSCI_B2_BASE
333 //!         - \b EUSCI_B3_BASE
334 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
335 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
336 //!  I2C mode.
337 //!
338 //! Modified bits are \b UCTR of \b UCBxCTL1 register.
339 //!
340 //! \return None
341 //!         Return one of the following:
342 //!         - \b EUSCI_B_I2C_TRANSMIT_MODE
343 //!         - \b EUSCI_B_I2C_RECEIVE_MODE
344 //!         \n indicating the current mode
345 //
346 //*****************************************************************************
347 extern uint_fast8_t I2C_getMode(uint32_t moduleInstance);
348
349 //*****************************************************************************
350 //
351 //! Transmits a byte from the I2C Module.
352 //!
353 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
354 //! parameters vary from part to part, but can include:
355 //!         - \b EUSCI_B0_BASE
356 //!         - \b EUSCI_B1_BASE
357 //!         - \b EUSCI_B2_BASE
358 //!         - \b EUSCI_B3_BASE
359 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
360 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
361 //!  I2C mode.
362 //!
363 //! \param transmitData data to be transmitted from the I2C module
364 //!
365 //! This function will place the supplied data into I2C transmit data register
366 //! to start transmission
367 //! Modified register is \b UCBxTXBUF register
368 //!
369 //! \return None.
370 //
371 //*****************************************************************************
372 extern void I2C_slavePutData(uint32_t moduleInstance, uint8_t transmitData);
373
374 //*****************************************************************************
375 //
376 //! Receives a byte that has been sent to the I2C Module.
377 //!
378 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
379 //! parameters vary from part to part, but can include:
380 //!         - \b EUSCI_B0_BASE
381 //!         - \b EUSCI_B1_BASE
382 //!         - \b EUSCI_B2_BASE
383 //!         - \b EUSCI_B3_BASE
384 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
385 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
386 //!  I2C mode.
387 //!
388 //! This function reads a byte of data from the I2C receive data Register.
389 //!
390 //! \return Returns the byte received from by the I2C module, cast as an
391 //! uint8_t.
392 //! Modified bit is \b UCBxRXBUF register
393 //
394 //*****************************************************************************
395 extern uint8_t I2C_slaveGetData(uint32_t moduleInstance);
396
397 //*****************************************************************************
398 //
399 //! Indicates whether or not the I2C bus is busy.
400 //!
401 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
402 //! parameters vary from part to part, but can include:
403 //!         - \b EUSCI_B0_BASE
404 //!         - \b EUSCI_B1_BASE
405 //!         - \b EUSCI_B2_BASE
406 //!         - \b EUSCI_B3_BASE
407 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
408 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
409 //!  I2C mode.
410 //!
411 //!
412 //! This function returns an indication of whether or not the I2C bus is
413 //! busy.This function checks the status of the bus via UCBBUSY bit in
414 //! UCBxSTAT register.
415 //!
416 //! \return Returns EUSCI_B_I2C_BUS_BUSY if the I2C Master is busy; otherwise,
417 //! returns EUSCI_B_I2C_BUS_NOT_BUSY.
418 //
419 //*****************************************************************************
420 extern uint8_t I2C_isBusBusy(uint32_t moduleInstance);
421
422 //*****************************************************************************
423 //
424 //! Does single byte transmission from Master to Slave
425 //!
426 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
427 //! parameters vary from part to part, but can include:
428 //!         - \b EUSCI_B0_BASE
429 //!         - \b EUSCI_B1_BASE
430 //!         - \b EUSCI_B2_BASE
431 //!         - \b EUSCI_B3_BASE
432 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
433 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
434 //!  I2C mode.
435 //!
436 //! \param txData is the data byte to be transmitted
437 //!
438 //! This function is used by the Master module to send a single byte.
439 //! This function
440 //! - Sends START
441 //! - Transmits the byte to the Slave
442 //! - Sends STOP
443 //!
444 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
445 //! \b UCBxIE
446 //!
447 //! \return none
448 //
449 //*****************************************************************************
450 extern void I2C_masterSendSingleByte(uint32_t moduleInstance, uint8_t txData);
451
452 //*****************************************************************************
453 //
454 //! Does single byte transmission from Master to Slave with timeout
455 //!
456 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
457 //! parameters vary from part to part, but can include:
458 //!         - \b EUSCI_B0_BASE
459 //!         - \b EUSCI_B1_BASE
460 //!         - \b EUSCI_B2_BASE
461 //!         - \b EUSCI_B3_BASE
462 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
463 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
464 //!  I2C mode.
465 //!
466 //! \param txData is the data byte to be transmitted
467 //! \param timeout is the amount of time to wait until giving up
468 //!
469 //! This function is used by the Master module to send a single byte.
470 //! This function
471 //! - Sends START
472 //! - Transmits the byte to the Slave
473 //! - Sends STOP
474 //!
475 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
476 //! \b UCBxIE
477 //!
478 //! \return 0x01 or 0x00URE of the transmission process.
479 //
480 //*****************************************************************************
481 extern bool I2C_masterSendSingleByteWithTimeout(uint32_t moduleInstance,
482         uint8_t txData, uint32_t timeout);
483
484 //*****************************************************************************
485 //
486 //! Starts multi-byte transmission from Master to Slave
487 //!
488 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
489 //! parameters vary from part to part, but can include:
490 //!         - \b EUSCI_B0_BASE
491 //!         - \b EUSCI_B1_BASE
492 //!         - \b EUSCI_B2_BASE
493 //!         - \b EUSCI_B3_BASE
494 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
495 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
496 //!  I2C mode.
497 //!
498 //! \param txData is the first data byte to be transmitted
499 //!
500 //! This function is used by the Master module to send a single byte.
501 //! This function
502 //! - Sends START
503 //! - Transmits the first data byte of a multi-byte transmission to the Slave
504 //!
505 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
506 //! \b UCBxIE
507 //!
508 //! \return None.
509 //
510 //*****************************************************************************
511 extern void I2C_masterSendMultiByteStart(uint32_t moduleInstance,
512         uint8_t txData);
513
514 //*****************************************************************************
515 //
516 //! Starts multi-byte transmission from Master to Slave with timeout
517 //!
518 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
519 //! parameters vary from part to part, but can include:
520 //!         - \b EUSCI_B0_BASE
521 //!         - \b EUSCI_B1_BASE
522 //!         - \b EUSCI_B2_BASE
523 //!         - \b EUSCI_B3_BASE
524 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
525 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
526 //!  I2C mode.
527 //!
528 //! \param txData is the first data byte to be transmitted
529 //! \param timeout is the amount of time to wait until giving up
530 //!
531 //! This function is used by the Master module to send a single byte.
532 //! This function
533 //! - Sends START
534 //! - Transmits the first data byte of a multi-byte transmission to the Slave
535 //!
536 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
537 //! \b UCBxIE
538 //!
539 //! \return 0x01 or 0x00URE of the transmission process.
540 //
541 //*****************************************************************************
542 extern bool I2C_masterSendMultiByteStartWithTimeout(uint32_t moduleInstance,
543         uint8_t txData, uint32_t timeout);
544
545 //*****************************************************************************
546 //
547 //! Continues multi-byte transmission from Master to Slave
548 //!
549 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
550 //! parameters vary from part to part, but can include:
551 //!         - \b EUSCI_B0_BASE
552 //!         - \b EUSCI_B1_BASE
553 //!         - \b EUSCI_B2_BASE
554 //!         - \b EUSCI_B3_BASE
555 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
556 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
557 //!  I2C mode.
558 //!
559 //! \param txData is the next data byte to be transmitted
560 //!
561 //! This function is used by the Master module continue each byte of a
562 //! multi-byte trasmission. This function
563 //! - Transmits each data byte of a multi-byte transmission to the Slave
564 //!
565 //! Modified registers are \b UCBxTXBUF
566 //!
567 //! \return None.
568 //
569 //*****************************************************************************
570 extern void I2C_masterSendMultiByteNext(uint32_t moduleInstance,
571         uint8_t txData);
572
573 //*****************************************************************************
574 //
575 //! Continues multi-byte transmission from Master to Slave with timeout
576 //!
577 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
578 //! parameters vary from part to part, but can include:
579 //!         - \b EUSCI_B0_BASE
580 //!         - \b EUSCI_B1_BASE
581 //!         - \b EUSCI_B2_BASE
582 //!         - \b EUSCI_B3_BASE
583 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
584 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
585 //!  I2C mode.
586 //!
587 //! \param txData is the next data byte to be transmitted
588 //!
589 //! \param timeout is the amount of time to wait until giving up
590 //!
591 //! This function is used by the Master module continue each byte of a
592 //! multi-byte transmission. This function
593 //! - Transmits each data byte of a multi-byte transmission to the Slave
594 //!
595 //! Modified registers are \b UCBxTXBUF
596 //!
597 //! \return 0x01 or 0x00URE of the transmission process.
598 //
599 //*****************************************************************************
600 extern bool I2C_masterSendMultiByteNextWithTimeout(uint32_t moduleInstance,
601         uint8_t txData, uint32_t timeout);
602
603 //*****************************************************************************
604 //
605 //! Finishes multi-byte transmission from Master to Slave
606 //!
607 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
608 //! parameters vary from part to part, but can include:
609 //!         - \b EUSCI_B0_BASE
610 //!         - \b EUSCI_B1_BASE
611 //!         - \b EUSCI_B2_BASE
612 //!         - \b EUSCI_B3_BASE
613 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
614 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
615 //!  I2C mode.
616 //!
617 //! \param txData is the last data byte to be transmitted in a multi-byte
618 //! transmsission
619 //!
620 //! This function is used by the Master module to send the last byte and STOP.
621 //! This function
622 //! - Transmits the last data byte of a multi-byte transmission to the Slave
623 //! - Sends STOP
624 //!
625 //! Modified registers are \b UCBxTXBUF and \b UCBxCTL1.
626 //!
627 //! \return None.
628 //
629 //*****************************************************************************
630 extern void I2C_masterSendMultiByteFinish(uint32_t moduleInstance,
631         uint8_t txData);
632
633 //*****************************************************************************
634 //
635 //! Finishes multi-byte transmission from Master to Slave with timeout
636 //!
637 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
638 //! parameters vary from part to part, but can include:
639 //!         - \b EUSCI_B0_BASE
640 //!         - \b EUSCI_B1_BASE
641 //!         - \b EUSCI_B2_BASE
642 //!         - \b EUSCI_B3_BASE
643 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
644 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
645 //!  I2C mode.
646 //!
647 //! \param txData is the last data byte to be transmitted in a multi-byte
648 //! transmission
649 //! \param timeout is the amount of time to wait until giving up
650 //!
651 //! This function is used by the Master module to send the last byte and STOP.
652 //! This function
653 //! - Transmits the last data byte of a multi-byte transmission to the Slave
654 //! - Sends STOP
655 //!
656 //! Modified registers are \b UCBxTXBUF and \b UCBxCTL1.
657 //!
658 //! \return 0x01 or 0x00URE of the transmission process.
659 //
660 //*****************************************************************************
661 extern bool I2C_masterSendMultiByteFinishWithTimeout(uint32_t moduleInstance,
662         uint8_t txData, uint32_t timeout);
663
664 //*****************************************************************************
665 //
666 //! Send STOP byte at the end of a multi-byte transmission from Master to Slave
667 //!
668 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
669 //! parameters vary from part to part, but can include:
670 //!         - \b EUSCI_B0_BASE
671 //!         - \b EUSCI_B1_BASE
672 //!         - \b EUSCI_B2_BASE
673 //!         - \b EUSCI_B3_BASE
674 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
675 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
676 //!  I2C mode.
677 //!
678 //!
679 //! This function is used by the Master module send STOP at the end of a
680 //! multi-byte transmission
681 //!
682 //! This function
683 //! - Send a STOP after current transmission is complete
684 //!
685 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
686 //! \return None.
687 //
688 //*****************************************************************************
689 extern void I2C_masterSendMultiByteStop(uint32_t moduleInstance);
690
691 //*****************************************************************************
692 //
693 //! Send STOP byte at the end of a multi-byte transmission from Master to Slave
694 //! with timeout
695 //!
696 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
697 //! parameters vary from part to part, but can include:
698 //!         - \b EUSCI_B0_BASE
699 //!         - \b EUSCI_B1_BASE
700 //!         - \b EUSCI_B2_BASE
701 //!         - \b EUSCI_B3_BASE
702 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
703 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
704 //!  I2C mode.
705 //!
706 //! \param timeout is the amount of time to wait until giving up
707 //!
708 //! This function is used by the Master module send STOP at the end of a
709 //! multi-byte transmission
710 //!
711 //! This function
712 //! - Send a STOP after current transmission is complete
713 //!
714 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
715 //! \return 0x01 or 0x00URE of the transmission process.
716 //
717 //*****************************************************************************
718 extern bool I2C_masterSendMultiByteStopWithTimeout(uint32_t moduleInstance,
719         uint32_t timeout);
720
721 //*****************************************************************************
722 //
723 //! Starts reception at the Master end
724 //!
725 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
726 //! parameters vary from part to part, but can include:
727 //!         - \b EUSCI_B0_BASE
728 //!         - \b EUSCI_B1_BASE
729 //!         - \b EUSCI_B2_BASE
730 //!         - \b EUSCI_B3_BASE
731 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
732 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
733 //!  I2C mode.
734 //!
735 //!
736 //! This function is used by the Master module initiate reception of a single
737 //! byte. This function
738 //! - Sends START
739 //!
740 //! Modified bits are \b UCTXSTT bit of \b UCBxCTL1.
741 //! \return None.
742 //
743 //*****************************************************************************
744 extern void I2C_masterReceiveStart(uint32_t moduleInstance);
745
746 //*****************************************************************************
747 //
748 //! Starts multi-byte reception at the Master end one byte at a time
749 //!
750 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
751 //! parameters vary from part to part, but can include:
752 //!         - \b EUSCI_B0_BASE
753 //!         - \b EUSCI_B1_BASE
754 //!         - \b EUSCI_B2_BASE
755 //!         - \b EUSCI_B3_BASE
756 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
757 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
758 //!  I2C mode.
759 //!
760 //!
761 //! This function is used by the Master module to receive each byte of a
762 //! multi-byte reception
763 //! This function reads currently received byte
764 //!
765 //! Modified register is \b UCBxRXBUF.
766 //! \return Received byte at Master end.
767 //
768 //*****************************************************************************
769 extern uint8_t I2C_masterReceiveMultiByteNext(uint32_t moduleInstance);
770
771 //*****************************************************************************
772 //
773 //! Finishes multi-byte reception at the Master end
774 //!
775 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
776 //! parameters vary from part to part, but can include:
777 //!         - \b EUSCI_B0_BASE
778 //!         - \b EUSCI_B1_BASE
779 //!         - \b EUSCI_B2_BASE
780 //!         - \b EUSCI_B3_BASE
781 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
782 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
783 //!  I2C mode.
784 //!
785 //!
786 //! This function is used by the Master module to initiate completion of a
787 //! multi-byte reception
788 //! This function
789 //! - Receives the current byte and initiates the STOP from Master to Slave
790 //!
791 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
792 //!
793 //! \return Received byte at Master end.
794 //
795 //*****************************************************************************
796 extern uint8_t I2C_masterReceiveMultiByteFinish(uint32_t moduleInstance);
797
798 //*****************************************************************************
799 //
800 //! Finishes multi-byte reception at the Master end with timeout
801 //!
802 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
803 //! parameters vary from part to part, but can include:
804 //!         - \b EUSCI_B0_BASE
805 //!         - \b EUSCI_B1_BASE
806 //!         - \b EUSCI_B2_BASE
807 //!         - \b EUSCI_B3_BASE
808 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
809 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
810 //!  I2C mode.
811 //!
812 //! \param txData is a pointer to the location to store the received byte at
813 //!     master end
814 //! \param timeout is the amount of time to wait until giving up
815 //!
816 //! This function is used by the Master module to initiate completion of a
817 //! multi-byte reception
818 //! This function
819 //! - Receives the current byte and initiates the STOP from Master to Slave
820 //!
821 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
822 //!
823 //! \return 0x01 or 0x00URE of the transmission process.
824 //
825 //*****************************************************************************
826 extern bool I2C_masterReceiveMultiByteFinishWithTimeout(uint32_t moduleInstance,
827         uint8_t *txData, uint32_t timeout);
828
829 //*****************************************************************************
830 //
831 //! Sends the STOP at the end of a multi-byte reception at the Master end
832 //!
833 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
834 //! parameters vary from part to part, but can include:
835 //!         - \b EUSCI_B0_BASE
836 //!         - \b EUSCI_B1_BASE
837 //!         - \b EUSCI_B2_BASE
838 //!         - \b EUSCI_B3_BASE
839 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
840 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
841 //!  I2C mode.
842 //!
843 //!
844 //! This function is used by the Master module to initiate STOP
845 //!
846 //! Modified bits are UCTXSTP bit of UCBxCTL1.
847 //!
848 //! \return None.
849 //
850 //*****************************************************************************
851 extern void I2C_masterReceiveMultiByteStop(uint32_t moduleInstance);
852
853 //*****************************************************************************
854 //
855 //! Does single byte reception from the slave
856 //!
857 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
858 //! parameters vary from part to part, but can include:
859 //!         - \b EUSCI_B0_BASE
860 //!         - \b EUSCI_B1_BASE
861 //!         - \b EUSCI_B2_BASE
862 //!         - \b EUSCI_B3_BASE
863 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
864 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
865 //!  I2C mode.
866 //!
867 //! This function is used by the Master module to receive a single byte.
868 //! This function:
869 //! - Sends START and STOP
870 //! - Waits for data reception
871 //! - Receives one byte from the Slave
872 //!
873 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
874 //! \b UCBxIE
875 //!
876 //! \return The byte that has been received from the slave
877 //
878 //*****************************************************************************
879 extern uint8_t I2C_masterReceiveSingleByte(uint32_t moduleInstance);
880
881 //*****************************************************************************
882 //
883 //! Receives a byte that has been sent to the I2C Master Module.
884 //!
885 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
886 //! parameters vary from part to part, but can include:
887 //!         - \b EUSCI_B0_BASE
888 //!         - \b EUSCI_B1_BASE
889 //!         - \b EUSCI_B2_BASE
890 //!         - \b EUSCI_B3_BASE
891 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
892 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
893 //!  I2C mode.
894 //!
895 //!
896 //! This function reads a byte of data from the I2C receive data Register.
897 //!
898 //! \return Returns the byte received from by the I2C module, cast as an
899 //! uint8_t.
900 //
901 //*****************************************************************************
902 extern uint8_t I2C_masterReceiveSingle(uint32_t moduleInstance);
903
904 //*****************************************************************************
905 //
906 //! Returns the address of the RX Buffer of the I2C for the DMA module.
907 //!
908 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
909 //! parameters vary from part to part, but can include:
910 //!         - \b EUSCI_B0_BASE
911 //!         - \b EUSCI_B1_BASE
912 //!         - \b EUSCI_B2_BASE
913 //!         - \b EUSCI_B3_BASE
914 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
915 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
916 //!  I2C mode.
917 //!
918 //!
919 //! Returns the address of the I2C RX Buffer. This can be used in conjunction
920 //! with the DMA to store the received data directly to memory.
921 //!
922 //! \return NONE
923 //
924 //*****************************************************************************
925 extern uint32_t I2C_getReceiveBufferAddressForDMA(uint32_t moduleInstance);
926
927 //*****************************************************************************
928 //
929 //! Returns the address of the TX Buffer of the I2C for the DMA module.
930 //!
931 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
932 //! parameters vary from part to part, but can include:
933 //!         - \b EUSCI_B0_BASE
934 //!         - \b EUSCI_B1_BASE
935 //!         - \b EUSCI_B2_BASE
936 //!         - \b EUSCI_B3_BASE
937 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
938 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
939 //!  I2C mode.
940 //!
941 //!
942 //! Returns the address of the I2C TX Buffer. This can be used in conjunction
943 //! with the DMA to obtain transmitted data directly from memory.
944 //!
945 //! \return NONE
946 //
947 //*****************************************************************************
948 extern uint32_t I2C_getTransmitBufferAddressForDMA(uint32_t moduleInstance);
949
950 //*****************************************************************************
951 //
952 //! Indicates whether STOP got sent.
953 //!
954 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
955 //! parameters vary from part to part, but can include:
956 //!         - \b EUSCI_B0_BASE
957 //!         - \b EUSCI_B1_BASE
958 //!         - \b EUSCI_B2_BASE
959 //!         - \b EUSCI_B3_BASE
960 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
961 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
962 //!  I2C mode.
963 //!
964 //!
965 //! This function returns an indication of whether or not STOP got sent
966 //! This function checks the status of the bus via UCTXSTP bit in
967 //! UCBxCTL1 register.
968 //!
969 //! \return Returns EUSCI_B_I2C_STOP_SEND_COMPLETE if the I2C Master
970 //!         finished sending STOP; otherwise, returns EUSCI_B_I2C_SENDING_STOP.
971 //
972 //*****************************************************************************
973 extern uint8_t I2C_masterIsStopSent(uint32_t moduleInstance);
974
975 //*****************************************************************************
976 //
977 //! Indicates whether Start got sent.
978 //!
979 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
980 //! parameters vary from part to part, but can include:
981 //!         - \b EUSCI_B0_BASE
982 //!         - \b EUSCI_B1_BASE
983 //!         - \b EUSCI_B2_BASE
984 //!         - \b EUSCI_B3_BASE
985 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
986 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
987 //!  I2C mode.
988 //!
989 //!
990 //! This function returns an indication of whether or not Start got sent
991 //! This function checks the status of the bus via UCTXSTT bit in
992 //! UCBxCTL1 register.
993 //!
994 //! \return Returns true if the START has been sent, false if it is sending
995 //
996 //*****************************************************************************
997 extern bool I2C_masterIsStartSent(uint32_t moduleInstance);
998
999 //*****************************************************************************
1000 //
1001 //! This function is used by the Master module to initiate START
1002 //!
1003 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1004 //! parameters vary from part to part, but can include:
1005 //!         - \b EUSCI_B0_BASE
1006 //!         - \b EUSCI_B1_BASE
1007 //!         - \b EUSCI_B2_BASE
1008 //!         - \b EUSCI_B3_BASE
1009 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1010 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1011 //!  I2C mode.
1012 //!
1013 //!
1014 //! This function is used by the Master module to initiate STOP
1015 //!
1016 //! Modified bits are UCTXSTT bit of UCBxCTLW0.
1017 //!
1018 //! \return None.
1019 //
1020 //*****************************************************************************
1021 extern void I2C_masterSendStart(uint32_t moduleInstance);
1022
1023 //*****************************************************************************
1024 //
1025 //! Enables Multi Master Mode
1026 //!
1027 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1028 //! parameters vary from part to part, but can include:
1029 //!         - \b EUSCI_B0_BASE
1030 //!         - \b EUSCI_B1_BASE
1031 //!         - \b EUSCI_B2_BASE
1032 //!         - \b EUSCI_B3_BASE
1033 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1034 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1035 //!  I2C mode.
1036 //!
1037 //!
1038 //! At the end of this function, the I2C module is still disabled till
1039 //! I2C_enableModule is invoked
1040 //!
1041 //! Modified bits are \b UCSWRST of \b OFS_UCBxCTLW0, \b UCMM bit of
1042 //! \b UCBxCTLW0
1043 //!
1044 //! \return None.
1045 //
1046 //*****************************************************************************
1047 extern void I2C_enableMultiMasterMode(uint32_t moduleInstance);
1048
1049 //*****************************************************************************
1050 //
1051 //! Disables Multi Master Mode
1052 //!
1053 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1054 //! parameters vary from part to part, but can include:
1055 //!         - \b EUSCI_B0_BASE
1056 //!         - \b EUSCI_B1_BASE
1057 //!         - \b EUSCI_B2_BASE
1058 //!         - \b EUSCI_B3_BASE
1059 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1060 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1061 //!  I2C mode.
1062 //!
1063 //!
1064 //! At the end of this function, the I2C module is still disabled till
1065 //! I2C_enableModule is invoked
1066 //!
1067 //! Modified bits are \b UCSWRST of \b OFS_UCBxCTLW0, \b UCMM bit of
1068 //! \b UCBxCTLW0
1069 //!
1070 //! \return None.
1071 //
1072 //*****************************************************************************
1073 extern void I2C_disableMultiMasterMode(uint32_t moduleInstance);
1074
1075 //*****************************************************************************
1076 //
1077 //! Enables individual I2C interrupt sources.
1078 //!
1079 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1080 //! parameters vary from part to part, but can include:
1081 //!         - \b EUSCI_B0_BASE
1082 //!         - \b EUSCI_B1_BASE
1083 //!         - \b EUSCI_B2_BASE
1084 //!         - \b EUSCI_B3_BASE
1085 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1086 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1087 //!  I2C mode.
1088 //!
1089 //! \param mask is the bit mask of the interrupt sources to
1090 //!                          be enabled.
1091 //!
1092 //! Enables the indicated I2C interrupt sources.  Only the sources that
1093 //! are enabled can be reflected to the processor interrupt; disabled sources
1094 //! have no effect on the processor.
1095 //!
1096 //! The mask parameter is the logical OR of any of the following:
1097 //!
1098 //! - \b EUSCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
1099 //! - \b EUSCI_B_I2C_START_INTERRUPT - START condition interrupt
1100 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
1101 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
1102 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
1103 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
1104 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT0 - Receive interrupt0
1105 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT1 - Receive interrupt1
1106 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT2 - Receive interrupt2
1107 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT3 - Receive interrupt3
1108 //! - \b EUSCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
1109 //! - \b EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
1110 //! - \b EUSCI_B_I2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
1111 //! - \b EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt
1112 //!                                                 enable
1113 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1114 //!
1115 //! Modified registers are UCBxIFG and OFS_UCBxIE.
1116 //!
1117 //! \return None.
1118 //
1119 //*****************************************************************************
1120 extern void I2C_enableInterrupt(uint32_t moduleInstance, uint_fast16_t mask);
1121
1122 //*****************************************************************************
1123 //
1124 //! Disables individual I2C interrupt sources.
1125 //!
1126 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1127 //! parameters vary from part to part, but can include:
1128 //!         - \b EUSCI_B0_BASE
1129 //!         - \b EUSCI_B1_BASE
1130 //!         - \b EUSCI_B2_BASE
1131 //!         - \b EUSCI_B3_BASE
1132 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1133 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1134 //!  I2C mode.
1135 //!
1136 //! \param mask is the bit mask of the interrupt sources to be
1137 //! disabled.
1138 //!
1139 //! Disables the indicated I2C interrupt sources.  Only the sources that
1140 //! are enabled can be reflected to the processor interrupt; disabled sources
1141 //! have no effect on the processor.
1142 //!
1143 //! The mask parameter is the logical OR of any of the following:
1144 //!
1145 //! - \b EUSCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
1146 //! - \b EUSCI_B_I2C_START_INTERRUPT - START condition interrupt
1147 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
1148 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
1149 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
1150 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
1151 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT0 - Receive interrupt0
1152 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT1 - Receive interrupt1
1153 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT2 - Receive interrupt2
1154 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT3 - Receive interrupt3
1155 //! - \b EUSCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
1156 //! - \b EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
1157 //! - \b EUSCI_B_I2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
1158 //! - \b EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt
1159 //!                                                enable
1160 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1161 //!
1162 //! Modified register is \b UCBxIE.
1163 //!
1164 //! \return None.
1165 //
1166 //*****************************************************************************
1167 extern void I2C_disableInterrupt(uint32_t moduleInstance, uint_fast16_t mask);
1168
1169 //*****************************************************************************
1170 //
1171 //! Clears I2C interrupt sources.
1172 //!
1173 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1174 //! parameters vary from part to part, but can include:
1175 //!         - \b EUSCI_B0_BASE
1176 //!         - \b EUSCI_B1_BASE
1177 //!         - \b EUSCI_B2_BASE
1178 //!         - \b EUSCI_B3_BASE
1179 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1180 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1181 //!  I2C mode.
1182 //!
1183 //! \param mask is a bit mask of the interrupt sources to be cleared.
1184 //!
1185 //! The I2C interrupt source is cleared, so that it no longer asserts.
1186 //! The highest interrupt flag is automatically cleared when an interrupt vector
1187 //! generator is used.
1188 //!
1189 //! The mask parameter has the same definition as the mask
1190 //! parameter to I2C_enableInterrupt().
1191 //!
1192 //! Modified register is \b UCBxIFG.
1193 //!
1194 //! \return None.
1195 //
1196 //*****************************************************************************
1197 extern void I2C_clearInterruptFlag(uint32_t moduleInstance, uint_fast16_t mask);
1198
1199 //*****************************************************************************
1200 //
1201 //! Gets the current I2C interrupt status.
1202 //!
1203 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1204 //! parameters vary from part to part, but can include:
1205 //!         - \b EUSCI_B0_BASE
1206 //!         - \b EUSCI_B1_BASE
1207 //!         - \b EUSCI_B2_BASE
1208 //!         - \b EUSCI_B3_BASE
1209 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1210 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1211 //!  I2C mode.
1212 //! \param mask is the masked interrupt flag status to be returned.
1213 //!        Mask value is the logical OR of any of the following:
1214 //!        - \b EUSCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
1215 //!        - \b EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost
1216 //!           interrupt
1217 //!        - \b EUSCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
1218 //!        - \b EUSCI_B_I2C_START_INTERRUPT - START condition interrupt
1219 //!        - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
1220 //!        - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
1221 //!        - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
1222 //!        - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
1223 //!        - \b EUSCI_B_I2C_RECEIVE_INTERRUPT0 - Receive interrupt0
1224 //!        - \b EUSCI_B_I2C_RECEIVE_INTERRUPT1 - Receive interrupt1
1225 //!        - \b EUSCI_B_I2C_RECEIVE_INTERRUPT2 - Receive interrupt2
1226 //!        - \b EUSCI_B_I2C_RECEIVE_INTERRUPT3 - Receive interrupt3
1227 //!        - \b EUSCI_B_I2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt
1228 //!        - \b EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout
1229 //!           interrupt enable
1230 //!        - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt
1231 //!           enable
1232 //!
1233 //! \return the masked status of the interrupt flag
1234 //! - \b EUSCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
1235 //! - \b EUSCI_B_I2C_START_INTERRUPT - START condition interrupt
1236 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
1237 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
1238 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
1239 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
1240 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT0 - Receive interrupt0
1241 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT1 - Receive interrupt1
1242 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT2 - Receive interrupt2
1243 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT3 - Receive interrupt3
1244 //! - \b EUSCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
1245 //! - \b EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
1246 //! - \b EUSCI_B_I2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
1247 //! - \b EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt
1248 //!                                                enable
1249 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1250 //
1251 //*****************************************************************************
1252 extern uint_fast16_t I2C_getInterruptStatus(uint32_t moduleInstance, uint16_t mask);
1253
1254 //*****************************************************************************
1255 //
1256 //! Gets the current I2C interrupt status masked with the enabled interrupts.
1257 //! This function is useful to call in ISRs to get a list of pending interrupts
1258 //! that are actually enabled and could have caused the ISR.
1259 //!
1260 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1261 //! parameters vary from part to part, but can include:
1262 //!         - \b EUSCI_B0_BASE
1263 //!         - \b EUSCI_B1_BASE
1264 //!         - \b EUSCI_B2_BASE
1265 //!         - \b EUSCI_B3_BASE
1266 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1267 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1268 //!  I2C mode.
1269 //!
1270 //! \return the masked status of the interrupt flag
1271 //! - \b EUSCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
1272 //! - \b EUSCI_B_I2C_START_INTERRUPT - START condition interrupt
1273 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
1274 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
1275 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
1276 //! - \b EUSCI_B_I2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
1277 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT0 - Receive interrupt0
1278 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT1 - Receive interrupt1
1279 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT2 - Receive interrupt2
1280 //! - \b EUSCI_B_I2C_RECEIVE_INTERRUPT3 - Receive interrupt3
1281 //! - \b EUSCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
1282 //! - \b EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
1283 //! - \b EUSCI_B_I2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
1284 //! - \b EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt
1285 //!                                                enable
1286 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1287 //
1288 //*****************************************************************************
1289 extern uint_fast16_t I2C_getEnabledInterruptStatus(uint32_t moduleInstance);
1290
1291 //*****************************************************************************
1292 //
1293 //! Registers an interrupt handler for I2C interrupts.
1294 //!
1295 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1296 //! parameters vary from part to part, but can include:
1297 //!         - \b EUSCI_B0_BASE
1298 //!         - \b EUSCI_B1_BASE
1299 //!         - \b EUSCI_B2_BASE
1300 //!         - \b EUSCI_B3_BASE
1301 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1302 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1303 //!  I2C mode.
1304 //!
1305 //! \param intHandler is a pointer to the function to be called when the
1306 //! timer capture compare interrupt occurs.
1307 //!
1308 //! This function registers the handler to be called when an I2C
1309 //! interrupt occurs. This function enables the global interrupt in the
1310 //! interrupt controller; specific I2C interrupts must be enabled
1311 //! via I2C_enableInterrupt().  It is the interrupt handler's responsibility to
1312 //! clear the interrupt source via I2C_clearInterruptFlag().
1313 //!
1314 //! \sa Interrupt_registerInterrupt() for important information about
1315 //! registering interrupt handlers.
1316 //!
1317 //! \return None.
1318 //
1319 //*****************************************************************************
1320 extern void I2C_registerInterrupt(uint32_t moduleInstance,
1321         void (*intHandler)(void));
1322
1323 //*****************************************************************************
1324 //
1325 //! Unregisters the interrupt handler for the timer
1326 //!
1327 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1328 //! parameters vary from part to part, but can include:
1329 //!         - \b EUSCI_B0_BASE
1330 //!         - \b EUSCI_B1_BASE
1331 //!         - \b EUSCI_B2_BASE
1332 //!         - \b EUSCI_B3_BASE
1333 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1334 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1335 //!  I2C mode.
1336 //!
1337 //! This function unregisters the handler to be called when timer
1338 //! interrupt occurs.  This function also masks off the interrupt in the
1339 //! interrupt controller so that the interrupt handler no longer is called.
1340 //!
1341 //! \sa Interrupt_registerInterrupt() for important information about
1342 //! registering interrupt handlers.
1343 //!
1344 //! \return None.
1345 //
1346 //*****************************************************************************
1347 extern void I2C_unregisterInterrupt(uint32_t moduleInstance);
1348
1349
1350 //*****************************************************************************
1351 //
1352 //! This function is used by the slave to send a NAK out over the I2C line
1353 //!
1354 //! \param moduleInstance is the instance of the eUSCI B (I2C) module. Valid
1355 //! parameters vary from part to part, but can include:
1356 //!         - \b EUSCI_B0_BASE
1357 //!         - \b EUSCI_B1_BASE
1358 //!         - \b EUSCI_B2_BASE
1359 //!         - \b EUSCI_B3_BASE
1360 //!  <br>It is important to note that for eUSCI modules, only "B" modules such as
1361 //!  EUSCI_B0 can be used. "A" modules such as EUSCI_A0 do not support the
1362 //!  I2C mode.
1363 //!
1364 //! \return None.
1365 //
1366 //*****************************************************************************
1367 extern void I2C_slaveSendNAK(uint32_t moduleInstance);
1368
1369 /* Backwards Compatibility Layer */
1370 #define EUSCI_B_I2C_slaveInit I2C_initSlave
1371 #define EUSCI_B_I2C_enable I2C_enableModule
1372 #define EUSCI_B_I2C_disable I2C_disableModule
1373 #define EUSCI_B_I2C_setSlaveAddress I2C_setSlaveAddress
1374 #define EUSCI_B_I2C_setMode I2C_setMode
1375 #define EUSCI_B_I2C_getMode I2C_getMode
1376 #define EUSCI_B_I2C_slaveDataPut I2C_slavePutData
1377 #define EUSCI_B_I2C_slaveDataGet I2C_slaveGetData
1378 #define EUSCI_B_I2C_isBusBusy I2C_isBusBusy
1379 #define EUSCI_B_I2C_masterIsStopSent I2C_masterIsStopSent
1380 #define EUSCI_B_I2C_masterIsStartSent I2C_masterIsStartSent
1381 #define EUSCI_B_I2C_enableInterrupt I2C_enableInterrupt
1382 #define EUSCI_B_I2C_disableInterrupt I2C_disableInterrupt
1383 #define EUSCI_B_I2C_clearInterruptFlag I2C_clearInterruptFlag
1384 #define EUSCI_B_I2C_getInterruptStatus  I2C_getEnabledInterruptStatus
1385 #define EUSCI_B_I2C_masterSendSingleByte I2C_masterSendSingleByte
1386 #define EUSCI_B_I2C_masterReceiveSingleByte I2C_masterReceiveSingleByte
1387 #define EUSCI_B_I2C_masterSendSingleByteWithTimeout I2C_masterSendSingleByteWithTimeout
1388 #define EUSCI_B_I2C_masterMultiByteSendStart I2C_masterSendMultiByteStart
1389 #define EUSCI_B_I2C_masterMultiByteSendStartWithTimeout I2C_masterSendMultiByteStartWithTimeout
1390 #define EUSCI_B_I2C_masterMultiByteSendNext I2C_masterSendMultiByteNext
1391 #define EUSCI_B_I2C_masterMultiByteSendNextWithTimeout I2C_masterSendMultiByteNextWithTimeout
1392 #define EUSCI_B_I2C_masterMultiByteSendFinish I2C_masterSendMultiByteFinish
1393 #define EUSCI_B_I2C_masterMultiByteSendFinishWithTimeout I2C_masterSendMultiByteFinishWithTimeout
1394 #define EUSCI_B_I2C_masterSendStart I2C_masterSendStart
1395 #define EUSCI_B_I2C_masterMultiByteSendStop I2C_masterSendMultiByteStop
1396 #define EUSCI_B_I2C_masterMultiByteSendStopWithTimeout I2C_masterSendMultiByteStopWithTimeout
1397 #define EUSCI_B_I2C_masterReceiveStart I2C_masterReceiveStart
1398 #define EUSCI_B_I2C_masterMultiByteReceiveNext I2C_masterReceiveMultiByteNext
1399 #define EUSCI_B_I2C_masterMultiByteReceiveFinish I2C_masterReceiveMultiByteFinish
1400 #define EUSCI_B_I2C_masterMultiByteReceiveFinishWithTimeout I2C_masterReceiveMultiByteFinishWithTimeout
1401 #define EUSCI_B_I2C_masterMultiByteReceiveStop I2C_masterReceiveMultiByteStop
1402 #define EUSCI_B_I2C_enableMultiMasterMode I2C_enableMultiMasterMode
1403 #define EUSCI_B_I2C_disableMultiMasterMode I2C_disableMultiMasterMode
1404 #define EUSCI_B_I2C_masterSingleReceive I2C_masterReceiveSingle
1405 #define EUSCI_B_I2C_getReceiveBufferAddressForDMA I2C_getReceiveBufferAddressForDMA
1406 #define EUSCI_B_I2C_getTransmitBufferAddressForDMA I2C_getTransmitBufferAddressForDMA
1407
1408
1409 //*****************************************************************************
1410 //
1411 // Mark the end of the C bindings section for C++ compilers.
1412 //
1413 //*****************************************************************************
1414 #ifdef __cplusplus
1415 }
1416 #endif
1417
1418 //*****************************************************************************
1419 //
1420 // Close the Doxygen group.
1421 //! @}
1422 //
1423 //*****************************************************************************
1424
1425 #endif /* I2C_H_ */
1426