#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... | |
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.
| MAX6956::MAX6956 | ( | ) |
Default constructor, uses default I2C address.
Definition at line 40 of file MAX6956.cpp.
| MAX6956::MAX6956 | ( | uint8_t | address | ) |
Specific address constructor.
| address | I2C address |
Definition at line 49 of file MAX6956.cpp.
| void MAX6956::configAllPorts | ( | uint8_t | portConfig | ) |
Configure all ports the same
| portConfig | Valid options are: 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
| 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 |
| Num | Dec | Hex | Prt | Port Status Array | Ports Config Array |
|---|---|---|---|---|---|
| 00 | 44 | 0x2C | P12 | portsStatus[0][0] | portsConfig[0][1-0] |
| 01 | 45 | 0x2D | P13 | portsStatus[0][1] | portsConfig[0][3-2] |
| 02 | 46 | 0x2E | P14 | portsStatus[0][2] | portsConfig[0][5-4] |
| 03 | 47 | 0x2F | P15 | portsStatus[0][3] | portsConfig[0][7-6] |
| 04 | 48 | 0x30 | P16 | portsStatus[0][4] | portsConfig[1][1-0] |
| 05 | 49 | 0x31 | P17 | portsStatus[0][5] | portsConfig[1][3-2] |
| 06 | 50 | 0x32 | P18 | portsStatus[0][6] | portsConfig[1][5-4] |
| 07 | 51 | 0x33 | P19 | portsStatus[0][7] | portsConfig[1][7-6] |
| 08 | 52 | 0x34 | P20 | portsStatus[1][0] | portsConfig[2][1-0] |
| 09 | 53 | 0x35 | P21 | portsStatus[1][1] | portsConfig[2][3-2] |
| 10 | 54 | 0x36 | P22 | portsStatus[1][2] | portsConfig[2][5-4] |
| 11 | 55 | 0x37 | P23 | portsStatus[1][3] | portsConfig[2][7-6] |
| 12 | 56 | 0x38 | P24 | portsStatus[1][4] | portsConfig[3][1-0] |
| 13 | 57 | 0x39 | P25 | portsStatus[1][5] | portsConfig[3][3-2] |
| 14 | 58 | 0x3A | P26 | portsStatus[1][6] | portsConfig[3][5-4] |
| 15 | 59 | 0x3B | P27 | portsStatus[1][7] | portsConfig[3][7-6] |
| 16 | 60 | 0x3C | P28 | portsStatus[2][0] | portsConfig[4][1-0] |
| 17 | 61 | 0x3D | P29 | portsStatus[2][1] | portsConfig[4][3-2] |
| 18 | 62 | 0x3E | P30 | portsStatus[2][2] | portsConfig[4][5-4] |
| 19 | 63 | 0x3F | P31 | portsStatus[2][3] | portsConfig[4][7-6] |
| port | Port register address (MAX6956_RA_PORT12, ect) |
| portConfig | Valid options are: 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
| lower | Lower port register address (MAX6956_RA_PORT12, ect) |
| upper | Upper port register address (MAX6956_RA_PORT12, ect) |
| portConfig | Valid options are: 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
Definition at line 94 of file MAX6956.cpp.
| bool MAX6956::getEnableIndividualCurrent | ( | ) |
Get transition detection configuration bit
Definition at line 134 of file MAX6956.cpp.
| bool MAX6956::getEnableTransitionDetection | ( | ) |
Get transition detection configuration bit
Definition at line 152 of file MAX6956.cpp.
| uint8_t MAX6956::getGlobalCurrent | ( | ) |
Get 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.
Definition at line 205 of file MAX6956.cpp.
| bool MAX6956::getPower | ( | ) |
Get power configuration bit
Definition at line 110 of file MAX6956.cpp.
| bool MAX6956::getTestMode | ( | ) |
Returns true if test mode is enabled.
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.
| power | 0 is min, 15 is max brightness. |
Definition at line 444 of file MAX6956.cpp.
| void MAX6956::setConfigReg | ( | uint8_t | config | ) |
Set config register
| config | uint8_t value to set register |
Definition at line 102 of file MAX6956.cpp.
| void MAX6956::setEnableIndividualCurrent | ( | bool | global | ) |
Enable or disable global current
| global | Boolean value, true enables, false disables individual current |
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.
| transition | Boolean value, true enables, false disables transition detection |
Definition at line 162 of file MAX6956.cpp.
| void MAX6956::setGlobalCurrent | ( | uint8_t | current | ) |
Set current globally
| current | uint8_t 0-15, 0 = min, 15 = max brightness |
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
| mask | 8 bit value. MSB is ignored. |
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.
| port | Port register address (MAX6956_RA_PORT12, ect) |
| power | 0 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.
| port | Port register address (MAX6956_RA_PORT12, ect) |
| power | 0 is off, 15 is max brightness. |
Definition at line 346 of file MAX6956.cpp.
| void MAX6956::setPower | ( | bool | power | ) |
Enable or disable power
| power | Boolean value, true enables, false disables power |
Definition at line 118 of file MAX6956.cpp.
| void MAX6956::setTestMode | ( | bool | test | ) |
Enable or disable test mode
| test | Boolean, true enables, false disables |
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.
Definition at line 72 of file MAX6956.cpp.
| void MAX6956::togglePower | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
| 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]
| 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]
1.8.5