2 * Originally from mbed Microcontroller Library
3 * Copyright (c) 2006-2013 ARM Limited
4 * Copyright (c) 2014 Intel Corporation
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
35 maa_result_t maa_i2c_init(i2c_t* dev);
37 /** Set the frequency of the I2C interface
39 * @param hz The bus frequency in hertz
41 void maa_i2c_frequency(i2c_t* dev, int hz);
43 /** Checks to see if this I2C Slave has been addressed.
46 * A status indicating if the device has been addressed, and how
47 * - NoData - the slave has not been addressed
48 * - ReadAddressed - the master has requested a read from this slave
49 * - WriteAddressed - the master is writing to this slave
50 * - WriteGeneral - the master is writing to all slave
52 int maa_i2c_receive(i2c_t* dev);
54 /** Read from an I2C master.
56 * @param data pointer to the byte array to read data in to
57 * @param length maximum number of bytes to read
63 int maa_i2c_read(i2c_t* dev, char *data, int length);
65 /** Read a single byte from an I2C master.
70 int maa_i2c_read_byte(i2c_t* dev);
72 /** Write to an I2C master.
74 * @param data pointer to the byte array to be transmitted
75 * @param length the number of bytes to transmite
81 int maa_i2c_write(i2c_t* dev, const char *data, int length);
83 /** Write a single byte to an I2C master.
85 * @data the byte to write
88 * '1' if an ACK was received,
91 int maa_i2c_write_byte(i2c_t* dev, int data);
93 /** Sets the I2C slave address.
95 * @param address The address to set for the slave (ignoring the least
96 * signifcant bit). If set to 0, the slave will only respond to the
97 * general call address.
99 void maa_i2c_address(i2c_t* dev, int address);
101 /** De-inits an i2c_t device
103 void maa_i2c_stop(i2c_t* dev);