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.

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Wed May 07 09:00:07 2014 +0100
Parent:
177:d57c40a064c8
Child:
179:fdae7a0cf091
Commit message:
Synchronized with git revision 42a3edb815167b2aed138226781ff2ebcac662e4

Full URL: https://github.com/mbedmicro/mbed/commit/42a3edb815167b2aed138226781ff2ebcac662e4/

Changed in this revision

targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c	Thu May 01 13:00:08 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c	Wed May 07 09:00:07 2014 +0100
@@ -48,8 +48,6 @@
       2304, 2560, 3072, 3840
 };
 
-static uint8_t first_read;
-
 
 void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
     // determine the I2C to use
@@ -70,8 +68,6 @@
 
     pinmap_pinout(sda, PinMap_I2C_SDA);
     pinmap_pinout(scl, PinMap_I2C_SCL);
-
-    first_read = 1;
 }
 
 int i2c_start(i2c_t *obj) {
@@ -83,7 +79,6 @@
         obj->i2c->C1 |= I2C_C1_MST_MASK;
         obj->i2c->C1 |= I2C_C1_TX_MASK;
     }
-    first_read = 1;
     return 0;
 }
 
@@ -98,7 +93,6 @@
     // code provided with the freedom board
     for (n = 0; n < 100; n++)
         __NOP();
-    first_read = 1;
     return 0;
 }
 
@@ -279,30 +273,19 @@
 
 int i2c_byte_read(i2c_t *obj, int last) {
     char data;
-
+    
     // set rx mode
     obj->i2c->C1 &= ~I2C_C1_TX_MASK;
-
-    if(first_read) {
-        // first dummy read
-        i2c_do_read(obj, &data, 0);
-        first_read = 0;
-    }
-
-    if (last) {
-        // set tx mode
-        obj->i2c->C1 |= I2C_C1_TX_MASK;
-        return obj->i2c->D;
-    }
-
+    
+    // Setup read
     i2c_do_read(obj, &data, last);
 
-    return data;
+    // set tx mode
+    obj->i2c->C1 |= I2C_C1_TX_MASK;
+    return obj->i2c->D;
 }
 
 int i2c_byte_write(i2c_t *obj, int data) {
-    first_read = 1;
-
     // set tx mode
     obj->i2c->C1 |= I2C_C1_TX_MASK;
 
--- a/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c	Thu May 01 13:00:08 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_KLXX/i2c_api.c	Wed May 07 09:00:07 2014 +0100
@@ -37,8 +37,6 @@
       2304, 2560, 3072, 3840
 };
 
-static uint8_t first_read;
-
 
 void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
     // determine the I2C to use
@@ -63,8 +61,6 @@
 
     pinmap_pinout(sda, PinMap_I2C_SDA);
     pinmap_pinout(scl, PinMap_I2C_SCL);
-    
-    first_read = 1;
 }
 
 int i2c_start(i2c_t *obj) {
@@ -84,7 +80,6 @@
         obj->i2c->C1 |= I2C_C1_MST_MASK;
         obj->i2c->C1 |= I2C_C1_TX_MASK;
     }
-    first_read = 1;
     return 0;
 }
 
@@ -98,7 +93,6 @@
     // This wait is also included on the samples
     // code provided with the freedom board
     for (n = 0; n < 100; n++) __NOP();
-    first_read = 1;
     return 0;
 }
 
@@ -284,26 +278,15 @@
     // set rx mode
     obj->i2c->C1 &= ~I2C_C1_TX_MASK;
     
-    if(first_read) {
-        // first dummy read
-        i2c_do_read(obj, &data, 0);
-        first_read = 0;
-    }
-    
-    if (last) {
-        // set tx mode
-        obj->i2c->C1 |= I2C_C1_TX_MASK;
-        return obj->i2c->D;
-    }
-        
+    // Setup read
     i2c_do_read(obj, &data, last);
-    
-    return data;
+
+    // set tx mode
+    obj->i2c->C1 |= I2C_C1_TX_MASK;
+    return obj->i2c->D;
 }
 
 int i2c_byte_write(i2c_t *obj, int data) {
-    first_read = 1;
-    
     // set tx mode
     obj->i2c->C1 |= I2C_C1_TX_MASK;
     
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c	Thu May 01 13:00:08 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/i2c_api.c	Wed May 07 09:00:07 2014 +0100
@@ -44,8 +44,6 @@
     {NC   , NC   , 0}
 };
 
-static uint8_t first_read;
-
 void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
     uint32_t i2c_sda = pinmap_peripheral(sda, PinMap_I2C_SDA);
     uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL);
@@ -60,12 +58,10 @@
 
     pinmap_pinout(sda, PinMap_I2C_SDA);
     pinmap_pinout(scl, PinMap_I2C_SCL);
-    first_read = 1;
 }
 
 int i2c_start(i2c_t *obj) {
     i2c_hal_send_start(obj->instance);
-    first_read = 1;
     return 0;
 }
 
@@ -78,7 +74,6 @@
     // This wait is also included on the samples
     // code provided with the freedom board
     for (n = 0; n < 100; n++) __NOP();
-    first_read = 1;
     return 0;
 }
 
@@ -229,26 +224,15 @@
     // set rx mode
     i2c_hal_set_direction(obj->instance, kI2CReceive);
 
-    if(first_read) {
-        // first dummy read
-        i2c_do_read(obj, &data, 0);
-        first_read = 0;
-    }
-
-    if (last) {
-        // set tx mode
-        i2c_hal_set_direction(obj->instance, kI2CTransmit);
-        return i2c_hal_read(obj->instance);
-    }
-
+    // Setup read
     i2c_do_read(obj, &data, last);
 
-    return data;
+    // set tx mode
+    i2c_hal_set_direction(obj->instance, kI2CTransmit);
+    return i2c_hal_read(obj->instance);
 }
 
 int i2c_byte_write(i2c_t *obj, int data) {
-    first_read = 1;
-
     // set tx mode
     i2c_hal_set_direction(obj->instance, kI2CTransmit);