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
Laurent MEUNIER 2016-12-19 11:31:41 +01:00
parent 70667349ee
commit d67b431f17
1 changed files with 4 additions and 10 deletions

View File

@ -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();