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.
Dependents: Seeed_Barometer_Sensor_Example
Fork of mbed-src by
Diff: targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c
- Revision:
- 178:a873352662d8
- Parent:
- 73:299c67215126
- Child:
- 180:097147d37470
diff -r d57c40a064c8 -r a873352662d8 targets/hal/TARGET_Freescale/TARGET_K20D5M/i2c_api.c
--- 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;
