Files
OpenCellular/include/i2c.h
Bill Richardson e5b17f9047 Add 8-bit I2C read/write functions.
These provide 8-bit accesses to registers within an I2C device.

BUG=chrome-os-partner:7839
TEST=none

Testing will come when I start using them.

Change-Id: Ib53d3347253bccee93cb9c5da12db92970155d92
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-02-13 16:16:10 -08:00

40 lines
1.3 KiB
C

/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* I2C interface for Chrome EC */
#ifndef __CROS_EC_I2C_H
#define __CROS_EC_I2C_H
#include "common.h"
/* Flags for slave address field, in addition to the 8-bit address */
#define I2C_FLAG_BIG_ENDIAN 0x100 /* 16 byte values are MSB-first */
/* Initializes the module. */
int i2c_init(void);
/* Reads a 16-bit register from the slave at 8-bit slave address
* <slaveaddr>, at the specified 8-bit <offset> in the slave's address
* space. */
int i2c_read16(int port, int slave_addr, int offset, int* data);
/* Writes a 16-bit register to the slave at 8-bit slave address
* <slaveaddr>, at the specified 8-bit <offset> in the slave's address
* space. */
int i2c_write16(int port, int slave_addr, int offset, int data);
/* Reads an 8-bit register from the slave at 8-bit slave address
* <slaveaddr>, at the specified 8-bit <offset> in the slave's address
* space. */
int i2c_read8(int port, int slave_addr, int offset, int* data);
/* Writes an 8-bit register to the slave at 8-bit slave address
* <slaveaddr>, at the specified 8-bit <offset> in the slave's address
* space. */
int i2c_write8(int port, int slave_addr, int offset, int data);
#endif /* __CROS_EC_I2C_H */