From: VaibhavGhadiok <vai...@gm...> - 2010-10-27 23:34:25
|
Thanks for your response. I want to communicate with an I2C sensor. This is my gumstix main program. //I open i2c-dev0: That works I2cSetSlaveAddress( i2cDev, 0x69, I2C_USE_CRC ); //The address of the sensor is 0x69 as according to the datasheet. We have the last bit pulled high. I2cReadRegisterITG3200(i2cDev, GyroAddress, RegisterAddress, GyroData, GyroDataLength); DatatoWrite[0] = 0x15; //Register Address DatatoWrite[1] = 0x1B; // Data to write to the I2cWriteRegisterITG3200 ( i2cDev, GyroAddress, &DatatoWrite, 2 ); ***************************************These are the functions have written to read and write from/to an I2C Sensor************************* /** * Write a register value on the ITG-3200 */ int I2cWriteRegisterITG3200 ( int i2cDev, ///< Handle to i2c-dev file uint16_t DeviceAddress, //Made this 16 bit since the structure uses a 16 bit value for address uint8_t *wrData, ///< Pointer to data (Register, Data) uint8_t wrLen ///< NUmber of bytes to write ) { struct i2c_rdwr_ioctl_data rdwr; struct i2c_msg msg; LogDebug( "----- I2cSendBytes wrLen = 0x%02x -----\n", wrLen ); msg.addr = DeviceAddress; msg.flags = 0; msg.len = wrLen; msg.buf = (char *)wrData; rdwr.msgs = &msg; rdwr.nmsgs = 1; // tell the driver we want the device at address b1101000 //This works if (ioctl(i2cDev, I2C_SLAVE, DeviceAddress)<0) printf("\nioctlwrite failed\n"); if (write(i2cDev, wrData, 2) < 0) printf("\nioctlwrite2 failed\n"); fflush(stdout); //if ( ioctl( i2cDev, I2C_RDWR, &rdwr ) < 0 ) //{ //LogError( "I2cWriteRegisterITG3200: ioctl failed: %s (%d)\n", strerror( errno ), errno ); //return -1; //} return 0; } //I2cWriteRegisterITG3200 We are unable to write. It just sparks an error: "octlwrite2 failed". As it is unable to write. And Howl error as it is unable to read. I have the pull-ups on the sensor installed. 10K. This seems ok as according to the Philips I2C documentation. My sensor works off 3.3 V so I have a Logic Converter to convert from the Robostix SDA, SCL pinout (which are at 5 V) to the Sensor SDA, SCL. Thanks Dave Hylands wrote: > > Hi, > > On Wed, Oct 27, 2010 at 1:05 PM, VaibhavGhadiok > <vai...@gm...> wrote: >> >> hi everyone >> >> While trying to debug communication issues with an I2C sensor using >> I2cSendBytes and combined read/write as talked about in one of the posts, >> I >> used the same commands on the robostix as well. I tried to verify the >> output >> of my program using the i2c utility provided on the gumstix. Results are >> below. >> >> As one can note I am always returned the address of the register instead >> of >> the value in it. >> >> root@gumstix-custom-verdex:~$ i2c 0x0B rb 0x6F >> 0x6f > > So, I'll assume that you're running the i2c-io program on the robostix? > It wasn't designed to make it look like a normal i2c device. > > It was designed that you write a command, along with some optional > arguments, and then read back the response. This is often called > "block" mode in the smbus documentation. > > Try this: > > i2c --count=18 0x0B rb 0xB0 > > In this case it's writing down 0xB0 (the address) and then reading 18 > bytes. 0xB0 corresponds to the BL_REG_GET_INFO command (from > robostix/Shared/BootLoader.h) and it returns the BootLoaderInfo_t > structure, which I think is 18 bytes. > > i2c-io was the program designed to work with the i2c-io program on the > robostix. The i2c program was designed for working with more > traditional i2c devices which have a very simple interface (more of a > memory-register style layout, where i2c-io is more command/response). > The i2c program doesn't really have any support for the > command/response portion of the protocol (except for commands which > are a single byte). > > -- > Dave Hylands > Shuswap, BC, Canada > http://www.DaveHylands.com/ > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > gumstix-users mailing list > gum...@li... > https://lists.sourceforge.net/lists/listinfo/gumstix-users > > -- View this message in context: http://old.nabble.com/i2c-%27robostix-address%27--rb--%27regadd-%27returns-%27regadd%27-tp30070714p30072246.html Sent from the Gumstix mailing list archive at Nabble.com. |