SMFSW / WireWrapper

Arduino Wrapper for Wire library (for SAM, ESP8266...)
MIT License
3 stars 1 forks source link

using WireWrapper on MKR1000 with SAMD21 core #3

Open monamomeni opened 6 years ago

monamomeni commented 6 years ago

Hello and thanks for providing this library. I had tried writing a wrapper for Wire with no luck :) I need to use is in the C header of another library (not main Arduino sketch).

I am no expert sorry if I ask a basic question:

I didn't understand how FRAM in examples is initialized. Is there any other definition that should be added for specific hardware? If I want to use it with an analog front end device, with slave address 0x5B, what would be the effect of writing: I2C_SLAVE AFE ;

and then giving reference &AFE in initialization step? Also, I see ci2c in most of the lines. Is it applicable to Samd21 cortex M0+ on MKR1000 boards?

Thanks again!

SMFSW commented 6 years ago

Hello,

sorry for long time in answering.

FRAM components doesn't need real init process, this step mainly initializes the I2C_SLAVE struct with I2C address, speed and register size of the I2C slave.

Some other components needs an initialization phase sending some parameters before it works the desired way.

Can you please provide the reference of the analog I2C chip you're trying to use? It would help giving some hints on how to properly set it up.

You can declare the slave as you mention and giving reference to it when calling init with proper parameters (address 0x5B (beware if the address is already shifted or not), communication speed, and the size of it's internal registers (8 or 16b)).

Yes, you can see ci2c mentioned, but it's refering to another lib in my account (dedicated only to AVR µcontrollers). ci2c is coded to work directly with AVR registers to set up and make the communication work; SAM families uses different registers, WireWrapper as it's name states uses Wire library from arduino, but providing the I2C_SLAVE abstraction layer. This means code will be the same in a sketch, but portable between different arduino platforms when WireWrapper.h is included (which is not the case with ci2c).