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.
Revision 2:0d772298e874, committed 2016-05-26
- Comitter:
- coisme
- Date:
- Thu May 26 21:04:28 2016 +0000
- Parent:
- 1:e02d9e33b9f3
- Commit message:
- Bug fixed. I2C write operation and bit calculation.
Changed in this revision
| tca9554a.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e02d9e33b9f3 -r 0d772298e874 tca9554a.cpp
--- a/tca9554a.cpp Thu May 05 17:55:38 2016 +0000
+++ b/tca9554a.cpp Thu May 26 21:04:28 2016 +0000
@@ -18,7 +18,7 @@
// Reads the register value.
char val = 0;
- if (connection->read((slaveAddress << 1), &val, LEN_ONE_BYTE) != 0) {
+ if (connection->read(((slaveAddress << 1) | 0x01), &val, LEN_ONE_BYTE) != 0) {
return ERROR_I2C_READ;
}
@@ -34,10 +34,10 @@
buf[1] = (char)val;
// Writes to the devices.
- if (connection->write(slaveAddress, buf, LEN_TWO_BYTE) != 0) {
+ if (connection->write((slaveAddress << 1), buf, LEN_TWO_BYTE) != 0) {
return ERROR_I2C_WRITE;
}
-
+
return SUCCESS;
}
@@ -98,7 +98,7 @@
}
// Modify the specified bit by port.
- buf = ((buf & (~port)) | val);
+ buf = ((buf & (~port) | (port * val)));
// Write back the modified value to the register.
if ((status=write(REG_ADDR_OUTPUT, buf)) != SUCCESS) {