#include "inc/hw_types.h"
#include "driverlib/5xx_6xx/debug.h"
#include "driverlib/5xx_6xx/ei2c.h"
#include "deprecated/CCS/msp430xgeneric.h"
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_masterIsSTOPSent (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_masterSendStart (unsigned int baseAddress) |
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) |
void | eI2C_enableMultiMasterMode (unsigned int baseAddress) |
void | eI2C_disableMultiMasterMode (unsigned int baseAddress) |
unsigned char | eI2C_masterSingleReceive (unsigned int baseAddress) |
unsigned long | eI2C_getReceiveBufferAddressForDMA (unsigned int baseAddress) |
unsigned long | eI2C_getTransmitBufferAddressForDMA (unsigned int baseAddress) |
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.
baseAddress | is the base address of the I2C Master module. |
selectClockSource | is the clocksource. Valid values are eI2C_CLOCKSOURCE_ACLK eI2C_CLOCKSOURCE_SMCLK |
i2cClk | is the rate of the clock supplied to the I2C module. |
dataRate | set up for selecting data transfer rate. Valid values are eI2C_SET_DATA_RATE_400KBPS eI2C_SET_DATA_RATE_100KBPS |
byteCounterThreshold | sets threshold for automatic STOP or UCSTPIFG |
autoSTOPGeneration | sets 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
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.
baseAddress | is the base address of the I2C Slave module. |
slaveAddress | 7-bit slave address |
slaveAddressOffset | Own 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 |
slaveOwnAddressEnable | selects 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
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.
baseAddress | is the base address of the USCI I2C module. |
This will enable operation of the I2C block. Modified bits are UCSWRST of UCBxCTL1 register.
References HWREG.
void eI2C_disable | ( | unsigned int | baseAddress | ) |
Disables the I2C block.
baseAddress | is the base address of the USCI I2C module. |
This will disable operation of the I2C block. Modified bits are UCSWRST of UCBxCTL1 register.
References HWREG.
void eI2C_setSlaveAddress | ( | unsigned int | baseAddress, |
unsigned char | slaveAddress | ||
) |
Sets the address that the I2C Master will place on the bus.
baseAddress | is the base address of the I2C Master module. |
slaveAddress | 7-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
References HWREG.
void eI2C_setMode | ( | unsigned int | baseAddress, |
unsigned char | mode | ||
) |
Sets the mode of the I2C device
baseAddress | is the base address of the I2C Master module. |
receive | indicates 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
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.
baseAddress | is the base address of the I2C module. |
transmitData | data 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
References HWREG.
unsigned char eI2C_slaveDataGet | ( | unsigned int | baseAddress | ) |
Receives a byte that has been sent to the I2C Module.
baseAddress | is the base address of the I2C module. |
This function reads a byte of data from the I2C receive data Register.
References HWREG.
unsigned char eI2C_isBusBusy | ( | unsigned int | baseAddress | ) |
Indicates whether or not the I2C bus is busy.
baseAddress | is 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.
References HWREG.
unsigned char eI2C_masterIsSTOPSent | ( | unsigned int | baseAddress | ) |
Indicates whether STOP got sent.
baseAddress | is 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.
References HWREG.
void eI2C_enableInterrupt | ( | unsigned int | baseAddress, |
unsigned int | mask | ||
) |
Enables individual I2C interrupt sources.
baseAddress | is the base address of the I2C module. |
interruptFlags | is 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:
Modified registers are UCBxIFG and OFS_UCBxIE.
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.
baseAddress | is the base address of the I2C module. |
mask | is 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:
Modified register is UCBxIE.
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.
baseAddress | is the base address of the I2C Slave module. |
mask | is 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.
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.
baseAddress | is the base address of the I2C module. |
mask | is 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.
Modified register is UCBxIFG.
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
baseAddress | is the base address of the I2C Master module. |
txData | is the data byte to be transmitted |
This function is used by the Master module to send a single byte. This function
Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE
References HWREG.
void eI2C_masterMultiByteSendStart | ( | unsigned int | baseAddress, |
unsigned char | txData | ||
) |
Starts multi-byte transmission from Master to Slave
baseAddress | is the base address of the I2C Master module. |
txData | is the first data byte to be transmitted |
This function is used by the Master module to send a single byte. This function
Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE
References HWREG.
void eI2C_masterMultiByteSendNext | ( | unsigned int | baseAddress, |
unsigned char | txData | ||
) |
Continues multi-byte transmission from Master to Slave
baseAddress | is the base address of the I2C Master module. |
txData | is 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
Modified registers are UCBxTXBUF
References HWREG.
void eI2C_masterMultiByteSendFinish | ( | unsigned int | baseAddress, |
unsigned char | txData | ||
) |
Finishes multi-byte transmission from Master to Slave
baseAddress | is the base address of the I2C Master module. |
txData | is 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
Modified registers are UCBxTXBUF and UCBxCTL1.
References HWREG.
void eI2C_masterSendStart | ( | unsigned int | baseAddress | ) |
This function is used by the Master module to initiate START
baseAddress | is 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.
References HWREG.
void eI2C_masterMultiByteSendStop | ( | unsigned int | baseAddress | ) |
Send STOP byte at the end of a multi-byte transmission from Master to Slave
baseAddress | is 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
Modified bits are UCTXSTP bit of UCBxCTL1.
References HWREG.
void eI2C_masterReceiveStart | ( | unsigned int | baseAddress | ) |
Starts reception at the Master end
baseAddress | is the base address of the I2C Master module. |
This function is used by the Master module initiate reception of a single byte. This function
Modified bits are UCTXSTT bit of UCBxCTL1.
References HWREG.
unsigned char eI2C_masterMultiByteReceiveNext | ( | unsigned int | baseAddress | ) |
Starts multi-byte reception at the Master end one byte at a time
baseAddress | is 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.
References HWREG.
unsigned char eI2C_masterMultiByteReceiveFinish | ( | unsigned int | baseAddress | ) |
Finishes multi-byte reception at the Master end
baseAddress | is 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
Modified bits are UCTXSTP bit of UCBxCTL1.
References HWREG.
void eI2C_masterMultiByteReceiveStop | ( | unsigned int | baseAddress | ) |
Sends the STOP at the end of a multi-byte reception at the Master end
baseAddress | is 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.
References HWREG.
void eI2C_enableMultiMasterMode | ( | unsigned int | baseAddress | ) |
Enables Multi Master Mode
baseAddress | is 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
References HWREG.
void eI2C_disableMultiMasterMode | ( | unsigned int | baseAddress | ) |
Disables Multi Master Mode
baseAddress | is 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
References HWREG.
unsigned char eI2C_masterSingleReceive | ( | unsigned int | baseAddress | ) |
Receives a byte that has been sent to the I2C Master Module.
baseAddress | is the base address of the I2C module. |
This function reads a byte of data from the I2C receive data Register.
References HWREG.
unsigned long eI2C_getReceiveBufferAddressForDMA | ( | unsigned int | baseAddress | ) |
Returns the address of the RX Buffer of the I2C for the DMA module.
baseAddress | is 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.
unsigned long eI2C_getTransmitBufferAddressForDMA | ( | unsigned int | baseAddress | ) |
Returns the address of the TX Buffer of the I2C for the DMA module.
baseAddress | is 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.