Defines | Functions
ei2c.h File Reference

Go to the source code of this file.

Defines

#define __MSP430_HAS_EUSCI_Bx__
#define eI2C_CLOCKSOURCE_ACLK   UCSSEL__ACLK
#define eI2C_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK
#define eI2C_NAK_INTERRUPT   UCNACKIE
#define eI2C_ARBITRATIONLOST_INTERRUPT   UCALIE
#define eI2C_STOP_INTERRUPT   UCSTPIE
#define eI2C_START_INTERRUPT   UCSTTIE
#define eI2C_TRANSMIT_INTERRUPT0   UCTXIE0
#define eI2C_TRANSMIT_INTERRUPT1   UCTXIE1
#define eI2C_TRANSMIT_INTERRUPT2   UCTXIE2
#define eI2C_TRANSMIT_INTERRUPT3   UCTXIE3
#define eI2C_RECEIVE_INTERRUPT0   UCRXIE0
#define eI2C_RECEIVE_INTERRUPT1   UCRXIE1
#define eI2C_RECEIVE_INTERRUPT2   UCRXIE2
#define eI2C_RECEIVE_INTERRUPT3   UCRXIE3
#define eI2C_BIT9_POSITION_INTERRUPT   UCBIT9IE
#define eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT   UCCLTOIE
#define eI2C_BYTE_COUNTER_INTERRUPT   UCBCNTIE
#define eI2C_SET_DATA_RATE_400KBPS   400000
#define eI2C_SET_DATA_RATE_100KBPS   100000
#define eI2C_BUS_BUSY   UCBBUSY
#define eI2C_BUS_NOT_BUSY   0x00
#define eI2C_OWN_ADDRESS_DISABLE   0x00
#define eI2C_OWN_ADDRESS_ENABLE   UCOAEN
#define eI2C_NO_AUTO_STOP   UCASTP_0
#define eI2C_SET_BYTECOUNT_THRESHOLD_FLAG   UCASTP_1
#define eI2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD   UCASTP_2
#define eI2C_SINGLE_MASTER_ENVIRONMENT   0x00
#define eI2C_MULTI_MASTER_ENVIRONMENT   UCMM
#define eI2C_OWN_ADDRESS_OFFSET0   0x00
#define eI2C_OWN_ADDRESS_OFFSET1   0x02
#define eI2C_OWN_ADDRESS_OFFSET2   0x04
#define eI2C_OWN_ADDRESS_OFFSET3   0x06
#define eI2C_TRANSMIT_MODE   UCTR
#define eI2C_RECEIVE_MODE   0x00
#define eI2C_SENDING_STOP   UCTXSTP
#define eI2C_STOP_SEND_COMPLETE   0x00

Functions

void eI2C_masterInit (unsigned int baseAddress, unsigned char selectClockSource, unsigned long i2cClk, unsigned long dataRate, unsigned char byteCounterThreshold, unsigned char autoSTOPGeneration)
void eI2C_slaveInit (unsigned int baseAddress, unsigned char slaveAddress, unsigned char slaveAddressOffset, unsigned long slaveOwnAddressEnable)
void eI2C_enable (unsigned int baseAddress)
void eI2C_disable (unsigned int baseAddress)
void eI2C_setSlaveAddress (unsigned int baseAddress, unsigned char slaveAddress)
void eI2C_setMode (unsigned int baseAddress, unsigned char mode)
void eI2C_slaveDataPut (unsigned int baseAddress, unsigned char transmitData)
unsigned char eI2C_slaveDataGet (unsigned int baseAddress)
unsigned char eI2C_isBusBusy (unsigned int baseAddress)
unsigned char eI2C_isBusy (unsigned int baseAddress)
void eI2C_enableInterrupt (unsigned int baseAddress, unsigned int mask)
void eI2C_disableInterrupt (unsigned int baseAddress, unsigned int mask)
void eI2C_clearInterruptFlag (unsigned int baseAddress, unsigned int mask)
unsigned char eI2C_getInterruptStatus (unsigned int baseAddress, unsigned int mask)
void eI2C_masterSendSingleByte (unsigned int baseAddress, unsigned char txData)
void eI2C_masterMultiByteSendStart (unsigned int baseAddress, unsigned char txData)
void eI2C_masterMultiByteSendNext (unsigned int baseAddress, unsigned char txData)
void eI2C_masterMultiByteSendFinish (unsigned int baseAddress, unsigned char txData)
void eI2C_masterMultiByteSendStop (unsigned int baseAddress)
void eI2C_masterReceiveStart (unsigned int baseAddress)
unsigned char eI2C_masterMultiByteReceiveNext (unsigned int baseAddress)
unsigned char eI2C_masterMultiByteReceiveFinish (unsigned int baseAddress)
void eI2C_masterMultiByteReceiveStop (unsigned int baseAddress)
unsigned char eI2C_masterSingleReceive (unsigned int baseAddress)
unsigned long eI2C_getReceiveBufferAddressForDMA (unsigned int baseAddress)
unsigned long eI2C_getTransmitBufferAddressForDMA (unsigned int baseAddress)
unsigned char eI2C_masterIsSTOPSent (unsigned int baseAddress)
void eI2C_masterSendStart (unsigned int baseAddress)
void eI2C_enableMultiMasterMode (unsigned int baseAddress)
void eI2C_disableMultiMasterMode (unsigned int baseAddress)

Define Documentation

#define __MSP430_HAS_EUSCI_Bx__
#define eI2C_CLOCKSOURCE_ACLK   UCSSEL__ACLK

Referenced by eI2C_masterInit().

#define eI2C_CLOCKSOURCE_SMCLK   UCSSEL__SMCLK

Referenced by eI2C_masterInit().

#define eI2C_NAK_INTERRUPT   UCNACKIE
#define eI2C_ARBITRATIONLOST_INTERRUPT   UCALIE
#define eI2C_STOP_INTERRUPT   UCSTPIE
#define eI2C_START_INTERRUPT   UCSTTIE
#define eI2C_TRANSMIT_INTERRUPT0   UCTXIE0
#define eI2C_TRANSMIT_INTERRUPT1   UCTXIE1
#define eI2C_TRANSMIT_INTERRUPT2   UCTXIE2
#define eI2C_TRANSMIT_INTERRUPT3   UCTXIE3
#define eI2C_RECEIVE_INTERRUPT0   UCRXIE0
#define eI2C_RECEIVE_INTERRUPT1   UCRXIE1
#define eI2C_RECEIVE_INTERRUPT2   UCRXIE2
#define eI2C_RECEIVE_INTERRUPT3   UCRXIE3
#define eI2C_BIT9_POSITION_INTERRUPT   UCBIT9IE
#define eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT   UCCLTOIE
#define eI2C_BYTE_COUNTER_INTERRUPT   UCBCNTIE
#define eI2C_SET_DATA_RATE_400KBPS   400000

Referenced by eI2C_masterInit().

#define eI2C_SET_DATA_RATE_100KBPS   100000

Referenced by eI2C_masterInit().

#define eI2C_BUS_BUSY   UCBBUSY
#define eI2C_BUS_NOT_BUSY   0x00
#define eI2C_OWN_ADDRESS_DISABLE   0x00
#define eI2C_OWN_ADDRESS_ENABLE   UCOAEN
#define eI2C_NO_AUTO_STOP   UCASTP_0

Referenced by eI2C_masterInit().

#define eI2C_SET_BYTECOUNT_THRESHOLD_FLAG   UCASTP_1

Referenced by eI2C_masterInit().

#define eI2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD   UCASTP_2
#define eI2C_SINGLE_MASTER_ENVIRONMENT   0x00
#define eI2C_MULTI_MASTER_ENVIRONMENT   UCMM
#define eI2C_OWN_ADDRESS_OFFSET0   0x00

Referenced by eI2C_slaveInit().

#define eI2C_OWN_ADDRESS_OFFSET1   0x02

Referenced by eI2C_slaveInit().

#define eI2C_OWN_ADDRESS_OFFSET2   0x04

Referenced by eI2C_slaveInit().

#define eI2C_OWN_ADDRESS_OFFSET3   0x06

Referenced by eI2C_slaveInit().

#define eI2C_TRANSMIT_MODE   UCTR

Referenced by eI2C_setMode().

#define eI2C_RECEIVE_MODE   0x00

Referenced by eI2C_setMode().

#define eI2C_SENDING_STOP   UCTXSTP
#define eI2C_STOP_SEND_COMPLETE   0x00

Function Documentation

void eI2C_masterInit ( unsigned int  baseAddress,
unsigned char  selectClockSource,
unsigned long  i2cClk,
unsigned long  dataRate,
unsigned char  byteCounterThreshold,
unsigned char  autoSTOPGeneration 
)

Initializes the I2C Master block.

Parameters:
baseAddressis the base address of the I2C Master module.
selectClockSourceis the clocksource. Valid values are eI2C_CLOCKSOURCE_ACLK eI2C_CLOCKSOURCE_SMCLK
i2cClkis the rate of the clock supplied to the I2C module.
dataRateset up for selecting data transfer rate. Valid values are eI2C_SET_DATA_RATE_400KBPS eI2C_SET_DATA_RATE_100KBPS
byteCounterThresholdsets threshold for automatic STOP or UCSTPIFG
autoSTOPGenerationsets up the STOP condition generation. Valid values are eI2C_NO_AUTO_STOP eI2C_SET_BYTECOUNT_THRESHOLD_FLAG eI2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD

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 eI2C_enable is invoked

If the parameter dataRate is eI2C_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.

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

Returns:
None.

References ASSERT, eI2C_CLOCKSOURCE_ACLK, eI2C_CLOCKSOURCE_SMCLK, eI2C_NO_AUTO_STOP, eI2C_SET_BYTECOUNT_THRESHOLD_FLAG, eI2C_SET_DATA_RATE_100KBPS, eI2C_SET_DATA_RATE_400KBPS, and HWREG.

void eI2C_slaveInit ( unsigned int  baseAddress,
unsigned char  slaveAddress,
unsigned char  slaveAddressOffset,
unsigned long  slaveOwnAddressEnable 
)

Initializes the I2C Slave block.

Parameters:
baseAddressis the base address of the I2C Slave module.
slaveAddress7-bit slave address
slaveAddressOffsetOwn address Offset referred to- 'x' value of UCBxI2COAx. Valid values are eI2C_OWN_ADDRESS_OFFSET0, eI2C_OWN_ADDRESS_OFFSET1, eI2C_OWN_ADDRESS_OFFSET2, eI2C_OWN_ADDRESS_OFFSET3
slaveOwnAddressEnableselects if the specified address is enabled or disabled. Valid values are eI2C_OWN_ADDRESS_DISABLE, eI2C_OWN_ADDRESS_ENABLE

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 eI2C_enable is invoked.

The parameter slaveAddress is the value that will be compared against the slave address sent by an I2C master. Modified bits are UCMODE_3, UCSYNC of UCBxCTL0 register UCSWRST of UCBxCTL1 register UCBxI2COA register

Returns:
None.

References ASSERT, eI2C_OWN_ADDRESS_OFFSET0, eI2C_OWN_ADDRESS_OFFSET1, eI2C_OWN_ADDRESS_OFFSET2, eI2C_OWN_ADDRESS_OFFSET3, and HWREG.

void eI2C_enable ( unsigned int  baseAddress)

Enables the I2C block.

Parameters:
baseAddressis the base address of the USCI I2C module.

This will enable operation of the I2C block. Modified bits are UCSWRST of UCBxCTL1 register.

Returns:
None.

References HWREG.

void eI2C_disable ( unsigned int  baseAddress)

Disables the I2C block.

Parameters:
baseAddressis the base address of the USCI I2C module.

This will disable operation of the I2C block. Modified bits are UCSWRST of UCBxCTL1 register.

Returns:
None.

References HWREG.

void eI2C_setSlaveAddress ( unsigned int  baseAddress,
unsigned char  slaveAddress 
)

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

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

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

Returns:
None.

References HWREG.

void eI2C_setMode ( unsigned int  baseAddress,
unsigned char  mode 
)

Sets the mode of the I2C device

Parameters:
baseAddressis the base address of the I2C Master module.
receiveindicates whether module is in transmit/receive mode

When the receive parameter is set to eI2C_TRANSMIT_MODE, the address will indicate that the I2C module is in receive mode; otherwise, the I2C module is in send mode. Valid values are eI2C_TRANSMIT_MODE eI2C_RECEIVE_MODE [Default value] Modified bits are UCTR of UCBxCTL1 register

Returns:
None.

References ASSERT, eI2C_RECEIVE_MODE, eI2C_TRANSMIT_MODE, and HWREG.

void eI2C_slaveDataPut ( unsigned int  baseAddress,
unsigned char  transmitData 
)

Transmits a byte from the I2C Module.

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

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

Returns:
None.

References HWREG.

unsigned char eI2C_slaveDataGet ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C module.

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

Returns:
Returns the byte received from by the I2C module, cast as an unsigned char. Modified bit is UCBxRXBUF register

References HWREG.

unsigned char eI2C_isBusBusy ( unsigned int  baseAddress)

Indicates whether or not the I2C bus is busy.

Parameters:
baseAddressis the base address of the I2C module.

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.

Returns:
Returns eI2C_BUS_BUSY if the I2C Master is busy; otherwise, returns eI2C_BUS_NOT_BUSY.

References HWREG.

unsigned char eI2C_isBusy ( unsigned int  baseAddress)
void eI2C_enableInterrupt ( unsigned int  baseAddress,
unsigned int  mask 
)

Enables individual I2C interrupt sources.

Parameters:
baseAddressis the base address of the I2C module.
interruptFlagsis the bit mask of the interrupt sources to be enabled.

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.

The mask parameter is the logical OR of any of the following:

  • eI2C_STOP_INTERRUPT - STOP condition interrupt
  • eI2C_START_INTERRUPT - START condition interrupt
  • eI2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
  • eI2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
  • eI2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
  • eI2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
  • eI2C_RECEIVE_INTERRUPT0 - Receive interrupt0
  • eI2C_RECEIVE_INTERRUPT1 - Receive interrupt1
  • eI2C_RECEIVE_INTERRUPT2 - Receive interrupt2
  • eI2C_RECEIVE_INTERRUPT3 - Receive interrupt3
  • eI2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • eI2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
  • eI2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
  • eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt enable
  • eI2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable

Modified registers are UCBxIFG and OFS_UCBxIE.

Returns:
None.

References ASSERT, eI2C_ARBITRATIONLOST_INTERRUPT, eI2C_BIT9_POSITION_INTERRUPT, eI2C_BYTE_COUNTER_INTERRUPT, eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT, eI2C_NAK_INTERRUPT, eI2C_RECEIVE_INTERRUPT0, eI2C_RECEIVE_INTERRUPT1, eI2C_RECEIVE_INTERRUPT2, eI2C_RECEIVE_INTERRUPT3, eI2C_START_INTERRUPT, eI2C_STOP_INTERRUPT, eI2C_TRANSMIT_INTERRUPT0, eI2C_TRANSMIT_INTERRUPT1, eI2C_TRANSMIT_INTERRUPT2, eI2C_TRANSMIT_INTERRUPT3, and HWREG.

void eI2C_disableInterrupt ( unsigned int  baseAddress,
unsigned int  mask 
)

Disables individual I2C interrupt sources.

Parameters:
baseAddressis the base address of the I2C module.
maskis the bit mask of the interrupt sources to be disabled.

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.

The mask parameter is the logical OR of any of the following:

  • eI2C_STOP_INTERRUPT - STOP condition interrupt
  • eI2C_START_INTERRUPT - START condition interrupt
  • eI2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
  • eI2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
  • eI2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
  • eI2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
  • eI2C_RECEIVE_INTERRUPT0 - Receive interrupt0
  • eI2C_RECEIVE_INTERRUPT1 - Receive interrupt1
  • eI2C_RECEIVE_INTERRUPT2 - Receive interrupt2
  • eI2C_RECEIVE_INTERRUPT3 - Receive interrupt3
  • eI2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • eI2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
  • eI2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
  • eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt enable
  • eI2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable

Modified register is UCBxIE.

Returns:
None.

References ASSERT, eI2C_ARBITRATIONLOST_INTERRUPT, eI2C_BIT9_POSITION_INTERRUPT, eI2C_BYTE_COUNTER_INTERRUPT, eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT, eI2C_NAK_INTERRUPT, eI2C_RECEIVE_INTERRUPT0, eI2C_RECEIVE_INTERRUPT1, eI2C_RECEIVE_INTERRUPT2, eI2C_RECEIVE_INTERRUPT3, eI2C_START_INTERRUPT, eI2C_STOP_INTERRUPT, eI2C_TRANSMIT_INTERRUPT0, eI2C_TRANSMIT_INTERRUPT1, eI2C_TRANSMIT_INTERRUPT2, eI2C_TRANSMIT_INTERRUPT3, and HWREG.

void eI2C_clearInterruptFlag ( unsigned int  baseAddress,
unsigned int  mask 
)

Clears I2C interrupt sources.

Parameters:
baseAddressis the base address of the I2C Slave module.
maskis a bit mask of the interrupt sources to be cleared.

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.

The mask parameter has the same definition as the mask parameter to eI2C_enableInterrupt().

Modified register is UCBxIFG.

Returns:
None.

References ASSERT, eI2C_ARBITRATIONLOST_INTERRUPT, eI2C_BIT9_POSITION_INTERRUPT, eI2C_BYTE_COUNTER_INTERRUPT, eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT, eI2C_NAK_INTERRUPT, eI2C_RECEIVE_INTERRUPT0, eI2C_RECEIVE_INTERRUPT1, eI2C_RECEIVE_INTERRUPT2, eI2C_RECEIVE_INTERRUPT3, eI2C_START_INTERRUPT, eI2C_STOP_INTERRUPT, eI2C_TRANSMIT_INTERRUPT0, eI2C_TRANSMIT_INTERRUPT1, eI2C_TRANSMIT_INTERRUPT2, eI2C_TRANSMIT_INTERRUPT3, and HWREG.

unsigned char eI2C_getInterruptStatus ( unsigned int  baseAddress,
unsigned int  mask 
)

Gets the current I2C interrupt status.

Parameters:
baseAddressis the base address of the I2C module.
maskis the masked interrupt flag status to be returned.

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

  • eI2C_STOP_INTERRUPT - STOP condition interrupt
  • eI2C_START_INTERRUPT - START condition interrupt
  • eI2C_TRANSMIT_INTERRUPT0 - Transmit interrupt0
  • eI2C_TRANSMIT_INTERRUPT1 - Transmit interrupt1
  • eI2C_TRANSMIT_INTERRUPT2 - Transmit interrupt2
  • eI2C_TRANSMIT_INTERRUPT3 - Transmit interrupt3
  • eI2C_RECEIVE_INTERRUPT0 - Receive interrupt0
  • eI2C_RECEIVE_INTERRUPT1 - Receive interrupt1
  • eI2C_RECEIVE_INTERRUPT2 - Receive interrupt2
  • eI2C_RECEIVE_INTERRUPT3 - Receive interrupt3
  • eI2C_NAK_INTERRUPT - Not-acknowledge interrupt
  • eI2C_ARBITRATIONLOST_INTERRUPT - Arbitration lost interrupt
  • eI2C_BIT9_POSITION_INTERRUPT - Bit position 9 interrupt enable
  • eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT - Clock low timeout interrupt enable
  • eI2C_BYTE_COUNTER_INTERRUPT - Byte counter interrupt enable

Modified register is UCBxIFG.

Returns:
the masked status of the interrupt flag

References ASSERT, eI2C_ARBITRATIONLOST_INTERRUPT, eI2C_BIT9_POSITION_INTERRUPT, eI2C_BYTE_COUNTER_INTERRUPT, eI2C_CLOCK_LOW_TIMEOUT_INTERRUPT, eI2C_NAK_INTERRUPT, eI2C_RECEIVE_INTERRUPT0, eI2C_RECEIVE_INTERRUPT1, eI2C_RECEIVE_INTERRUPT2, eI2C_RECEIVE_INTERRUPT3, eI2C_START_INTERRUPT, eI2C_STOP_INTERRUPT, eI2C_TRANSMIT_INTERRUPT0, eI2C_TRANSMIT_INTERRUPT1, eI2C_TRANSMIT_INTERRUPT2, eI2C_TRANSMIT_INTERRUPT3, and HWREG.

void eI2C_masterSendSingleByte ( unsigned int  baseAddress,
unsigned char  txData 
)

Does single byte transmission from Master to Slave

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

This function is used by the Master module to send a single byte. This function

  • Sends START
  • Transmits the byte to the Slave
  • Sends STOP

Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE

Returns:
None.

References HWREG.

void eI2C_masterMultiByteSendStart ( unsigned int  baseAddress,
unsigned char  txData 
)

Starts multi-byte transmission from Master to Slave

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

This function is used by the Master module to send a single byte. This function

  • Sends START
  • Transmits the first data byte of a multi-byte transmission to the Slave

Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE

Returns:
None.

References HWREG.

void eI2C_masterMultiByteSendNext ( unsigned int  baseAddress,
unsigned char  txData 
)

Continues multi-byte transmission from Master to Slave

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

This function is used by the Master module continue each byte of a multi-byte trasmission. This function

  • Transmits each data byte of a multi-byte transmission to the Slave

Modified registers are UCBxTXBUF

Returns:
None.

References HWREG.

void eI2C_masterMultiByteSendFinish ( unsigned int  baseAddress,
unsigned char  txData 
)

Finishes multi-byte transmission from Master to Slave

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

This function is used by the Master module to send the last byte and STOP. This function

  • Transmits the last data byte of a multi-byte transmission to the Slave
  • Sends STOP

Modified registers are UCBxTXBUF and UCBxCTL1.

Returns:
None.

References HWREG.

void eI2C_masterMultiByteSendStop ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C Master module.

This function is used by the Master module send STOP at the end of a multi-byte trasmission

This function

  • Send a STOP after current transmission is complete

Modified bits are UCTXSTP bit of UCBxCTL1.

Returns:
None.

References HWREG.

void eI2C_masterReceiveStart ( unsigned int  baseAddress)

Starts reception at the Master end

Parameters:
baseAddressis the base address of the I2C Master module.

This function is used by the Master module initiate reception of a single byte. This function

  • Sends START

Modified bits are UCTXSTT bit of UCBxCTL1.

Returns:
None.

References HWREG.

unsigned char eI2C_masterMultiByteReceiveNext ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C Master module.

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

Modified register is UCBxRXBUF.

Returns:
Received byte at Master end.

References HWREG.

unsigned char eI2C_masterMultiByteReceiveFinish ( unsigned int  baseAddress)

Finishes multi-byte reception at the Master end

Parameters:
baseAddressis the base address of the I2C Master module.

This function is used by the Master module to initiate completion of a multi-byte reception This function

  • Receives the current byte and initiates the STOP from Master to Slave

Modified bits are UCTXSTP bit of UCBxCTL1.

Returns:
Received byte at Master end.

References HWREG.

void eI2C_masterMultiByteReceiveStop ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C Master module.

This function is used by the Master module to initiate STOP

Modified bits are UCTXSTP bit of UCBxCTL1.

Returns:
None.

References HWREG.

unsigned char eI2C_masterSingleReceive ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C module.

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

Returns:
Returns the byte received from by the I2C module, cast as an unsigned char.

References HWREG.

unsigned long eI2C_getReceiveBufferAddressForDMA ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C 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.

Returns:
NONE
unsigned long eI2C_getTransmitBufferAddressForDMA ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the I2C 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.

Returns:
NONE
unsigned char eI2C_masterIsSTOPSent ( unsigned int  baseAddress)

Indicates whether STOP got sent.

Parameters:
baseAddressis the base address of the I2C module.

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.

Returns:
Returns eI2C_STOP_SEND_COMPLETE if the I2C Master is busy; otherwise, returns eI2C_SENDING_STOP.

References HWREG.

void eI2C_masterSendStart ( unsigned int  baseAddress)

This function is used by the Master module to initiate START

Parameters:
baseAddressis the base address of the I2C Master module.

This function is used by the Master module to initiate STOP

Modified bits are UCTXSTT bit of UCBxCTLW0.

Returns:
None.

References HWREG.

void eI2C_enableMultiMasterMode ( unsigned int  baseAddress)

Enables Multi Master Mode

Parameters:
baseAddressis the base address of the I2C module.

At the end of this function, the I2C module is still disabled till eI2C_enable is invoked

Modified bits are UCSWRST of OFS_UCBxCTLW0, UCMM bit of UCBxCTLW0

Returns:
None.

References HWREG.

void eI2C_disableMultiMasterMode ( unsigned int  baseAddress)

Disables Multi Master Mode

Parameters:
baseAddressis the base address of the I2C module.

At the end of this function, the I2C module is still disabled till eI2C_enable is invoked

Modified bits are UCSWRST of OFS_UCBxCTLW0, UCMM bit of UCBxCTLW0

Returns:
None.

References HWREG.


Copyright 2012, Texas Instruments Incorporated