terça-feira, 3 de fevereiro de 2015

Instatiating PCA9555 gpio expander in a imx-i2c bus

Obs. 1. You should get the latest PCA953x source file, found here, and compile it as a module (check all dependencies when doing it).

Edit: If needed, check Creating a complete cross-compile Makefile

Step 1) i2cdetect -l
Shows available i2c buses on the processor

Step 2) i2cdetect -y 2
Shows I2C devices' addresses connected to the 2 bus

Let's say address 0x27 is used by an unknown device
Step 3) i2cdump 2 0x27
Show the content of the device's register
If the amount and content of registers are the same as specified in the device's datasheet, the device on the address 0x27 is the one we are looking for.

Step 4) insmod pca953x
Install pca953x module

Step 5) echo pca9555 0x27 > /sys/bus/i2c/devices/i2c-2/new_device
Creates a device called pca9555 (adress 0x27) in i2c-2 bus

Step 6) It is possible to check if the installation went ok by issuing
dmesg | tail - 2

Step 7) A new gpio, called gpiochip240, should appear in /sys/class/gpio. Issue
cd /sys/class/gpio/gpiochip240 to verify

Step 8) The address 255 is refereed as I1.7 (base address is 240). So if you want to control, let's say, I1.0, you should use address 248.
Issue: echo "248" > /sys/class/gpio/export to create a gpio248 in /sys/class/gpio

Step 9) In order to configure as an output, issue echo "out" > /sys/class/gpio/gpio248/direction


Step 10) To control the output level, issue echo "1" > /sys/class/gpio/gpio248/value OR echo "0" > /sys/class/gpio/gpio248/value

References:
1) http://www.fabhub.net/entry.php?2184-PCA9535-and-the-Raspberry-Pi&goto=next
2) ftp://ftp.ts.fujitsu.com/pub/mainboard-oem-sales/Products/Mainboards/Industrial&ExtendedLifetime/D323x-S/IndustrialTools_D323x-S/Linux_SystemMonitoring&Watchdog&GPIO/GPIO_PCA9554a_Linux_X86-X64_HowTo.txt


Nenhum comentário:

Postar um comentário