Now you can use NC as InterruptIn

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Revision:
36:f6278b3e7c82
Parent:
33:1573db91352c
diff -r 407b0b127eb8 -r f6278b3e7c82 Components/STMPE1600/stmpe1600_class.h
--- a/Components/STMPE1600/stmpe1600_class.h	Wed Nov 18 16:35:04 2015 +0000
+++ b/Components/STMPE1600/stmpe1600_class.h	Tue Nov 24 16:04:41 2015 +0000
@@ -1,10 +1,10 @@
 /**
  ******************************************************************************
- * @file    vl6180x_class.h
+ * @file    stmpe1600_class.h
  * @author  AST / EST
  * @version V0.0.1
  * @date    14-April-2015
- * @brief   Header file for component VL6180X
+ * @brief   Header file for component stmpe1600
  ******************************************************************************
  * @attention
  *
@@ -80,7 +80,7 @@
     GPIO_13,
     GPIO_14,
     GPIO_15,
-		NOT_CON
+	NOT_CON
 } ExpGpioPinName;   
 
 typedef enum {
@@ -89,10 +89,18 @@
     NOT_CONNECTED
 }ExpGpioPinDirection;
 
-
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a single stmpe1600 GPIO expander output pin
+ */
 class STMPE1600DigiOut {
 	
  public: 
+    /** Constructor
+     * @param[in] &i2c device I2C to be used for communication
+     * @param[in] outpinname the desired out pin name to be created
+     * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
+     * @param[in] lvl the default ot pin level  
+     */ 
     STMPE1600DigiOut (DevI2C &i2c, ExpGpioPinName outpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS, bool lvl=STMPE1600_DEF_DIGIOUT_LVL): dev_i2c(i2c), expdevaddr(DevAddr), exppinname(outpinname) 
     {
        uint8_t data[2];				
@@ -106,6 +114,11 @@
        write(lvl);
     }   
 
+	/**
+	 * @brief       Write on the out pin
+	 * @param[in]   lvl level to write
+	 * @return      0 on Success
+	 */			
     void write (int lvl) 
     {
        uint8_t data[2];			
@@ -116,7 +129,10 @@
        if (lvl) *(uint16_t*)data = *(uint16_t*)data | (uint16_t)(1<<(uint16_t)exppinname);
        dev_i2c.i2c_write(data, expdevaddr, GPSR_0_7, 2);
     }
-		
+
+	/**
+	 * @brief       Overload assignement operator
+	 */					
     STMPE1600DigiOut& operator=(int lvl)
     {
        write (lvl);
@@ -129,9 +145,17 @@
     ExpGpioPinName exppinname; 	
 };
 
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a single stmpe1600 GPIO expander input pin
+ */
 class STMPE1600DigiIn 
 {	
  public: 
+     /** Constructor
+     * @param[in] &i2c device I2C to be used for communication
+     * @param[in] inpinname the desired input pin name to be created
+     * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
+     */ 
     STMPE1600DigiIn (DevI2C &i2c, ExpGpioPinName inpinname, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS): dev_i2c(i2c), expdevaddr(DevAddr), exppinname(inpinname) 
     {
        uint8_t data[2];
@@ -142,6 +166,10 @@
        dev_i2c.i2c_write(data, expdevaddr, GPDR_0_7, 2);
     }         
 
+	/**
+	 * @brief       Read the input pin
+	 * @return      The pin logical state 0 or 1
+	 */			
     bool read () 
     {
        uint8_t data[2];
@@ -164,10 +192,16 @@
     ExpGpioPinName exppinname;      
 };
 
-
+/* Classes -------------------------------------------------------------------*/
+/** Class representing a whole stmpe1600 component (16 gpio)
+ */
 class STMPE1600 {
 	
  public: 
+    /** Constructor
+    * @param[in] &i2c device I2C to be used for communication
+    * @param[in] DevAddr the stmpe1600 I2C device addres (deft STMPE1600_DEF_DEVICE_ADDRESS)
+    */ 
     STMPE1600 (DevI2C &i2c, uint8_t DevAddr=STMPE1600_DEF_DEVICE_ADDRESS ) : dev_i2c(i2c)
     { 
        dev_i2c = i2c;								
@@ -180,51 +214,86 @@
 			 write16bitReg (GPSR_0_7, &GPSR0_15);			
     }
 
+	/**
+	 * @brief       Write the SYS_CTRL register 
+	 * @param[in]   Data to be written (bit fields)
+	 */		
     void writeSYS_CTRL (uint8_t data)     // data = SOFT_RESET reset the device
     {
 	     dev_i2c.i2c_write((uint8_t*)SYS_CTRL, expdevaddr, data, 1);
     }
-
-		bool setGPIO (ExpGpioPinName PinName) 
-		{
-			 if (PinName == NOT_CON) return true;			
-			 GPSR0_15 = GPSR0_15 | ((uint16_t)0x0001<<PinName);
-			 write16bitReg (GPSR_0_7 , &GPSR0_15);
-			 return false;
-		}
+    
+	/**
+	 * @brief       Set the out pin
+	 * @param[in]   The pin name
+	 * @return      0 on Success
+	 */			
+	bool setGPIO (ExpGpioPinName PinName) 
+	{
+		 if (PinName == NOT_CON) return true;			
+		 GPSR0_15 = GPSR0_15 | ((uint16_t)0x0001<<PinName);
+		 write16bitReg (GPSR_0_7 , &GPSR0_15);
+		 return false;
+	}
+	
+	/**
+	 * @brief       Clear the out pin
+	 * @param[in]   The pin name
+	 * @return      0 on Success
+	 */			
+	bool clrGPIO (ExpGpioPinName PinName) 
+	{
+		 if (PinName == NOT_CON) return true;			
+		 GPSR0_15 = GPSR0_15 & (~((uint16_t)0x0001<<PinName));
+		 write16bitReg (GPSR_0_7 , &GPSR0_15);
+		 return false;
+	}		
+	
+	/**
+	 * @brief       Read the input pin
+	 * @param[in]   The pin name
+	 * @return      The logical pin level
+	 */					
+	bool rdGPIO (ExpGpioPinName PinName) 
+	{				
+		  uint16_t gpmr0_15;
+		  if (PinName == NOT_CON) return true;
+		  read16bitReg (GPMR_0_7, &gpmr0_15);
+		  gpmr0_15 = gpmr0_15 & ((uint16_t)0x0001<<PinName);
+		  if (gpmr0_15) return true; 			
+		  return false;			
+	}
+	
+	/**
+	 * @brief       Set the pin direction
+	 * @param[in]   The pin name
+	 * @param[in]   The pin direction	 
+	 * @return      0 on success
+	 */					
+	bool setGPIOdir (ExpGpioPinName PinName, ExpGpioPinDirection PinDir) 
+	{
+	       if (PinName == NOT_CON || PinDir == NOT_CONNECTED) return true; 
+		   GPDR0_15 = GPDR0_15 & (~((uint16_t)0x0001<<PinName));  // clear the Pin
+		   GPDR0_15 = GPDR0_15 | ((uint16_t)PinDir<<PinName);
+		   write16bitReg (GPDR_0_7 , &GPDR0_15);
+		   return false;
+	}
 
-		bool clrGPIO (ExpGpioPinName PinName) 
-		{
-			 if (PinName == NOT_CON) return true;			
-			 GPSR0_15 = GPSR0_15 & (~((uint16_t)0x0001<<PinName));
-			 write16bitReg (GPSR_0_7 , &GPSR0_15);
-			 return false;
-		}		
-		
-		bool rdGPIO (ExpGpioPinName PinName) 
-		{				
-			  uint16_t gpmr0_15;
-			  if (PinName == NOT_CON) return true;
-			  read16bitReg (GPMR_0_7, &gpmr0_15);
-			  gpmr0_15 = gpmr0_15 & ((uint16_t)0x0001<<PinName);
-			  if (gpmr0_15) return true; 			
-			  return false;			
-		}
-
-		bool setGPIOdir (ExpGpioPinName PinName, ExpGpioPinDirection PinDir) 
-		{
-				 if (PinName == NOT_CON || PinDir == NOT_CONNECTED) return true; 
-			   GPDR0_15 = GPDR0_15 & (~((uint16_t)0x0001<<PinName));  // clear the Pin
-			   GPDR0_15 = GPDR0_15 | ((uint16_t)PinDir<<PinName);
-			   write16bitReg (GPDR_0_7 , &GPDR0_15);
-			   return false;
-		}
-
+	/**
+	 * @brief       Read a 16 bits register
+	 * @param[in]   The register address
+	 * @param[in]   The pointer to the read data
+	 */					
     void read16bitReg (uint8_t Reg16Addr, uint16_t *Reg16Data)
     {
        dev_i2c.i2c_read((uint8_t*)Reg16Data, expdevaddr, Reg16Addr, 2);	
     }				
-		
+
+	/**
+	 * @brief       Write a 16 bits register
+	 * @param[in]   The register address
+	 * @param[in]   The pointer to the data to be written
+	 */							
     void write16bitReg (uint8_t Reg16Addr, uint16_t *Reg16Data)
     {
        dev_i2c.i2c_write((uint8_t*)Reg16Data, expdevaddr, Reg16Addr, 2);