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