2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
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.
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.
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.
40 //*****************************************************************************
42 //! \addtogroup i2c_api
45 //*****************************************************************************
47 //*****************************************************************************
49 // If building with a C++ compiler, make all of the definitions in this header
52 //*****************************************************************************
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
67 #define EUSCI_B_I2C_SET_DATA_RATE_400KBPS 400000
68 #define EUSCI_B_I2C_SET_DATA_RATE_100KBPS 100000
70 #define EUSCI_B_I2C_CLOCKSOURCE_ACLK UCSSEL__ACLK
71 #define EUSCI_B_I2C_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
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
78 #define EUSCI_B_I2C_OWN_ADDRESS_DISABLE 0x00
79 #define EUSCI_B_I2C_OWN_ADDRESS_ENABLE UCOAEN
81 #define EUSCI_B_I2C_TRANSMIT_MODE UCTR
82 #define EUSCI_B_I2C_RECEIVE_MODE 0x00
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
100 #define EUSCI_B_I2C_BUS_BUSY UCBBUSY
101 #define EUSCI_B_I2C_BUS_NOT_BUSY 0x00
103 #define EUSCI_B_I2C_STOP_SEND_COMPLETE 0x00
104 #define EUSCI_B_I2C_SENDING_STOP UCTXSTP
106 #define EUSCI_B_I2C_START_SEND_COMPLETE 0x00
107 #define EUSCI_B_I2C_SENDING_START UCTXSTT
109 //*****************************************************************************
111 //! \typedef eUSCI_I2C_MasterConfig
112 //! \brief Type definition for \link _eUSCI_I2C_MasterConfig \endlink structure
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.
118 //*****************************************************************************
121 uint_fast8_t selectClockSource;
124 uint_fast8_t byteCounterThreshold;
125 uint_fast8_t autoSTOPGeneration;
126 } eUSCI_I2C_MasterConfig;
129 //*****************************************************************************
131 //! Initializes the I2C Master block.
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
142 //! \param config Configuration structure for I2C master mode
145 //! <b>Configuration options for \link eUSCI_I2C_MasterConfig \endlink structure.</b>
148 //! \param selectClockSource is the clock source.
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.
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.
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
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
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.
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
180 //*****************************************************************************
181 extern void I2C_initMaster(uint32_t moduleInstance,
182 const eUSCI_I2C_MasterConfig *config);
184 //*****************************************************************************
186 //! Initializes the I2C Slave block.
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
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
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.
215 //! The parameter slaveAddress is the value that will be compared against the
216 //! slave address sent by an I2C master.
218 //! Modified bits are \b UCMODE_3, \b UCSYNC of \b UCBxCTL0 register
219 //! \b UCSWRST of \b UCBxCTL1 register
220 //! \b UCBxI2COA register
224 //*****************************************************************************
225 extern void I2C_initSlave(uint32_t moduleInstance, uint_fast16_t slaveAddress,
226 uint_fast8_t slaveAddressOffset, uint32_t slaveOwnAddressEnable);
228 //*****************************************************************************
230 //! Enables the I2C block.
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
242 //! This will enable operation of the I2C block.
243 //! Modified bits are \b UCSWRST of \b UCBxCTL1 register.
247 //*****************************************************************************
248 extern void I2C_enableModule(uint32_t moduleInstance);
250 //*****************************************************************************
252 //! Disables the I2C block.
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
264 //! This will disable operation of the I2C block.
265 //! Modified bits are \b UCSWRST of \b UCBxCTL1 register.
269 //*****************************************************************************
270 extern void I2C_disableModule(uint32_t moduleInstance);
272 //*****************************************************************************
274 //! Sets the address that the I2C Master will place on the bus.
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
286 //! \param slaveAddress 7-bit slave address
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
294 //*****************************************************************************
295 extern void I2C_setSlaveAddress(uint32_t moduleInstance,
296 uint_fast16_t slaveAddress);
298 //*****************************************************************************
300 //! Sets the mode of the I2C device
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
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]
316 //! Modified bits are \b UCTR of \b UCBxCTL1 register
320 //*****************************************************************************
321 extern void I2C_setMode(uint32_t moduleInstance, uint_fast8_t mode);
323 //*****************************************************************************
325 //! \brief Gets the mode of the I2C device
327 //! Current I2C transmit/receive mode.
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
339 //! Modified bits are \b UCTR of \b UCBxCTL1 register.
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
347 //*****************************************************************************
348 extern uint_fast8_t I2C_getMode(uint32_t moduleInstance);
350 //*****************************************************************************
352 //! Transmits a byte from the I2C Module.
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
364 //! \param transmitData data to be transmitted from the I2C module
366 //! This function will place the supplied data into I2C transmit data register
367 //! to start transmission
368 //! Modified register is \b UCBxTXBUF register
372 //*****************************************************************************
373 extern void I2C_slavePutData(uint32_t moduleInstance, uint8_t transmitData);
375 //*****************************************************************************
377 //! Receives a byte that has been sent to the I2C Module.
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
389 //! This function reads a byte of data from the I2C receive data Register.
391 //! \return Returns the byte received from by the I2C module, cast as an
393 //! Modified bit is \b UCBxRXBUF register
395 //*****************************************************************************
396 extern uint8_t I2C_slaveGetData(uint32_t moduleInstance);
398 //*****************************************************************************
400 //! Indicates whether or not the I2C bus is busy.
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
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.
417 //! \return Returns EUSCI_B_I2C_BUS_BUSY if the I2C Master is busy; otherwise,
418 //! returns EUSCI_B_I2C_BUS_NOT_BUSY.
420 //*****************************************************************************
421 extern uint8_t I2C_isBusBusy(uint32_t moduleInstance);
423 //*****************************************************************************
425 //! Does single byte transmission from Master to Slave
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
437 //! \param txData is the data byte to be transmitted
439 //! This function is used by the Master module to send a single byte.
442 //! - Transmits the byte to the Slave
445 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
450 //*****************************************************************************
451 extern void I2C_masterSendSingleByte(uint32_t moduleInstance, uint8_t txData);
453 //*****************************************************************************
455 //! Does single byte transmission from Master to Slave with timeout
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
467 //! \param txData is the data byte to be transmitted
468 //! \param timeout is the amount of time to wait until giving up
470 //! This function is used by the Master module to send a single byte.
473 //! - Transmits the byte to the Slave
476 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
479 //! \return 0x01 or 0x00URE of the transmission process.
481 //*****************************************************************************
482 extern bool I2C_masterSendSingleByteWithTimeout(uint32_t moduleInstance,
483 uint8_t txData, uint32_t timeout);
485 //*****************************************************************************
487 //! Starts multi-byte transmission from Master to Slave
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
499 //! \param txData is the first data byte to be transmitted
501 //! This function is used by the Master module to send a single byte.
504 //! - Transmits the first data byte of a multi-byte transmission to the Slave
506 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
511 //*****************************************************************************
512 extern void I2C_masterSendMultiByteStart(uint32_t moduleInstance,
515 //*****************************************************************************
517 //! Starts multi-byte transmission from Master to Slave with timeout
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
529 //! \param txData is the first data byte to be transmitted
530 //! \param timeout is the amount of time to wait until giving up
532 //! This function is used by the Master module to send a single byte.
535 //! - Transmits the first data byte of a multi-byte transmission to the Slave
537 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
540 //! \return 0x01 or 0x00URE of the transmission process.
542 //*****************************************************************************
543 extern bool I2C_masterSendMultiByteStartWithTimeout(uint32_t moduleInstance,
544 uint8_t txData, uint32_t timeout);
546 //*****************************************************************************
548 //! Continues multi-byte transmission from Master to Slave
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
560 //! \param txData is the next data byte to be transmitted
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
566 //! Modified registers are \b UCBxTXBUF
570 //*****************************************************************************
571 extern void I2C_masterSendMultiByteNext(uint32_t moduleInstance,
574 //*****************************************************************************
576 //! Continues multi-byte transmission from Master to Slave with timeout
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
588 //! \param txData is the next data byte to be transmitted
590 //! \param timeout is the amount of time to wait until giving up
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
596 //! Modified registers are \b UCBxTXBUF
598 //! \return 0x01 or 0x00URE of the transmission process.
600 //*****************************************************************************
601 extern bool I2C_masterSendMultiByteNextWithTimeout(uint32_t moduleInstance,
602 uint8_t txData, uint32_t timeout);
604 //*****************************************************************************
606 //! Finishes multi-byte transmission from Master to Slave
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
618 //! \param txData is the last data byte to be transmitted in a multi-byte
621 //! This function is used by the Master module to send the last byte and STOP.
623 //! - Transmits the last data byte of a multi-byte transmission to the Slave
626 //! Modified registers are \b UCBxTXBUF and \b UCBxCTL1.
630 //*****************************************************************************
631 extern void I2C_masterSendMultiByteFinish(uint32_t moduleInstance,
634 //*****************************************************************************
636 //! Finishes multi-byte transmission from Master to Slave with timeout
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
648 //! \param txData is the last data byte to be transmitted in a multi-byte
650 //! \param timeout is the amount of time to wait until giving up
652 //! This function is used by the Master module to send the last byte and STOP.
654 //! - Transmits the last data byte of a multi-byte transmission to the Slave
657 //! Modified registers are \b UCBxTXBUF and \b UCBxCTL1.
659 //! \return 0x01 or 0x00URE of the transmission process.
661 //*****************************************************************************
662 extern bool I2C_masterSendMultiByteFinishWithTimeout(uint32_t moduleInstance,
663 uint8_t txData, uint32_t timeout);
665 //*****************************************************************************
667 //! Send STOP byte at the end of a multi-byte transmission from Master to Slave
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
680 //! This function is used by the Master module send STOP at the end of a
681 //! multi-byte transmission
684 //! - Send a STOP after current transmission is complete
686 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
689 //*****************************************************************************
690 extern void I2C_masterSendMultiByteStop(uint32_t moduleInstance);
692 //*****************************************************************************
694 //! Send STOP byte at the end of a multi-byte transmission from Master to Slave
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
707 //! \param timeout is the amount of time to wait until giving up
709 //! This function is used by the Master module send STOP at the end of a
710 //! multi-byte transmission
713 //! - Send a STOP after current transmission is complete
715 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
716 //! \return 0x01 or 0x00URE of the transmission process.
718 //*****************************************************************************
719 extern bool I2C_masterSendMultiByteStopWithTimeout(uint32_t moduleInstance,
722 //*****************************************************************************
724 //! Starts reception at the Master end
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
737 //! This function is used by the Master module initiate reception of a single
738 //! byte. This function
741 //! Modified bits are \b UCTXSTT bit of \b UCBxCTL1.
744 //*****************************************************************************
745 extern void I2C_masterReceiveStart(uint32_t moduleInstance);
747 //*****************************************************************************
749 //! Starts multi-byte reception at the Master end one byte at a time
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
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
766 //! Modified register is \b UCBxRXBUF.
767 //! \return Received byte at Master end.
769 //*****************************************************************************
770 extern uint8_t I2C_masterReceiveMultiByteNext(uint32_t moduleInstance);
772 //*****************************************************************************
774 //! Finishes multi-byte reception at the Master end
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
787 //! This function is used by the Master module to initiate completion of a
788 //! multi-byte reception
790 //! - Receives the current byte and initiates the STOP from Master to Slave
792 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
794 //! \return Received byte at Master end.
796 //*****************************************************************************
797 extern uint8_t I2C_masterReceiveMultiByteFinish(uint32_t moduleInstance);
799 //*****************************************************************************
801 //! Finishes multi-byte reception at the Master end with timeout
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
813 //! \param txData is a pointer to the location to store the received byte at
815 //! \param timeout is the amount of time to wait until giving up
817 //! This function is used by the Master module to initiate completion of a
818 //! multi-byte reception
820 //! - Receives the current byte and initiates the STOP from Master to Slave
822 //! Modified bits are \b UCTXSTP bit of \b UCBxCTL1.
824 //! \return 0x01 or 0x00URE of the transmission process.
826 //*****************************************************************************
827 extern bool I2C_masterReceiveMultiByteFinishWithTimeout(uint32_t moduleInstance,
828 uint8_t *txData, uint32_t timeout);
830 //*****************************************************************************
832 //! Sends the STOP at the end of a multi-byte reception at the Master end
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
845 //! This function is used by the Master module to initiate STOP
847 //! Modified bits are UCTXSTP bit of UCBxCTL1.
851 //*****************************************************************************
852 extern void I2C_masterReceiveMultiByteStop(uint32_t moduleInstance);
854 //*****************************************************************************
856 //! Does single byte reception from the slave
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
868 //! This function is used by the Master module to receive a single byte.
870 //! - Sends START and STOP
871 //! - Waits for data reception
872 //! - Receives one byte from the Slave
874 //! Modified registers are \b UCBxIE, \b UCBxCTL1, \b UCBxIFG, \b UCBxTXBUF,
877 //! \return The byte that has been received from the slave
879 //*****************************************************************************
880 extern uint8_t I2C_masterReceiveSingleByte(uint32_t moduleInstance);
882 //*****************************************************************************
884 //! Receives a byte that has been sent to the I2C Master Module.
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
897 //! This function reads a byte of data from the I2C receive data Register.
899 //! \return Returns the byte received from by the I2C module, cast as an
902 //*****************************************************************************
903 extern uint8_t I2C_masterReceiveSingle(uint32_t moduleInstance);
905 //*****************************************************************************
907 //! Returns the address of the RX Buffer of the I2C for the DMA module.
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
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.
925 //*****************************************************************************
926 extern uint32_t I2C_getReceiveBufferAddressForDMA(uint32_t moduleInstance);
928 //*****************************************************************************
930 //! Returns the address of the TX Buffer of the I2C for the DMA module.
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
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.
948 //*****************************************************************************
949 extern uint32_t I2C_getTransmitBufferAddressForDMA(uint32_t moduleInstance);
951 //*****************************************************************************
953 //! Indicates whether STOP got sent.
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
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.
970 //! \return Returns EUSCI_B_I2C_STOP_SEND_COMPLETE if the I2C Master
971 //! finished sending STOP; otherwise, returns EUSCI_B_I2C_SENDING_STOP.
973 //*****************************************************************************
974 extern uint8_t I2C_masterIsStopSent(uint32_t moduleInstance);
976 //*****************************************************************************
978 //! Indicates whether Start got sent.
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
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.
995 //! \return Returns true if the START has been sent, false if it is sending
997 //*****************************************************************************
998 extern bool I2C_masterIsStartSent(uint32_t moduleInstance);
1000 //*****************************************************************************
1002 //! This function is used by the Master module to initiate START
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
1015 //! This function is used by the Master module to initiate STOP
1017 //! Modified bits are UCTXSTT bit of UCBxCTLW0.
1021 //*****************************************************************************
1022 extern void I2C_masterSendStart(uint32_t moduleInstance);
1024 //*****************************************************************************
1026 //! Enables Multi Master Mode
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
1039 //! At the end of this function, the I2C module is still disabled till
1040 //! I2C_enableModule is invoked
1042 //! Modified bits are \b UCSWRST of \b OFS_UCBxCTLW0, \b UCMM bit of
1047 //*****************************************************************************
1048 extern void I2C_enableMultiMasterMode(uint32_t moduleInstance);
1050 //*****************************************************************************
1052 //! Disables Multi Master Mode
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
1065 //! At the end of this function, the I2C module is still disabled till
1066 //! I2C_enableModule is invoked
1068 //! Modified bits are \b UCSWRST of \b OFS_UCBxCTLW0, \b UCMM bit of
1073 //*****************************************************************************
1074 extern void I2C_disableMultiMasterMode(uint32_t moduleInstance);
1076 //*****************************************************************************
1078 //! Enables individual I2C interrupt sources.
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
1090 //! \param mask is the bit mask of the interrupt sources to
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.
1097 //! The mask parameter is the logical OR of any of the following:
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
1114 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1116 //! Modified registers are UCBxIFG and OFS_UCBxIE.
1120 //*****************************************************************************
1121 extern void I2C_enableInterrupt(uint32_t moduleInstance, uint_fast16_t mask);
1123 //*****************************************************************************
1125 //! Disables individual I2C interrupt sources.
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
1137 //! \param mask is the bit mask of the interrupt sources to be
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.
1144 //! The mask parameter is the logical OR of any of the following:
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
1161 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1163 //! Modified register is \b UCBxIE.
1167 //*****************************************************************************
1168 extern void I2C_disableInterrupt(uint32_t moduleInstance, uint_fast16_t mask);
1170 //*****************************************************************************
1172 //! Clears I2C interrupt sources.
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
1184 //! \param mask is a bit mask of the interrupt sources to be cleared.
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.
1190 //! The mask parameter has the same definition as the mask
1191 //! parameter to I2C_enableInterrupt().
1193 //! Modified register is \b UCBxIFG.
1197 //*****************************************************************************
1198 extern void I2C_clearInterruptFlag(uint32_t moduleInstance, uint_fast16_t mask);
1200 //*****************************************************************************
1202 //! Gets the current I2C interrupt status.
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
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
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
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
1250 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1252 //*****************************************************************************
1253 uint_fast16_t I2C_getInterruptStatus(uint32_t moduleInstance, uint16_t mask);
1255 //*****************************************************************************
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.
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
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
1287 //! - \b EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable
1289 //*****************************************************************************
1290 extern uint_fast16_t I2C_getEnabledInterruptStatus(uint32_t moduleInstance);
1292 //*****************************************************************************
1294 //! Registers an interrupt handler for I2C interrupts.
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
1306 //! \param intHandler is a pointer to the function to be called when the
1307 //! timer capture compare interrupt occurs.
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().
1315 //! \sa Interrupt_registerInterrupt() for important information about
1316 //! registering interrupt handlers.
1320 //*****************************************************************************
1321 extern void I2C_registerInterrupt(uint32_t moduleInstance,
1322 void (*intHandler)(void));
1324 //*****************************************************************************
1326 //! Unregisters the interrupt handler for the timer
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
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.
1342 //! \sa Interrupt_registerInterrupt() for important information about
1343 //! registering interrupt handlers.
1347 //*****************************************************************************
1348 extern void I2C_unregisterInterrupt(uint32_t moduleInstance);
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
1390 //*****************************************************************************
1392 // Mark the end of the C bindings section for C++ compilers.
1394 //*****************************************************************************
1399 //*****************************************************************************
1401 // Close the Doxygen group.
1404 //*****************************************************************************