-
Notifications
You must be signed in to change notification settings - Fork 13.3k
I2C slave support; resolving conflicts against current master #5162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cores/esp8266/core_esp8266_si2c.c
Outdated
static volatile uint8_t twi_rxBufferIndex; | ||
|
||
static void (*twi_onSlaveTransmit)(void); | ||
static void (*twi_onSlaveReceive)(uint8_t*, int); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the second arg is the size of the first, it should be unsigned, preferably size_t.
cores/esp8266/core_esp8266_si2c.c
Outdated
twi_sda = sda; | ||
twi_scl = scl; | ||
pinMode(twi_sda, INPUT_PULLUP); | ||
pinMode(twi_scl, INPUT_PULLUP); | ||
twi_setClock(preferred_si2c_clock); | ||
//pinMode(2, OUTPUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want these commented lines left here, or should they be removed?
cores/esp8266/core_esp8266_si2c.c
Outdated
|
||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this commented function here or should it be removed?
cores/esp8266/core_esp8266_si2c.c
Outdated
unsigned int i; | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" | ||
unsigned int reg; | ||
for(i=0;i<v;i++) | ||
reg = GPI; | ||
for(i=0;i<v;i++) reg = GPI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No single line for (please put the body on its own line)
cores/esp8266/core_esp8266_si2c.c
Outdated
#pragma GCC diagnostic pop | ||
} | ||
|
||
static bool twi_write_start(void) { | ||
SCL_HIGH(); | ||
SDA_HIGH(); | ||
if (SDA_READ() == 0) | ||
return false; | ||
if (SDA_READ() == 0) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No single line if please
cores/esp8266/core_esp8266_si2c.c
Outdated
return I2C_SCL_HELD_LOW; //SCL held low by another device, no procedure available to recover | ||
int clockCount = 20; | ||
uint8_t twi_status(){ | ||
if (SCL_READ()==0) return I2C_SCL_HELD_LOW; //SCL held low by another device, no procedure available to recover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line if
cores/esp8266/core_esp8266_si2c.c
Outdated
return I2C_SCL_HELD_LOW_AFTER_READ; //I2C bus error. SCL held low beyond slave clock stretch time | ||
while (SDA_READ()==0 && clockCount>0){ //if SDA low, read the bits slaves have to sent to a max | ||
twi_read_bit(); | ||
if (SCL_READ()==0) return I2C_SCL_HELD_LOW_AFTER_READ; //I2C bus error. SCL held low beyond slave clock stretch time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Single line if.
There are several more cases of ifs and fors, I'll skip pointing out the rest in the interest of sanity
cores/esp8266/core_esp8266_si2c.c
Outdated
} | ||
} | ||
|
||
#if 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want this #if 1, or can it be cleaned up?
cores/esp8266/core_esp8266_si2c.c
Outdated
|
||
// wait for stop condition to be exectued on bus | ||
// TWINT is not set after a stop condition! | ||
while (false) { //TWCR & _BV(TWSTO)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This while(false) makes no sense to me. Is it a remnant of something that didn't work as expected (I.e. comments)? Is there a ToDo here?
cores/esp8266/core_esp8266_si2c.c
Outdated
//digitalWrite(13, HIGH); | ||
//switch(TW_STATUS){ | ||
switch(status) { | ||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep this huge piece of commented out code, or can it be removed?
Changes handled. |
…Arduino into i2c_slave_by_bjoham * 'i2c_slave_by_bjoham' of https://github.com/thinx-cloud/Arduino: cleaning up commit as requested by esp8266#5162 (review)
* I2C slave support; resolving conflicts against current master * removed unused argument, updateded to hopefully pass Travis * cleaning up commit as requested by #5162 (review) * cleaning up commit as requested by #5162 (review) * type fix
Replacing outdated/conflicting PR from #5161