libmcp23016
1.1
Linux userspace driver for Microchip MCP23016 I/O expanders
|
libmcp23016 provides a simple and straightforward API for accessing Microchip MCP23016 I/O expanders from userspace. It relies on the libgpiod and libi2cd libraries to interface with the Linux kernel.
libmcp23016 development is hosted on GitHub. A code coverage report is also available.
libmcp23016's main data structures and functions are documented in the Main API module. Most uses of the API are straightforward: a MCP23016 device handle is first created by calling mcp23016_open(), which is then passed to supporting functions followed by a call to mcp23016_close() to close the handle and free associated memory. As the MCP23016 lacks a hardware reset, it is advised that a software reset be issued by calling mcp23016_reset() after opening the device handle to ensure the device is in a consistent state. Interrupt output is managed separately to support multiple devices. See the Interrupt Output module for more details.
The following example demonstrates getting the port value from a MCP23016 device at position 0 (I2C slave address 0x20
):
Care should be taken if the device handle is shared between threads as libmcp23016 is not inherently thread-safe. Calls using the same handle should be restricted to a single thread or synchronized using a mutual exclusion mechanism.
libmcp23016 is distributed under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or any later version. See COPYING for more details.