Giter Site home page Giter Site logo

i2c's Introduction

I2C

I2C.cpp - A free library for I2C communication of Arduino Nano or Mega. This library mimics the functions of the official Wire library, but provides some advanced features, see version 1.1 description below.

I haven't tested it on other boards but any one uses ATmega48A/PA/88A/PA/168A/PA/328/P or Atmel ATmega640/V-1280/V-1281/V-2560/V-2561/V chip should work. Please note that this library needs the 8-bit Timer/Counter0. Please note that the delay() may block this library.

Please refer to https://longnight975551865.wordpress.com/2018/02/11/write-your-own-i%c2%b2c-library/ for more information.

Feedback and contribution is welcome!

Version 1.2

  • Fix some bugs in timeout.

Version 1.1

  • added timeout function which ensures the program won't hang up. Please note the timeout() function uses the 8-bit Timer/Counter0.
  • added a new requestFrom() that overloaded the previous one. The new requestFrom() takes a user-defined array and its index and stores data in the specified location of this array.

Version 1.0

  • Basic functions of I2C bus, similar to the official "wire" library.

Created by Yudi Ren, Feb 1, 2018.

[email protected]

Version 1.0

i2c's People

Contributors

earsuit avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

i2c's Issues

How to use this library with esp32s

Hi i want to use this library with esp32, but when i upload example with this library that provide the error like below:
MPU9250:100:5: error: expected constructor, destructor, or type conversion before '(' token

ISR(TIMER1_COMPA_vect){

     ^

MPU9250:100:4: error: expected constructor, destructor, or type conversion before '(' token

 ISR(TIMER1_COMPA_vect){

    ^

C:\Program Files (x86)\Arduino\libraries\I2C-master\examples\MPU9250\MPU9250.ino: In function 'void timerInterruptSetup()':

MPU9250:150:5: error: 'TCCR1A' was not declared in this scope

     TCCR1A = 0x00;

     ^

MPU9250:151:5: error: 'TCCR1B' was not declared in this scope

     TCCR1B = (_BV(WGM12)) | (_BV(CS11)) | (_BV(CS10));  //CTC mode, clk/64

     ^

In file included from sketch\MPU9250.ino.cpp:1:0:

MPU9250:151:19: error: 'WGM12' was not declared in this scope

     TCCR1B = (_BV(WGM12)) | (_BV(CS11)) | (_BV(CS10));  //CTC mode, clk/64

                   ^

C:\Users\Haseo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1\cores\esp32/Arduino.h:105:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

MPU9250:151:34: error: 'CS11' was not declared in this scope

     TCCR1B = (_BV(WGM12)) | (_BV(CS11)) | (_BV(CS10));  //CTC mode, clk/64

                                  ^

C:\Users\Haseo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1\cores\esp32/Arduino.h:105:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

MPU9250:151:48: error: 'CS10' was not declared in this scope

     TCCR1B = (_BV(WGM12)) | (_BV(CS11)) | (_BV(CS10));  //CTC mode, clk/64

                                                ^

C:\Users\Haseo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1\cores\esp32/Arduino.h:105:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

MPU9250:152:5: error: 'OCR1A' was not declared in this scope

     OCR1A = OUTPUT_COMPARE; //set to 200ms

     ^

MPU9250:153:5: error: 'TCNT1' was not declared in this scope

     TCNT1 = 0x00; //initialise the counter

     ^

MPU9250:154:5: error: 'TIMSK1' was not declared in this scope

     TIMSK1 = _BV(OCIE1A);  //Output Compare A Match Interrupt Enable

     ^

In file included from sketch\MPU9250.ino.cpp:1:0:

MPU9250:154:18: error: 'OCIE1A' was not declared in this scope

     TIMSK1 = _BV(OCIE1A);  //Output Compare A Match Interrupt Enable

                  ^

C:\Users\Haseo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.1\cores\esp32/Arduino.h:105:25: note: in definition of macro '_BV'

 #define _BV(b) (1UL << (b))

                         ^

exit status 1
expected constructor, destructor, or type conversion before '(' token

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.