EE445M RTOS
Taken at the University of Texas Spring 2015
I2c_api

Functions

static uint32_t _I2CIntNumberGet (uint32_t ui32Base)
 
void I2CMasterInitExpClk (uint32_t ui32Base, uint32_t ui32I2CClk, bool bFast)
 
void I2CSlaveInit (uint32_t ui32Base, uint8_t ui8SlaveAddr)
 
void I2CSlaveAddressSet (uint32_t ui32Base, uint8_t ui8AddrNum, uint8_t ui8SlaveAddr)
 
void I2CMasterEnable (uint32_t ui32Base)
 
void I2CSlaveEnable (uint32_t ui32Base)
 
void I2CMasterDisable (uint32_t ui32Base)
 
void I2CSlaveDisable (uint32_t ui32Base)
 
void I2CIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
 
void I2CIntUnregister (uint32_t ui32Base)
 
void I2CMasterIntEnable (uint32_t ui32Base)
 
void I2CMasterIntEnableEx (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void I2CSlaveIntEnable (uint32_t ui32Base)
 
void I2CSlaveIntEnableEx (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void I2CMasterIntDisable (uint32_t ui32Base)
 
void I2CMasterIntDisableEx (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void I2CSlaveIntDisable (uint32_t ui32Base)
 
void I2CSlaveIntDisableEx (uint32_t ui32Base, uint32_t ui32IntFlags)
 
bool I2CMasterIntStatus (uint32_t ui32Base, bool bMasked)
 
uint32_t I2CMasterIntStatusEx (uint32_t ui32Base, bool bMasked)
 
bool I2CSlaveIntStatus (uint32_t ui32Base, bool bMasked)
 
uint32_t I2CSlaveIntStatusEx (uint32_t ui32Base, bool bMasked)
 
void I2CMasterIntClear (uint32_t ui32Base)
 
void I2CMasterIntClearEx (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void I2CSlaveIntClear (uint32_t ui32Base)
 
void I2CSlaveIntClearEx (uint32_t ui32Base, uint32_t ui32IntFlags)
 
void I2CMasterSlaveAddrSet (uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)
 
uint32_t I2CMasterLineStateGet (uint32_t ui32Base)
 
bool I2CMasterBusy (uint32_t ui32Base)
 
bool I2CMasterBusBusy (uint32_t ui32Base)
 
void I2CMasterControl (uint32_t ui32Base, uint32_t ui32Cmd)
 
uint32_t I2CMasterErr (uint32_t ui32Base)
 
void I2CMasterDataPut (uint32_t ui32Base, uint8_t ui8Data)
 
uint32_t I2CMasterDataGet (uint32_t ui32Base)
 
void I2CMasterTimeoutSet (uint32_t ui32Base, uint32_t ui32Value)
 
void I2CSlaveACKOverride (uint32_t ui32Base, bool bEnable)
 
void I2CSlaveACKValueSet (uint32_t ui32Base, bool bACK)
 
uint32_t I2CSlaveStatus (uint32_t ui32Base)
 
void I2CSlaveDataPut (uint32_t ui32Base, uint8_t ui8Data)
 
uint32_t I2CSlaveDataGet (uint32_t ui32Base)
 
void I2CTxFIFOConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void I2CTxFIFOFlush (uint32_t ui32Base)
 
void I2CRxFIFOConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void I2CRxFIFOFlush (uint32_t ui32Base)
 
uint32_t I2CFIFOStatus (uint32_t ui32Base)
 
void I2CFIFODataPut (uint32_t ui32Base, uint8_t ui8Data)
 
uint32_t I2CFIFODataPutNonBlocking (uint32_t ui32Base, uint8_t ui8Data)
 
uint32_t I2CFIFODataGet (uint32_t ui32Base)
 
uint32_t I2CFIFODataGetNonBlocking (uint32_t ui32Base, uint8_t *pui8Data)
 
void I2CMasterBurstLengthSet (uint32_t ui32Base, uint8_t ui8Length)
 
uint32_t I2CMasterBurstCountGet (uint32_t ui32Base)
 
void I2CMasterGlitchFilterConfigSet (uint32_t ui32Base, uint32_t ui32Config)
 
void I2CSlaveFIFOEnable (uint32_t ui32Base, uint32_t ui32Config)
 
void I2CSlaveFIFODisable (uint32_t ui32Base)
 

Variables

static const uint32_t g_ppui32I2CIntMap [][2]
 
static const int_fast8_t g_i8I2CIntMapRows
 
static const uint32_t g_ppui32I2CIntMapSnowflake [][2]
 
static const int_fast8_t g_i8I2CIntMapSnowflakeRows
 

Detailed Description

Function Documentation

static uint32_t _I2CIntNumberGet ( uint32_t  ui32Base)
static

Definition at line 131 of file i2c.c.

References ASSERT, CLASS_IS_TM4C129, g_i8I2CIntMapRows, g_i8I2CIntMapSnowflakeRows, g_ppui32I2CIntMap, and g_ppui32I2CIntMapSnowflake.

Referenced by I2CIntRegister(), and I2CIntUnregister().

132 {
133  int_fast8_t i8Idx, i8Rows;
134  const uint32_t (*ppui32I2CIntMap)[2];
135 
136  //
137  // Check the arguments.
138  //
139  ASSERT(_I2CBaseValid(ui32Base));
140 
141  ppui32I2CIntMap = g_ppui32I2CIntMap;
142  i8Rows = g_i8I2CIntMapRows;
143 
144  if(CLASS_IS_TM4C129)
145  {
146  ppui32I2CIntMap = g_ppui32I2CIntMapSnowflake;
148  }
149 
150  //
151  // Loop through the table that maps I2C base addresses to interrupt
152  // numbers.
153  //
154  for(i8Idx = 0; i8Idx < i8Rows; i8Idx++)
155  {
156  //
157  // See if this base address matches.
158  //
159  if(ppui32I2CIntMap[i8Idx][0] == ui32Base)
160  {
161  //
162  // Return the corresponding interrupt number.
163  //
164  return(ppui32I2CIntMap[i8Idx][1]);
165  }
166  }
167 
168  //
169  // The base address could not be found, so return an error.
170  //
171  return(0);
172 }
static const int_fast8_t g_i8I2CIntMapSnowflakeRows
Definition: i2c.c:89
static const uint32_t g_ppui32I2CIntMapSnowflake[][2]
Definition: i2c.c:76
static const uint32_t g_ppui32I2CIntMap[][2]
Definition: i2c.c:63
#define ASSERT(expr)
Definition: debug.h:67
static const int_fast8_t g_i8I2CIntMapRows
Definition: i2c.c:73
#define CLASS_IS_TM4C129
Definition: hw_types.h:99

Here is the caller graph for this function:

uint32_t I2CFIFODataGet ( uint32_t  ui32Base)

Reads a byte from the I2C receive FIFO.

Parameters
ui32Baseis the base address of the I2C module.

This function reads a byte of data from I2C receive FIFO and places it in the location specified by the pui8Data parameter. If there is no data available, this function waits until data is received before returning.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
The data byte.

Definition at line 1901 of file i2c.c.

References ASSERT, HWREG, I2C_FIFOSTATUS_RXFE, I2C_O_FIFODATA, and I2C_O_FIFOSTATUS.

1902 {
1903  //
1904  // Check the arguments.
1905  //
1906  ASSERT(_I2CBaseValid(ui32Base));
1907 
1908  //
1909  // Wait until there is data to read.
1910  //
1911  while(HWREG(ui32Base + I2C_O_FIFOSTATUS) & I2C_FIFOSTATUS_RXFE)
1912  {
1913  }
1914 
1915  //
1916  // Read a byte.
1917  //
1918  return(HWREG(ui32Base + I2C_O_FIFODATA));
1919 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_FIFOSTATUS
Definition: hw_i2c.h:76
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_FIFOSTATUS_RXFE
Definition: hw_i2c.h:450
#define I2C_O_FIFODATA
Definition: hw_i2c.h:74
uint32_t I2CFIFODataGetNonBlocking ( uint32_t  ui32Base,
uint8_t *  pui8Data 
)

Reads a byte from the I2C receive FIFO.

Parameters
ui32Baseis the base address of the I2C module.
pui8Datais a pointer where the read data is stored.

This function reads a byte of data from I2C receive FIFO and places it in the location specified by the pui8Data parameter. If there is no data available, this functions returns 0.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
The number of elements read from the I2C receive FIFO.

Definition at line 1939 of file i2c.c.

References ASSERT, HWREG, I2C_FIFOSTATUS_RXFE, I2C_O_FIFODATA, and I2C_O_FIFOSTATUS.

1940 {
1941  //
1942  // Check the arguments.
1943  //
1944  ASSERT(_I2CBaseValid(ui32Base));
1945 
1946  //
1947  // If nothing in the FIFO, return zero.
1948  //
1949  if(HWREG(ui32Base + I2C_O_FIFOSTATUS) & I2C_FIFOSTATUS_RXFE)
1950  {
1951  return(0);
1952  }
1953  else
1954  {
1955  *pui8Data = HWREG(ui32Base + I2C_O_FIFODATA);
1956  return(1);
1957  }
1958 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_FIFOSTATUS
Definition: hw_i2c.h:76
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_FIFOSTATUS_RXFE
Definition: hw_i2c.h:450
#define I2C_O_FIFODATA
Definition: hw_i2c.h:74
void I2CFIFODataPut ( uint32_t  ui32Base,
uint8_t  ui8Data 
)

Writes a data byte to the I2C transmit FIFO.

Parameters
ui32Baseis the base address of the I2C module.
ui8Datais the data to be placed into the transmit FIFO.

This function adds a byte of data to the I2C transmit FIFO. If there is no space available in the FIFO, this function waits for space to become available before returning.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1826 of file i2c.c.

References ASSERT, HWREG, I2C_FIFOSTATUS_TXFF, I2C_O_FIFODATA, and I2C_O_FIFOSTATUS.

1827 {
1828  //
1829  // Check the arguments.
1830  //
1831  ASSERT(_I2CBaseValid(ui32Base));
1832 
1833  //
1834  // Wait until there is space.
1835  //
1836  while(HWREG(ui32Base + I2C_O_FIFOSTATUS) & I2C_FIFOSTATUS_TXFF)
1837  {
1838  }
1839 
1840  //
1841  // Place data into the FIFO.
1842  //
1843  HWREG(ui32Base + I2C_O_FIFODATA) = ui8Data;
1844 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_FIFOSTATUS
Definition: hw_i2c.h:76
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_FIFOSTATUS_TXFF
Definition: hw_i2c.h:453
#define I2C_O_FIFODATA
Definition: hw_i2c.h:74
uint32_t I2CFIFODataPutNonBlocking ( uint32_t  ui32Base,
uint8_t  ui8Data 
)

Writes a data byte to the I2C transmit FIFO.

Parameters
ui32Baseis the base address of the I2C module.
ui8Datais the data to be placed into the transmit FIFO.

This function adds a byte of data to the I2C transmit FIFO. If there is no space available in the FIFO, this function returns a zero.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
The number of elements added to the I2C transmit FIFO.

Definition at line 1863 of file i2c.c.

References ASSERT, HWREG, I2C_FIFOSTATUS_TXFF, I2C_O_FIFODATA, and I2C_O_FIFOSTATUS.

1864 {
1865  //
1866  // Check the arguments.
1867  //
1868  ASSERT(_I2CBaseValid(ui32Base));
1869 
1870  //
1871  // If FIFO is full, return zero.
1872  //
1873  if(HWREG(ui32Base + I2C_O_FIFOSTATUS) & I2C_FIFOSTATUS_TXFF)
1874  {
1875  return(0);
1876  }
1877  else
1878  {
1879  HWREG(ui32Base + I2C_O_FIFODATA) = ui8Data;
1880  return(1);
1881  }
1882 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_FIFOSTATUS
Definition: hw_i2c.h:76
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_FIFOSTATUS_TXFF
Definition: hw_i2c.h:453
#define I2C_O_FIFODATA
Definition: hw_i2c.h:74
uint32_t I2CFIFOStatus ( uint32_t  ui32Base)

Gets the current FIFO status.

Parameters
ui32Baseis the base address of the I2C module.

This function retrieves the status for both the transmit (TX) and receive (RX) FIFOs. The trigger level for the transmit FIFO is set using I2CTxFIFOConfigSet() and for the receive FIFO using I2CTxFIFOConfigSet().

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
Returns the FIFO status, enumerated as a bit field containing I2C_FIFO_RX_BELOW_TRIG_LEVEL, I2C_FIFO_RX_FULL, I2C_FIFO_RX_EMPTY, I2C_FIFO_TX_BELOW_TRIG_LEVEL, I2C_FIFO_TX_FULL, and I2C_FIFO_TX_EMPTY.

Definition at line 1795 of file i2c.c.

References ASSERT, HWREG, and I2C_O_FIFOSTATUS.

1796 {
1797  //
1798  // Check the arguments.
1799  //
1800  ASSERT(_I2CBaseValid(ui32Base));
1801 
1802  //
1803  // Return the contents of the FIFO status register.
1804  //
1805  return(HWREG(ui32Base + I2C_O_FIFOSTATUS));
1806 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_FIFOSTATUS
Definition: hw_i2c.h:76
#define ASSERT(expr)
Definition: debug.h:67
void I2CIntRegister ( uint32_t  ui32Base,
void(*)(void)  pfnHandler 
)

Registers an interrupt handler for the I2C module.

Parameters
ui32Baseis the base address of the I2C module.
pfnHandleris a pointer to the function to be called when the I2C interrupt occurs.

This function sets 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 I2CMasterIntEnable() and I2CSlaveIntEnable(). If necessary, it is the interrupt handler's responsibility to clear the interrupt source via I2CMasterIntClear() and I2CSlaveIntClear().

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 473 of file i2c.c.

References _I2CIntNumberGet(), ASSERT, IntEnable(), and IntRegister().

474 {
475  uint32_t ui32Int;
476 
477  //
478  // Check the arguments.
479  //
480  ASSERT(_I2CBaseValid(ui32Base));
481 
482  //
483  // Determine the interrupt number based on the I2C port.
484  //
485  ui32Int = _I2CIntNumberGet(ui32Base);
486 
487  ASSERT(ui32Int != 0);
488 
489  //
490  // Register the interrupt handler, returning an error if an error occurs.
491  //
492  IntRegister(ui32Int, pfnHandler);
493 
494  //
495  // Enable the I2C interrupt.
496  //
497  IntEnable(ui32Int);
498 }
#define ASSERT(expr)
Definition: debug.h:67
static uint32_t _I2CIntNumberGet(uint32_t ui32Base)
Definition: i2c.c:131
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Definition: interrupt.c:309
void IntEnable(uint32_t ui32Interrupt)
Definition: interrupt.c:610

Here is the call graph for this function:

void I2CIntUnregister ( uint32_t  ui32Base)

Unregisters an interrupt handler for the I2C module.

Parameters
ui32Baseis the base address of the I2C module.

This function clears the handler to be called when an I2C interrupt occurs. This function also masks off the interrupt in the interrupt r controller so that the interrupt handler no longer is called.

See also
IntRegister() for important information about registering interrupt handlers.
Returns
None.

Definition at line 517 of file i2c.c.

References _I2CIntNumberGet(), ASSERT, IntDisable(), and IntUnregister().

518 {
519  uint32_t ui32Int;
520 
521  //
522  // Check the arguments.
523  //
524  ASSERT(_I2CBaseValid(ui32Base));
525 
526  //
527  // Determine the interrupt number based on the I2C port.
528  //
529  ui32Int = _I2CIntNumberGet(ui32Base);
530 
531  ASSERT(ui32Int != 0);
532 
533  //
534  // Disable the interrupt.
535  //
536  IntDisable(ui32Int);
537 
538  //
539  // Unregister the interrupt handler.
540  //
541  IntUnregister(ui32Int);
542 }
#define ASSERT(expr)
Definition: debug.h:67
void IntUnregister(uint32_t ui32Interrupt)
Definition: interrupt.c:381
static uint32_t _I2CIntNumberGet(uint32_t ui32Base)
Definition: i2c.c:131
void IntDisable(uint32_t ui32Interrupt)
Definition: interrupt.c:684

Here is the call graph for this function:

uint32_t I2CMasterBurstCountGet ( uint32_t  ui32Base)

Returns the current value of the burst transfer counter.

Parameters
ui32Baseis the base address of the I2C module.

This function returns the current value of the burst transfer counter that is used by the FIFO mechanism. Software can use this value to determine how many bytes remain in a transfer, or where in the transfer the burst operation was if an error has occurred.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 2012 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MBCNT.

2013 {
2014  //
2015  // Check the arguments.
2016  //
2017  ASSERT(_I2CBaseValid(ui32Base));
2018 
2019  //
2020  // Get burst count.
2021  //
2022  return(HWREG(ui32Base + I2C_O_MBCNT));
2023 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MBCNT
Definition: hw_i2c.h:62
void I2CMasterBurstLengthSet ( uint32_t  ui32Base,
uint8_t  ui8Length 
)

Set the burst length for a I2C master FIFO operation.

Parameters
ui32Baseis the base address of the I2C module.
ui8Lengthis the length of the burst transfer.

This function configures the burst length for a I2C Master FIFO operation. The burst field is limited to 8 bits or 256 bytes. The burst length applies to a single I2CMCS BURST operation meaning that it specifies the burst length for only the current operation (can be TX or RX). Each burst operation must configure the burst length prior to writing the BURST bit in the I2CMCS using I2CMasterControl().

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1981 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MBLEN.

1982 {
1983  //
1984  // Check the arguments.
1985  //
1986  ASSERT(_I2CBaseValid(ui32Base) && (ui8Length < 255));
1987 
1988  //
1989  // Set the burst length.
1990  //
1991  HWREG(ui32Base + I2C_O_MBLEN) = ui8Length;
1992 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MBLEN
Definition: hw_i2c.h:61
bool I2CMasterBusBusy ( uint32_t  ui32Base)

Indicates whether or not the I2C bus is busy.

Parameters
ui32Baseis the base address of the I2C module.

This function returns an indication of whether or not the I2C bus is busy. This function can be used in a multi-master environment to determine if another master is currently using the bus.

Returns
Returns true if the I2C bus is busy; otherwise, returns false.

Definition at line 1222 of file i2c.c.

References ASSERT, HWREG, I2C_MCS_BUSBSY, and I2C_O_MCS.

1223 {
1224  //
1225  // Check the arguments.
1226  //
1227  ASSERT(_I2CBaseValid(ui32Base));
1228 
1229  //
1230  // Return the bus busy status.
1231  //
1232  if(HWREG(ui32Base + I2C_O_MCS) & I2C_MCS_BUSBSY)
1233  {
1234  return(true);
1235  }
1236  else
1237  {
1238  return(false);
1239  }
1240 }
#define I2C_O_MCS
Definition: hw_i2c.h:49
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MCS_BUSBSY
Definition: hw_i2c.h:98
bool I2CMasterBusy ( uint32_t  ui32Base)

Indicates whether or not the I2C Master is busy.

Parameters
ui32Baseis the base address of the I2C module.

This function returns an indication of whether or not the I2C Master is busy transmitting or receiving data.

Returns
Returns true if the I2C Master is busy; otherwise, returns false.

Definition at line 1187 of file i2c.c.

References ASSERT, HWREG, I2C_MCS_BUSY, and I2C_O_MCS.

1188 {
1189  //
1190  // Check the arguments.
1191  //
1192  ASSERT(_I2CBaseValid(ui32Base));
1193 
1194  //
1195  // Return the busy status.
1196  //
1197  if(HWREG(ui32Base + I2C_O_MCS) & I2C_MCS_BUSY)
1198  {
1199  return(true);
1200  }
1201  else
1202  {
1203  return(false);
1204  }
1205 }
#define I2C_O_MCS
Definition: hw_i2c.h:49
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MCS_BUSY
Definition: hw_i2c.h:110
void I2CMasterControl ( uint32_t  ui32Base,
uint32_t  ui32Cmd 
)

Controls the state of the I2C Master.

Parameters
ui32Baseis the base address of the I2C module.
ui32Cmdcommand to be issued to the I2C Master.

This function is used to control the state of the Master send and receive operations. The ui8Cmd parameter can be one of the following values:

  • I2C_MASTER_CMD_SINGLE_SEND
  • I2C_MASTER_CMD_SINGLE_RECEIVE
  • I2C_MASTER_CMD_BURST_SEND_START
  • I2C_MASTER_CMD_BURST_SEND_CONT
  • I2C_MASTER_CMD_BURST_SEND_FINISH
  • I2C_MASTER_CMD_BURST_SEND_ERROR_STOP
  • I2C_MASTER_CMD_BURST_RECEIVE_START
  • I2C_MASTER_CMD_BURST_RECEIVE_CONT
  • I2C_MASTER_CMD_BURST_RECEIVE_FINISH
  • I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP
  • I2C_MASTER_CMD_QUICK_COMMAND
  • I2C_MASTER_CMD_HS_MASTER_CODE_SEND
  • I2C_MASTER_CMD_FIFO_SINGLE_SEND
  • I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE
  • I2C_MASTER_CMD_FIFO_BURST_SEND_START
  • I2C_MASTER_CMD_FIFO_BURST_SEND_CONT
  • I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH
  • I2C_MASTER_CMD_FIFO_BURST_SEND_ERROR_STOP
  • I2C_MASTER_CMD_FIFO_BURST_RECEIVE_START
  • I2C_MASTER_CMD_FIFO_BURST_RECEIVE_CONT
  • I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH
  • I2C_MASTER_CMD_FIFO_BURST_RECEIVE_ERROR_STOP
Note
Not all Tiva devices have an I2C FIFO and support the FIFO commands. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1284 of file i2c.c.

References ASSERT, HWREG, I2C_MASTER_CMD_BURST_RECEIVE_CONT, I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP, I2C_MASTER_CMD_BURST_RECEIVE_FINISH, I2C_MASTER_CMD_BURST_RECEIVE_START, I2C_MASTER_CMD_BURST_SEND_CONT, I2C_MASTER_CMD_BURST_SEND_ERROR_STOP, I2C_MASTER_CMD_BURST_SEND_FINISH, I2C_MASTER_CMD_BURST_SEND_START, I2C_MASTER_CMD_FIFO_BURST_RECEIVE_CONT, I2C_MASTER_CMD_FIFO_BURST_RECEIVE_ERROR_STOP, I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH, I2C_MASTER_CMD_FIFO_BURST_RECEIVE_START, I2C_MASTER_CMD_FIFO_BURST_SEND_CONT, I2C_MASTER_CMD_FIFO_BURST_SEND_ERROR_STOP, I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH, I2C_MASTER_CMD_FIFO_BURST_SEND_START, I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE, I2C_MASTER_CMD_FIFO_SINGLE_SEND, I2C_MASTER_CMD_HS_MASTER_CODE_SEND, I2C_MASTER_CMD_QUICK_COMMAND, I2C_MASTER_CMD_SINGLE_RECEIVE, I2C_MASTER_CMD_SINGLE_SEND, and I2C_O_MCS.

1285 {
1286  //
1287  // Check the arguments.
1288  //
1289  ASSERT(_I2CBaseValid(ui32Base));
1290  ASSERT((ui32Cmd == I2C_MASTER_CMD_SINGLE_SEND) ||
1291  (ui32Cmd == I2C_MASTER_CMD_SINGLE_RECEIVE) ||
1292  (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_START) ||
1293  (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_CONT) ||
1294  (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_FINISH) ||
1295  (ui32Cmd == I2C_MASTER_CMD_BURST_SEND_ERROR_STOP) ||
1296  (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_START) ||
1297  (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_CONT) ||
1298  (ui32Cmd == I2C_MASTER_CMD_BURST_RECEIVE_FINISH) ||
1300  (ui32Cmd == I2C_MASTER_CMD_QUICK_COMMAND) ||
1301  (ui32Cmd == I2C_MASTER_CMD_FIFO_SINGLE_SEND) ||
1302  (ui32Cmd == I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE) ||
1303  (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_SEND_START) ||
1304  (ui32Cmd == I2C_MASTER_CMD_FIFO_BURST_SEND_CONT) ||
1311  (ui32Cmd == I2C_MASTER_CMD_HS_MASTER_CODE_SEND));
1312 
1313  //
1314  // Send the command.
1315  //
1316  HWREG(ui32Base + I2C_O_MCS) = ui32Cmd;
1317 }
#define I2C_MASTER_CMD_FIFO_BURST_SEND_START
Definition: i2c.h:103
#define I2C_O_MCS
Definition: hw_i2c.h:49
#define I2C_MASTER_CMD_BURST_RECEIVE_FINISH
Definition: i2c.h:91
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_START
Definition: i2c.h:111
#define I2C_MASTER_CMD_FIFO_SINGLE_RECEIVE
Definition: i2c.h:101
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MASTER_CMD_FIFO_BURST_SEND_ERROR_STOP
Definition: i2c.h:109
#define I2C_MASTER_CMD_HS_MASTER_CODE_SEND
Definition: i2c.h:97
#define I2C_MASTER_CMD_BURST_SEND_START
Definition: i2c.h:77
#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_FINISH
Definition: i2c.h:115
#define I2C_MASTER_CMD_FIFO_BURST_SEND_FINISH
Definition: i2c.h:107
#define I2C_MASTER_CMD_BURST_RECEIVE_START
Definition: i2c.h:87
#define I2C_MASTER_CMD_QUICK_COMMAND
Definition: i2c.h:95
#define I2C_MASTER_CMD_BURST_SEND_FINISH
Definition: i2c.h:81
#define I2C_MASTER_CMD_FIFO_BURST_SEND_CONT
Definition: i2c.h:105
#define I2C_MASTER_CMD_SINGLE_RECEIVE
Definition: i2c.h:75
#define I2C_MASTER_CMD_BURST_RECEIVE_CONT
Definition: i2c.h:89
#define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP
Definition: i2c.h:93
#define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP
Definition: i2c.h:85
#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_ERROR_STOP
Definition: i2c.h:117
#define I2C_MASTER_CMD_SINGLE_SEND
Definition: i2c.h:73
#define I2C_MASTER_CMD_FIFO_SINGLE_SEND
Definition: i2c.h:99
#define I2C_MASTER_CMD_BURST_SEND_CONT
Definition: i2c.h:79
#define I2C_MASTER_CMD_FIFO_BURST_RECEIVE_CONT
Definition: i2c.h:113
uint32_t I2CMasterDataGet ( uint32_t  ui32Base)

Receives a byte that has been sent to the I2C Master.

Parameters
ui32Baseis the base address of the I2C module.

This function reads a byte of data from the I2C Master Data Register.

Returns
Returns the byte received from by the I2C Master, cast as an uint32_t.

Definition at line 1409 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MDR.

1410 {
1411  //
1412  // Check the arguments.
1413  //
1414  ASSERT(_I2CBaseValid(ui32Base));
1415 
1416  //
1417  // Read a byte.
1418  //
1419  return(HWREG(ui32Base + I2C_O_MDR));
1420 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MDR
Definition: hw_i2c.h:50
void I2CMasterDataPut ( uint32_t  ui32Base,
uint8_t  ui8Data 
)

Transmits a byte from the I2C Master.

Parameters
ui32Baseis the base address of the I2C module.
ui8Datadata to be transmitted from the I2C Master.

This function places the supplied data into I2C Master Data Register.

Returns
None.

Definition at line 1383 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MDR.

1384 {
1385  //
1386  // Check the arguments.
1387  //
1388  ASSERT(_I2CBaseValid(ui32Base));
1389 
1390  //
1391  // Write the byte.
1392  //
1393  HWREG(ui32Base + I2C_O_MDR) = ui8Data;
1394 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MDR
Definition: hw_i2c.h:50
void I2CMasterDisable ( uint32_t  ui32Base)

Disables the I2C master block.

Parameters
ui32Baseis the base address of the I2C module.

This function disables operation of the I2C master block.

Returns
None.

Definition at line 408 of file i2c.c.

References ASSERT, HWREG, I2C_MCR_MFE, and I2C_O_MCR.

409 {
410  //
411  // Check the arguments.
412  //
413  ASSERT(_I2CBaseValid(ui32Base));
414 
415  //
416  // Disable the master block.
417  //
418  HWREG(ui32Base + I2C_O_MCR) &= ~(I2C_MCR_MFE);
419 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MCR_MFE
Definition: hw_i2c.h:239
#define I2C_O_MCR
Definition: hw_i2c.h:57
void I2CMasterEnable ( uint32_t  ui32Base)

Enables the I2C Master block.

Parameters
ui32Baseis the base address of the I2C module.

This function enables operation of the I2C Master block.

Returns
None.

Definition at line 353 of file i2c.c.

References ASSERT, HWREG, I2C_MCR_MFE, and I2C_O_MCR.

Referenced by I2CMasterInitExpClk().

354 {
355  //
356  // Check the arguments.
357  //
358  ASSERT(_I2CBaseValid(ui32Base));
359 
360  //
361  // Enable the master block.
362  //
363  HWREG(ui32Base + I2C_O_MCR) |= I2C_MCR_MFE;
364 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MCR_MFE
Definition: hw_i2c.h:239
#define I2C_O_MCR
Definition: hw_i2c.h:57

Here is the caller graph for this function:

uint32_t I2CMasterErr ( uint32_t  ui32Base)

Gets the error status of the I2C Master.

Parameters
ui32Baseis the base address of the I2C module.

This function is used to obtain the error status of the Master send and receive operations.

Returns
Returns the error status, as one of I2C_MASTER_ERR_NONE, I2C_MASTER_ERR_ADDR_ACK, I2C_MASTER_ERR_DATA_ACK, or I2C_MASTER_ERR_ARB_LOST.

Definition at line 1334 of file i2c.c.

References ASSERT, HWREG, I2C_MASTER_ERR_NONE, I2C_MCS_ADRACK, I2C_MCS_ARBLST, I2C_MCS_BUSY, I2C_MCS_DATACK, I2C_MCS_ERROR, and I2C_O_MCS.

1335 {
1336  uint32_t ui32Err;
1337 
1338  //
1339  // Check the arguments.
1340  //
1341  ASSERT(_I2CBaseValid(ui32Base));
1342 
1343  //
1344  // Get the raw error state
1345  //
1346  ui32Err = HWREG(ui32Base + I2C_O_MCS);
1347 
1348  //
1349  // If the I2C master is busy, then all the other bit are invalid, and
1350  // don't have an error to report.
1351  //
1352  if(ui32Err & I2C_MCS_BUSY)
1353  {
1354  return(I2C_MASTER_ERR_NONE);
1355  }
1356 
1357  //
1358  // Check for errors.
1359  //
1360  if(ui32Err & (I2C_MCS_ERROR | I2C_MCS_ARBLST))
1361  {
1362  return(ui32Err & (I2C_MCS_ARBLST | I2C_MCS_DATACK | I2C_MCS_ADRACK));
1363  }
1364  else
1365  {
1366  return(I2C_MASTER_ERR_NONE);
1367  }
1368 }
#define I2C_O_MCS
Definition: hw_i2c.h:49
#define I2C_MCS_ADRACK
Definition: hw_i2c.h:105
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MCS_DATACK
Definition: hw_i2c.h:104
#define I2C_MASTER_ERR_NONE
Definition: i2c.h:147
#define I2C_MCS_ERROR
Definition: hw_i2c.h:107
#define I2C_MCS_ARBLST
Definition: hw_i2c.h:101
#define I2C_MCS_BUSY
Definition: hw_i2c.h:110
void I2CMasterGlitchFilterConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the I2C Master glitch filter.

Parameters
ui32Baseis the base address of the I2C module.
ui32Configis the glitch filter configuration.

This function configures the I2C Master glitch filter. The value passed in to ui32Config determines the sampling range of the glitch filter, which is configurable between 1 and 32 system clock cycles. The default configuration of the glitch filter is 0 system clock cycles, which means that it's disabled.

The ui32Config field should be any of the following values:

  • I2C_MASTER_GLITCH_FILTER_DISABLED
  • I2C_MASTER_GLITCH_FILTER_1
  • I2C_MASTER_GLITCH_FILTER_2
  • I2C_MASTER_GLITCH_FILTER_3
  • I2C_MASTER_GLITCH_FILTER_4
  • I2C_MASTER_GLITCH_FILTER_8
  • I2C_MASTER_GLITCH_FILTER_16
  • I2C_MASTER_GLITCH_FILTER_32
Note
Not all Tiva devices support this function. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 2056 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MTPR.

2057 {
2058  //
2059  // Check the arguments.
2060  //
2061  ASSERT(_I2CBaseValid(ui32Base));
2062 
2063  //
2064  // Configure the glitch filter field of MTPR.
2065  //
2066  HWREG(ui32Base + I2C_O_MTPR) |= ui32Config;
2067 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MTPR
Definition: hw_i2c.h:51
void I2CMasterInitExpClk ( uint32_t  ui32Base,
uint32_t  ui32I2CClk,
bool  bFast 
)

Initializes the I2C Master block.

Parameters
ui32Baseis the base address of the I2C module.
ui32I2CClkis the rate of the clock supplied to the I2C module.
bFastset up for fast data transfers.

This function initializes operation of the I2C Master block by configuring the bus speed for the master and enabling the I2C Master block.

If the parameter bFast is true, then the master block is set up to transfer data at 400 Kbps; otherwise, it is set up to transfer data at 100 Kbps. If Fast Mode Plus (1 Mbps) is desired, software should manually write the I2CMTPR after calling this function. For High Speed (3.4 Mbps) mode, a specific command is used to switch to the faster clocks after the initial communication with the slave is done at either 100 Kbps or 400 Kbps.

The peripheral clock is the same as the processor clock. This value is returned by SysCtlClockGet(), or it can be explicitly hard coded if it is constant and known (to save the code/execution overhead of a call to SysCtlClockGet()).

Returns
None.

Definition at line 202 of file i2c.c.

References ASSERT, HWREG, I2C_MTPR_HS, I2C_O_MTPR, I2C_O_PP, I2C_PP_HS, and I2CMasterEnable().

204 {
205  uint32_t ui32SCLFreq;
206  uint32_t ui32TPR;
207 
208  //
209  // Check the arguments.
210  //
211  ASSERT(_I2CBaseValid(ui32Base));
212 
213  //
214  // Must enable the device before doing anything else.
215  //
216  I2CMasterEnable(ui32Base);
217 
218  //
219  // Get the desired SCL speed.
220  //
221  if(bFast == true)
222  {
223  ui32SCLFreq = 400000;
224  }
225  else
226  {
227  ui32SCLFreq = 100000;
228  }
229 
230  //
231  // Compute the clock divider that achieves the fastest speed less than or
232  // equal to the desired speed. The numerator is biased to favor a larger
233  // clock divider so that the resulting clock is always less than or equal
234  // to the desired clock, never greater.
235  //
236  ui32TPR = ((ui32I2CClk + (2 * 10 * ui32SCLFreq) - 1) /
237  (2 * 10 * ui32SCLFreq)) - 1;
238  HWREG(ui32Base + I2C_O_MTPR) = ui32TPR;
239 
240  //
241  // Check to see if this I2C peripheral is High-Speed enabled. If yes, also
242  // choose the fastest speed that is less than or equal to 3.4 Mbps.
243  //
244  if(HWREG(ui32Base + I2C_O_PP) & I2C_PP_HS)
245  {
246  ui32TPR = ((ui32I2CClk + (2 * 3 * 3400000) - 1) /
247  (2 * 3 * 3400000)) - 1;
248  HWREG(ui32Base + I2C_O_MTPR) = I2C_MTPR_HS | ui32TPR;
249  }
250 }
void I2CMasterEnable(uint32_t ui32Base)
Definition: i2c.c:353
#define I2C_O_PP
Definition: hw_i2c.h:77
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_MTPR_HS
Definition: hw_i2c.h:135
#define I2C_PP_HS
Definition: hw_i2c.h:461
#define I2C_O_MTPR
Definition: hw_i2c.h:51

Here is the call graph for this function:

void I2CMasterIntClear ( uint32_t  ui32Base)

Clears I2C Master interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.

The I2C Master interrupt source is cleared, so that it no longer asserts. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.

Definition at line 974 of file i2c.c.

References ASSERT, HWREG, I2C_MICR_IC, I2C_O_MICR, and I2C_O_MMIS.

975 {
976  //
977  // Check the arguments.
978  //
979  ASSERT(_I2CBaseValid(ui32Base));
980 
981  //
982  // Clear the I2C master interrupt source.
983  //
984  HWREG(ui32Base + I2C_O_MICR) = I2C_MICR_IC;
985 
986  //
987  // Workaround for I2C master interrupt clear errata for rev B Tiva
988  // devices. For later devices, this write is ignored and therefore
989  // harmless (other than the slight performance hit).
990  //
991  HWREG(ui32Base + I2C_O_MMIS) = I2C_MICR_IC;
992 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_MICR
Definition: hw_i2c.h:56
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MMIS
Definition: hw_i2c.h:54
#define I2C_MICR_IC
Definition: hw_i2c.h:230
void I2CMasterIntClearEx ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears I2C Master interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.
ui32IntFlagsis a bit mask of the interrupt sources to be cleared.

The specified I2C Master interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to I2CMasterIntEnableEx().

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.

Definition at line 1021 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MICR.

1022 {
1023  //
1024  // Check the arguments.
1025  //
1026  ASSERT(_I2CBaseValid(ui32Base));
1027 
1028  //
1029  // Clear the I2C master interrupt source.
1030  //
1031  HWREG(ui32Base + I2C_O_MICR) = ui32IntFlags;
1032 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_O_MICR
Definition: hw_i2c.h:56
#define ASSERT(expr)
Definition: debug.h:67
void I2CMasterIntDisable ( uint32_t  ui32Base)

Disables the I2C Master interrupt.

Parameters
ui32Baseis the base address of the I2C module.

This function disables the I2C Master interrupt source.

Returns
None.

Definition at line 697 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MIMR.

698 {
699  //
700  // Check the arguments.
701  //
702  ASSERT(_I2CBaseValid(ui32Base));
703 
704  //
705  // Disable the master interrupt.
706  //
707  HWREG(ui32Base + I2C_O_MIMR) = 0;
708 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MIMR
Definition: hw_i2c.h:52
void I2CMasterIntDisableEx ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables individual I2C Master interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.
ui32IntFlagsis the bit mask of the interrupt sources to be disabled.

This function disables the indicated I2C Master interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to I2CMasterIntEnableEx().

Returns
None.

Definition at line 729 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MIMR.

730 {
731  //
732  // Check the arguments.
733  //
734  ASSERT(_I2CBaseValid(ui32Base));
735 
736  //
737  // Disable the master interrupt.
738  //
739  HWREG(ui32Base + I2C_O_MIMR) &= ~ui32IntFlags;
740 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MIMR
Definition: hw_i2c.h:52
void I2CMasterIntEnable ( uint32_t  ui32Base)

Enables the I2C Master interrupt.

Parameters
ui32Baseis the base address of the I2C module.

This function enables the I2C Master interrupt source.

Returns
None.

Definition at line 556 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MIMR.

557 {
558  //
559  // Check the arguments.
560  //
561  ASSERT(_I2CBaseValid(ui32Base));
562 
563  //
564  // Enable the master interrupt.
565  //
566  HWREG(ui32Base + I2C_O_MIMR) = 1;
567 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MIMR
Definition: hw_i2c.h:52
void I2CMasterIntEnableEx ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables individual I2C Master interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.
ui32IntFlagsis the bit mask of the interrupt sources to be enabled.

This function enables the indicated I2C Master interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter is the logical OR of any of the following:

  • I2C_MASTER_INT_RX_FIFO_FULL - RX FIFO Full interrupt
  • I2C_MASTER_INT_TX_FIFO_EMPTY - TX FIFO Empty interrupt
  • I2C_MASTER_INT_RX_FIFO_REQ - RX FIFO Request interrupt
  • I2C_MASTER_INT_TX_FIFO_REQ - TX FIFO Request interrupt
  • I2C_MASTER_INT_ARB_LOST - Arbitration Lost interrupt
  • I2C_MASTER_INT_STOP - Stop Condition interrupt
  • I2C_MASTER_INT_START - Start Condition interrupt
  • I2C_MASTER_INT_NACK - Address/Data NACK interrupt
  • I2C_MASTER_INT_TX_DMA_DONE - TX DMA Complete interrupt
  • I2C_MASTER_INT_RX_DMA_DONE - RX DMA Complete interrupt
  • I2C_MASTER_INT_TIMEOUT - Clock Timeout interrupt
  • I2C_MASTER_INT_DATA - Data interrupt
Note
Not all Tiva devices support all of the listed interrupt sources. Please consult the device data sheet to determine if these features are supported.
Returns
None.

Definition at line 603 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MIMR.

604 {
605  //
606  // Check the arguments.
607  //
608  ASSERT(_I2CBaseValid(ui32Base));
609 
610  //
611  // Enable the master interrupt.
612  //
613  HWREG(ui32Base + I2C_O_MIMR) |= ui32IntFlags;
614 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MIMR
Definition: hw_i2c.h:52
bool I2CMasterIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current I2C Master interrupt status.

Parameters
ui32Baseis the base address of the I2C module.
bMaskedis false if the raw interrupt status is requested and true if the masked interrupt status is requested.

This function returns the interrupt status for the I2C module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
The current interrupt status, returned as true if active or false if not active.

Definition at line 816 of file i2c.c.

References ASSERT, HWREG, I2C_O_MMIS, and I2C_O_MRIS.

817 {
818  //
819  // Check the arguments.
820  //
821  ASSERT(_I2CBaseValid(ui32Base));
822 
823  //
824  // Return either the interrupt status or the raw interrupt status as
825  // requested.
826  //
827  if(bMasked)
828  {
829  return((HWREG(ui32Base + I2C_O_MMIS)) ? true : false);
830  }
831  else
832  {
833  return((HWREG(ui32Base + I2C_O_MRIS)) ? true : false);
834  }
835 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MMIS
Definition: hw_i2c.h:54
#define I2C_O_MRIS
Definition: hw_i2c.h:53
uint32_t I2CMasterIntStatusEx ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current I2C Master interrupt status.

Parameters
ui32Baseis the base address of the I2C module.
bMaskedis false if the raw interrupt status is requested and true if the masked interrupt status is requested.

This function returns the interrupt status for the I2C module. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
Returns the current interrupt status, enumerated as a bit field of values described in I2CMasterIntEnableEx().

Definition at line 854 of file i2c.c.

References ASSERT, HWREG, I2C_O_MMIS, and I2C_O_MRIS.

855 {
856  //
857  // Check the arguments.
858  //
859  ASSERT(_I2CBaseValid(ui32Base));
860 
861  //
862  // Return either the interrupt status or the raw interrupt status as
863  // requested.
864  //
865  if(bMasked)
866  {
867  return(HWREG(ui32Base + I2C_O_MMIS));
868  }
869  else
870  {
871  return(HWREG(ui32Base + I2C_O_MRIS));
872  }
873 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MMIS
Definition: hw_i2c.h:54
#define I2C_O_MRIS
Definition: hw_i2c.h:53
uint32_t I2CMasterLineStateGet ( uint32_t  ui32Base)

Reads the state of the SDA and SCL pins.

Parameters
ui32Baseis the base address of the I2C module.

This function returns the state of the I2C bus by providing the real time values of the SDA and SCL pins.

Note
Not all Tiva devices support this function. Please consult the device data sheet to determine if this feature is supported.
Returns
Returns the state of the bus with SDA in bit position 1 and SCL in bit position 0.

Definition at line 1160 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MBMON.

1161 {
1162  //
1163  // Check the arguments.
1164  //
1165  ASSERT(_I2CBaseValid(ui32Base));
1166 
1167  //
1168  // Return the line state.
1169  //
1170  return(HWREG(ui32Base + I2C_O_MBMON));
1171 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MBMON
Definition: hw_i2c.h:60
void I2CMasterSlaveAddrSet ( uint32_t  ui32Base,
uint8_t  ui8SlaveAddr,
bool  bReceive 
)

Sets the address that the I2C Master places on the bus.

Parameters
ui32Baseis the base address of the I2C module.
ui8SlaveAddr7-bit slave address
bReceiveflag indicating the type of communication with the slave

This function configures the address that the I2C Master places on the bus when initiating a transaction. When the bReceive parameter is set to true, the address indicates that the I2C Master is initiating a read from the slave; otherwise the address indicates that the I2C Master is initiating a write to the slave.

Returns
None.

Definition at line 1128 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MSA.

1130 {
1131  //
1132  // Check the arguments.
1133  //
1134  ASSERT(_I2CBaseValid(ui32Base));
1135  ASSERT(!(ui8SlaveAddr & 0x80));
1136 
1137  //
1138  // Set the address of the slave with which the master will communicate.
1139  //
1140  HWREG(ui32Base + I2C_O_MSA) = (ui8SlaveAddr << 1) | bReceive;
1141 }
#define I2C_O_MSA
Definition: hw_i2c.h:48
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
void I2CMasterTimeoutSet ( uint32_t  ui32Base,
uint32_t  ui32Value 
)

Sets the Master clock timeout value.

Parameters
ui32Baseis the base address of the I2C module.
ui32Valueis the number of I2C clocks before the timeout is asserted.

This function enables and configures the clock low timeout feature in the I2C peripheral. This feature is implemented as a 12-bit counter, with the upper 8-bits being programmable. For example, to program a timeout of 20ms with a 100-kHz SCL frequency, ui32Value is 0x7d.

Note
Not all Tiva devices support this function. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1442 of file i2c.c.

References ASSERT, HWREG, and I2C_O_MCLKOCNT.

1443 {
1444  //
1445  // Check the arguments.
1446  //
1447  ASSERT(_I2CBaseValid(ui32Base));
1448 
1449  //
1450  // Write the timeout value.
1451  //
1452  HWREG(ui32Base + I2C_O_MCLKOCNT) = ui32Value;
1453 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_MCLKOCNT
Definition: hw_i2c.h:58
void I2CRxFIFOConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the I2C receive (RX) FIFO.

Parameters
ui32Baseis the base address of the I2C module.
ui32Configis the configuration of the FIFO using specified macros.

This configures the I2C peripheral's receive FIFO. The receive FIFO can be used by the master or slave, but not both. The following macros are used to configure the RX FIFO behavior for master or slave, with or without DMA:

I2C_FIFO_CFG_RX_MASTER, I2C_FIFO_CFG_RX_SLAVE, I2C_FIFO_CFG_RX_MASTER_DMA, I2C_FIFO_CFG_RX_SLAVE_DMA

To select the trigger level, one of the following macros should be used:

I2C_FIFO_CFG_RX_TRIG_1, I2C_FIFO_CFG_RX_TRIG_2, I2C_FIFO_CFG_RX_TRIG_3, I2C_FIFO_CFG_RX_TRIG_4, I2C_FIFO_CFG_RX_TRIG_5, I2C_FIFO_CFG_RX_TRIG_6, I2C_FIFO_CFG_RX_TRIG_7, I2C_FIFO_CFG_RX_TRIG_8

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1729 of file i2c.c.

References ASSERT, HWREG, and I2C_O_FIFOCTL.

1730 {
1731  //
1732  // Check the arguments.
1733  //
1734  ASSERT(_I2CBaseValid(ui32Base));
1735 
1736  //
1737  // Clear receive configuration data.
1738  //
1739  HWREG(ui32Base + I2C_O_FIFOCTL) &= 0x0000ffff;
1740 
1741  //
1742  // Store new receive configuration data.
1743  //
1744  HWREG(ui32Base + I2C_O_FIFOCTL) |= ui32Config;
1745 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_FIFOCTL
Definition: hw_i2c.h:75
void I2CRxFIFOFlush ( uint32_t  ui32Base)

Flushes the receive (RX) FIFO.

Parameters
ui32Baseis the base address of the I2C module.

This function flushes the I2C receive FIFO.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1762 of file i2c.c.

References ASSERT, HWREG, I2C_FIFOCTL_RXFLUSH, and I2C_O_FIFOCTL.

1763 {
1764  //
1765  // Check the arguments.
1766  //
1767  ASSERT(_I2CBaseValid(ui32Base));
1768 
1769  //
1770  // Flush the TX FIFO.
1771  //
1772  HWREG(ui32Base + I2C_O_FIFOCTL) |= I2C_FIFOCTL_RXFLUSH;
1773 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_FIFOCTL
Definition: hw_i2c.h:75
#define I2C_FIFOCTL_RXFLUSH
Definition: hw_i2c.h:431
void I2CSlaveACKOverride ( uint32_t  ui32Base,
bool  bEnable 
)

Configures ACK override behavior of the I2C Slave.

Parameters
ui32Baseis the base address of the I2C module.
bEnableenables or disables ACK override.

This function enables or disables ACK override, allowing the user application to drive the value on SDA during the ACK cycle.

Note
Not all Tiva devices support this function. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1472 of file i2c.c.

References ASSERT, HWREG, I2C_O_SACKCTL, and I2C_SACKCTL_ACKOEN.

1473 {
1474  //
1475  // Check the arguments.
1476  //
1477  ASSERT(_I2CBaseValid(ui32Base));
1478 
1479  //
1480  // Enable or disable based on bEnable.
1481  //
1482  if(bEnable)
1483  {
1484  HWREG(ui32Base + I2C_O_SACKCTL) |= I2C_SACKCTL_ACKOEN;
1485  }
1486  else
1487  {
1488  HWREG(ui32Base + I2C_O_SACKCTL) &= ~I2C_SACKCTL_ACKOEN;
1489  }
1490 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_SACKCTL_ACKOEN
Definition: hw_i2c.h:415
#define I2C_O_SACKCTL
Definition: hw_i2c.h:73
void I2CSlaveACKValueSet ( uint32_t  ui32Base,
bool  bACK 
)

Writes the ACK value.

Parameters
ui32Baseis the base address of the I2C module.
bACKchooses whether to ACK (true) or NACK (false) the transfer.

This function puts the desired ACK value on SDA during the ACK cycle. The value written is only valid when ACK override is enabled using I2CSlaveACKOverride().

Returns
None.

Definition at line 1507 of file i2c.c.

References ASSERT, HWREG, I2C_O_SACKCTL, and I2C_SACKCTL_ACKOVAL.

1508 {
1509  //
1510  // Check the arguments.
1511  //
1512  ASSERT(_I2CBaseValid(ui32Base));
1513 
1514  //
1515  // ACK or NACK based on the value of bACK.
1516  //
1517  if(bACK)
1518  {
1519  HWREG(ui32Base + I2C_O_SACKCTL) &= ~I2C_SACKCTL_ACKOVAL;
1520  }
1521  else
1522  {
1523  HWREG(ui32Base + I2C_O_SACKCTL) |= I2C_SACKCTL_ACKOVAL;
1524  }
1525 }
#define HWREG(x)
Definition: hw_types.h:48
#define I2C_SACKCTL_ACKOVAL
Definition: hw_i2c.h:414
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SACKCTL
Definition: hw_i2c.h:73
void I2CSlaveAddressSet ( uint32_t  ui32Base,
uint8_t  ui8AddrNum,
uint8_t  ui8SlaveAddr 
)

Sets the I2C slave address.

Parameters
ui32Baseis the base address of the I2C module.
ui8AddrNumdetermines which slave address is set.
ui8SlaveAddris the 7-bit slave address

This function writes the specified slave address. The ui32AddrNum field dictates which slave address is configured. For example, a value of 0 configures the primary address and a value of 1 configures the secondary.

Note
Not all Tiva devices support a secondary address. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 307 of file i2c.c.

References ASSERT, HWREG, I2C_O_SOAR, I2C_O_SOAR2, and I2C_SOAR2_OAR2EN.

308 {
309  //
310  // Check the arguments.
311  //
312  ASSERT(_I2CBaseValid(ui32Base));
313  ASSERT(!(ui8AddrNum > 1));
314  ASSERT(!(ui8SlaveAddr & 0x80));
315 
316  //
317  // Determine which slave address is being set.
318  //
319  switch(ui8AddrNum)
320  {
321  //
322  // Set up the primary slave address.
323  //
324  case 0:
325  {
326  HWREG(ui32Base + I2C_O_SOAR) = ui8SlaveAddr;
327  break;
328  }
329 
330  //
331  // Set up and enable the secondary slave address.
332  //
333  case 1:
334  {
335  HWREG(ui32Base + I2C_O_SOAR2) = I2C_SOAR2_OAR2EN | ui8SlaveAddr;
336  break;
337  }
338  }
339 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_SOAR2_OAR2EN
Definition: hw_i2c.h:405
#define I2C_O_SOAR
Definition: hw_i2c.h:64
#define I2C_O_SOAR2
Definition: hw_i2c.h:72
uint32_t I2CSlaveDataGet ( uint32_t  ui32Base)

Receives a byte that has been sent to the I2C Slave.

Parameters
ui32Baseis the base address of the I2C module.

This function reads a byte of data from the I2C Slave Data Register.

Returns
Returns the byte received from by the I2C Slave, cast as an uint32_t.

Definition at line 1613 of file i2c.c.

References ASSERT, HWREG, and I2C_O_SDR.

1614 {
1615  //
1616  // Check the arguments.
1617  //
1618  ASSERT(_I2CBaseValid(ui32Base));
1619 
1620  //
1621  // Read a byte.
1622  //
1623  return(HWREG(ui32Base + I2C_O_SDR));
1624 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SDR
Definition: hw_i2c.h:66
void I2CSlaveDataPut ( uint32_t  ui32Base,
uint8_t  ui8Data 
)

Transmits a byte from the I2C Slave.

Parameters
ui32Baseis the base address of the I2C module.
ui8Datais the data to be transmitted from the I2C Slave

This function places the supplied data into I2C Slave Data Register.

Returns
None.

Definition at line 1587 of file i2c.c.

References ASSERT, HWREG, and I2C_O_SDR.

1588 {
1589  //
1590  // Check the arguments.
1591  //
1592  ASSERT(_I2CBaseValid(ui32Base));
1593 
1594  //
1595  // Write the byte.
1596  //
1597  HWREG(ui32Base + I2C_O_SDR) = ui8Data;
1598 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SDR
Definition: hw_i2c.h:66
void I2CSlaveDisable ( uint32_t  ui32Base)

Disables the I2C slave block.

Parameters
ui32Baseis the base address of the I2C module.

This function disables operation of the I2C slave block.

Returns
None.

Definition at line 433 of file i2c.c.

References ASSERT, HWREG, I2C_MCR_SFE, I2C_O_MCR, and I2C_O_SCSR.

434 {
435  //
436  // Check the arguments.
437  //
438  ASSERT(_I2CBaseValid(ui32Base));
439 
440  //
441  // Disable the slave.
442  //
443  HWREG(ui32Base + I2C_O_SCSR) = 0;
444 
445  //
446  // Disable the clock to the slave block.
447  //
448  HWREG(ui32Base + I2C_O_MCR) &= ~(I2C_MCR_SFE);
449 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SCSR
Definition: hw_i2c.h:65
#define I2C_MCR_SFE
Definition: hw_i2c.h:238
#define I2C_O_MCR
Definition: hw_i2c.h:57
void I2CSlaveEnable ( uint32_t  ui32Base)

Enables the I2C Slave block.

Parameters
ui32Baseis the base address of the I2C module.

This fucntion enables operation of the I2C Slave block.

Returns
None.

Definition at line 378 of file i2c.c.

References ASSERT, HWREG, I2C_MCR_SFE, I2C_O_MCR, I2C_O_SCSR, and I2C_SCSR_DA.

Referenced by I2CSlaveInit().

379 {
380  //
381  // Check the arguments.
382  //
383  ASSERT(_I2CBaseValid(ui32Base));
384 
385  //
386  // Enable the clock to the slave block.
387  //
388  HWREG(ui32Base + I2C_O_MCR) |= I2C_MCR_SFE;
389 
390  //
391  // Enable the slave.
392  //
393  HWREG(ui32Base + I2C_O_SCSR) = I2C_SCSR_DA;
394 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SCSR
Definition: hw_i2c.h:65
#define I2C_MCR_SFE
Definition: hw_i2c.h:238
#define I2C_SCSR_DA
Definition: hw_i2c.h:311
#define I2C_O_MCR
Definition: hw_i2c.h:57

Here is the caller graph for this function:

void I2CSlaveFIFODisable ( uint32_t  ui32Base)

Disable FIFO usage for the I2C Slave.

Parameters
ui32Baseis the base address of the I2C module.

This function disables the FIFOs for the I2C Slave. After calling this this function, the FIFOs are disabled, but the Slave remains active.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 2125 of file i2c.c.

References ASSERT, HWREG, I2C_O_SCSR, and I2C_SCSR_DA.

2126 {
2127  //
2128  // Check the arguments.
2129  //
2130  ASSERT(_I2CBaseValid(ui32Base));
2131 
2132  //
2133  // Disable slave FIFOs.
2134  //
2135  HWREG(ui32Base + I2C_O_SCSR) = I2C_SCSR_DA;
2136 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SCSR
Definition: hw_i2c.h:65
#define I2C_SCSR_DA
Definition: hw_i2c.h:311
void I2CSlaveFIFOEnable ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Enables FIFO usage for the I2C Slave.

Parameters
ui32Baseis the base address of the I2C module.
ui32Configis the desired FIFO configuration of the I2C Slave.

This function configures the I2C Slave to use the FIFO(s). This function should be used in combination with I2CTxFIFOConfigSet() and/or I2CRxFIFOConfigSet(), which configure the FIFO trigger level and tell the FIFO hardware whether to interact with the I2C Master or Slave. The application appropriate combination of I2C_SLAVE_TX_FIFO_ENABLE and I2C_SLAVE_RX_FIFO_ENABLE should be passed in to the ui32Config field.

The Slave I2CSCSR register is write-only, so any call to I2CSlaveEnable(), I2CSlaveDisable or I2CSlaveFIFOEnable() overwrites the slave configuration. Therefore, application software should call I2CSlaveEnable() followed by I2CSlaveFIFOEnable() with the desired FIFO configuration.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 2096 of file i2c.c.

References ASSERT, HWREG, I2C_O_SCSR, and I2C_SCSR_DA.

2097 {
2098  //
2099  // Check the arguments.
2100  //
2101  ASSERT(_I2CBaseValid(ui32Base));
2102 
2103  //
2104  // Enable the FIFOs for the slave.
2105  //
2106  HWREG(ui32Base + I2C_O_SCSR) = ui32Config | I2C_SCSR_DA;
2107 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SCSR
Definition: hw_i2c.h:65
#define I2C_SCSR_DA
Definition: hw_i2c.h:311
void I2CSlaveInit ( uint32_t  ui32Base,
uint8_t  ui8SlaveAddr 
)

Initializes the I2C Slave block.

Parameters
ui32Baseis the base address of the I2C module.
ui8SlaveAddr7-bit slave address

This function initializes operation of the I2C Slave block by configuring the slave address and enabling the I2C Slave block.

The parameter ui8SlaveAddr is the value that is compared against the slave address sent by an I2C master.

Returns
None.

Definition at line 269 of file i2c.c.

References ASSERT, HWREG, I2C_O_SOAR, and I2CSlaveEnable().

270 {
271  //
272  // Check the arguments.
273  //
274  ASSERT(_I2CBaseValid(ui32Base));
275  ASSERT(!(ui8SlaveAddr & 0x80));
276 
277  //
278  // Must enable the device before doing anything else.
279  //
280  I2CSlaveEnable(ui32Base);
281 
282  //
283  // Set up the slave address.
284  //
285  HWREG(ui32Base + I2C_O_SOAR) = ui8SlaveAddr;
286 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SOAR
Definition: hw_i2c.h:64
void I2CSlaveEnable(uint32_t ui32Base)
Definition: i2c.c:378

Here is the call graph for this function:

void I2CSlaveIntClear ( uint32_t  ui32Base)

Clears I2C Slave interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.

The I2C Slave interrupt source is cleared, so that it no longer asserts. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.

Definition at line 1057 of file i2c.c.

References ASSERT, HWREG, I2C_O_SICR, and I2C_SICR_DATAIC.

1058 {
1059  //
1060  // Check the arguments.
1061  //
1062  ASSERT(_I2CBaseValid(ui32Base));
1063 
1064  //
1065  // Clear the I2C slave interrupt source.
1066  //
1067  HWREG(ui32Base + I2C_O_SICR) = I2C_SICR_DATAIC;
1068 }
#define I2C_SICR_DATAIC
Definition: hw_i2c.h:398
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SICR
Definition: hw_i2c.h:71
void I2CSlaveIntClearEx ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Clears I2C Slave interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.
ui32IntFlagsis a bit mask of the interrupt sources to be cleared.

The specified I2C Slave interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to I2CSlaveIntEnableEx().

Note
Because there is a write buffer in the Cortex-M processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).
Returns
None.

Definition at line 1097 of file i2c.c.

References ASSERT, HWREG, and I2C_O_SICR.

1098 {
1099  //
1100  // Check the arguments.
1101  //
1102  ASSERT(_I2CBaseValid(ui32Base));
1103 
1104  //
1105  // Clear the I2C slave interrupt source.
1106  //
1107  HWREG(ui32Base + I2C_O_SICR) = ui32IntFlags;
1108 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SICR
Definition: hw_i2c.h:71
void I2CSlaveIntDisable ( uint32_t  ui32Base)

Disables the I2C Slave interrupt.

Parameters
ui32Baseis the base address of the I2C module.

This function disables the I2C Slave interrupt source.

Returns
None.

Definition at line 754 of file i2c.c.

References ASSERT, HWREG, I2C_O_SIMR, and I2C_SLAVE_INT_DATA.

755 {
756  //
757  // Check the arguments.
758  //
759  ASSERT(_I2CBaseValid(ui32Base));
760 
761  //
762  // Disable the slave interrupt.
763  //
764  HWREG(ui32Base + I2C_O_SIMR) &= ~I2C_SLAVE_INT_DATA;
765 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SIMR
Definition: hw_i2c.h:67
#define I2C_SLAVE_INT_DATA
Definition: i2c.h:217
void I2CSlaveIntDisableEx ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Disables individual I2C Slave interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.
ui32IntFlagsis the bit mask of the interrupt sources to be disabled.

This function disables the indicated I2C Slave interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter has the same definition as the ui32IntFlags parameter to I2CSlaveIntEnableEx().

Returns
None.

Definition at line 786 of file i2c.c.

References ASSERT, HWREG, and I2C_O_SIMR.

787 {
788  //
789  // Check the arguments.
790  //
791  ASSERT(_I2CBaseValid(ui32Base));
792 
793  //
794  // Disable the slave interrupt.
795  //
796  HWREG(ui32Base + I2C_O_SIMR) &= ~ui32IntFlags;
797 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SIMR
Definition: hw_i2c.h:67
void I2CSlaveIntEnable ( uint32_t  ui32Base)

Enables the I2C Slave interrupt.

Parameters
ui32Baseis the base address of the I2C module.

This function enables the I2C Slave interrupt source.

Returns
None.

Definition at line 628 of file i2c.c.

References ASSERT, HWREG, I2C_O_SIMR, and I2C_SLAVE_INT_DATA.

629 {
630  //
631  // Check the arguments.
632  //
633  ASSERT(_I2CBaseValid(ui32Base));
634 
635  //
636  // Enable the slave interrupt.
637  //
638  HWREG(ui32Base + I2C_O_SIMR) |= I2C_SLAVE_INT_DATA;
639 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SIMR
Definition: hw_i2c.h:67
#define I2C_SLAVE_INT_DATA
Definition: i2c.h:217
void I2CSlaveIntEnableEx ( uint32_t  ui32Base,
uint32_t  ui32IntFlags 
)

Enables individual I2C Slave interrupt sources.

Parameters
ui32Baseis the base address of the I2C module.
ui32IntFlagsis the bit mask of the interrupt sources to be enabled.

This function enables the indicated I2C Slave interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

The ui32IntFlags parameter is the logical OR of any of the following:

  • I2C_SLAVE_INT_RX_FIFO_FULL - RX FIFO Full interrupt
  • I2C_SLAVE_INT_TX_FIFO_EMPTY - TX FIFO Empty interrupt
  • I2C_SLAVE_INT_RX_FIFO_REQ - RX FIFO Request interrupt
  • I2C_SLAVE_INT_TX_FIFO_REQ - TX FIFO Request interrupt
  • I2C_SLAVE_INT_TX_DMA_DONE - TX DMA Complete interrupt
  • I2C_SLAVE_INT_RX_DMA_DONE - RX DMA Complete interrupt
  • I2C_SLAVE_INT_STOP - Stop condition detected interrupt
  • I2C_SLAVE_INT_START - Start condition detected interrupt
  • I2C_SLAVE_INT_DATA - Data interrupt
Note
Not all Tiva devices support the all of the listed interrupts. Please consult the device data sheet to determine if these features are supported.
Returns
None.

Definition at line 672 of file i2c.c.

References ASSERT, HWREG, and I2C_O_SIMR.

673 {
674  //
675  // Check the arguments.
676  //
677  ASSERT(_I2CBaseValid(ui32Base));
678 
679  //
680  // Enable the slave interrupt.
681  //
682  HWREG(ui32Base + I2C_O_SIMR) |= ui32IntFlags;
683 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SIMR
Definition: hw_i2c.h:67
bool I2CSlaveIntStatus ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current I2C Slave interrupt status.

Parameters
ui32Baseis the base address of the I2C module.
bMaskedis false if the raw interrupt status is requested and true if the masked interrupt status is requested.

This function returns the interrupt status for the I2C Slave. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
The current interrupt status, returned as true if active or false if not active.

Definition at line 892 of file i2c.c.

References ASSERT, HWREG, I2C_O_SMIS, and I2C_O_SRIS.

893 {
894  //
895  // Check the arguments.
896  //
897  ASSERT(_I2CBaseValid(ui32Base));
898 
899  //
900  // Return either the interrupt status or the raw interrupt status as
901  // requested.
902  //
903  if(bMasked)
904  {
905  return((HWREG(ui32Base + I2C_O_SMIS)) ? true : false);
906  }
907  else
908  {
909  return((HWREG(ui32Base + I2C_O_SRIS)) ? true : false);
910  }
911 }
#define I2C_O_SMIS
Definition: hw_i2c.h:69
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SRIS
Definition: hw_i2c.h:68
uint32_t I2CSlaveIntStatusEx ( uint32_t  ui32Base,
bool  bMasked 
)

Gets the current I2C Slave interrupt status.

Parameters
ui32Baseis the base address of the I2C module.
bMaskedis false if the raw interrupt status is requested and true if the masked interrupt status is requested.

This function returns the interrupt status for the I2C Slave. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Returns
Returns the current interrupt status, enumerated as a bit field of values described in I2CSlaveIntEnableEx().

Definition at line 930 of file i2c.c.

References ASSERT, HWREG, I2C_O_SMIS, and I2C_O_SRIS.

931 {
932  //
933  // Check the arguments.
934  //
935  ASSERT(_I2CBaseValid(ui32Base));
936 
937  //
938  // Return either the interrupt status or the raw interrupt status as
939  // requested.
940  //
941  if(bMasked)
942  {
943  return(HWREG(ui32Base + I2C_O_SMIS));
944  }
945  else
946  {
947  return(HWREG(ui32Base + I2C_O_SRIS));
948  }
949 }
#define I2C_O_SMIS
Definition: hw_i2c.h:69
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SRIS
Definition: hw_i2c.h:68
uint32_t I2CSlaveStatus ( uint32_t  ui32Base)

Gets the I2C Slave status

Parameters
ui32Baseis the base address of the I2C module.

This function returns the action requested from a master, if any. Possible values are:

  • I2C_SLAVE_ACT_NONE
  • I2C_SLAVE_ACT_RREQ
  • I2C_SLAVE_ACT_TREQ
  • I2C_SLAVE_ACT_RREQ_FBR
  • I2C_SLAVE_ACT_OWN2SEL
  • I2C_SLAVE_ACT_QCMD
  • I2C_SLAVE_ACT_QCMD_DATA
Note
Not all Tiva devices support the second I2C slave's own address or the quick command function. Please consult the device data sheet to determine if these features are supported.
Returns
Returns I2C_SLAVE_ACT_NONE to indicate that no action has been requested of the I2C Slave, I2C_SLAVE_ACT_RREQ to indicate that an I2C master has sent data to the I2C Slave, I2C_SLAVE_ACT_TREQ to indicate that an I2C master has requested that the I2C Slave send data, I2C_SLAVE_ACT_RREQ_FBR to indicate that an I2C master has sent data to the I2C slave and the first byte following the slave's own address has been received, I2C_SLAVE_ACT_OWN2SEL to indicate that the second I2C slave address was matched, I2C_SLAVE_ACT_QCMD to indicate that a quick command was received, and I2C_SLAVE_ACT_QCMD_DATA to indicate that the data bit was set when the quick command was received.

Definition at line 1561 of file i2c.c.

References ASSERT, HWREG, and I2C_O_SCSR.

1562 {
1563  //
1564  // Check the arguments.
1565  //
1566  ASSERT(_I2CBaseValid(ui32Base));
1567 
1568  //
1569  // Return the slave status.
1570  //
1571  return(HWREG(ui32Base + I2C_O_SCSR));
1572 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_SCSR
Definition: hw_i2c.h:65
void I2CTxFIFOConfigSet ( uint32_t  ui32Base,
uint32_t  ui32Config 
)

Configures the I2C transmit (TX) FIFO.

Parameters
ui32Baseis the base address of the I2C module.
ui32Configis the configuration of the FIFO using specified macros.

This configures the I2C peripheral's transmit FIFO. The transmit FIFO can be used by the master or slave, but not both. The following macros are used to configure the TX FIFO behavior for master or slave, with or without DMA:

I2C_FIFO_CFG_TX_MASTER, I2C_FIFO_CFG_TX_SLAVE, I2C_FIFO_CFG_TX_MASTER_DMA, I2C_FIFO_CFG_TX_SLAVE_DMA

To select the trigger level, one of the following macros should be used:

I2C_FIFO_CFG_TX_TRIG_1, I2C_FIFO_CFG_TX_TRIG_2, I2C_FIFO_CFG_TX_TRIG_3, I2C_FIFO_CFG_TX_TRIG_4, I2C_FIFO_CFG_TX_TRIG_5, I2C_FIFO_CFG_TX_TRIG_6, I2C_FIFO_CFG_TX_TRIG_7, I2C_FIFO_CFG_TX_TRIG_8

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1655 of file i2c.c.

References ASSERT, HWREG, and I2C_O_FIFOCTL.

1656 {
1657  //
1658  // Check the arguments.
1659  //
1660  ASSERT(_I2CBaseValid(ui32Base));
1661 
1662  //
1663  // Clear transmit configuration data.
1664  //
1665  HWREG(ui32Base + I2C_O_FIFOCTL) &= 0xffff0000;
1666 
1667  //
1668  // Store new transmit configuration data.
1669  //
1670  HWREG(ui32Base + I2C_O_FIFOCTL) |= ui32Config;
1671 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_FIFOCTL
Definition: hw_i2c.h:75
void I2CTxFIFOFlush ( uint32_t  ui32Base)

Flushes the transmit (TX) FIFO.

Parameters
ui32Baseis the base address of the I2C module.

This function flushes the I2C transmit FIFO.

Note
Not all Tiva devices have an I2C FIFO. Please consult the device data sheet to determine if this feature is supported.
Returns
None.

Definition at line 1688 of file i2c.c.

References ASSERT, HWREG, I2C_FIFOCTL_TXFLUSH, and I2C_O_FIFOCTL.

1689 {
1690  //
1691  // Check the arguments.
1692  //
1693  ASSERT(_I2CBaseValid(ui32Base));
1694 
1695  //
1696  // Flush the TX FIFO.
1697  //
1698  HWREG(ui32Base + I2C_O_FIFOCTL) |= I2C_FIFOCTL_TXFLUSH;
1699 }
#define HWREG(x)
Definition: hw_types.h:48
#define ASSERT(expr)
Definition: debug.h:67
#define I2C_O_FIFOCTL
Definition: hw_i2c.h:75
#define I2C_FIFOCTL_TXFLUSH
Definition: hw_i2c.h:435

Variable Documentation

const int_fast8_t g_i8I2CIntMapRows
static
Initial value:
=
sizeof(g_ppui32I2CIntMap) / sizeof(g_ppui32I2CIntMap[0])
static const uint32_t g_ppui32I2CIntMap[][2]
Definition: i2c.c:63

Definition at line 73 of file i2c.c.

Referenced by _I2CIntNumberGet().

const int_fast8_t g_i8I2CIntMapSnowflakeRows
static
Initial value:
=
static const uint32_t g_ppui32I2CIntMapSnowflake[][2]
Definition: i2c.c:76

Definition at line 89 of file i2c.c.

Referenced by _I2CIntNumberGet().

const uint32_t g_ppui32I2CIntMap[][2]
static
Initial value:
=
{
}
#define I2C1_BASE
Definition: hw_memmap.h:70
#define I2C4_BASE
Definition: hw_memmap.h:125
#define INT_I2C1_TM4C123
Definition: hw_ints.h:102
#define INT_I2C5_TM4C123
Definition: hw_ints.h:145
#define INT_I2C0_TM4C123
Definition: hw_ints.h:72
#define I2C5_BASE
Definition: hw_memmap.h:126
#define INT_I2C3_TM4C123
Definition: hw_ints.h:126
#define INT_I2C2_TM4C123
Definition: hw_ints.h:125
#define I2C0_BASE
Definition: hw_memmap.h:69
#define I2C3_BASE
Definition: hw_memmap.h:72
#define I2C2_BASE
Definition: hw_memmap.h:71
#define INT_I2C4_TM4C123
Definition: hw_ints.h:144

Definition at line 63 of file i2c.c.

Referenced by _I2CIntNumberGet().

const uint32_t g_ppui32I2CIntMapSnowflake[][2]
static
Initial value:
=
{
}
#define INT_I2C7_TM4C129
Definition: hw_ints.h:277
#define INT_I2C8_TM4C129
Definition: hw_ints.h:279
#define INT_I2C9_TM4C129
Definition: hw_ints.h:280
#define INT_I2C0_TM4C129
Definition: hw_ints.h:184
#define I2C9_BASE
Definition: hw_memmap.h:124
#define INT_I2C3_TM4C129
Definition: hw_ints.h:238
#define I2C1_BASE
Definition: hw_memmap.h:70
#define INT_I2C2_TM4C129
Definition: hw_ints.h:237
#define I2C4_BASE
Definition: hw_memmap.h:125
#define I2C5_BASE
Definition: hw_memmap.h:126
#define INT_I2C1_TM4C129
Definition: hw_ints.h:213
#define I2C7_BASE
Definition: hw_memmap.h:128
#define INT_I2C5_TM4C129
Definition: hw_ints.h:246
#define I2C6_BASE
Definition: hw_memmap.h:127
#define I2C0_BASE
Definition: hw_memmap.h:69
#define I2C8_BASE
Definition: hw_memmap.h:123
#define I2C3_BASE
Definition: hw_memmap.h:72
#define I2C2_BASE
Definition: hw_memmap.h:71
#define INT_I2C4_TM4C129
Definition: hw_ints.h:245
#define INT_I2C6_TM4C129
Definition: hw_ints.h:276

Definition at line 76 of file i2c.c.

Referenced by _I2CIntNumberGet().