iNEMO and MEMS
Posted: Tue Oct 21, 2014 6:34 pm
Hi, anyone have started to work with iNEMO? I'm trying to import ST libs. Anyone else is working on this?
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);
i2c_scanner1();
i2cStop(&I2CD1);
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");
chThdSleepMilliseconds(10);
for(x=1;x<128;x++){
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);
else
chprintf((BaseSequentialStream *)&SDU1, "%d", x);
chThdSleepMilliseconds(10);
}
chThdSleepMilliseconds(500);
chprintf((BaseSequentialStream *)&SDU1,"outside i2c1 scanner\n");
chThdSleepMilliseconds(10);
}
slave device address (7 bits) without R/W bit