#include "inc/hw_types.h"
#include "driverlib/5xx_6xx/debug.h"
#include "driverlib/5xx_6xx/i2c.h"
#include "deprecated/CCS/msp430xgeneric.h"
Functions | |
void | I2C_masterInit (unsigned int baseAddress, unsigned char selectClockSource, unsigned long i2cClk, unsigned long dataRate) |
void | I2C_slaveInit (unsigned int baseAddress, unsigned char slaveAddress) |
void | I2C_enable (unsigned int baseAddress) |
void | I2C_disable (unsigned int baseAddress) |
void | I2C_setSlaveAddress (unsigned int baseAddress, unsigned char slaveAddress) |
void | I2C_setMode (unsigned int baseAddress, unsigned char mode) |
void | I2C_slaveDataPut (unsigned int baseAddress, unsigned char transmitData) |
unsigned char | I2C_slaveDataGet (unsigned int baseAddress) |
unsigned char | I2C_isBusBusy (unsigned int baseAddress) |
unsigned char | I2C_isBusy (unsigned int baseAddress) |
unsigned char | I2C_masterIsSTOPSent (unsigned int baseAddress) |
void | I2C_masterSendStart (unsigned int baseAddress) |
void | I2C_enableInterrupt (unsigned int baseAddress, unsigned char mask) |
void | I2C_disableInterrupt (unsigned int baseAddress, unsigned char mask) |
void | I2C_clearInterruptFlag (unsigned int baseAddress, unsigned char mask) |
unsigned char | I2C_getInterruptStatus (unsigned int baseAddress, unsigned char mask) |
void | I2C_masterSendSingleByte (unsigned int baseAddress, unsigned char txData) |
void | I2C_masterMultiByteSendStart (unsigned int baseAddress, unsigned char txData) |
void | I2C_masterMultiByteSendNext (unsigned int baseAddress, unsigned char txData) |
void | I2C_masterMultiByteSendFinish (unsigned int baseAddress, unsigned char txData) |
void | I2C_masterMultiByteSendStop (unsigned int baseAddress) |
void | I2C_masterMultiByteReceiveStart (unsigned int baseAddress) |
unsigned char | I2C_masterMultiByteReceiveNext (unsigned int baseAddress) |
unsigned char | I2C_masterMultiByteReceiveFinish (unsigned int baseAddress) |
void | I2C_masterMultiByteReceiveStop (unsigned int baseAddress) |
void | I2C_masterSingleReceiveStart (unsigned int baseAddress) |
unsigned char | I2C_masterSingleReceive (unsigned int baseAddress) |
unsigned long | I2C_getReceiveBufferAddressForDMA (unsigned int baseAddress) |
unsigned long | I2C_getTransmitBufferAddressForDMA (unsigned int baseAddress) |
void I2C_masterInit | ( | unsigned int | baseAddress, |
unsigned char | selectClockSource, | ||
unsigned long | i2cClk, | ||
unsigned long | dataRate | ||
) |
Initializes the I2C Master block.
baseAddress | is the base address of the I2C Master module. |
selectClockSource | is the clocksource. Valid values are I2C_CLOCKSOURCE_ACLK I2C_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 I2C_SET_DATA_RATE_400KBPS I2C_SET_DATA_RATE_100KBPS |
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 I2C_enable is invoked
If the parameter dataRate is 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.
Modified bits are UCMST,UCMODE_3,UCSYNC of UCBxCTL0 register UCSSELx, UCSWRST, of UCBxCTL1 register UCBxBR0 and UCBxBR1 regsiters
References ASSERT, HWREG, HWREGB, I2C_CLOCKSOURCE_ACLK, I2C_CLOCKSOURCE_SMCLK, I2C_SET_DATA_RATE_100KBPS, and I2C_SET_DATA_RATE_400KBPS.
void I2C_slaveInit | ( | unsigned int | baseAddress, |
unsigned char | slaveAddress | ||
) |
Initializes the I2C Slave block.
baseAddress | is the base address of the I2C Slave module. |
slaveAddress | 7-bit slave address |
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 I2C_enable is invoked.
The parameter slaveAddress is the value that will be compared against the slave address sent by an I2C master. Modified buts are UCMODE_3, UCSYNC of UCBxCTL0 register UCSWRST of UCBxCTL1 register UCBxI2COA register
void I2C_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 HWREGB.
void I2C_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 HWREGB.
void I2C_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 bits are UCSWRST of UCBxCTL1 register UCBxI2CSA register
References HWREG.
void I2C_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 I2C_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 I2C_TRANSMIT_MODE I2C_RECEIVE_MODE [Default value] Modified bits are UCTR of UCBxCTL1 register
References ASSERT, HWREGB, I2C_RECEIVE_MODE, and I2C_TRANSMIT_MODE.
void I2C_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 HWREGB.
unsigned char I2C_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 HWREGB.
unsigned char I2C_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 HWREGB.
unsigned char I2C_isBusy | ( | unsigned int | baseAddress | ) |
DEPRECATED - Function may be removed in future release. Indicates whether or not the I2C module is busy.
baseAddress | is the base address of the I2C module. |
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.
References HWREGB, I2C_BUS_BUSY, and I2C_BUS_NOT_BUSY.
unsigned char I2C_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 HWREGB.
void I2C_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 UCBxCTL1.
References HWREGB.
void I2C_enableInterrupt | ( | unsigned int | baseAddress, |
unsigned char | 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, HWREG, HWREGB, I2C_ARBITRATIONLOST_INTERRUPT, I2C_NAK_INTERRUPT, I2C_RECEIVE_INTERRUPT, I2C_START_INTERRUPT, I2C_STOP_INTERRUPT, and I2C_TRANSMIT_INTERRUPT.
void I2C_disableInterrupt | ( | unsigned int | baseAddress, |
unsigned char | 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, HWREGB, I2C_ARBITRATIONLOST_INTERRUPT, I2C_NAK_INTERRUPT, I2C_RECEIVE_INTERRUPT, I2C_START_INTERRUPT, I2C_STOP_INTERRUPT, and I2C_TRANSMIT_INTERRUPT.
void I2C_clearInterruptFlag | ( | unsigned int | baseAddress, |
unsigned char | 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 I2C_enableInterrupt().
Modified register is UCBxIFG.
References ASSERT, HWREGB, I2C_ARBITRATIONLOST_INTERRUPT, I2C_NAK_INTERRUPT, I2C_RECEIVE_INTERRUPT, I2C_START_INTERRUPT, I2C_STOP_INTERRUPT, and I2C_TRANSMIT_INTERRUPT.
unsigned char I2C_getInterruptStatus | ( | unsigned int | baseAddress, |
unsigned char | 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, HWREGB, I2C_ARBITRATIONLOST_INTERRUPT, I2C_NAK_INTERRUPT, I2C_RECEIVE_INTERRUPT, I2C_START_INTERRUPT, I2C_STOP_INTERRUPT, and I2C_TRANSMIT_INTERRUPT.
void I2C_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 HWREGB.
void I2C_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 HWREGB.
void I2C_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 HWREGB.
void I2C_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 HWREGB.
void I2C_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 HWREGB.
void I2C_masterMultiByteReceiveStart | ( | unsigned int | baseAddress | ) |
Starts 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 initiate reception of a single byte. This function
Modified bits are UCTXSTT bit of UCBxCTL1.
References HWREGB.
unsigned char I2C_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 HWREGB.
unsigned char I2C_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 HWREGB.
void I2C_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 HWREGB.
void I2C_masterSingleReceiveStart | ( | unsigned int | baseAddress | ) |
Initiates a single byte Reception at the Master End
baseAddress | is the base address of the I2C Master module. |
This function sends a START and STOP immediately to indicate Single byte reception
Modified bits are UCTXSTT and UCTXSTP of UCBxCTL1, GIE
References HWREGB.
unsigned char I2C_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 HWREGB.
unsigned long I2C_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 I2C_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.