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