Code Monkey home page Code Monkey logo

tinywirem's Introduction

TinyWireM Build StatusDocumentation

ATtiny (e.g. Adafruit Trinket, Gemma) I2C library, adapted from BroHogan's code on Arduino Playground: http://playground.arduino.cc/Code/USIi2c

Minor changes for consistency with the Arduino 1.0 Wire library (e.g. uses write() instead of send()). Buffer size slightly increased for Adafruit_LEDBackpack use.

On the Trinket boards, pin #0 is SDA (I2C data), pin #2 is SCK (I2C clock).

tinywirem's People

Contributors

datacute avatar evaherrada avatar frank26080115 avatar ladyada avatar paintyourdragon avatar saintgimp avatar tdicola avatar tyeth avatar wouterbt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinywirem's Issues

New release needed

Could you please bump the version in library.properties, and release a new version, so that the Arduino IDE library manager will enable users to get the latest code with the committed bug fixes?

Platformio compile error - util/delay.h error

  • Board: Adafruit Feather M4
  • Plaftformio with RTClib
  • Issue: the library is giving a compile error
    .pio\libdeps\adafruit_feather_m4\TinyWireM_ID797\USI_TWI_Master.cpp:23:10: fatal error: util/delay.h: No such file or directory #include <util/delay.h> ^~~~~~~~~~~~~~
    I have tried the usual suspects but cant figure it out. compiles fine in arduino ide though.

Conflict with Adafruit_PWMServoDriver on `TinyWireM.send`

  • Arduino board: Digispark

  • Arduino IDE version: 1.8.5

  • Steps to reproduce the problem:

-- Ensure a basic sketch works with the uC. DONE.

-- Install Adafruit PWM Servo Driver Library for Digispark, Branch: TinyWireM, by placing the uncompressed folder called "Adafruit_PWMServoDriver" into Documents\Arduino\libraries, per instructions at above link. DONE.

-- Load File menu > Examples > Adafruit_PWMServoDriver > pwmtest. DONE.

-- Compile, and receive error:

Adafruit_PWMServoDriver.cpp:63:20: error: call of overloaded 'send(uint16_t&)' is ambiguous

TinyWireM.send(on);

                ^

D:\Documents\Arduino\libraries\Adafruit_PWMServoDriver\Adafruit_PWMServoDriver.cpp:63:20: note: candidates are:

In file included from D:\Documents\Arduino\libraries\Adafruit_PWMServoDriver\Adafruit_PWMServoDriver.cpp:19:0:

C:\Users\Baby Burrito\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\TinyWireM/TinyWireM.h:65:10: note: void USI_TWI::send(uint8_t)

 void send(uint8_t b)               { write(b); }

      ^

C:\Users\Baby Burrito\AppData\Local\Arduino15\packages\digistump\hardware\avr\1.6.7\libraries\TinyWireM/TinyWireM.h:67:10: note: void USI_TWI::send(int)

 void send(int n)                   { write((uint8_t)n); }

      ^

write() function failed to detect buffer overflow

I found the write() function always lost the last data.
USI_BufIdx is start from 0, so the expression for compare with USI_BUF_SIZE require minus 1:
if (USI_BufIdx >= USI_BUF_SIZE - 1) return 0; // dont blow out the buffer

Attiny 2313/4313 not compiling

Hello, I have been trying to use this library and I found a small issue. In the USI_TWI_Master.h, I found that the board definitions for the 2313/4313 fail to compile. I have made some changes to that file and now it compiles. I have not tested it as of 5/22/2017 yet but will do so in the future.

Line 92 contains: #if defined(AVR_AT90Tiny2313) | defined(AVR_ATtiny2313)
This is what it was before I changed it

Line 92 should contain: #if defined(AVR_ATtiny2313) | defined(AVR_ATtiny4313)
This is what I changed it to and the code will compile now.

Bit Or / Logical Or

This is Bit Or
#if defined(__AVR_AT90Mega169__) | defined(__AVR_ATmega169__) | \ defined(__AVR_AT90Mega165__) | defined(__AVR_ATmega165__) | \ defined(__AVR_ATmega325__) | defined(__AVR_ATmega3250__) | \ defined(__AVR_ATmega645__) | defined(__AVR_ATmega6450__) | \ defined(__AVR_ATmega329__) | defined(__AVR_ATmega3290__) | \ defined(__AVR_ATmega649__) | defined(__AVR_ATmega6490__)

This is Logical Or
#if defined(__AVR_AT90Mega169__) || defined(__AVR_ATmega169__) || \ defined(__AVR_AT90Mega165__) || defined(__AVR_ATmega165__) || \ defined(__AVR_ATmega325__) || defined(__AVR_ATmega3250__) || \ defined(__AVR_ATmega645__) || defined(__AVR_ATmega6450__) || \ defined(__AVR_ATmega329__) || defined(__AVR_ATmega3290__) || \ defined(__AVR_ATmega649__) || defined(__AVR_ATmega6490__)

Which is right?

Question: Support 0/1/2 series without USI

Hi, this is more a question than an issue, sorry if there was another way to ask.
As the title suggest, is there a chance these newer processors will be supported, the biggest issue I see is lacking USI support.

USI_TWI::endTransmission() not returning status

In TinyWireM.cpp the function endTransmission() is not returning proper status.
This breaks code that checks for return status information using the endTransmission() function.
This:

uint8_t USI_TWI::endTransmission() {
  endTransmission(1);
}

Should be changed to:

uint8_t USI_TWI::endTransmission() {
  return(endTransmission(1));
}

endTransmission() does not return SCL high on NAK

  • Arduino board: None -- raw ATTiny25

  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.3 (Windows Store 1.8.6.0)

-I'm using a Tiny25 to scan for an unknown number of I2C devices so I later can only send data to devices that I know exist. In doing this, I'm sending a known request for version info from the slave devices. The problem is if the device doesn't exist then TinyWireM.endTransmission() does not return the SCL line to high.

You can see the clock not returning to high here:
full data

Close up of where the problem starts:
zoom
Data 0x14 is the reply from a device, address 0x11 is a non-existent possible device.

Snippet of the scanning code:
for (int a = 0x10; a < 0x18; a++) { TinyWireM.beginTransmission(a); TinyWireM.send(0x7F); TinyWireM.endTransmission(); if (TinyWireM.requestFrom(a, 1) > 0) { Addresses[AirChains++] = a; while(TinyWireM.available()) { TinyWireM.receive(); } } delayMicroseconds (50); }

Zillions of errors when used on incorrect architecture

If a user includes TinyWireM.h in a sketch and builds for say an Uno board, they will get tons of errors.
They can easily be confused and not recognize the issue. (I have seen this first hand)
The current library.properties says the library works on any architecture.
The properties files should indicate that it is AVR only.
But even specifying that the library architecture is AVR only does not fully solve the issue.
So to fully remedy the issue, TinyWireM.h should also use conditionals to explicitly check the processor type being used and crash the compile with a meaningful error message when attempting to use it on an unsupported processor.

Even better would be to work with the Attiny core maintainer and get this library into to actual core so that it is only available when that tiny core type is being used.

Custom SDA or SCL pin declaration for ATTINY85

Hello there,

In the TInyWireM library, we got the SDA , SCL pins declared in the USI_TWI_Master.h file.
So can we change the pin declarations of the SDA ,SCL pins in the file and expect the library to work with the new pins declared?

Thanks in Advance

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.