text: // I2Cdev library collection - Main I2C device class header file
  // Abstracts bit and byte I2C R/W functions into a convenient class
  // 2013-06-05 by Jeff Rowberg <jeff@rowberg.net>
  //
  // Changelog:
  //      2015-10-30 - simondlevy : support i2c_t3 for Teensy3.1
  //      2013-05-06 - add Francesco Ferrara's Fastwire v0.24 implementation with small modifications
  //      2013-05-05 - fix issue with writing bit values to words (Sasquatch/Farzanegan)
  //      2012-06-09 - fix major issue with reading > 32 bytes at a time with Arduino Wire
  //                 - add compiler warnings when using outdated or IDE or limited I2Cdev implementation
  //      2011-11-01 - fix write*Bits mask calculation (thanks sasquatch @ Arduino forums)
  //      2011-10-03 - added automatic Arduino version detection for ease of use
  //      2011-10-02 - added Gene Knight's NBWire TwoWire class implementation with small modifications
  //      2011-08-31 - added support for Arduino 1.0 Wire library (methods are different from 0.x)
  //      2011-08-03 - added optional timeout parameter to read* methods to easily change from default
  //      2011-08-02 - added support for 16-bit registers
  //                 - fixed incorrect Doxygen comments on some methods
  //                 - added timeout value for read operations (thanks mem @ Arduino forums)
  //      2011-07-30 - changed read/write function structures to return success or byte counts
  //                 - made all methods static for multi-device memory savings
  //      2011-07-28 - initial release
  
  /* ============================================
  I2Cdev device library code is placed under the MIT license
  Copyright (c) 2013 Jeff Rowberg
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.
  ===============================================
  */
  
  #ifndef _I2CDEV_H_
  #define _I2CDEV_H_
  
  // -----------------------------------------------------------------------------
  // I2C interface implementation setting
  // -----------------------------------------------------------------------------
  #ifndef I2CDEV_IMPLEMENTATION
  //#define I2CDEV_IMPLEMENTATION       I2CDEV_ARDUINO_WIRE
  #define I2CDEV_IMPLEMENTATION       I2CDEV_BUILTIN_FASTWIRE
  #endif
  
  // comment this out if you are using a non-optimal IDE/implementation setting
  // but want the compiler to shut up about it
  #define I2CDEV_IMPLEMENTATION_WARNINGS
  
  // -----------------------------------------------------------------------------
  // I2C interface implementation options
  // -----------------------------------------------------------------------------
  #define I2CDEV_ARDUINO_WIRE         1 // Wire object from Arduino
  #define I2CDEV_BUILTIN_NBWIRE       2 // Tweaked Wire object from Gene Knight's NBWire project
                                        // ^^^ NBWire implementation is still buggy w/some interrupts!
  #define I2CDEV_BUILTIN_FASTWIRE     3 // FastWire object from Francesco Ferrara's project
  #define I2CDEV_I2CMASTER_LIBRARY    4 // I2C object from DSSCircuits I2C-Master Library at https://github.com/DSSCircuits/I2C-Master-Library
  
  // -----------------------------------------------------------------------------
  // Arduino-style "Serial.print" debug constant (uncomment to enable)
  // -----------------------------------------------------------------------------
  //#define I2CDEV_SERIAL_DEBUG
  
  #ifdef ARDUINO
      #include "Arduino.h"
      #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
      #include <Wire.h>
      #endif
  #endif
  
  
  
  // 1000ms default read timeout (modify with "I2Cdev::readTimeout = [ms];")
  #define I2CDEV_DEFAULT_READ_TIMEOUT     1000
  
  class I2Cdev {
      public:
          I2Cdev();
          static void begin( uint32_t freq );
  
          static int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout);
          static int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout);
  
          static bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data);
          static bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data);
          static bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data);
          static bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data);
          static bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data);
          static bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data);
          static bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data);
          static bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data);
  
          static uint16_t readTimeout;
  };
  
  #if I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  
  #endif
  
  #endif /* _I2CDEV_H_ */
  