eUSCI Inter-Integrated Circuit (I2C) serial communication module. More...
Data Structures | |
struct | eUSCI_I2C_MasterConfig |
struct | _eUSCI_I2C_MasterConfig |
Type definition for _eUSCI_I2C_MasterConfig structure. More... | |
Functions | |
void | I2C_initMaster (uint32_t moduleInstance, const eUSCI_I2C_MasterConfig *config) |
void | I2C_initSlave (uint32_t moduleInstance, uint_fast16_t slaveAddress, uint_fast8_t slaveAddressOffset, uint32_t slaveOwnAddressEnable) |
void | I2C_enableModule (uint32_t moduleInstance) |
void | I2C_disableModule (uint32_t moduleInstance) |
void | I2C_setSlaveAddress (uint32_t moduleInstance, uint_fast16_t slaveAddress) |
void | I2C_setMode (uint32_t moduleInstance, uint_fast8_t mode) |
void | I2C_setTimeout (uint32_t moduleInstance, uint_fast16_t timeout) |
uint_fast8_t | I2C_getMode (uint32_t moduleInstance) |
Gets the mode of the I2C device. More... | |
void | I2C_slavePutData (uint32_t moduleInstance, uint8_t transmitData) |
uint8_t | I2C_slaveGetData (uint32_t moduleInstance) |
uint8_t | I2C_isBusBusy (uint32_t moduleInstance) |
void | I2C_masterSendSingleByte (uint32_t moduleInstance, uint8_t txData) |
bool | I2C_masterSendSingleByteWithTimeout (uint32_t moduleInstance, uint8_t txData, uint32_t timeout) |
void | I2C_masterSendMultiByteStart (uint32_t moduleInstance, uint8_t txData) |
bool | I2C_masterSendMultiByteStartWithTimeout (uint32_t moduleInstance, uint8_t txData, uint32_t timeout) |
void | I2C_masterSendMultiByteNext (uint32_t moduleInstance, uint8_t txData) |
bool | I2C_masterSendMultiByteNextWithTimeout (uint32_t moduleInstance, uint8_t txData, uint32_t timeout) |
bool | I2C_masterSendMultiByteFinish (uint32_t moduleInstance, uint8_t txData) |
bool | I2C_masterSendMultiByteFinishWithTimeout (uint32_t moduleInstance, uint8_t txData, uint32_t timeout) |
void | I2C_masterSendMultiByteStop (uint32_t moduleInstance) |
bool | I2C_masterSendMultiByteStopWithTimeout (uint32_t moduleInstance, uint32_t timeout) |
void | I2C_masterReceiveStart (uint32_t moduleInstance) |
uint8_t | I2C_masterReceiveMultiByteNext (uint32_t moduleInstance) |
uint8_t | I2C_masterReceiveMultiByteFinish (uint32_t moduleInstance) |
bool | I2C_masterReceiveMultiByteFinishWithTimeout (uint32_t moduleInstance, uint8_t *txData, uint32_t timeout) |
void | I2C_masterReceiveMultiByteStop (uint32_t moduleInstance) |
uint8_t | I2C_masterReceiveSingleByte (uint32_t moduleInstance) |
uint8_t | I2C_masterReceiveSingle (uint32_t moduleInstance) |
uint32_t | I2C_getReceiveBufferAddressForDMA (uint32_t moduleInstance) |
uint32_t | I2C_getTransmitBufferAddressForDMA (uint32_t moduleInstance) |
uint8_t | I2C_masterIsStopSent (uint32_t moduleInstance) |
bool | I2C_masterIsStartSent (uint32_t moduleInstance) |
void | I2C_masterSendStart (uint32_t moduleInstance) |
void | I2C_enableMultiMasterMode (uint32_t moduleInstance) |
void | I2C_disableMultiMasterMode (uint32_t moduleInstance) |
void | I2C_enableInterrupt (uint32_t moduleInstance, uint_fast16_t mask) |
void | I2C_disableInterrupt (uint32_t moduleInstance, uint_fast16_t mask) |
void | I2C_clearInterruptFlag (uint32_t moduleInstance, uint_fast16_t mask) |
uint_fast16_t | I2C_getInterruptStatus (uint32_t moduleInstance, uint16_t mask) |
uint_fast16_t | I2C_getEnabledInterruptStatus (uint32_t moduleInstance) |
void | I2C_registerInterrupt (uint32_t moduleInstance, void(*intHandler)(void)) |
void | I2C_unregisterInterrupt (uint32_t moduleInstance) |
void | I2C_slaveSendNAK (uint32_t moduleInstance) |
eUSCI Inter-Integrated Circuit (I2C) serial communication module.
In I2C mode, the eUSCI_B module provides an interface between the device and I2C-compatible devices connected by the two-wire I2C serial bus. External components attached to the I2C bus serially transmit and/or receive serial data to/from the eUSCI_B module through the 2-wire I2C interface. The Inter-Integrated Circuit (I2C) API provides a set of functions for using the SDK I2C modules. Functions are provided to initialize the I2C modules, to send and receive data, obtain status, and to manage interrupts for the I2C modules. For the sake of simplicity and code readability, the EUSCI_B module name has been omitted from the API name space.
The I2C module provide the ability to communicate to other IC devices over an I2C bus. The I2C bus is specified to support devices that can both transmit and receive (write and read) data. Also, devices on the I2C bus can be designated as either a master or a slave. The SDK L I2C modules support both sending and receiving data as either a master or a slave, and also support the simultaneous operation as both a master and a slave.
I2C module can generate interrupts. The I2C module configured as a master will generate interrupts when a transmit or receive operation is completed (or aborted due to an error). The I2C module configured as a slave will generate interrupts when data has been sent or requested by a master.
The user must first initialize the I2C module and configure it as a master with a call to I2C_initMaster . That function will set the clock and data rates. This is followed by a call to set the slave address with which the master intends to communicate with using I2C_setSlaveAddress . Then the mode of operation (transmit or receive) is chosen using I2C_setMode . The I2C module may now be enabled using I2C_enableModule . It is recommended to enable the I2C module before enabling the interrupts. Any transmission or reception of data may be initiated at this point after interrupts are enabled (if any).
The transaction can then be initiated on the bus by calling the transmit or receive related APIs as listed below.
Master Single Byte Transmission
Master Multiple Byte Transmission
Master Single Byte Reception
Master Multiple Byte Reception
For the interrupt-driven transaction, the user must register an interrupt handler for the I2C devices and enable the I2C interrupt.
The user must first call the I2C_initSlave to initialize the slave module in I2C mode and set the slave address. This is followed by a call to set the mode of operation (transmit or receive). The I2C module may now be enabled using I2C_enableModule . It is recommended to enable the I2C module before enabling the interrupts. Any transmission or reception of data may be initiated at this point after interrupts are enabled (if any).
The transaction can then be initiated on the bus by calling the transmit or receive related APIs as listed below.
Slave Transmission API
Slave Reception API
For the interrupt-driven transaction, the user must register an interrupt handler for the I2C devices and enable the I2C interrupt.
Below is a simple example of how to setup the I2C module for master operation with a 400KHz clock.
First, below is an example of setting up the I2C module configuration structure:
Below are the actual DriverLib calls to configure/setup the I2C module:
#define EUSCI_B_I2C_NO_AUTO_STOP EUSCI_B_CTLW1_ASTP_0 |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_SET_BYTECOUNT_THRESHOLD_FLAG EUSCI_B_CTLW1_ASTP_1 |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD EUSCI_B_CTLW1_ASTP_2 |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_SET_DATA_RATE_1MBPS 1000000 |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_SET_DATA_RATE_400KBPS 400000 |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_SET_DATA_RATE_100KBPS 100000 |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_CLOCKSOURCE_ACLK EUSCI_B_CTLW0_SSEL__ACLK |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_CLOCKSOURCE_SMCLK EUSCI_B_CTLW0_SSEL__SMCLK |
Referenced by I2C_initMaster().
#define EUSCI_B_I2C_OWN_ADDRESS_OFFSET0 0x00 |
Referenced by I2C_initSlave().
#define EUSCI_B_I2C_OWN_ADDRESS_OFFSET1 0x02 |
Referenced by I2C_initSlave().
#define EUSCI_B_I2C_OWN_ADDRESS_OFFSET2 0x04 |
Referenced by I2C_initSlave().
#define EUSCI_B_I2C_OWN_ADDRESS_OFFSET3 0x06 |
Referenced by I2C_initSlave().
#define EUSCI_B_I2C_OWN_ADDRESS_DISABLE 0x00 |
#define EUSCI_B_I2C_OWN_ADDRESS_ENABLE EUSCI_B_I2COA0_OAEN |
#define EUSCI_B_I2C_TRANSMIT_MODE EUSCI_B_CTLW0_TR |
Referenced by I2C_setMode().
#define EUSCI_B_I2C_RECEIVE_MODE 0x00 |
Referenced by I2C_setMode().
#define EUSCI_B_I2C_TIMEOUT_DISABLE EUSCI_B_CTLW1_CLTO_0 |
Referenced by I2C_setTimeout().
#define EUSCI_B_I2C_TIMEOUT_28_MS EUSCI_B_CTLW1_CLTO_1 |
Referenced by I2C_setTimeout().
#define EUSCI_B_I2C_TIMEOUT_31_MS EUSCI_B_CTLW1_CLTO_2 |
Referenced by I2C_setTimeout().
#define EUSCI_B_I2C_TIMEOUT_34_MS EUSCI_B_CTLW1_CLTO_3 |
Referenced by I2C_setTimeout().
#define EUSCI_B_I2C_NAK_INTERRUPT EUSCI_B_IE_NACKIE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT EUSCI_B_IE_ALIE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_STOP_INTERRUPT EUSCI_B_IE_STPIE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_START_INTERRUPT EUSCI_B_IE_STTIE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_TRANSMIT_INTERRUPT0 EUSCI_B_IE_TXIE0 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_TRANSMIT_INTERRUPT1 EUSCI_B_IE_TXIE1 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_TRANSMIT_INTERRUPT2 EUSCI_B_IE_TXIE2 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_TRANSMIT_INTERRUPT3 EUSCI_B_IE_TXIE3 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_RECEIVE_INTERRUPT0 EUSCI_B_IE_RXIE0 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_RECEIVE_INTERRUPT1 EUSCI_B_IE_RXIE1 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_RECEIVE_INTERRUPT2 EUSCI_B_IE_RXIE2 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_RECEIVE_INTERRUPT3 EUSCI_B_IE_RXIE3 |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_BIT9_POSITION_INTERRUPT EUSCI_B_IE_BIT9IE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT EUSCI_B_IE_CLTOIE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT EUSCI_B_IE_BCNTIE |
Referenced by I2C_clearInterruptFlag(), I2C_disableInterrupt(), I2C_enableInterrupt(), and I2C_getInterruptStatus().
#define EUSCI_B_I2C_BUS_BUSY EUSCI_B_STATW_BBUSY |
#define EUSCI_B_I2C_BUS_NOT_BUSY 0x00 |
#define EUSCI_B_I2C_STOP_SEND_COMPLETE 0x00 |
#define EUSCI_B_I2C_SENDING_STOP EUSCI_B_CTLW0_TXSTP |
#define EUSCI_B_I2C_START_SEND_COMPLETE 0x00 |
#define EUSCI_B_I2C_SENDING_START EUSCI_B_CTLW0_TXSTT |
#define EUSCI_B_I2C_slaveInit I2C_initSlave |
#define EUSCI_B_I2C_enable I2C_enableModule |
#define EUSCI_B_I2C_disable I2C_disableModule |
#define EUSCI_B_I2C_setSlaveAddress I2C_setSlaveAddress |
#define EUSCI_B_I2C_setMode I2C_setMode |
#define EUSCI_B_I2C_getMode I2C_getMode |
#define EUSCI_B_I2C_slaveDataPut I2C_slavePutData |
#define EUSCI_B_I2C_slaveDataGet I2C_slaveGetData |
#define EUSCI_B_I2C_isBusBusy I2C_isBusBusy |
#define EUSCI_B_I2C_masterIsStopSent I2C_masterIsStopSent |
#define EUSCI_B_I2C_masterIsStartSent I2C_masterIsStartSent |
#define EUSCI_B_I2C_enableInterrupt I2C_enableInterrupt |
#define EUSCI_B_I2C_disableInterrupt I2C_disableInterrupt |
#define EUSCI_B_I2C_clearInterruptFlag I2C_clearInterruptFlag |
#define EUSCI_B_I2C_getInterruptStatus I2C_getEnabledInterruptStatus |
#define EUSCI_B_I2C_masterSendSingleByte I2C_masterSendSingleByte |
#define EUSCI_B_I2C_masterReceiveSingleByte I2C_masterReceiveSingleByte |
#define EUSCI_B_I2C_masterSendSingleByteWithTimeout I2C_masterSendSingleByteWithTimeout |
#define EUSCI_B_I2C_masterMultiByteSendStart I2C_masterSendMultiByteStart |
#define EUSCI_B_I2C_masterMultiByteSendStartWithTimeout I2C_masterSendMultiByteStartWithTimeout |
#define EUSCI_B_I2C_masterMultiByteSendNext I2C_masterSendMultiByteNext |
#define EUSCI_B_I2C_masterMultiByteSendNextWithTimeout I2C_masterSendMultiByteNextWithTimeout |
#define EUSCI_B_I2C_masterMultiByteSendFinish I2C_masterSendMultiByteFinish |
#define EUSCI_B_I2C_masterMultiByteSendFinishWithTimeout I2C_masterSendMultiByteFinishWithTimeout |
#define EUSCI_B_I2C_masterSendStart I2C_masterSendStart |
#define EUSCI_B_I2C_masterMultiByteSendStop I2C_masterSendMultiByteStop |
#define EUSCI_B_I2C_masterMultiByteSendStopWithTimeout I2C_masterSendMultiByteStopWithTimeout |
#define EUSCI_B_I2C_masterReceiveStart I2C_masterReceiveStart |
#define EUSCI_B_I2C_masterMultiByteReceiveNext I2C_masterReceiveMultiByteNext |
#define EUSCI_B_I2C_masterMultiByteReceiveFinish I2C_masterReceiveMultiByteFinish |
#define EUSCI_B_I2C_masterMultiByteReceiveFinishWithTimeout I2C_masterReceiveMultiByteFinishWithTimeout |
#define EUSCI_B_I2C_masterMultiByteReceiveStop I2C_masterReceiveMultiByteStop |
#define EUSCI_B_I2C_enableMultiMasterMode I2C_enableMultiMasterMode |
#define EUSCI_B_I2C_disableMultiMasterMode I2C_disableMultiMasterMode |
#define EUSCI_B_I2C_masterSingleReceive I2C_masterReceiveSingle |
#define EUSCI_B_I2C_getReceiveBufferAddressForDMA I2C_getReceiveBufferAddressForDMA |
#define EUSCI_B_I2C_getTransmitBufferAddressForDMA I2C_getTransmitBufferAddressForDMA |
void I2C_initMaster | ( | uint32_t | moduleInstance, |
const eUSCI_I2C_MasterConfig * | config | ||
) |
Initializes the I2C Master block.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
config | Configuration structure for I2C master mode |
Configuration options for eUSCI_I2C_MasterConfig structure.
selectClockSource | is the clock source. Valid values are
|
i2cClk | is the rate of the clock supplied to the I2C module (the frequency in Hz of the clock source specified in selectClockSource). |
dataRate | set up for selecting data transfer rate. Valid values are
|
byteCounterThreshold | sets threshold for automatic STOP or UCSTPIFG |
autoSTOPGeneration | sets up the STOP condition generation. Valid values are
|
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_enableModule is invoked
Modified bits are UCMST,UCMODE_3,UCSYNC of UCBxCTL0 register UCSSELx, UCSWRST, of UCBxCTL1 register UCBxBR0 and UCBxBR1 registers
References ASSERT, eUSCI_I2C_MasterConfig::autoSTOPGeneration, eUSCI_I2C_MasterConfig::byteCounterThreshold, eUSCI_I2C_MasterConfig::dataRate, EUSCI_B_CMSIS, EUSCI_B_I2C_CLOCKSOURCE_ACLK, EUSCI_B_I2C_CLOCKSOURCE_SMCLK, EUSCI_B_I2C_NO_AUTO_STOP, EUSCI_B_I2C_SEND_STOP_AUTOMATICALLY_ON_BYTECOUNT_THRESHOLD, EUSCI_B_I2C_SET_BYTECOUNT_THRESHOLD_FLAG, EUSCI_B_I2C_SET_DATA_RATE_100KBPS, EUSCI_B_I2C_SET_DATA_RATE_1MBPS, EUSCI_B_I2C_SET_DATA_RATE_400KBPS, eUSCI_I2C_MasterConfig::i2cClk, and eUSCI_I2C_MasterConfig::selectClockSource.
void I2C_initSlave | ( | uint32_t | moduleInstance, |
uint_fast16_t | slaveAddress, | ||
uint_fast8_t | slaveAddressOffset, | ||
uint32_t | slaveOwnAddressEnable | ||
) |
Initializes the I2C Slave block.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
slaveAddress | 7-bit or 10-bit slave address |
slaveAddressOffset | Own address Offset referred to- 'x' value of UCBxI2COAx. Valid values are:
|
slaveOwnAddressEnable | selects if the specified address is enabled or disabled. Valid values are:
|
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_enableModule 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, EUSCI_B_CMSIS, EUSCI_B_I2C_OWN_ADDRESS_OFFSET0, EUSCI_B_I2C_OWN_ADDRESS_OFFSET1, EUSCI_B_I2C_OWN_ADDRESS_OFFSET2, EUSCI_B_I2C_OWN_ADDRESS_OFFSET3, and HWREG16.
void I2C_enableModule | ( | uint32_t | moduleInstance | ) |
Enables the I2C block.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This will enable operation of the I2C block. Modified bits are UCSWRST of UCBxCTL1 register.
References EUSCI_B_CMSIS.
void I2C_disableModule | ( | uint32_t | moduleInstance | ) |
Disables the I2C block.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This will disable operation of the I2C block. Modified bits are UCSWRST of UCBxCTL1 register.
References EUSCI_B_CMSIS.
void I2C_setSlaveAddress | ( | uint32_t | moduleInstance, |
uint_fast16_t | slaveAddress | ||
) |
Sets the address that the I2C Master will place on the bus.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
slaveAddress | 7-bit or 10-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 EUSCI_B_CMSIS.
void I2C_setMode | ( | uint32_t | moduleInstance, |
uint_fast8_t | mode | ||
) |
Sets the mode of the I2C device
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
mode | indicates whether module is in transmit/receive mode
|
Modified bits are UCTR of UCBxCTL1 register
References ASSERT, EUSCI_B_CMSIS, EUSCI_B_I2C_RECEIVE_MODE, and EUSCI_B_I2C_TRANSMIT_MODE.
void I2C_setTimeout | ( | uint32_t | moduleInstance, |
uint_fast16_t | timeout | ||
) |
Sets the timeout of the I2C device
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
timeout | indicates desired timeout
|
Modified bits are UCSWRST of UCBxCTL0 and UCCLTO of UCBxCTL1 registers
References ASSERT, EUSCI_B_CMSIS, EUSCI_B_I2C_TIMEOUT_28_MS, EUSCI_B_I2C_TIMEOUT_31_MS, EUSCI_B_I2C_TIMEOUT_34_MS, and EUSCI_B_I2C_TIMEOUT_DISABLE.
uint_fast8_t I2C_getMode | ( | uint32_t | moduleInstance | ) |
Gets the mode of the I2C device.
Current I2C transmit/receive mode.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
Modified bits are UCTR of UCBxCTL1 register.
References EUSCI_B_CMSIS.
void I2C_slavePutData | ( | uint32_t | moduleInstance, |
uint8_t | transmitData | ||
) |
Transmits a byte from the I2C Module.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
transmitData | data to be transmitted from the I2C module |
This function will place the supplied data into I2C transmit data register to start transmission Modified register is UCBxTXBUF register
References EUSCI_B_CMSIS.
uint8_t I2C_slaveGetData | ( | uint32_t | moduleInstance | ) |
Receives a byte that has been sent to the I2C Module.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function reads a byte of data from the I2C receive data Register.
References EUSCI_B_CMSIS.
uint8_t I2C_isBusBusy | ( | uint32_t | moduleInstance | ) |
Indicates whether or not the I2C bus is busy.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
void I2C_masterSendSingleByte | ( | uint32_t | moduleInstance, |
uint8_t | txData | ||
) |
Does single byte transmission from Master to Slave
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
bool I2C_masterSendSingleByteWithTimeout | ( | uint32_t | moduleInstance, |
uint8_t | txData, | ||
uint32_t | timeout | ||
) |
Does single byte transmission from Master to Slave with timeout
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
txData | is the data byte to be transmitted |
timeout | is the amount of time to wait until giving up |
This function is used by the Master module to send a single byte. This function
Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE
References ASSERT, and EUSCI_B_CMSIS.
void I2C_masterSendMultiByteStart | ( | uint32_t | moduleInstance, |
uint8_t | txData | ||
) |
Starts multi-byte transmission from Master to Slave
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
bool I2C_masterSendMultiByteStartWithTimeout | ( | uint32_t | moduleInstance, |
uint8_t | txData, | ||
uint32_t | timeout | ||
) |
Starts multi-byte transmission from Master to Slave with timeout
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
txData | is the first data byte to be transmitted |
timeout | is the amount of time to wait until giving up |
This function is used by the Master module to send a single byte. This function
Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE
References ASSERT, and EUSCI_B_CMSIS.
void I2C_masterSendMultiByteNext | ( | uint32_t | moduleInstance, |
uint8_t | txData | ||
) |
Continues multi-byte transmission from Master to Slave
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
bool I2C_masterSendMultiByteNextWithTimeout | ( | uint32_t | moduleInstance, |
uint8_t | txData, | ||
uint32_t | timeout | ||
) |
Continues multi-byte transmission from Master to Slave with timeout
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
txData | is the next data byte to be transmitted |
timeout | is the amount of time to wait until giving up |
This function is used by the Master module continue each byte of a multi-byte transmission. This function
Modified registers are UCBxTXBUF
References ASSERT, and EUSCI_B_CMSIS.
bool I2C_masterSendMultiByteFinish | ( | uint32_t | moduleInstance, |
uint8_t | txData | ||
) |
Finishes multi-byte transmission from Master to Slave
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
txData | is the last data byte to be transmitted in a multi-byte transmsission |
This function is used by the Master module to send the last byte and STOP. This function
Modified registers are UCBxTXBUF and UCBxCTL1.
References EUSCI_B_CMSIS.
bool I2C_masterSendMultiByteFinishWithTimeout | ( | uint32_t | moduleInstance, |
uint8_t | txData, | ||
uint32_t | timeout | ||
) |
Finishes multi-byte transmission from Master to Slave with timeout
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
txData | is the last data byte to be transmitted in a multi-byte transmission |
timeout | is the amount of time to wait until giving up |
This function is used by the Master module to send the last byte and STOP. This function
Modified registers are UCBxTXBUF and UCBxCTL1.
References ASSERT, and EUSCI_B_CMSIS.
void I2C_masterSendMultiByteStop | ( | uint32_t | moduleInstance | ) |
Send STOP byte at the end of a multi-byte transmission from Master to Slave
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function is used by the Master module send STOP at the end of a multi-byte transmission
This function
Modified bits are UCTXSTP bit of UCBxCTL1.
References EUSCI_B_CMSIS.
bool I2C_masterSendMultiByteStopWithTimeout | ( | uint32_t | moduleInstance, |
uint32_t | timeout | ||
) |
Send STOP byte at the end of a multi-byte transmission from Master to Slave with timeout
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
timeout | is the amount of time to wait until giving up |
This function is used by the Master module send STOP at the end of a multi-byte transmission
This function
Modified bits are UCTXSTP bit of UCBxCTL1.
References ASSERT, and EUSCI_B_CMSIS.
void I2C_masterReceiveStart | ( | uint32_t | moduleInstance | ) |
Starts reception at the Master end
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function is used by the Master module initiate reception of a single byte. This function
Modified bits are UCTXSTT bit of UCBxCTL1.
References EUSCI_B_CMSIS.
uint8_t I2C_masterReceiveMultiByteNext | ( | uint32_t | moduleInstance | ) |
Starts multi-byte reception at the Master end one byte at a time
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
uint8_t I2C_masterReceiveMultiByteFinish | ( | uint32_t | moduleInstance | ) |
Finishes multi-byte reception at the Master end
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
bool I2C_masterReceiveMultiByteFinishWithTimeout | ( | uint32_t | moduleInstance, |
uint8_t * | txData, | ||
uint32_t | timeout | ||
) |
Finishes multi-byte reception at the Master end with timeout
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
txData | is a pointer to the location to store the received byte at master end |
timeout | is the amount of time to wait until giving up |
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 ASSERT, and EUSCI_B_CMSIS.
void I2C_masterReceiveMultiByteStop | ( | uint32_t | moduleInstance | ) |
Sends the STOP at the end of a multi-byte reception at the Master end
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function is used by the Master module to initiate STOP
Modified bits are UCTXSTP bit of UCBxCTL1.
References EUSCI_B_CMSIS.
uint8_t I2C_masterReceiveSingleByte | ( | uint32_t | moduleInstance | ) |
Does single byte reception from the slave
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function is used by the Master module to receive a single byte. This function:
Modified registers are UCBxIE, UCBxCTL1, UCBxIFG, UCBxTXBUF, UCBxIE
References EUSCI_B_CMSIS.
uint8_t I2C_masterReceiveSingle | ( | uint32_t | moduleInstance | ) |
Receives a byte that has been sent to the I2C Master Module.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function reads a byte of data from the I2C receive data Register.
References EUSCI_B_CMSIS.
uint32_t I2C_getReceiveBufferAddressForDMA | ( | uint32_t | moduleInstance | ) |
Returns the address of the RX Buffer of the I2C for the DMA module.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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.
References EUSCI_B_CMSIS.
uint32_t I2C_getTransmitBufferAddressForDMA | ( | uint32_t | moduleInstance | ) |
Returns the address of the TX Buffer of the I2C for the DMA module.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
Returns the address of the I2C TX Buffer. This can be used in conjunction with the DMA to obtain transmitted data directly from memory.
References EUSCI_B_CMSIS.
uint8_t I2C_masterIsStopSent | ( | uint32_t | moduleInstance | ) |
Indicates whether STOP got sent.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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 EUSCI_B_CMSIS.
bool I2C_masterIsStartSent | ( | uint32_t | moduleInstance | ) |
Indicates whether Start got sent.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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.
References EUSCI_B_CMSIS.
void I2C_masterSendStart | ( | uint32_t | moduleInstance | ) |
This function is used by the Master module to initiate START
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function is used by the Master module to initiate STOP
Modified bits are UCTXSTT bit of UCBxCTLW0.
References EUSCI_B_CMSIS.
void I2C_enableMultiMasterMode | ( | uint32_t | moduleInstance | ) |
Enables Multi Master Mode
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
At the end of this function, the I2C module is still disabled till I2C_enableModule is invoked
Modified bits are UCSWRST of OFS_UCBxCTLW0, UCMM bit of UCBxCTLW0
References EUSCI_B_CMSIS.
void I2C_disableMultiMasterMode | ( | uint32_t | moduleInstance | ) |
Disables Multi Master Mode
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
At the end of this function, the I2C module is still disabled till I2C_enableModule is invoked
Modified bits are UCSWRST of OFS_UCBxCTLW0, UCMM bit of UCBxCTLW0
References EUSCI_B_CMSIS.
void I2C_enableInterrupt | ( | uint32_t | moduleInstance, |
uint_fast16_t | mask | ||
) |
Enables individual I2C interrupt sources.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
mask | 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, EUSCI_B_CMSIS, EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT, EUSCI_B_I2C_BIT9_POSITION_INTERRUPT, EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT, EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT, EUSCI_B_I2C_NAK_INTERRUPT, EUSCI_B_I2C_RECEIVE_INTERRUPT0, EUSCI_B_I2C_RECEIVE_INTERRUPT1, EUSCI_B_I2C_RECEIVE_INTERRUPT2, EUSCI_B_I2C_RECEIVE_INTERRUPT3, EUSCI_B_I2C_START_INTERRUPT, EUSCI_B_I2C_STOP_INTERRUPT, EUSCI_B_I2C_TRANSMIT_INTERRUPT0, EUSCI_B_I2C_TRANSMIT_INTERRUPT1, EUSCI_B_I2C_TRANSMIT_INTERRUPT2, and EUSCI_B_I2C_TRANSMIT_INTERRUPT3.
void I2C_disableInterrupt | ( | uint32_t | moduleInstance, |
uint_fast16_t | mask | ||
) |
Disables individual I2C interrupt sources.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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, EUSCI_B_CMSIS, EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT, EUSCI_B_I2C_BIT9_POSITION_INTERRUPT, EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT, EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT, EUSCI_B_I2C_NAK_INTERRUPT, EUSCI_B_I2C_RECEIVE_INTERRUPT0, EUSCI_B_I2C_RECEIVE_INTERRUPT1, EUSCI_B_I2C_RECEIVE_INTERRUPT2, EUSCI_B_I2C_RECEIVE_INTERRUPT3, EUSCI_B_I2C_START_INTERRUPT, EUSCI_B_I2C_STOP_INTERRUPT, EUSCI_B_I2C_TRANSMIT_INTERRUPT0, EUSCI_B_I2C_TRANSMIT_INTERRUPT1, EUSCI_B_I2C_TRANSMIT_INTERRUPT2, and EUSCI_B_I2C_TRANSMIT_INTERRUPT3.
void I2C_clearInterruptFlag | ( | uint32_t | moduleInstance, |
uint_fast16_t | mask | ||
) |
Clears I2C interrupt sources.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
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, EUSCI_B_CMSIS, EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT, EUSCI_B_I2C_BIT9_POSITION_INTERRUPT, EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT, EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT, EUSCI_B_I2C_NAK_INTERRUPT, EUSCI_B_I2C_RECEIVE_INTERRUPT0, EUSCI_B_I2C_RECEIVE_INTERRUPT1, EUSCI_B_I2C_RECEIVE_INTERRUPT2, EUSCI_B_I2C_RECEIVE_INTERRUPT3, EUSCI_B_I2C_START_INTERRUPT, EUSCI_B_I2C_STOP_INTERRUPT, EUSCI_B_I2C_TRANSMIT_INTERRUPT0, EUSCI_B_I2C_TRANSMIT_INTERRUPT1, EUSCI_B_I2C_TRANSMIT_INTERRUPT2, and EUSCI_B_I2C_TRANSMIT_INTERRUPT3.
uint_fast16_t I2C_getInterruptStatus | ( | uint32_t | moduleInstance, |
uint16_t | mask | ||
) |
Gets the current I2C interrupt status.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
mask | is the masked interrupt flag status to be returned. Mask value is the logical OR of any of the following:
|
References ASSERT, EUSCI_B_CMSIS, EUSCI_B_I2C_ARBITRATIONLOST_INTERRUPT, EUSCI_B_I2C_BIT9_POSITION_INTERRUPT, EUSCI_B_I2C_BYTE_COUNTER_INTERRUPT, EUSCI_B_I2C_CLOCK_LOW_TIMEOUT_INTERRUPT, EUSCI_B_I2C_NAK_INTERRUPT, EUSCI_B_I2C_RECEIVE_INTERRUPT0, EUSCI_B_I2C_RECEIVE_INTERRUPT1, EUSCI_B_I2C_RECEIVE_INTERRUPT2, EUSCI_B_I2C_RECEIVE_INTERRUPT3, EUSCI_B_I2C_START_INTERRUPT, EUSCI_B_I2C_STOP_INTERRUPT, EUSCI_B_I2C_TRANSMIT_INTERRUPT0, EUSCI_B_I2C_TRANSMIT_INTERRUPT1, EUSCI_B_I2C_TRANSMIT_INTERRUPT2, and EUSCI_B_I2C_TRANSMIT_INTERRUPT3.
Referenced by I2C_getEnabledInterruptStatus().
uint_fast16_t I2C_getEnabledInterruptStatus | ( | uint32_t | moduleInstance | ) |
Gets the current I2C interrupt status masked with the enabled interrupts. This function is useful to call in ISRs to get a list of pending interrupts that are actually enabled and could have caused the ISR.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
References EUSCI_B_CMSIS, and I2C_getInterruptStatus().
void I2C_registerInterrupt | ( | uint32_t | moduleInstance, |
void(*)(void) | intHandler | ||
) |
Registers an interrupt handler for I2C interrupts.
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
intHandler | is a pointer to the function to be called when the timer capture compare interrupt occurs. |
This function registers the handler to be called when an I2C interrupt occurs. This function enables the global interrupt in the interrupt controller; specific I2C interrupts must be enabled via I2C_enableInterrupt(). It is the interrupt handler's responsibility to clear the interrupt source via I2C_clearInterruptFlag().
References ASSERT, INT_EUSCIB0, INT_EUSCIB1, INT_EUSCIB2, INT_EUSCIB3, Interrupt_enableInterrupt(), and Interrupt_registerInterrupt().
void I2C_unregisterInterrupt | ( | uint32_t | moduleInstance | ) |
Unregisters the interrupt handler for the timer
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
This function unregisters the handler to be called when timer interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.
References ASSERT, INT_EUSCIB0, INT_EUSCIB1, INT_EUSCIB2, INT_EUSCIB3, Interrupt_disableInterrupt(), and Interrupt_unregisterInterrupt().
void I2C_slaveSendNAK | ( | uint32_t | moduleInstance | ) |
This function is used by the slave to send a NAK out over the I2C line
moduleInstance | is the instance of the eUSCI B (I2C) module. Valid parameters vary from part to part, but can include:
|
References EUSCI_B_CMSIS.