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.
MCP23008 Class Reference
#include <MCP23008.h>
Public Member Functions | |
MCP23008 (PinName sda, PinName scl, int i2cAddress) | |
Constructor for the MCP23008 connected to specified I2C pins at a specific address. | |
void | reset (void) |
Reset MCP23008 device to its power-on state. | |
void | config (unsigned char dir_config, unsigned char pullup_config, unsigned char polarity_config) |
Configure an MCP23008 device. | |
void | write_mask (unsigned char data, unsigned char mask) |
Write a masked 16-bit value to the device. | |
int | read_mask (unsigned char mask) |
Read a 8-bit value from the device and apply mask. | |
void | write_bit (int value, int bit_number) |
Write a 0/1 value to an output bit. | |
int | read_bit (int bit_number) |
Read a 0/1 value from an input bit. |
Detailed Description
MCP23008 class.
Allow access to an I2C connected MCP23008 8-bit I/O extender chip Example:
Definition at line 68 of file MCP23008.h.
Constructor & Destructor Documentation
MCP23008 | ( | PinName | sda, |
PinName | scl, | ||
int | i2cAddress | ||
) |
Constructor for the MCP23008 connected to specified I2C pins at a specific address.
8-bit I/O expander with I2C interface
- Parameters:
-
sda I2C data pin scl I2C clock pin i2cAddress I2C address
Definition at line 29 of file MCP23008.cpp.
Member Function Documentation
void config | ( | unsigned char | dir_config, |
unsigned char | pullup_config, | ||
unsigned char | polarity_config | ||
) |
Configure an MCP23008 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 67 of file MCP23008.cpp.
int read_bit | ( | int | bit_number ) |
Read a 0/1 value from an input bit.
- Parameters:
-
bit_number bit number range 0 --> 7
- Returns:
- 0/1 value read
Definition at line 150 of file MCP23008.cpp.
int read_mask | ( | unsigned char | mask ) |
Read a 8-bit value from the device and apply mask.
- Parameters:
-
mask 8-bit mask value
- Returns:
- 8-bit data with mask applied
Definition at line 125 of file MCP23008.cpp.
void reset | ( | void | ) |
Reset MCP23008 device to its power-on state.
Definition at line 39 of file MCP23008.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 --> 7
Definition at line 136 of file MCP23008.cpp.
void write_mask | ( | unsigned char | data, |
unsigned char | mask | ||
) |
Write a masked 16-bit value to the device.
- Parameters:
-
data 8-bit data value mask 8-bit mask value
Definition at line 116 of file MCP23008.cpp.
Generated on Sat Jul 16 2022 03:23:52 by
