Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
mcp230xx.h File Reference
#include "ultibo/gpio.h"
#include "ultibo/i2c.h"

Go to the source code of this file.

Data Structures

struct  _MCP230XXGPIO

Macros

#define MCP23008_GPIO_DESCRIPTION   "Microchip MCP23008 8-bit I/O Expander"
 Description of MCP23008 device.
#define MCP23017_GPIO_DESCRIPTION   "Microchip MCP23016 16-bit I/O Expander"
 Description of MCP23017 device.
#define MCP23008_GPIO_MIN_PIN   GPIO_PIN_0
#define MCP23008_GPIO_MAX_PIN   GPIO_PIN_7
#define MCP23008_GPIO_PIN_COUNT   8
#define MCP23017_GPIO_MIN_PIN   GPIO_PIN_0
#define MCP23017_GPIO_MAX_PIN   GPIO_PIN_15
#define MCP23017_GPIO_PIN_COUNT   16
#define MCP230XX_GPIO_MAX_LEVEL   GPIO_LEVEL_HIGH
#define MCP230XX_GPIO_MAX_PULL   GPIO_PULL_UP
#define MCP230XX_GPIO_MIN_FUNCTION   GPIO_FUNCTION_IN
#define MCP230XX_GPIO_MAX_FUNCTION   GPIO_FUNCTION_OUT
#define MCP230XX_CHIP_MCP23008   0
#define MCP230XX_CHIP_MCP23017   1
#define MCP230XX_I2C_RATE   400000
 Default I2C clock rate (Device supports 100KHz, 400KHz and 1.7MHz.
#define MCP23008_I2C_SIZE   1
 Number of bytes to read/write all pin values for any register.
#define MCP23017_I2C_SIZE   2
 Number of bytes to read/write all pin values for any register.
#define MCP230XX_I2C_MAX_SIZE   2
 Maximum number of bytes to read/write all pin values for any register.
#define MCP23008_I2C_MAX_REG   0x0A
 Maximum register address for the I2C interface.
#define MCP23017_I2C_MAX_REG   0x1A
 Maximum register address for the I2C interface (Only 21 (0x15) registers exists, mappings differ between modes).

Typedefs

typedef struct _MCP230XXGPIO MCP230XXGPIO

Functions

GPIO_DEVICE *STDCALL mcp23008_gpio_create (I2C_DEVICE *i2c, uint16_t address)
 Create, register and start a new MCP23008 GPIO device connected to the specified I2C device.
GPIO_DEVICE *STDCALL mcp23017_gpio_create (I2C_DEVICE *i2c, uint16_t address)
 Create, register and start a new MCP23017 GPIO device connected to the specified I2C device.
uint32_t STDCALL mcp230xx_gpio_destroy (GPIO_DEVICE *gpio)
 Stop, deregister and destroy an MCP230XX GPIO device created by this driver.

Macro Definition Documentation

◆ MCP23008_GPIO_DESCRIPTION

#define MCP23008_GPIO_DESCRIPTION   "Microchip MCP23008 8-bit I/O Expander"

Description of MCP23008 device.

MCP230XX specific constants

◆ MCP23017_GPIO_DESCRIPTION

#define MCP23017_GPIO_DESCRIPTION   "Microchip MCP23016 16-bit I/O Expander"

Description of MCP23017 device.

◆ MCP23008_GPIO_MIN_PIN

#define MCP23008_GPIO_MIN_PIN   GPIO_PIN_0

◆ MCP23008_GPIO_MAX_PIN

#define MCP23008_GPIO_MAX_PIN   GPIO_PIN_7

◆ MCP23008_GPIO_PIN_COUNT

#define MCP23008_GPIO_PIN_COUNT   8

◆ MCP23017_GPIO_MIN_PIN

#define MCP23017_GPIO_MIN_PIN   GPIO_PIN_0

◆ MCP23017_GPIO_MAX_PIN

#define MCP23017_GPIO_MAX_PIN   GPIO_PIN_15

◆ MCP23017_GPIO_PIN_COUNT

#define MCP23017_GPIO_PIN_COUNT   16

◆ MCP230XX_GPIO_MAX_LEVEL

#define MCP230XX_GPIO_MAX_LEVEL   GPIO_LEVEL_HIGH

◆ MCP230XX_GPIO_MAX_PULL

#define MCP230XX_GPIO_MAX_PULL   GPIO_PULL_UP

◆ MCP230XX_GPIO_MIN_FUNCTION

#define MCP230XX_GPIO_MIN_FUNCTION   GPIO_FUNCTION_IN

◆ MCP230XX_GPIO_MAX_FUNCTION

#define MCP230XX_GPIO_MAX_FUNCTION   GPIO_FUNCTION_OUT

◆ MCP230XX_CHIP_MCP23008

#define MCP230XX_CHIP_MCP23008   0

MCP230XX chip constants

◆ MCP230XX_CHIP_MCP23017

#define MCP230XX_CHIP_MCP23017   1

◆ MCP230XX_I2C_RATE

#define MCP230XX_I2C_RATE   400000

Default I2C clock rate (Device supports 100KHz, 400KHz and 1.7MHz.

MCP230XX I2C constants

◆ MCP23008_I2C_SIZE

#define MCP23008_I2C_SIZE   1

Number of bytes to read/write all pin values for any register.

◆ MCP23017_I2C_SIZE

#define MCP23017_I2C_SIZE   2

Number of bytes to read/write all pin values for any register.

◆ MCP230XX_I2C_MAX_SIZE

#define MCP230XX_I2C_MAX_SIZE   2

Maximum number of bytes to read/write all pin values for any register.

◆ MCP23008_I2C_MAX_REG

#define MCP23008_I2C_MAX_REG   0x0A

Maximum register address for the I2C interface.

◆ MCP23017_I2C_MAX_REG

#define MCP23017_I2C_MAX_REG   0x1A

Maximum register address for the I2C interface (Only 21 (0x15) registers exists, mappings differ between modes).

Typedef Documentation

◆ MCP230XXGPIO

typedef struct _MCP230XXGPIO MCP230XXGPIO

MCP230XX specific types

Function Documentation

◆ mcp23008_gpio_create()

GPIO_DEVICE *STDCALL mcp23008_gpio_create ( I2C_DEVICE * i2c,
uint16_t address )

Create, register and start a new MCP23008 GPIO device connected to the specified I2C device.

MCP230XX Functions

Parameters
I2CThe I2C device this MCP23008 is connected to
AddressThe I2C address for this MCP23008
Returns
Pointer to the new GPIO device or nil on failure

◆ mcp23017_gpio_create()

GPIO_DEVICE *STDCALL mcp23017_gpio_create ( I2C_DEVICE * i2c,
uint16_t address )

Create, register and start a new MCP23017 GPIO device connected to the specified I2C device.

Parameters
I2CThe I2C device this MCP23017 is connected to
AddressThe I2C address for this MCP23017
Returns
Pointer to the new GPIO device or nil on failure

◆ mcp230xx_gpio_destroy()

uint32_t STDCALL mcp230xx_gpio_destroy ( GPIO_DEVICE * gpio)

Stop, deregister and destroy an MCP230XX GPIO device created by this driver.

Parameters
GPIOThe GPIO device to destroy
Returns
ERROR_SUCCESS if completed or another error code on failure