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.
Dependents: PCA9626_Hello PCA9624_Hello PCA9622_Hello
Revision 0:7a206e6db594, committed 2015-02-26
- Comitter:
- nxp_ip
- Date:
- Thu Feb 26 09:16:41 2015 +0000
- Child:
- 1:6fcc4f604988
- Commit message:
- Initial version
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9622/PCA9622.cpp Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "PCA9622.h"
+
+PCA9622::PCA9622( PinName i2c_sda, PinName i2c_scl, char i2c_address )
+ : PCA962x( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 16 )
+{
+ initialize();
+}
+
+PCA9622::PCA9622( I2C &i2c_obj, char i2c_address )
+ : PCA962x( i2c_obj, i2c_address ), n_of_ports( 16 )
+{
+ initialize();
+}
+
+PCA9622::~PCA9622()
+{
+}
+
+void PCA9622::initialize( void )
+{
+ char init_array0[] = {
+ PCA962x::AUTO_INCREMENT | REGISTER_START, // Command
+ 0x00, 0x00, // MODE1, MODE2
+ };
+ char init_array1[] = {
+ PCA962x::AUTO_INCREMENT | LEDOUT_REGISTER_START, // Command
+ 0xAA, 0xAA, 0xAA, 0xAA, // LEDOUT[1:0]
+ };
+
+ write( init_array0, sizeof( init_array0 ) );
+ write( init_array1, sizeof( init_array1 ) );
+}
+
+char PCA9622::pwm_register_access( int port )
+{
+ if ( port < n_of_ports )
+ return ( PWM_REGISTER_START + port );
+
+ return ( PWMALL );
+}
+
+int PCA9622::number_of_ports( void )
+{
+ return ( n_of_ports );
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9622/PCA9622.h Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,159 @@
+/** PCA9622 PWM control LED driver
+ *
+ * An operation sample of PCA9622 16-channel Fm+ I2C-bus 100mA/40V LED driver.
+ * mbed accesses the PCA9622 registers through I2C.
+ *
+ * @class PCA9622
+ * @author Akifumi (Tedd) OKANO, NXP Semiconductors
+ * @version 0.5
+ * @date 26-Feb-2015
+ *
+ * Released under the Apache 2 license License
+ *
+ * About PCA9622:
+ * http://www.nxp.com/products/lighting_driver_and_controller_ics/i2c_led_display_control/series/PCA9622.html
+ */
+
+#ifndef MBED_PCA9622
+#define MBED_PCA9622
+
+#include "mbed.h"
+#include "PCA962x.h"
+
+/** PCA9622 class
+ *
+ * This is a driver code for the PCA9622 16-channel Fm+ I2C-bus 100mA/40V PWM control LED driver.
+ * This class provides interface for PCA9622 operation and accessing its registers.
+ * Detail information is available on next URL.
+ * http://www.nxp.com/products/lighting_driver_and_controller_ics/i2c_led_display_control/series/PCA9622.html
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ *
+ * #include "PCA9622.h"
+ * PCA9622 led_cntlr( p28, p27, 0x3E ); // SDA, SCL, Slave_address(option)
+ *
+ * int main()
+ * {
+ * while(1) {
+ * for ( int port = 0; port < led_cntlr.number_of_ports(); port++ ) {
+ * for ( int i = 1; i <= 100; i++ ) {
+ * led_cntlr.pwm( port, (float)i / 100.0 );
+ * wait( 0.01 );
+ * }
+ * }
+ * led_cntlr.pwm( ALLPORTS, 0.0 );
+ * }
+ * }
+ * @endcode
+ */
+
+class PCA9622 : public PCA962x
+{
+public:
+ /** Name of the PCA9622 registers */
+ enum command_reg {
+ MODE1, MODE2,
+ PWM0, PWM1, PWM2, PWM3,
+ PWM4, PWM5, PWM6, PWM7,
+ PWM8, PWM9, PWM10, PWM11,
+ PWM12, PWM13, PWM14, PWM15,
+ GRPPWM, GRPFREQ,
+ LEDOUT0, LEDOUT1, LEDOUT2, LEDOUT3,
+ SUBADR1, SUBADR2, SUBADR3, ALLCALLADR,
+
+ REGISTER_START = MODE1,
+ LEDOUT_REGISTER_START = LEDOUT0,
+ PWM_REGISTER_START = PWM0,
+ };
+
+ /** Create a PCA9629A instance connected to specified I2C pins with specified address
+ *
+ * @param i2c_sda I2C-bus SDA pin
+ * @param i2c_sda I2C-bus SCL pin
+ * @param i2c_address I2C-bus address (default: 0xC0)
+ */
+ PCA9622( PinName i2c_sda, PinName i2c_scl, char i2c_address = PCA962x::DEFAULT_I2C_ADDR );
+
+ /** Create a PCA9629A instance connected to specified I2C pins with specified address
+ *
+ * @param i2c_obj I2C object (instance)
+ * @param i2c_address I2C-bus address (default: 0xC0)
+ */
+ PCA9622( I2C &i2c_obj, char i2c_address = PCA962x::DEFAULT_I2C_ADDR );
+
+ /** Destractor
+ *
+ */
+ virtual ~PCA9622();
+
+ /** Returns the number of output ports
+ *
+ * @returns
+ * The number of output ports
+ */
+ virtual int number_of_ports( void );
+
+#if DOXYGEN_ONLY
+ /** Set the output duty-cycle, specified as a percentage (float)
+ *
+ * @param port Selecting output port
+ * 'ALLPORTS' can be used to set all port duty-cycle same value.
+ * @param v A floating-point value representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ * Values outside this range will have undefined behavior.
+ */
+ void pwm( int port, float v );
+
+ /** Set all output port duty-cycle, specified as a percentage (array of float)
+ *
+ * @param vp Aray to floating-point values representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ *
+ * @note
+ * The aray should have length of 16
+ */
+ void pwm( float *vp );
+
+ /** Register write (single byte) : Low level access to device register
+ *
+ * @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 );
+#endif
+
+private:
+ virtual void initialize( void );
+ virtual char pwm_register_access( int port );
+
+ const int n_of_ports;
+}
+;
+
+#endif // MBED_PCA9622
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9624/PCA9624.cpp Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "PCA9624.h"
+
+PCA9624::PCA9624( PinName i2c_sda, PinName i2c_scl, char i2c_address )
+ : PCA962x( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 8 )
+{
+ initialize();
+}
+
+PCA9624::PCA9624( I2C &i2c_obj, char i2c_address )
+ : PCA962x( i2c_obj, i2c_address ), n_of_ports( 8 )
+{
+ initialize();
+}
+
+PCA9624::~PCA9624()
+{
+}
+
+void PCA9624::initialize( void )
+{
+ char init_array0[] = {
+ PCA962x::AUTO_INCREMENT | REGISTER_START, // Command
+ 0x00, 0x00, // MODE1, MODE2
+ };
+ char init_array1[] = {
+ PCA962x::AUTO_INCREMENT | LEDOUT_REGISTER_START, // Command
+ 0xAA, 0xAA, // LEDOUT[1:0]
+ };
+
+ write( init_array0, sizeof( init_array0 ) );
+ write( init_array1, sizeof( init_array1 ) );
+}
+
+char PCA9624::pwm_register_access( int port )
+{
+ if ( port < n_of_ports )
+ return ( PWM_REGISTER_START + port );
+
+ return ( PWMALL );
+}
+
+int PCA9624::number_of_ports( void )
+{
+ return ( n_of_ports );
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9624/PCA9624.h Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,157 @@
+/** PCA9624 PWM control LED driver
+ *
+ * An operation sample of PCA9624 8-channel Fm+ I2C-bus 100mA/40V LED driver.
+ * mbed accesses the PCA9624 registers through I2C.
+ *
+ * @class PCA9624
+ * @author Akifumi (Tedd) OKANO, NXP Semiconductors
+ * @version 0.5
+ * @date 26-Feb-2015
+ *
+ * Released under the Apache 2 license License
+ *
+ * About PCA9624:
+ * http://www.nxp.com/products/lighting_driver_and_controller_ics/i2c_led_display_control/series/PCA9624.html
+ */
+
+#ifndef MBED_PCA9624
+#define MBED_PCA9624
+
+#include "mbed.h"
+#include "PCA962x.h"
+
+/** PCA9624 class
+ *
+ * This is a driver code for the PCA9624 8-channel Fm+ I2C-bus 100mA/40V PWM control LED driver.
+ * This class provides interface for PCA9624 operation and accessing its registers.
+ * Detail information is available on next URL.
+ * http://www.nxp.com/products/lighting_driver_and_controller_ics/i2c_led_display_control/series/PCA9624.html
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ *
+ * #include "PCA9624.h"
+ * PCA9624 led_cntlr( p28, p27, 0x3E ); // SDA, SCL, Slave_address(option)
+ *
+ * int main()
+ * {
+ * while(1) {
+ * for ( int port = 0; port < led_cntlr.number_of_ports(); port++ ) {
+ * for ( int i = 1; i <= 100; i++ ) {
+ * led_cntlr.pwm( port, (float)i / 100.0 );
+ * wait( 0.01 );
+ * }
+ * }
+ * led_cntlr.pwm( ALLPORTS, 0.0 );
+ * }
+ * }
+ * @endcode
+ */
+
+class PCA9624 : public PCA962x
+{
+public:
+ /** Name of the PCA9624 registers */
+ enum command_reg {
+ MODE1, MODE2,
+ PWM0, PWM1, PWM2, PWM3,
+ PWM4, PWM5, PWM6, PWM7,
+ GRPPWM, GRPFREQ,
+ LEDOUT0, LEDOUT1,
+ SUBADR1, SUBADR2, SUBADR3, ALLCALLADR,
+
+ REGISTER_START = MODE1,
+ LEDOUT_REGISTER_START = LEDOUT0,
+ PWM_REGISTER_START = PWM0,
+ };
+
+ /** Create a PCA9629A instance connected to specified I2C pins with specified address
+ *
+ * @param i2c_sda I2C-bus SDA pin
+ * @param i2c_sda I2C-bus SCL pin
+ * @param i2c_address I2C-bus address (default: 0xC0)
+ */
+ PCA9624( PinName i2c_sda, PinName i2c_scl, char i2c_address = PCA962x::DEFAULT_I2C_ADDR );
+
+ /** Create a PCA9629A instance connected to specified I2C pins with specified address
+ *
+ * @param i2c_obj I2C object (instance)
+ * @param i2c_address I2C-bus address (default: 0xC0)
+ */
+ PCA9624( I2C &i2c_obj, char i2c_address = PCA962x::DEFAULT_I2C_ADDR );
+
+ /** Destractor
+ *
+ */
+ virtual ~PCA9624();
+
+ /** Returns the number of output ports
+ *
+ * @returns
+ * The number of output ports
+ */
+ virtual int number_of_ports( void );
+
+#if DOXYGEN_ONLY
+ /** Set the output duty-cycle, specified as a percentage (float)
+ *
+ * @param port Selecting output port
+ * 'ALLPORTS' can be used to set all port duty-cycle same value.
+ * @param v A floating-point value representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ * Values outside this range will have undefined behavior.
+ */
+ void pwm( int port, float v );
+
+ /** Set all output port duty-cycle, specified as a percentage (array of float)
+ *
+ * @param vp Aray to floating-point values representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ *
+ * @note
+ * The aray should have length of 8
+ */
+ void pwm( float *vp );
+
+ /** Register write (single byte) : Low level access to device register
+ *
+ * @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 );
+#endif
+
+private:
+ virtual void initialize( void );
+ virtual char pwm_register_access( int port );
+
+ const int n_of_ports;
+}
+;
+
+#endif // MBED_PCA9624
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9626/PCA9626.cpp Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "PCA9626.h"
+
+PCA9626::PCA9626( PinName i2c_sda, PinName i2c_scl, char i2c_address )
+ : PCA962x( i2c_sda, i2c_scl, i2c_address ), n_of_ports( 24 )
+{
+ initialize();
+}
+
+PCA9626::PCA9626( I2C &i2c_obj, char i2c_address )
+ : PCA962x( i2c_obj, i2c_address ), n_of_ports( 24 )
+{
+ initialize();
+}
+
+PCA9626::~PCA9626()
+{
+}
+
+void PCA9626::initialize( void )
+{
+ char init_array0[] = {
+ PCA962x::AUTO_INCREMENT | REGISTER_START, // Command
+ 0x00, 0x00, // MODE1, MODE2
+ };
+ char init_array1[] = {
+ PCA962x::AUTO_INCREMENT | LEDOUT_REGISTER_START, // Command
+ 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, // LEDOUT[5:0]
+ };
+
+ write( init_array0, sizeof( init_array0 ) );
+ write( init_array1, sizeof( init_array1 ) );
+}
+
+char PCA9626::pwm_register_access( int port )
+{
+ if ( port < n_of_ports )
+ return ( PWM_REGISTER_START + port );
+
+ return ( PWMALL );
+}
+
+int PCA9626::number_of_ports( void )
+{
+ return ( n_of_ports );
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PCA9626/PCA9626.h Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,161 @@
+/** PCA9626 PWM control LED driver
+ *
+ * An operation sample of PCA9626 24-channel Fm+ I2C-bus 100mA/40 V LED driver.
+ * mbed accesses the PCA9626 registers through I2C.
+ *
+ * @class PCA9626
+ * @author Akifumi (Tedd) OKANO, NXP Semiconductors
+ * @version 0.5
+ * @date 26-Feb-2015
+ *
+ * Released under the Apache 2 license License
+ *
+ * About PCA9626:
+ * http://www.nxp.com/products/lighting_driver_and_controller_ics/i2c_led_display_control/series/PCA9626.html
+ */
+
+#ifndef MBED_PCA9626
+#define MBED_PCA9626
+
+#include "mbed.h"
+#include "PCA962x.h"
+
+/** PCA9626 class
+ *
+ * This is a driver code for the PCA9626 24-channel Fm+ I2C-bus 100mA/40V PWM control LED driver.
+ * This class provides interface for PCA9626 operation and accessing its registers.
+ * Detail information is available on next URL.
+ * http://www.nxp.com/products/lighting_driver_and_controller_ics/i2c_led_display_control/series/PCA9626.html
+ *
+ * Example:
+ * @code
+ * #include "mbed.h"
+ *
+ * #include "PCA9626.h"
+ * PCA9626 led_cntlr( p28, p27, 0x3E ); // SDA, SCL, Slave_address(option)
+ *
+ * int main()
+ * {
+ * while(1) {
+ * for ( int port = 0; port < led_cntlr.number_of_ports(); port++ ) {
+ * for ( int i = 1; i <= 100; i++ ) {
+ * led_cntlr.pwm( port, (float)i / 100.0 );
+ * wait( 0.01 );
+ * }
+ * }
+ * led_cntlr.pwm( ALLPORTS, 0.0 );
+ * }
+ * }
+ * @endcode
+ */
+
+class PCA9626 : public PCA962x
+{
+public:
+ /** Name of the PCA9626 registers */
+ enum command_reg {
+ MODE1, MODE2,
+ PWM0, PWM1, PWM2, PWM3,
+ PWM4, PWM5, PWM6, PWM7,
+ PWM8, PWM9, PWM10, PWM11,
+ PWM12, PWM13, PWM14, PWM15,
+ PWM16, PWM17, PWM18, PWM19,
+ PWM20, PWM21, PWM22, PWM23,
+ GRPPWM, GRPFREQ, CHASE,
+ LEDOUT0, LEDOUT1, LEDOUT2, LEDOUT3, LEDOUT4, LEDOUT5,
+ SUBADR1, SUBADR2, SUBADR3, ALLCALLADR,
+
+ REGISTER_START = MODE1,
+ LEDOUT_REGISTER_START = LEDOUT0,
+ PWM_REGISTER_START = PWM0,
+ };
+
+ /** Create a PCA9629A instance connected to specified I2C pins with specified address
+ *
+ * @param i2c_sda I2C-bus SDA pin
+ * @param i2c_sda I2C-bus SCL pin
+ * @param i2c_address I2C-bus address (default: 0xC0)
+ */
+ PCA9626( PinName i2c_sda, PinName i2c_scl, char i2c_address = PCA962x::DEFAULT_I2C_ADDR );
+
+ /** Create a PCA9629A instance connected to specified I2C pins with specified address
+ *
+ * @param i2c_obj I2C object (instance)
+ * @param i2c_address I2C-bus address (default: 0xC0)
+ */
+ PCA9626( I2C &i2c_obj, char i2c_address = PCA962x::DEFAULT_I2C_ADDR );
+
+ /** Destractor
+ *
+ */
+ virtual ~PCA9626();
+
+ /** Returns the number of output ports
+ *
+ * @returns
+ * The number of output ports
+ */
+ virtual int number_of_ports( void );
+
+#if DOXYGEN_ONLY
+ /** Set the output duty-cycle, specified as a percentage (float)
+ *
+ * @param port Selecting output port
+ * 'ALLPORTS' can be used to set all port duty-cycle same value.
+ * @param v A floating-point value representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ * Values outside this range will have undefined behavior.
+ */
+ void pwm( int port, float v );
+
+ /** Set all output port duty-cycle, specified as a percentage (array of float)
+ *
+ * @param vp Aray to floating-point values representing the output duty-cycle,
+ * specified as a percentage. The value should lie between
+ * 0.0f (representing on 0%) and 1.0f (representing on 100%).
+ *
+ * @note
+ * The aray should have length of 24
+ */
+ void pwm( float *vp );
+
+ /** Register write (single byte) : Low level access to device register
+ *
+ * @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 );
+#endif
+
+private:
+ virtual void initialize( void );
+ virtual char pwm_register_access( int port );
+
+ const int n_of_ports;
+}
+;
+
+#endif // MBED_PCA9626
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/base_class/PCA962x.cpp Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,88 @@
+#include "mbed.h"
+#include "PCA962x.h"
+
+PCA962x::PCA962x( PinName i2c_sda, PinName i2c_scl, char i2c_address )
+ : i2c_p( new I2C( i2c_sda, i2c_scl ) ), i2c( *i2c_p ), address( i2c_address )
+{
+}
+
+PCA962x::PCA962x( I2C &i2c_, char i2c_address )
+ : i2c_p( NULL ), i2c( i2c_ ), address( i2c_address )
+{
+}
+
+PCA962x::~PCA962x()
+{
+ if ( NULL != i2c_p )
+ delete i2c_p;
+}
+
+void PCA962x::reset( void )
+{
+ char va[] = { 0xA5, 0x5A };
+ i2c.write( 0x06, va, sizeof( va ) );
+}
+
+void PCA962x::pwm( int port, float v )
+{
+ char reg_addr;
+
+ reg_addr = pwm_register_access( port );
+
+ if ( PWMALL == reg_addr ) {
+ int np = number_of_ports();
+ float va[ np ];
+
+ for ( int i = 0; i < np; i++ )
+ va[ i ] = v;
+
+ pwm( va );
+
+ } else {
+ write( reg_addr, (char)(v * 255.0) );
+ }
+}
+
+void PCA962x::pwm( float *vp )
+{
+ int n_of_ports = number_of_ports();
+ char data[ n_of_ports + 1 ];
+
+ *data = pwm_register_access( 0 );
+
+ for ( int i = 1; i <= n_of_ports; i++ )
+ data[ i ] = (char)(*vp++ * 255.0);
+
+ write( data, sizeof( data ) );
+}
+
+void PCA962x::write( char *data, int length )
+{
+ *data |= AUTO_INCREMENT;
+ i2c.write( address, data, length );
+}
+
+void PCA962x::write( char reg_addr, char data )
+{
+ char c[2];
+
+ c[0] = reg_addr;
+ c[1] = data;
+
+ i2c.write( address, c, 2 );
+}
+
+void PCA962x::read( char reg_addr, char *data, int length )
+{
+ reg_addr |= 0x80;
+ i2c.write( address, (char *)(®_addr), 1, true );
+ i2c.read( address, data, length );
+}
+
+char PCA962x::read( char reg_addr )
+{
+ i2c.write( address, (char *)(®_addr), 1, true );
+ i2c.read( address, (char *)(®_addr), 1 );
+
+ return ( reg_addr );
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/base_class/PCA962x.h Thu Feb 26 09:16:41 2015 +0000
@@ -0,0 +1,62 @@
+/** PCA962x PWM control LED driver family
+ *
+ * Abstract class for PCA962x family
+ * No instance can be made from this class
+ *
+ * @class PCA9956A
+ * @author Akifumi (Tedd) OKANO, NXP Semiconductors
+ * @version 0.5
+ * @date 26-Feb-2015
+ *
+ * Released under the Apache 2 license License
+ */
+
+#ifndef MBED_PCA962x
+#define MBED_PCA962x
+
+#include "mbed.h"
+
+#define ALLPORTS 0xFF
+#define DEFAULT_PWM 1.0
+
+/** PCA962x class
+ *
+ * Abstract class for PCA962x family
+ * No instance can be made from this class
+ */
+class PCA962x
+{
+public:
+ PCA962x( PinName i2c_sda, PinName i2c_scl, char i2c_address = DEFAULT_I2C_ADDR );
+ PCA962x( I2C &i2c_obj, char i2c_address = DEFAULT_I2C_ADDR );
+ virtual ~PCA962x();
+
+ void reset( void );
+
+ void pwm( int port, float v );
+ void pwm( float *vp );
+ virtual int number_of_ports( void ) = 0;
+
+ void write( char reg_addr, char data );
+ void write( char *data, int length );
+ char read( char reg_addr );
+ void read( char reg_addr, char *data, int length );
+
+protected:
+ enum {
+ DEFAULT_I2C_ADDR = 0xC0,
+ AUTO_INCREMENT = 0x80,
+ PWMALL = 0xFF
+ };
+
+private:
+ virtual void initialize( void ) = 0;
+ virtual char pwm_register_access( int port ) = 0;
+
+ I2C *i2c_p;
+ I2C &i2c;
+ char address; // I2C slave address
+}
+;
+
+#endif // MBED_PCA962x
PCA9622, PCA9624, PCA9626 : 8, 16 & 24ch LED driver (Voltage switch type)