EFR32 Blue Gecko 1 Software Documentation  efr32bg1-doc-5.1.2
em_i2c.h File Reference

Detailed Description

Inter-intergrated circuit (I2C) peripheral API.

Version
5.1.2

License

Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no obligation to support this Software. Silicon Labs is providing the Software "AS IS", with no express or implied warranties of any kind, including, but not limited to, any implied warranties of merchantability or fitness for any particular purpose or warranties against infringement of any proprietary rights of a third party.

Silicon Labs will not be liable for any consequential, incidental, or special damages, or any other relief, or for any claim by any third party, arising from your use of this Software.

Definition in file em_i2c.h.

#include "em_device.h"
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  I2C_Init_TypeDef
 
struct  I2C_TransferSeq_TypeDef
 Master mode transfer message structure used to define a complete I2C transfer sequence (from start to stop). More...
 

Macros

#define I2C_FLAG_10BIT_ADDR   0x0010
 
#define I2C_FLAG_READ   0x0002
 Indicate plain read sequence: S+ADDR(R)+DATA0+P. More...
 
#define I2C_FLAG_WRITE   0x0001
 Indicate plain write sequence: S+ADDR(W)+DATA0+P. More...
 
#define I2C_FLAG_WRITE_READ   0x0004
 Indicate combined write/read sequence: S+ADDR(W)+DATA0+Sr+ADDR(R)+DATA1+P. More...
 
#define I2C_FLAG_WRITE_WRITE   0x0008
 Indicate write sequence using two buffers: S+ADDR(W)+DATA0+DATA1+P. More...
 
#define I2C_FREQ_FAST_MAX   392157
 Fast mode max frequency assuming using 6:3 ratio for Nlow:Nhigh. More...
 
#define I2C_FREQ_FASTPLUS_MAX   987167
 Fast mode+ max frequency assuming using 11:6 ratio for Nlow:Nhigh. More...
 
#define I2C_FREQ_STANDARD_MAX   92000
 Standard mode max frequency assuming using 4:4 ratio for Nlow:Nhigh. More...
 
#define I2C_INIT_DEFAULT
 

Enumerations

enum  I2C_ClockHLR_TypeDef {
  i2cClockHLRStandard = _I2C_CTRL_CLHR_STANDARD,
  i2cClockHLRAsymetric = _I2C_CTRL_CLHR_ASYMMETRIC,
  i2cClockHLRFast = _I2C_CTRL_CLHR_FAST
}
 
enum  I2C_TransferReturn_TypeDef {
  i2cTransferInProgress = 1,
  i2cTransferDone = 0,
  i2cTransferNack = -1,
  i2cTransferBusErr = -2,
  i2cTransferArbLost = -3,
  i2cTransferUsageFault = -4,
  i2cTransferSwFault = -5
}
 

Functions

uint32_t I2C_BusFreqGet (I2C_TypeDef *i2c)
 Get current configured I2C bus frequency. More...
 
void I2C_BusFreqSet (I2C_TypeDef *i2c, uint32_t freqRef, uint32_t freqScl, I2C_ClockHLR_TypeDef i2cMode)
 Set I2C bus frequency. More...
 
void I2C_Enable (I2C_TypeDef *i2c, bool enable)
 Enable/disable I2C. More...
 
void I2C_Init (I2C_TypeDef *i2c, const I2C_Init_TypeDef *init)
 Initialize I2C. More...
 
__STATIC_INLINE void I2C_IntClear (I2C_TypeDef *i2c, uint32_t flags)
 Clear one or more pending I2C interrupts. More...
 
__STATIC_INLINE void I2C_IntDisable (I2C_TypeDef *i2c, uint32_t flags)
 Disable one or more I2C interrupts. More...
 
__STATIC_INLINE void I2C_IntEnable (I2C_TypeDef *i2c, uint32_t flags)
 Enable one or more I2C interrupts. More...
 
__STATIC_INLINE uint32_t I2C_IntGet (I2C_TypeDef *i2c)
 Get pending I2C interrupt flags. More...
 
__STATIC_INLINE uint32_t I2C_IntGetEnabled (I2C_TypeDef *i2c)
 Get enabled and pending I2C interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More...
 
__STATIC_INLINE void I2C_IntSet (I2C_TypeDef *i2c, uint32_t flags)
 Set one or more pending I2C interrupts from SW. More...
 
void I2C_Reset (I2C_TypeDef *i2c)
 Reset I2C to same state as after a HW reset. More...
 
__STATIC_INLINE uint8_t I2C_SlaveAddressGet (I2C_TypeDef *i2c)
 Get slave address used for I2C peripheral (when operating in slave mode). More...
 
__STATIC_INLINE uint8_t I2C_SlaveAddressMaskGet (I2C_TypeDef *i2c)
 Get slave address mask used for I2C peripheral (when operating in slave mode). More...
 
__STATIC_INLINE void I2C_SlaveAddressMaskSet (I2C_TypeDef *i2c, uint8_t mask)
 Set slave address mask used for I2C peripheral (when operating in slave mode). More...
 
__STATIC_INLINE void I2C_SlaveAddressSet (I2C_TypeDef *i2c, uint8_t addr)
 Set slave address to use for I2C peripheral (when operating in slave mode). More...
 
I2C_TransferReturn_TypeDef I2C_Transfer (I2C_TypeDef *i2c)
 Continue an initiated I2C transfer (single master mode only). More...
 
I2C_TransferReturn_TypeDef I2C_TransferInit (I2C_TypeDef *i2c, I2C_TransferSeq_TypeDef *seq)
 Prepare and start an I2C transfer (single master mode only). More...