MAX6956  1.0
MAX6956i2Clibrary
 All Data Structures Files Functions Variables Macros
Public Member Functions | Data Fields | Private Attributes
MAX6956 Class Reference

#include <MAX6956.h>

Public Member Functions

 MAX6956 ()
 
 MAX6956 (uint8_t address)
 
void initialize ()
 
bool testConnection ()
 
void reset ()
 
uint8_t getConfigReg ()
 
void setConfigReg (uint8_t config)
 
bool getPower ()
 
void togglePower ()
 
void setPower (bool power)
 
bool getEnableIndividualCurrent ()
 
void setEnableIndividualCurrent (bool global)
 
bool getEnableTransitionDetection ()
 
void setEnableTransitionDetection (bool transition)
 
uint8_t getGlobalCurrent ()
 
void setGlobalCurrent (uint8_t current)
 
bool getTestMode ()
 
void setTestMode (bool test)
 
uint8_t getInputMask ()
 
void setInputMask (uint8_t mask)
 
void configPort (uint8_t port, uint8_t portConfig)
 
void configPorts (uint8_t lower, uint8_t upper, uint8_t portConfig)
 
void configAllPorts (uint8_t portConfig)
 
void setPortLevel (uint8_t port, uint8_t power)
 0 = off, 1-15 brightness levels. More...
 
void setPortCurrent (uint8_t port, uint8_t power)
 0-15 brightness levels. More...
 
void setAllPortsCurrent (uint8_t power)
 0-15, 0 = min brightness (not off) 15 = max More...
 
void enableAllPorts ()
 
void disableAllPorts ()
 

Data Fields

uint8_t portsConfig [5]
 
uint8_t portsStatus [3]
 

Private Attributes

uint8_t devAddr
 Holds the current device address. More...
 
uint8_t buffer [1]
 Buffer for reading data from the device. More...
 
uint8_t portConfig
 Holder for port config bit pair. More...
 
uint8_t portCurrentRA
 Holder for port current register. More...
 
uint8_t portCurrentBit
 Holder for the current bit offset. More...
 
uint8_t psArrayIndex
 array index More...
 
uint8_t psBitPosition
 bit position More...
 

Detailed Description

A library for controlling the MAX6956 using i2C.

The MAX6956 compact, serial-interfaced LED display driver/I/O expander provide microprocessors with up to 28 ports. Each port is individually user configurable to either a logic input, logic output, or common-anode (CA) LED constant-current segment driver. Each port configured as an LED segment driver behaves as a digitally controlled constant-current sink, with 16 equal current steps from 1.5mA to 24mA. The LED drivers are suitable for both discrete LEDs and CA numeric and alphanumeric LED digits.

Each port configured as a general-purpose I/O (GPIO) can be either a push-pull logic output capable of sink- ing 10mA and sourcing 4.5mA, or a Schmitt logic input with optional internal pullup. Seven ports feature config- urable transition detection logic, which generates an interrupt upon change of port logic level. The MAX6956 is controlled through an I2C-compatible 2-wire serial interface, and uses four-level logic to allow 16 I 2C addresses from only 2 select pins.

The MAX6956AAX and MAX6956ATL have 28 ports and are available in 36-pin SSOP and 40-pin thin QFN packages, respectively. The MAX6956AAI and MAX6956ANI have 20 ports and are available in 28-pin SSOP and 28-pin DIP packages, respectively.

For an SPI-interfaced version, refer to the MAX6957 data sheet. For a lower cost pin-compatible port expander without the constant-current LED drive capa- bility, refer to the MAX7300 data sheet.

Definition at line 456 of file MAX6956.h.

Constructor & Destructor Documentation

MAX6956::MAX6956 ( )

Default constructor, uses default I2C address.

See Also
MAX6956_DEFAULT_ADDRESS

Definition at line 40 of file MAX6956.cpp.

MAX6956::MAX6956 ( uint8_t  address)

Specific address constructor.

Parameters
addressI2C address
See Also
MAX6956_DEFAULT_ADDRESS
MAX6956_ADDRESS

Definition at line 49 of file MAX6956.cpp.

Member Function Documentation

void MAX6956::configAllPorts ( uint8_t  portConfig)
Configure all ports the same
Parameters
portConfigValid options are: MAX6956_OUTPUT_LED, MAX6956_OUTPUT_GPIO, MAX6956_INPUT_WO_PULL, MAX6956_INPUT_W_PULL
See Also
MAX6956_OUTPUT_LED
MAX6956_OUTPUT_GPIO
MAX6956_INPUT_WO_PULL
MAX6956_INPUT_W_PULL

Definition at line 332 of file MAX6956.cpp.

void MAX6956::configPort ( uint8_t  port,
uint8_t  portConfig 
)
Takes an INDIVIDUAL port register address (MAX6956_RA_PORT12, ect)
and configures it as: MAX6956_OUTPUT_LED, MAX6956_OUTPUT_GPIO,
MAX6956_INPUT_WO_PULL, or MAX6956_INPUT_W_PULL

Port registers

Addr. Name
0x09 MAX6956_RA_CONFIG_P7P6P5P4
0x0A MAX6956_RA_CONFIG_P11P10P9P8
0x0B MAX6956_RA_CONFIG_P15P14P13P12
0x0C MAX6956_RA_CONFIG_P19P18P17P16
0x0D MAX6956_RA_CONFIG_P23P22P21P20
0x0E MAX6956_RA_CONFIG_P27P26P25P24
0x0F MAX6956_RA_CONFIG_P31P30P29P28
NumDecHex PrtPort Status ArrayPorts Config Array
00 44 0x2CP12portsStatus[0][0]portsConfig[0][1-0]
01 45 0x2DP13portsStatus[0][1]portsConfig[0][3-2]
02 46 0x2EP14portsStatus[0][2]portsConfig[0][5-4]
03 47 0x2FP15portsStatus[0][3]portsConfig[0][7-6]
04 48 0x30P16portsStatus[0][4]portsConfig[1][1-0]
05 49 0x31P17portsStatus[0][5]portsConfig[1][3-2]
06 50 0x32P18portsStatus[0][6]portsConfig[1][5-4]
07 51 0x33P19portsStatus[0][7]portsConfig[1][7-6]
08 52 0x34P20portsStatus[1][0]portsConfig[2][1-0]
09 53 0x35P21portsStatus[1][1]portsConfig[2][3-2]
10 54 0x36P22portsStatus[1][2]portsConfig[2][5-4]
11 55 0x37P23portsStatus[1][3]portsConfig[2][7-6]
12 56 0x38P24portsStatus[1][4]portsConfig[3][1-0]
13 57 0x39P25portsStatus[1][5]portsConfig[3][3-2]
14 58 0x3AP26portsStatus[1][6]portsConfig[3][5-4]
15 59 0x3BP27portsStatus[1][7]portsConfig[3][7-6]
16 60 0x3CP28portsStatus[2][0]portsConfig[4][1-0]
17 61 0x3DP29portsStatus[2][1]portsConfig[4][3-2]
18 62 0x3EP30portsStatus[2][2]portsConfig[4][5-4]
19 63 0x3FP31portsStatus[2][3]portsConfig[4][7-6]
Parameters
portPort register address (MAX6956_RA_PORT12, ect)
portConfigValid options are: MAX6956_OUTPUT_LED, MAX6956_OUTPUT_GPIO, MAX6956_INPUT_WO_PULL, MAX6956_INPUT_W_PULL
See Also
MAX6956_RA_PORT12 MAX6956_RA_PORT13 MAX6956_RA_PORT14 MAX6956_RA_PORT15 MAX6956_RA_PORT16 MAX6956_RA_PORT17 MAX6956_RA_PORT18 MAX6956_RA_PORT19 MAX6956_RA_PORT20 MAX6956_RA_PORT21 MAX6956_RA_PORT22 MAX6956_RA_PORT23 MAX6956_RA_PORT24 MAX6956_RA_PORT25 MAX6956_RA_PORT26 MAX6956_RA_PORT27 MAX6956_RA_PORT28 MAX6956_RA_PORT29 MAX6956_RA_PORT30 MAX6956_RA_PORT31
MAX6956_OUTPUT_LED MAX6956_OUTPUT_GPIO MAX6956_INPUT_WO_PULL MAX6956_INPUT_W_PULL

Definition at line 265 of file MAX6956.cpp.

void MAX6956::configPorts ( uint8_t  lower,
uint8_t  upper,
uint8_t  portConfig 
)

Configure consecutive range of ports

Parameters
lowerLower port register address (MAX6956_RA_PORT12, ect)
upperUpper port register address (MAX6956_RA_PORT12, ect)
portConfigValid options are: MAX6956_OUTPUT_LED, MAX6956_OUTPUT_GPIO, MAX6956_INPUT_WO_PULL, MAX6956_INPUT_W_PULL
See Also
MAX6956_OUTPUT_LED
MAX6956_OUTPUT_GPIO
MAX6956_INPUT_WO_PULL
MAX6956_INPUT_W_PULL

Definition at line 285 of file MAX6956.cpp.

void MAX6956::disableAllPorts ( )

Write 0's to all port registers.

Definition at line 463 of file MAX6956.cpp.

void MAX6956::enableAllPorts ( )

Write 1's to all port registers. This enables ports set as outputs and they will always have some brightness, port must be disabled to turn off completely.

Definition at line 453 of file MAX6956.cpp.

uint8_t MAX6956::getConfigReg ( )
Config register
Returns
uint8_t value of register
See Also
MAX6956_RA_CONFIGURATION

Definition at line 94 of file MAX6956.cpp.

bool MAX6956::getEnableIndividualCurrent ( )
Get transition detection configuration bit 
Returns
Boolean value if global current is enabled or not
See Also
MAX6956_RA_CONFIGURATION

Definition at line 134 of file MAX6956.cpp.

bool MAX6956::getEnableTransitionDetection ( )
Get transition detection configuration bit 
Returns
Boolean value if transition detection is enabled or not
See Also
MAX6956_RA_CONFIGURATION

Definition at line 152 of file MAX6956.cpp.

uint8_t MAX6956::getGlobalCurrent ( )
Get global current 
Returns
uint8_t value of register
See Also
MAX6956_RA_GLOBAL_CURRENT

Definition at line 171 of file MAX6956.cpp.

uint8_t MAX6956::getInputMask ( )
Get the input mask to see which ports have changed. MSB is cleared after every read.
Returns
uint8_t value of register
See Also
MAX6956_RA_TRANSITION_DETECT

Definition at line 205 of file MAX6956.cpp.

bool MAX6956::getPower ( )
Get power configuration bit 
Returns
Boolean value if power is enabled or not
See Also
MAX6956_RA_CONFIGURATION

Definition at line 110 of file MAX6956.cpp.

bool MAX6956::getTestMode ( )
Returns true if test mode is enabled. 
Returns
uint8_t value of register
See Also
MAX6956_RA_DISPLAY_TEST

Definition at line 188 of file MAX6956.cpp.

void MAX6956::initialize ( )

Power on and prepare for general usage.

The 28-pin MAX6956ANI and MAX6956AAI make only 20 ports available, P12 to P31.

The eight unused ports should be configured as outputs on power-up by writing 0x55 to registers 0x09 and 0x0A. If this is not done,the eight unused ports remain as unconnected inputs and quiescent supply current rises, although there is no damage to the part.

Definition at line 54 of file MAX6956.cpp.

void MAX6956::reset ( )

Set registers back to Power-up Configuration

Definition at line 80 of file MAX6956.cpp.

void MAX6956::setAllPortsCurrent ( uint8_t  power)

0-15, 0 = min brightness (not off) 15 = max

Set ALL port current registers (MAX6956_RA_PORT12, ect) to the SAME power level 0-15. 0 is off, 15 is max brightness.

Parameters
power0 is min, 15 is max brightness.

Definition at line 444 of file MAX6956.cpp.

void MAX6956::setConfigReg ( uint8_t  config)
Set config register
Parameters
configuint8_t value to set register
See Also
MAX6956_RA_CONFIGURATION

Definition at line 102 of file MAX6956.cpp.

void MAX6956::setEnableIndividualCurrent ( bool  global)
Enable or disable global current
Parameters
globalBoolean value, true enables, false disables individual current
See Also
MAX6956_RA_CONFIGURATION
getGlobalCurrent()
setGlobalCurrent()

Definition at line 144 of file MAX6956.cpp.

void MAX6956::setEnableTransitionDetection ( bool  transition)
Enable or disable transition detection. Must be reset after every mask read.
Parameters
transitionBoolean value, true enables, false disables transition detection
See Also
MAX6956_RA_CONFIGURATION
getInputMask()
setInputMask()

Definition at line 162 of file MAX6956.cpp.

void MAX6956::setGlobalCurrent ( uint8_t  current)
Set current globally
Parameters
currentuint8_t 0-15, 0 = min, 15 = max brightness
See Also
MAX6956_RA_GLOBAL_CURRENT

Definition at line 179 of file MAX6956.cpp.

void MAX6956::setInputMask ( uint8_t  mask)
Set the input mask for which ports to monitor with transition detection
Parameters
mask8 bit value. MSB is ignored.
See Also
MAX6956_RA_TRANSITION_DETECT

Definition at line 214 of file MAX6956.cpp.

void MAX6956::setPortCurrent ( uint8_t  port,
uint8_t  power 
)

0-15 brightness levels.

Takes an INDIVIDUAL port register address (MAX6956_RA_PORT12, ect)

and sets it to a power level 0-15. 0 is min, 15 is max brightness.

Parameters
portPort register address (MAX6956_RA_PORT12, ect)
power0 is min, 15 is max brightness.

Definition at line 404 of file MAX6956.cpp.

void MAX6956::setPortLevel ( uint8_t  port,
uint8_t  power 
)

0 = off, 1-15 brightness levels.

Takes an individual port register address (MAX6956_RA_PORT12, ect)

and sets it to a power scale where 0 = off.

Parameters
portPort register address (MAX6956_RA_PORT12, ect)
power0 is off, 15 is max brightness.

Definition at line 346 of file MAX6956.cpp.

void MAX6956::setPower ( bool  power)
Enable or disable power
Parameters
powerBoolean value, true enables, false disables power
See Also
MAX6956_RA_CONFIGURATION

Definition at line 118 of file MAX6956.cpp.

void MAX6956::setTestMode ( bool  test)
Enable or disable test mode
Parameters
testBoolean, true enables, false disables
See Also
MAX6956_RA_DISPLAY_TEST

Definition at line 196 of file MAX6956.cpp.

bool MAX6956::testConnection ( )

Verify the I2C connection. Make sure the device is connected and responds as expected.

Returns
True if connection is valid, false otherwise

Definition at line 72 of file MAX6956.cpp.

void MAX6956::togglePower ( )
Toggle power
See Also
MAX6956_RA_CONFIGURATION

Definition at line 124 of file MAX6956.cpp.

Field Documentation

uint8_t MAX6956::buffer[1]
private

Buffer for reading data from the device.

Definition at line 556 of file MAX6956.h.

uint8_t MAX6956::devAddr
private

Holds the current device address.

Definition at line 555 of file MAX6956.h.

uint8_t MAX6956::portConfig
private

Holder for port config bit pair.

Definition at line 557 of file MAX6956.h.

uint8_t MAX6956::portCurrentBit
private

Holder for the current bit offset.

Definition at line 559 of file MAX6956.h.

uint8_t MAX6956::portCurrentRA
private

Holder for port current register.

Definition at line 558 of file MAX6956.h.

uint8_t MAX6956::portsConfig[5]

Array that mirrors the configuration of all the ports.

P12 = portsConfig[0][1-0] P13 = portsConfig[0][3-2] P14 = portsConfig[0][5-4] P15 = portsConfig[0][7-6] P16 = portsConfig[1][1-0] P17 = portsConfig[1][3-2] P18 = portsConfig[1][5-4] P19 = portsConfig[1][7-6] P20 = portsConfig[2][1-0] P21 = portsConfig[2][3-2] P22 = portsConfig[2][5-4] P23 = portsConfig[2][7-6] P24 = portsConfig[3][1-0] P25 = portsConfig[3][3-2] P26 = portsConfig[3][5-4] P27 = portsConfig[3][7-6] P28 = portsConfig[4][1-0] P29 = portsConfig[4][3-2] P30 = portsConfig[4][5-4] P31 = portsConfig[4][7-6]

Definition at line 527 of file MAX6956.h.

uint8_t MAX6956::portsStatus[3]

Array that mirrors the on/off status of all the ports.

P12 = portsStatus[0][0] P13 = portsStatus[0][1] P14 = portsStatus[0][2] P15 = portsStatus[0][3] P16 = portsStatus[0][4] P17 = portsStatus[0][5] P18 = portsStatus[0][6] P19 = portsStatus[0][7] P20 = portsStatus[1][0] P21 = portsStatus[1][1] P22 = portsStatus[1][2] P23 = portsStatus[1][3] P24 = portsStatus[1][4] P25 = portsStatus[1][5] P26 = portsStatus[1][6] P27 = portsStatus[1][7] P28 = portsStatus[2][0] P29 = portsStatus[2][1] P30 = portsStatus[2][2] P31 = portsStatus[2][3]

Definition at line 552 of file MAX6956.h.

uint8_t MAX6956::psArrayIndex
private

array index

Definition at line 560 of file MAX6956.h.

uint8_t MAX6956::psBitPosition
private

bit position

Definition at line 561 of file MAX6956.h.


The documentation for this class was generated from the following files: