Author Topic: "Porting I²C based libraries/devices"  (Read 4084 times)

forsakenrider

  • Newbie
  • *
  • Posts: 26
"Porting I²C based libraries/devices"
« on: April 28, 2013, 09:25:10 am »
Porting I²C based libraries/devices 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) 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?

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: "Porting I²C based libraries/devices"
« Reply #1 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

forsakenrider

  • Newbie
  • *
  • Posts: 26
Re: "Porting I²C based libraries/devices"
« Reply #2 on: April 29, 2013, 11:24:43 am »
Thanks! looks like thats done it

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