CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
[i2c] Inter-Integrated Circuit

## Functions
void | I2CMasterInitExpClk (uint32_t ui32Base, uint32_t ui32I2CClk, bool bFast)
| Initializes the I2C Master block. More...
__STATIC_INLINE void | I2CMasterControl (uint32_t ui32Base, uint32_t ui32Cmd)
| Controls the state of the I2C Master module. More...
__STATIC_INLINE void | I2CMasterSlaveAddrSet (uint32_t ui32Base, uint8_t ui8SlaveAddr, bool bReceive)
| Sets the address that the I2C Master will place on the bus. More...
__STATIC_INLINE void | I2CMasterEnable (uint32_t ui32Base)
| Enables the I2C Master block. More...
__STATIC_INLINE void | I2CMasterDisable (uint32_t ui32Base)
| Disables the I2C master block. More...
__STATIC_INLINE bool | I2CMasterBusy (uint32_t ui32Base)
| Indicates whether or not the I2C Master is busy. More...
__STATIC_INLINE bool | I2CMasterBusBusy (uint32_t ui32Base)
| Indicates whether or not the I2C bus is busy. More...
__STATIC_INLINE uint32_t | I2CMasterDataGet (uint32_t ui32Base)
| Receives a byte that has been sent to the I2C Master. More...
__STATIC_INLINE void | I2CMasterDataPut (uint32_t ui32Base, uint8_t ui8Data)
| Transmits a byte from the I2C Master. More...
uint32_t | I2CMasterErr (uint32_t ui32Base)
| Gets the error status of the I2C Master module. More...
__STATIC_INLINE void | I2CMasterIntEnable (uint32_t ui32Base)
| Enables the I2C Master interrupt. More...
__STATIC_INLINE void | I2CMasterIntDisable (uint32_t ui32Base)
| Disables the I2C Master interrupt. More...
__STATIC_INLINE void | I2CMasterIntClear (uint32_t ui32Base)
| Clears I2C Master interrupt sources. More...
__STATIC_INLINE bool | I2CMasterIntStatus (uint32_t ui32Base, bool bMasked)
| Gets the current I2C Master interrupt status. More...
__STATIC_INLINE void | I2CSlaveEnable (uint32_t ui32Base)
| Enables the I2C Slave block. More...
__STATIC_INLINE void | I2CSlaveInit (uint32_t ui32Base, uint8_t ui8SlaveAddr)
| Initializes the I2C Slave block. More...
__STATIC_INLINE void | I2CSlaveAddressSet (uint32_t ui32Base, uint8_t ui8SlaveAddr)
| Sets the I2C slave address. More...
__STATIC_INLINE void | I2CSlaveDisable (uint32_t ui32Base)
| Disables the I2C slave block. More...
__STATIC_INLINE uint32_t | I2CSlaveStatus (uint32_t ui32Base)
| Gets the I2C Slave module status. More...
__STATIC_INLINE uint32_t | I2CSlaveDataGet (uint32_t ui32Base)
| Receives a byte that has been sent to the I2C Slave. More...
__STATIC_INLINE void | I2CSlaveDataPut (uint32_t ui32Base, uint8_t ui8Data)
| Transmits a byte from the I2C Slave. More...
__STATIC_INLINE void | I2CSlaveIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
| Enables individual I2C Slave interrupt sources. More...
__STATIC_INLINE void | I2CSlaveIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
| Disables individual I2C Slave interrupt sources. More...
__STATIC_INLINE void | I2CSlaveIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
| Clears I2C Slave interrupt sources. More...
__STATIC_INLINE uint32_t | I2CSlaveIntStatus (uint32_t ui32Base, bool bMasked)
| Gets the current I2C Slave interrupt status. More...
void | I2CIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
| Registers an interrupt handler for the I2C module. More...
void | I2CIntUnregister (uint32_t ui32Base)
| Unregisters an interrupt handler for the I2C module. More...

## Detailed Description

## Function Documentation

void I2CIntRegister | ( | uint32_t | ui32Base,
|  | void(*)(void) | pfnHandler
| ) |  |

Registers an interrupt handler for the I2C module.

This sets the handler to be called when an I2C interrupt occurs. This will enable 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().

Parameters

  ui32Base | is the base address of the I2C Master module.
  pfnHandler | is a pointer to the function to be called when the I2C interrupt occurs.

Returns
  None

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

Definition at line 150 of file i2c.c.

void I2CIntUnregister | ( | uint32_t | ui32Base | ) |

Unregisters an interrupt handler for the I2C module.

This function will clear the handler to be called when an I2C interrupt occurs. This will also mask off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

Parameters

  ui32Base | is the base address of the I2C Master module.

Returns
  None

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

Definition at line 181 of file i2c.c.

__STATIC_INLINE bool I2CMasterBusBusy | ( | uint32_t | ui32Base | ) |

Indicates whether or not the I2C bus is busy.

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.

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  Returns status of the I2C bus:
  - `true` : I2C bus is busy.
  - `false` : I2C bus is not busy.

Definition at line 403 of file i2c.h.

__STATIC_INLINE bool I2CMasterBusy | ( | uint32_t | ui32Base | ) |

Indicates whether or not the I2C Master is busy.

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

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  Returns status of I2C Master:
  - `true` : I2C Master is busy.
  - `false` : I2C Master is not busy.

Definition at line 367 of file i2c.h.

__STATIC_INLINE void I2CMasterControl | ( | uint32_t | ui32Base,
|  | uint32_t | ui32Cmd
| ) |  |

Controls the state of the I2C Master module.

This function is used to control the state of the Master module send and receive operations.

Parameters

  ui32Base | is the base address of the I2C module.
  ui32Cmd | is the command to be issued by the I2C Master module The 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

Returns
  None

Definition at line 228 of file i2c.h.

__STATIC_INLINE uint32_t I2CMasterDataGet | ( | uint32_t | ui32Base | ) |

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

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

Parameters

  ui32Base | is the base address of the I2C module.

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

Definition at line 436 of file i2c.h.

__STATIC_INLINE void I2CMasterDataPut | ( | uint32_t | ui32Base,
|  | uint8_t | ui8Data
| ) |  |

Transmits a byte from the I2C Master.

This function will place the supplied data into I2C Master Data Register.

Parameters

  ui32Base | is the base address of the I2C module.
  ui8Data | is the data to be transmitted by the I2C Master

Returns
  None

Definition at line 462 of file i2c.h.

__STATIC_INLINE void I2CMasterDisable | ( | uint32_t | ui32Base | ) |

Disables the I2C master block.

This will disable operation of the I2C master block.

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  None

Definition at line 334 of file i2c.h.

__STATIC_INLINE void I2CMasterEnable | ( | uint32_t | ui32Base | ) |

Enables the I2C Master block.

This will enable operation of the I2C Master block.

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  None

Definition at line 304 of file i2c.h.

Referenced by I2CMasterInitExpClk().

uint32_t I2CMasterErr | ( | uint32_t | ui32Base | ) |

Gets the error status of the I2C Master module.

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

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  Returns the error status of the Master module:
  - I2C_MASTER_ERR_NONE
  - I2C_MASTER_ERR_ADDR_ACK
  - I2C_MASTER_ERR_DATA_ACK
  - I2C_MASTER_ERR_ARB_LOST

Definition at line 108 of file i2c.c.

void I2CMasterInitExpClk | ( | uint32_t | ui32Base,
|  | uint32_t | ui32I2CClk,
|  | bool | bFast
| ) |  |

Initializes the I2C Master block.

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, and will have enabled the I2C Master block.

If the parameter `bFast` is `true`, then the master block will be set up to transfer data at 400 kbps; otherwise, it will be set up to transfer data at 100 kbps.

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

Parameters

  ui32Base | is the base address of the I2C module.
  ui32I2CClk | is the rate of the clock supplied to the I2C module.
  bFast | set up for fast data transfers.

Returns
  None

Definition at line 64 of file i2c.c.

__STATIC_INLINE void I2CMasterIntClear | ( | uint32_t | ui32Base | ) |

Clears I2C Master interrupt sources.

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

Note
  Because there is a write buffer in the Cortex-M3 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).

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  None

Definition at line 566 of file i2c.h.

__STATIC_INLINE void I2CMasterIntDisable | ( | uint32_t | ui32Base | ) |

Disables the I2C Master interrupt.

Disables the I2C Master interrupt source.

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  None

Definition at line 530 of file i2c.h.

__STATIC_INLINE void I2CMasterIntEnable | ( | uint32_t | ui32Base | ) |

Enables the I2C Master interrupt.

Enables the I2C Master interrupt source.

Parameters

  ui32Base | is the base address of the I2C module.

Returns
  None

Definition at line 505 of file i2c.h.

__STATIC_INLINE bool I2CMasterIntStatus | ( | uint32_t | ui32Base,
|  | bool | bMasked
| ) |  |

Gets the current I2C Master interrupt status.

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

Parameters

  ui32Base | is the base address of the I2C Master module.
  bMasked | selects either raw or masked interrupt status. `false` : Raw interrupt status is requested. `true` : Masked interrupt status is requested.

Returns
  Returns the current interrupt status.
  - `true` : Active.
  - `false` : Not active.

Definition at line 598 of file i2c.h.

__STATIC_INLINE void I2CMasterSlaveAddrSet | ( | uint32_t | ui32Base,
|  | uint8_t | ui8SlaveAddr,
|  | bool | bReceive
| ) |  |

Sets the address that the I2C Master will place on the bus.

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

Parameters

  ui32Base | is the base address of the I2C module.
  ui8SlaveAddr | is a 7-bit slave address
  bReceive | flag indicates the type of communication with the slave. `true` : I2C Master is initiating a read from the slave. `false` : I2C Master is initiating a write to the slave.

Returns
  None

Definition at line 277 of file i2c.h.

__STATIC_INLINE void I2CSlaveAddressSet | ( | uint32_t | ui32Base,
|  | uint8_t | ui8SlaveAddr
| ) |  |

Sets the I2C slave address.

This function writes the specified slave address.

Parameters

  ui32Base | is the base address of the I2C Slave module.
  ui8SlaveAddr | is the 7-bit slave address

Returns
  None.

Definition at line 699 of file i2c.h.

__STATIC_INLINE uint32_t I2CSlaveDataGet | ( | uint32_t | ui32Base | ) |

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

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

Parameters

  ui32Base | is the base address of the I2C Slave module.

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

Definition at line 786 of file i2c.h.

__STATIC_INLINE void I2CSlaveDataPut | ( | uint32_t | ui32Base,
|  | uint8_t | ui8Data
| ) |  |

Transmits a byte from the I2C Slave.

This function will place the supplied data into I2C Slave Data Register.

Parameters

  ui32Base | is the base address of the I2C Slave module.
  ui8Data | data to be transmitted from the I2C Slave.

Returns
  None

Definition at line 812 of file i2c.h.

__STATIC_INLINE void I2CSlaveDisable | ( | uint32_t | ui32Base | ) |

Disables the I2C slave block.

This will disable operation of the I2C slave block.

Parameters

  ui32Base | is the base address of the I2C Slave module.

Returns
  None

Definition at line 725 of file i2c.h.

__STATIC_INLINE void I2CSlaveEnable | ( | uint32_t | ui32Base | ) |

Enables the I2C Slave block.

This will enable operation of the I2C Slave block.

Parameters

  ui32Base | is the base address of the I2C Slave module.

Returns
  None

Definition at line 631 of file i2c.h.

Referenced by I2CSlaveInit().

__STATIC_INLINE void I2CSlaveInit | ( | uint32_t | ui32Base,
|  | uint8_t | ui8SlaveAddr
| ) |  |

Initializes the I2C Slave block.

This function initializes operation of the I2C Slave block. Upon successful initialization of the I2C blocks, this function will have set the slave address and have enabled the I2C Slave block.

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

Parameters

  ui32Base | is the base address of the I2C Slave module.
  ui8SlaveAddr | is the 7-bit slave address.

Returns
  None

Definition at line 667 of file i2c.h.

__STATIC_INLINE void I2CSlaveIntClear | ( | uint32_t | ui32Base,
|  | uint32_t | ui32IntFlags
| ) |  |

Clears I2C Slave interrupt sources.

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

Note
  Because there is a write buffer in the Cortex-M3 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).

Parameters

  ui32Base | is the base address of the I2C module.
  ui32IntFlags | is a bit mask of the interrupt sources to be cleared. The parameter is the bitwise OR of any of the following: I2C_SLAVE_INT_STOP I2C_SLAVE_INT_START I2C_SLAVE_INT_DATA

Returns
  None

Definition at line 929 of file i2c.h.

__STATIC_INLINE void I2CSlaveIntDisable | ( | uint32_t | ui32Base,
|  | uint32_t | ui32IntFlags
| ) |  |

Disables individual I2C Slave interrupt sources.

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.

Parameters

  ui32Base | is the base address of the I2C Slave module.
  ui32IntFlags | is the bit mask of the interrupt sources to be disabled. The parameter is the bitwise OR of any of the following: I2C_SLAVE_INT_STOP I2C_SLAVE_INT_START I2C_SLAVE_INT_DATA

Returns
  None

Definition at line 882 of file i2c.h.

__STATIC_INLINE void I2CSlaveIntEnable | ( | uint32_t | ui32Base,
|  | uint32_t | ui32IntFlags
| ) |  |

Enables individual I2C Slave interrupt sources.

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.

Parameters

  ui32Base | is the base address of the I2C module.
  ui32IntFlags | is the bit mask of the slave interrupt sources to be enabled. The parameter is the bitwise OR of any of the following: I2C_SLAVE_INT_STOP I2C_SLAVE_INT_START I2C_SLAVE_INT_DATA

Returns
  None

Definition at line 844 of file i2c.h.

__STATIC_INLINE uint32_t I2CSlaveIntStatus | ( | uint32_t | ui32Base,
|  | bool | bMasked
| ) |  |

Gets the current I2C Slave interrupt status.

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

Parameters

  ui32Base | is the base address of the I2C Slave module.
  bMasked | selects either raw or masked interrupt status. `false` : Raw interrupt status is requested. `true` : Masked interrupt status is requested.

Returns
  Returns the current interrupt status as an OR'ed combination of:
  - I2C_SLAVE_INT_STOP
  - I2C_SLAVE_INT_START
  - I2C_SLAVE_INT_DATA

Definition at line 963 of file i2c.h.

__STATIC_INLINE uint32_t I2CSlaveStatus | ( | uint32_t | ui32Base | ) |

Gets the I2C Slave module status.

This function will return the action requested from a master, if any.

Parameters

  ui32Base | is the base address of the I2C Slave module.

Returns
  Returns the status of the I2C Slave module:
  - I2C_SLAVE_ACT_NONE : No action has been requested of the I2C Slave module.
  - I2C_SLAVE_ACT_RREQ : An I2C master has sent data to the I2C Slave module.
  - I2C_SLAVE_ACT_TREQ : An I2C master has requested that the I2C Slave module send data.
  - I2C_SLAVE_ACT_RREQ_FBR : An I2C master has sent data to the I2C slave and the first byte following the slave's own address has been received.

Definition at line 760 of file i2c.h.

## Macro Definition Documentation

#define I2C_MASTER_CMD_BURST_RECEIVE_CONT 0x00000009

Definition at line 112 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_RECEIVE_ERROR_STOP 0x00000004

Definition at line 116 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_RECEIVE_FINISH 0x00000005

Definition at line 114 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_RECEIVE_START 0x0000000b

Definition at line 110 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_SEND_CONT 0x00000001

Definition at line 104 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_SEND_ERROR_STOP 0x00000004

Definition at line 108 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_SEND_FINISH 0x00000005

Definition at line 106 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_BURST_SEND_START 0x00000003

Definition at line 102 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_CMD_SINGLE_RECEIVE 0x00000007

Definition at line 100 of file i2c.h.

#define I2C_MASTER_CMD_SINGLE_SEND 0x00000007

Definition at line 98 of file i2c.h.

Referenced by I2CMasterControl().

#define I2C_MASTER_ERR_ADDR_ACK 0x00000004

Definition at line 125 of file i2c.h.

#define I2C_MASTER_ERR_ARB_LOST 0x00000010

Definition at line 127 of file i2c.h.

#define I2C_MASTER_ERR_DATA_ACK 0x00000008

Definition at line 126 of file i2c.h.

#define I2C_MASTER_ERR_NONE 0

Definition at line 124 of file i2c.h.

Referenced by I2CMasterErr().

#define I2C_SLAVE_ACT_NONE 0

Definition at line 134 of file i2c.h.

#define I2C_SLAVE_ACT_RREQ 0x00000001

Definition at line 135 of file i2c.h.

#define I2C_SLAVE_ACT_RREQ_FBR 0x00000005

Definition at line 137 of file i2c.h.

#define I2C_SLAVE_ACT_TREQ 0x00000002

Definition at line 136 of file i2c.h.

#define I2C_SLAVE_INT_DATA 0x00000001

Definition at line 146 of file i2c.h.

Referenced by I2CSlaveIntDisable(), and I2CSlaveIntEnable().

#define I2C_SLAVE_INT_START 0x00000002

Definition at line 145 of file i2c.h.

Referenced by I2CSlaveIntDisable(), and I2CSlaveIntEnable().

#define I2C_SLAVE_INT_STOP 0x00000004

Definition at line 144 of file i2c.h.

Referenced by I2CSlaveIntDisable(), and I2CSlaveIntEnable().