![]() |
![]() |
|
MSP430™CapTIvateSoftwareLibraryAPIGuide
1_70_00_03
|
I2C slave driver module for the eUSCI_B I2C peripheral. More...
Data Structures | |
| struct | tI2CSlavePort |
Macros | |
| #define | I2CSLAVE__EUSCI_VECTOR (USCI_B0_VECTOR) |
| #define | I2CSLAVE__EUSCI_IV (UCB0IV) |
| #define | I2CSLAVE__INT_MASK (0x0F) |
| #define | I2C__INIT_REQ_SIGNAL (I2CSLAVE__REQ_POUT &= ~I2CSLAVE__REQ_MASK) |
| #define | I2C__PULL_REQ_SIGNAL (I2CSLAVE__REQ_PDIR |= I2CSLAVE__REQ_MASK) |
| #define | I2C__RELEASE_REQ_SIGNAL (I2CSLAVE__REQ_PDIR &= ~I2CSLAVE__REQ_MASK) |
| #define | I2CSLAVE__EUSCI_B_PERIPHERAL (EUSCI_B0_BASE) |
| #define | I2CSLAVE__ADDRESS (0x0A) |
| #define | I2CSLAVE__LPMx_bits (LPM3_bits) |
| #define | I2CSLAVE__INVALID_BYTE (0xFF) |
| #define | I2CSLAVE__TIMEOUT_ENABLE (true) |
| #define | I2CSLAVE__REQ_TIMEOUT_CYCLES (66) |
| #define | I2CSLAVE__TXFR_TIMEOUT_CYCLES (264) |
Enumerations | |
| enum | tI2CSlaveStates { eI2CSlaveIsClosed = 0x00, eI2CSlaveIsIdle = 0x01, eI2CSlaveIsBeingRead = 0x02, eI2CSlaveIsBeingWrittenTo = 0x03 } |
| enumerates the possible I2C slave driver states. More... | |
| enum | tI2CSlaveErrors { eI2CSlaveTransmitRequestTimeout, eI2CSlaveTransactionTimeout, eI2CSlaveReceiveBufferFull, eI2CSlaveWasReadBeyondTransmitBuffer } |
Functions | |
| void | I2CSlave_openPort (const tI2CSlavePort *pPort) |
| void | I2CSlave_closePort (void) |
| uint8_t | I2CSlave_getPortStatus (void) |
| void | I2CSlave_setTransmitBuffer (uint8_t *pBuffer, uint16_t ui16Length) |
| void | I2CSlave_setRequestFlag (void) |
| __interrupt void | I2CSlave_ISR (void) |
Variables | |
| const tI2CSlavePort * | g_pI2CSlavePort |
| const EUSCI_B_I2C_initSlaveParam | g_I2CSlaveConfiguration |
| const uint8_t * | g_pI2CTransmitBuffer |
| var g_pI2CTransmitBuffer stores a pointer to the current transmit buffer. More... | |
| uint16_t | g_ui16I2CLength |
| volatile uint16_t | g_ui16I2CIndex |
| var g_ui16I2CIndex stores the current transmit or receive buffer index. More... | |
| volatile uint8_t | g_I2CSlaveStatus = eI2CSlaveIsClosed |
| volatile bool | g_bI2CSlaveRequestPending |
| const tFunctionTimer | g_I2CSlaveFunctionTimer |
I2C slave driver module for the eUSCI_B I2C peripheral.
This is the I2C slave port driver header file. The I2C slave port driver enables interrupt-driven I2C-bus transactions via a simple API. The implementation requires one eUSCI_B instance, and the MSP430 DriverLib version 2.10.00.00 or greater.
This is the I2C slave definitions file. This file sets the configuration parameters for the I2C slave port.
| #define I2CSLAVE__EUSCI_VECTOR (USCI_B0_VECTOR) |
def I2CSLAVE__EUSCI_VECTOR defines the interrupt vector location of the selected eUSCI_B I2C peripheral. def I2CSLAVE__EUSCI_IV defines the interrupt vector of the selected eUSCI_B I2C peripheral.
| #define I2CSLAVE__EUSCI_IV (UCB0IV) |
Referenced by I2CSlave_ISR().
| #define I2CSLAVE__INT_MASK (0x0F) |
def I2CSLAVE__INT_MASK defines the interrupt enable mask for the eUSCI_B I2C peripheral. The used interrupts include START, STOP, RX, and TX.
Referenced by I2CSlave_openPort().
| #define I2C__INIT_REQ_SIGNAL (I2CSLAVE__REQ_POUT &= ~I2CSLAVE__REQ_MASK) |
def I2C__INIT_REQ_SIGNAL is a macro for setting the I2C request line to active low.
Referenced by I2CSlave_openPort().
| #define I2C__PULL_REQ_SIGNAL (I2CSLAVE__REQ_PDIR |= I2CSLAVE__REQ_MASK) |
def I2C__PULL_REQ_SIGNAL is a macro for pulling the I2C request line by changing its state from Hi-Z to output low (current sink)
Referenced by I2CSlave_setRequestFlag().
| #define I2C__RELEASE_REQ_SIGNAL (I2CSLAVE__REQ_PDIR &= ~I2CSLAVE__REQ_MASK) |
def I2C__RELEASE_REQ_SIGNAL us a macro for releasing the I2C request line by returing its state to Hi-Z from output low.
Referenced by I2CSlave_setRequestFlag().
| #define I2CSLAVE__EUSCI_B_PERIPHERAL (EUSCI_B0_BASE) |
Referenced by I2CSlave_closePort(), and I2CSlave_openPort().
| #define I2CSLAVE__ADDRESS (0x0A) |
| #define I2CSLAVE__LPMx_bits (LPM3_bits) |
Referenced by I2CSlave_setRequestFlag(), and I2CSlave_setTransmitBuffer().
| #define I2CSLAVE__INVALID_BYTE (0xFF) |
| #define I2CSLAVE__TIMEOUT_ENABLE (true) |
| #define I2CSLAVE__REQ_TIMEOUT_CYCLES (66) |
| #define I2CSLAVE__TXFR_TIMEOUT_CYCLES (264) |
| enum tI2CSlaveStates |
| enum tI2CSlaveErrors |
| void I2CSlave_openPort | ( | const tI2CSlavePort * | pPort | ) |
This function opens the I2C slave port on the specified HW eUSCI_B peripheral. This function must be called before the port is used.
| pPort | is a pointer to the I2C Slave Port configuration structure. The user must populate and provide this structure to the I2C slave port driver. The data structure must remain at the same address throughout the operation of the driver. |
References eI2CSlaveIsIdle, g_bI2CSlaveRequestPending, g_I2CSlaveConfiguration, g_I2CSlaveStatus, I2C__INIT_REQ_SIGNAL, I2CSLAVE__EUSCI_B_PERIPHERAL, I2CSLAVE__INT_MASK, I2CSlave_closePort(), and Timer_startDelayedFunctionTimer().
| void I2CSlave_closePort | ( | void | ) |
This function closes the I2C slave port on the specified HW eUSCI_B peripheral.
References eI2CSlaveIsClosed, g_I2CSlaveStatus, I2CSLAVE__EUSCI_B_PERIPHERAL, and Timer_stopDelayedFunctionTimer().
Referenced by I2CSlave_openPort().
| uint8_t I2CSlave_getPortStatus | ( | void | ) |
This function returns the status of the I2C port when called. The possible I2C statuses are enumerated under tI2CSlaveStates.
References g_I2CSlaveStatus.
| void I2CSlave_setTransmitBuffer | ( | uint8_t * | pBuffer, |
| uint16_t | ui16Length | ||
| ) |
This function sets a new transmit buffer in the I2C peripheral. To send a buffer of data to the I2C bus master, use this function to inform the driver of the buffer location and size. Then call the I2CSlave_setTransmitRequestFlag function to signal the host to begin transmission. If a current read is either pending or currently in progress, this function will block until that operation has completed or timed out before updating the transmit buffer pointer and length.
| pBuffer | is a pointer to the new transmit buffer |
| ui16Length | is an integer specifying the valid data length in the buffer |
References eI2CSlaveIsBeingRead, g_bI2CSlaveRequestPending, g_I2CSlaveStatus, g_pI2CTransmitBuffer, g_ui16I2CLength, and I2CSLAVE__LPMx_bits.
| void I2CSlave_setRequestFlag | ( | void | ) |
This function pulls the I2C request line to signal the bus master that data is waiting to be read from this device. This function will block until either the bus master begins to read out the data OR the read post times out, at which point the error callback will be called to handle the error.
References eTimerDelayedFunction_A, g_bI2CSlaveRequestPending, I2C__PULL_REQ_SIGNAL, I2C__RELEASE_REQ_SIGNAL, I2CSLAVE__LPMx_bits, Timer_cancelDelayedFunction(), and Timer_scheduleDelayedFunction().
| __interrupt void I2CSlave_ISR | ( | void | ) |
References eI2CSlaveIsBeingWrittenTo, g_I2CSlaveStatus, and I2CSLAVE__EUSCI_IV.
| const tI2CSlavePort* g_pI2CSlavePort |
var g_pI2CSlavePort stores a pointer to the I2C slave port configuration structure that was passed to the I2CSlave_openPort function. The I2C slave driver does not modify this structure.
| const EUSCI_B_I2C_initSlaveParam g_I2CSlaveConfiguration |
var g_I2CSlaveConfiguration stores the MSP430 DriverLib EUSCI_B_I2C configuration parameters for the EUSCI_B_I2C_initSlave() function call.
Referenced by I2CSlave_openPort().
| const uint8_t* g_pI2CTransmitBuffer |
var g_pI2CTransmitBuffer stores a pointer to the current transmit buffer.
Referenced by I2CSlave_setTransmitBuffer().
| uint16_t g_ui16I2CLength |
var g_ui16I2CLength stores the valid data length of the data pointed to by g_pI2CTransmitBuffer.
Referenced by I2CSlave_setTransmitBuffer().
| volatile uint16_t g_ui16I2CIndex |
var g_ui16I2CIndex stores the current transmit or receive buffer index.
| volatile uint8_t g_I2CSlaveStatus = eI2CSlaveIsClosed |
var g_I2CSlaveStatus stores the current status of the I2C slave port. possible options are enumerated in tI2CSlaveStates.
Referenced by I2CSlave_closePort(), I2CSlave_getPortStatus(), I2CSlave_ISR(), I2CSlave_openPort(), and I2CSlave_setTransmitBuffer().
| volatile bool g_bI2CSlaveRequestPending |
var g_bI2CSlaveRequestPending indicates whether or not a read operation is currently pending on the I2C bus master.
Referenced by I2CSlave_openPort(), I2CSlave_setRequestFlag(), and I2CSlave_setTransmitBuffer().
| const tFunctionTimer g_I2CSlaveFunctionTimer |
var g_I2CSlaveFunctionTimer contains the function timer configuration for the two I2C timeout events- a slave request timeout (Fxn A) and an I2C transaction timeout (Fxn B)