Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: utils/i2cconfig.cpp
- Revision:
- 18:3f1b52616d00
- Parent:
- 15:5433f9d94cd7
- Child:
- 21:38c6b11aa348
--- a/utils/i2cconfig.cpp Mon Aug 31 15:20:36 2015 +0000
+++ b/utils/i2cconfig.cpp Thu Sep 03 20:10:39 2015 +0000
@@ -45,6 +45,9 @@
#include <stdint.h>
#include "mbed.h"
+#include "cli_uart.h"
+#include "osi.h"
+
#include "i2cconfig.h"
#include "cli_uart.h"
#include "myBoardInit.h"
@@ -53,6 +56,8 @@
I2C i2c(PB_9, PB_8);
+OsiLockObj_t g_i2cLock;
+
//*****************************************************************************
//
@@ -107,12 +112,16 @@
*/
int32_t err = 0;
+// RTOS_MUTEX_ACQUIRE(&g_i2cLock);
+
err = i2c.read(ucDevAddr,(char*)ucBuffer,ulSize);
if(err == 1){
Uart_Write((uint8_t*)"Return error I2C read\n\r");
+// RTOS_MUTEX_RELEASE(&g_i2cLock);
return -1;
}
-// wait_ms(1);
+// wait_ms(1);
+// RTOS_MUTEX_RELEASE(&g_i2cLock);
return 0;
}
//****************************************************************************
@@ -153,13 +162,16 @@
i2c.stop();
*/
int32_t err = 0;
-
+
+// RTOS_MUTEX_ACQUIRE(&g_i2cLock);
err = i2c.write(ucDevAddr,(char*)ucBuffer,ulSize);
if(err == 1){
Uart_Write((uint8_t*)"Return error I2C write\n\r");
+// RTOS_MUTEX_RELEASE(&g_i2cLock);
return -1;
}
-// wait_ms(1);
+// wait_ms(1);
+// RTOS_MUTEX_RELEASE(&g_i2cLock);
return 0;
}