You are viewing an older revision! See the latest version
Table of Contents
PAC9675 IO Expander¶
The PCA9675 is an I2C based device with 16 quasi bidirectional IO pins configurable as either input or output. The 16 pins are each capable of sinking 25mA when driving loads and is therefore useful as an LED driver. The IO pins can also be turned into input mode as well as be used to read digital inputs from switches.
It is important when driving this device to ensure that the correct IO configuration is set as a pin configured for output mode could contest with an input signal. The worst case scenario is when a digital input pin is has a logic 1 applied to it and the pin is inadvertantly driven as an output with logic 0 output. In this scenario a high level of current will flow into the device, causing possible damage.
With this suite of software a class has been created for the PCA9675. This object class allows the user to select which I2C peripheral he wants to use with the device and to also to assign a custom I2C slave address. The slave address must be the same as what is configured in hardware for the device, but the C++ class does allow for multiple objects/devices connected to the same I2C bus.
To use the class the user must first create an I2C object on which the PCA9675 will sit
I2C CNTRL_i2c(p9, p10);
In this case the I2C object is called CNTRL_i2c and uses pins p9 and 10 on the mbed module. Secondly the user must then create the object for the PCA9675 specifying which I2C bus he wants to use and the I2C slave address for the device
PCA9675 BaseBoardLatch(&CNTRL_i2c, PCA9675_BASE_BOARD_SLAVE_ADDRESS);
Here the object is called BaseBoardLatch, the I2C bus used in the one we have just created called CNTRL_i2c, and the slave address is referenced via a #define.