i2c remap and i2c_master_enable()

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
schoch
Posts: 18
Joined: Thu Jan 25, 2018 11:13 pm

i2c remap and i2c_master_enable()

Post by schoch » Mon Dec 03, 2018 10:47 pm

It appears that _i2c_handle_remap is depricated and there is some flag in i2c_master_enable to enable I2C1 on PB8 and PB9. I'm not able to call the function and I don't know how to include it.

Code: Select all

// this is the syntax required?
#include ???/i2c.h ?
i2c_master_enable(I2C1,I2C_REMAP);
This is very hard to search for since there have been changes to Wire, HWire, SoftWire and it depends on the post date for the correctness of the answers. I can't find an example of this on github or google. What includes do I need and what is the flag to do the remap? I also saw a note that maybe I should be using SoftWire? I also saw that I2C2 has problems with Serial3. All very confusing.

My goal is to use PB6/PB7 for T4C1/T4C2.

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: i2c remap and i2c_master_enable()

Post by stevestrong » Mon Dec 03, 2018 11:19 pm

Just use Wire, it is per default set to those pins.

schoch
Posts: 18
Joined: Thu Jan 25, 2018 11:13 pm

Re: i2c remap and i2c_master_enable()

Post by schoch » Mon Dec 03, 2018 11:59 pm

My blue pill is using PB6/PB7 with the default Wire.h. I'd like to use PB8/PB9 for i2c1 and PB6/PB7 for encoder inputs using Timer4 Ch1,Ch2.

I'd be happy to use I2C2 but I have not found a way to do that and I believe there is some issue with Serial3.

Alternatively I could use SoftWire but I'm not sure how to do that with the Adafruit grafix lib.

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: i2c remap and i2c_master_enable()

Post by stevestrong » Tue Dec 04, 2018 8:35 am

Which Adafruit graphics lib? Please provide link.

Normally you can define another instance this way:

Code: Select all

TwoWire my_wire(2); // use I2C 2
and use that in the lib.

schoch
Posts: 18
Joined: Thu Jan 25, 2018 11:13 pm

Re: i2c remap and i2c_master_enable()

Post by schoch » Tue Dec 04, 2018 5:58 pm


Post Reply