Re: Esp8266 Multiple i2c buses with wire or other soft i2c
Posted: Sun Jan 29, 2017 1:53 pm
I've look deeper at the core files, and now I understand about this behaviour :
The Wire class is using lower level twi function from core_esp8266_si2c.c, which has the pins variables as global static :
So, it only remember the last value given to the last twi_init() call.
To fix that and having the possibilties to have multiple Wire object, it requires first to remove the static or create a new function twi_setpins(), and then in every Wire methods add code to set those pins number using the values stored in the Write object.
Probably a PR should be submitted for having this fixed forever...
The Wire class is using lower level twi function from core_esp8266_si2c.c, which has the pins variables as global static :
Code: Select all
static unsigned char twi_sda, twi_scl;
So, it only remember the last value given to the last twi_init() call.
To fix that and having the possibilties to have multiple Wire object, it requires first to remove the static or create a new function twi_setpins(), and then in every Wire methods add code to set those pins number using the values stored in the Write object.
Probably a PR should be submitted for having this fixed forever...