Page 1 of 1


Posted: Tue Oct 21, 2014 6:34 pm
by RoccoMarco
Hi, anyone have started to work with iNEMO? I'm trying to import ST libs. Anyone else is working on this?

Re: iNEMO and MEMS

Posted: Sat Jan 17, 2015 7:30 pm
by gabriele
i am trying to include the INEMOEngineLibrary within my application.
In the comments in the include files I read that i am expected to provide an implementation for the Lsm303dlhcAccI2CBufferRead
function (let's take only the accelerometer as an example).

So i was trying to get started with the I2C communication between the ARM processor and the LSM303DLHC sensor.
I implemented a function to scan all the available I2C addresses.

The following code is in the main thread:

Code: Select all


// I2C configuration
I2CConfig i2cconfig;
i2cconfig.op_mode = OPMODE_I2C;
i2cconfig.clock_speed = 400000;
i2cconfig.duty_cycle = FAST_DUTY_CYCLE_2;

i2cStart(&I2CD1, &i2cconfig);



where the i2c_scanner1 function is:

Code: Select all

void i2c_scanner1(void){
   uint8_t x = 0, txbuf[2],rxbuf[2];
   int32_t messages = 0;

   chprintf((BaseSequentialStream *)&SDU1,"inside i2c1 scanner\n");

      txbuf[0] = 0x00;
      txbuf[1] = 0x00;

       messages = i2cMasterTransmit(&I2CD1, x, txbuf, 2, rxbuf, 0);

       if(messages == 0)
         chprintf((BaseSequentialStream *)&SDU1, "I2C1: Sensor is available on Address: %x \r\n", x, messages);
         chprintf((BaseSequentialStream *)&SDU1, "%d", x);
   chprintf((BaseSequentialStream *)&SDU1,"outside i2c1 scanner\n");

None of the 128 addresses replies to the scanning. I always get the RDY_TIMEOUT message from i2cMasterTransmit().
If i provide the i2cMasterTransmit() with some known addresses of the sensors i get the RDY_TIMEOUT as well.

What am i missing? (i am pretty new with embedded programming... :oops:)



Re: iNEMO and MEMS

Posted: Sat Jan 17, 2015 8:15 pm
by RoccoMarco
Hi, I have already created a library that allow you to use ST Engine with ChibiOS, its name is PLAY and is released on sourceforge. Anyway try LSM303DLHC is connected on I2CD2 and L3GD20 on SPID2.

Re: iNEMO and MEMS

Posted: Tue Jan 20, 2015 11:03 am
by gabriele
Hi rocco

Thanks for your quick reply!
I have just downloaded your library! I have tried the demos and everything's ok!
Great piece of work! and thanks for sharing!

By the way, i would like to understand what i am missing in the i2c_scanner1 function.
I executed the scanner i2c_scanner1 function on I2C2 and i got 2 replies, at the addresses 0x19 and 0x1E,
which are not the addresses of the accelerometer and magnetometer (0x33 and 0x3D respectively).

Of course i am missing something in my scanner function, since in your library you communicate with
the sensors through the expected addresses.

In addition, i would like to get barometer data as well. If i am not wrong, it is not included in PLAY. And it
would be a good exercise for me to make the ST libraries for LPS331AP work.
That's why i would like to understand what i am missing.

Thanks for your patience!


Re: iNEMO and MEMS

Posted: Tue Jan 20, 2015 11:49 am
by RoccoMarco
you could read here (i2cMasterReceiveTimeout doku) that addr must be
slave device address (7 bits) without R/W bit

Anyway I will develop pressure sensor, temperature and humidity module ASAP.

Re: iNEMO and MEMS

Posted: Tue Jan 20, 2015 11:59 am
by gabriele

ok... :oops: ! without considering the R/W bit everything is ok!

Thanks, and looking forward for the pressure sensor.


Re: iNEMO and MEMS

Posted: Tue Jan 20, 2015 12:36 pm
by RoccoMarco
Don't worry, at that time I have been trapped on this point for a couple of days. :D
Good work,