Main data structures and functions.
More...
|
| struct mcp23016_device * | mcp23016_open (const char *path, unsigned int num) |
| | Open the MCP23016 device specified by path and num. More...
|
| |
| void | mcp23016_close (struct mcp23016_device *dev) |
| | Close a MCP23016 device handle and free associated memory. More...
|
| |
| int | mcp23016_reset (struct mcp23016_device *dev) |
| | Issue a software reset, which resets registers to POR defaults and clears pending interrupts. More...
|
| |
| int | mcp23016_get_port (struct mcp23016_device *dev, uint16_t *val) |
| | Get the port value. More...
|
| |
| int | mcp23016_set_port (struct mcp23016_device *dev, uint16_t val) |
| | Set the port value. More...
|
| |
| int | mcp23016_get_output (struct mcp23016_device *dev, uint16_t *val) |
| | Get the output latch value. More...
|
| |
| int | mcp23016_set_output (struct mcp23016_device *dev, uint16_t val) |
| | Set the output latch value. More...
|
| |
| int | mcp23016_get_polarity (struct mcp23016_device *dev, uint16_t *val) |
| | Get the input polarity value. More...
|
| |
| int | mcp23016_set_polarity (struct mcp23016_device *dev, uint16_t val) |
| | Set the input polarity value. More...
|
| |
| int | mcp23016_get_direction (struct mcp23016_device *dev, uint16_t *val) |
| | Get the I/O direction value. More...
|
| |
| int | mcp23016_set_direction (struct mcp23016_device *dev, uint16_t val) |
| | Set the I/O direction value. More...
|
| |
| int | mcp23016_get_interrupt (struct mcp23016_device *dev, uint16_t *val) |
| | Get the interrupt capture value. More...
|
| |
| static int | mcp23016_clear_interrupt (struct mcp23016_device *dev) |
| | Clear interrupt status. More...
|
| |
| int | mcp23016_get_control (struct mcp23016_device *dev, uint16_t *val) |
| | Get the I/O control value. More...
|
| |
| int | mcp23016_set_control (struct mcp23016_device *dev, uint16_t val) |
| | Set the I/O control value. More...
|
| |
Main data structures and functions.
#include <mcp23016.h>
◆ mcp23016_control
Enum that describes I/O control values.
| Enumerator |
|---|
| MCP23016_CONTROL_IARES_NORMAL | Normal interrupt activity resolution (32ms).
|
| MCP23016_CONTROL_IARES_FAST | Fast interrupt activity resolution (200us).
|
◆ mcp23016_clear_interrupt()
Clear interrupt status.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function is equivalent to calling:
◆ mcp23016_close()
Close a MCP23016 device handle and free associated memory.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
Once closed, dev is no longer valid for use.
◆ mcp23016_get_control()
Get the I/O control value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | Pointer to the value to receive. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function returns the value of the IOCON0 and IOCON1 registers in the low and high bytes, respectively.
◆ mcp23016_get_direction()
| int mcp23016_get_direction |
( |
struct mcp23016_device * |
dev, |
|
|
uint16_t * |
val |
|
) |
| |
Get the I/O direction value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | Pointer to the value to receive. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function returns the value of the IODIR0 and IODIR1 registers in the low and high bytes, respectively.
◆ mcp23016_get_interrupt()
| int mcp23016_get_interrupt |
( |
struct mcp23016_device * |
dev, |
|
|
uint16_t * |
val |
|
) |
| |
Get the interrupt capture value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | Pointer to the value to receive. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function returns the value of the INTCAP0 and INTCAP1 registers in the low and high bytes, respectively.
◆ mcp23016_get_output()
Get the output latch value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | Pointer to the value to receive. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function returns the value of the OLAT0 and OLAT1 registers in the low and high bytes, respectively.
◆ mcp23016_get_polarity()
Get the input polarity value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | Pointer to the value to receive. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function returns the value of the IPOL0 and IPOL1 registers in the low and high bytes, respectively.
◆ mcp23016_get_port()
Get the port value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | Pointer to the value to receive. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function returns the value of the GP0 and GP1 registers in the low and high bytes, respectively.
◆ mcp23016_open()
| struct mcp23016_device* mcp23016_open |
( |
const char * |
path, |
|
|
unsigned int |
num |
|
) |
| |
Open the MCP23016 device specified by path and num.
- Parameters
-
| path | Pointer to an I2C character device. |
| num | Relative position of device on I2C bus (ie. AD0-2). |
- Returns
- Pointer to a MCP23016 device handle, or
NULL on error with errno set appropriately.
◆ mcp23016_reset()
Issue a software reset, which resets registers to POR defaults and clears pending interrupts.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
◆ mcp23016_set_control()
Set the I/O control value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | The value to set. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function writes the value of the IOCON0 and IOCON1 registers in the low and high bytes, respectively.
◆ mcp23016_set_direction()
Set the I/O direction value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | The value to set. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function writes the value of the IODIR0 and IODIR1 registers in the low and high bytes, respectively.
◆ mcp23016_set_output()
Set the output latch value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | The value to set. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function writes the value of the OLAT0 and OLAT1 registers in the low and high bytes, respectively.
◆ mcp23016_set_polarity()
Set the input polarity value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | The value to set. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function writes the value of the IPOL0 and IPOL1 registers in the low and high bytes, respectively.
◆ mcp23016_set_port()
Set the port value.
- Parameters
-
| dev | Pointer to a MCP23016 device handle. |
| val | The value to set. |
- Returns
- 0 on success, or -1 on error with
errno set appropriately.
This function writes the value of the GP0 and GP1 registers in the low and high bytes, respectively.
int mcp23016_get_interrupt(struct mcp23016_device *dev, uint16_t *val)
Get the interrupt capture value.