Added support for banked registers
Dependents: Component_Test_Interface FalconWing MX_Spoile_Test Simple_Power_Distribution ... more
Revision 3:72da9cd002bd, committed 2011-08-21
- Comitter:
- wim
- Date:
- Sun Aug 21 13:59:48 2011 +0000
- Parent:
- 2:2d4ee919e8a7
- Child:
- 4:868db61f5f4e
- Commit message:
- Fixed problem in _read() method
Changed in this revision
| MCP23017.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MCP23017.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MCP23017.cpp Mon Dec 20 16:04:04 2010 +0000
+++ b/MCP23017.cpp Sun Aug 21 13:59:48 2011 +0000
@@ -5,6 +5,7 @@
*
* version 0.2 Initial Release
* version 0.3 Cleaned up
+* version 0.4 Fixed problem with _read method
*/
#include "mbed.h"
@@ -13,7 +14,7 @@
/** Create an MCP23017 object connected to the specified I2C object and using the specified deviceAddress
*
* @param I2C &i2c the I2C port to connect to
-* @param char deviceAddress the address of the MSC23017
+* @param char deviceAddress the address of the MCP23017
*/
MCP23017::MCP23017(I2C &i2c, char deviceAddress) : _i2c(i2c) {
_writeOpcode = deviceAddress & 0xFE; // low order bit = 0 for write
@@ -23,24 +24,23 @@
/** Read from specified MCP23017 register
*
-* @param char address the internal registeraddress of the MSC23017
+* @param char address the internal registeraddress of the MCP23017
* @returns data from register
*/
char MCP23017::_read(char address) {
char data[2];
- char result;
data[0] = address;
- _i2c.write(_writeOpcode, data, 1); // Select Register for reading
- result = _i2c.read(_readOpcode); // Read from selected Register
+ _i2c.write(_writeOpcode, data, 1); // Select Register for reading
+ _i2c.read(_readOpcode, data, 1); // Read from selected Register
- return result;
+ return data[0];
}
/** Write to specified MCP23017 register
*
-* @param char address the internal registeraddress of the MSC23017
+* @param char address the internal registeraddress of the MCP23017
*/
void MCP23017::_write(char address, char byte) {
char data[2];
--- a/MCP23017.h Mon Dec 20 16:04:04 2010 +0000
+++ b/MCP23017.h Sun Aug 21 13:59:48 2011 +0000
@@ -5,6 +5,7 @@
*
* version 0.2 Initial Release
* version 0.3 Cleaned up
+* version 0.4 Fixed problem with _read method
*/
#include "mbed.h"
@@ -53,7 +54,7 @@
/** Create an MCP23017 object connected to the specified I2C object and using the specified deviceAddress
*
* @param I2C &i2c the I2C port to connect to
- * @param char deviceAddress the address of the MSC23017
+ * @param char deviceAddress the address of the MCP23017
*/
MCP23017(I2C &i2c, char deviceAddress);
@@ -105,13 +106,13 @@
/** Write to specified MCP23017 register
*
- * @param char address the internal registeraddress of the MSC23017
+ * @param char address the internal registeraddress of the MCP23017
*/
void _write(char address, char byte);
/** Read from specified MCP23017 register
*
- * @param char address the internal registeraddress of the MSC23017
+ * @param char address the internal registeraddress of the MCP23017
* @returns data from register
*/
char _read(char address);
MCP2317 I2C 16 bit I/O expander