libmcp23016  1.1
Linux userspace driver for Microchip MCP23016 I/O expanders
mcp23016.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2021 Steven Stallion <sstallion@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2.1 of the License, or
8  * (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13  * the GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef MCP23016_H
20 #define MCP23016_H
21 
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
45 };
46 
51 struct mcp23016_device;
52 
62 struct mcp23016_device *mcp23016_open(const char *path, unsigned int num);
63 
71 void mcp23016_close(struct mcp23016_device *dev);
72 
81 int mcp23016_reset(struct mcp23016_device *dev);
82 
94 int mcp23016_get_port(struct mcp23016_device *dev, uint16_t *val);
95 
107 int mcp23016_set_port(struct mcp23016_device *dev, uint16_t val);
108 
120 int mcp23016_get_output(struct mcp23016_device *dev, uint16_t *val);
121 
133 int mcp23016_set_output(struct mcp23016_device *dev, uint16_t val);
134 
146 int mcp23016_get_polarity(struct mcp23016_device *dev, uint16_t *val);
147 
159 int mcp23016_set_polarity(struct mcp23016_device *dev, uint16_t val);
160 
172 int mcp23016_get_direction(struct mcp23016_device *dev, uint16_t *val);
173 
185 int mcp23016_set_direction(struct mcp23016_device *dev, uint16_t val);
186 
198 int mcp23016_get_interrupt(struct mcp23016_device *dev, uint16_t *val);
199 
213 static inline int mcp23016_clear_interrupt(struct mcp23016_device *dev)
214 {
215  uint16_t dummy;
216 
217  return mcp23016_get_interrupt(dev, &dummy);
218 }
219 
231 int mcp23016_get_control(struct mcp23016_device *dev, uint16_t *val);
232 
244 int mcp23016_set_control(struct mcp23016_device *dev, uint16_t val);
245 
263 struct mcp23016_interrupt;
264 
274 struct mcp23016_interrupt *mcp23016_interrupt_open(const char *path, unsigned int offset);
275 
284 
294 
298 #ifdef __cplusplus
299 }
300 #endif
301 
302 #endif /* MCP23016_H */
mcp23016_set_control
int mcp23016_set_control(struct mcp23016_device *dev, uint16_t val)
Set the I/O control value.
mcp23016_interrupt_close
void mcp23016_interrupt_close(struct mcp23016_interrupt *intr)
Close a MCP23016 interrupt handle and free associated memory.
mcp23016_device
Handle to a MCP23016 device.
mcp23016_set_port
int mcp23016_set_port(struct mcp23016_device *dev, uint16_t val)
Set the port value.
mcp23016_interrupt_open
struct mcp23016_interrupt * mcp23016_interrupt_open(const char *path, unsigned int offset)
Open the MCP23016 interrupt specified by path and offset.
mcp23016_set_polarity
int mcp23016_set_polarity(struct mcp23016_device *dev, uint16_t val)
Set the input polarity value.
mcp23016_has_interrupt
int mcp23016_has_interrupt(struct mcp23016_interrupt *intr)
Check interrupt output status.
mcp23016_get_polarity
int mcp23016_get_polarity(struct mcp23016_device *dev, uint16_t *val)
Get the input polarity value.
mcp23016_get_port
int mcp23016_get_port(struct mcp23016_device *dev, uint16_t *val)
Get the port value.
MCP23016_CONTROL_IARES_NORMAL
@ MCP23016_CONTROL_IARES_NORMAL
Definition: mcp23016.h:43
mcp23016_reset
int mcp23016_reset(struct mcp23016_device *dev)
Issue a software reset, which resets registers to POR defaults and clears pending interrupts.
MCP23016_CONTROL_IARES_FAST
@ MCP23016_CONTROL_IARES_FAST
Definition: mcp23016.h:44
mcp23016_get_direction
int mcp23016_get_direction(struct mcp23016_device *dev, uint16_t *val)
Get the I/O direction value.
mcp23016_open
struct mcp23016_device * mcp23016_open(const char *path, unsigned int num)
Open the MCP23016 device specified by path and num.
mcp23016_set_direction
int mcp23016_set_direction(struct mcp23016_device *dev, uint16_t val)
Set the I/O direction value.
mcp23016_get_output
int mcp23016_get_output(struct mcp23016_device *dev, uint16_t *val)
Get the output latch value.
mcp23016_get_interrupt
int mcp23016_get_interrupt(struct mcp23016_device *dev, uint16_t *val)
Get the interrupt capture value.
mcp23016_clear_interrupt
static int mcp23016_clear_interrupt(struct mcp23016_device *dev)
Clear interrupt status.
Definition: mcp23016.h:213
mcp23016_control
mcp23016_control
Enum that describes I/O control values.
Definition: mcp23016.h:42
mcp23016_interrupt
Handle to a MCP23016 interrupt.
mcp23016_set_output
int mcp23016_set_output(struct mcp23016_device *dev, uint16_t val)
Set the output latch value.
mcp23016_close
void mcp23016_close(struct mcp23016_device *dev)
Close a MCP23016 device handle and free associated memory.
mcp23016_get_control
int mcp23016_get_control(struct mcp23016_device *dev, uint16_t *val)
Get the I/O control value.