Basic library of routines to interface to a Microchip MCP23017 16-bit I/O expander using an I2C interface.

Dependents:   AdaFruit_RGBLCD SX1276_GPS

Fork of MCP23017 by jim herd

Revision:
5:79b8535dc5ac
Parent:
4:32fd6ee97dff
Child:
6:1144e6353b50
--- a/MCP23017.cpp	Sun Nov 28 21:38:25 2010 +0000
+++ b/MCP23017.cpp	Sun Nov 28 22:13:12 2010 +0000
@@ -32,7 +32,7 @@
     reset();                                  // initialise chip to power-on condition
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * reset
  * Set configuration (IOCON) and direction(IODIR) registers to initial state
  */
@@ -60,7 +60,7 @@
     shadow_IPOL  = 0;
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * pinMode
  */
 void MCP23017::pinMode(int pin, int mode) {
@@ -72,7 +72,7 @@
     writeRegister(IODIR, (unsigned short)shadow_IODIR);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * digitalRead
  */
 int MCP23017::digitalRead(int pin) {
@@ -84,7 +84,7 @@
     }
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * write_bit
  * Write a 1/0 to a single bit of the 16-bit port
  */
@@ -97,7 +97,7 @@
     writeRegister(GPIO, (unsigned short)shadow_GPIO);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * Write a combination of bits to the 16-bit port
  */
 void MCP23017::write_mask(unsigned short data, unsigned short mask) {
@@ -105,7 +105,7 @@
     writeRegister(GPIO, (unsigned short)shadow_GPIO);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * read_bit
  * Read a single bit from the 16-bit port
  */
@@ -114,7 +114,7 @@
     return  ((shadow_GPIO >> bit_number) & 0x0001);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * read_mask
  */
 int  MCP23017::read_mask(unsigned short mask) {
@@ -122,7 +122,7 @@
     return (shadow_GPIO & mask);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * Config
  * set direction and pull-up registers
  */
@@ -135,7 +135,7 @@
     writeRegister(IPOL, (unsigned short)shadow_IPOL);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * digitalWrite
  */
 void MCP23017::digitalWrite(int pin, int val) {
@@ -161,7 +161,7 @@
     }
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * digitalWordRead
  */
 unsigned short MCP23017::digitalWordRead() {
@@ -169,7 +169,7 @@
     return shadow_GPIO;
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * digitalWordWrite
  */
 void MCP23017::digitalWordWrite(unsigned short w) {
@@ -177,14 +177,14 @@
     writeRegister(GPIO, (unsigned short)shadow_GPIO);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * inputPolarityMask
  */
 void MCP23017::inputPolarityMask(unsigned short mask) {
     writeRegister(IPOL, mask);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * inputoutputMask
  */
 void MCP23017::inputOutputMask(unsigned short mask) {
@@ -192,7 +192,7 @@
     writeRegister(IODIR, (unsigned short)shadow_IODIR);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * internalPullupMask
  */
 void MCP23017::internalPullupMask(unsigned short mask) {
@@ -203,7 +203,7 @@
 
 
 //PRIVATE
-/*******************************************************************************
+/* ******************************************************************************
  * writeRegister
  * write a byte
  */
@@ -215,7 +215,7 @@
     _i2c.write(MCP23017_i2cAddress, buffer, 2);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * writeRegister
  * write two bytes
  */
@@ -230,7 +230,7 @@
     _i2c.write(MCP23017_i2cAddress, buffer, 3);
 }
 
-/*******************************************************************************
+/* ******************************************************************************
  * readRegister
  */
 int MCP23017::readRegister(int regAddress) {