hardware i2c pins as GPIO

Started by Mayank15, December 19, 2012, 06:47:39 PM

Previous topic - Next topic

Mayank15

I got two iMX233-OlinuXino-Mini boards and both boards have jumpers soldered to hardware i2c which is PIN22/LCD_EN/I2C_SCL and PIN21/LCD_HSYNC/I2C_SDA. The manual says that the default should be to PIN29/SOFT_SCL and PIN28/SOFT_SDA which is inconsistent. Furthermore, is there a way to use these pins as GPIOs? The manual says they are mapped to Linux GPIO 55 and 56.
But if i try a command something like echo out > /sys/class/gpio/gpio55/direction i get No such file or directory error. Hence, is there a way to access these pins where i can set them high or low?

dpwhittaker

The original revision of the board had the software jumpers set, and the current revision switched to hardware.  I guess the manual did not get updated.

GPIO:

echo 55 > /sys/class/gpio/export

then:

echo out > /sys/class/gpio/gpio55/direction

should work.

Mayank15

Thanks for the quick reply

That didn't really work it gave me
-bash: echo: write error: Device or resource busy

I am using the demo code for MOD-LCD3310 located at https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/iMX233/MOD-LCD3310

Hence, i am trying to find a way to use these pins without moving the jumper around. Is there a way i can write to these pins in C to get the Demo code working?

dpwhittaker

It's easy to switch the pins around in that demo code.  Near the top of the file, change:

#define LCD_RES_MAKE_OUT()      gpio_output(0, 23);
#define LCD_RES_HIGH()         GPIO_WRITE(0, 23, 1);
#define LCD_RES_LOW()         GPIO_WRITE(0, 23, 0);

#define LCD_DC_MAKE_OUT()      gpio_output(0, 25);
#define LCD_DC_HIGH()         GPIO_WRITE(0, 25, 1);
#define LCD_DC_LOW()         GPIO_WRITE(0, 25, 0);

to:

#define LCD_RES_MAKE_OUT()      gpio_output(1, 23);
#define LCD_RES_HIGH()         GPIO_WRITE(1, 23, 1);
#define LCD_RES_LOW()         GPIO_WRITE(1, 23, 0);

#define LCD_DC_MAKE_OUT()      gpio_output(1, 24);
#define LCD_DC_HIGH()         GPIO_WRITE(1, 24, 1);
#define LCD_DC_LOW()         GPIO_WRITE(1, 24, 0);

That's bank 1 (which starts at gpio 32), pin 23 and 24 (32 + 23 = 55, and 32 + 24 = 56).

You'll probably also need to put gpio_wr(0x134, 0x3C000); at the top of LCDInit (see 37.4.5 in the datasheet).  This will ensure that those pins are set up as GPIO pins and not I2C pins (they might be set to I2C by the kernel during boot).

Recompile that and it should get the demo working without switching your jumpers around.