This is a driver code for the PCA9632 is an I2C-bus controlled 4-bit LED driver optimized for Red/Green/Blue/Amber (RGBA) color mixing applications. In Individual brightness control mode, each LED output has its own 8-bit resolution (256 steps) fixed frequency Individual PWM controller that operates at 1.5625 kHz with a duty cycle that is adjustable from 0 % to 99.6 % to allow the LED to be set to a specific brightness value. This library including device class and "LedPwmOut class API" for ease of use.

Dependencies:   CompLedDvr

Dependents:   PCA9632_Hello

Please refer to the component page for details

The PCA9632 is an I²C-bus controlled 4-bit LED driver optimized for Red/Green/Blue/Amber (RGBA) color mixing applications.

High-level API is available

A high-level API that can be used as the "PwmOut" of bed-SDK is available.
This API enables to make instances of each LED output pins and control PWM duty cycle by assignment.
For detail information, refer API document of LedPwmOut Class class which is included in PCA962xA class library.

#include "mbed.h"
#include "PCA9632.h"

PCA9632     led_cntlr( p28, p27, 0xC4 );  //  SDA, SCL, Slave_address(option)
LedPwmOut   led( led_cntlr, L0 );

int main()
{
    while( 1 ) {
        for( float p = 0.0f; p < 1.0f; p += 0.1f ) {
            led     = p;
            wait( 0.1 );
        }
    }
}
Revision:
2:3574bf73abf5
Parent:
0:da1fe3fe7093
--- a/PCA9632.h	Wed Mar 04 08:37:34 2015 +0000
+++ b/PCA9632.h	Thu Mar 19 10:34:33 2015 +0000
@@ -27,11 +27,11 @@
  *
  *  @class   PCA9632
  *
- *  This is a driver code for the PCA9632 is an I2C-bus controlled 4-bit LED driver 
- *  optimized for Red/Green/Blue/Amber (RGBA) color mixing applications. In Individual 
- *  brightness control mode, each LED output has its own 8-bit resolution (256 steps) 
- *  fixed frequency Individual PWM controller that operates at 1.5625 kHz with a duty 
- *  cycle that is adjustable from 0 % to 99.6 % to allow the LED to be set to a specific 
+ *  This is a driver code for the PCA9632 is an I2C-bus controlled 4-bit LED driver
+ *  optimized for Red/Green/Blue/Amber (RGBA) color mixing applications. In Individual
+ *  brightness control mode, each LED output has its own 8-bit resolution (256 steps)
+ *  fixed frequency Individual PWM controller that operates at 1.5625 kHz with a duty
+ *  cycle that is adjustable from 0 % to 99.6 % to allow the LED to be set to a specific
  *  brightness value.
  *  This class provides interface for PCA9632 operation and accessing its registers.
  *  Detail information is available on next URL.
@@ -41,10 +41,10 @@
  *  @code
  *  #include "mbed.h"
  *  #include "PCA9632.h"
- *  
+ *
  *  PCA9632     led_cntlr( p28, p27, 0xC4 );    //  SDA, SCL, Slave_address(option)
  *  LedPwmOut   led( led_cntlr, L0 );           //  for LED0 pin
- *  
+ *
  *  int main()
  *  {
  *      //
@@ -57,9 +57,9 @@
  *      //  2nd sample is using PCA9632 class function.
  *      //    the 'pwm()' function takes LED channel number and duty-ratio value
  *      //
- *  
+ *
  *      while ( 1 ) {
- *          
+ *
  *          //
  *          //  1st sample is using LedPwmOut API.
  *          //  PWM control via LedPwmOut
@@ -70,7 +70,7 @@
  *                  wait( 0.1 );
  *              }
  *          }
- *  
+ *
  *          //
  *          //  2nd sample is using PCA9632 class function.
  *          //  PWM control by device class function call
@@ -89,13 +89,32 @@
 {
 public:
 
-    /** Name of the PCA9632 registers */
+#if DOXYGEN_ONLY
+    /** PCA9626 pin names high-level API i.e. LedPwmOut */
+    typedef enum {
+        L0,            /**< LED0 pin                               */
+        L1,            /**< LED2 pin                               */
+        L2,            /**< LED2 pin                               */
+        L3,            /**< LED2 pin                               */
+        L_NC = ~0x0L   /**< for when the pin is left no-connection */
+    } LedPinName;
+#endif // DOXYGEN_ONLY
+
+    /** Name of the PCA9632 registers (for direct register access) */
     enum command_reg {
-        MODE1,   MODE2,
-        PWM0,    PWM1,    PWM2,    PWM3,
-        GRPPWM,  GRPFREQ,
-        LEDOUT,
-        SUBADR1, SUBADR2, SUBADR3, ALLCALLADR,
+        MODE1,      /**< MODE1 register      */
+        MODE2,      /**< MODE2 register      */
+        PWM0,       /**< PWM0 register       */
+        PWM1,       /**< PWM1 register       */
+        PWM2,       /**< PWM2 register       */
+        PWM3,       /**< PWM3 register       */
+        GRPPWM,     /**< GRPPWM register     */
+        GRPFREQ,    /**< GRPFREQ register    */
+        LEDOUT,     /**< LEDOUT register    */
+        SUBADR1,    /**< SUBADR1 register    */
+        SUBADR2,    /**< SUBADR2 register    */
+        SUBADR3,    /**< SUBADR3 register    */
+        ALLCALLADR, /**< ALLCALLADR register */
 
         REGISTER_START          = MODE1,
         PWM_REGISTER_START      = PWM0,
@@ -155,29 +174,29 @@
      *
      * @param reg_addr  Register address
      * @param data      Value for setting into the register
-     */    
+     */
     void    write( char reg_addr, char data );
 
     /** Register write (multiple bytes) : Low level access to device register
      *
      * @param data      Pointer to an array. First 1 byte should be the writing start register address
      * @param length    Length of data
-     */    
+     */
     void    write( char *data, int length );
- 
+
     /** Register read (single byte) : Low level access to device register
      *
      * @param reg_addr  Register address
      * @return          Read value from register
-     */    
+     */
     char    read( char reg_addr );
-    
+
     /** Register write (multiple bytes) : Low level access to device register
      *
      * @param reg_addr  Register address
      * @param data      Pointer to an array. The values are stored in this array.
      * @param length    Length of data
-     */    
+     */
 
     void    read( char reg_addr, char *data, int length );