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.
Diff: MCP23017_I2C.h
- Revision:
- 2:3bea48e1505c
- Parent:
- 1:ec9e770173d5
diff -r ec9e770173d5 -r 3bea48e1505c MCP23017_I2C.h
--- a/MCP23017_I2C.h Fri Jan 09 15:35:40 2015 +0000
+++ b/MCP23017_I2C.h Tue Jan 13 10:09:01 2015 +0000
@@ -41,6 +41,7 @@
* @author Yann Garcia (Don't hesitate to contact me: garcia.yann@gmail.com)
*/
class CMCP23017_I2C : public AbstractGpioExpender {
+
/** Reference counter used to guarentee unicity of the instance of I2C class
*/
static unsigned char I2CModuleRefCounter;
@@ -48,24 +49,33 @@
/** Device address input: A0, A1, A2 (Pins <1,3>). See DS21203K/DS21189D - Figure 5-1: Control Byte Format for address format details
*/
unsigned char _slaveAddress;
+
/** Interrupt on GPIOA
*/
InterruptIn *_intA;
+
/** Interrupt on GPIOB
*/
InterruptIn *_intB;
+
/** Device reset pin
*/
DigitalOut *_reset;
+
/** PortA config
*/
unsigned char _gpioAFlags;
+
/** PortB config
*/
unsigned char _gpioBFlags;
+ /** Map of declared buses
+ */
std::map<unsigned char, std::list<unsigned char> > _buses;
+ /** Buses identifier index
+ */
unsigned char _busesIndex;
/** An unique instance of I2C class
@@ -109,22 +119,46 @@
*/
virtual void reset();
+ /** Setup device interrupt mechanism
+ * @param p_mirroring Set to 0x00 to disable INTA/B mirroring, 0x01 otherwise. Default: 0x00
+ * @param p_openDrain Set to 0x00 for active driver output, 0x01 for opn drain output. Default: 0x00
+ * @param p_polarity Set to 0x00 for interrupt active low, 0x01 otherwise. Default: 0x00
+ */
virtual void setupInterrupts(const unsigned char mirroring = 0x00, const unsigned char p_openDrain = 0x00, const unsigned char polarity = 0x00);
+
/** Setup interrupt for a specific IO port
* @param p_pinId The IO port identifier
* @param p_mode The interrupt mode
- * @return 0 on success, negative value otherwise
+ * @return 0 on success, -1 on wrong parameters and -2 otherwise
*/
virtual int setupInterruptPin(const unsigned char p_gpioId, const InterruptModes p_mode = OnRising);
+ /** Setup pull mode for a specific IO port
+ * @param p_gpioId The IO port identifier
+ * @param p_mode The interrupt mode
+ * @return 0 on success, -1 on wrong parameters and -2 otherwise
+ */
+ virtual int setupPullPin(const unsigned char p_gpioId, const PullModes p_mode = PullOff);
+
/** Get interrupt information and clear it
* @param p_gpioId The IO port identifier where the interrupt occured
* @param p_value The logic value on the pin port where the interrupt occured
- * @return 0 on success, negative value otherwise
+ * @return 0 on success, -1 on wrong parameters and -2 otherwise
*/
- virtual int getLastInterruptPin(unsigned char * p_gpioId, unsigned char * p_value);
+ virtual int getLastInterruptPinAndValue(unsigned char * p_gpioId, unsigned char * p_value);
- virtual int read(const unsigned char p_gpioId, unsigned char * p_value);
+ /** Read the specific GPIO port pin
+ * @param p_gpioId The GPIO port pin to be read
+ * @param p_value The GPIO port pin value
+ * @return 0 on success, -1 on wrong parameters and -2 otherwise
+ */
+ virtual int read(const unsigned char p_gpioId, unsigned char * p_value);
+
+ /** Write value to the specific GPIO port pin
+ * @param p_gpioId The GPIO port pin to be written
+ * @param p_value The GPIO port pin value
+ * @return 0 on success, -1 on wrong parameters and -2 otherwise
+ */
virtual int write(const unsigned char p_gpioId, const unsigned char p_value);
virtual unsigned char createBus(const std::list<unsigned char> p_lines, const PinMode p_mode = PullNone);
@@ -133,10 +167,12 @@
virtual int busWrite(const unsigned char p_busId, const unsigned short p_value);
/** Attach a function to call when a interrupt occurs on the GPIOA input ports
+ * @param p_fptr The pointer to the "C" callback function
*/
virtual void setIntrACallback(void (* p_fptr)(void));
- /** Attach a function to call when a rising edge occurs on the input
+ /** Attach a function to call when a interrupt occurs on the GPIOB input ports
+ * @param p_fptr The pointer to the "C" callback function
*/
virtual void setIntrBCallback(void (* p_fptr)(void));