PU2CLR MCP23008 Arduino Library
1.0.7
Arduino Library for MCP23008 Device - By Ricardo Lima Caratti
|
Functions | |
bool | MCP::isBitValueHigh (uint8_t byteValue, uint8_t bitNumber) |
Checks if the Bit Value of a given bit position is high. More... | |
void | MCP::setClock (long freq) |
Sets I2C bus to a given frequency. More... | |
uint8_t | MCP::lookForDevice () |
Look for MCP23008 device I2C Address. More... | |
void | MCP::reset () |
Resets the MCP23008. More... | |
void | MCP::setup (uint8_t i2c=0x20, uint8_t io=GPIO_OUTPUT, int reset_pint=-1, long i2c_freq=100000) |
Starts the MCP23008. More... | |
|
inline |
Checks if the Bit Value of a given bit position is high.
This funcion is useful to extract a bit value (0 or 1) from a given MCP23008 register
byteValue | byte or register value |
bitNumber | bit offset (number / possition from 0 to 7) |
|
inline |
Sets I2C bus to a given frequency.
100000 = 100KHz; 400000 = 400KHz etc
Plese check the property I2C bus frequency/speed of your board
Referenced by MCP::setup().
uint8_t MCP::lookForDevice | ( | ) |
Look for MCP23008 device I2C Address.
This method will look for a valid MCP23008 device adress between 0x20 and 0x27
void MCP::reset | ( | ) |
Resets the MCP23008.
this method can be used if you want to control the reset of the MCP23008 device. You need to select the Arduino pin via setup method.
You can used the MCP23008 RESET pin connected to the Arduino RESET pin. In this case, you not need to use this function.
References MCP::reset_pin.
Referenced by MCP::setup().
void MCP::setup | ( | uint8_t | i2c = 0x20 , |
uint8_t | io = GPIO_OUTPUT , |
||
int | reset_pin = -1 , |
||
long | i2c_bus_freq = 100000 |
||
) |
Starts the MCP23008.
Starts the MCP23008 and sets the default values.
i2c | I2C address (0x20 ~ 0x27) - default 0x20; ports input / output setup; Arduino reset pin; and I2C clock frequency |
io | If 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. |
reset_pin | if you want to control the reset, select an Arduino pin to do that. |
i2c_bus_freq | set the I2C bus frequency/speed (default 100000 = 100KHz) |
References MCP::reset(), MCP::reset_pin, and MCP::setClock().