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: PCA9956A_Hello pca9956b_two_demoboards PCA9955A_Gradation_control PCA9955A_Gradation_control ... more
PCA9955A Class Reference
#include <PCA9955A.h>
Inherits PCA995xA.
Public Types | |
enum | LedPinName { L0, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L_NC = ~0x0L } |
PCA9955A pin names high-level API i.e. More... | |
enum | command_reg { MODE1 = 0x00, MODE2, LEDOUT0, LEDOUT1, LEDOUT2, LEDOUT3, GRPPWM = 0x06, GRPFREQ, PWM0, PWM1, PWM2, PWM3, PWM4, PWM5, PWM6, PWM7, PWM8, PWM9, PWM10, PWM11, PWM12, PWM13, PWM14, PWM15, IREF0, IREF1, IREF2, IREF3, IREF4, IREF5, IREF6, IREF7, IREF8, IREF9, IREF10, IREF11, IREF12, IREF13, IREF14, IREF15, RAMP_RATE_GRP0, STEP_TIME_GRP0, HOLD_CNTL_GRP0, IREF_GRP0, RAMP_RATE_GRP1, STEP_TIME_GRP1, HOLD_CNTL_GRP1, IREF_GRP1, RAMP_RATE_GRP2, STEP_TIME_GRP2, HOLD_CNTL_GRP2, IREF_GRP2, RAMP_RATE_GRP3, STEP_TIME_GRP3, HOLD_CNTL_GRP3, IREF_GRP3, GRAD_MODE_SEL0 = 0x38, GRAD_MODE_SEL1, GRAD_GRP_SEL0, GRAD_GRP_SEL1, GRAD_GRP_SEL2, GRAD_GRP_SEL3, GRAD_CNTL, OFFSET = 0x3F, SUBADR1, SUBADR2, SUBADR3, ALLCALLADR, PWMALL, IREFALL, EFLAG0, EFLAG1 } |
Name of the PCA9955A registers (for direct register access) More... | |
Public Member Functions | |
PCA9955A (PinName i2c_sda, PinName i2c_scl, char i2c_address=PCA995xA::DEFAULT_I2C_ADDR) | |
Create a PCA9955A instance connected to specified I2C pins with specified address. | |
PCA9955A (I2C &i2c_obj, char i2c_address=PCA995xA::DEFAULT_I2C_ADDR) | |
Create a PCA9955A instance connected to specified I2C pins with specified address. | |
virtual | ~PCA9955A () |
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 | current (int port, float vp) |
Set the output current, specified as a percentage (float) | |
void | current (float *vP) |
Set all output port curent, 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. | |
float | gradation_ramp_setting (char group, float cycle, char flag_on, char flag_off, int ramp_flag) |
Gradation control setting. | |
void | gradation_group_setting (char group, char port) |
Gradation control: Port assignment to group. | |
void | gradation_start (char group, char continuous_flag=true) |
Gradation control: Start. | |
void | gradation_stop (void) |
Gradation control: Stop. | |
void | gradation_group_clear (void) |
Gradation control: Clear all group assignments. | |
void | gradation_setting (int group, char ramp_rate, char step_time, char hold_cntl, char iref) |
Setting gradation control registers (low level setting API) | |
void | dump_gradation_registers (void) |
Setting gradation register dump (for debugging) |
Detailed Description
PCA9955A class.
PCA9955A constant current LED driver.
This is a driver code for the PCA9955A 16-channel Fm+ I2C-bus 57mA/20V constant current LED driver. This class provides interface for PCA9955A operation and accessing its registers. Detail information is available on next URL. http://www.nxp.com/products/interface_and_connectivity/i2c/i2c_led_display_control/PCA9955ATW.html
Next sample code shows operation based on low-level-API (operated by just device instane)
Example:
// PCA9955A operation sample using its device instance #include "mbed.h" #include "PCA9955A.h" PCA9955A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option) int main() { led_cntlr.current( ALLPORTS, 1.0 ); // Set all ports output current 100% 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.
// PCA9955A operation sample using high-level-API #include "mbed.h" #include "PCA9955A.h" PCA9955A led_cntlr( p28, p27, 0x02 ); // SDA, SCL, Slave_address(option) LedPwmOutCC led0( led_cntlr, L0 ); // Instance for LED0 pin LedPwmOutCC led1( led_cntlr, L1 ); // Instance for LED1 pin LedPwmOutCC led2( led_cntlr, L2 ); // Instance for LED2 pin int main() { led0.current( 0.5 ); // LED0 pin current output setting to 50% led1.current( 0.5 ); // LED1 pin current output setting to 50% led2.current( 0.5 ); // LED2 pin current output setting to 50% 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 PCA9955A 16-channel Fm+ I2C-bus 57mA/20V constant current LED driver. mbed accesses PCA9955A registers via I2C.
- Version:
- 0.6
- Date:
- 19-Mar-2015 (minor fix on 17-Jun-2022)
Released under the Apache 2 license
About PCA9955A: http://www.nxp.com/products/interface_and_connectivity/i2c/i2c_led_display_control/PCA9955ATW.html
Definition at line 97 of file PCA9955A.h.
Member Enumeration Documentation
enum command_reg |
Name of the PCA9955A registers (for direct register access)
- Enumerator:
Definition at line 125 of file PCA9955A.h.
enum LedPinName |
PCA9955A pin names high-level API i.e.
LedPwmOutCC
- Enumerator:
Definition at line 103 of file PCA9955A.h.
Constructor & Destructor Documentation
PCA9955A | ( | PinName | i2c_sda, |
PinName | i2c_scl, | ||
char | i2c_address = PCA995xA::DEFAULT_I2C_ADDR |
||
) |
Create a PCA9955A instance connected to specified I2C pins with specified address.
- Parameters:
-
i2c_sda I2C-bus SDA pin i2c_sda I2C-bus SCL pin i2c_address (option) I2C-bus address (default: 0xC0)
Definition at line 4 of file PCA9955A.cpp.
PCA9955A | ( | I2C & | i2c_obj, |
char | i2c_address = PCA995xA::DEFAULT_I2C_ADDR |
||
) |
Create a PCA9955A instance connected to specified I2C pins with specified address.
- Parameters:
-
i2c_obj I2C object (instance) i2c_address (option) I2C-bus address (default: 0xC0)
Definition at line 10 of file PCA9955A.cpp.
~PCA9955A | ( | ) | [virtual] |
Destractor.
Definition at line 16 of file PCA9955A.cpp.
Member Function Documentation
void current | ( | int | port, |
float | vp | ||
) | [virtual] |
Set the output current, specified as a percentage (float)
- Parameters:
-
port Selecting output port 'ALLPORTS' can be used to set all port current same value. v A floating-point value representing the output current, 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 PCA995xA.
void current | ( | float * | vP ) |
Set all output port curent, specified as a percentage (array of float)
- Parameters:
-
vp Aray to floating-point values representing the output current, 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
Reimplemented from PCA995xA.
void dump_gradation_registers | ( | void | ) |
Setting gradation register dump (for debugging)
Definition at line 241 of file PCA9955A.cpp.
void gradation_group_clear | ( | void | ) |
Gradation control: Clear all group assignments.
Set all output port operation to no-gradation control
Definition at line 147 of file PCA9955A.cpp.
void gradation_group_setting | ( | char | group, |
char | port | ||
) |
Gradation control: Port assignment to group.
Each ports which is going to use in gradation control should be assigned to group. This function help to assign the port to 1 of 4 groups.
- Parameters:
-
group Target group port A output port which is being assigned to the target group
Definition at line 130 of file PCA9955A.cpp.
float gradation_ramp_setting | ( | char | group, |
float | cycle, | ||
char | flag_on, | ||
char | flag_off, | ||
int | ramp_flag | ||
) |
Gradation control setting.
Auto calculation and register setting API for gradation control. User can set the gradation by specifying cycle, hold-ON/OFF time and ramp-up/down enabling. All register values are calcurated automatically to have fine gradation setting. In this routine, the IREF (current) setting is fixed to maximum (i.e. 0xFF)
- Parameters:
-
group Group selector cycle Ramp rate register (RAMP_RATE_GRPn) value flag_on Holding time for ON can be selected from available constants. Those are 0, 0.25, 0.5, 0.75, 1, 2, 4 and 6 seconds. Use one of next words: HOLD_0_00_SEC, HOLD_0_25_SEC, HOLD_0_50_SEC, HOLD_0_75_SEC, HOLD_1_00_SEC, HOLD_2_00_SEC, HOLD_4_00_SEC or HOLD_6_00_SEC flag_off Holding time for OFF can be selected from available constants. Those are 0, 0.25, 0.5, 0.75, 1, 2, 4 and 6 seconds. Use one of next words: HOLD_0_00_SEC, HOLD_0_25_SEC, HOLD_0_50_SEC, HOLD_0_75_SEC, HOLD_1_00_SEC, HOLD_2_00_SEC, HOLD_4_00_SEC or HOLD_6_00_SEC ramp_flag Choose one from next words : NO_RAMP, RAMP_UP_ONLY, RAMP_DOWN_ONLY or RAMP_UP_DOWN
- Returns:
- calculated actual time for one cycle (in seconds)
- See also:
- gradation_setting()
Definition at line 156 of file PCA9955A.cpp.
void gradation_setting | ( | int | group, |
char | ramp_rate, | ||
char | step_time, | ||
char | hold_cntl, | ||
char | iref | ||
) |
Setting gradation control registers (low level setting API)
- Parameters:
-
group Group selector ramp_rate Ramp rate register (RAMP_RATE_GRPn) value step_time Step time register (STEP_TIME_GRPn) value hold_cntl Hold control register (HOLD_CNTL_GRPn) value iref IREF (current setting) register (IREF_GRPn) value
- See also:
- gradation_ramp_setting()
Definition at line 60 of file PCA9955A.cpp.
void gradation_start | ( | char | group, |
char | continuous_flag = true |
||
) |
Gradation control: Start.
- Parameters:
-
group Group selector continuous_flag (option) Set false for one-shot operation
Definition at line 72 of file PCA9955A.cpp.
void gradation_stop | ( | void | ) |
Gradation control: Stop.
Definition at line 85 of file PCA9955A.cpp.
int number_of_ports | ( | void | ) | [virtual] |
Returns the number of output ports.
- Returns:
- The number of output ports
Implements PCA995xA.
Definition at line 52 of file PCA9955A.cpp.
void pwm | ( | int | port, |
float | v | ||
) | [virtual] |
Set the output duty-cycle, specified as a percentage (float)
- Parameters:
-
port Selecting output port 'ALLPORTS' can be used to set all port duty-cycle same value. 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.
Reimplemented from PCA995xA.
void pwm | ( | float * | vp ) |
Set all output port duty-cycle, specified as a percentage (array of float)
- Parameters:
-
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
Reimplemented from PCA995xA.
void read | ( | char | reg_addr, |
char * | data, | ||
int | length | ||
) |
Register write (multiple bytes) : Low level access to device register.
- Parameters:
-
reg_addr Register address data Pointer to an array. The values are stored in this array. length Length of data
Reimplemented from PCA995xA.
char read | ( | char | reg_addr ) |
Register read (single byte) : Low level access to device register.
- Parameters:
-
reg_addr Register address
- Returns:
- Read value from register
Reimplemented from PCA995xA.
void write | ( | char | reg_addr, |
char | data | ||
) |
Register write (single byte) : Low level access to device register.
- Parameters:
-
reg_addr Register address data Value for setting into the register
Reimplemented from PCA995xA.
void write | ( | char * | data, |
int | length | ||
) |
Register write (multiple bytes) : Low level access to device register.
- Parameters:
-
data Pointer to an array. First 1 byte should be the writing start register address length Length of data
Reimplemented from PCA995xA.
Generated on Wed Jul 13 2022 08:07:57 by
