> Has anybody ever used two SA1100 GPIO lines to provide I2C bus? Any hints
> or drivers would be greatly appreciated.

Yes; for a 3.3v bus you just need pull-ups and that's about it. You can do
it with just 2 lines, but for safety we use two lines for data - one as an
input, and one which (when high) drives a mosfet to pull the data line low.

It's very easy to modify one of the 2.4 i2c drivers (eg, the parallel port
one) to use GPIOs. Take a look at drivers/i2c/i2c-velleman.c and do a few
twiddles:

static void bit_jupiter_setscl(void *data, int state)
{
    if (state) GPSR=JUPITER_I2CCLOCK;
    else GPCR=JUPITER_I2CCLOCK;
}

static void bit_jupiter_setsda(void *data, int state)
{
    if (state) {
        /* Let it float */
        GPCR=JUPITER_I2CDATAOUT;
    } else {
        /* Pull it low */
        GPSR=JUPITER_I2CDATAOUT;
    }
}

static int bit_jupiter_getscl(void *data)
{
    /* SCL is directly driven as we are master, so transitions are basically
immediate */
    return ( (GPLR&JUPITER_I2CCLOCK)!=0 );
}

static int bit_jupiter_getsda(void *data)
{
    return ( (GPLR&JUPITER_I2CDATAIN)!=0 );
}

If you need a 5v bus, then stick a buffer on the clock output and a 5v
tolerant (eg LVX series) input buffer on the input.

Hugo



_______________________________________________
http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm

Reply via email to