Digistump Forums

The Digispark => Digispark (Original) Support => Topic started by: forsakenrider on April 28, 2013, 09:25:10 am

Title: "Porting I²C based libraries/devices"
Post by: forsakenrider on April 28, 2013, 09:25:10 am
Porting I²C based libraries/devices (http://digistump.com/wiki/digispark/tutorials/i2c) is a page in the Wiki without information. How is it coming along?

I've got a 16 channel i2c PWM driver board from adafruit (here (http://www.adafruit.com/products/815)) and I want to port the library to digispark. I havent gotten very far but I've figured out a few of the issues. Like tinywire uses Send and Receive instead of Read and Write.

Is there a list of all the differences somewhere? will this even work?
Title: Re: "Porting I²C based libraries/devices"
Post by: digistump on April 29, 2013, 10:44:32 am
I guess it never got written because no one has asked about it yet (until now) and most people have had no issue porting i2c libraries - generally it's pretty straightforward -


This has worked for all the libraries I've ported:


include tinywirem.h
in setup call TinyWireM.begin()


comment out Wire.h


replace all Wire.write/send with TinyWireM.send
same for read/receive


That's it - if that doesn't work let me know and I'll take a look at the library as soon as I have a chance
Title: Re: "Porting I²C based libraries/devices"
Post by: forsakenrider on April 29, 2013, 11:24:43 am
Thanks! looks like thats done it

I was missing the
Code: [Select]
TinyWireM.begin()