]>
cloudbase.mooo.com Git - z180-stamp.git/blob - include/i2c.h
2 * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
4 * Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
5 * Copyright (C) 2009 - 2013 Heiko Schocher <hs@denx.de>
6 * Changes for multibus/multiadapter I2C support.
9 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com.
11 * SPDX-License-Identifier: GPL-2.0+
13 * The original I2C interface was
14 * (C) 2000 by Paolo Scaffardi (arsenio@tin.it)
15 * AIRVENT SAM s.p.a - RIMINI(ITALY)
16 * but has been changed substantially.
23 * Configuration items.
26 #define I2C_RXTX_LEN 128 /* maximum tx/rx buffer length */
30 * Initialization, must be called once on start up, may be called
31 * repeatedly to change the speed.
33 void i2c_init(uint32_t speed
);
36 * Probe the given I2C chip address. Returns 0 if a chip responded,
39 int i2c_probe(uint8_t chip
);
42 * Read/Write interface:
43 * chip: I2C chip address, range 0..127
44 * addr: Memory (register) address within the chip
45 * alen: Number of bytes to use for addr (typically 1, 2 for larger
46 * memories, 0 for register type devices with only one
48 * buffer: Where to read/write the data
49 * len: How many bytes to read/write
51 * Returns: 0 on success, not 0 on failure
53 int i2c_read(uint8_t chip
, unsigned int addr
, uint_fast8_t alen
,
54 uint8_t *buffer
, uint_fast8_t len
);
55 int i2c_write(uint8_t chip
, unsigned int addr
, uint_fast8_t alen
,
56 uint8_t *buffer
, uint_fast8_t len
);
59 * Utility routines to read/write registers.
61 uint8_t i2c_reg_read(uint8_t addr
, uint8_t reg
);
63 void i2c_reg_write(uint8_t addr
, uint8_t reg
, uint8_t val
);