mirror of https://github.com/ARMmbed/mbed-os.git
I2C test: let slave time to get notified
depending on timing and HW, there might be some delay before the master request gets notified, so better loop in while than a single call to slave.receive()pull/3488/head
parent
70667349ee
commit
d67b431f17
|
@ -89,11 +89,8 @@ int main()
|
|||
master.start();
|
||||
master.write(ADDR);
|
||||
master.write(sent);
|
||||
if(slave.receive() != I2CSlave::WriteAddressed)
|
||||
{
|
||||
notify_completion(false);
|
||||
return 1;
|
||||
}
|
||||
while(slave.receive() != I2CSlave::WriteAddressed);
|
||||
|
||||
slave.read(&received, 1);
|
||||
if(sent != received)
|
||||
{
|
||||
|
@ -105,11 +102,8 @@ int main()
|
|||
// Second transfer: slave to master
|
||||
master.start();
|
||||
master.write(ADDR | 1);
|
||||
if(slave.receive() != I2CSlave::ReadAddressed)
|
||||
{
|
||||
notify_completion(false);
|
||||
return 1;
|
||||
}
|
||||
while(slave.receive() != I2CSlave::ReadAddressed);
|
||||
|
||||
slave.write(received);
|
||||
received = master.read(0);
|
||||
slave.stop();
|
||||
|
|
Loading…
Reference in New Issue