MSP430 Driver Library  1.80.00.18
Functions
Usci_i2c_api

Functions

void USCI_I2C_masterInit (uint32_t baseAddress, uint8_t selectClockSource, uint32_t i2cClk, uint32_t dataRate)
 Initializes the I2C Master block. More...
 
void USCI_I2C_slaveInit (uint32_t baseAddress, uint8_t slaveAddress)
 Initializes the I2C Slave block. More...
 
void USCI_I2C_enable (uint32_t baseAddress)
 Enables the I2C block. More...
 
void USCI_I2C_disable (uint32_t baseAddress)
 Disables the I2C block. More...
 
void USCI_I2C_setSlaveAddress (uint32_t baseAddress, uint8_t slaveAddress)
 Sets the address that the I2C Master will place on the bus. More...
 
void USCI_I2C_setMode (uint32_t baseAddress, uint8_t mode)
 Sets the mode of the I2C device. More...
 
void USCI_I2C_slaveDataPut (uint32_t baseAddress, uint8_t transmitData)
 Transmits a byte from the I2C Module. More...
 
uint8_t USCI_I2C_slaveDataGet (uint32_t baseAddress)
 Receives a byte that has been sent to the I2C Module. More...
 
uint8_t USCI_I2C_isBusBusy (uint32_t baseAddress)
 Indicates whether or not the I2C bus is busy. More...
 
uint8_t USCI_I2C_isBusy (uint32_t baseAddress)
 DEPRECATED - Function may be removed in future release. Indicates whether or not the I2C module is busy. More...
 
uint8_t USCI_I2C_masterIsStopSent (uint32_t baseAddress)
 Indicates whether STOP got sent. More...
 
uint8_t USCI_I2C_masterIsStartSent (uint32_t baseAddress)
 Indicates whether START got sent. More...
 
void USCI_I2C_masterSendStart (uint32_t baseAddress)
 This function is used by the Master module to initiate START. More...
 
void USCI_I2C_enableInterrupt (uint32_t baseAddress, uint8_t mask)
 Enables individual I2C interrupt sources. More...
 
void USCI_I2C_disableInterrupt (uint32_t baseAddress, uint8_t mask)
 Disables individual I2C interrupt sources. More...
 
void USCI_I2C_clearInterruptFlag (uint32_t baseAddress, uint8_t mask)
 Clears I2C interrupt sources. More...
 
uint8_t USCI_I2C_getInterruptStatus (uint32_t baseAddress, uint8_t mask)
 Gets the current I2C interrupt status. More...
 
void USCI_I2C_masterSendSingleByte (uint32_t baseAddress, uint8_t txData)
 Does single byte transmission from Master to Slave. More...
 
bool USCI_I2C_masterSendSingleByteWithTimeout (uint32_t baseAddress, uint8_t txData, uint32_t timeout)
 Does single byte transmission from Master to Slave with timeout. More...
 
void USCI_I2C_masterMultiByteSendStart (uint32_t baseAddress, uint8_t txData)
 Starts multi-byte transmission from Master to Slave. More...
 
bool USCI_I2C_masterMultiByteSendStartWithTimeout (uint32_t baseAddress, uint8_t txData, uint32_t timeout)
 Starts multi-byte transmission from Master to Slave with timeout. More...
 
void USCI_I2C_masterMultiByteSendNext (uint32_t baseAddress, uint8_t txData)
 Continues multi-byte transmission from Master to Slave. More...
 
bool USCI_I2C_masterMultiByteSendNextWithTimeout (uint32_t baseAddress, uint8_t txData, uint32_t timeout)
 Continues multi-byte transmission from Master to Slave with timeout. More...
 
void USCI_I2C_masterMultiByteSendFinish (uint32_t baseAddress, uint8_t txData)
 Finishes multi-byte transmission from Master to Slave. More...
 
bool USCI_I2C_masterMultiByteSendFinishWithTimeout (uint32_t baseAddress, uint8_t txData, uint32_t timeout)
 Finishes multi-byte transmission from Master to Slave with timeout. More...
 
void USCI_I2C_masterMultiByteSendStop (uint32_t baseAddress)
 Send STOP byte at the end of a multi-byte transmission from Master to Slave. More...
 
bool USCI_I2C_masterMultiByteSendStopWithTimeout (uint32_t baseAddress, uint32_t timeout)
 Send STOP byte at the end of a multi-byte transmission from Master to Slave with timeout. More...
 
void USCI_I2C_masterMultiByteReceiveStart (uint32_t baseAddress)
 Starts multi-byte reception at the Master end. More...
 
uint8_t USCI_I2C_masterMultiByteReceiveNext (uint32_t baseAddress)
 Starts multi-byte reception at the Master end one byte at a time. More...
 
uint8_t USCI_I2C_masterMultiByteReceiveFinish (uint32_t baseAddress)
 Finishes multi-byte reception at the Master end. More...
 
bool USCI_I2C_masterMultiByteReceiveFinishWithTimeout (uint32_t baseAddress, uint8_t *rxData, uint32_t timeout)
 Finishes multi-byte reception at the Master end with timeout. More...
 
void USCI_I2C_masterMultiByteReceiveStop (uint32_t baseAddress)
 Sends the STOP at the end of a multi-byte reception at the Master end. More...
 
void USCI_I2C_masterSingleReceiveStart (uint32_t baseAddress)
 Initiates a single byte Reception at the Master End. More...
 
bool USCI_I2C_masterSingleReceiveStartWithTimeout (uint32_t baseAddress, uint32_t timeout)
 Initiates a single byte Reception at the Master End with timeout. More...
 
uint8_t USCI_I2C_masterSingleReceive (uint32_t baseAddress)
 Receives a byte that has been sent to the I2C Master Module. More...
 
uint32_t USCI_I2C_getReceiveBufferAddressForDMA (uint32_t baseAddress)
 Returns the address of the RX Buffer of the I2C for the DMA module. More...
 
uint32_t USCI_I2C_getTransmitBufferAddressForDMA (uint32_t baseAddress)
 Returns the address of the TX Buffer of the I2C for the DMA module. More...
 

Detailed Description

Function Documentation

void USCI_I2C_masterInit ( uint32_t  baseAddress,
uint8_t  selectClockSource,
uint32_t  i2cClk,
uint32_t  dataRate 
)

Initializes the I2C Master block.

This function initializes operation of the I2C Master block. Upon successful initialization of the I2C block, this function will have set the bus speed for the master; however I2C module is still disabled till USCI_I2C_enable is invoked. If the parameter dataRate is USCI_I2C_SET_DATA_RATE_400KBPS, then the master block will be set up to transfer data at 400 kbps; otherwise, it will be set up to transfer data at 100 kbps.

Parameters
baseAddressis the base address of the I2C Master module.
selectClockSourceis the clocksource. Valid values are:
  • USCI_I2C_CLOCKSOURCE_ACLK
  • USCI_I2C_CLOCKSOURCE_SMCLK
i2cClkis the rate of the clock supplied to the I2C module.
dataRateset up for selecting data transfer rate. Valid values are:
  • USCI_I2C_SET_DATA_RATE_400KBPS
  • USCI_I2C_SET_DATA_RATE_100KBPS

Modified bits are UCBxBR0 of UCBxBR1 register; bits UCSSELx and UCSWRST of UCBxCTL1 register; bits UCMST, UCMODE_3 and UCSYNC of UCBxCTL0 register.

Returns
None

References HWREG16, HWREG8, OFS_UCBxBRW, OFS_UCBxCTL0, OFS_UCBxCTL1, UCMODE_3, UCMST, UCSWRST, UCSYNC, USCI_I2C_CLOCKSOURCE_ACLK, USCI_I2C_CLOCKSOURCE_SMCLK, USCI_I2C_SET_DATA_RATE_100KBPS, and USCI_I2C_SET_DATA_RATE_400KBPS.

void USCI_I2C_slaveInit ( uint32_t  baseAddress,
uint8_t  slaveAddress 
)

Initializes the I2C Slave block.

This function initializes operation of the I2C as a Slave mode. Upon successful initialization of the I2C blocks, this function will have set the slave address but the I2C module is still disabled till USCI_I2C_enable is invoked.

Parameters
baseAddressis the base address of the I2C Slave module.
slaveAddress7-bit slave address

Modified bits of UCBxI2COA register; bits UCSWRST of UCBxCTL1 register; bits UCMODE_3 and UCSYNC of UCBxCTL0 register.

Returns
None

References HWREG16, HWREG8, OFS_UCBxCTL0, OFS_UCBxCTL1, OFS_UCBxI2COA, UCMODE_3, UCMST, UCSWRST, and UCSYNC.

void USCI_I2C_enable ( uint32_t  baseAddress)

Enables the I2C block.

This will enable operation of the I2C block.

Parameters
baseAddressis the base address of the USCI I2C module.

Modified bits are UCSWRST of UCBxCTL1 register.

Returns
None

References HWREG8, OFS_UCBxCTL1, and UCSWRST.

void USCI_I2C_disable ( uint32_t  baseAddress)

Disables the I2C block.

This will disable operation of the I2C block.

Parameters
baseAddressis the base address of the USCI I2C module.

Modified bits are UCSWRST of UCBxCTL1 register.

Returns
None

References HWREG8, OFS_UCBxCTL1, and UCSWRST.

void USCI_I2C_setSlaveAddress ( uint32_t  baseAddress,
uint8_t  slaveAddress 
)

Sets the address that the I2C Master will place on the bus.

This function will set the address that the I2C Master will place on the bus when initiating a transaction.

Parameters
baseAddressis the base address of the I2C Master module.
slaveAddress7-bit slave address

Modified bits of UCBxI2CSA register; bits UCSWRST of UCBxCTL1 register.

Returns
None

References HWREG16, and OFS_UCBxI2CSA.

void USCI_I2C_setMode ( uint32_t  baseAddress,
uint8_t  mode 
)

Sets the mode of the I2C device.

When the receive parameter is set to USCI_I2C_TRANSMIT_MODE, the address will indicate that the I2C module is in receive mode; otherwise, the I2C module is in send mode.

Parameters
baseAddressis the base address of the I2C Master module.
modeindicates whether module is in transmit/receive mode Valid values are:
  • USCI_I2C_TRANSMIT_MODE
  • USCI_I2C_RECEIVE_MODE [Default]
Returns
None

References HWREG8, OFS_UCBxCTL1, USCI_I2C_RECEIVE_MODE, and USCI_I2C_TRANSMIT_MODE.

void USCI_I2C_slaveDataPut ( uint32_t  baseAddress,
uint8_t  transmitData 
)

Transmits a byte from the I2C Module.

This function will place the supplied data into I2C transmit data register to start transmission Modified bit is UCBxTXBUF register

Parameters
baseAddressis the base address of the I2C module.
transmitDatadata to be transmitted from the I2C module

Modified bits of UCBxTXBUF register.

Returns
None

References HWREG8, and OFS_UCBxTXBUF.

uint8_t USCI_I2C_slaveDataGet ( uint32_t  baseAddress)

Receives a byte that has been sent to the I2C Module.

This function reads a byte of data from the I2C receive data Register.

Parameters
baseAddressis the base address of the I2C module.
Returns
Returns the byte received from by the I2C module, cast as an uint8_t.

References HWREG8, and OFS_UCBxRXBUF.

uint8_t USCI_I2C_isBusBusy ( uint32_t  baseAddress)

Indicates whether or not the I2C bus is busy.

This function returns an indication of whether or not the I2C bus is busy.This function checks the status of the bus via UCBBUSY bit in UCBxSTAT register.

Parameters
baseAddressis the base address of the I2C module.
Returns
Returns USCI_I2C_BUS_BUSY if the I2C Master is busy; otherwise, returns USCI_I2C_BUS_NOT_BUSY. Return one of the following:
  • USCI_I2C_BUS_BUSY
  • USCI_I2C_BUS_NOT_BUSY
    indicating if the USCI_I2C is busy

References HWREG8, OFS_UCBxSTAT, and UCBBUSY.

uint8_t USCI_I2C_isBusy ( uint32_t  baseAddress)

DEPRECATED - Function may be removed in future release. Indicates whether or not the I2C module is busy.

This function returns an indication of whether or not the I2C module is busy transmitting or receiving data. This function checks if the Transmit or receive flag is set.

Parameters
baseAddressis the base address of the I2C module.
Returns
Returns USCI_I2C_BUS_BUSY if the I2C module is busy; otherwise, returns USCI_I2C_BUS_NOT_BUSY. Return one of the following:
  • USCI_I2C_BUS_BUSY
  • USCI_I2C_BUS_NOT_BUSY
    indicating if the USCI_I2C is busy

References HWREG8, OFS_UCBxIFG, UCRXIFG, UCTXIFG, USCI_I2C_BUS_BUSY, and USCI_I2C_BUS_NOT_BUSY.

uint8_t USCI_I2C_masterIsStopSent ( uint32_t  baseAddress)

Indicates whether STOP got sent.

This function returns an indication of whether or not STOP got sent This function checks the status of the bus via UCTXSTP bit in UCBxCTL1 register.

Parameters
baseAddressis the base address of the I2C module.
Returns
Returns USCI_I2C_STOP_SEND_COMPLETE if the I2C Master finished sending STOP; otherwise, returns USCI_I2C_SENDING_STOP. Return one of the following:
  • USCI_I2C_SENDING_STOP
  • USCI_I2C_STOP_SEND_COMPLETE

References HWREG8, OFS_UCBxCTL1, and UCTXSTP.

uint8_t USCI_I2C_masterIsStartSent ( uint32_t  baseAddress)

Indicates whether START got sent.

This function returns an indication of whether or not START got sent This function checks the status of the bus via UCTXSTT bit in UCBxCTL1 register.

Parameters
baseAddressis the base address of the I2C module.
Returns
Returns USCI_I2C_START_SEND_COMPLETE if the I2C Master finished sending START; otherwise, returns USCI_I2C_SENDING_START. Return one of the following:
  • USCI_I2C_SENDING_START
  • USCI_I2C_START_SEND_COMPLETE

References HWREG8, OFS_UCBxCTL1, and UCTXSTT.

void USCI_I2C_masterSendStart ( uint32_t  baseAddress)

This function is used by the Master module to initiate START.

This function is used by the Master module to initiate STOP

Parameters
baseAddressis the base address of the I2C Master module.
Returns
None

References HWREG8, OFS_UCBxCTL1, and UCTXSTT.

void USCI_I2C_enableInterrupt ( uint32_t  baseAddress,
uint8_t  mask 
)

Enables individual I2C interrupt sources.

Enables the indicated I2C interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. Does not clear interrupt flags.

Parameters
baseAddressis the base address of the I2C module.
maskis the bit mask of the interrupt sources to be enabled. Mask value is the logical OR of any of the following:
  • USCI_I2C_STOP_INTERRUPT - STOP condition interrupt
  • USCI_I2C_START_INTERRUPT - START condition interrupt
  • USCI_I2C_RECEIVE_INTERRUPT - Receive interrupt
  • USCI_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
  • USCI_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • USCI_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt

Modified bits of UCBxIE register.

Returns
None

References HWREG8, OFS_UCBxIE, USCI_I2C_ARBITRATIONLOST_INTERRUPT, USCI_I2C_NAK_INTERRUPT, USCI_I2C_RECEIVE_INTERRUPT, USCI_I2C_START_INTERRUPT, USCI_I2C_STOP_INTERRUPT, and USCI_I2C_TRANSMIT_INTERRUPT.

void USCI_I2C_disableInterrupt ( uint32_t  baseAddress,
uint8_t  mask 
)

Disables individual I2C interrupt sources.

Disables the indicated I2C interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Parameters
baseAddressis the base address of the I2C module.
maskis the bit mask of the interrupt sources to be disabled. Mask value is the logical OR of any of the following:
  • USCI_I2C_STOP_INTERRUPT - STOP condition interrupt
  • USCI_I2C_START_INTERRUPT - START condition interrupt
  • USCI_I2C_RECEIVE_INTERRUPT - Receive interrupt
  • USCI_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
  • USCI_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • USCI_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt

Modified bits of UCBxIE register.

Returns
None

References HWREG8, OFS_UCBxIE, USCI_I2C_ARBITRATIONLOST_INTERRUPT, USCI_I2C_NAK_INTERRUPT, USCI_I2C_RECEIVE_INTERRUPT, USCI_I2C_START_INTERRUPT, USCI_I2C_STOP_INTERRUPT, and USCI_I2C_TRANSMIT_INTERRUPT.

void USCI_I2C_clearInterruptFlag ( uint32_t  baseAddress,
uint8_t  mask 
)

Clears I2C interrupt sources.

The I2C interrupt source is cleared, so that it no longer asserts. The highest interrupt flag is automatically cleared when an interrupt vector generator is used.

Parameters
baseAddressis the base address of the I2C Slave module.
maskis a bit mask of the interrupt sources to be cleared. Mask value is the logical OR of any of the following:
  • USCI_I2C_STOP_INTERRUPT - STOP condition interrupt
  • USCI_I2C_START_INTERRUPT - START condition interrupt
  • USCI_I2C_RECEIVE_INTERRUPT - Receive interrupt
  • USCI_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
  • USCI_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • USCI_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt

Modified bits of UCBxIFG register.

Returns
None

References HWREG8, OFS_UCBxIFG, USCI_I2C_ARBITRATIONLOST_INTERRUPT, USCI_I2C_NAK_INTERRUPT, USCI_I2C_RECEIVE_INTERRUPT, USCI_I2C_START_INTERRUPT, USCI_I2C_STOP_INTERRUPT, and USCI_I2C_TRANSMIT_INTERRUPT.

uint8_t USCI_I2C_getInterruptStatus ( uint32_t  baseAddress,
uint8_t  mask 
)

Gets the current I2C interrupt status.

This returns the interrupt status for the I2C module based on which flag is passed. mask parameter can be logic OR of any of the following selection.

Parameters
baseAddressis the base address of the I2C module.
maskis the masked interrupt flag status to be returned. Mask value is the logical OR of any of the following:
  • USCI_I2C_STOP_INTERRUPT - STOP condition interrupt
  • USCI_I2C_START_INTERRUPT - START condition interrupt
  • USCI_I2C_RECEIVE_INTERRUPT - Receive interrupt
  • USCI_I2C_TRANSMIT_INTERRUPT - Transmit interrupt
  • USCI_I2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • USCI_I2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
Returns
the masked status of the interrupt flag Return Logical OR of any of the following:
  • USCI_I2C_STOP_INTERRUPT STOP condition interrupt
  • USCI_I2C_START_INTERRUPT START condition interrupt
  • USCI_I2C_RECEIVE_INTERRUPT Receive interrupt
  • USCI_I2C_TRANSMIT_INTERRUPT Transmit interrupt
  • USCI_I2C_NAK_INTERRUPT Not-acknowledge interrupt
  • USCI_I2C_ARBITRATIONLOST_INTERRUPT Arbitration lost interrupt
    indicating the status of the masked interrupts

References HWREG8, OFS_UCBxIFG, USCI_I2C_ARBITRATIONLOST_INTERRUPT, USCI_I2C_NAK_INTERRUPT, USCI_I2C_RECEIVE_INTERRUPT, USCI_I2C_START_INTERRUPT, USCI_I2C_STOP_INTERRUPT, and USCI_I2C_TRANSMIT_INTERRUPT.

void USCI_I2C_masterSendSingleByte ( uint32_t  baseAddress,
uint8_t  txData 
)

Does single byte transmission from Master to Slave.

This function is used by the Master module to send a single byte.This function does the following: - Sends START; - Transmits the byte to the Slave; - Sends STOP

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the data byte to be transmitted

Modified bits of UCBxTXBUF register, bits of UCBxIFG register, bits of UCBxCTL1 register and bits of UCBxIE register.

Returns
None

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, UCTR, UCTXIE, UCTXIFG, UCTXSTP, and UCTXSTT.

bool USCI_I2C_masterSendSingleByteWithTimeout ( uint32_t  baseAddress,
uint8_t  txData,
uint32_t  timeout 
)

Does single byte transmission from Master to Slave with timeout.

This function is used by the Master module to send a single byte. This function does the following: - Sends START; - Transmits the byte to the Slave; - Sends STOP

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the data byte to be transmitted
timeoutis the amount of time to wait until giving up

Modified bits of UCBxTXBUF register, bits of UCBxIFG register, bits of UCBxCTL1 register and bits of UCBxIE register.

Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, STATUS_FAIL, STATUS_SUCCESS, UCTR, UCTXIE, UCTXIFG, UCTXSTP, and UCTXSTT.

void USCI_I2C_masterMultiByteSendStart ( uint32_t  baseAddress,
uint8_t  txData 
)

Starts multi-byte transmission from Master to Slave.

This function is used by the Master module to send a single byte. This function does the following: - Sends START; - Transmits the first data byte of a multi-byte transmission to the Slave

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the first data byte to be transmitted

Modified bits of UCBxTXBUF register, bits of UCBxIFG register, bits of UCBxCTL1 register and bits of UCBxIE register.

Returns
None

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, UCTR, UCTXIE, UCTXIFG, and UCTXSTT.

bool USCI_I2C_masterMultiByteSendStartWithTimeout ( uint32_t  baseAddress,
uint8_t  txData,
uint32_t  timeout 
)

Starts multi-byte transmission from Master to Slave with timeout.

This function is used by the Master module to send a single byte. This function does the following: - Sends START; - Transmits the first data byte of a multi-byte transmission to the Slave

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the first data byte to be transmitted
timeoutis the amount of time to wait until giving up
Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, STATUS_FAIL, STATUS_SUCCESS, UCTR, UCTXIE, UCTXIFG, and UCTXSTT.

void USCI_I2C_masterMultiByteSendNext ( uint32_t  baseAddress,
uint8_t  txData 
)

Continues multi-byte transmission from Master to Slave.

This function is used by the Master module continue each byte of a multi- byte transmission. This function does the following: -Transmits each data byte of a multi-byte transmission to the Slave

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the next data byte to be transmitted

Modified bits of UCBxTXBUF register.

Returns
None

References HWREG8, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, UCTXIE, and UCTXIFG.

bool USCI_I2C_masterMultiByteSendNextWithTimeout ( uint32_t  baseAddress,
uint8_t  txData,
uint32_t  timeout 
)

Continues multi-byte transmission from Master to Slave with timeout.

This function is used by the Master module continue each byte of a multi- byte transmission. This function does the following: -Transmits each data byte of a multi-byte transmission to the Slave

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the next data byte to be transmitted
timeoutis the amount of time to wait until giving up

Modified bits of UCBxTXBUF register.

Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References HWREG8, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, STATUS_FAIL, STATUS_SUCCESS, UCTXIE, and UCTXIFG.

void USCI_I2C_masterMultiByteSendFinish ( uint32_t  baseAddress,
uint8_t  txData 
)

Finishes multi-byte transmission from Master to Slave.

This function is used by the Master module to send the last byte and STOP. This function does the following: - Transmits the last data byte of a multi-byte transmission to the Slave; - Sends STOP

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the last data byte to be transmitted in a multi-byte transmission

Modified bits of UCBxTXBUF register and bits of UCBxCTL1 register.

Returns
None

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, UCTXIE, UCTXIFG, and UCTXSTP.

bool USCI_I2C_masterMultiByteSendFinishWithTimeout ( uint32_t  baseAddress,
uint8_t  txData,
uint32_t  timeout 
)

Finishes multi-byte transmission from Master to Slave with timeout.

This function is used by the Master module to send the last byte and STOP. This function does the following: - Transmits the last data byte of a multi-byte transmission to the Slave; - Sends STOP

Parameters
baseAddressis the base address of the I2C Master module.
txDatais the last data byte to be transmitted in a multi-byte transmission
timeoutis the amount of time to wait until giving up

Modified bits of UCBxTXBUF register and bits of UCBxCTL1 register.

Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxTXBUF, STATUS_FAIL, STATUS_SUCCESS, UCTXIE, UCTXIFG, and UCTXSTP.

void USCI_I2C_masterMultiByteSendStop ( uint32_t  baseAddress)

Send STOP byte at the end of a multi-byte transmission from Master to Slave.

This function is used by the Master module send STOP at the end of a multi- byte transmission. This function does the following: - Sends a STOP after current transmission is complete

Parameters
baseAddressis the base address of the I2C Master module.

Modified bits are UCTXSTP of UCBxCTL1 register.

Returns
None

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, UCTXIE, UCTXIFG, and UCTXSTP.

bool USCI_I2C_masterMultiByteSendStopWithTimeout ( uint32_t  baseAddress,
uint32_t  timeout 
)

Send STOP byte at the end of a multi-byte transmission from Master to Slave with timeout.

This function is used by the Master module send STOP at the end of a multi- byte transmission. This function does the following: - Sends a STOP after current transmission is complete

Parameters
baseAddressis the base address of the I2C Master module.
timeoutis the amount of time to wait until giving up

Modified bits are UCTXSTP of UCBxCTL1 register.

Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIE, OFS_UCBxIFG, STATUS_FAIL, STATUS_SUCCESS, UCTXIE, UCTXIFG, and UCTXSTP.

void USCI_I2C_masterMultiByteReceiveStart ( uint32_t  baseAddress)

Starts multi-byte reception at the Master end.

This function is used by the Master module initiate reception of a single byte. This function does the following: - Sends START

Parameters
baseAddressis the base address of the I2C Master module.

Modified bits are UCTXSTT of UCBxCTL1 register.

Returns
None

References HWREG8, OFS_UCBxCTL1, UCTR, and UCTXSTT.

uint8_t USCI_I2C_masterMultiByteReceiveNext ( uint32_t  baseAddress)

Starts multi-byte reception at the Master end one byte at a time.

This function is used by the Master module to receive each byte of a multi- byte reception. This function reads currently received byte

Parameters
baseAddressis the base address of the I2C Master module.
Returns
Received byte at Master end.

References HWREG8, and OFS_UCBxRXBUF.

uint8_t USCI_I2C_masterMultiByteReceiveFinish ( uint32_t  baseAddress)

Finishes multi-byte reception at the Master end.

This function is used by the Master module to initiate completion of a multi-byte reception. This function does the following: - Receives the current byte and initiates the STOP from Master to Slave

Parameters
baseAddressis the base address of the I2C Master module.

Modified bits are UCTXSTP of UCBxCTL1 register.

Returns
Received byte at Master end.

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIFG, OFS_UCBxRXBUF, UCRXIFG, and UCTXSTP.

bool USCI_I2C_masterMultiByteReceiveFinishWithTimeout ( uint32_t  baseAddress,
uint8_t *  rxData,
uint32_t  timeout 
)

Finishes multi-byte reception at the Master end with timeout.

This function is used by the Master module to initiate completion of a multi-byte reception. This function does the following: - Receives the current byte and initiates the STOP from Master to Slave

Parameters
baseAddressis the base address of the I2C Master module.
rxDatais a pointer to the location to store the received byte at master end
timeoutis the amount of time to wait until giving up

Modified bits are UCTXSTP of UCBxCTL1 register.

Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References HWREG8, OFS_UCBxCTL1, OFS_UCBxIFG, OFS_UCBxRXBUF, STATUS_FAIL, STATUS_SUCCESS, UCRXIFG, and UCTXSTP.

void USCI_I2C_masterMultiByteReceiveStop ( uint32_t  baseAddress)

Sends the STOP at the end of a multi-byte reception at the Master end.

This function is used by the Master module to initiate STOP

Parameters
baseAddressis the base address of the I2C Master module.

Modified bits are UCTXSTP of UCBxCTL1 register.

Returns
None

References HWREG8, OFS_UCBxCTL1, and UCTXSTP.

void USCI_I2C_masterSingleReceiveStart ( uint32_t  baseAddress)

Initiates a single byte Reception at the Master End.

This function sends a START and STOP immediately to indicate Single byte reception

Parameters
baseAddressis the base address of the I2C Master module.

Modified bits are GIE of SR register; bits UCTXSTT and UCTXSTP of UCBxCTL1 register.

Returns
None

References GIE, HWREG8, OFS_UCBxCTL1, UCTR, UCTXSTP, and UCTXSTT.

bool USCI_I2C_masterSingleReceiveStartWithTimeout ( uint32_t  baseAddress,
uint32_t  timeout 
)

Initiates a single byte Reception at the Master End with timeout.

This function sends a START and STOP immediately to indicate Single byte reception

Parameters
baseAddressis the base address of the I2C Master module.
timeoutis the amount of time to wait until giving up

Modified bits are GIE of SR register; bits UCTXSTT and UCTXSTP of UCBxCTL1 register.

Returns
STATUS_SUCCESS or STATUS_FAILURE of the transmission process.

References GIE, HWREG8, OFS_UCBxCTL1, OFS_UCBxIFG, STATUS_FAIL, STATUS_SUCCESS, UCTR, UCTXSTP, and UCTXSTT.

uint8_t USCI_I2C_masterSingleReceive ( uint32_t  baseAddress)

Receives a byte that has been sent to the I2C Master Module.

This function reads a byte of data from the I2C receive data Register.

Parameters
baseAddressis the base address of the I2C module.
Returns
Returns the byte received from by the I2C module, cast as an uint8_t.

References HWREG8, OFS_UCBxIE, OFS_UCBxIFG, OFS_UCBxRXBUF, UCRXIE, and UCRXIFG.

uint32_t USCI_I2C_getReceiveBufferAddressForDMA ( uint32_t  baseAddress)

Returns the address of the RX Buffer of the I2C for the DMA module.

Returns the address of the I2C RX Buffer. This can be used in conjunction with the DMA to store the received data directly to memory.

Parameters
baseAddressis the base address of the I2C module.
Returns
the address of the RX Buffer

References OFS_UCBxRXBUF.

uint32_t USCI_I2C_getTransmitBufferAddressForDMA ( uint32_t  baseAddress)

Returns the address of the TX Buffer of the I2C for the DMA module.

Returns the address of the I2C TX Buffer. This can be used in conjunction with the DMA to obtain transmitted data directly from memory.

Parameters
baseAddressis the base address of the I2C module.
Returns
the address of the TX Buffer

References OFS_UCBxTXBUF.


Copyright 2014, Texas Instruments Incorporated