mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Revision:
211:fb8edfff6ae1
Parent:
210:45934c3d812a
Child:
227:7bd0639b8911
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c	Fri May 23 14:00:06 2014 +0100
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_L053R8/i2c_api.c	Sun May 25 08:00:07 2014 +0100
@@ -165,8 +165,8 @@
 
     /* update CR2 register */
     i2c->CR2 = (i2c->CR2 & (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP)))
-             | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16 ) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_READ);
-            
+               | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_READ);
+
     // Read all bytes
     for (count = 0; count < length; count++) {
         value = i2c_byte_read(obj, 0);
@@ -181,7 +181,8 @@
             return 0;
         }
     }
-    __HAL_I2C_CLEAR_FLAG(&I2cHandle,I2C_FLAG_TC);
+
+    __HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_TC);
 
     // If not repeated start, send stop.
     if (stop) {
@@ -211,10 +212,8 @@
 
     /* update CR2 register */
     i2c->CR2 = (i2c->CR2 & (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP)))
-             | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16 ) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_WRITE);
-   
+               | (uint32_t)(((uint32_t)address & I2C_CR2_SADD) | (((uint32_t)length << 16) & I2C_CR2_NBYTES) | (uint32_t)I2C_SOFTEND_MODE | (uint32_t)I2C_GENERATE_START_WRITE);
 
-    
     for (count = 0; count < length; count++) {
         i2c_byte_write(obj, data[count]);
     }
@@ -225,9 +224,10 @@
         timeout--;
         if (timeout == 0) {
             return 0;
-    }
+        }
     }
-    __HAL_I2C_CLEAR_FLAG(&I2cHandle,I2C_FLAG_TC);
+
+    __HAL_I2C_CLEAR_FLAG(&I2cHandle, I2C_FLAG_TC);
 
     // If not repeated start, send stop.
     if (stop) {
@@ -275,7 +275,7 @@
     }
 
     i2c->TXDR = (uint8_t)data;
-    
+
     return 1;
 }
 
@@ -355,7 +355,7 @@
 
 int i2c_slave_read(i2c_t *obj, char *data, int length) {
     char size = 0;
-  
+
     if (length == 0) return 0;
 
     while (size < length) data[size++] = (char)i2c_byte_read(obj, 0);