i2c.h File Reference

Low-level I2C peripheral driver interface definition. More...

Detailed Description

Low-level I2C peripheral driver interface definition.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de
Thomas Eichinger thoma.nosp@m.s.ei.nosp@m.ching.nosp@m.er@f.nosp@m.u-ber.nosp@m.lin..nosp@m.de

Definition in file i2c.h.

#include <stdint.h>
#include <stddef.h>
#include <limits.h>
#include "periph_conf.h"
#include "periph_cpu.h"
#include "periph/dev_enums.h"
+ Include dependency graph for i2c.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define I2C_READ   (0x0001)
 Read bit needs to be set when reading.
 
#define I2C_10BIT_MAGIC   (0xF0u)
 Special bit pattern indicating a 10 bit address is used. More...
 

Functions

void i2c_init (i2c_t dev)
 Initialize the given I2C bus. More...
 
int i2c_acquire (i2c_t dev)
 Get mutually exclusive access to the given I2C bus. More...
 
int i2c_release (i2c_t dev)
 Release the given I2C device to be used by others. More...
 
int i2c_read_reg (i2c_t dev, uint16_t addr, uint16_t reg, void *data, uint8_t flags)
 Convenience function for reading one byte from a given register address. More...
 
int i2c_read_regs (i2c_t dev, uint16_t addr, uint16_t reg, void *data, size_t len, uint8_t flags)
 Convenience function for reading several bytes from a given register address. More...
 
int i2c_read_byte (i2c_t dev, uint16_t addr, void *data, uint8_t flags)
 Convenience function for reading one byte from a device. More...
 
int i2c_read_bytes (i2c_t dev, uint16_t addr, void *data, size_t len, uint8_t flags)
 Convenience function for reading bytes from a device. More...
 
int i2c_write_byte (i2c_t dev, uint16_t addr, uint8_t data, uint8_t flags)
 Convenience function for writing a single byte onto the bus. More...
 
int i2c_write_bytes (i2c_t dev, uint16_t addr, const void *data, size_t len, uint8_t flags)
 Convenience function for writing several bytes onto the bus. More...
 
int i2c_write_reg (i2c_t dev, uint16_t addr, uint16_t reg, uint8_t data, uint8_t flags)
 Convenience function for writing one byte to a given register address. More...
 
int i2c_write_regs (i2c_t dev, uint16_t addr, uint16_t reg, const void *data, size_t len, uint8_t flags)
 Convenience function for writing data to a given register address. More...
 
#define I2C_DEV(x)   (x)
 Default I2C device access macro. More...
 
#define I2C_UNDEF   (UINT_MAX)
 Default I2C undefined value.
 
typedef unsigned int i2c_t
 Default i2c_t type definition.
 
enum  i2c_speed_t {
  I2C_SPEED_LOW = 0x01, I2C_SPEED_NORMAL = 100000U, I2C_SPEED_FAST = 400000U, I2C_SPEED_FAST_PLUS = 0x02,
  I2C_SPEED_HIGH = 0x03, I2C_SPEED_LOW = 0x01, I2C_SPEED_NORMAL = TWI_FREQUENCY_FREQUENCY_K100, I2C_SPEED_FAST = TWI_FREQUENCY_FREQUENCY_K400,
  I2C_SPEED_FAST_PLUS = 0x02, I2C_SPEED_HIGH = 0x03, I2C_SPEED_LOW = 0xff, I2C_SPEED_NORMAL = TWIM_FREQUENCY_FREQUENCY_K100,
  I2C_SPEED_FAST = TWIM_FREQUENCY_FREQUENCY_K400, I2C_SPEED_FAST_PLUS = 0xfe, I2C_SPEED_HIGH = 0xfd, I2C_SPEED_LOW = 10000U,
  I2C_SPEED_NORMAL = 100000U, I2C_SPEED_FAST = 400000U, I2C_SPEED_FAST_PLUS = 1000000U, I2C_SPEED_HIGH = 3400000U,
  I2C_SPEED_NORMAL, I2C_SPEED_FAST, I2C_SPEED_LOW = 0, I2C_SPEED_NORMAL,
  I2C_SPEED_FAST, I2C_SPEED_FAST_PLUS, I2C_SPEED_HIGH
}
 Default mapping of I2C bus speed values. More...
 
enum  i2c_flags_t { I2C_ADDR10 = 0x01, I2C_REG16 = 0x02, I2C_NOSTOP = 0x04, I2C_NOSTART = 0x08 }
 I2C transfer flags. More...