proposal for arduino/Ardiono#3290 I only did the change for the master begins to avoid flipflopping if more than 1 Arduino is used on a I2C.
This commit is contained in:
parent
fb7c2cc02e
commit
11472bf771
|
@ -53,6 +53,18 @@ TwoWire::TwoWire()
|
||||||
|
|
||||||
void TwoWire::begin(void)
|
void TwoWire::begin(void)
|
||||||
{
|
{
|
||||||
|
/*make sure all slaves can finish their messages started before a reset*/
|
||||||
|
pinMode(SCL, OUTPUT);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
digitalWrite(SCL, HIGH);
|
||||||
|
delayMicroseconds(3);
|
||||||
|
digitalWrite(SCL, LOW);
|
||||||
|
delayMicroseconds(3);
|
||||||
|
}
|
||||||
|
pinMode(SCL, INPUT);
|
||||||
|
/*End of: make sure all slaves can finish their messages started before a reset*/
|
||||||
|
|
||||||
rxBufferIndex = 0;
|
rxBufferIndex = 0;
|
||||||
rxBufferLength = 0;
|
rxBufferLength = 0;
|
||||||
|
|
||||||
|
@ -67,7 +79,13 @@ void TwoWire::begin(uint8_t address)
|
||||||
twi_setAddress(address);
|
twi_setAddress(address);
|
||||||
twi_attachSlaveTxEvent(onRequestService);
|
twi_attachSlaveTxEvent(onRequestService);
|
||||||
twi_attachSlaveRxEvent(onReceiveService);
|
twi_attachSlaveRxEvent(onReceiveService);
|
||||||
begin();
|
rxBufferIndex = 0;
|
||||||
|
rxBufferLength = 0;
|
||||||
|
|
||||||
|
txBufferIndex = 0;
|
||||||
|
txBufferLength = 0;
|
||||||
|
|
||||||
|
twi_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoWire::begin(int address)
|
void TwoWire::begin(int address)
|
||||||
|
|
Loading…
Reference in New Issue