InetrfaceProducts NXP / PCA962x

Dependencies:   CompLedDvr

Dependents:   PCA9626_Hello PCA9624_Hello PCA9622_Hello

Embed: (wiki syntax)

« Back to documentation index

PCA9624 Class Reference

PCA9624 Class Reference

PCA9624 class. More...

#include <PCA9624.h>

Inherits PCA962x.

Public Types

enum  LedPinName {
  L0, L1, L2, L3,
  L4, L5, L6, L7,
  L_NC = ~0x0L
}
 

PCA9624 pin names high-level API i.e.

More...
enum  command_reg {
  MODE1, MODE2, PWM0, PWM1,
  PWM2, PWM3, PWM4, PWM5,
  PWM6, PWM7, GRPPWM, GRPFREQ,
  LEDOUT0, LEDOUT1, SUBADR1, SUBADR2,
  SUBADR3, ALLCALLADR
}
 

Name of the PCA9624 registers (for direct register access)

More...

Public Member Functions

 PCA9624 (PinName i2c_sda, PinName i2c_scl, char i2c_address=PCA962x::DEFAULT_I2C_ADDR)
 Create a PCA9626 instance connected to specified I2C pins with specified address.
 PCA9624 (I2C &i2c_obj, char i2c_address=PCA962x::DEFAULT_I2C_ADDR)
 Create a PCA9626 instance connected to specified I2C pins with specified address.
virtual ~PCA9624 ()
 Destractor.
virtual int number_of_ports (void)
 Returns the number of output ports.
void pwm (int port, float v)
 Set the output duty-cycle, specified as a percentage (float)
void pwm (float *vp)
 Set all output port duty-cycle, specified as a percentage (array of float)
void write (char reg_addr, char data)
 Register write (single byte) : Low level access to device register.
void write (char *data, int length)
 Register write (multiple bytes) : Low level access to device register.
char read (char reg_addr)
 Register read (single byte) : Low level access to device register.
void read (char reg_addr, char *data, int length)
 Register write (multiple bytes) : Low level access to device register.

Detailed Description

PCA9624 class.

PCA9624 PWM control LED driver.

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

Next sample code shows operation based on low-level-API (operated by just device instane)

Example:

  //  PCA9624 operation sample using its device instance
  
  #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 );
      }
  }

The high-level-API:LedPwmOutCC is also available. It can be used like next sample code.

  //  PCA9624 operation sample using high-level-API

  #include "mbed.h"
  #include "PCA9624.h"

  PCA9624     led_cntlr( p28, p27, 0x3E );    //  SDA, SCL, Slave_address(option)
  LedPwmOut   led0( led_cntlr, L0  );         //  Instance for LED0 pin
  LedPwmOut   led1( led_cntlr, L1  );         //  Instance for LED1 pin
  LedPwmOut   led2( led_cntlr, L2  );         //  Instance for LED2 pin

  int main()
  {
      while(1) {

          for ( float p = 1.0; p >= 0.0; p -= 0.01 ) {
              led0    = p;    //  Set LED0 output PWM dutycycle as 'p'
              wait( 0.01 );
          }

          for ( float p = 1.0; p >= 0.0; p -= 0.01 ) {
              led1    = p;    //  Set LED1 output PWM dutycycle as 'p'
              wait( 0.01 );
          }

          for ( float p = 1.0; p >= 0.0; p -= 0.01 ) {
              led2    = p;    //  Set LED2 output PWM dutycycle as 'p'
              wait( 0.01 );
          }
      }
  }

An operation sample of PCA9624 8-channel Fm+ I2C-bus 100mA/40V LED driver. mbed accesses the PCA9624 registers through I2C.

Author:
Akifumi (Tedd) OKANO, NXP Semiconductors
Version:
0.6
Date:
04-Mar-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

Definition at line 93 of file PCA9624.h.


Member Enumeration Documentation

Name of the PCA9624 registers (for direct register access)

Enumerator:
MODE1 

MODE1 register.

MODE2 

MODE2 register.

PWM0 

PWM0 register.

PWM1 

PWM1 register.

PWM2 

PWM2 register.

PWM3 

PWM3 register.

PWM4 

PWM4 register.

PWM5 

PWM5 register.

PWM6 

PWM6 register.

PWM7 

PWM7 register.

GRPPWM 

GRPPWM register.

GRPFREQ 

GRPFREQ register.

LEDOUT0 

LEDOUT0 register.

LEDOUT1 

LEDOUT1 register.

SUBADR1 

SUBADR1 register.

SUBADR2 

SUBADR2 register.

SUBADR3 

SUBADR3 register.

ALLCALLADR 

ALLCALLADR register.

Definition at line 113 of file PCA9624.h.

enum LedPinName

PCA9624 pin names high-level API i.e.

LedPwmOut

Enumerator:
L0 

LED0 pin.

L1 

LED2 pin.

L2 

LED2 pin.

L3 

LED2 pin.

L4 

LED2 pin.

L5 

LED2 pin.

L6 

LED2 pin.

L7 

LED2 pin.

L_NC 

for when the pin is left no-connection

Definition at line 99 of file PCA9624.h.


Constructor & Destructor Documentation

PCA9624 ( PinName  i2c_sda,
PinName  i2c_scl,
char  i2c_address = PCA962x::DEFAULT_I2C_ADDR 
)

Create a PCA9626 instance connected to specified I2C pins with specified address.

Parameters:
i2c_sdaI2C-bus SDA pin
i2c_sdaI2C-bus SCL pin
i2c_addressI2C-bus address (default: 0xC0)

Definition at line 4 of file PCA9624.cpp.

PCA9624 ( I2C &  i2c_obj,
char  i2c_address = PCA962x::DEFAULT_I2C_ADDR 
)

Create a PCA9626 instance connected to specified I2C pins with specified address.

Parameters:
i2c_objI2C object (instance)
i2c_addressI2C-bus address (default: 0xC0)

Definition at line 10 of file PCA9624.cpp.

~PCA9624 (  ) [virtual]

Destractor.

Definition at line 16 of file PCA9624.cpp.


Member Function Documentation

int number_of_ports ( void   ) [virtual]

Returns the number of output ports.

Returns:
The number of output ports

Implements PCA962x.

Definition at line 43 of file PCA9624.cpp.

void pwm ( int  port,
float  v 
) [virtual]

Set the output duty-cycle, specified as a percentage (float)

Parameters:
portSelecting output port 'ALLPORTS' can be used to set all port duty-cycle same value.
vA 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.

Reimplemented from PCA962x.

void pwm ( float *  vp )

Set all output port duty-cycle, specified as a percentage (array of float)

Parameters:
vpAray 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

Reimplemented from PCA962x.

char read ( char  reg_addr )

Register read (single byte) : Low level access to device register.

Parameters:
reg_addrRegister address
Returns:
Read value from register

Reimplemented from PCA962x.

void read ( char  reg_addr,
char *  data,
int  length 
)

Register write (multiple bytes) : Low level access to device register.

Parameters:
reg_addrRegister address
dataPointer to an array. The values are stored in this array.
lengthLength of data

Reimplemented from PCA962x.

void write ( char *  data,
int  length 
)

Register write (multiple bytes) : Low level access to device register.

Parameters:
dataPointer to an array. First 1 byte should be the writing start register address
lengthLength of data

Reimplemented from PCA962x.

void write ( char  reg_addr,
char  data 
)

Register write (single byte) : Low level access to device register.

Parameters:
reg_addrRegister address
dataValue for setting into the register

Reimplemented from PCA962x.