From: RussellMorin <rm...@wp...> - 2008-10-22 17:00:31
|
Hi Dave, That seems to be working correctly now. :) How do I tell I2C_IO_SetGPIODir whether I want it to set the pin to input or output? From what you told me, output works like this: I2C_IO_SetGPIODir(i2cDev, port, enmask, enmask), but I can't figure out how to change the direction if I want to get input. Thanks again for all your help, -Russ Morin Dave Hylands wrote: > > Hi Russel, > >> I2C_IO_SetGPIODir(i2cDev, port, enmask, 1); // Set the pin to >> output >> I2C_IO_SetGPIO(i2cDev, port, enmask, 1); > > I think that you need to use: > >> I2C_IO_SetGPIODir(i2cDev, port, enmask, enmask); // Set the pin to >> output >> I2C_IO_SetGPIO(i2cDev, port, enmask, enmask); > > And the same thing here. Replace the 1's with the mask. > >> // Set the direction of all the motor pins to output >> I2C_IO_SetGPIODir(i2cDev, port, m11mask, 1); >> I2C_IO_SetGPIODir(i2cDev, port, m12mask, 1); >> I2C_IO_SetGPIODir(i2cDev, port, m21mask, 1); >> I2C_IO_SetGPIODir(i2cDev, port, m22mask, 1); > > You could actually do it all in a single call: > >> I2C_IO_SetGPIODir(i2cDev, port, m11mask | m12mask | m21mask | >> m22mask, m11mask | m12mask | m21mask | m22mask); > >> uint8_t i = 0; >> while (i < 4) >> { >> uint8_t pinVal; >> I2C_IO_GetGPIO(i2cDev, port, &pinVal); >> printf("Pinval = %i\n", pinVal); >> i++; >> } > > And the GetGPIO function returns all 8 pins for a single port, and you > need to mask out the particular pin you're looking for. > > -- > Dave Hylands > Shuswap, BC, Canada > http://www.DaveHylands.com/ > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users > > -- View this message in context: http://www.nabble.com/i2c-I-O-Problem-tp20110061p20115253.html Sent from the Gumstix mailing list archive at Nabble.com. |