PU2CLR MCP23008 Arduino Library  1.0.1
Arduino Library for MCP23008 Device - By Ricardo Lima Caratti
MCP Class Reference

#include <pu2clr_mcp23008.h>

Public Member Functions

void setup (uint8_t i2c=0x20, uint8_t io=GPIO_OUTPUT)
 Starts the MCP23008. More...
 
void setGPIOS (uint8_t value)
 Sets a value to the GPIO Register. More...
 
uint8_t getRegister (uint8_t reg)
 Gets the corrent register information. More...
 
void setRegister (uint8_t reg, uint8_t value)
 Sets a value to a given register. More...
 
void turnGpioOn (uint8_t gpio)
 Turns a given GPIO port on (high level) More...
 
void turnGpioOff (uint8_t gpio)
 Turns a given GPIO port off (low level) More...
 
void pullUpGpioOn (uint8_t gpio)
 Turns intenal pull up resistor ON to a given GPIO PIN (high level) More...
 
void pullUpGpioOff (uint8_t gpio)
 Turns intenal pull up resistor OFF to a given GPIO PIN (low level) More...
 
uint8_t getGPIOS ()
 Return the current MCP GPIO pin levels. More...
 

Protected Attributes

uint8_t i2cAddress = 0x20
 
uint8_t gpios = 0
 

Member Function Documentation

◆ setup()

void MCP::setup ( uint8_t  i2c = 0x20,
uint8_t  io = GPIO_OUTPUT 
)

Starts the MCP23008.

Parameters
i2cI2C address (0x20 ~ 0x27) - default 0x20
ioIf GPIO_OUTPUT (0), all GPIO PINS will configured to output If GPIO_INPUT (255), all GPIO PINS will configured to input
You also can use a bitmask to configure some pins for input and other pins for output.

◆ setGPIOS()

void MCP::setGPIOS ( uint8_t  value)

Sets a value to the GPIO Register.

Parameters
value(8 bits)

◆ getRegister()

uint8_t MCP::getRegister ( uint8_t  reg)

Gets the corrent register information.

Parameters
reg(0x00 ~ 0xA) see MCP23008 registers documentation
Returns
uint8_t current register value

◆ setRegister()

void MCP::setRegister ( uint8_t  reg,
uint8_t  value 
)

Sets a value to a given register.

Parameters
reg(0x00 ~ 0xA) see MCP23008 registers documentation
valuevalue (8 bits)

◆ turnGpioOn()

void MCP::turnGpioOn ( uint8_t  gpio)

Turns a given GPIO port on (high level)

Parameters
gpiothe GPIO/PIN number (0-7)

◆ turnGpioOff()

void MCP::turnGpioOff ( uint8_t  gpio)

Turns a given GPIO port off (low level)

Parameters
gpiothe GPIO/PIN number (0-7)

◆ pullUpGpioOn()

void MCP::pullUpGpioOn ( uint8_t  gpio)

Turns intenal pull up resistor ON to a given GPIO PIN (high level)

Parameters
gpiothe GPIO/PIN number (0-7)

◆ pullUpGpioOff()

void MCP::pullUpGpioOff ( uint8_t  gpio)

Turns intenal pull up resistor OFF to a given GPIO PIN (low level)

Parameters
gpiothe GPIO/PIN number (0-7)

◆ getGPIOS()

uint8_t MCP::getGPIOS ( )
inline

Return the current MCP GPIO pin levels.

Returns
uint8_t

Field Documentation

◆ i2cAddress

uint8_t MCP::i2cAddress = 0x20
protected

◆ gpios

uint8_t MCP::gpios = 0
protected

The documentation for this class was generated from the following files: