From 192134967dab203b662c34343f36ef4f1c4bd6a8 Mon Sep 17 00:00:00 2001 From: FredericG Date: Sat, 1 May 2010 14:54:35 +0000 Subject: [PATCH] Lock I2C before usage as it should git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@565 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Tests/test_i2c_PCF8570.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flight/OpenPilot/Tests/test_i2c_PCF8570.c b/flight/OpenPilot/Tests/test_i2c_PCF8570.c index bf9d06a4e..919c74fbb 100644 --- a/flight/OpenPilot/Tests/test_i2c_PCF8570.c +++ b/flight/OpenPilot/Tests/test_i2c_PCF8570.c @@ -117,6 +117,7 @@ static void TestTask(void *pvParameters) i = 0; } + if (PIOS_I2C_LockDevice(0)) { uint8_t buf[20]; if (PIOS_I2C_Transfer(I2C_Write, DEVICE_ADDRESS<<1, (uint8_t*)"\x10\xA0\xA1\xA2", 4) != 0) @@ -140,6 +141,12 @@ static void TestTask(void *pvParameters) if (memcmp(buf, "\xA0\xA1\xA2",3) != 0) OnError(); + PIOS_I2C_UnlockDevice(); + } + else + { + // Could not lock device + OnError(); } vTaskDelayUntil(&xLastExecutionTime, 10 / portTICK_RATE_MS);