MSP430 DriverLib for MSP430F5xx_6xx Devices  2.91.13.01
usci_b_i2c.h
1 //*****************************************************************************
2 //
3 // usci_b_i2c.h - Driver for the USCI_B_I2C Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_USCI_B_I2C_H__
8 #define __MSP430WARE_USCI_B_I2C_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_USCI_Bx__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
28 //! \brief Used in the USCI_B_I2C_initMaster() function as the param parameter.
29 //
30 //*****************************************************************************
32  //! Is the clocksource.
33  //! \n Valid values are:
34  //! - \b USCI_B_I2C_CLOCKSOURCE_ACLK
35  //! - \b USCI_B_I2C_CLOCKSOURCE_SMCLK
37  //! Is the rate of the clock supplied to the I2C module.
38  uint32_t i2cClk;
39  //! Set up for selecting data transfer rate.
40  //! \n Valid values are:
41  //! - \b USCI_B_I2C_SET_DATA_RATE_400KBPS
42  //! - \b USCI_B_I2C_SET_DATA_RATE_100KBPS
43  uint32_t dataRate;
45 
46 
47 //*****************************************************************************
48 //
49 // The following are values that can be passed to the param parameter for
50 // functions: USCI_B_I2C_initMaster().
51 //
52 //*****************************************************************************
53 #define USCI_B_I2C_CLOCKSOURCE_ACLK UCSSEL__ACLK
54 #define USCI_B_I2C_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
55 
56 //*****************************************************************************
57 //
58 // The following are values that can be passed to the param parameter for
59 // functions: USCI_B_I2C_initMaster().
60 //
61 //*****************************************************************************
62 #define USCI_B_I2C_SET_DATA_RATE_400KBPS 400000
63 #define USCI_B_I2C_SET_DATA_RATE_100KBPS 100000
64 
65 //*****************************************************************************
66 //
67 // The following are values that can be passed to the mode parameter for
68 // functions: USCI_B_I2C_setMode().
69 //
70 //*****************************************************************************
71 #define USCI_B_I2C_TRANSMIT_MODE UCTR
72 #define USCI_B_I2C_RECEIVE_MODE 0x00
73 
74 //*****************************************************************************
75 //
76 // The following are values that can be passed to the mask parameter for
77 // functions: USCI_B_I2C_enableInterrupt(), USCI_B_I2C_disableInterrupt(),
78 // USCI_B_I2C_clearInterrupt(), and USCI_B_I2C_getInterruptStatus() as well as
79 // returned by the USCI_B_I2C_getInterruptStatus() function.
80 //
81 //*****************************************************************************
82 #define USCI_B_I2C_STOP_INTERRUPT UCSTPIE
83 #define USCI_B_I2C_START_INTERRUPT UCSTTIE
84 #define USCI_B_I2C_RECEIVE_INTERRUPT UCRXIE
85 #define USCI_B_I2C_TRANSMIT_INTERRUPT UCTXIE
86 #define USCI_B_I2C_NAK_INTERRUPT UCNACKIE
87 #define USCI_B_I2C_ARBITRATIONLOST_INTERRUPT UCALIE
88 
89 //*****************************************************************************
90 //
91 // The following are values that can be passed toThe following are values that
92 // can be returned by the USCI_B_I2C_isBusy() function and the
93 // USCI_B_I2C_isBusBusy() function.
94 //
95 //*****************************************************************************
96 #define USCI_B_I2C_BUS_BUSY UCBBUSY
97 #define USCI_B_I2C_BUS_NOT_BUSY 0x00
98 
99 //*****************************************************************************
100 //
101 // The following are values that can be passed toThe following are values that
102 // can be returned by the USCI_B_I2C_masterIsStartSent() function.
103 //
104 //*****************************************************************************
105 #define USCI_B_I2C_SENDING_START UCTXSTT
106 #define USCI_B_I2C_START_SEND_COMPLETE 0x00
107 
108 //*****************************************************************************
109 //
110 // The following are values that can be passed toThe following are values that
111 // can be returned by the USCI_B_I2C_masterIsStopSent() function.
112 //
113 //*****************************************************************************
114 #define USCI_B_I2C_SENDING_STOP UCTXSTP
115 #define USCI_B_I2C_STOP_SEND_COMPLETE 0x00
116 
117 //*****************************************************************************
118 //
119 // Prototypes for the APIs.
120 //
121 //*****************************************************************************
122 
123 //*****************************************************************************
124 //
125 //! \brief Initializes the I2C Master block.
126 //!
127 //! This function initializes operation of the I2C Master block. Upon
128 //! successful initialization of the I2C block, this function will have set the
129 //! bus speed for the master; however I2C module is still disabled till
130 //! USCI_B_I2C_enable is invoked. If the parameter \e dataRate is
131 //! USCI_B_I2C_SET_DATA_RATE_400KBPS, then the master block will be set up to
132 //! transfer data at 400 kbps; otherwise, it will be set up to transfer data at
133 //! 100 kbps.
134 //!
135 //! \param baseAddress is the base address of the I2C Master module.
136 //! \param param is the pointe to struct for master initialization.
137 //!
138 //! Modified bits are \b UCBxBR0 of \b UCBxBR1 register; bits \b UCSSELx and \b
139 //! UCSWRST of \b UCBxCTL1 register; bits \b UCMST, \b UCMODE_3 and \b UCSYNC
140 //! of \b UCBxCTL0 register.
141 //!
142 //! \return None
143 //
144 //*****************************************************************************
145 extern void USCI_B_I2C_initMaster(uint16_t baseAddress,
147 
148 //*****************************************************************************
149 //
150 //! \brief Initializes the I2C Slave block.
151 //!
152 //! This function initializes operation of the I2C as a Slave mode. Upon
153 //! successful initialization of the I2C blocks, this function will have set
154 //! the slave address but the I2C module is still disabled till
155 //! USCI_B_I2C_enable is invoked.
156 //!
157 //! \param baseAddress is the base address of the I2C Slave module.
158 //! \param slaveAddress 7-bit slave address
159 //!
160 //! Modified bits of \b UCBxI2COA register; bits \b UCSWRST of \b UCBxCTL1
161 //! register; bits \b UCMODE_3 and \b UCSYNC of \b UCBxCTL0 register.
162 //!
163 //! \return None
164 //
165 //*****************************************************************************
166 extern void USCI_B_I2C_initSlave(uint16_t baseAddress,
167  uint8_t slaveAddress);
168 
169 //*****************************************************************************
170 //
171 //! \brief Enables the I2C block.
172 //!
173 //! This will enable operation of the I2C block.
174 //!
175 //! \param baseAddress is the base address of the USCI I2C module.
176 //!
177 //! Modified bits are \b UCSWRST of \b UCBxCTL1 register.
178 //!
179 //! \return None
180 //
181 //*****************************************************************************
182 extern void USCI_B_I2C_enable(uint16_t baseAddress);
183 
184 //*****************************************************************************
185 //
186 //! \brief Disables the I2C block.
187 //!
188 //! This will disable operation of the I2C block.
189 //!
190 //! \param baseAddress is the base address of the USCI I2C module.
191 //!
192 //! Modified bits are \b UCSWRST of \b UCBxCTL1 register.
193 //!
194 //! \return None
195 //
196 //*****************************************************************************
197 extern void USCI_B_I2C_disable(uint16_t baseAddress);
198 
199 //*****************************************************************************
200 //
201 //! \brief Sets the address that the I2C Master will place on the bus.
202 //!
203 //! This function will set the address that the I2C Master will place on the
204 //! bus when initiating a transaction.
205 //!
206 //! \param baseAddress is the base address of the I2C Master module.
207 //! \param slaveAddress 7-bit slave address
208 //!
209 //! Modified bits of \b UCBxI2CSA register; bits \b UCSWRST of \b UCBxCTL1
210 //! register.
211 //!
212 //! \return None
213 //
214 //*****************************************************************************
215 extern void USCI_B_I2C_setSlaveAddress(uint16_t baseAddress,
216  uint8_t slaveAddress);
217 
218 //*****************************************************************************
219 //
220 //! \brief Sets the mode of the I2C device
221 //!
222 //! When the receive parameter is set to USCI_B_I2C_TRANSMIT_MODE, the address
223 //! will indicate that the I2C module is in receive mode; otherwise, the I2C
224 //! module is in send mode.
225 //!
226 //! \param baseAddress is the base address of the I2C Master module.
227 //! \param mode indicates whether module is in transmit/receive mode
228 //! Valid values are:
229 //! - \b USCI_B_I2C_TRANSMIT_MODE
230 //! - \b USCI_B_I2C_RECEIVE_MODE [Default]
231 //!
232 //! \return None
233 //
234 //*****************************************************************************
235 extern void USCI_B_I2C_setMode(uint16_t baseAddress,
236  uint8_t mode);
237 
238 //*****************************************************************************
239 //
240 //! \brief Transmits a byte from the I2C Module.
241 //!
242 //! This function will place the supplied data into I2C transmit data register
243 //! to start transmission Modified bit is UCBxTXBUF register
244 //!
245 //! \param baseAddress is the base address of the I2C module.
246 //! \param transmitData data to be transmitted from the I2C module
247 //!
248 //! Modified bits of \b UCBxTXBUF register.
249 //!
250 //! \return None
251 //
252 //*****************************************************************************
253 extern void USCI_B_I2C_slavePutData(uint16_t baseAddress,
254  uint8_t transmitData);
255 
256 //*****************************************************************************
257 //
258 //! \brief Receives a byte that has been sent to the I2C Module.
259 //!
260 //! This function reads a byte of data from the I2C receive data Register.
261 //!
262 //! \param baseAddress is the base address of the I2C module.
263 //!
264 //! \return Returns the byte received from by the I2C module, cast as an
265 //! uint8_t.
266 //
267 //*****************************************************************************
268 extern uint8_t USCI_B_I2C_slaveGetData(uint16_t baseAddress);
269 
270 //*****************************************************************************
271 //
272 //! \brief Indicates whether or not the I2C bus is busy.
273 //!
274 //! This function returns an indication of whether or not the I2C bus is
275 //! busy.This function checks the status of the bus via UCBBUSY bit in UCBxSTAT
276 //! register.
277 //!
278 //! \param baseAddress is the base address of the I2C module.
279 //!
280 //! \return Returns USCI_B_I2C_BUS_BUSY if the I2C Master is busy; otherwise,
281 //! returns USCI_B_I2C_BUS_NOT_BUSY.
282 //! Return one of the following:
283 //! - \b USCI_B_I2C_BUS_BUSY
284 //! - \b USCI_B_I2C_BUS_NOT_BUSY
285 //! \n indicating if the USCI_B_I2C is busy
286 //
287 //*****************************************************************************
288 extern uint8_t USCI_B_I2C_isBusBusy(uint16_t baseAddress);
289 
290 //*****************************************************************************
291 //
292 //! \brief DEPRECATED - Function may be removed in future release. Indicates
293 //! whether or not the I2C module is busy.
294 //!
295 //! This function returns an indication of whether or not the I2C module is
296 //! busy transmitting or receiving data. This function checks if the Transmit
297 //! or receive flag is set.
298 //!
299 //! \param baseAddress is the base address of the I2C module.
300 //!
301 //! \return Returns USCI_B_I2C_BUS_BUSY if the I2C module is busy; otherwise,
302 //! returns USCI_B_I2C_BUS_NOT_BUSY.
303 //! Return one of the following:
304 //! - \b USCI_B_I2C_BUS_BUSY
305 //! - \b USCI_B_I2C_BUS_NOT_BUSY
306 //! \n indicating if the USCI_B_I2C is busy
307 //
308 //*****************************************************************************
309 extern uint8_t USCI_B_I2C_isBusy(uint16_t baseAddress);
310 
311 //*****************************************************************************
312 //
313 //! \brief Indicates whether STOP got sent.
314 //!
315 //! This function returns an indication of whether or not STOP got sent This
316 //! function checks the status of the bus via UCTXSTP bit in UCBxCTL1 register.
317 //!
318 //! \param baseAddress is the base address of the I2C module.
319 //!
320 //! \return Returns USCI_B_I2C_STOP_SEND_COMPLETE if the I2C Master finished
321 //! sending STOP; otherwise, returns USCI_B_I2C_SENDING_STOP.
322 //! Return one of the following:
323 //! - \b USCI_B_I2C_SENDING_STOP
324 //! - \b USCI_B_I2C_STOP_SEND_COMPLETE
325 //
326 //*****************************************************************************
327 extern uint8_t USCI_B_I2C_masterIsStopSent(uint16_t baseAddress);
328 
329 //*****************************************************************************
330 //
331 //! \brief Indicates whether START got sent.
332 //!
333 //! This function returns an indication of whether or not START got sent This
334 //! function checks the status of the bus via UCTXSTT bit in UCBxCTL1 register.
335 //!
336 //! \param baseAddress is the base address of the I2C module.
337 //!
338 //! \return Returns USCI_B_I2C_START_SEND_COMPLETE if the I2C Master finished
339 //! sending START; otherwise, returns USCI_B_I2C_SENDING_START.
340 //! Return one of the following:
341 //! - \b USCI_B_I2C_SENDING_START
342 //! - \b USCI_B_I2C_START_SEND_COMPLETE
343 //
344 //*****************************************************************************
345 extern uint8_t USCI_B_I2C_masterIsStartSent(uint16_t baseAddress);
346 
347 //*****************************************************************************
348 //
349 //! \brief This function is used by the Master module to initiate START
350 //!
351 //! This function is used by the Master module to initiate STOP
352 //!
353 //! \param baseAddress is the base address of the I2C Master module.
354 //!
355 //! \return None
356 //
357 //*****************************************************************************
358 extern void USCI_B_I2C_masterSendStart(uint16_t baseAddress);
359 
360 //*****************************************************************************
361 //
362 //! \brief Enables individual I2C interrupt sources.
363 //!
364 //! Enables the indicated I2C interrupt sources. Only the sources that are
365 //! enabled can be reflected to the processor interrupt; disabled sources have
366 //! no effect on the processor. Does not clear interrupt flags.
367 //!
368 //! \param baseAddress is the base address of the I2C module.
369 //! \param mask is the bit mask of the interrupt sources to be enabled.
370 //! Mask value is the logical OR of any of the following:
371 //! - \b USCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
372 //! - \b USCI_B_I2C_START_INTERRUPT - START condition interrupt
373 //! - \b USCI_B_I2C_RECEIVE_INTERRUPT - Receive interrupt
374 //! - \b USCI_B_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
375 //! - \b USCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
376 //! - \b USCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost
377 //! interrupt
378 //!
379 //! Modified bits of \b UCBxIE register.
380 //!
381 //! \return None
382 //
383 //*****************************************************************************
384 extern void USCI_B_I2C_enableInterrupt(uint16_t baseAddress,
385  uint8_t mask);
386 
387 //*****************************************************************************
388 //
389 //! \brief Disables individual I2C interrupt sources.
390 //!
391 //! Disables the indicated I2C interrupt sources. Only the sources that are
392 //! enabled can be reflected to the processor interrupt; disabled sources have
393 //! no effect on the processor.
394 //!
395 //! \param baseAddress is the base address of the I2C module.
396 //! \param mask is the bit mask of the interrupt sources to be disabled.
397 //! Mask value is the logical OR of any of the following:
398 //! - \b USCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
399 //! - \b USCI_B_I2C_START_INTERRUPT - START condition interrupt
400 //! - \b USCI_B_I2C_RECEIVE_INTERRUPT - Receive interrupt
401 //! - \b USCI_B_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
402 //! - \b USCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
403 //! - \b USCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost
404 //! interrupt
405 //!
406 //! Modified bits of \b UCBxIE register.
407 //!
408 //! \return None
409 //
410 //*****************************************************************************
411 extern void USCI_B_I2C_disableInterrupt(uint16_t baseAddress,
412  uint8_t mask);
413 
414 //*****************************************************************************
415 //
416 //! \brief Clears I2C interrupt sources.
417 //!
418 //! The I2C interrupt source is cleared, so that it no longer asserts. The
419 //! highest interrupt flag is automatically cleared when an interrupt vector
420 //! generator is used.
421 //!
422 //! \param baseAddress is the base address of the I2C Slave module.
423 //! \param mask is a bit mask of the interrupt sources to be cleared.
424 //! Mask value is the logical OR of any of the following:
425 //! - \b USCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
426 //! - \b USCI_B_I2C_START_INTERRUPT - START condition interrupt
427 //! - \b USCI_B_I2C_RECEIVE_INTERRUPT - Receive interrupt
428 //! - \b USCI_B_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
429 //! - \b USCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
430 //! - \b USCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost
431 //! interrupt
432 //!
433 //! Modified bits of \b UCBxIFG register.
434 //!
435 //! \return None
436 //
437 //*****************************************************************************
438 extern void USCI_B_I2C_clearInterrupt(uint16_t baseAddress,
439  uint8_t mask);
440 
441 //*****************************************************************************
442 //
443 //! \brief Gets the current I2C interrupt status.
444 //!
445 //! This returns the interrupt status for the I2C module based on which flag is
446 //! passed. mask parameter can be logic OR of any of the following selection.
447 //!
448 //! \param baseAddress is the base address of the I2C module.
449 //! \param mask is the masked interrupt flag status to be returned.
450 //! Mask value is the logical OR of any of the following:
451 //! - \b USCI_B_I2C_STOP_INTERRUPT - STOP condition interrupt
452 //! - \b USCI_B_I2C_START_INTERRUPT - START condition interrupt
453 //! - \b USCI_B_I2C_RECEIVE_INTERRUPT - Receive interrupt
454 //! - \b USCI_B_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
455 //! - \b USCI_B_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
456 //! - \b USCI_B_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost
457 //! interrupt
458 //!
459 //! \return the masked status of the interrupt flag
460 //! Return Logical OR of any of the following:
461 //! - \b USCI_B_I2C_STOP_INTERRUPT STOP condition interrupt
462 //! - \b USCI_B_I2C_START_INTERRUPT START condition interrupt
463 //! - \b USCI_B_I2C_RECEIVE_INTERRUPT Receive interrupt
464 //! - \b USCI_B_I2C_TRANSMIT_INTERRUPT Transmit interrupt
465 //! - \b USCI_B_I2C_NAK_INTERRUPT Not-acknowledge interrupt
466 //! - \b USCI_B_I2C_ARBITRATIONLOST_INTERRUPT Arbitration lost
467 //! interrupt
468 //! \n indicating the status of the masked interrupts
469 //
470 //*****************************************************************************
471 extern uint8_t USCI_B_I2C_getInterruptStatus(uint16_t baseAddress,
472  uint8_t mask);
473 
474 //*****************************************************************************
475 //
476 //! \brief Does single byte transmission from Master to Slave
477 //!
478 //! This function is used by the Master module to send a single byte.This
479 //! function does the following: - Sends START; - Transmits the byte to the
480 //! Slave; - Sends STOP
481 //!
482 //! \param baseAddress is the base address of the I2C Master module.
483 //! \param txData is the data byte to be transmitted
484 //!
485 //! Modified bits of \b UCBxTXBUF register, bits of \b UCBxIFG register, bits
486 //! of \b UCBxCTL1 register and bits of \b UCBxIE register.
487 //!
488 //! \return None
489 //
490 //*****************************************************************************
491 extern void USCI_B_I2C_masterSendSingleByte(uint16_t baseAddress,
492  uint8_t txData);
493 
494 //*****************************************************************************
495 //
496 //! \brief Does single byte transmission from Master to Slave with timeout
497 //!
498 //! This function is used by the Master module to send a single byte. This
499 //! function does the following: - Sends START; - Transmits the byte to the
500 //! Slave; - Sends STOP
501 //!
502 //! \param baseAddress is the base address of the I2C Master module.
503 //! \param txData is the data byte to be transmitted
504 //! \param timeout is the amount of time to wait until giving up
505 //!
506 //! Modified bits of \b UCBxTXBUF register, bits of \b UCBxIFG register, bits
507 //! of \b UCBxCTL1 register and bits of \b UCBxIE register.
508 //!
509 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
510 //
511 //*****************************************************************************
512 extern bool USCI_B_I2C_masterSendSingleByteWithTimeout(uint16_t baseAddress,
513  uint8_t txData,
514  uint32_t timeout);
515 
516 //*****************************************************************************
517 //
518 //! \brief Starts multi-byte transmission from Master to Slave
519 //!
520 //! This function is used by the Master module to send a single byte. This
521 //! function does the following: - Sends START; - Transmits the first data byte
522 //! of a multi-byte transmission to the Slave
523 //!
524 //! \param baseAddress is the base address of the I2C Master module.
525 //! \param txData is the first data byte to be transmitted
526 //!
527 //! Modified bits of \b UCBxTXBUF register, bits of \b UCBxIFG register, bits
528 //! of \b UCBxCTL1 register and bits of \b UCBxIE register.
529 //!
530 //! \return None
531 //
532 //*****************************************************************************
533 extern void USCI_B_I2C_masterSendMultiByteStart(uint16_t baseAddress,
534  uint8_t txData);
535 
536 //*****************************************************************************
537 //
538 //! \brief Starts multi-byte transmission from Master to Slave with timeout
539 //!
540 //! This function is used by the Master module to send a single byte. This
541 //! function does the following: - Sends START; - Transmits the first data byte
542 //! of a multi-byte transmission to the Slave
543 //!
544 //! \param baseAddress is the base address of the I2C Master module.
545 //! \param txData is the first data byte to be transmitted
546 //! \param timeout is the amount of time to wait until giving up
547 //!
548 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
549 //
550 //*****************************************************************************
551 extern bool USCI_B_I2C_masterSendMultiByteStartWithTimeout(uint16_t baseAddress,
552  uint8_t txData,
553  uint32_t timeout);
554 
555 //*****************************************************************************
556 //
557 //! \brief Continues multi-byte transmission from Master to Slave
558 //!
559 //! This function is used by the Master module continue each byte of a multi-
560 //! byte transmission. This function does the following: -Transmits each data
561 //! byte of a multi-byte transmission to the Slave
562 //!
563 //! \param baseAddress is the base address of the I2C Master module.
564 //! \param txData is the next data byte to be transmitted
565 //!
566 //! Modified bits of \b UCBxTXBUF register.
567 //!
568 //! \return None
569 //
570 //*****************************************************************************
571 extern void USCI_B_I2C_masterSendMultiByteNext(uint16_t baseAddress,
572  uint8_t txData);
573 
574 //*****************************************************************************
575 //
576 //! \brief Continues multi-byte transmission from Master to Slave with timeout
577 //!
578 //! This function is used by the Master module continue each byte of a multi-
579 //! byte transmission. This function does the following: -Transmits each data
580 //! byte of a multi-byte transmission to the Slave
581 //!
582 //! \param baseAddress is the base address of the I2C Master module.
583 //! \param txData is the next data byte to be transmitted
584 //! \param timeout is the amount of time to wait until giving up
585 //!
586 //! Modified bits of \b UCBxTXBUF register.
587 //!
588 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
589 //
590 //*****************************************************************************
591 extern bool USCI_B_I2C_masterSendMultiByteNextWithTimeout(uint16_t baseAddress,
592  uint8_t txData,
593  uint32_t timeout);
594 
595 //*****************************************************************************
596 //
597 //! \brief Finishes multi-byte transmission from Master to Slave
598 //!
599 //! This function is used by the Master module to send the last byte and STOP.
600 //! This function does the following: - Transmits the last data byte of a
601 //! multi-byte transmission to the Slave; - Sends STOP
602 //!
603 //! \param baseAddress is the base address of the I2C Master module.
604 //! \param txData is the last data byte to be transmitted in a multi-byte
605 //! transmission
606 //!
607 //! Modified bits of \b UCBxTXBUF register and bits of \b UCBxCTL1 register.
608 //!
609 //! \return None
610 //
611 //*****************************************************************************
612 extern void USCI_B_I2C_masterSendMultiByteFinish(uint16_t baseAddress,
613  uint8_t txData);
614 
615 //*****************************************************************************
616 //
617 //! \brief Finishes multi-byte transmission from Master to Slave with timeout
618 //!
619 //! This function is used by the Master module to send the last byte and STOP.
620 //! This function does the following: - Transmits the last data byte of a
621 //! multi-byte transmission to the Slave; - Sends STOP
622 //!
623 //! \param baseAddress is the base address of the I2C Master module.
624 //! \param txData is the last data byte to be transmitted in a multi-byte
625 //! transmission
626 //! \param timeout is the amount of time to wait until giving up
627 //!
628 //! Modified bits of \b UCBxTXBUF register and bits of \b UCBxCTL1 register.
629 //!
630 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
631 //
632 //*****************************************************************************
633 extern bool USCI_B_I2C_masterSendMultiByteFinishWithTimeout(uint16_t baseAddress,
634  uint8_t txData,
635  uint32_t timeout);
636 
637 //*****************************************************************************
638 //
639 //! \brief Send STOP byte at the end of a multi-byte transmission from Master
640 //! to Slave
641 //!
642 //! This function is used by the Master module send STOP at the end of a multi-
643 //! byte transmission. This function does the following: - Sends a STOP after
644 //! current transmission is complete
645 //!
646 //! \param baseAddress is the base address of the I2C Master module.
647 //!
648 //! Modified bits are \b UCTXSTP of \b UCBxCTL1 register.
649 //!
650 //! \return None
651 //
652 //*****************************************************************************
653 extern void USCI_B_I2C_masterSendMultiByteStop(uint16_t baseAddress);
654 
655 //*****************************************************************************
656 //
657 //! \brief Send STOP byte at the end of a multi-byte transmission from Master
658 //! to Slave with timeout
659 //!
660 //! This function is used by the Master module send STOP at the end of a multi-
661 //! byte transmission. This function does the following: - Sends a STOP after
662 //! current transmission is complete
663 //!
664 //! \param baseAddress is the base address of the I2C Master module.
665 //! \param timeout is the amount of time to wait until giving up
666 //!
667 //! Modified bits are \b UCTXSTP of \b UCBxCTL1 register.
668 //!
669 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
670 //
671 //*****************************************************************************
672 extern bool USCI_B_I2C_masterSendMultiByteStopWithTimeout(uint16_t baseAddress,
673  uint32_t timeout);
674 
675 //*****************************************************************************
676 //
677 //! \brief Starts multi-byte reception at the Master end
678 //!
679 //! This function is used by the Master module initiate reception of a single
680 //! byte. This function does the following: - Sends START
681 //!
682 //! \param baseAddress is the base address of the I2C Master module.
683 //!
684 //! Modified bits are \b UCTXSTT of \b UCBxCTL1 register.
685 //!
686 //! \return None
687 //
688 //*****************************************************************************
689 extern void USCI_B_I2C_masterReceiveMultiByteStart(uint16_t baseAddress);
690 
691 //*****************************************************************************
692 //
693 //! \brief Starts multi-byte reception at the Master end one byte at a time
694 //!
695 //! This function is used by the Master module to receive each byte of a multi-
696 //! byte reception. This function reads currently received byte
697 //!
698 //! \param baseAddress is the base address of the I2C Master module.
699 //!
700 //! \return Received byte at Master end.
701 //
702 //*****************************************************************************
703 extern uint8_t USCI_B_I2C_masterReceiveMultiByteNext(uint16_t baseAddress);
704 
705 //*****************************************************************************
706 //
707 //! \brief Finishes multi-byte reception at the Master end
708 //!
709 //! This function is used by the Master module to initiate completion of a
710 //! multi-byte reception. This function does the following: - Receives the
711 //! current byte and initiates the STOP from Master to Slave
712 //!
713 //! \param baseAddress is the base address of the I2C Master module.
714 //!
715 //! Modified bits are \b UCTXSTP of \b UCBxCTL1 register.
716 //!
717 //! \return Received byte at Master end.
718 //
719 //*****************************************************************************
720 extern uint8_t USCI_B_I2C_masterReceiveMultiByteFinish(uint16_t baseAddress);
721 
722 //*****************************************************************************
723 //
724 //! \brief Finishes multi-byte reception at the Master end with timeout
725 //!
726 //! This function is used by the Master module to initiate completion of a
727 //! multi-byte reception. This function does the following: - Receives the
728 //! current byte and initiates the STOP from Master to Slave
729 //!
730 //! \param baseAddress is the base address of the I2C Master module.
731 //! \param rxData is a pointer to the location to store the received byte at
732 //! master end
733 //! \param timeout is the amount of time to wait until giving up
734 //!
735 //! Modified bits are \b UCTXSTP of \b UCBxCTL1 register.
736 //!
737 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
738 //
739 //*****************************************************************************
740 extern bool USCI_B_I2C_masterReceiveMultiByteFinishWithTimeout(uint16_t baseAddress,
741  uint8_t *rxData,
742  uint32_t timeout);
743 
744 //*****************************************************************************
745 //
746 //! \brief Sends the STOP at the end of a multi-byte reception at the Master
747 //! end
748 //!
749 //! This function is used by the Master module to initiate STOP
750 //!
751 //! \param baseAddress is the base address of the I2C Master module.
752 //!
753 //! Modified bits are \b UCTXSTP of \b UCBxCTL1 register.
754 //!
755 //! \return None
756 //
757 //*****************************************************************************
758 extern void USCI_B_I2C_masterReceiveMultiByteStop(uint16_t baseAddress);
759 
760 //*****************************************************************************
761 //
762 //! \brief Initiates a single byte Reception at the Master End
763 //!
764 //! This function sends a START and STOP immediately to indicate Single byte
765 //! reception
766 //!
767 //! \param baseAddress is the base address of the I2C Master module.
768 //!
769 //! Modified bits are \b GIE of \b SR register; bits \b UCTXSTT and \b UCTXSTP
770 //! of \b UCBxCTL1 register.
771 //!
772 //! \return None
773 //
774 //*****************************************************************************
775 extern void USCI_B_I2C_masterReceiveSingleStart(uint16_t baseAddress);
776 
777 //*****************************************************************************
778 //
779 //! \brief Initiates a single byte Reception at the Master End with timeout
780 //!
781 //! This function sends a START and STOP immediately to indicate Single byte
782 //! reception
783 //!
784 //! \param baseAddress is the base address of the I2C Master module.
785 //! \param timeout is the amount of time to wait until giving up
786 //!
787 //! Modified bits are \b GIE of \b SR register; bits \b UCTXSTT and \b UCTXSTP
788 //! of \b UCBxCTL1 register.
789 //!
790 //! \return STATUS_SUCCESS or STATUS_FAILURE of the transmission process.
791 //
792 //*****************************************************************************
793 extern bool USCI_B_I2C_masterReceiveSingleStartWithTimeout(uint16_t baseAddress,
794  uint32_t timeout);
795 
796 //*****************************************************************************
797 //
798 //! \brief Receives a byte that has been sent to the I2C Master Module.
799 //!
800 //! This function reads a byte of data from the I2C receive data Register.
801 //!
802 //! \param baseAddress is the base address of the I2C module.
803 //!
804 //! \return Returns the byte received from by the I2C module, cast as an
805 //! uint8_t.
806 //
807 //*****************************************************************************
808 extern uint8_t USCI_B_I2C_masterReceiveSingle(uint16_t baseAddress);
809 
810 //*****************************************************************************
811 //
812 //! \brief Returns the address of the RX Buffer of the I2C for the DMA module.
813 //!
814 //! Returns the address of the I2C RX Buffer. This can be used in conjunction
815 //! with the DMA to store the received data directly to memory.
816 //!
817 //! \param baseAddress is the base address of the I2C module.
818 //!
819 //! \return the address of the RX Buffer
820 //
821 //*****************************************************************************
822 extern uint32_t USCI_B_I2C_getReceiveBufferAddressForDMA(uint16_t baseAddress);
823 
824 //*****************************************************************************
825 //
826 //! \brief Returns the address of the TX Buffer of the I2C for the DMA module.
827 //!
828 //! Returns the address of the I2C TX Buffer. This can be used in conjunction
829 //! with the DMA to obtain transmitted data directly from memory.
830 //!
831 //! \param baseAddress is the base address of the I2C module.
832 //!
833 //! \return the address of the TX Buffer
834 //
835 //*****************************************************************************
836 extern uint32_t USCI_B_I2C_getTransmitBufferAddressForDMA(uint16_t baseAddress);
837 
838 //*****************************************************************************
839 //
840 // Mark the end of the C bindings section for C++ compilers.
841 //
842 //*****************************************************************************
843 #ifdef __cplusplus
844 }
845 #endif
846 
847 #endif
848 #endif // __MSP430WARE_USCI_B_I2C_H__
void USCI_B_I2C_masterSendMultiByteNext(uint16_t baseAddress, uint8_t txData)
Continues multi-byte transmission from Master to Slave.
Definition: usci_b_i2c.c:306
void USCI_B_I2C_setSlaveAddress(uint16_t baseAddress, uint8_t slaveAddress)
Sets the address that the I2C Master will place on the bus.
Definition: usci_b_i2c.c:77
void USCI_B_I2C_masterSendMultiByteStop(uint16_t baseAddress)
Send STOP byte at the end of a multi-byte transmission from Master to Slave.
Definition: usci_b_i2c.c:397
uint8_t USCI_B_I2C_slaveGetData(uint16_t baseAddress)
Receives a byte that has been sent to the I2C Module.
Definition: usci_b_i2c.c:101
void USCI_B_I2C_disableInterrupt(uint16_t baseAddress, uint8_t mask)
Disables individual I2C interrupt sources.
Definition: usci_b_i2c.c:148
bool USCI_B_I2C_masterSendMultiByteStopWithTimeout(uint16_t baseAddress, uint32_t timeout)
Send STOP byte at the end of a multi-byte transmission from Master to Slave with timeout.
Definition: usci_b_i2c.c:409
bool USCI_B_I2C_masterSendMultiByteNextWithTimeout(uint16_t baseAddress, uint8_t txData, uint32_t timeout)
Continues multi-byte transmission from Master to Slave with timeout.
Definition: usci_b_i2c.c:320
uint8_t USCI_B_I2C_masterIsStartSent(uint16_t baseAddress)
Indicates whether START got sent.
Definition: usci_b_i2c.c:129
void USCI_B_I2C_masterSendMultiByteStart(uint16_t baseAddress, uint8_t txData)
Starts multi-byte transmission from Master to Slave.
Definition: usci_b_i2c.c:252
void USCI_B_I2C_masterReceiveSingleStart(uint16_t baseAddress)
Initiates a single byte Reception at the Master End.
Definition: usci_b_i2c.c:501
void USCI_B_I2C_masterReceiveMultiByteStop(uint16_t baseAddress)
Sends the STOP at the end of a multi-byte reception at the Master end.
Definition: usci_b_i2c.c:495
bool USCI_B_I2C_masterReceiveMultiByteFinishWithTimeout(uint16_t baseAddress, uint8_t *rxData, uint32_t timeout)
Finishes multi-byte reception at the Master end with timeout.
Definition: usci_b_i2c.c:462
bool USCI_B_I2C_masterSendMultiByteStartWithTimeout(uint16_t baseAddress, uint8_t txData, uint32_t timeout)
Starts multi-byte transmission from Master to Slave with timeout.
Definition: usci_b_i2c.c:275
uint8_t USCI_B_I2C_isBusy(uint16_t baseAddress)
DEPRECATED - Function may be removed in future release. Indicates whether or not the I2C module is bu...
Definition: usci_b_i2c.c:113
uint8_t USCI_B_I2C_masterReceiveSingle(uint16_t baseAddress)
Receives a byte that has been sent to the I2C Master Module.
Definition: usci_b_i2c.c:564
bool USCI_B_I2C_masterReceiveSingleStartWithTimeout(uint16_t baseAddress, uint32_t timeout)
Initiates a single byte Reception at the Master End with timeout.
Definition: usci_b_i2c.c:528
void USCI_B_I2C_masterReceiveMultiByteStart(uint16_t baseAddress)
Starts multi-byte reception at the Master end.
Definition: usci_b_i2c.c:429
uint8_t USCI_B_I2C_isBusBusy(uint16_t baseAddress)
Indicates whether or not the I2C bus is busy.
Definition: usci_b_i2c.c:107
uint8_t USCI_B_I2C_masterReceiveMultiByteFinish(uint16_t baseAddress)
Finishes multi-byte reception at the Master end.
Definition: usci_b_i2c.c:442
uint8_t USCI_B_I2C_getInterruptStatus(uint16_t baseAddress, uint8_t mask)
Gets the current I2C interrupt status.
Definition: usci_b_i2c.c:164
void USCI_B_I2C_disable(uint16_t baseAddress)
Disables the I2C block.
Definition: usci_b_i2c.c:71
bool USCI_B_I2C_masterSendSingleByteWithTimeout(uint16_t baseAddress, uint8_t txData, uint32_t timeout)
Does single byte transmission from Master to Slave with timeout.
Definition: usci_b_i2c.c:204
void USCI_B_I2C_enableInterrupt(uint16_t baseAddress, uint8_t mask)
Enables individual I2C interrupt sources.
Definition: usci_b_i2c.c:140
void USCI_B_I2C_initMaster(uint16_t baseAddress, USCI_B_I2C_initMasterParam *param)
Initializes the I2C Master block.
Definition: usci_b_i2c.c:21
uint32_t i2cClk
Is the rate of the clock supplied to the I2C module.
Definition: usci_b_i2c.h:38
uint8_t USCI_B_I2C_masterIsStopSent(uint16_t baseAddress)
Indicates whether STOP got sent.
Definition: usci_b_i2c.c:123
void USCI_B_I2C_initSlave(uint16_t baseAddress, uint8_t slaveAddress)
Initializes the I2C Slave block.
Definition: usci_b_i2c.c:48
void USCI_B_I2C_enable(uint16_t baseAddress)
Enables the I2C block.
Definition: usci_b_i2c.c:65
void USCI_B_I2C_masterSendMultiByteFinish(uint16_t baseAddress, uint8_t txData)
Finishes multi-byte transmission from Master to Slave.
Definition: usci_b_i2c.c:342
uint32_t USCI_B_I2C_getTransmitBufferAddressForDMA(uint16_t baseAddress)
Returns the address of the TX Buffer of the I2C for the DMA module.
Definition: usci_b_i2c.c:580
uint32_t dataRate
Definition: usci_b_i2c.h:43
void USCI_B_I2C_masterSendSingleByte(uint16_t baseAddress, uint8_t txData)
Does single byte transmission from Master to Slave.
Definition: usci_b_i2c.c:172
void USCI_B_I2C_masterSendStart(uint16_t baseAddress)
This function is used by the Master module to initiate START.
Definition: usci_b_i2c.c:135
uint8_t USCI_B_I2C_masterReceiveMultiByteNext(uint16_t baseAddress)
Starts multi-byte reception at the Master end one byte at a time.
Definition: usci_b_i2c.c:437
Used in the USCI_B_I2C_initMaster() function as the param parameter.
Definition: usci_b_i2c.h:31
uint32_t USCI_B_I2C_getReceiveBufferAddressForDMA(uint16_t baseAddress)
Returns the address of the RX Buffer of the I2C for the DMA module.
Definition: usci_b_i2c.c:575
uint8_t selectClockSource
Definition: usci_b_i2c.h:36
void USCI_B_I2C_setMode(uint16_t baseAddress, uint8_t mode)
Sets the mode of the I2C device.
Definition: usci_b_i2c.c:85
void USCI_B_I2C_clearInterrupt(uint16_t baseAddress, uint8_t mask)
Clears I2C interrupt sources.
Definition: usci_b_i2c.c:156
bool USCI_B_I2C_masterSendMultiByteFinishWithTimeout(uint16_t baseAddress, uint8_t txData, uint32_t timeout)
Finishes multi-byte transmission from Master to Slave with timeout.
Definition: usci_b_i2c.c:362
void USCI_B_I2C_slavePutData(uint16_t baseAddress, uint8_t transmitData)
Transmits a byte from the I2C Module.
Definition: usci_b_i2c.c:93

Copyright 2020, Texas Instruments Incorporated