I'm putting together a serialization wrapper for I2C bus access for my SYS/BIOS-based application, and while most of the documentation is clear the sequence of operation looks a bit off:
The user must first initialize the USCI_B_I2C module and configure it as a master with a call to USCI_B_I2C_masterInit(). 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 USCI_B_I2C_setSlaveAddress. Then the mode of operation (transmit or receive) is chosen using USCI_B_I2C_setMode. The USCI_B_I2C module may now be enabled using USCI_B_I2C_enable. It is recommended to enable the USCI_B_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. APIs that include a time-out can be used to avoid being stuck in an infinite loop if the device is stuck waiting for an IFG flag to be set.
I need to communicate with multiple slaves on the bus, so while the text indicates that I should set the slave address BEFORE the bus is enabled, is it permissible to do that with the I2C enabled? Also, I will be transacting on the bus, so I'm assuming I can switch transmit/receive modes wthout having to disable/enable the bus...
All info appreciated!
Ed Averill