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 <limits.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_FLAG_WRITE   0
 Flag signaling a write operation on the bus. More...
 
#define I2C_FLAG_READ   1
 Flag signaling a read operation on the bus.
 
#define I2C_DEV(x)   (x)
 Default I2C device access macro.
 
#define I2C_UNDEF   (UINT_MAX)
 Default I2C undefined value.
 

Typedefs

typedef unsigned int i2c_t
 Default i2c_t type definition.
 

Enumerations

enum  i2c_speed_t {
  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 = 0, I2C_SPEED_NORMAL, I2C_SPEED_FAST,
  I2C_SPEED_FAST_PLUS, I2C_SPEED_HIGH
}
 Default mapping of I2C bus speed values. More...
 

Functions

int i2c_init_master (i2c_t dev, i2c_speed_t speed)
 Initialize an I2C device to run as bus master. 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_byte (i2c_t dev, uint8_t address, void *data)
 Read one byte from an I2C device with the given address. More...
 
int i2c_read_bytes (i2c_t dev, uint8_t address, void *data, int length)
 Read multiple bytes from an I2C device with the given address. More...
 
int i2c_read_reg (i2c_t dev, uint8_t address, uint8_t reg, void *data)
 Read one byte from a register at the I2C slave with the given address. More...
 
int i2c_read_regs (i2c_t dev, uint8_t address, uint8_t reg, void *data, int length)
 Read multiple bytes from a register at the I2C slave with the given address. More...
 
int i2c_write_byte (i2c_t dev, uint8_t address, uint8_t data)
 Write one byte to an I2C device with the given address. More...
 
int i2c_write_bytes (i2c_t dev, uint8_t address, const void *data, int length)
 Write multiple bytes to an I2C device with the given address. More...
 
int i2c_write_reg (i2c_t dev, uint8_t address, uint8_t reg, uint8_t data)
 Write one byte to a register at the I2C slave with the given address. More...
 
int i2c_write_regs (i2c_t dev, uint8_t address, uint8_t reg, const void *data, int length)
 Write multiple bytes to a register at the I2C slave with the given address. More...
 
void i2c_poweron (i2c_t dev)
 Power on the given I2C peripheral. More...
 
void i2c_poweroff (i2c_t dev)
 Power off the given I2C peripheral. More...