1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Write counter-value to memory in Task2

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@577 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
FredericG 2010-05-03 18:31:34 +00:00 committed by FredericG
parent 58514baa49
commit 0c65a90a9d

View File

@ -168,6 +168,7 @@ static void Task2(void *pvParameters)
portTickType xLastExecutionTime;
xLastExecutionTime = xTaskGetTickCount();
uint32_t count = 0;
for(;;)
{
@ -175,7 +176,9 @@ static void Task2(void *pvParameters)
if (PIOS_I2C_LockDevice(100))
{
if (PIOS_I2C_Transfer(I2C_Write, DEVICE_2_ADDRESS<<1, (uint8_t*)"\x10\xF0\xF1\xF2", 4) != 0)
buf[0] = 0x10; // The address
memcpy(&buf[1], &count, 4); // The data to write
if (PIOS_I2C_Transfer(I2C_Write, DEVICE_2_ADDRESS<<1, buf, 5) != 0)
OnError();
PIOS_I2C_UnlockDevice();
}
@ -191,11 +194,12 @@ static void Task2(void *pvParameters)
if (PIOS_I2C_Transfer(I2C_Write_WithoutStop, DEVICE_2_ADDRESS<<1, (uint8_t*)"\x10", 1) != 0)
OnError();
if (PIOS_I2C_Transfer(I2C_Read, DEVICE_2_ADDRESS<<1, buf, 3) != 0)
if (PIOS_I2C_Transfer(I2C_Read, DEVICE_2_ADDRESS<<1, buf, 4) != 0)
OnError();
if (memcmp(buf, "\xF0\xF1\xF2",3) != 0)
if (memcmp(buf, &count, 4) != 0)
OnError();
PIOS_I2C_UnlockDevice();
}
else
@ -204,6 +208,8 @@ static void Task2(void *pvParameters)
}
vTaskDelayUntil(&xLastExecutionTime, 10 / portTICK_RATE_MS);
count++;
}
}