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: state_machine_modes_1_12_11 state_machine_modes_1_12_11_11h
MCP23017 Class Reference
#include <MCP23017.h>
Public Member Functions | |
| MCP23017 (PinName sda, PinName scl, int i2cAddress) | |
| Constructor for the MCP23017 connected to specified I2C pins at a specific address. | |
| void | reset (void) |
| Reset MCP23017 device to its power-on state. | |
| void | write_bit (int value, int bit_number) |
| Write a 0/1 value to an output bit. | |
| void | write_mask (unsigned short data, unsigned short mask) |
| Write a masked 16-bit value to the device. | |
| int | read_bit (int bit_number) |
| Read a 0/1 value from an input bit. | |
| int | read_mask (unsigned short mask) |
| Read a 16-bit value from the device and apply mask. | |
| void | config (unsigned short dir_config, unsigned short pullup_config, unsigned short polarity_config) |
| Configure an MCP23017 device. | |
Detailed Description
MCP23017 class.
Allow access to an I2C connected MCP23017 16-bit I/O extender chip Example:
MCP23017 *par_port;
Definition at line 54 of file MCP23017.h.
Constructor & Destructor Documentation
| MCP23017 | ( | PinName | sda, |
| PinName | scl, | ||
| int | i2cAddress | ||
| ) |
Constructor for the MCP23017 connected to specified I2C pins at a specific address.
16-bit I/O expander with I2C interface
- Parameters:
-
sda I2C data pin scl I2C clock pin i2cAddress I2C address
Definition at line 30 of file MCP23017.cpp.
Member Function Documentation
| void config | ( | unsigned short | dir_config, |
| unsigned short | pullup_config, | ||
| unsigned short | polarity_config | ||
| ) |
Configure an MCP23017 device.
- Parameters:
-
dir_config data direction value (1 = input, 0 = output) pullup_config 100k pullup value (1 = enabled, 0 = disabled) polarity_config polarity value (1 = flip, 0 = normal)
Definition at line 105 of file MCP23017.cpp.
| int read_bit | ( | int | bit_number ) |
Read a 0/1 value from an input bit.
- Parameters:
-
bit_number bit number range 0 --> 15
- Returns:
- 0/1 value read
Definition at line 88 of file MCP23017.cpp.
| int read_mask | ( | unsigned short | mask ) |
Read a 16-bit value from the device and apply mask.
- Parameters:
-
mask 16-bit mask value
- Returns:
- 16-bit data with mask applied
Definition at line 96 of file MCP23017.cpp.
| void reset | ( | void | ) |
Reset MCP23017 device to its power-on state.
Definition at line 39 of file MCP23017.cpp.
| void write_bit | ( | int | value, |
| int | bit_number | ||
| ) |
Write a 0/1 value to an output bit.
- Parameters:
-
value 0 or 1 bit_number bit number range 0 --> 15
Definition at line 67 of file MCP23017.cpp.
| void write_mask | ( | unsigned short | data, |
| unsigned short | mask | ||
| ) |
Write a masked 16-bit value to the device.
- Parameters:
-
data 16-bit data value mask 16-bit mask value
Definition at line 79 of file MCP23017.cpp.
Generated on Wed Jul 13 2022 06:35:37 by
1.7.2