/* ANY-LICENSE V1.0 ---------------- You can use these files under any license approved by the Open Source Initiative, preferrably one of the popular licenses, as long as the license you choose is compatible to the dependencies of these files. See http://www.opensource.org/licenses/ for a list of approved licenses. Author: Martin Furter Project: Tins AVR Lib Repository: http://repos.borg.ch/projects/tins_avr_lib/trunk Copyright: 2016 */ #ifndef TAL_I2C_H #define TAL_I2C_H /** \defgroup I2C I2C routines @{ */ #include #ifdef __cplusplus extern "C" { #endif /// Last status. extern uint8_t i2c_last_status; /// Last expected status. extern uint8_t i2c_exp_status; /** * Initialize I2C. * * @param fast If true 400kHz clock is used, else 125kHz. */ void i2c_init( bool fast ); /** * Write the specified bytes to the I2C device with the given address. * * @param addr Address of the I2C device (0..127). * @param count Number of bytes to write. * @param data Pointer to the data. * @return true for success and false for failure. */ uint8_t i2c_write( uint8_t addr, uint8_t count, uint8_t* data ); /** * Write the specified bytes to the I2C device with the given address. * * @param addr Address of the I2C device (0..127). * @param count Number of bytes to write. * @param data Pointer to the data. * @param count2 Number of bytes to write. * @param data2 Pointer to the data. * @return true for success and false for failure. */ uint8_t i2c_write2( uint8_t addr, uint8_t count, uint8_t* data, uint8_t count2, uint8_t* data2, bool nostop ); /** * Read the specified bytes to the I2C device with the given address. * * @param addr Address of the I2C device (0..127). * @param count Number of bytes to read. * @param data Pointer to the data. * @return true for success and false for failure. */ uint8_t i2c_read( uint8_t addr, uint8_t count, uint8_t* data ); #ifdef __cplusplus } #endif /// @} #endif // TAL_I2C_H